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 boolean
add(char item)
boolean
addAll(char... source)
boolean
addAll(CharIterable source)
void
addOccurrences(char item, int occurrences)
boolean
allSatisfy(CharPredicate predicate)
Returns true if all of the elements in the CharIterable return true for the specified predicate, otherwise returns false.boolean
anySatisfy(CharPredicate predicate)
Returns true if any of the elements in the CharIterable return true for the specified predicate, otherwise returns false.void
appendString(Appendable appendable, String start, String separator, String end)
Prints a string representation of this collection onto the givenAppendable
.MutableCharBag
asSynchronized()
MutableCharBag
asUnmodifiable()
MutableList<CharIntPair>
bottomOccurrences(int count)
Returns thecount
least frequently occurring items.MutableCharIterator
charIterator()
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.void
clear()
<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.boolean
contains(char value)
Returns true if the value is contained in the CharIterable, and false if it is not.int
count(CharPredicate predicate)
Returns a count of the number of elements in the CharIterable that return true for the specified predicate.char
detectIfNone(CharPredicate predicate, char ifNone)
void
each(CharProcedure procedure)
A synonym for forEach.boolean
equals(Object otherBag)
Follows the same general contract asBag.equals(Object)
.void
forEach(CharProcedure procedure)
Applies the CharProcedure to each element in the CharIterable.void
forEachWithOccurrences(CharIntProcedure procedure)
For each distinct item, with the number of occurrences, execute the specified procedure.int
hashCode()
Follows the same general contract asBag.hashCode()
.<T> T
injectInto(T injectedValue, ObjectCharToObjectFunction<? super T,? extends T> function)
boolean
isEmpty()
Returns true if this iterable has zero items.char
max()
char
min()
static CharHashBag
newBag(int size)
static CharHashBag
newBag(CharBag source)
static CharHashBag
newBag(CharIterable source)
static CharHashBag
newBagWith(char... source)
CharHashBag
newEmpty()
Creates a new empty CharHashBag.boolean
noneSatisfy(CharPredicate predicate)
Returns true if none of the elements in the CharIterable return true for the specified predicate, otherwise returns false.boolean
notEmpty()
The English equivalent of !this.isEmpty()int
occurrencesOf(char item)
The occurrences of a distinct item in the bag.void
readExternal(ObjectInput in)
CharHashBag
reject(CharPredicate predicate)
Returns a new CharIterable with all of the elements in the CharIterable that return false for the specified predicate.boolean
remove(char item)
boolean
removeAll(char... source)
boolean
removeAll(CharIterable source)
boolean
removeIf(CharPredicate predicate)
boolean
removeOccurrences(char item, int occurrences)
boolean
retainAll(char... source)
boolean
retainAll(CharIterable source)
CharHashBag
select(CharPredicate predicate)
Returns a new CharIterable with all of the elements in the CharIterable that return true for the specified predicate.CharHashBag
selectByOccurrences(IntPredicate predicate)
Returns all elements of the bag that have a number of occurrences that satisfy the predicate.MutableCharSet
selectUnique()
Returns all elements of the bag that have exactly one occurrence.int
size()
Returns the number of items in this iterable.int
sizeDistinct()
The size of the Bag when counting only distinct elements.long
sum()
char[]
toArray()
Converts the CharIterable to a primitive char array.char[]
toArray(char[] array)
Converts the CharIterable to a primitive char array.ImmutableCharBag
toImmutable()
Returns an immutable copy of this bag.MutableList<CharIntPair>
topOccurrences(int count)
Returns thecount
most frequently occurring items.CharHashBag
with(char element)
CharHashBag
with(char element1, char element2)
CharHashBag
with(char element1, char element2, char element3)
CharHashBag
withAll(CharIterable iterable)
CharHashBag
without(char element)
CharHashBag
withoutAll(CharIterable iterable)
void
writeExternal(ObjectOutput out)
Methods inherited from class org.eclipse.collections.impl.primitive.AbstractCharIterable
asLazy, average, containsAll, containsAll, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toString
Methods inherited from interface org.eclipse.collections.api.bag.primitive.CharBag
toStringOfItemToCount
Methods 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, toSortedList
Methods inherited from interface org.eclipse.collections.api.bag.primitive.MutableCharBag
selectDuplicates, tap
Methods 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:PrimitiveIterable
Returns true if this iterable has zero items.- Specified by:
isEmpty
in interfacePrimitiveIterable
-
notEmpty
public boolean notEmpty()Description copied from interface:PrimitiveIterable
The English equivalent of !this.isEmpty()- Specified by:
notEmpty
in interfacePrimitiveIterable
-
size
public int size()Description copied from interface:PrimitiveIterable
Returns the number of items in this iterable.- Specified by:
size
in interfacePrimitiveIterable
-
sizeDistinct
public int sizeDistinct()Description copied from interface:CharBag
The size of the Bag when counting only distinct elements.- Specified by:
sizeDistinct
in interfaceCharBag
-
clear
public void clear()- Specified by:
clear
in interfaceMutableCharCollection
-
with
- Specified by:
with
in interfaceMutableCharBag
- Specified by:
with
in interfaceMutableCharCollection
-
with
-
with
-
withAll
- Specified by:
withAll
in interfaceMutableCharBag
- Specified by:
withAll
in interfaceMutableCharCollection
-
without
- Specified by:
without
in interfaceMutableCharBag
- Specified by:
without
in interfaceMutableCharCollection
-
withoutAll
- Specified by:
withoutAll
in interfaceMutableCharBag
- Specified by:
withoutAll
in interfaceMutableCharCollection
-
contains
public boolean contains(char value)Description copied from interface:CharIterable
Returns true if the value is contained in the CharIterable, and false if it is not.- Specified by:
contains
in interfaceCharIterable
-
occurrencesOf
public int occurrencesOf(char item)Description copied from interface:CharBag
The occurrences of a distinct item in the bag.- Specified by:
occurrencesOf
in interfaceCharBag
-
forEachWithOccurrences
Description copied from interface:CharBag
For each distinct item, with the number of occurrences, execute the specified procedure.- Specified by:
forEachWithOccurrences
in interfaceCharBag
-
selectByOccurrences
Description copied from interface:MutableCharBag
Returns all elements of the bag that have a number of occurrences that satisfy the predicate.- Specified by:
selectByOccurrences
in interfaceCharBag
- Specified by:
selectByOccurrences
in interfaceMutableCharBag
-
selectUnique
Description copied from interface:MutableCharBag
Returns all elements of the bag that have exactly one occurrence.- Specified by:
selectUnique
in interfaceCharBag
- Specified by:
selectUnique
in interfaceMutableCharBag
-
topOccurrences
Description copied from interface:MutableCharBag
Returns thecount
most 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:
topOccurrences
in interfaceCharBag
- Specified by:
topOccurrences
in interfaceMutableCharBag
-
bottomOccurrences
Description copied from interface:MutableCharBag
Returns thecount
least 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:
bottomOccurrences
in interfaceCharBag
- Specified by:
bottomOccurrences
in interfaceMutableCharBag
-
add
public boolean add(char item)- Specified by:
add
in interfaceMutableCharCollection
-
remove
public boolean remove(char item)- Specified by:
remove
in interfaceMutableCharCollection
-
removeIf
- Specified by:
removeIf
in interfaceMutableCharCollection
-
addAll
public boolean addAll(char... source)- Specified by:
addAll
in interfaceMutableCharCollection
-
addAll
- Specified by:
addAll
in interfaceMutableCharCollection
-
removeAll
public boolean removeAll(char... source)- Specified by:
removeAll
in interfaceMutableCharCollection
-
removeAll
- Specified by:
removeAll
in interfaceMutableCharCollection
-
retainAll
- Specified by:
retainAll
in interfaceMutableCharCollection
- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(char... source)- Specified by:
retainAll
in interfaceMutableCharCollection
- See Also:
Collection.retainAll(Collection)
-
addOccurrences
public void addOccurrences(char item, int occurrences)- Specified by:
addOccurrences
in interfaceMutableCharBag
-
removeOccurrences
public boolean removeOccurrences(char item, int occurrences)- Specified by:
removeOccurrences
in interfaceMutableCharBag
-
forEach
Description copied from interface:CharIterable
Applies the CharProcedure to each element in the CharIterable.- Specified by:
forEach
in interfaceCharIterable
-
each
Description copied from interface:CharIterable
A synonym for forEach.- Specified by:
each
in interfaceCharIterable
- Since:
- 7.0.
-
select
Description copied from interface:CharIterable
Returns a new CharIterable with all of the elements in the CharIterable that return true for the specified predicate.- Specified by:
select
in interfaceCharBag
- Specified by:
select
in interfaceCharIterable
- Specified by:
select
in interfaceMutableCharBag
- Specified by:
select
in interfaceMutableCharCollection
-
reject
Description copied from interface:CharIterable
Returns a new CharIterable with all of the elements in the CharIterable that return false for the specified predicate.- Specified by:
reject
in interfaceCharBag
- Specified by:
reject
in interfaceCharIterable
- Specified by:
reject
in interfaceMutableCharBag
- Specified by:
reject
in interfaceMutableCharCollection
-
injectInto
public <T> T injectInto(T injectedValue, ObjectCharToObjectFunction<? super T,? extends T> function)- Specified by:
injectInto
in interfaceCharIterable
-
chunk
Description copied from interface:CharIterable
Partitions elements in fixed size chunks.- Specified by:
chunk
in interfaceCharIterable
- Parameters:
size
- the number of elements per chunk- Returns:
- A
RichIterable
containingCharIterable
s of sizesize
, except the last will be truncated if the elements don't divide evenly.
-
equals
Description copied from interface:CharBag
Follows the same general contract asBag.equals(Object)
. -
hashCode
public int hashCode()Description copied from interface:CharBag
Follows the same general contract asBag.hashCode()
. -
appendString
Description copied from interface:PrimitiveIterable
Prints a string representation of this collection onto the givenAppendable
. Prints the string returned byPrimitiveIterable.makeString(String, String, String)
.- Specified by:
appendString
in interfacePrimitiveIterable
-
count
Description copied from interface:CharIterable
Returns a count of the number of elements in the CharIterable that return true for the specified predicate.- Specified by:
count
in interfaceCharIterable
-
anySatisfy
Description copied from interface:CharIterable
Returns true if any of the elements in the CharIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfy
in interfaceCharIterable
-
allSatisfy
Description copied from interface:CharIterable
Returns true if all of the elements in the CharIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfy
in interfaceCharIterable
-
noneSatisfy
Description copied from interface:CharIterable
Returns true if none of the elements in the CharIterable return true for the specified predicate, otherwise returns false.- Specified by:
noneSatisfy
in interfaceCharIterable
-
detectIfNone
- Specified by:
detectIfNone
in interfaceCharIterable
-
collect
Description copied from interface:CharIterable
Returns 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:
collect
in interfaceCharBag
- Specified by:
collect
in interfaceCharIterable
- Specified by:
collect
in interfaceMutableCharBag
- Specified by:
collect
in interfaceMutableCharCollection
-
max
public char max()- Specified by:
max
in interfaceCharIterable
-
min
public char min()- Specified by:
min
in interfaceCharIterable
-
sum
public long sum()- Specified by:
sum
in interfaceCharIterable
-
toArray
public char[] toArray()Description copied from interface:CharIterable
Converts the CharIterable to a primitive char array.- Specified by:
toArray
in interfaceCharIterable
-
toArray
public char[] toArray(char[] array)Description copied from interface:CharIterable
Converts 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:
toArray
in interfaceCharIterable
-
asUnmodifiable
- Specified by:
asUnmodifiable
in interfaceMutableCharBag
- Specified by:
asUnmodifiable
in interfaceMutableCharCollection
-
asSynchronized
- Specified by:
asSynchronized
in interfaceMutableCharBag
- Specified by:
asSynchronized
in interfaceMutableCharCollection
-
toImmutable
Description copied from interface:MutableCharBag
Returns an immutable copy of this bag.- Specified by:
toImmutable
in interfaceCharBag
- Specified by:
toImmutable
in interfaceMutableCharBag
- Specified by:
toImmutable
in interfaceMutableCharCollection
-
newEmpty
Creates a new empty CharHashBag.- Specified by:
newEmpty
in interfaceMutableCharBag
- Specified by:
newEmpty
in interfaceMutableCharCollection
- Since:
- 9.2.
-
charIterator
Description copied from interface:CharIterable
Returns a primitive iterator that can be used to iterate over the CharIterable in an imperative style.- Specified by:
charIterator
in interfaceCharIterable
- Specified by:
charIterator
in interfaceMutableCharCollection
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
-