| Modifier and Type | Class and Description |
|---|---|
| private class |
| Modifier and Type | Field and Description |
|---|---|
| protected MutableObjectIntMap | |
| protected int |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | add(T item)
Implements java. Ensures that this collection contains the specified element (optional operation). |
| public int | addOccurrences(T item, int occurrences)
Implements org. Add number of |
| public boolean | allSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
Implements org. Returns true if the predicate evaluates to true for all elements of the Bag. |
| public boolean | anySatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
Implements org. Returns true if the predicate evaluates to true for any element of the Bag. |
| public void | clear()
Implements java. Removes all of the elements from this collection (optional operation). |
| protected abstract int | |
| public boolean | contains(Object o)
Overrides org. Implements org. Returns true if the iterable has an element which responds true to element.equals(object). |
| public T | detectWithOccurrences(ObjectIntPredicate<? super T> predicate)
Implements org. Returns an element of the Bag that satisfies the predicate or null if such an element does not exist |
| public RichIterable | distinctView()
Overrides default org. Returns an unmodifiable view on the distinct elements with the same complexity as the Bag implementation. |
| public void | each(Procedure<? super T> procedure)
Implements org. The procedure is executed for each element in the iterable. |
| public boolean | equals(Object other)
Overrides java. Implements org. Two bags |
| public <P> void | forEachWith(Procedure2<? super T, ? super P> procedure, P parameter)
Overrides org. Implements org. The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument. |
| public void | forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)
Overrides org. Implements org. Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure. |
| public void | forEachWithOccurrences(ObjectIntProcedure<? super T> objectIntProcedure)
Implements org. For each distinct item, with the number of occurrences, execute the specified procedure. |
| protected RichIterable | getKeysView()
Implements abstract org.
|
| public <V> HashBagMultimap | groupBy(Function<? super T, ? extends V> function)
Implements org. For each element of the iterable, the function is evaluated and the results of these evaluations are collected into a new multimap, where the transformed value is the key and the original values are added to the same (or similar) species of collection as the source iterable. |
| public <V> HashBagMultimap | groupByEach(Function<? super T, ? extends Iterable<V>> function)
Implements org. Similar to |
| public int | hashCode()
Overrides java. Implements org. Returns the hash code for this Bag, defined as this. |
| public boolean | isEmpty()
Overrides org. Implements org. Returns true if this iterable has zero items. |
| public Iterator | iterator()
Implements java. Returns an iterator over elements of type |
| public boolean | noneSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
Implements org. Returns true if the Bag is empty or if the predicate evaluates to false for all elements of the Bag. |
| public int | occurrencesOf(Object item)
Implements org. The occurrences of a distinct item in the bag. |
| public boolean | remove(Object item)
Implements java. Removes a single instance of the specified element from this collection, if it is present (optional operation). |
| public boolean | removeAllIterable(Iterable<?> iterable)
Implements org.
|
| public boolean | removeIf(Predicate<? super T> predicate)
Implements org. Removes all elements in the collection that evaluate to true for the specified predicate. |
| public <P> boolean | removeIfWith(Predicate2<? super T, ? super P> predicate, P parameter)
Implements org. Removes all elements in the collection that evaluate to true for the specified predicate2 and parameter. |
| public boolean | removeOccurrences(Object item, int occurrences)
Implements org.
|
| public boolean | setOccurrences(T item, int occurrences)
Implements org.
|
| public int | size()
Implements org. Returns the number of items in this iterable. |
| public int | sizeDistinct()
Implements org. The size of the Bag when counting only distinct elements. |
| public MutableMap | toMapOfItemToCount()
Implements org. Converts the Bag to a Map of the Item type to its count as an Integer. |
| items | back to summary |
|---|---|
| protected MutableObjectIntMap<T> items | |
| size | back to summary |
|---|---|
| protected int size | |
| AbstractHashBag | back to summary |
|---|---|
| public AbstractHashBag() | |
| add | back to summary |
|---|---|
| public boolean add(T item) Implements java. Doc from java. Ensures that this collection contains the specified element (optional
operation). Returns
Collections that support this operation may place limitations on what
elements may be added to this collection. In particular, some
collections will refuse to add
If a collection refuses to add a particular element for any reason
other than that it already contains the element, it must throw
an exception (rather than returning
| |
| addOccurrences | back to summary |
|---|---|
| public int addOccurrences(T item, int occurrences) Implements org. Doc from org. Add number of For Example:
MutableBagIterable<String> names = Bags.mutable.of("A", "B", "B");
Assert.assertEquals(4, names.addOccurrences("A", 3));
| |
| allSatisfyWithOccurrences | back to summary |
|---|---|
| public boolean allSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate) Implements org. Doc from org. Returns true if the predicate evaluates to true for all elements of the Bag. Returns false if the Bag is empty or if not all elements return true for the predicate.
| |
| anySatisfyWithOccurrences | back to summary |
|---|---|
| public boolean anySatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate) Implements org. Doc from org. Returns true if the predicate evaluates to true for any element of the Bag. Returns false if the Bag is empty or if no element returns true for the predicate.
| |
| clear | back to summary |
|---|---|
| public void clear() Implements java. Doc from java. Removes all of the elements from this collection (optional operation). The collection will be empty after this method returns.
| |
| computeHashCode | back to summary |
|---|---|
| protected abstract int computeHashCode(T item) | |
| contains | back to summary |
|---|---|
| public boolean contains(Object o) Overrides org. Implements org. Doc from org. Returns true if the iterable has an element which responds true to element.equals(object).
| |
| detectWithOccurrences | back to summary |
|---|---|
| public T detectWithOccurrences(ObjectIntPredicate<? super T> predicate) Implements org. Doc from org. Returns an element of the Bag that satisfies the predicate or null if such an element does not exist
| |
| distinctView | back to summary |
|---|---|
| public RichIterable Overrides default org. Doc from org. Returns an unmodifiable view on the distinct elements with the same complexity as the Bag implementation.
| |
| each | back to summary |
|---|---|
| public void each(Procedure<? super T> procedure) Implements org. Doc from org. The procedure is executed for each element in the iterable. Example using a Java 8 lambda expression: people.each(person -> LOGGER.info(person.getName()));This method is a variant of InternalIterable#forEach(Procedure)
that has a signature conflict with Iterable#forEach(java..
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Implements org. Doc from org. Two bags
| |
| forEachWith | back to summary |
|---|---|
| public <P> void forEachWith(Procedure2<? super T, ? super P> procedure, P parameter) Overrides org. Implements org. Doc from org. The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument. Example using a Java 8 lambda:
people.forEachWith((Person person, Person other) ->
{
if (person.isRelatedTo(other))
{
LOGGER.info(person.getName());
}
}, fred);
Example using an anonymous inner class:
people.forEachWith(new Procedure2<Person, Person>()
{
public void value(Person person, Person other)
{
if (person.isRelatedTo(other))
{
LOGGER.info(person.getName());
}
}
}, fred);
| |
| forEachWithIndex | back to summary |
|---|---|
| public void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure) Overrides org. Implements org. Doc from org. Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure. Example using a Java 8 lambda:
people.forEachWithIndex((Person person, int index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));
Example using an anonymous inner class:
people.forEachWithIndex(new ObjectIntProcedure<Person>()
{
public void value(Person person, int index)
{
LOGGER.info("Index: " + index + " person: " + person.getName());
}
});
| |
| forEachWithOccurrences | back to summary |
|---|---|
| public void forEachWithOccurrences(ObjectIntProcedure<? super T> objectIntProcedure) Implements org. Doc from org. For each distinct item, with the number of occurrences, execute the specified procedure.
| |
| getKeysView | back to summary |
|---|---|
| protected RichIterable Implements abstract org.
| |
| groupBy | back to summary |
|---|---|
| public <V> HashBagMultimap Implements org. Doc from org. For each element of the iterable, the function is evaluated and the results of these evaluations are collected into a new multimap, where the transformed value is the key and the original values are added to the same (or similar) species of collection as the source iterable. Example using a Java 8 method reference:
Multimap<String, Person> peopleByLastName =
people.groupBy(Person::getLastName);
| |
| groupByEach | back to summary |
|---|---|
| public <V> HashBagMultimap Implements org. Doc from org. Similar to
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements org. Doc from org. Returns the hash code for this Bag, defined as this.
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Overrides org. Implements org. Doc from org. Returns true if this iterable has zero items.
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Doc from java. Returns an iterator over elements of type
| |
| noneSatisfyWithOccurrences | back to summary |
|---|---|
| public boolean noneSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate) Implements org. Doc from org. Returns true if the Bag is empty or if the predicate evaluates to false for all elements of the Bag. Returns false if the predicate evaluates to true for at least one element of the Bag.
| |
| occurrencesOf | back to summary |
|---|---|
| public int occurrencesOf(Object item) Implements org. Doc from org. The occurrences of a distinct item in the bag.
| |
| remove | back to summary |
|---|---|
| public boolean remove(Object item) Implements java. Doc from java. Removes a single instance of the specified element from this
collection, if it is present (optional operation). More formally,
removes an element
| |
| removeAllIterable | back to summary |
|---|---|
| public boolean removeAllIterable(Iterable<?> iterable) Implements org.
| |
| removeIf | back to summary |
|---|---|
| public boolean removeIf(Predicate<? super T> predicate) Implements org. Doc from org. Removes all elements in the collection that evaluate to true for the specified predicate. e.g. return lastNames.removeIf(Predicates.isNull());
| |
| removeIfWith | back to summary |
|---|---|
| public <P> boolean removeIfWith(Predicate2<? super T, ? super P> predicate, P parameter) Implements org. Doc from org. Removes all elements in the collection that evaluate to true for the specified predicate2 and parameter. return lastNames.removeIfWith(Predicates2.isNull(), null);
| |
| removeOccurrences | back to summary |
|---|---|
| public boolean removeOccurrences(Object item, int occurrences) Implements org.
| |
| setOccurrences | back to summary |
|---|---|
| public boolean setOccurrences(T item, int occurrences) Implements org.
| |
| size | back to summary |
|---|---|
| public int size() Implements org. Doc from org. Returns the number of items in this iterable.
| |
| sizeDistinct | back to summary |
|---|---|
| public int sizeDistinct() Implements org. Doc from org. The size of the Bag when counting only distinct elements.
| |
| toMapOfItemToCount | back to summary |
|---|---|
| public MutableMap Implements org. Doc from org. Converts the Bag to a Map of the Item type to its count as an Integer.
| |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private T | |
| private final Iterator | |
| private int |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public T | |
| public void | remove()
Overrides default java. Removes from the underlying collection the last element returned by this iterator (optional operation). |
| canRemove | back to summary |
|---|---|
| private boolean canRemove | |
| currentItem | back to summary |
|---|---|
| private T currentItem | |
| iterator | back to summary |
|---|---|
| private final Iterator<T> iterator | |
| occurrences | back to summary |
|---|---|
| private int occurrences | |
| InternalIterator | back to summary |
|---|---|
| private InternalIterator() | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public T next() Implements java. Doc from java. Returns the next element in the iteration.
| |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the
| |