fsprojects/FSharpx.Collections


PersistentVector<'T>

Namespace: FSharpx.Collections

PersistentVector is an ordered linear structure implementing the inverse of the List signature, (last, initial, conj) in place of (head, tail, cons). Length is O(1). Indexed lookup or update (returning a new immutable instance of Vector) of any element is O(log32n), which is close enough to O(1) as to make no practical difference: a PersistentVector containing 4 billion items can lookup or update any item in at most 7 steps. Ordering is by insertion history. The original idea can be found in Clojure.

Instance members

Instance memberDescription
Conj(arg1)
Signature: 'T -> PersistentVector<'T>

O(1). Returns a new vector with the element added at the end.

Initial
Signature: PersistentVector<'T>

O(1) for all practical purposes; really O(log32n). Returns a new vector without the last item. If the collection is empty it throws an exception.

CompiledName: get_Initial

IsEmpty
Signature: bool

O(1). Returns true if the vector has no elements.

CompiledName: get_IsEmpty

[arg1]
Signature: int -> 'T

O(1) for all practical purposes; really O(log32n). Returns vector element at the index.

CompiledName: get_Item

Last
Signature: 'T

O(1). Returns the last element in the vector. If the vector is empty it throws an exception.

CompiledName: get_Last

Length
Signature: int

O(1). Returns the number of items in the vector.

CompiledName: get_Length

Rev()
Signature: unit -> PersistentVector<'T>

O(n). Returns random access list reversed.

TryInitial
Signature: PersistentVector<'T> option

O(1) for all practical purposes; really O(log32n). Returns option vector without the last item.

CompiledName: get_TryInitial

TryLast
Signature: 'T option

O(1). Returns option last element in the vector.

CompiledName: get_TryLast

TryUnconj
Signature: (PersistentVector<'T> * 'T) option

O(1) for all practical purposes; really O(log32n). Returns option tuple last element and vector without last item

CompiledName: get_TryUnconj

TryUpdate(arg1, arg2)
Signature: (int * 'T) -> PersistentVector<'T> option

O(1) for all practical purposes; really O(log32n). Returns option vector that contains the given value at the index.

Unconj
Signature: PersistentVector<'T> * 'T

O(1) for all practical purposes; really O(log32n). Returns tuple last element and vector without last item

CompiledName: get_Unconj

Update(arg1, arg2)
Signature: (int * 'T) -> PersistentVector<'T>

O(1) for all practical purposes; really O(log32n). Returns a new vector that contains the given value at the index.

Static members

Static memberDescription
Empty()
Signature: unit -> PersistentVector<'T>

O(1). Returns a new PersistentVector with no elements.

Fork me on GitHub