fsprojects/FSharpx.Collections


RandomAccessList<'T>

Namespace: FSharpx.Collections

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.

CompiledName: get_Head

IsEmpty
Signature: bool

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

CompiledName: get_IsEmpty

[arg1]
Signature: int -> 'T

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

CompiledName: get_Item

Length
Signature: int

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

CompiledName: get_Length

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.

CompiledName: get_Tail

TryHead
Signature: 'T option

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

CompiledName: get_TryHead

TryTail
Signature: RandomAccessList<'T> option

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

CompiledName: get_TryTail

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

CompiledName: get_TryUncons

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

CompiledName: get_Uncons

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