Class Bag<E>
java.lang.Object
java.util.AbstractCollection<E>
org.apache.sis.internal.util.Bag<E>
- Type Parameters:
E- type of elements in this bag.
- All Implemented Interfaces:
Iterable<E>, Collection<E>
A collection in which elements order does not matter (as in
Set)
but in which duplicated elements are allowed (as in List).
The "bag" word is used in ISO specifications for such kind of collection.
This base class is suitable to collection returned by Map.values();
it is not necessarily a good fit for all other subtypes of AbstractCollection.
This abstract class implements the equals(Object) and hashCode() methods.
Subclasses need to override at least AbstractCollection.size() and AbstractCollection.iterator().
- Since:
- 1.0
- Version:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class AbstractCollection
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toStringMethods inherited from interface Collection
parallelStream, removeIf, spliterator, stream
-
Constructor Details
-
Bag
protected Bag()Creates a new instance.
-
-
Method Details
-
equals
Compares this bag with the given object for equality. This method performs comparisons only with instances ofBag, and returnsfalsefor all other kinds of collection. We do not compare with arbitrary collection implementations.Rational:
Collection.equals(Object)contract explicitly forbids comparisons withListandSet. The rational explained inCollectionjavadoc applies also to other kind ofCollectionimplementations: we cannot enforceCollection.equals(Object)to be symmetric in such cases.- Specified by:
equalsin interfaceCollection<E>- Overrides:
equalsin classObject- Parameters:
other- the other object to compare with this bag.- Returns:
trueif the two bags are equal.
-
hashCode
-