This a suite of very high-performance immutable-collections.
- For lists you should always prefer to use
Seq<A>
- it is about 10x faster thanLst<A>
. The only reason you'd pickLst<A>
is if you needed to do inserts into the middle of the list:Seq<A>
doesn't allow this (it only allows prepending or appending), as it would be a performance hit.Seq<A>
is backed by an array, and so it has exceptional memory locality,Lst<A>
is an AVL tree to allow for efficient
insertion, but suffers from poorer memory locality. - For 'dictionaries' or maps as we prefer to call them, then
HashMap
is the fastest implemention you'll find in .NET-land. It is unsorted. If you need a sorted dictionary, useMap
.HashMap
uses the CHAMP data-structure,Map
uses an AVL tree. - The same goes for sets, prefer
HashSet
overSet
, unless you need the set to be sorted.
You can construct the collection types using the constrctor functions in the Prelude
:
HashMap<string, int> hashSet = HashMap(("a", 1), ("b", 2), ("c", 3));
HashSet<int> hashMap = HashSet(1, 2, 3);
Map<string, int> hashSet = Map(("a", 1), ("b", 2), ("c", 3));
Set<int> hashMap = Set(1, 2, 3);
Seq<int> list = Seq(1, 2, 3);
Lst<int> list = List(1, 2, 3);
- Prelude
- Empty = new()
- Cons <A> (this A head)
- Cons <A> (this A head, SeqEmpty empty)
- Cons <A> (this A head, Seq<A> tail)
- Cons <A> (this A head, A[] tail)
- Cons <A> (this A head, Arr<A> tail)
- Cons <A> (this A head, IEnumerable<A> tail)
- Cons <A> (this A head, Lst<A> tail)
- Sort <OrdA, A> (this IEnumerable<A> xs)
- Sort <OrdA, A> (this Seq<A> xs)
- Sort <OrdA, A> (this Lst<A> xs)
- Sort <OrdA, A> (this Arr<A> xs)
- Sort <OrdA, A> (this A[] xs)
- Naturals
- LongNaturals
- Range (long from, long count, long step = 1)
- Range (int from, int count, int step = 1)
- Range (char from, char to)
- Map <K, V> ()
- Map <K, V> ((K, V) head, params (K, V)[] tail)
- toMap <K, V> (IEnumerable<(K, V)> items)
- toMap <K, V> (ReadOnlySpan<(K, V)> items)
- Map <OrdK, K, V> ()
- Map <OrdK, K, V> ((K, V) head, params (K, V)[] tail)
- toMap <OrdK, K, V> (IEnumerable<(K, V)> items)
- toMap <OrdK, K, V> (ReadOnlySpan<(K, V)> items)
- HashMap <K, V> ()
- HashMap <K, V> ((K, V) head, params (K, V)[] tail)
- toHashMap <K, V> (IEnumerable<(K, V)> items)
- toHashMap <K, V> (ReadOnlySpan<(K, V)> items)
- HashMap <EqK, K, V> ()
- HashMap <EqK, K, V> ((K, V) head, params (K, V)[] tail)
- toHashMap <EqK, K, V> (IEnumerable<(K, V)> items)
- toHashMap <EqK, K, V> (ReadOnlySpan<(K, V)> items)
- TrackingHashMap <K, V> ()
- TrackingHashMap <K, V> ((K, V) head, params (K, V)[] tail)
- toTrackingHashMap <K, V> (IEnumerable<(K, V)> items)
- toTrackingHashMap <K, V> (ReadOnlySpan<(K, V)> items)
- TrackingHashMap <EqK, K, V> ()
- TrackingHashMap <EqK, K, V> ((K, V) head, params (K, V)[] tail)
- toTrackingHashMap <EqK, K, V> (IEnumerable<(K, V)> items)
- toTrackingHashMap <EqK, K, V> (ReadOnlySpan<(K, V)> items)
- AtomHashMap <K, V> ()
- AtomHashMap <K, V> ((K, V) head, params (K, V)[] tail)
- AtomHashMap <K, V> (HashMap<K, V> items)
- toAtomHashMap <K, V> (IEnumerable<(K, V)> items)
- toAtomHashMap <K, V> (ReadOnlySpan<(K, V)> items)
- AtomHashMap <EqK, K, V> ()
- AtomHashMap <EqK, K, V> ((K, V) head, params (K, V)[] tail)
- AtomHashMap <EqK, K, V> (HashMap<EqK, K, V> items)
- toAtomHashMap <EqK, K, V> (IEnumerable<(K, V)> items)
- toAtomHashMap <EqK, K, V> (ReadOnlySpan<(K, V)> items)
- List <T> ()
- List <T> (T x, params T[] xs)
- toList <T> (Arr<T> items)
- toList <T> (IEnumerable<T> items)
- toList <T> (ReadOnlySpan<T> items)
- Array <T> ()
- Array <T> (T x, params T[] xs)
- toArray <T> (IEnumerable<T> items)
- toArray <T> (ReadOnlySpan<T> items)
- Queue <T> ()
- Queue <T> (params T[] items)
- toQueue <T> (IEnumerable<T> items)
- toQueue <T> (ReadOnlySpan<T> items)
- Stack <T> ()
- Stack <T> (params T[] items)
- toStack <T> (IEnumerable<T> items)
- toStackRev <T> (IEnumerable<T> items)
- toMapUpdate <K, V> (IEnumerable<(K, V)> keyValues)
- toMapUpdate <K, V> (ReadOnlySpan<(K, V)> keyValues)
- toMapTry <K, V> (IEnumerable<(K, V)> keyValues)
- toMapTry <K, V> (ReadOnlySpan<(K, V)> keyValues)
- Set <T> ()
- Set <T> (T head, params T[] tail)
- toSet <T> (IEnumerable<T> items)
- toSet <T> (ReadOnlySpan<T> items)
- Set <OrdT, T> ()
- Set <OrdT, T> (T head, params T[] tail)
- toSet <OrdT, T> (IEnumerable<T> items)
- toSet <OrdT, T> (ReadOnlySpan<T> items)
- HashSet <T> ()
- HashSet <T> (T head, params T[] tail)
- toHashSet <T> (IEnumerable<T> items)
- toHashSet <T> (ReadOnlySpan<T> items)
- HashSet <EqT, T> ()
- HashSet <EqT, T> (T head, params T[] tail)
- toHashSet <EqT, T> (IEnumerable<T> items)
- toHashSet <EqT, T> (ReadOnlySpan<T> items)
- Query <T> (params T[] items)
- toQuery <T> (IEnumerable<T> items)
- match <A, B> (IEnumerable<A> list, Func<B> Empty, Func<Seq<A>, B> More)
- match <A, B> (IEnumerable<A> list, Func<B> Empty, Func<A, Seq<A>, B> More)
- match <T, R> (IEnumerable<T> list, Func<R> Empty, Func<T, R> One, Func<T, Seq<T>, R> More)
- match <K, V, R> (Map<K, V> map, K key, Func<V, R> Some, Func<R> None)
- match <K, V> (Map<K, V> map, K key, Action<V> Some, Action None)
- match <K, V, R> (HashMap<K, V> map, K key, Func<V, R> Some, Func<R> None)
- match <K, V> (HashMap<K, V> map, K key, Action<V> Some, Action None)
- Iterable <A> ()
- Iterable <A> (ReadOnlySpan<A> value)
- Iterable <A> (A fst, A snd, params A[] rest)
- Iterable <A> (IEnumerable<A>? value)
- Seq <A> ()
- Seq1 <A> (A value)
- Seq <A> (A value)
- Seq <A> (A a, A b)
- Seq <A> (A a, A b, A c)
- Seq <A> (A a, A b, A c, A d)
- Seq <A> (A a, A b, A c, A d, A e)
- Seq <A> (A a, A b, A c, A d, A e, A f)
- Seq <A> (A a, A b, A c, A d, A e, A f, A g)
- Seq <A> (A a, A b, A c, A d, A e, A f, A g, A h)
- Seq <A> (A a, A b, A c, A d, A e, A f, A g, A h, params A[] tail)
- Seq <A> (ReadOnlySpan<A> value)
- Seq <A> (IEnumerable<A>? value)
- toSeq <A> (IEnumerable<A>? value)
- toSeq <A> (A? value)
- toSeq <A> (A[]? value)
- toSeq <A> (Arr<A> value)
- toSeq <A> (IList<A>? value)
- toSeq <A> (ICollection<A>? value)
- toSeq <L, R> (Either<L, R> value)
- toSeq <A> (ValueTuple<A> tup)
- toSeq <A> (ValueTuple<A, A> tup)
- toSeq <A> (ValueTuple<A, A, A> tup)
- toSeq <A> (ValueTuple<A, A, A, A> tup)
- toSeq <A> (ValueTuple<A, A, A, A, A> tup)
- toSeq <A> (ValueTuple<A, A, A, A, A, A> tup)
- toSeq <A> (ValueTuple<A, A, A, A, A, A, A> tup)
- AtomSeq <A> ()
- AtomSeq <A> (params A[] items)
- AtomSeq <A> (Seq<A> items)
- AtomSeq <A> (IEnumerable<A> items)
- Diff <EqA, A> (this IEnumerable<A> va, IEnumerable<A> vb)
- Apply <EqA, A> (this IEnumerable<A> va, Patch<EqA, A> patch)
- Apply <EqA, A> (this Lst<A> va, Patch<EqA, A> patch)
- Apply <EqA, A> (this Seq<A> va, Patch<EqA, A> patch)
- Apply <EqA, A> (this SpanArray<A> va, Patch<EqA, A> patch)
- Apply <EqA, A> (this A[] va, Patch<EqA, A> patch)
- Apply <EqA, A> (this Arr<A> va, Patch<EqA, A> patch)
- Apply <EqA, A> (this List<A> va, Patch<EqA, A> patch)
- Applicable <EqA, A> (this IEnumerable<A> va, Patch<EqA, A> patch)
Sub modules
Arr |
BiMap |
HashMap |
HashSet |
Iterable |
List |
Map |
Queue |
Seq |
Set |
Stack |
TrackingHashMap |
TrieMap |
TrieSet |
field SeqEmpty Empty = new() Source #
Represents an empty sequence
property Iterable<long> LongNaturals Source #
Lazy sequence of natural numbers up to Int64.MaxValue
method Seq<A> Cons <A> (this A head) Source #
Construct a sequence from any value
type | A | Type of the items in the sequence |
param | head | Head item in the sequence |
returns |
method Seq<A> Cons <A> (this A head, SeqEmpty empty) Source #
Construct a sequence from any value
type | A | Type of the items in the sequence |
param | head | Head item in the sequence |
returns |
method Seq<A> Cons <A> (this A head, Seq<A> tail) Source #
Construct a list from head and tail; head becomes the first item in the list.
type | A | Type of the items in the sequence |
param | head | Head item in the sequence |
param | tail | Tail of the sequence |
returns |
method Seq<A> Cons <A> (this A head, A[] tail) Source #
Construct a list from head and tail; head becomes the first item in the list.
type | A | Type of the items in the sequence |
param | head | Head item in the sequence |
param | tail | Tail of the sequence |
returns |
method Seq<A> Cons <A> (this A head, Arr<A> tail) Source #
Construct a list from head and tail; head becomes the first item in the list.
type | A | Type of the items in the sequence |
param | head | Head item in the sequence |
param | tail | Tail of the sequence |
returns |
method Seq<A> Cons <A> (this A head, IEnumerable<A> tail) Source #
Construct a list from head and tail; head becomes the first item in the list.
type | A | Type of the items in the sequence |
param | head | Head item in the sequence |
param | tail | Tail of the sequence |
returns |
method Lst<A> Cons <A> (this A head, Lst<A> tail) Source #
Construct a list from head and tail; head becomes the first item in the list.
type | A | Type of the items in the sequence |
param | head | Head item in the sequence |
param | tail | Tail of the sequence |
returns |
method IEnumerable<A> Sort <OrdA, A> (this IEnumerable<A> xs) Source #
Provide a sorted enumerable
method Range<long> Range (long from, long count, long step = 1) Source #
Lazily generate a range of integers.
method Range<int> Range (int from, int count, int step = 1) Source #
Lazily generate a range of integers.
method Range<char> Range (char from, char to) Source #
Lazily generate a range of chars.
Remarks: Can go in a positive direction ('a'..'z') as well as negative ('z'..'a')
method Map<OrdK, K, V> Map <OrdK, K, V> ((K, V) head, params (K, V)[] tail) Source #
Create an immutable map
method Map<OrdK, K, V> toMap <OrdK, K, V> (IEnumerable<(K, V)> items) Source #
Create an immutable map
method Map<OrdK, K, V> toMap <OrdK, K, V> (ReadOnlySpan<(K, V)> items) Source #
Create an immutable map
method HashMap<K, V> HashMap <K, V> ((K, V) head, params (K, V)[] tail) Source #
Create an immutable hash-map
method HashMap<K, V> toHashMap <K, V> (IEnumerable<(K, V)> items) Source #
Create an immutable hash-map
method HashMap<K, V> toHashMap <K, V> (ReadOnlySpan<(K, V)> items) Source #
Create an immutable hash-map
method HashMap<EqK, K, V> HashMap <EqK, K, V> () Source #
Create an immutable hash-map
method HashMap<EqK, K, V> HashMap <EqK, K, V> ((K, V) head, params (K, V)[] tail) Source #
Create an immutable hash-map
method HashMap<EqK, K, V> toHashMap <EqK, K, V> (IEnumerable<(K, V)> items) Source #
Create an immutable hash-map
method HashMap<EqK, K, V> toHashMap <EqK, K, V> (ReadOnlySpan<(K, V)> items) Source #
Create an immutable hash-map
method TrackingHashMap<K, V> TrackingHashMap <K, V> () Source #
Create an immutable tracking hash-map
method TrackingHashMap<K, V> TrackingHashMap <K, V> ((K, V) head, params (K, V)[] tail) Source #
Create an immutable tracking hash-map
method TrackingHashMap<K, V> toTrackingHashMap <K, V> (IEnumerable<(K, V)> items) Source #
Create an immutable tracking hash-map
method TrackingHashMap<K, V> toTrackingHashMap <K, V> (ReadOnlySpan<(K, V)> items) Source #
Create an immutable tracking hash-map
method TrackingHashMap<EqK, K, V> TrackingHashMap <EqK, K, V> () Source #
Create an immutable tracking hash-map
method TrackingHashMap<EqK, K, V> TrackingHashMap <EqK, K, V> ((K, V) head, params (K, V)[] tail) Source #
Create an immutable tracking hash-map
method TrackingHashMap<EqK, K, V> toTrackingHashMap <EqK, K, V> (IEnumerable<(K, V)> items) Source #
Create an immutable tracking hash-map
method TrackingHashMap<EqK, K, V> toTrackingHashMap <EqK, K, V> (ReadOnlySpan<(K, V)> items) Source #
Create an immutable tracking hash-map
method AtomHashMap<K, V> AtomHashMap <K, V> () Source #
Create an immutable hash-map
method AtomHashMap<K, V> AtomHashMap <K, V> ((K, V) head, params (K, V)[] tail) Source #
Create an immutable hash-map
method AtomHashMap<K, V> AtomHashMap <K, V> (HashMap<K, V> items) Source #
Create an immutable hash-map
method AtomHashMap<K, V> toAtomHashMap <K, V> (IEnumerable<(K, V)> items) Source #
Create an immutable hash-map
method AtomHashMap<K, V> toAtomHashMap <K, V> (ReadOnlySpan<(K, V)> items) Source #
Create an immutable hash-map
method AtomHashMap<EqK, K, V> AtomHashMap <EqK, K, V> () Source #
Create an immutable hash-map
method AtomHashMap<EqK, K, V> AtomHashMap <EqK, K, V> ((K, V) head, params (K, V)[] tail) Source #
Create an immutable hash-map
method AtomHashMap<EqK, K, V> AtomHashMap <EqK, K, V> (HashMap<EqK, K, V> items) Source #
Create an immutable hash-map
method AtomHashMap<EqK, K, V> toAtomHashMap <EqK, K, V> (IEnumerable<(K, V)> items) Source #
Create an immutable hash-map
method AtomHashMap<EqK, K, V> toAtomHashMap <EqK, K, V> (ReadOnlySpan<(K, V)> items) Source #
Create an immutable hash-map
method Stck<T> toStackRev <T> (IEnumerable<T> items) Source #
Create an immutable stack
method Map<K, V> toMapUpdate <K, V> (IEnumerable<(K, V)> keyValues) Source #
Create an immutable map, updating duplicates so that the final value of any key is retained
method Map<K, V> toMapUpdate <K, V> (ReadOnlySpan<(K, V)> keyValues) Source #
Create an immutable map, updating duplicates so that the final value of any key is retained
method Map<K, V> toMapTry <K, V> (IEnumerable<(K, V)> keyValues) Source #
Create an immutable map, ignoring duplicates so the first value of any key is retained
method Map<K, V> toMapTry <K, V> (ReadOnlySpan<(K, V)> keyValues) Source #
Create an immutable map, ignoring duplicates so the first value of any key is retained
method Set<OrdT, T> Set <OrdT, T> (T head, params T[] tail) Source #
Create an immutable set
method Set<OrdT, T> toSet <OrdT, T> (IEnumerable<T> items) Source #
Create an immutable set
method Set<OrdT, T> toSet <OrdT, T> (ReadOnlySpan<T> items) Source #
Create an immutable set
method HashSet<EqT, T> HashSet <EqT, T> (T head, params T[] tail) Source #
Create an immutable hash-set
method HashSet<EqT, T> toHashSet <EqT, T> (IEnumerable<T> items) Source #
Create an immutable hash-set
method HashSet<EqT, T> toHashSet <EqT, T> (ReadOnlySpan<T> items) Source #
Create an immutable hash-set
method B match <A, B> (IEnumerable<A> list, Func<B> Empty, Func<Seq<A>, B> More) Source #
Match empty list, or multi-item list
type | B | Return value type |
param | Empty | Match for an empty list |
param | More | Match for a non-empty |
returns | Result of match function invoked |
method B match <A, B> (IEnumerable<A> list, Func<B> Empty, Func<A, Seq<A>, B> More) Source #
List pattern matching
method R match <T, R> (IEnumerable<T> list, Func<R> Empty, Func<T, R> One, Func<T, Seq<T>, R> More) Source #
List pattern matching
method Iterable<A> Iterable <A> (ReadOnlySpan<A> value) Source #
Construct a sequence from an Enumerable
method Iterable<A> Iterable <A> (A fst, A snd, params A[] rest) Source #
Construct a sequence from an Enumerable
method Iterable<A> Iterable <A> (IEnumerable<A>? value) Source #
Construct a sequence from an Enumerable
Deals with value == null
by returning []
and also memoizes the
items in the enumerable as they're being consumed.
method Seq<A> Seq <A> (A value) Source #
Construct a singleton sequence from any value
var list = Seq(1);
method Seq<A> Seq <A> (A a, A b, A c) Source #
Construct a sequence from any value
var list = Seq(1, 2, 3);
method Seq<A> Seq <A> (A a, A b, A c, A d) Source #
Construct a sequence from any value
var list = Seq(1, 2, 3, 4);
method Seq<A> Seq <A> (A a, A b, A c, A d, A e) Source #
Construct a sequence from any value
var list = Seq(1, 2, 3, 4, 5);
method Seq<A> Seq <A> (A a, A b, A c, A d, A e, A f) Source #
Construct a sequence from any value
var list = Seq(1, 2, 3, 4, 5, 6);
method Seq<A> Seq <A> (A a, A b, A c, A d, A e, A f, A g) Source #
Construct a sequence from any value
var list = Seq(1, 2, 3, 4, 5, 6, 7);
method Seq<A> Seq <A> (A a, A b, A c, A d, A e, A f, A g, A h) Source #
Construct a sequence from any value
var list = Seq(1, 2, 3, 4, 5, 6, 7, 8);
method Seq<A> Seq <A> (A a, A b, A c, A d, A e, A f, A g, A h, params A[] tail) Source #
Construct a sequence from any value
var list = Seq(1, 2, 3, 4);
method Seq<A> Seq <A> (ReadOnlySpan<A> value) Source #
Construct a sequence from an Enumerable
Deals with value == null
by returning []
and also memoizes the
items in the enumerable as they're being consumed.
method Seq<A> Seq <A> (IEnumerable<A>? value) Source #
Construct a sequence from an Enumerable
Deals with value == null
by returning []
and also memoizes the
items in the enumerable as they're being consumed.
method Seq<A> toSeq <A> (IEnumerable<A>? value) Source #
Construct a sequence from an Enumerable
Deals with value == null
by returning []
and also memoizes the
items in the enumerable as they're being consumed.
method Seq<A> toSeq <A> (A? value) Source #
Construct a sequence from a nullable HasValue == true : [x] HasValue == false : []
method Seq<R> toSeq <L, R> (Either<L, R> value) Source #
Construct a sequence from an either Right(x) : [x] Left(y) : []
method Seq<A> toSeq <A> (ValueTuple<A, A, A, A, A, A> tup) Source #
Construct a sequence from a tuple
method Seq<A> toSeq <A> (ValueTuple<A, A, A, A, A, A, A> tup) Source #
Construct a sequence from a tuple
method Patch<EqA, A> Diff <EqA, A> (this IEnumerable<A> va, IEnumerable<A> vb) Source #
Compute the difference between two documents, using the Wagner-Fischer algorithm. O(mn) time and space.
apply(diff(d,e), d) == e
diff(d, d) == Patch.empty
apply(diff(d, e), d) == apply(inverse(diff(e, d)), d)
apply(append(diff(a, b), diff(b, c), a) == apply(diff(a, c), a)
applicable(diff(a, b) a)
method IEnumerable<A> Apply <EqA, A> (this IEnumerable<A> va, Patch<EqA, A> patch) Source #
Apply the supplied patch to this collection
method Lst<A> Apply <EqA, A> (this Lst<A> va, Patch<EqA, A> patch) Source #
Apply the supplied patch to this collection
method Seq<A> Apply <EqA, A> (this Seq<A> va, Patch<EqA, A> patch) Source #
Apply the supplied patch to this collection
method SpanArray<A> Apply <EqA, A> (this SpanArray<A> va, Patch<EqA, A> patch) Source #
Apply the supplied patch to this collection
method A[] Apply <EqA, A> (this A[] va, Patch<EqA, A> patch) Source #
Apply the supplied patch to this collection
method Arr<A> Apply <EqA, A> (this Arr<A> va, Patch<EqA, A> patch) Source #
Apply the supplied patch to this collection
method List<A> Apply <EqA, A> (this List<A> va, Patch<EqA, A> patch) Source #
Apply the supplied patch to this collection
method bool Applicable <EqA, A> (this IEnumerable<A> va, Patch<EqA, A> patch) Source #
Returns true if a patch can be safely applied to a document, that is,
applicable(p, d)
holds when d
is a valid source document for the patch p
.