Fixed Enums
This commit is contained in:
parent
502f22cea3
commit
58e20bb513
@ -519,7 +519,7 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
||||
|
||||
@Override
|
||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> reverseIterator() {
|
||||
return new ReverseBiIterator<>(new EntryIterator(false));
|
||||
return new EntryIterator(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -661,7 +661,7 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
||||
|
||||
@Override
|
||||
public LIST_ITERATOR KEY_GENERIC_TYPE reverseIterator() {
|
||||
return new ReverseBiIteratorBRACES(new KeyIterator(false));
|
||||
return new KeyIterator(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -746,7 +746,7 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
||||
@Override
|
||||
public VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE reversed() { return new VALUE_ABSTRACT_COLLECTION.VALUE_REVERSED_ORDERED_COLLECTIONVALUE_BRACES(this, this::reverseIterator); }
|
||||
private VALUE_ITERATOR VALUE_GENERIC_TYPE reverseIterator() {
|
||||
return new VALUE_ABSTRACT_COLLECTION.ReverseBiIteratorVALUE_BRACES(new ValueIterator(false));
|
||||
return new ValueIterator(false);
|
||||
}
|
||||
@Override
|
||||
public void addFirst(VALUE_TYPE e) { throw new UnsupportedOperationException(); }
|
||||
@ -892,17 +892,20 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
||||
}
|
||||
|
||||
private class MapIterator {
|
||||
boolean forward;
|
||||
int previous = -1;
|
||||
int next = -1;
|
||||
int current = -1;
|
||||
int index = 0;
|
||||
|
||||
MapIterator(boolean start) {
|
||||
this.forward = start;
|
||||
if(start) next = firstIndex;
|
||||
else previous = lastIndex;
|
||||
}
|
||||
|
||||
MapIterator(T from) {
|
||||
this.forward = true;
|
||||
previous = from.ordinal() - 1;
|
||||
index = from.ordinal();
|
||||
next = from.ordinal();
|
||||
@ -910,11 +913,11 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
||||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
return next != -1;
|
||||
return (forward ? next : previous) != -1;
|
||||
}
|
||||
|
||||
public boolean hasPrevious() {
|
||||
return previous != -1;
|
||||
return (forward ? previous : next) != -1;
|
||||
}
|
||||
|
||||
public int nextIndex() {
|
||||
@ -949,20 +952,30 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
||||
|
||||
public int previousEntry() {
|
||||
if(!hasPrevious()) throw new NoSuchElementException();
|
||||
current = previous;
|
||||
previous = (int)(links[current] >> 32);
|
||||
next = current;
|
||||
if(forward) moveBackwards();
|
||||
else moveForwards();
|
||||
if(index >= 0) index--;
|
||||
return current;
|
||||
}
|
||||
|
||||
public int nextEntry() {
|
||||
if(!hasNext()) throw new NoSuchElementException();
|
||||
if(forward) moveForwards();
|
||||
else moveBackwards();
|
||||
if(index >= 0) index++;
|
||||
return current;
|
||||
}
|
||||
|
||||
private void moveBackwards() {
|
||||
current = previous;
|
||||
previous = (int)(links[current] >> 32);
|
||||
next = current;
|
||||
}
|
||||
|
||||
private void moveForwards() {
|
||||
current = next;
|
||||
next = (int)(links[current]);
|
||||
previous = current;
|
||||
if(index >= 0) index++;
|
||||
return current;
|
||||
}
|
||||
|
||||
private void ensureIndexKnown() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user