Class TreeBag<T>
- java.lang.Object
-
- org.eclipse.collections.impl.AbstractRichIterable<T>
-
- org.eclipse.collections.impl.bag.AbstractBag<T>
-
- org.eclipse.collections.impl.bag.mutable.AbstractMutableBagIterable<T>
-
- org.eclipse.collections.impl.bag.sorted.mutable.AbstractMutableSortedBag<T>
-
- org.eclipse.collections.impl.bag.sorted.mutable.TreeBag<T>
-
- All Implemented Interfaces:
Externalizable,Serializable,Cloneable,Comparable<SortedBag<T>>,Iterable<T>,Collection<T>,Bag<T>,MutableBagIterable<T>,MutableSortedBag<T>,SortedBag<T>,MutableCollection<T>,InternalIterable<T>,OrderedIterable<T>,ReversibleIterable<T>,SortedIterable<T>,RichIterable<T>
public class TreeBag<T> extends AbstractMutableSortedBag<T> implements Externalizable
A TreeBag is a MutableSortedBag which uses a SortedMap as its underlying data store. Each key in the SortedMap represents some item, and the value in the map represents the current number of occurrences of that item.- Since:
- 4.2
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(T item)intaddOccurrences(T item, int occurrences)booleanallSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)booleananySatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)voidclear()TreeBag<T>clone()Comparator<? super T>comparator()intcompareTo(SortedBag<T> otherBag)booleancontains(Object o)<S> booleancorresponds(OrderedIterable<S> other, Predicate2<? super T,? super S> predicate)intdetectIndex(Predicate<? super T> predicate)TdetectWithOccurrences(ObjectIntPredicate<? super T> predicate)MutableSortedSet<T>distinct()RichIterable<T>distinctView()MutableSortedBag<T>drop(int count)voideach(Procedure<? super T> procedure)booleanequals(Object other)voidforEach(int fromIndex, int toIndex, Procedure<? super T> procedure)<P> voidforEachWith(Procedure2<? super T,? super P> procedure, P parameter)voidforEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure)voidforEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)voidforEachWithOccurrences(ObjectIntProcedure<? super T> procedure)<V> TreeBagMultimap<V,T>groupBy(Function<? super T,? extends V> function)<V> TreeBagMultimap<V,T>groupByEach(Function<? super T,? extends Iterable<V>> function)inthashCode()intindexOf(Object object)booleanisEmpty()Iterator<T>iterator()static <E> TreeBag<E>newBag()static <E> TreeBag<E>newBag(Iterable<? extends E> source)static <E> TreeBag<E>newBag(Comparator<? super E> comparator)static <E> TreeBag<E>newBag(Comparator<? super E> comparator, Iterable<? extends E> iterable)static <E> TreeBag<E>newBagWith(E... elements)static <E> TreeBag<E>newBagWith(Comparator<? super E> comparator, E... elements)MutableSortedBag<T>newEmpty()booleannoneSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)intoccurrencesOf(Object item)voidreadExternal(ObjectInput in)booleanremove(Object item)booleanremoveAllIterable(Iterable<?> iterable)booleanremoveIf(Predicate<? super T> predicate)<P> booleanremoveIfWith(Predicate2<? super T,? super P> predicate, P parameter)booleanremoveOccurrences(Object item, int occurrences)MutableSortedBag<T>selectByOccurrences(IntPredicate predicate)booleansetOccurrences(T item, int occurrences)intsize()intsizeDistinct()MutableSortedBag<T>take(int count)MutableStack<T>toStack()TreeBag<T>with(T element)TreeBag<T>with(T... elements)TreeBag<T>with(T element1, T element2)TreeBag<T>with(T element1, T element2, T element3)TreeBag<T>withAll(Iterable<? extends T> iterable)TreeBag<T>without(T element)TreeBag<T>withoutAll(Iterable<? extends T> iterable)voidwriteExternal(ObjectOutput out)MutableSortedSet<Pair<T,Integer>>zipWithIndex()-
Methods inherited from class org.eclipse.collections.impl.bag.sorted.mutable.AbstractMutableSortedBag
asParallel, asSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, collectWithIndex, collectWithIndex, collectWithOccurrences, countBy, countByEach, countByWith, detectLastIndex, dropWhile, flatCollect, partition, partitionWhile, partitionWith, reject, rejectWith, select, selectInstancesOf, selectWith, takeWhile, tap, toImmutable, toMapOfItemToCount, toReversed, zip
-
Methods inherited from class org.eclipse.collections.impl.bag.mutable.AbstractMutableBagIterable
addAll, addAllIterable, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, bottomOccurrences, chunk, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, getFirst, getLast, groupByUniqueKey, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, removeAll, retainAll, retainAllIterable, selectAndRejectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, topOccurrences
-
Methods inherited from class org.eclipse.collections.impl.bag.AbstractBag
collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, count, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, groupBy, groupByEach, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoWith, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toSet, toSortedBag, toSortedBag, toSortedList, toSortedSet, toSortedSet, toStringOfItemToCount
-
Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
appendString, appendString, asLazy, containsAll, containsAllArguments, containsAllIterable, countWith, forEach, groupByUniqueKey, into, toArray, toArray, toBiMap, toMap, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSetBy, toString, zip, zipWithIndex
-
Methods inherited from interface org.eclipse.collections.api.bag.Bag
aggregateBy, collectWithOccurrences, reduceInPlace, reduceInPlace, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toStringOfItemToCount
-
Methods inherited from interface java.util.Collection
addAll, containsAll, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach
-
Methods inherited from interface org.eclipse.collections.api.bag.MutableBagIterable
bottomOccurrences, selectDuplicates, selectUnique, topOccurrences
-
Methods inherited from interface org.eclipse.collections.api.collection.MutableCollection
addAllIterable, aggregateBy, aggregateInPlaceBy, flatCollectWith, groupByUniqueKey, injectIntoWith, retainAllIterable, selectAndRejectWith, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from interface org.eclipse.collections.api.bag.sorted.MutableSortedBag
flatCollectWith, selectDuplicates, selectUnique, toImmutableSortedBag
-
Methods inherited from interface org.eclipse.collections.api.ordered.OrderedIterable
getFirst, getFirstOptional, getLast, getLastOptional, rejectWithIndex, selectWithIndex, zip, zipWithIndex
-
Methods inherited from interface org.eclipse.collections.api.ordered.ReversibleIterable
asReversed, reverseForEach, reverseForEachWithIndex
-
Methods inherited from interface org.eclipse.collections.api.RichIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, makeString, makeString, makeString, makeString, max, maxBy, maxByOptional, maxOptional, maxOptional, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString
-
-
-
-
Constructor Detail
-
TreeBag
public TreeBag()
-
TreeBag
public TreeBag(Comparator<? super T> comparator)
-
TreeBag
public TreeBag(Comparator<? super T> comparator, Iterable<? extends T> iterable)
-
-
Method Detail
-
newBag
public static <E> TreeBag<E> newBag()
-
newBag
public static <E> TreeBag<E> newBag(Comparator<? super E> comparator)
-
newBag
public static <E> TreeBag<E> newBag(Comparator<? super E> comparator, Iterable<? extends E> iterable)
-
newBagWith
public static <E> TreeBag<E> newBagWith(E... elements)
-
newBagWith
public static <E> TreeBag<E> newBagWith(Comparator<? super E> comparator, E... elements)
-
clone
public TreeBag<T> clone()
- Specified by:
clonein interfaceMutableSortedBag<T>- Specified by:
clonein classAbstractMutableSortedBag<T>
-
equals
public boolean equals(Object other)
-
hashCode
public int hashCode()
-
sizeDistinct
public int sizeDistinct()
- Specified by:
sizeDistinctin interfaceBag<T>
-
forEachWithOccurrences
public void forEachWithOccurrences(ObjectIntProcedure<? super T> procedure)
- Specified by:
forEachWithOccurrencesin interfaceBag<T>
-
selectByOccurrences
public MutableSortedBag<T> selectByOccurrences(IntPredicate predicate)
- Specified by:
selectByOccurrencesin interfaceBag<T>- Specified by:
selectByOccurrencesin interfaceMutableBagIterable<T>- Specified by:
selectByOccurrencesin interfaceMutableSortedBag<T>- Specified by:
selectByOccurrencesin interfaceSortedBag<T>
-
occurrencesOf
public int occurrencesOf(Object item)
- Specified by:
occurrencesOfin interfaceBag<T>
-
anySatisfyWithOccurrences
public boolean anySatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
- Specified by:
anySatisfyWithOccurrencesin interfaceBag<T>
-
allSatisfyWithOccurrences
public boolean allSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
- Specified by:
allSatisfyWithOccurrencesin interfaceBag<T>
-
noneSatisfyWithOccurrences
public boolean noneSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
- Specified by:
noneSatisfyWithOccurrencesin interfaceBag<T>
-
detectWithOccurrences
public T detectWithOccurrences(ObjectIntPredicate<? super T> predicate)
- Specified by:
detectWithOccurrencesin interfaceBag<T>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection<T>- Specified by:
isEmptyin interfaceRichIterable<T>- Overrides:
isEmptyin classAbstractRichIterable<T>
-
remove
public boolean remove(Object item)
- Specified by:
removein interfaceCollection<T>
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<T>
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection<T>- Specified by:
containsin interfaceRichIterable<T>- Overrides:
containsin classAbstractRichIterable<T>
-
compareTo
public int compareTo(SortedBag<T> otherBag)
- Specified by:
compareToin interfaceComparable<T>
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
each
public void each(Procedure<? super T> procedure)
- Specified by:
eachin interfaceRichIterable<T>
-
forEachWithIndex
public void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)
- Specified by:
forEachWithIndexin interfaceInternalIterable<T>- Specified by:
forEachWithIndexin interfaceOrderedIterable<T>- Overrides:
forEachWithIndexin classAbstractRichIterable<T>
-
forEach
public void forEach(int fromIndex, int toIndex, Procedure<? super T> procedure)- Specified by:
forEachin interfaceOrderedIterable<T>
-
forEachWithIndex
public void forEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure)- Specified by:
forEachWithIndexin interfaceOrderedIterable<T>
-
forEachWith
public <P> void forEachWith(Procedure2<? super T,? super P> procedure, P parameter)
- Specified by:
forEachWithin interfaceInternalIterable<T>- Overrides:
forEachWithin classAbstractRichIterable<T>
-
addOccurrences
public int addOccurrences(T item, int occurrences)
- Specified by:
addOccurrencesin interfaceMutableBagIterable<T>
-
removeOccurrences
public boolean removeOccurrences(Object item, int occurrences)
- Specified by:
removeOccurrencesin interfaceMutableBagIterable<T>
-
setOccurrences
public boolean setOccurrences(T item, int occurrences)
- Specified by:
setOccurrencesin interfaceMutableBagIterable<T>
-
without
public TreeBag<T> without(T element)
- Specified by:
withoutin interfaceMutableBagIterable<T>- Specified by:
withoutin interfaceMutableCollection<T>- Specified by:
withoutin interfaceMutableSortedBag<T>
-
withAll
public TreeBag<T> withAll(Iterable<? extends T> iterable)
- Specified by:
withAllin interfaceMutableBagIterable<T>- Specified by:
withAllin interfaceMutableCollection<T>- Specified by:
withAllin interfaceMutableSortedBag<T>
-
withoutAll
public TreeBag<T> withoutAll(Iterable<? extends T> iterable)
- Specified by:
withoutAllin interfaceMutableBagIterable<T>- Specified by:
withoutAllin interfaceMutableCollection<T>- Specified by:
withoutAllin interfaceMutableSortedBag<T>
-
with
public TreeBag<T> with(T element)
- Specified by:
within interfaceMutableBagIterable<T>- Specified by:
within interfaceMutableCollection<T>- Specified by:
within interfaceMutableSortedBag<T>
-
newEmpty
public MutableSortedBag<T> newEmpty()
- Specified by:
newEmptyin interfaceMutableCollection<T>- Specified by:
newEmptyin interfaceMutableSortedBag<T>
-
removeIf
public boolean removeIf(Predicate<? super T> predicate)
- Specified by:
removeIfin interfaceMutableCollection<T>
-
removeIfWith
public <P> boolean removeIfWith(Predicate2<? super T,? super P> predicate, P parameter)
- Specified by:
removeIfWithin interfaceMutableCollection<T>
-
removeAllIterable
public boolean removeAllIterable(Iterable<?> iterable)
- Specified by:
removeAllIterablein interfaceMutableCollection<T>
-
size
public int size()
- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfaceRichIterable<T>
-
indexOf
public int indexOf(Object object)
- Specified by:
indexOfin interfaceOrderedIterable<T>
-
zipWithIndex
public MutableSortedSet<Pair<T,Integer>> zipWithIndex()
- Specified by:
zipWithIndexin interfaceBag<T>- Specified by:
zipWithIndexin interfaceMutableBagIterable<T>- Specified by:
zipWithIndexin interfaceMutableCollection<T>- Specified by:
zipWithIndexin interfaceMutableSortedBag<T>- Specified by:
zipWithIndexin interfaceOrderedIterable<T>- Specified by:
zipWithIndexin interfaceReversibleIterable<T>- Specified by:
zipWithIndexin interfaceRichIterable<T>- Specified by:
zipWithIndexin interfaceSortedBag<T>- Specified by:
zipWithIndexin interfaceSortedIterable<T>
-
distinct
public MutableSortedSet<T> distinct()
- Specified by:
distinctin interfaceMutableSortedBag<T>- Specified by:
distinctin interfaceOrderedIterable<T>- Specified by:
distinctin interfaceReversibleIterable<T>- Specified by:
distinctin interfaceSortedBag<T>- Specified by:
distinctin interfaceSortedIterable<T>
-
groupBy
public <V> TreeBagMultimap<V,T> groupBy(Function<? super T,? extends V> function)
- Specified by:
groupByin interfaceBag<T>- Specified by:
groupByin interfaceMutableBagIterable<T>- Specified by:
groupByin interfaceMutableCollection<T>- Specified by:
groupByin interfaceMutableSortedBag<T>- Specified by:
groupByin interfaceOrderedIterable<T>- Specified by:
groupByin interfaceReversibleIterable<T>- Specified by:
groupByin interfaceRichIterable<T>- Specified by:
groupByin interfaceSortedBag<T>- Specified by:
groupByin interfaceSortedIterable<T>
-
groupByEach
public <V> TreeBagMultimap<V,T> groupByEach(Function<? super T,? extends Iterable<V>> function)
- Specified by:
groupByEachin interfaceBag<T>- Specified by:
groupByEachin interfaceMutableBagIterable<T>- Specified by:
groupByEachin interfaceMutableCollection<T>- Specified by:
groupByEachin interfaceMutableSortedBag<T>- Specified by:
groupByEachin interfaceOrderedIterable<T>- Specified by:
groupByEachin interfaceReversibleIterable<T>- Specified by:
groupByEachin interfaceRichIterable<T>- Specified by:
groupByEachin interfaceSortedBag<T>- Specified by:
groupByEachin interfaceSortedIterable<T>
-
detectIndex
public int detectIndex(Predicate<? super T> predicate)
- Specified by:
detectIndexin interfaceOrderedIterable<T>
-
corresponds
public <S> boolean corresponds(OrderedIterable<S> other, Predicate2<? super T,? super S> predicate)
- Specified by:
correspondsin interfaceOrderedIterable<T>
-
toStack
public MutableStack<T> toStack()
- Specified by:
toStackin interfaceOrderedIterable<T>
-
take
public MutableSortedBag<T> take(int count)
- Specified by:
takein interfaceMutableSortedBag<T>- Specified by:
takein interfaceReversibleIterable<T>- Specified by:
takein interfaceSortedBag<T>
-
drop
public MutableSortedBag<T> drop(int count)
- Specified by:
dropin interfaceMutableSortedBag<T>- Specified by:
dropin interfaceReversibleIterable<T>- Specified by:
dropin interfaceSortedBag<T>
-
comparator
public Comparator<? super T> comparator()
- Specified by:
comparatorin interfaceSortedBag<T>- Specified by:
comparatorin interfaceSortedIterable<T>
-
add
public boolean add(T item)
- Specified by:
addin interfaceCollection<T>
-
distinctView
public RichIterable<T> distinctView()
- Specified by:
distinctViewin interfaceBag<T>
-
-