Top Description Inners Fields Constructors Methods
org.pcollections

public final Class MapPSet<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
Imports
java.io.Serializable, java.util.Collection, .Iterator

A map-backed persistent set.

If the backing map is thread-safe, then this implementation is thread-safe (assuming Java's AbstractSet is thread-safe), although its iterators may not be.

Author
harold

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum

Field Summary

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

Constructor Summary

AccessConstructor and Description
private
MapPSet(final PMap<E, Object> map)

Method Summary

Modifier and TypeMethod and Description
public boolean
contains(final Object
element whose presence in this set is to be tested
e
)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Collection.contains, java.util.Set.contains.

Returns true if this set contains the specified element.

public static <E> MapPSet<E>

Returns:

a PSet with the elements of map.keySet(), backed by map
from
(final PMap<E, ?> map)

public static <E> MapPSet<E>

Returns:

from(map).plus(e)
from
(final PMap<E, ?> map, E e)

public static <E> MapPSet<E>

Returns:

from(map).plusAll(list)
from
(final PMap<E, ?> map, final Collection<? extends E> list)

public MapPSet<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 MapPSet<E>
public MapPSet<E>
public MapPSet<E>
plus(final E e)

Implements org.pcollections.PSet.plus.

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

Implements org.pcollections.PSet.plusAll.

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

mapback to summary
private final PMap<E, Object> map
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

MapPSetback to summary
private MapPSet(final PMap<E, Object> map)

Method Detail

containsback to summary
public boolean contains(final Object e)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Collection.contains, java.util.Set.contains.

Doc from java.util.Set.contains.

Returns true if this set contains the specified element. More formally, returns true if and only if this set contains an element e such that Objects.equals(o, e).

Parameters
e:Object

element whose presence in this set is to be tested

Returns:boolean

true if this set contains the specified element

Annotations
@Override
fromback to summary
public static <E> MapPSet<E> from(final PMap<E, ?> map)
Returns:MapPSet<E>

a PSet with the elements of map.keySet(), backed by map

Annotations
@SuppressWarnings:unchecked
fromback to summary
public static <E> MapPSet<E> from(final PMap<E, ?> map, E e)
Returns:MapPSet<E>

from(map).plus(e)

fromback to summary
public static <E> MapPSet<E> from(final PMap<E, ?> map, final Collection<? extends E> list)
Returns:MapPSet<E>

from(map).plusAll(list)

intersectback to summary
public MapPSet<E> intersect(Collection<? extends E> list)

Overrides default org.pcollections.PSet.intersect.

Returns:MapPSet<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 MapPSet<E> minus(final Object e)

Implements org.pcollections.PSet.minus.

Returns:MapPSet<E>

Doc from org.pcollections.PCollection.minus.

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

minusAllback to summary
public MapPSet<E> minusAll(final Collection<?> list)

Implements org.pcollections.PSet.minusAll.

Returns:MapPSet<E>

Doc from org.pcollections.PCollection.minusAll.

this with all elements of list completely removed

plusback to summary
public MapPSet<E> plus(final E e)

Implements org.pcollections.PSet.plus.

Returns:MapPSet<E>

Doc from org.pcollections.PCollection.plus.

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

plusAllback to summary
public MapPSet<E> plusAll(final Collection<? extends E> list)

Implements org.pcollections.PSet.plusAll.

Returns:MapPSet<E>

Doc from org.pcollections.PCollection.plusAll.

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

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
org.pcollections back to summary

private final Enum MapPSet.In

extends Enum<MapPSet.In>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final MapPSet.In

Constructor Summary

AccessConstructor and Description
private
In()

Method Summary

Modifier and TypeMethod and Description
public static MapPSet.In
public static MapPSet.In[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INback to summary
public static final MapPSet.In IN

Constructor Detail

Inback to summary
private In()

Method Detail

valueOfback to summary
public static MapPSet.In valueOf(String name)
valuesback to summary
public static MapPSet.In[] values()