3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-07 20:10:06 +01:00

Fixed the history/queue array lists being iterated in the wrong direction.

Dieser Commit ist enthalten in:
sk89q 2010-12-02 09:42:17 -08:00
Ursprung c710e38944
Commit 2e77753204
2 geänderte Dateien mit 56 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -49,22 +49,22 @@ public class EditSession {
* Stores the original blocks before modification. * Stores the original blocks before modification.
*/ */
private DoubleArrayList<BlockVector,BaseBlock> original = private DoubleArrayList<BlockVector,BaseBlock> original =
new DoubleArrayList<BlockVector,BaseBlock>(); new DoubleArrayList<BlockVector,BaseBlock>(true);
/** /**
* Stores the current blocks. * Stores the current blocks.
*/ */
private DoubleArrayList<BlockVector,BaseBlock> current = private DoubleArrayList<BlockVector,BaseBlock> current =
new DoubleArrayList<BlockVector,BaseBlock>(); new DoubleArrayList<BlockVector,BaseBlock>(false);
/** /**
* Blocks that should be placed before last. * Blocks that should be placed before last.
*/ */
private DoubleArrayList<BlockVector,BaseBlock> queueAfter = private DoubleArrayList<BlockVector,BaseBlock> queueAfter =
new DoubleArrayList<BlockVector,BaseBlock>(); new DoubleArrayList<BlockVector,BaseBlock>(false);
/** /**
* Blocks that should be placed last. * Blocks that should be placed last.
*/ */
private DoubleArrayList<BlockVector,BaseBlock> queueLast = private DoubleArrayList<BlockVector,BaseBlock> queueLast =
new DoubleArrayList<BlockVector,BaseBlock>(); new DoubleArrayList<BlockVector,BaseBlock>(false);
/** /**
* The maximum number of blocks to change at a time. If this number is * The maximum number of blocks to change at a time. If this number is
* exceeded, a MaxChangedBlocksException exception will be * exceeded, a MaxChangedBlocksException exception will be

Datei anzeigen

@ -40,6 +40,19 @@ public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> {
* Second list. * Second list.
*/ */
private List<B> listB = new ArrayList<B>(); private List<B> listB = new ArrayList<B>();
/**
* Is reversed when iterating.
*/
private boolean isReversed = false;
/**
* Construct the object.
*
* @param isReversed
*/
public DoubleArrayList(boolean isReversed) {
this.isReversed = isReversed;
}
/** /**
* Add an item. * Add an item.
@ -74,9 +87,15 @@ public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> {
* @return * @return
*/ */
public Iterator<Map.Entry<A,B>> iterator() { public Iterator<Map.Entry<A,B>> iterator() {
return new EntryIterator<Map.Entry<A,B>>( if (isReversed) {
listA.listIterator(listA.size()), return new ReverseEntryIterator<Map.Entry<A,B>>(
listB.listIterator(listB.size())); listA.listIterator(listA.size()),
listB.listIterator(listB.size()));
} else {
return new ForwardEntryIterator<Map.Entry<A,B>>(
listA.iterator(),
listB.iterator());
}
} }
/** /**
@ -85,11 +104,39 @@ public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> {
* @param <A> * @param <A>
* @param <B> * @param <B>
*/ */
public class EntryIterator<T extends Map.Entry> implements Iterator<Map.Entry<A,B>> { public class ForwardEntryIterator<T extends Map.Entry> implements Iterator<Map.Entry<A,B>> {
private Iterator<A> keyIterator;
private Iterator<B> valueIterator;
public ForwardEntryIterator(Iterator<A> keyIterator, Iterator<B> valueIterator) {
this.keyIterator = keyIterator;
this.valueIterator = valueIterator;
}
public boolean hasNext() {
return keyIterator.hasNext();
}
public Map.Entry<A,B> next() throws NoSuchElementException {
return new Entry<A,B>(keyIterator.next(), valueIterator.next());
}
public void remove() {
throw new UnsupportedOperationException();
}
}
/**
* Entry iterator.
*
* @param <A>
* @param <B>
*/
public class ReverseEntryIterator<T extends Map.Entry> implements Iterator<Map.Entry<A,B>> {
private ListIterator<A> keyIterator; private ListIterator<A> keyIterator;
private ListIterator<B> valueIterator; private ListIterator<B> valueIterator;
public EntryIterator(ListIterator<A> keyIterator, ListIterator<B> valueIterator) { public ReverseEntryIterator(ListIterator<A> keyIterator, ListIterator<B> valueIterator) {
this.keyIterator = keyIterator; this.keyIterator = keyIterator;
this.valueIterator = valueIterator; this.valueIterator = valueIterator;
} }