org.pcollections
Class MapPBag<E>
java.lang.Object
java.util.AbstractCollection<E>
org.pcollections.MapPBag<E>
- Type Parameters:
E
-
- All Implemented Interfaces:
- Iterable<E>, Collection<E>, PBag<E>, PCollection<E>
public final class MapPBag<E>
- extends AbstractCollection<E>
- implements PBag<E>
A map-backed persistent bag.
If the backing map is thread-safe, then this implementation is thread-safe
(assuming Java's AbstractCollection is thread-safe), although its iterators
may not be.
- Author:
- harold
Methods inherited from class java.util.AbstractCollection |
add, addAll, clear, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString |
empty
public static <E> MapPBag<E> empty(PMap<E,Integer> map)
- Type Parameters:
E
- - Parameters:
map
-
- Returns:
- a PBag backed by an empty version of map, i.e. by map.minusAll(map.keySet())
size
public int size()
- Specified by:
size
in interface Collection<E>
- Specified by:
size
in class AbstractCollection<E>
iterator
public Iterator<E> iterator()
- Specified by:
iterator
in interface Iterable<E>
- Specified by:
iterator
in interface Collection<E>
- Specified by:
iterator
in class AbstractCollection<E>
contains
public boolean contains(Object e)
- Specified by:
contains
in interface Collection<E>
- Overrides:
contains
in class AbstractCollection<E>
hashCode
public int hashCode()
- Specified by:
hashCode
in interface Collection<E>
- Overrides:
hashCode
in class Object
equals
public boolean equals(Object that)
- Specified by:
equals
in interface Collection<E>
- Overrides:
equals
in class Object
plus
public MapPBag<E> plus(E e)
- Specified by:
plus
in interface PBag<E>
- Specified by:
plus
in interface PCollection<E>
- Parameters:
e
- non-null
- Returns:
- a collection which contains e and all of the elements of this
minus
public MapPBag<E> minus(Object e)
- Specified by:
minus
in interface PBag<E>
- Specified by:
minus
in interface PCollection<E>
- Returns:
- this with a single instance of e removed, if e is in this
plusAll
public MapPBag<E> plusAll(Collection<? extends E> list)
- Specified by:
plusAll
in interface PBag<E>
- Specified by:
plusAll
in interface PCollection<E>
- Parameters:
list
- contains no null elements
- Returns:
- a collection which contains all of the elements of list and this
minusAll
public MapPBag<E> minusAll(Collection<?> list)
- Specified by:
minusAll
in interface PBag<E>
- Specified by:
minusAll
in interface PCollection<E>
- Returns:
- this with all elements of list completely removed
Copyright © 2011. All Rights Reserved.