Yaaf.FSharp.Helper


RandomAccessList<'T>

Defined in Yaaf.FSharp.Helper.dll.

RandomAccessList is an ordered linear structure implementing the List signature (head, tail, cons), as well as inspection (lookup) and update (returning a new immutable instance) of any element in the structure by index. Length is O(1). Indexed lookup or update (returning a new immutable instance of RandomAccessList) of any element is O(log32n), which is close enough to O(1) as to make no practical difference: a RandomAccessList containing 4 billion items can lookup or update any item in at most 7 steps. Ordering is by insertion history. While PersistentVector<'T> is appending to the end this version prepends elements to the list.

Instance members

Instance memberDescription
Cons(arg1)
Signature: 'T -> RandomAccessList<'T>

O(1). Returns a new random access list with the element added at the start.

Head
Signature: 'T

O(1). Returns the first element in the random access list. If the random access list is empty it throws an exception.

IsEmpty
Signature: bool

O(1). Returns true if the random access list has no elements.

[arg1]
Signature: int -> 'T

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

Length
Signature: int

O(1). Returns the number of items in the random access list.

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

O(n). Returns random access list reversed.

Tail
Signature: RandomAccessList<'T>

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

TryHead
Signature: 'T option

O(1). Returns option first element in the random access list.

TryTail
Signature: RandomAccessList<'T> option

O(1) for all practical purposes; really O(log32n). Returns option random access list without the first item.

TryUncons
Signature: ('T * RandomAccessList<'T>) option

O(1) for all practical purposes; really O(log32n). Returns option tuple first element and random access list without first item

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

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

Uncons
Signature: 'T * RandomAccessList<'T>

O(1) for all practical purposes; really O(log32n). Returns tuple first element and random access list without first item

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

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

Fork me on GitHub