java.lang.Object | +--org.apache.commons.collections.DefaultMapBagAll Implemented Interfaces:
No-argument constructor. |
DefaultMapBag(Map map) Constructor that assigns the specified Map as the backing store. |
boolean | add(Object object) Adds a new element to the bag by incrementing its count in the underlying map. |
boolean | add(Object object, int nCopies) Adds a new element to the bag by incrementing its count in the map. |
boolean | addAll(Collection coll) Invokes #add(Object) for each element in the given collection. |
int | Actually walks the bag to make sure the count is correct and resets the running total |
void | clear() Clears the bag by clearing the underlying map. |
boolean | contains(Object object) Determines if the bag contains the given element by checking if the underlying map contains the element as a key. |
boolean | containsAll(Collection coll) Determines if the bag contains the given elements. |
boolean | containsAll(Bag other) Returns true if the bag contains all elements in the given collection, respecting cardinality. |
boolean | equals(Object object) Returns true if the given object is not null, has the precise type of this bag, and contains the same number of occurrences of all the same elements. |
int | getCount(Object object) Returns the number of occurrence of the given element in this bag by looking up its count in the underlying map. |
Map | getMap() Utility method for implementations to access the map that backs this bag. |
int | hashCode() Returns the hash code of the underlying map. |
boolean | isEmpty() Returns true if the underlying map is empty. |
Iterator | iterator() |
boolean | remove(Object object) |
boolean | remove(Object object, int nCopies) |
boolean | removeAll(Collection coll) |
boolean | retainAll(Collection coll) Remove any members of the bag that are not in the given bag, respecting cardinality. |
boolean | Remove any members of the bag that are not in the given bag, respecting cardinality. |
void | setMap(Map map) Utility method for implementations to set the map that backs this bag. |
int | size() Returns the number of elements in this bag. |
Object[] | toArray() Returns an array of all of this bag's elements. |
Object[] | toArray(Object[] array) Returns an array of all of this bag's elements. |
String | toString() Implement a toString() method suitable for debugging. |
Set | Returns an unmodifiable view of the underlying map's key set. |
public DefaultMapBag()
setMap(Map)
in
their constructors.
protected DefaultMapBag(Map map)
public boolean add(Object object, int nCopies)
public boolean add(Object object)
public boolean addAll(Collection coll)
protected int calcTotalSize()
public void clear()
public boolean contains(Object object)
public boolean containsAll(Collection coll)
public boolean containsAll(Bag other)
true
if the bag contains all elements in
the given collection, respecting cardinality.
public boolean equals(Object object)
public int getCount(Object object)
protected Map getMap()
public int hashCode()
public boolean isEmpty()
public Iterator iterator()
public boolean remove(Object object, int nCopies)
public boolean remove(Object object)
public boolean removeAll(Collection coll)
public boolean retainAll(Collection coll)
public boolean retainAll(Bag other)
retainAll(Collection)
protected void setMap(Map map)
public int size()
public Object[] toArray()
public Object[] toArray(Object[] array)
public String toString()
public Set uniqueSet()
setMap(Map)
in their constructor (or invoke the Map constructor) specifying a map instance that will be used to store the contents of the bag. The map will be used to map bag elements to a number; the number represents the number of occurrences of that element in the bag.