Externalizable
, Serializable
, BooleanBag
, MutableBooleanBag
, BooleanIterable
, MutableBooleanCollection
, PrimitiveIterable
public final class BooleanHashBag extends Object implements MutableBooleanBag, Externalizable
HashBag
, and is memory-optimized for boolean primitives.Constructor | Description |
---|---|
BooleanHashBag() |
|
BooleanHashBag(boolean... elements) |
|
BooleanHashBag(BooleanIterable iterable) |
|
BooleanHashBag(BooleanHashBag bag) |
Modifier and Type | Method | Description |
---|---|---|
boolean |
add(boolean item) |
|
boolean |
addAll(boolean... source) |
|
boolean |
addAll(BooleanIterable source) |
|
void |
addOccurrences(boolean item,
int occurrences) |
|
boolean |
allSatisfy(BooleanPredicate predicate) |
Returns true if all of the elements in the BooleanIterable return true for the
specified predicate, otherwise returns false.
|
boolean |
anySatisfy(BooleanPredicate predicate) |
Returns true if any of the elements in the BooleanIterable return true for the
specified predicate, otherwise returns false.
|
void |
appendString(Appendable appendable) |
Prints a string representation of this collection onto the given
Appendable . |
void |
appendString(Appendable appendable,
String separator) |
Prints a string representation of this collection onto the given
Appendable . |
void |
appendString(Appendable appendable,
String start,
String separator,
String end) |
Prints a string representation of this collection onto the given
Appendable . |
LazyBooleanIterable |
asLazy() |
Returns a LazyBooleanIterable adapter wrapping the source BooleanIterable.
|
MutableBooleanBag |
asSynchronized() |
|
MutableBooleanBag |
asUnmodifiable() |
|
MutableBooleanIterator |
booleanIterator() |
Returns a primitive iterator that can be used to iterate over the BooleanIterable in an
imperative style.
|
MutableList<BooleanIntPair> |
bottomOccurrences(int count) |
Returns the
count least frequently occurring items. |
RichIterable<BooleanIterable> |
chunk(int size) |
Partitions elements in fixed size chunks.
|
void |
clear() |
|
<V> MutableBag<V> |
collect(BooleanToObjectFunction<? extends V> function) |
Returns a new collection with the results of applying the specified function on each element of the source
collection.
|
boolean |
contains(boolean value) |
Returns true if the value is contained in the BooleanIterable, and false if it is not.
|
boolean |
containsAll(boolean... source) |
Returns true if the all of the values specified in the source array are contained
in the BooleanIterable, and false if they are not.
|
boolean |
containsAll(BooleanIterable source) |
Returns true if the all of the values specified in the source BooleanIterable are contained
in the BooleanIterable, and false if they are not.
|
int |
count(BooleanPredicate predicate) |
Returns a count of the number of elements in the BooleanIterable that return true for the
specified predicate.
|
boolean |
detectIfNone(BooleanPredicate predicate,
boolean ifNone) |
|
void |
each(BooleanProcedure procedure) |
A synonym for forEach.
|
boolean |
equals(Object otherBag) |
Follows the same general contract as
Bag.equals(Object) . |
void |
forEach(BooleanProcedure procedure) |
Applies the BooleanProcedure to each element in the BooleanIterable.
|
void |
forEachWithOccurrences(BooleanIntProcedure procedure) |
For each distinct item, with the number of occurrences, execute the specified procedure.
|
int |
hashCode() |
Follows the same general contract as
Bag.hashCode() . |
<T> T |
injectInto(T injectedValue,
ObjectBooleanToObjectFunction<? super T,? extends T> function) |
|
boolean |
isEmpty() |
Returns true if this iterable has zero items.
|
String |
makeString() |
Returns a string representation of this collection by delegating to
PrimitiveIterable.makeString(String) and defaulting
the separator parameter to the characters ", " (comma and space). |
String |
makeString(String separator) |
Returns a string representation of this collection by delegating to
PrimitiveIterable.makeString(String, String, String)
and defaulting the start and end parameters to "" (the empty String). |
String |
makeString(String start,
String separator,
String end) |
Returns a string representation of this collection with the elements separated by the specified
separator and enclosed between the start and end strings.
|
static BooleanHashBag |
newBag(BooleanIterable source) |
|
static BooleanHashBag |
newBagWith(boolean... source) |
|
boolean |
noneSatisfy(BooleanPredicate predicate) |
Returns true if none of the elements in the BooleanIterable return true for the
specified predicate, otherwise returns false.
|
boolean |
notEmpty() |
The English equivalent of !this.isEmpty()
|
int |
occurrencesOf(boolean item) |
The occurrences of a distinct item in the bag.
|
void |
readExternal(ObjectInput in) |
|
MutableBooleanBag |
reject(BooleanPredicate predicate) |
Returns a new BooleanIterable with all of the elements in the BooleanIterable that
return false for the specified predicate.
|
boolean |
remove(boolean item) |
|
boolean |
removeAll(boolean... source) |
|
boolean |
removeAll(BooleanIterable source) |
|
boolean |
removeOccurrences(boolean item,
int occurrences) |
|
boolean |
retainAll(boolean... source) |
|
boolean |
retainAll(BooleanIterable elements) |
|
MutableBooleanBag |
select(BooleanPredicate predicate) |
Returns a new BooleanIterable with all of the elements in the BooleanIterable that
return true for the specified predicate.
|
MutableBooleanBag |
selectByOccurrences(IntPredicate predicate) |
Returns all elements of the bag that have a number of occurrences that satisfy the predicate.
|
MutableBooleanSet |
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.
|
boolean[] |
toArray() |
Converts the BooleanIterable to a primitive boolean array.
|
MutableBooleanBag |
toBag() |
Converts the BooleanIterable to a new MutableBooleanBag.
|
ImmutableBooleanBag |
toImmutable() |
Returns an immutable copy of this bag.
|
MutableBooleanList |
toList() |
Converts the BooleanIterable to a new MutableBooleanList.
|
MutableList<BooleanIntPair> |
topOccurrences(int count) |
Returns the
count most frequently occurring items. |
MutableBooleanSet |
toSet() |
Converts the BooleanIterable to a new MutableBooleanSet.
|
String |
toString() |
Returns a string with the elements of this iterable separated by commas with spaces and
enclosed in square brackets.
|
BooleanHashBag |
with(boolean element) |
|
BooleanHashBag |
with(boolean element1,
boolean element2) |
|
BooleanHashBag |
with(boolean element1,
boolean element2,
boolean element3) |
|
BooleanHashBag |
withAll(BooleanIterable iterable) |
|
BooleanHashBag |
without(boolean element) |
|
BooleanHashBag |
withoutAll(BooleanIterable iterable) |
|
void |
writeExternal(ObjectOutput out) |
toStringOfItemToCount
collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, flatCollect, reduce, reduceIfEmpty, reject, select
newEmpty, selectDuplicates, tap
removeIf
public BooleanHashBag()
public BooleanHashBag(BooleanIterable iterable)
public BooleanHashBag(boolean... elements)
public BooleanHashBag(BooleanHashBag bag)
public static BooleanHashBag newBagWith(boolean... source)
public static BooleanHashBag newBag(BooleanIterable source)
public boolean isEmpty()
PrimitiveIterable
isEmpty
in interface PrimitiveIterable
public boolean notEmpty()
PrimitiveIterable
notEmpty
in interface PrimitiveIterable
public int size()
PrimitiveIterable
size
in interface PrimitiveIterable
public int sizeDistinct()
BooleanBag
sizeDistinct
in interface BooleanBag
public void clear()
clear
in interface MutableBooleanCollection
public BooleanHashBag with(boolean element)
with
in interface MutableBooleanBag
with
in interface MutableBooleanCollection
public BooleanHashBag with(boolean element1, boolean element2)
public BooleanHashBag with(boolean element1, boolean element2, boolean element3)
public BooleanHashBag withAll(BooleanIterable iterable)
withAll
in interface MutableBooleanBag
withAll
in interface MutableBooleanCollection
public BooleanHashBag without(boolean element)
without
in interface MutableBooleanBag
without
in interface MutableBooleanCollection
public BooleanHashBag withoutAll(BooleanIterable iterable)
withoutAll
in interface MutableBooleanBag
withoutAll
in interface MutableBooleanCollection
public MutableBooleanBag asUnmodifiable()
asUnmodifiable
in interface MutableBooleanBag
asUnmodifiable
in interface MutableBooleanCollection
public MutableBooleanBag asSynchronized()
asSynchronized
in interface MutableBooleanBag
asSynchronized
in interface MutableBooleanCollection
public ImmutableBooleanBag toImmutable()
MutableBooleanBag
toImmutable
in interface BooleanBag
toImmutable
in interface MutableBooleanBag
toImmutable
in interface MutableBooleanCollection
public boolean contains(boolean value)
BooleanIterable
contains
in interface BooleanIterable
public boolean containsAll(boolean... source)
BooleanIterable
containsAll
in interface BooleanIterable
public boolean containsAll(BooleanIterable source)
BooleanIterable
containsAll
in interface BooleanIterable
public int occurrencesOf(boolean item)
BooleanBag
occurrencesOf
in interface BooleanBag
public void forEachWithOccurrences(BooleanIntProcedure procedure)
BooleanBag
forEachWithOccurrences
in interface BooleanBag
public boolean add(boolean item)
add
in interface MutableBooleanCollection
public boolean remove(boolean item)
remove
in interface MutableBooleanCollection
public boolean addAll(boolean... source)
addAll
in interface MutableBooleanCollection
public boolean addAll(BooleanIterable source)
addAll
in interface MutableBooleanCollection
public boolean removeAll(boolean... source)
removeAll
in interface MutableBooleanCollection
public boolean removeAll(BooleanIterable source)
removeAll
in interface MutableBooleanCollection
public boolean retainAll(BooleanIterable elements)
retainAll
in interface MutableBooleanCollection
Collection.retainAll(Collection)
public boolean retainAll(boolean... source)
retainAll
in interface MutableBooleanCollection
Collection.retainAll(Collection)
public void addOccurrences(boolean item, int occurrences)
addOccurrences
in interface MutableBooleanBag
public boolean removeOccurrences(boolean item, int occurrences)
removeOccurrences
in interface MutableBooleanBag
public void forEach(BooleanProcedure procedure)
BooleanIterable
forEach
in interface BooleanIterable
public void each(BooleanProcedure procedure)
BooleanIterable
each
in interface BooleanIterable
public MutableBooleanBag select(BooleanPredicate predicate)
BooleanIterable
select
in interface BooleanBag
select
in interface BooleanIterable
select
in interface MutableBooleanBag
select
in interface MutableBooleanCollection
public MutableBooleanBag selectByOccurrences(IntPredicate predicate)
MutableBooleanBag
selectByOccurrences
in interface BooleanBag
selectByOccurrences
in interface MutableBooleanBag
public MutableList<BooleanIntPair> topOccurrences(int count)
MutableBooleanBag
count
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.topOccurrences
in interface BooleanBag
topOccurrences
in interface MutableBooleanBag
public MutableList<BooleanIntPair> bottomOccurrences(int count)
MutableBooleanBag
count
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.bottomOccurrences
in interface BooleanBag
bottomOccurrences
in interface MutableBooleanBag
public MutableBooleanBag reject(BooleanPredicate predicate)
BooleanIterable
reject
in interface BooleanBag
reject
in interface BooleanIterable
reject
in interface MutableBooleanBag
reject
in interface MutableBooleanCollection
public <T> T injectInto(T injectedValue, ObjectBooleanToObjectFunction<? super T,? extends T> function)
injectInto
in interface BooleanIterable
public RichIterable<BooleanIterable> chunk(int size)
BooleanIterable
chunk
in interface BooleanIterable
size
- the number of elements per chunkRichIterable
containing BooleanIterable
s of size size
, except the last will be
truncated if the elements don't divide evenly.public boolean equals(Object otherBag)
BooleanBag
Bag.equals(Object)
.equals
in interface BooleanBag
equals
in class Object
public int hashCode()
BooleanBag
Bag.hashCode()
.hashCode
in interface BooleanBag
hashCode
in class Object
public String toString()
PrimitiveIterable
Assert.assertEquals("[]", IntLists.mutable.empty().toString()); Assert.assertEquals("[1]", IntLists.mutable.with(1).toString()); Assert.assertEquals("[1, 2, 3]", IntLists.mutable.with(1, 2, 3).toString());
toString
in interface PrimitiveIterable
toString
in class Object
AbstractCollection.toString()
public String makeString()
PrimitiveIterable
PrimitiveIterable.makeString(String)
and defaulting
the separator parameter to the characters ", "
(comma and space).makeString
in interface PrimitiveIterable
public String makeString(String separator)
PrimitiveIterable
PrimitiveIterable.makeString(String, String, String)
and defaulting the start and end parameters to ""
(the empty String).makeString
in interface PrimitiveIterable
public String makeString(String start, String separator, String end)
PrimitiveIterable
makeString
in interface PrimitiveIterable
public void appendString(Appendable appendable)
PrimitiveIterable
Appendable
. Prints the string returned
by PrimitiveIterable.makeString()
.appendString
in interface PrimitiveIterable
public void appendString(Appendable appendable, String separator)
PrimitiveIterable
Appendable
. Prints the string returned
by PrimitiveIterable.makeString(String)
.appendString
in interface PrimitiveIterable
public void appendString(Appendable appendable, String start, String separator, String end)
PrimitiveIterable
Appendable
. Prints the string returned
by PrimitiveIterable.makeString(String, String, String)
.appendString
in interface PrimitiveIterable
public int count(BooleanPredicate predicate)
BooleanIterable
count
in interface BooleanIterable
public boolean anySatisfy(BooleanPredicate predicate)
BooleanIterable
anySatisfy
in interface BooleanIterable
public boolean allSatisfy(BooleanPredicate predicate)
BooleanIterable
allSatisfy
in interface BooleanIterable
public boolean noneSatisfy(BooleanPredicate predicate)
BooleanIterable
noneSatisfy
in interface BooleanIterable
public boolean detectIfNone(BooleanPredicate predicate, boolean ifNone)
detectIfNone
in interface BooleanIterable
public <V> MutableBag<V> collect(BooleanToObjectFunction<? extends V> function)
BooleanIterable
collect
in interface BooleanBag
collect
in interface BooleanIterable
collect
in interface MutableBooleanBag
collect
in interface MutableBooleanCollection
public boolean[] toArray()
BooleanIterable
toArray
in interface BooleanIterable
public MutableBooleanList toList()
BooleanIterable
toList
in interface BooleanIterable
public MutableBooleanSet toSet()
BooleanIterable
toSet
in interface BooleanIterable
public MutableBooleanBag toBag()
BooleanIterable
toBag
in interface BooleanIterable
public LazyBooleanIterable asLazy()
BooleanIterable
asLazy
in interface BooleanIterable
public MutableBooleanIterator booleanIterator()
BooleanIterable
booleanIterator
in interface BooleanIterable
booleanIterator
in interface MutableBooleanCollection
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException
readExternal
in interface Externalizable
IOException
public MutableBooleanSet selectUnique()
MutableBooleanBag
selectUnique
in interface BooleanBag
selectUnique
in interface MutableBooleanBag
Copyright © 2004–2019. All rights reserved.