Yaaf.FSharp.Helper


PersistentVector<'T>

Defined in Yaaf.FSharp.Helper.dll.

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](http://clojure.org/data_structures).

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.

IsEmpty
Signature: bool

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

[arg1]
Signature: int -> 'T

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

Last
Signature: 'T

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

Length
Signature: int

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

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.

TryLast
Signature: 'T option

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

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

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

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