Package eu.bandm.tools.ramus.runtime2
Class ReverseList<A>
java.lang.Object
java.util.AbstractCollection<A>
java.util.AbstractList<A>
eu.bandm.tools.ramus.runtime2.ReverseList<A>
- Type Parameters:
- A- The type of list elements
- All Implemented Interfaces:
- Iterable<A>,- Collection<A>,- List<A>,- SequencedCollection<A>
Generic, immutable, reverse single-linked lists.
 
Instances of this class are called reverse lists in the documentation. This does not refer to the order of their elements, but rather to the fact that they are held together by chains of references from back to front.
Reverse lists are optimized for incremental front-to-back
 construction; the append(A) operation is fast.  By contrast,
 both random access to individual elements (get(int)) and
 traversal of all elements (AbstractList.iterator()) are relatively slow.
 Making a copy to a read-optimized data structure (snapshot()) is recommended.
- 
Field SummaryFields inherited from class java.util.AbstractListmodCount
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionReturns an extension of this list by a given element.static <A> ReverseList<A> build(A... elems) Returns a reverse list copy of the given array.static <A> ReverseList<A> Returns a reverse list copy of the given list.static <A> ReverseList<A> cast(@Opt ReverseList<? extends A> list) static <A> ReverseList<A> empty()get(int i) getFront()Returns the sublist wothout the last element, if any.getLast()Returns the last element.booleanisEmpty()intsize()snapshot()Returns a copy of this reverse list.static <A> List<A> snapshot(ReverseList<A> rev) Deprecated.Methods inherited from class java.util.AbstractListadd, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods inherited from class java.util.AbstractCollectionaddAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.CollectionparallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.ListaddAll, addFirst, addLast, contains, containsAll, getFirst, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, toArray, toArray
- 
Constructor Details- 
ReverseList
 
- 
- 
Method Details- 
empty
- 
cast
- 
get
- 
sizepublic int size()- Specified by:
- sizein interface- Collection<A>
- Specified by:
- sizein interface- List<A>
- Specified by:
- sizein class- AbstractCollection<A>
 
- 
isEmptypublic boolean isEmpty()- Specified by:
- isEmptyin interface- Collection<A>
- Specified by:
- isEmptyin interface- List<A>
- Overrides:
- isEmptyin class- AbstractCollection<A>
 
- 
getFrontReturns the sublist wothout the last element, if any.
- 
getLastReturns the last element.- Throws:
- NoSuchElementException- if this list is empty.
 
- 
buildReturns a reverse list copy of the given list.- See Also:
 
- 
buildReturns a reverse list copy of the given array.- See Also:
 
- 
appendReturns an extension of this list by a given element.
- 
snapshotReturns a copy of this reverse list.The returned list is not guaranteed to be either modifiable or unmodifiable. Element access can be expected to be more efficient on the copy than on this reverse list. - See Also:
 
- 
snapshotDeprecated.use the instance methodsnapshot()instead.Returns a copy of this reverse list.
 
- 
snapshot()instead.