Package io.permazen.core.util
Class ObjIdSet
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<ObjId>
,Collection<ObjId>
,Set<ObjId>
A set of
ObjId
s.
This implementation is space optimized for the 64-bits of information contained in an ObjId
.
Instances do not accept null values and are not thread safe.
- See Also:
-
Constructor Summary
-
Method Summary
Methods inherited from class java.util.AbstractSet
equals, removeAll
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toString
Methods inherited from class java.lang.Object
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
addAll, containsAll, retainAll, spliterator, toArray
-
Constructor Details
-
ObjIdSet
public ObjIdSet()Constructs an empty instance. -
ObjIdSet
public ObjIdSet(int capacity) Constructs an instance with the given initial capacity.- Parameters:
capacity
- initial capacity- Throws:
IllegalArgumentException
- ifcapacity
is negative
-
ObjIdSet
Constructs an instance initialized with the given ID's.- Parameters:
ids
- initial contents for this instance- Throws:
IllegalArgumentException
- ifids
is nullNullPointerException
- if any ID inids
is null
-
-
Method Details
-
removeOne
Remove a single, arbitraryObjId
from this instance and return it.- Returns:
- the removed
ObjId
, or null if this instance is empty
-
iterator
-
size
public int size()- Specified by:
size
in interfaceCollection<ObjId>
- Specified by:
size
in interfaceSet<ObjId>
- Specified by:
size
in classAbstractCollection<ObjId>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<ObjId>
- Specified by:
isEmpty
in interfaceSet<ObjId>
- Overrides:
isEmpty
in classAbstractCollection<ObjId>
-
contains
- Specified by:
contains
in interfaceCollection<ObjId>
- Specified by:
contains
in interfaceSet<ObjId>
- Overrides:
contains
in classAbstractCollection<ObjId>
-
add
- Specified by:
add
in interfaceCollection<ObjId>
- Specified by:
add
in interfaceSet<ObjId>
- Overrides:
add
in classAbstractCollection<ObjId>
-
remove
- Specified by:
remove
in interfaceCollection<ObjId>
- Specified by:
remove
in interfaceSet<ObjId>
- Overrides:
remove
in classAbstractCollection<ObjId>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<ObjId>
- Specified by:
clear
in interfaceSet<ObjId>
- Overrides:
clear
in classAbstractCollection<ObjId>
-
toArray
- Specified by:
toArray
in interfaceCollection<ObjId>
- Specified by:
toArray
in interfaceSet<ObjId>
- Overrides:
toArray
in classAbstractCollection<ObjId>
-
toLongArray
public long[] toLongArray() -
sortedSnapshot
Create a sorted, immutable snapshot of this instance.- Returns:
- sorted, immutable snapshot
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection<ObjId>
- Specified by:
hashCode
in interfaceSet<ObjId>
- Overrides:
hashCode
in classAbstractSet<ObjId>
-
clone
-