java.lang.Object | +--org.apache.commons.collections.bag.AbstractMapBagAll Implemented Interfaces:
Constructor needed for subclass serialisation. |
AbstractMapBag(Map map) Constructor that assigns the specified Map as the backing store. |
boolean | add(Object object) Adds a new element to the bag, incrementing its count in the underlying map. |
boolean | add(Object object, int nCopies) Adds a new element to the bag, incrementing its count in the map. |
boolean | addAll(Collection coll) Invokes #add(Object) for each element in the given collection. |
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. |
void | doReadObject(Map map, ObjectInputStream in) Read the map in using a custom routine. |
void | doWriteObject(ObjectOutputStream out) Write the map out using a custom routine. |
boolean | equals(Object object) Compares this Bag to another. |
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() Gets a hash code for the Bag compatible with the definition of equals. |
boolean | isEmpty() Returns true if the underlying map is empty. |
Iterator | iterator() Gets an iterator over the bag elements. |
boolean | remove(Object object) Removes all copies of the specified object from the bag. |
boolean | remove(Object object, int nCopies) Removes a specified number of copies of an object from the bag. |
boolean | removeAll(Collection coll) Removes objects from the bag according to their count in the specified collection. |
boolean | retainAll(Collection coll) Remove any members of the bag that are not in the given bag, respecting cardinality. |
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. |
protected AbstractMapBag()
protected AbstractMapBag(Map map)
public boolean add(Object object, int nCopies)
public boolean add(Object object)
public boolean addAll(Collection coll)
public void clear()
public boolean contains(Object object)
public boolean containsAll(Collection coll)
protected void doReadObject(Map map, ObjectInputStream in)
protected void doWriteObject(ObjectOutputStream out)
public boolean equals(Object object)
public int getCount(Object object)
protected Map getMap()
public int hashCode()
(e==null ? 0 : e.hashCode()) ^ noOccurances)
.
This hash code is compatible with the Set interface.
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 int size()
public Object[] toArray()
public Object[] toArray(Object[] array)
public String toString()
public Set uniqueSet()