Package com.pnfsoftware.jeb.util.collect
Class FastLongSet
A (small) set of
long
values backed by a Bitmap
for fast insertion/retrieval and
zero allocation at run-time. The set range must not exceed 4G; the recommended max range
should not exceed a few thousands.-
Constructor Summary
ConstructorsConstructorDescriptionFastLongSet
(long end) Create a set for the range [0, end).FastLongSet
(long from, long to) Create a set.FastLongSet
(FastLongSet set0) Duplicate an existing set. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends Long> c) void
addAllFast
(FastLongSet other) Fast version ofaddAll(Collection)
.void
clear()
boolean
boolean
containsAll
(Collection<?> c) boolean
int
hashCode()
boolean
isEmpty()
iterator()
boolean
int
size()
toString()
Methods inherited from class java.util.AbstractSet
removeAll
Methods inherited from class java.util.AbstractCollection
retainAll, toArray, toArray
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
retainAll, spliterator, toArray, toArray
-
Constructor Details
-
FastLongSet
public FastLongSet(long from, long to) Create a set.- Parameters:
from
- range start (inclusive)to
- range end (exclusive)
-
FastLongSet
public FastLongSet(long end) Create a set for the range [0, end).- Parameters:
end
- range end (exclusive)
-
FastLongSet
Duplicate an existing set.- Parameters:
set0
- source set
-
-
Method Details
-
size
public int size()- Specified by:
size
in interfaceCollection<Long>
- Specified by:
size
in interfaceSet<Long>
- Specified by:
size
in classAbstractCollection<Long>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<Long>
- Specified by:
isEmpty
in interfaceSet<Long>
- Overrides:
isEmpty
in classAbstractCollection<Long>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<Long>
- Specified by:
clear
in interfaceSet<Long>
- Overrides:
clear
in classAbstractCollection<Long>
-
add
- Specified by:
add
in interfaceCollection<Long>
- Specified by:
add
in interfaceSet<Long>
- Overrides:
add
in classAbstractCollection<Long>
-
remove
- Specified by:
remove
in interfaceCollection<Long>
- Specified by:
remove
in interfaceSet<Long>
- Overrides:
remove
in classAbstractCollection<Long>
-
contains
- Specified by:
contains
in interfaceCollection<Long>
- Specified by:
contains
in interfaceSet<Long>
- Overrides:
contains
in classAbstractCollection<Long>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<Long>
- Specified by:
containsAll
in interfaceSet<Long>
- Overrides:
containsAll
in classAbstractCollection<Long>
-
addAll
- Specified by:
addAll
in interfaceCollection<Long>
- Specified by:
addAll
in interfaceSet<Long>
- Overrides:
addAll
in classAbstractCollection<Long>
-
addAllFast
Fast version ofaddAll(Collection)
. Restrictions: the input collection must be aFastLongSet
of the exact range.- Parameters:
other
-
-
iterator
-
toString
- Overrides:
toString
in classAbstractCollection<Long>
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection<Long>
- Specified by:
hashCode
in interfaceSet<Long>
- Overrides:
hashCode
in classAbstractSet<Long>
-
equals
- Specified by:
equals
in interfaceCollection<Long>
- Specified by:
equals
in interfaceSet<Long>
- Overrides:
equals
in classAbstractSet<Long>
-