Package org.sosy_lab.common.collect
Interface PersistentList<T>
-
- Type Parameters:
T- The type of values.
- All Superinterfaces:
Collection<T>,Iterable<T>,List<T>
- All Known Implementing Classes:
PersistentLinkedList
@Immutable(containerOf="T") public interface PersistentList<T> extends List<T>
Interface for persistent lists. A persistent data structure is immutable, but provides cheap copy-and-write operations. Thus all write operations ({with(Object), {without(Object)}) will not modify the current instance, but return a new instance instead.All modifying operations inherited from
Listare not supported and will always throwUnsupportedOperationException.Instances of this interface are thread-safe as long as published safely.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidadd(int pIndex, T pElement)Deprecated.Unsupported operation.booleanadd(T pE)Deprecated.Unsupported operation.booleanaddAll(int pIndex, Collection<? extends T> pC)Deprecated.Unsupported operation.booleanaddAll(Collection<? extends T> pC)Deprecated.Unsupported operation.voidclear()Deprecated.Unsupported operation.PersistentList<T>empty()Replacement for {clear()that returns an empty instance.Tremove(int pIndex)Deprecated.Unsupported operation.booleanremove(Object pO)Deprecated.Unsupported operation.booleanremoveAll(Collection<?> pC)Deprecated.Unsupported operation.voidreplaceAll(UnaryOperator<T> pOperator)Deprecated.Unsupported operation.booleanretainAll(Collection<?> pC)Deprecated.Unsupported operation.PersistentList<T>reversed()Returns a new list with the elements in the reverse order.Tset(int pIndex, T pElement)Deprecated.Unsupported operation.voidsort(Comparator<? super T> pC)Deprecated.Unsupported operation.PersistentList<T>with(T value)Replacement foradd(Object)that returns a fresh new instance.PersistentList<T>withAll(List<T> values)Replacement foraddAll(Collection)that returns a fresh new instance.PersistentList<T>without(T value)Replacement forremove(Object)that returns a fresh new instance.-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, size, spliterator, subList, toArray, toArray
-
-
-
-
Method Detail
-
with
@CheckReturnValue PersistentList<T> with(T value)
Replacement foradd(Object)that returns a fresh new instance. The position of insertion is not specified.
-
withAll
@CheckReturnValue PersistentList<T> withAll(List<T> values)
Replacement foraddAll(Collection)that returns a fresh new instance. The position of insertion is not specified.
-
without
@CheckReturnValue PersistentList<T> without(T value)
Replacement forremove(Object)that returns a fresh new instance. If the value occurs several times, only the first occurrence is removed.
-
empty
@CheckReturnValue PersistentList<T> empty()
Replacement for {clear()that returns an empty instance.
-
reversed
@CheckReturnValue PersistentList<T> reversed()
Returns a new list with the elements in the reverse order.
-
add
@Deprecated boolean add(T pE)
Deprecated.Unsupported operation.- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceList<T>- Throws:
UnsupportedOperationException- Always.
-
add
@Deprecated void add(int pIndex, T pElement)
Deprecated.Unsupported operation.- Specified by:
addin interfaceList<T>- Throws:
UnsupportedOperationException- Always.
-
addAll
@Deprecated boolean addAll(Collection<? extends T> pC)
Deprecated.Unsupported operation.- Specified by:
addAllin interfaceCollection<T>- Specified by:
addAllin interfaceList<T>- Throws:
UnsupportedOperationException- Always.
-
addAll
@Deprecated boolean addAll(int pIndex, Collection<? extends T> pC)
Deprecated.Unsupported operation.- Specified by:
addAllin interfaceList<T>- Throws:
UnsupportedOperationException- Always.
-
clear
@Deprecated void clear()
Deprecated.Unsupported operation.- Specified by:
clearin interfaceCollection<T>- Specified by:
clearin interfaceList<T>- Throws:
UnsupportedOperationException- Always.
-
remove
@Deprecated T remove(int pIndex)
Deprecated.Unsupported operation.- Specified by:
removein interfaceList<T>- Throws:
UnsupportedOperationException- Always.
-
remove
@Deprecated boolean remove(Object pO)
Deprecated.Unsupported operation.- Specified by:
removein interfaceCollection<T>- Specified by:
removein interfaceList<T>- Throws:
UnsupportedOperationException- Always.
-
removeAll
@Deprecated boolean removeAll(Collection<?> pC)
Deprecated.Unsupported operation.- Specified by:
removeAllin interfaceCollection<T>- Specified by:
removeAllin interfaceList<T>- Throws:
UnsupportedOperationException- Always.
-
replaceAll
@Deprecated void replaceAll(UnaryOperator<T> pOperator)
Deprecated.Unsupported operation.- Specified by:
replaceAllin interfaceList<T>- Throws:
UnsupportedOperationException- Always.
-
retainAll
@Deprecated boolean retainAll(Collection<?> pC)
Deprecated.Unsupported operation.- Specified by:
retainAllin interfaceCollection<T>- Specified by:
retainAllin interfaceList<T>- Throws:
UnsupportedOperationException- Always.
-
set
@Deprecated T set(int pIndex, T pElement)
Deprecated.Unsupported operation.- Specified by:
setin interfaceList<T>- Throws:
UnsupportedOperationException- Always.
-
sort
@Deprecated void sort(Comparator<? super T> pC)
Deprecated.Unsupported operation.- Specified by:
sortin interfaceList<T>- Throws:
UnsupportedOperationException- Always.
-
-