Top Description Fields Constructors Methods
org.pcollections

public Class OrderedPSet<E>

extends AbstractUnmodifiableSet<E>
implements PSet<E>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.pcollections.PSet, java.util.Set, java.util.Collection, java.lang.Iterable, org.pcollections.PCollection
Static Imports
java.util.Objects.requireNonNull

Like PSet but preserves insertion order. Persistent equivalent of LinkedHashSet.

(Note: this is different from PSortedSet, which keeps elements in the order specified by java.lang.Comparable#compareTo(Object) or java.util.Comparator#compare(Object, Object).)

Field Summary

Modifier and TypeField and Description
private final PSortedMap<Long, E>
private static final OrderedPSet<Object>
private final PMap<E, Long>
private static final long

Constructor Summary

AccessConstructor and Description
private
OrderedPSet(final PMap<E, Long> ids, final PSortedMap<Long, E> elements)

Method Summary

Modifier and TypeMethod and Description
public static <E> OrderedPSet<E>
public static <E> OrderedPSet<E>
from(final Collection<? extends E> list)

public OrderedPSet<E>
intersect(Collection<? extends E> list)

Overrides default org.pcollections.PSet.intersect.

public Iterator<E>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator, java.util.Set.iterator.

Returns an iterator over the elements in this set.

public OrderedPSet<E>
public OrderedPSet<E>
public OrderedPSet<E>
plus(final E e)

Implements org.pcollections.PSet.plus.

public OrderedPSet<E>
plusAll(final Collection<? extends E> list)

Implements org.pcollections.PSet.plusAll.

public static <E> OrderedPSet<E>
singleton(final E e)

public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Collection.size, java.util.Set.size.

Returns the number of elements in this set (its cardinality).

Inherited from org.pcollections.AbstractUnmodifiableSet:
addaddAllclearremoveremoveAllremoveIfretainAll

Field Detail

elementsback to summary
private final PSortedMap<Long, E> elements
EMPTYback to summary
private static final OrderedPSet<Object> EMPTY
idsback to summary
private final PMap<E, Long> ids
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

OrderedPSetback to summary
private OrderedPSet(final PMap<E, Long> ids, final PSortedMap<Long, E> elements)

Method Detail

emptyback to summary
public static <E> OrderedPSet<E> empty()
Annotations
@SuppressWarnings:unchecked
fromback to summary
public static <E> OrderedPSet<E> from(final Collection<? extends E> list)
Annotations
@SuppressWarnings:unchecked
intersectback to summary
public OrderedPSet<E> intersect(Collection<? extends E> list)

Overrides default org.pcollections.PSet.intersect.

Returns:OrderedPSet<E>

Doc from org.pcollections.PSet.intersect.

the equivalent of this.minusAll(this.minusAll(list)).

Annotations
@Override
iteratorback to summary
public Iterator<E> iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator, java.util.Set.iterator.

Doc from java.util.Set.iterator.

Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).

Returns:Iterator<E>

an iterator over the elements in this set

Annotations
@Override
minusback to summary
public OrderedPSet<E> minus(final Object e)

Implements org.pcollections.PSet.minus.

Returns:OrderedPSet<E>

Doc from org.pcollections.PCollection.minus.

this with a single instance of e removed, if e is in this

Annotations
@Override
minusAllback to summary
public OrderedPSet<E> minusAll(final Collection<?> list)

Implements org.pcollections.PSet.minusAll.

Returns:OrderedPSet<E>

Doc from org.pcollections.PCollection.minusAll.

this with all elements of list completely removed

Annotations
@Override
plusback to summary
public OrderedPSet<E> plus(final E e)

Implements org.pcollections.PSet.plus.

Returns:OrderedPSet<E>

Doc from org.pcollections.PCollection.plus.

a collection which contains e and all of the elements of this

Annotations
@Override
plusAllback to summary
public OrderedPSet<E> plusAll(final Collection<? extends E> list)

Implements org.pcollections.PSet.plusAll.

Returns:OrderedPSet<E>

Doc from org.pcollections.PCollection.plusAll.

a collection which contains all of the elements of list and this

Annotations
@Override
singletonback to summary
public static <E> OrderedPSet<E> singleton(final E e)
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Collection.size, java.util.Set.size.

Doc from java.util.Set.size.

Returns the number of elements in this set (its cardinality). If this set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this set (its cardinality)

Annotations
@Override