O - is OrderableByRef by Number type.public class OrderByRefList<O extends OrderableByRef<Number>> extends ArrayList<O>
OrderableByRef types are added then they are automatically ordered in the correct order on Add
If A->B means B is #getNextRef() of A, and B<-A means B is #getPreviousRef() of A.
Example:
.. lets assume a the following operations:
Mirror 1
A
B
C -> D
D -> A
... will result in sequence B, C, D, A
D <- A
B
C
C <- D
... will result in sequence C, D, A, B setReverseNext(boolean) is true, then Mirror2 can be made Mirror1 even though 2 uses "Next" convention as opposed to "Previous".
This class does not handle cycles and will throw an IllegalArgumentException if any cycle scenario arises. Following are some cycle scenarios:
setReverseNext(boolean),
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected Set<Number> |
linkedRevNextIds |
protected Map<Number,List<Number>> |
reverseNextToCurrentMap |
modCount| Constructor and Description |
|---|
OrderByRefList(Collection<O> c)
Add nodes from the Collection c, in the order of
OrderableByRef.getNextRef() or OrderableByRef.getPreviousRef().If no reference data exists then rely on natural order of the given collection. |
OrderByRefList(Collection<O> c,
boolean reverseNext)
Add nodes from the Collection c, in the order of
OrderableByRef.getNextRef() or OrderableByRef.getPreviousRef().If no reference data exists then rely on natural order of the given collection. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
detectCycle(Collection<O> c)
Throw a
RuntimeException type if any cycle detected. |
protected List<Number> |
getPrevious(O node) |
protected List |
getSequence(O node) |
boolean |
isReverseNext()
If true will observe all {next & current as
--> current & previous} |
void |
setReverseNext(boolean reverseNext)
If true will observe all {next & current as
--> current & previous} |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeequals, hashCodecontainsAll, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitcontainsAll, equals, hashCodeparallelStream, streampublic OrderByRefList(Collection<O> c)
OrderableByRef.getNextRef() or OrderableByRef.getPreviousRef().c - as Collectionpublic OrderByRefList(Collection<O> c, boolean reverseNext)
OrderableByRef.getNextRef() or OrderableByRef.getPreviousRef().c - as CollectionreverseNext - as boolean. See setReverseNext(boolean)protected List<Number> getPrevious(O node)
node - as OrderableByRef; for which immediate previous nodes to be retrievedreverseNext is true. Nullableprotected void detectCycle(Collection<O> c)
RuntimeException type if any cycle detected.public boolean isReverseNext()
--> current & previous}public void setReverseNext(boolean reverseNext)
--> current & previous}Copyright © 2018. All rights reserved.