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