public class BagImpl<E> extends AbstractCollection<E> implements Bag.Internal<E>
Bag
interface.
The implementation is optimized for populate then use. Map entries returned while populating may be stale by the time
subsequent usage occurs.Bag.Internal<E>
Constructor and Description |
---|
BagImpl() |
BagImpl(Collection<? extends E> someElements)
Deprecated.
|
BagImpl(Iterable<? extends E> someElements) |
BagImpl(Iterator<? extends E> someElements) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E anElement) |
void |
clear() |
boolean |
contains(Object anElement) |
int |
count(Object anElement)
Queries how many times the specified object occurs in me.
|
static <E> Bag<E> |
emptyBag() |
boolean |
equals(Object thatElement)
Returns true iff this bag and the argument bag have the same number of the same
elements.
|
Map<E,? extends Number> |
getMap()
Return the internal map of distinct object to count of that object.
|
int |
hashCode() |
Iterator<E> |
iterator() |
boolean |
remove(Object anElement)
removes every occurrence of anElement from the collection
|
int |
size() |
String |
toString() |
addAll, containsAll, isEmpty, removeAll, retainAll, toArray, toArray
addAll, containsAll, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray
public BagImpl()
@Deprecated public BagImpl(Collection<? extends E> someElements)
public static <E> Bag<E> emptyBag()
public boolean add(E anElement)
add
in interface Collection<E>
add
in class AbstractCollection<E>
public void clear()
clear
in interface Collection<E>
clear
in class AbstractCollection<E>
public boolean contains(Object anElement)
contains
in interface Collection<E>
contains
in class AbstractCollection<E>
public int count(Object anElement)
Bag
public boolean equals(Object thatElement)
equals
in interface Collection<E>
equals
in class Object
public Map<E,? extends Number> getMap()
Bag.Internal
getMap
in interface Bag.Internal<E>
public int hashCode()
hashCode
in interface Collection<E>
hashCode
in class Object
public Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in class AbstractCollection<E>
public boolean remove(Object anElement)
remove
in interface Collection<E>
remove
in class AbstractCollection<E>
public int size()
size
in interface Collection<E>
size
in class AbstractCollection<E>
public String toString()
toString
in class AbstractCollection<E>
Copyright © 2005, 2018 IBM Corporation and others. All Rights Reserved.