3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-13 14:40:07 +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.
*/
private DoubleArrayList<BlockVector,BaseBlock> original =
new DoubleArrayList<BlockVector,BaseBlock>();
new DoubleArrayList<BlockVector,BaseBlock>(true);
/**
* Stores the current blocks.
*/
private DoubleArrayList<BlockVector,BaseBlock> current =
new DoubleArrayList<BlockVector,BaseBlock>();
new DoubleArrayList<BlockVector,BaseBlock>(false);
/**
* Blocks that should be placed before last.
*/
private DoubleArrayList<BlockVector,BaseBlock> queueAfter =
new DoubleArrayList<BlockVector,BaseBlock>();
new DoubleArrayList<BlockVector,BaseBlock>(false);
/**
* Blocks that should be placed last.
*/
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
* 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.
*/
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.
@ -74,9 +87,43 @@ public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> {
* @return
*/
public Iterator<Map.Entry<A,B>> iterator() {
return new EntryIterator<Map.Entry<A,B>>(
listA.listIterator(listA.size()),
listB.listIterator(listB.size()));
if (isReversed) {
return new ReverseEntryIterator<Map.Entry<A,B>>(
listA.listIterator(listA.size()),
listB.listIterator(listB.size()));
} else {
return new ForwardEntryIterator<Map.Entry<A,B>>(
listA.iterator(),
listB.iterator());
}
}
/**
* Entry iterator.
*
* @param <A>
* @param <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();
}
}
/**
@ -85,11 +132,11 @@ public class DoubleArrayList<A,B> implements Iterable<Map.Entry<A,B>> {
* @param <A>
* @param <B>
*/
public class EntryIterator<T extends Map.Entry> implements Iterator<Map.Entry<A,B>> {
public class ReverseEntryIterator<T extends Map.Entry> implements Iterator<Map.Entry<A,B>> {
private ListIterator<A> keyIterator;
private ListIterator<B> valueIterator;
public EntryIterator(ListIterator<A> keyIterator, ListIterator<B> valueIterator) {
public ReverseEntryIterator(ListIterator<A> keyIterator, ListIterator<B> valueIterator) {
this.keyIterator = keyIterator;
this.valueIterator = valueIterator;
}