Google is failing me here... I thought this would be a very simple Q&A, but I cannot find any previous discussion of the matter.
Is there a reason why the Java Trove4J library does not include boolean primitive collections? Example: TByteHashSet
exists, but TBooleanHashSet
does not.
As a workaround, I can declare two byte constants for true(1) and false(0), but it would be more convenient to have a boolean primitive collection.
Eclipse Collections has
BooleanSet
,BooleanList
,BooleanStack
,BooleanBag
and primitive maps with boolean as values. There are both Mutable and Immutable versions. You can find all subinterfaces ofBooleanIterable
here. Factory classes for the different primitive containers are here.Here's an example of creating a
MutableBooleanList
andImmutableBooleanList
using the BooleanLists factory.Note: I am a committer for Eclipse Collections.