Class List<V>
java.lang.Object
io.lacuna.bifurcan.IList.Mixin<V>
io.lacuna.bifurcan.List<V>
- All Implemented Interfaces:
ICollection<IList<V>,
,V> IList<V>
,Cloneable
,Iterable<V>
An implementation of an immutable list which allows for elements to be added and removed from both ends of the
collection, as well as random-access reads and writes. Due to its
relaxed radix structure,
slice()
,
concat()
, and split()
are near-constant time.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.lacuna.bifurcan.IList
IList.Mixin<V>
-
Field Summary
FieldsFields inherited from class io.lacuna.bifurcan.IList.Mixin
hash
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()
static <V> List
<V> empty()
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> static <V> List
<V> static <V> List
<V> boolean
isLinear()
iterator()
linear()
This returns a data structure which is linear, or temporarily mutable.nth
(long idx) static <V> List
<V> of
(V... elements) long
size()
slice
(long start, long end) Methods inherited from class io.lacuna.bifurcan.IList.Mixin
equals, hashCode, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.lacuna.bifurcan.ICollection
nth
-
Field Details
-
EMPTY
-
prefix
-
suffix
-
-
Constructor Details
-
List
public List() -
List
-
-
Method Details
-
of
-
from
-
from
-
from
-
empty
-
nth
-
size
public long size()- Specified by:
size
in interfaceICollection<IList<V>,
V> - Returns:
- the number of elements in the collection
-
isLinear
-
addLast
-
addFirst
-
removeLast
- Specified by:
removeLast
in interfaceIList<V>
- Returns:
- a new list with the last value removed, or the same list if already empty
-
removeFirst
- Specified by:
removeFirst
in interfaceIList<V>
- Returns:
- a new list with the first value removed, or the same value if already empty
-
set
-
iterator
-
slice
-
concat
-
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.
-
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.
-
clone
- Specified by:
clone
in interfaceICollection<IList<V>,
V> - Overrides:
clone
in classIList.Mixin<V>
- Returns:
- a cloned copy of the collection
-