Class LinearSet<V>
java.lang.Object
io.lacuna.bifurcan.ISet.Mixin<V>
io.lacuna.bifurcan.LinearSet<V>
- All Implemented Interfaces:
ICollection<ISet<V>,
,V> ISet<V>
,Iterable<V>
,Predicate<V>
A set which builds atop
LinearMap
, and shares the same performance characteristics.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.lacuna.bifurcan.ISet
ISet.Mixin<V>
-
Field Summary
Fields inherited from class io.lacuna.bifurcan.ISet.Mixin
hash
-
Constructor Summary
ConstructorsConstructorDescriptionLinearSet
(int initialCapacity) LinearSet
(int initialCapacity, ToLongFunction<V> hashFn, BiPredicate<V, V> equalsFn) LinearSet
(ToLongFunction<V> hashFn, BiPredicate<V, V> equalsFn) -
Method Summary
Modifier and TypeMethodDescriptionclear()
clone()
boolean
difference
(ISet<V> s) forked()
This returns a data structure which is forked, which is equivalent to Clojure's persistent data structures, also sometimes called functional or immutable.static <V> LinearSet
<V> static <V> LinearSet
<V> static <V> LinearSet
<V> static <V> LinearSet
<V> from
(Collection<V> collection) static <V> LinearSet
<V> int
hashCode()
intersection
(ISet<V> s) boolean
isLinear()
iterator()
linear()
This returns a data structure which is linear, or temporarily mutable.nth
(long idx) static <V> LinearSet
<V> of
(V... elements) long
size()
split
(int parts) Splits the collection into roughly even pieces, for parallel processing.Methods inherited from class io.lacuna.bifurcan.ISet.Mixin
equals, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.lacuna.bifurcan.ICollection
nth
Methods inherited from interface io.lacuna.bifurcan.ISet
containsAll, containsAll, containsAny, containsAny, elements, iterator, sliceIndices, spliterator, stream, test, toArray, toArray, toSet
-
Constructor Details
-
LinearSet
public LinearSet() -
LinearSet
public LinearSet(int initialCapacity) - Parameters:
initialCapacity
- the initial capacity of the set
-
LinearSet
- Parameters:
initialCapacity
- the initial capacity of the sethashFn
- the hash function used by the setequalsFn
- the equality semantics used by the set
-
LinearSet
- Parameters:
hashFn
- the hash function used by the setequalsFn
- the equality semantics used by the set
-
-
Method Details
-
from
-
from
- Returns:
- a set containing the elements in
collection
-
from
-
from
-
from
-
of
- Returns:
- a set containing
elements
-
isLinear
public boolean isLinear()- Returns:
- true, if the set is linear
-
valueHash
- Returns:
- the hash function used by the set
-
valueEquality
- Returns:
- the equality semantics used by the set
-
add
-
remove
-
clear
-
contains
- Returns:
- true, if the set contains
value
-
size
public long size()- Returns:
- the number of elements in the collection
-
indexOf
- Returns:
- the position of
element
in the collection, if it's present
-
nth
- Returns:
- the element at
idx
-
iterator
-
zip
-
union
-
difference
-
intersection
-
forked
Description copied from interface:ICollection
This returns a data structure which is forked, which is equivalent to Clojure's persistent data structures, also sometimes called functional or immutable. This is called "forked" because it means that multiple functions can make divergent changes to the data structure without affecting each other.If only a single function or scope uses the data structure, it can be left as a linear data structure, which can have significant performance benefits.
If the data structure is already forked, it will simply return itself.
- Returns:
- a forked form of the data structure
-
linear
Description copied from interface:ICollection
This returns a data structure which is linear, or temporarily mutable. The term "linear", as used here, does not completely align with the formal definition of linear types as used in type theory. It is meant to describe the linear dataflow of the method calls, and as a converse to "forked" data structures.If
ICollection.forked()
is called on a linear collection, all references to that linear collection should be discarded.If the data structure is already linear, it will simply return itself.
- Returns:
- a linear form of this data structure
-
split
Description copied from interface:ICollection
Splits the collection into roughly even pieces, for parallel processing. Depending on the size and contents of the collection, this function may not return exactlyparts
subsets.- Parameters:
parts
- the target number of pieces- Returns:
- a list containing subsets of the collection.
-
hashCode
public int hashCode()- Overrides:
hashCode
in classISet.Mixin<V>
-
clone
- Specified by:
clone
in interfaceICollection<ISet<V>,
V> - Overrides:
clone
in classISet.Mixin<V>
- Returns:
- a cloned copy of the collection
-