Method Summary |
|
public boolean | add(Object object) Adds a new element to the bag, incrementing its count in the underlying map. |
public boolean | add(Object object, int nCopies) Adds a new element to the bag, incrementing its count in the map. |
public boolean | addAll(Collection coll) Invokes
AbstractMapBag.add(Object) for each element in the given collection. |
public void | clear() Clears the bag by clearing the underlying map. |
public boolean | contains(Object object) Determines if the bag contains the given element by checking if the
underlying map contains the element as a key. |
public 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. |
protected void | doReadObject(Map map, ObjectInputStream in) Read the map in using a custom routine. |
protected void | doWriteObject(ObjectOutputStream out) Write the map out using a custom routine. |
public boolean | equals(Object object) Compares this Bag to another. |
public 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. |
protected Map | getMap() Utility method for implementations to access the map that backs
this bag. |
public int | hashCode() Gets a hash code for the Bag compatible with the definition of equals. |
public boolean | isEmpty() Returns true if the underlying map is empty. |
public Iterator | iterator() Gets an iterator over the bag elements. |
public boolean | remove(Object object) Removes all copies of the specified object from the bag. |
public boolean | remove(Object object, int nCopies) Removes a specified number of copies of an object from the bag. |
public boolean | removeAll(Collection coll) Removes objects from the bag according to their count in the specified collection. |
public boolean | retainAll(Collection coll) Remove any members of the bag that are not in the given
bag, respecting cardinality. |
boolean | retainAll(Bag other) Remove any members of the bag that are not in the given
bag, respecting cardinality. |
public int | size() Returns the number of elements in this bag. |
public Object[] | toArray() Returns an array of all of this bag's elements. |
public Object[] | toArray(Object[] array) Returns an array of all of this bag's elements. |
public String | toString() Implement a toString() method suitable for debugging. |
public Set | uniqueSet() Returns an unmodifiable view of the underlying map's key set. |