- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- org.pcollections.AbstractUnmodifiableSet<E>
-
- org.pcollections.OrderedPSet<E>
-
- Type Parameters:
E
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.Set<E>
,PCollection<E>
,PSet<E>
public class OrderedPSet<E> extends AbstractUnmodifiableSet<E> implements PSet<E>, java.io.Serializable
LikePSet
but preserves insertion order. Persistent equivalent ofLinkedHashSet
.(Note: this is different from
PSortedSet
, which keeps elements in the order specified byComparable.compareTo(Object)
orComparator.compare(Object, Object)
.)- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private PSortedMap<java.lang.Long,E>
elements
private static OrderedPSet<java.lang.Object>
EMPTY
private PMap<E,java.lang.Long>
ids
private static long
serialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description private
OrderedPSet(PMap<E,java.lang.Long> ids, PSortedMap<java.lang.Long,E> elements)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <E> OrderedPSet<E>
empty()
static <E> OrderedPSet<E>
from(java.util.Collection<? extends E> list)
OrderedPSet<E>
intersect(java.util.Collection<? extends E> list)
java.util.Iterator<E>
iterator()
OrderedPSet<E>
minus(java.lang.Object e)
OrderedPSet<E>
minusAll(java.util.Collection<?> list)
OrderedPSet<E>
plus(E e)
OrderedPSet<E>
plusAll(java.util.Collection<? extends E> list)
static <E> OrderedPSet<E>
singleton(E e)
int
size()
-
Methods inherited from class org.pcollections.AbstractUnmodifiableSet
add, addAll, clear, remove, removeAll, removeIf, retainAll
-
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
EMPTY
private static final OrderedPSet<java.lang.Object> EMPTY
-
elements
private final PSortedMap<java.lang.Long,E> elements
-
-
Constructor Detail
-
OrderedPSet
private OrderedPSet(PMap<E,java.lang.Long> ids, PSortedMap<java.lang.Long,E> elements)
-
-
Method Detail
-
empty
public static <E> OrderedPSet<E> empty()
-
from
public static <E> OrderedPSet<E> from(java.util.Collection<? extends E> list)
-
singleton
public static <E> OrderedPSet<E> singleton(E e)
-
plus
public OrderedPSet<E> plus(E e)
-
plusAll
public OrderedPSet<E> plusAll(java.util.Collection<? extends E> list)
-
minus
public OrderedPSet<E> minus(java.lang.Object e)
-
minusAll
public OrderedPSet<E> minusAll(java.util.Collection<?> list)
-
intersect
public OrderedPSet<E> intersect(java.util.Collection<? extends E> list)
-
iterator
public java.util.Iterator<E> iterator()
-
-