Class CharHashBag
java.lang.Object
org.eclipse.collections.impl.primitive.AbstractCharIterable
org.eclipse.collections.impl.bag.mutable.primitive.CharHashBag
- All Implemented Interfaces:
Externalizable,Serializable,CharBag,MutableCharBag,CharIterable,MutableCharCollection,PrimitiveIterable
public class CharHashBag extends AbstractCharIterable implements MutableCharBag, Externalizable
CharHashBag is similar to
HashBag, and is memory-optimized for char primitives.
This file was automatically generated from template file primitiveHashBag.stg.- Since:
- 3.0.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description CharHashBag()CharHashBag(char... elements)CharHashBag(int size)CharHashBag(CharIterable iterable)CharHashBag(CharHashBag bag) -
Method Summary
Modifier and Type Method Description booleanadd(char item)booleanaddAll(char... source)booleanaddAll(CharIterable source)voidaddOccurrences(char item, int occurrences)booleanallSatisfy(CharPredicate predicate)Returns true if all of the elements in the CharIterable return true for the specified predicate, otherwise returns false.booleananySatisfy(CharPredicate predicate)Returns true if any of the elements in the CharIterable return true for the specified predicate, otherwise returns false.voidappendString(Appendable appendable, String start, String separator, String end)Prints a string representation of this collection onto the givenAppendable.MutableCharBagasSynchronized()MutableCharBagasUnmodifiable()MutableList<CharIntPair>bottomOccurrences(int count)Returns thecountleast frequently occurring items.MutableCharIteratorcharIterator()Returns a primitive iterator that can be used to iterate over the CharIterable in an imperative style.RichIterable<CharIterable>chunk(int size)Partitions elements in fixed size chunks.voidclear()<V> MutableBag<V>collect(CharToObjectFunction<? extends V> function)Returns a new collection with the results of applying the specified function on each element of the source collection.booleancontains(char value)Returns true if the value is contained in the CharIterable, and false if it is not.intcount(CharPredicate predicate)Returns a count of the number of elements in the CharIterable that return true for the specified predicate.chardetectIfNone(CharPredicate predicate, char ifNone)voideach(CharProcedure procedure)A synonym for forEach.booleanequals(Object otherBag)Follows the same general contract asBag.equals(Object).voidforEach(CharProcedure procedure)Applies the CharProcedure to each element in the CharIterable.voidforEachWithOccurrences(CharIntProcedure procedure)For each distinct item, with the number of occurrences, execute the specified procedure.inthashCode()Follows the same general contract asBag.hashCode().<T> TinjectInto(T injectedValue, ObjectCharToObjectFunction<? super T,? extends T> function)booleanisEmpty()Returns true if this iterable has zero items.charmax()charmin()static CharHashBagnewBag(int size)static CharHashBagnewBag(CharBag source)static CharHashBagnewBag(CharIterable source)static CharHashBagnewBagWith(char... source)CharHashBagnewEmpty()Creates a new empty CharHashBag.booleannoneSatisfy(CharPredicate predicate)Returns true if none of the elements in the CharIterable return true for the specified predicate, otherwise returns false.booleannotEmpty()The English equivalent of !this.isEmpty()intoccurrencesOf(char item)The occurrences of a distinct item in the bag.voidreadExternal(ObjectInput in)CharHashBagreject(CharPredicate predicate)Returns a new CharIterable with all of the elements in the CharIterable that return false for the specified predicate.booleanremove(char item)booleanremoveAll(char... source)booleanremoveAll(CharIterable source)booleanremoveIf(CharPredicate predicate)booleanremoveOccurrences(char item, int occurrences)booleanretainAll(char... source)booleanretainAll(CharIterable source)CharHashBagselect(CharPredicate predicate)Returns a new CharIterable with all of the elements in the CharIterable that return true for the specified predicate.CharHashBagselectByOccurrences(IntPredicate predicate)Returns all elements of the bag that have a number of occurrences that satisfy the predicate.MutableCharSetselectUnique()Returns all elements of the bag that have exactly one occurrence.intsize()Returns the number of items in this iterable.intsizeDistinct()The size of the Bag when counting only distinct elements.longsum()char[]toArray()Converts the CharIterable to a primitive char array.char[]toArray(char[] array)Converts the CharIterable to a primitive char array.ImmutableCharBagtoImmutable()Returns an immutable copy of this bag.MutableList<CharIntPair>topOccurrences(int count)Returns thecountmost frequently occurring items.CharHashBagwith(char element)CharHashBagwith(char element1, char element2)CharHashBagwith(char element1, char element2, char element3)CharHashBagwithAll(CharIterable iterable)CharHashBagwithout(char element)CharHashBagwithoutAll(CharIterable iterable)voidwriteExternal(ObjectOutput out)Methods inherited from class org.eclipse.collections.impl.primitive.AbstractCharIterable
asLazy, average, containsAll, containsAll, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toStringMethods inherited from interface org.eclipse.collections.api.bag.primitive.CharBag
toStringOfItemToCountMethods inherited from interface org.eclipse.collections.api.CharIterable
asLazy, average, averageIfEmpty, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, containsAll, containsAll, flatCollect, maxIfEmpty, median, medianIfEmpty, minIfEmpty, reduce, reduceIfEmpty, reject, select, summaryStatistics, toBag, toList, toSet, toSortedArray, toSortedListMethods inherited from interface org.eclipse.collections.api.bag.primitive.MutableCharBag
selectDuplicates, tapMethods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, makeString, makeString, makeString, toString
-
Constructor Details
-
CharHashBag
public CharHashBag() -
CharHashBag
public CharHashBag(int size) -
CharHashBag
-
CharHashBag
public CharHashBag(char... elements) -
CharHashBag
-
-
Method Details
-
newBag
-
newBagWith
-
newBag
-
newBag
-
isEmpty
public boolean isEmpty()Description copied from interface:PrimitiveIterableReturns true if this iterable has zero items.- Specified by:
isEmptyin interfacePrimitiveIterable
-
notEmpty
public boolean notEmpty()Description copied from interface:PrimitiveIterableThe English equivalent of !this.isEmpty()- Specified by:
notEmptyin interfacePrimitiveIterable
-
size
public int size()Description copied from interface:PrimitiveIterableReturns the number of items in this iterable.- Specified by:
sizein interfacePrimitiveIterable
-
sizeDistinct
public int sizeDistinct()Description copied from interface:CharBagThe size of the Bag when counting only distinct elements.- Specified by:
sizeDistinctin interfaceCharBag
-
clear
public void clear()- Specified by:
clearin interfaceMutableCharCollection
-
with
- Specified by:
within interfaceMutableCharBag- Specified by:
within interfaceMutableCharCollection
-
with
-
with
-
withAll
- Specified by:
withAllin interfaceMutableCharBag- Specified by:
withAllin interfaceMutableCharCollection
-
without
- Specified by:
withoutin interfaceMutableCharBag- Specified by:
withoutin interfaceMutableCharCollection
-
withoutAll
- Specified by:
withoutAllin interfaceMutableCharBag- Specified by:
withoutAllin interfaceMutableCharCollection
-
contains
public boolean contains(char value)Description copied from interface:CharIterableReturns true if the value is contained in the CharIterable, and false if it is not.- Specified by:
containsin interfaceCharIterable
-
occurrencesOf
public int occurrencesOf(char item)Description copied from interface:CharBagThe occurrences of a distinct item in the bag.- Specified by:
occurrencesOfin interfaceCharBag
-
forEachWithOccurrences
Description copied from interface:CharBagFor each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrencesin interfaceCharBag
-
selectByOccurrences
Description copied from interface:MutableCharBagReturns all elements of the bag that have a number of occurrences that satisfy the predicate.- Specified by:
selectByOccurrencesin interfaceCharBag- Specified by:
selectByOccurrencesin interfaceMutableCharBag
-
selectUnique
Description copied from interface:MutableCharBagReturns all elements of the bag that have exactly one occurrence.- Specified by:
selectUniquein interfaceCharBag- Specified by:
selectUniquein interfaceMutableCharBag
-
topOccurrences
Description copied from interface:MutableCharBagReturns thecountmost frequently occurring items. In the event of a tie, all of the items with the number of occurrences that match the occurrences of the last item will be returned.- Specified by:
topOccurrencesin interfaceCharBag- Specified by:
topOccurrencesin interfaceMutableCharBag
-
bottomOccurrences
Description copied from interface:MutableCharBagReturns thecountleast frequently occurring items. In the event of a tie, all of the items with the number of occurrences that match the occurrences of the last item will be returned.- Specified by:
bottomOccurrencesin interfaceCharBag- Specified by:
bottomOccurrencesin interfaceMutableCharBag
-
add
public boolean add(char item)- Specified by:
addin interfaceMutableCharCollection
-
remove
public boolean remove(char item)- Specified by:
removein interfaceMutableCharCollection
-
removeIf
- Specified by:
removeIfin interfaceMutableCharCollection
-
addAll
public boolean addAll(char... source)- Specified by:
addAllin interfaceMutableCharCollection
-
addAll
- Specified by:
addAllin interfaceMutableCharCollection
-
removeAll
public boolean removeAll(char... source)- Specified by:
removeAllin interfaceMutableCharCollection
-
removeAll
- Specified by:
removeAllin interfaceMutableCharCollection
-
retainAll
- Specified by:
retainAllin interfaceMutableCharCollection- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(char... source)- Specified by:
retainAllin interfaceMutableCharCollection- See Also:
Collection.retainAll(Collection)
-
addOccurrences
public void addOccurrences(char item, int occurrences)- Specified by:
addOccurrencesin interfaceMutableCharBag
-
removeOccurrences
public boolean removeOccurrences(char item, int occurrences)- Specified by:
removeOccurrencesin interfaceMutableCharBag
-
forEach
Description copied from interface:CharIterableApplies the CharProcedure to each element in the CharIterable.- Specified by:
forEachin interfaceCharIterable
-
each
Description copied from interface:CharIterableA synonym for forEach.- Specified by:
eachin interfaceCharIterable- Since:
- 7.0.
-
select
Description copied from interface:CharIterableReturns a new CharIterable with all of the elements in the CharIterable that return true for the specified predicate.- Specified by:
selectin interfaceCharBag- Specified by:
selectin interfaceCharIterable- Specified by:
selectin interfaceMutableCharBag- Specified by:
selectin interfaceMutableCharCollection
-
reject
Description copied from interface:CharIterableReturns a new CharIterable with all of the elements in the CharIterable that return false for the specified predicate.- Specified by:
rejectin interfaceCharBag- Specified by:
rejectin interfaceCharIterable- Specified by:
rejectin interfaceMutableCharBag- Specified by:
rejectin interfaceMutableCharCollection
-
injectInto
public <T> T injectInto(T injectedValue, ObjectCharToObjectFunction<? super T,? extends T> function)- Specified by:
injectIntoin interfaceCharIterable
-
chunk
Description copied from interface:CharIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceCharIterable- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingCharIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-
equals
Description copied from interface:CharBagFollows the same general contract asBag.equals(Object). -
hashCode
public int hashCode()Description copied from interface:CharBagFollows the same general contract asBag.hashCode(). -
appendString
Description copied from interface:PrimitiveIterablePrints a string representation of this collection onto the givenAppendable. Prints the string returned byPrimitiveIterable.makeString(String, String, String).- Specified by:
appendStringin interfacePrimitiveIterable
-
count
Description copied from interface:CharIterableReturns a count of the number of elements in the CharIterable that return true for the specified predicate.- Specified by:
countin interfaceCharIterable
-
anySatisfy
Description copied from interface:CharIterableReturns true if any of the elements in the CharIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfyin interfaceCharIterable
-
allSatisfy
Description copied from interface:CharIterableReturns true if all of the elements in the CharIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfyin interfaceCharIterable
-
noneSatisfy
Description copied from interface:CharIterableReturns true if none of the elements in the CharIterable return true for the specified predicate, otherwise returns false.- Specified by:
noneSatisfyin interfaceCharIterable
-
detectIfNone
- Specified by:
detectIfNonein interfaceCharIterable
-
collect
Description copied from interface:CharIterableReturns a new collection with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.- Specified by:
collectin interfaceCharBag- Specified by:
collectin interfaceCharIterable- Specified by:
collectin interfaceMutableCharBag- Specified by:
collectin interfaceMutableCharCollection
-
max
public char max()- Specified by:
maxin interfaceCharIterable
-
min
public char min()- Specified by:
minin interfaceCharIterable
-
sum
public long sum()- Specified by:
sumin interfaceCharIterable
-
toArray
public char[] toArray()Description copied from interface:CharIterableConverts the CharIterable to a primitive char array.- Specified by:
toArrayin interfaceCharIterable
-
toArray
public char[] toArray(char[] array)Description copied from interface:CharIterableConverts the CharIterable to a primitive char array. If the collection fits into the provided array it is used to store its elements and is returned from the method, otherwise a new array of the appropriate size is allocated and returned. If the iterable is empty, the target array is returned unchanged.- Specified by:
toArrayin interfaceCharIterable
-
asUnmodifiable
- Specified by:
asUnmodifiablein interfaceMutableCharBag- Specified by:
asUnmodifiablein interfaceMutableCharCollection
-
asSynchronized
- Specified by:
asSynchronizedin interfaceMutableCharBag- Specified by:
asSynchronizedin interfaceMutableCharCollection
-
toImmutable
Description copied from interface:MutableCharBagReturns an immutable copy of this bag.- Specified by:
toImmutablein interfaceCharBag- Specified by:
toImmutablein interfaceMutableCharBag- Specified by:
toImmutablein interfaceMutableCharCollection
-
newEmpty
Creates a new empty CharHashBag.- Specified by:
newEmptyin interfaceMutableCharBag- Specified by:
newEmptyin interfaceMutableCharCollection- Since:
- 9.2.
-
charIterator
Description copied from interface:CharIterableReturns a primitive iterator that can be used to iterate over the CharIterable in an imperative style.- Specified by:
charIteratorin interfaceCharIterable- Specified by:
charIteratorin interfaceMutableCharCollection
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOException
-