Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-09-06 16:12:51 +02:00
Fixed the history/queue array lists being iterated in the wrong direction.
Dieser Commit ist enthalten in:
Ursprung
c710e38944
Commit
2e77753204
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren