public class List<V> extends IList.Mixin<V> implements Cloneable
slice()
,
concat()
, and split()
are near-constant time.IList.Durable<V>, IList.Mixin<V>
Modifier and Type | Field and Description |
---|---|
static List |
EMPTY |
Object[] |
prefix |
Object[] |
suffix |
hash
Modifier | Constructor and Description |
---|---|
|
List() |
protected |
List(boolean linear,
io.lacuna.bifurcan.nodes.ListNodes.Node root,
int prefixLen,
Object[] prefix,
int suffixLen,
Object[] suffix) |
Modifier and Type | Method and Description |
---|---|
List<V> |
addFirst(V value) |
List<V> |
addLast(V value) |
List<V> |
clone() |
IList<V> |
concat(IList<V> l) |
static <V> List<V> |
empty() |
List<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> List<V> |
from(IList<V> list) |
static <V> List<V> |
from(Iterable<V> iterable) |
static <V> List<V> |
from(Iterator<V> iterator) |
boolean |
isLinear() |
Iterator<V> |
iterator() |
List<V> |
linear()
This returns a data structure which is linear, or temporarily mutable.
|
V |
nth(long idx) |
static <V> List<V> |
of(V... elements) |
List<V> |
removeFirst() |
List<V> |
removeLast() |
List<V> |
set(long idx,
V value) |
long |
size() |
List<V> |
slice(long start,
long end) |
equals, hashCode, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
diff, equals, first, iterator, last, save, split, spliterator, stream, toArray, toArray, toList, update
nth
public static final List EMPTY
public Object[] prefix
public Object[] suffix
public static <V> List<V> of(V... elements)
public static <V> List<V> empty()
public V nth(long idx)
nth
in interface ICollection<IList<V>,V>
idx
public long size()
size
in interface ICollection<IList<V>,V>
public boolean isLinear()
public List<V> removeLast()
removeLast
in interface IList<V>
public List<V> removeFirst()
removeFirst
in interface IList<V>
public List<V> set(long idx, V value)
set
in interface IList<V>
idx
overwritten with value
. If idx
is equal to
ICollection.size()
, the value is appended.public List<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 List<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<V> clone()
clone
in interface ICollection<IList<V>,V>
clone
in class IList.Mixin<V>