public class LinearSet<V> extends ISet.Mixin<V>
LinearMap
, and shares the same performance characteristics.ISet.Durable<V>, ISet.Mixin<V>
hash
Constructor and Description |
---|
LinearSet() |
LinearSet(int initialCapacity) |
LinearSet(int initialCapacity,
ToLongFunction<V> hashFn,
BiPredicate<V,V> equalsFn) |
LinearSet(ToLongFunction<V> hashFn,
BiPredicate<V,V> equalsFn) |
Modifier and Type | Method and Description |
---|---|
LinearSet<V> |
add(V value) |
LinearSet<V> |
clear() |
LinearSet<V> |
clone() |
boolean |
contains(V value) |
LinearSet<V> |
difference(ISet<V> s) |
ISet<V> |
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> |
from(Collection<V> collection) |
static <V> LinearSet<V> |
from(IList<V> list) |
static <V> LinearSet<V> |
from(ISet<V> set) |
static <V> LinearSet<V> |
from(Iterable<V> iterable) |
static <V> LinearSet<V> |
from(Iterator<V> iterator) |
int |
hashCode() |
OptionalLong |
indexOf(V element) |
LinearSet<V> |
intersection(ISet<V> s) |
boolean |
isLinear() |
Iterator<V> |
iterator() |
LinearSet<V> |
linear()
This returns a data structure which is linear, or temporarily mutable.
|
V |
nth(long idx) |
static <V> LinearSet<V> |
of(V... elements) |
LinearSet<V> |
remove(V value) |
long |
size() |
List<LinearSet<V>> |
split(int parts)
Splits the collection into roughly even pieces, for parallel processing.
|
LinearSet<V> |
union(ISet<V> s) |
BiPredicate<V,V> |
valueEquality() |
ToLongFunction<V> |
valueHash() |
<U> LinearMap<V,U> |
zip(Function<V,U> f) |
equals, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
containsAll, containsAll, containsAny, containsAny, diff, elements, iterator, sliceIndices, spliterator, stream, test, toArray, toArray, toSet
nth, save
public LinearSet()
public LinearSet(int initialCapacity)
initialCapacity
- the initial capacity of the setpublic LinearSet(int initialCapacity, ToLongFunction<V> hashFn, BiPredicate<V,V> equalsFn)
initialCapacity
- the initial capacity of the sethashFn
- the hash function used by the setequalsFn
- the equality semantics used by the setpublic LinearSet(ToLongFunction<V> hashFn, BiPredicate<V,V> equalsFn)
hashFn
- the hash function used by the setequalsFn
- the equality semantics used by the setpublic static <V> LinearSet<V> from(IList<V> list)
list
public static <V> LinearSet<V> from(Collection<V> collection)
collection
public static <V> LinearSet<V> from(Iterator<V> iterator)
iterator
public static <V> LinearSet<V> from(Iterable<V> iterable)
iterable
public static <V> LinearSet<V> from(ISet<V> set)
set
, with the same equality semanticspublic static <V> LinearSet<V> of(V... elements)
elements
public boolean isLinear()
public ToLongFunction<V> valueHash()
public BiPredicate<V,V> valueEquality()
public boolean contains(V value)
value
public long size()
public OptionalLong indexOf(V element)
element
in the collection, if it's presentpublic V nth(long idx)
idx
public <U> LinearMap<V,U> zip(Function<V,U> f)
f
, for each element in the setpublic LinearSet<V> difference(ISet<V> s)
set
public LinearSet<V> intersection(ISet<V> s)
set
public ISet<V> forked()
ICollection
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.
public LinearSet<V> linear()
ICollection
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.
public List<LinearSet<V>> split(int parts)
ICollection
parts
subsets.parts
- the target number of piecespublic int hashCode()
hashCode
in class ISet.Mixin<V>
public LinearSet<V> clone()
clone
in interface ICollection<ISet<V>,V>
clone
in class ISet.Mixin<V>