API: ICollection
The ICollection
interface is the root of Bifurcan's collection hierarchy. It provides the core functionality shared by all collections.
Key Methods
C linear()
Returns a temporarily mutable (linear) version of the collection. If the collection is already linear, it returns itself. This is the key to performing efficient batch updates.
boolean isLinear()
Returns true
if the collection is currently in a linear (mutable) state.
C forked()
Returns an immutable (forked) version of the collection. If the collection is already forked, it returns itself. This should be called after a series of linear updates to make the collection safe for sharing.
IList<? extends C> split(int parts)
Splits the collection into a list of approximately parts
sub-collections. This is designed to facilitate parallel processing.
long size()
Returns the number of elements in the collection.
V nth(long idx)
Returns the element at the specified index. For unordered collections like maps and sets, the index corresponds to an element's position in an implicit, stable iteration order.
Iterator<V> iterator()
Returns an iterator over the elements in the collection.
C clone()
Returns a cloned copy of the collection. If the collection is linear, the clone will also be linear but with a separate identity.