org.eclipse.ocl.examples.eventmanager.util
Class BagImpl<E>
java.lang.Object
java.util.AbstractCollection<E>
org.eclipse.ocl.examples.eventmanager.util.BagImpl<E>
- All Implemented Interfaces:
- java.lang.Iterable<E>, java.util.Collection<E>, Bag<E>
public class BagImpl<E>
- extends java.util.AbstractCollection<E>
- implements Bag<E>
Default implementation of the Bag
interface.
- Author:
- Christian W. Damus (cdamus), Axel Uhl
Method Summary |
boolean |
add(E o)
|
void |
clear()
|
boolean |
contains(java.lang.Object o)
|
int |
count(java.lang.Object o)
Queries how many times the specified object occurs in me. |
static
|
emptyBag()
|
boolean |
equals(java.lang.Object o)
Returns true iff this bag and the argument bag have the same number of the same
elements. |
int |
hashCode()
|
java.util.Iterator<E> |
iterator()
|
boolean |
remove(java.lang.Object o)
removes every occurrence of the object from the collection |
int |
size()
|
java.lang.String |
toString()
|
Methods inherited from class java.util.AbstractCollection |
addAll, containsAll, isEmpty, removeAll, retainAll, toArray, toArray |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
addAll, containsAll, isEmpty, removeAll, retainAll, toArray, toArray |
EMPTY_BAG
public static Bag<?> EMPTY_BAG
BagImpl
public BagImpl()
BagImpl
public BagImpl(java.util.Collection<? extends E> c)
emptyBag
public static <E> Bag<E> emptyBag()
remove
public boolean remove(java.lang.Object o)
- removes every occurrence of the object from the collection
- Specified by:
remove
in interface java.util.Collection<E>
- Overrides:
remove
in class java.util.AbstractCollection<E>
add
public boolean add(E o)
- Specified by:
add
in interface java.util.Collection<E>
- Overrides:
add
in class java.util.AbstractCollection<E>
contains
public boolean contains(java.lang.Object o)
- Specified by:
contains
in interface java.util.Collection<E>
- Overrides:
contains
in class java.util.AbstractCollection<E>
count
public int count(java.lang.Object o)
- Description copied from interface:
Bag
- Queries how many times the specified object occurs in me.
If I do not contain the object, then the count is zero.
- Specified by:
count
in interface Bag<E>
- Parameters:
o
- an object
- Returns:
- the number of times that it occurs in me
size
public int size()
- Specified by:
size
in interface java.util.Collection<E>
- Specified by:
size
in class java.util.AbstractCollection<E>
clear
public void clear()
- Specified by:
clear
in interface java.util.Collection<E>
- Overrides:
clear
in class java.util.AbstractCollection<E>
equals
public boolean equals(java.lang.Object o)
- Returns true iff this bag and the argument bag have the same number of the same
elements.
- Specified by:
equals
in interface java.util.Collection<E>
- Overrides:
equals
in class java.lang.Object
hashCode
public int hashCode()
- Specified by:
hashCode
in interface java.util.Collection<E>
- Overrides:
hashCode
in class java.lang.Object
iterator
public java.util.Iterator<E> iterator()
- Specified by:
iterator
in interface java.lang.Iterable<E>
- Specified by:
iterator
in interface java.util.Collection<E>
- Specified by:
iterator
in class java.util.AbstractCollection<E>
toString
public java.lang.String toString()
- Overrides:
toString
in class java.util.AbstractCollection<E>