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
List
are 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 void
add(int pIndex, T pElement)
Deprecated.Unsupported operation.boolean
add(T pE)
Deprecated.Unsupported operation.boolean
addAll(int pIndex, Collection<? extends T> pC)
Deprecated.Unsupported operation.boolean
addAll(Collection<? extends T> pC)
Deprecated.Unsupported operation.void
clear()
Deprecated.Unsupported operation.PersistentList<T>
empty()
Replacement for {clear()
that returns an empty instance.T
remove(int pIndex)
Deprecated.Unsupported operation.boolean
remove(Object pO)
Deprecated.Unsupported operation.boolean
removeAll(Collection<?> pC)
Deprecated.Unsupported operation.void
replaceAll(UnaryOperator<T> pOperator)
Deprecated.Unsupported operation.boolean
retainAll(Collection<?> pC)
Deprecated.Unsupported operation.PersistentList<T>
reversed()
Returns a new list with the elements in the reverse order.T
set(int pIndex, T pElement)
Deprecated.Unsupported operation.void
sort(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:
add
in interfaceCollection<T>
- Specified by:
add
in interfaceList<T>
- Throws:
UnsupportedOperationException
- Always.
-
add
@Deprecated void add(int pIndex, T pElement)
Deprecated.Unsupported operation.- Specified by:
add
in interfaceList<T>
- Throws:
UnsupportedOperationException
- Always.
-
addAll
@Deprecated boolean addAll(Collection<? extends T> pC)
Deprecated.Unsupported operation.- Specified by:
addAll
in interfaceCollection<T>
- Specified by:
addAll
in interfaceList<T>
- Throws:
UnsupportedOperationException
- Always.
-
addAll
@Deprecated boolean addAll(int pIndex, Collection<? extends T> pC)
Deprecated.Unsupported operation.- Specified by:
addAll
in interfaceList<T>
- Throws:
UnsupportedOperationException
- Always.
-
clear
@Deprecated void clear()
Deprecated.Unsupported operation.- Specified by:
clear
in interfaceCollection<T>
- Specified by:
clear
in interfaceList<T>
- Throws:
UnsupportedOperationException
- Always.
-
remove
@Deprecated T remove(int pIndex)
Deprecated.Unsupported operation.- Specified by:
remove
in interfaceList<T>
- Throws:
UnsupportedOperationException
- Always.
-
remove
@Deprecated boolean remove(Object pO)
Deprecated.Unsupported operation.- Specified by:
remove
in interfaceCollection<T>
- Specified by:
remove
in interfaceList<T>
- Throws:
UnsupportedOperationException
- Always.
-
removeAll
@Deprecated boolean removeAll(Collection<?> pC)
Deprecated.Unsupported operation.- Specified by:
removeAll
in interfaceCollection<T>
- Specified by:
removeAll
in interfaceList<T>
- Throws:
UnsupportedOperationException
- Always.
-
replaceAll
@Deprecated void replaceAll(UnaryOperator<T> pOperator)
Deprecated.Unsupported operation.- Specified by:
replaceAll
in interfaceList<T>
- Throws:
UnsupportedOperationException
- Always.
-
retainAll
@Deprecated boolean retainAll(Collection<?> pC)
Deprecated.Unsupported operation.- Specified by:
retainAll
in interfaceCollection<T>
- Specified by:
retainAll
in interfaceList<T>
- Throws:
UnsupportedOperationException
- Always.
-
set
@Deprecated T set(int pIndex, T pElement)
Deprecated.Unsupported operation.- Specified by:
set
in interfaceList<T>
- Throws:
UnsupportedOperationException
- Always.
-
sort
@Deprecated void sort(Comparator<? super T> pC)
Deprecated.Unsupported operation.- Specified by:
sort
in interfaceList<T>
- Throws:
UnsupportedOperationException
- Always.
-
-