LanguageExt.Core

LanguageExt.Core Immutable Collections Map

Contents

delegate WhenMissing <in K, in A, out B> Source #

delegate WhenMatched <in K, in A, in B, out C> Source #

struct Map <K, V> Source #

Immutable map AVL tree implementation AVL tree is a self-balancing binary search tree. wikipedia.org/wiki/AVL_tree

Parameters

type K

Key type

type V

Value type

Indexers

this [ V ] Source #

'this' accessor

Parameters

param key

Key

returns

value

Properties

property Map<K, V> Empty Source #

property object? Case Source #

Reference version for use in pattern-matching

Empty collection     = null
Singleton collection = (K, V)
More                 = ((K, V), Seq<(K, V)>)   -- head and tail

var res = list.Case switch
{

   (var x, var xs) => ...,
   A value         => ...,
   _               => ...
}

property bool IsEmpty Source #

Is the map empty

property int Count Source #

Number of items in the map

property int Length Source #

Alias of Count

property Iterable<K> Keys Source #

Enumerable of map keys

property Iterable<V> Values Source #

Enumerable of map values

property Iterable<(K Key, V Value)> Pairs Source #

Enumerable of in-order tuples that make up the map

Parameters

returns

Tuples

property Iterable<(K Key, V Value)> ValueTuples Source #

Enumerable of in-order tuples that make up the map

Parameters

returns

Tuples

property Option<(K Key, V Value)> Min Source #

Find the lowest ordered item in the map

property Option<(K Key, V Value)> Max Source #

Find the highest ordered item in the map

property Map<K, V> AdditiveIdentity Source #

Constructors

constructor Map (IEnumerable<(K Key, V Value)> items) Source #

constructor Map (IEnumerable<(K Key, V Value)> items, bool tryAdd) Source #

constructor Map (ReadOnlySpan<(K Key, V Value)> items) Source #

constructor Map (ReadOnlySpan<(K Key, V Value)> items, bool tryAdd) Source #

Methods

method Lens<Map<K, V>, V> item (K key) Source #

Item at index lens

method Lens<Map<K, V>, Option<V>> itemOrNone (K key) Source #

Item or none at index lens

method Lens<Map<K, V>, Map<K, B>> map <B> (Lens<V, B> lens) Source #

Lens map

method Map<K, V> Add (K key, V value) Source #

Atomically adds a new item to the map

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<K, V> TryAdd (K key, V value) Source #

Atomically adds a new item to the map. If the key already exists, then the new item is ignored

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<K, V> TryAdd (K key, V value, Func<Map<K, V>, V, Map<K, V>> Fail) Source #

Atomically adds a new item to the map. If the key already exists then the Fail handler is called with the unaltered map and the value already set for the key, it expects a new map returned.

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

param Fail

Delegate to handle failure, you're given the unaltered map and the value already set for the key

returns

New Map with the item added

method Map<K, V> AddRange (IEnumerable<Tuple<K, V>> range) Source #

Atomically adds a range of items to the map.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<K, V> AddRange (IEnumerable<(K, V)> range) Source #

Atomically adds a range of items to the map.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<K, V> TryAddRange (IEnumerable<Tuple<K, V>> range) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're ignored.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<K, V> TryAddRange (IEnumerable<(K, V)> range) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're ignored.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<K, V> TryAddRange (IEnumerable<KeyValuePair<K, V>> range) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're ignored.

Null is not allowed for a Key or a Value

Parameters

param range

Range of KeyValuePairs to add

returns

New Map with the items added

method Map<K, V> AddOrUpdateRange (IEnumerable<Tuple<K, V>> range) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're replaced.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<K, V> AddOrUpdateRange (IEnumerable<(K, V)> range) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're replaced.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<K, V> AddOrUpdateRange (IEnumerable<KeyValuePair<K, V>> range) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're replaced.

Null is not allowed for a Key or a Value

Parameters

param range

Range of KeyValuePairs to add

returns

New Map with the items added

method Map<K, V> Remove (K key) Source #

Atomically removes an item from the map If the key doesn't exists, the request is ignored.

Parameters

param key

Key

returns

New map with the item removed

method Option<V> Find (K key) Source #

Retrieve a value from the map by key

Parameters

param key

Key to find

returns

Found value

method Seq<V> FindSeq (K key) Source #

Retrieve a value from the map by key as an enumerable

Parameters

param key

Key to find

returns

Found value

method R Find <R> (K key, Func<V, R> Some, Func<R> None) Source #

Retrieve a value from the map by key and pattern match the result.

Parameters

param key

Key to find

returns

Found value

method Option<(K Key, V Value)> FindPredecessor (K key) Source #

Retrieve the value from previous item to specified key

Parameters

param key

Key to find

returns

Found key/value

method Option<(K Key, V Value)> FindExactOrPredecessor (K key) Source #

Retrieve the value from exact key, or if not found, the previous item

Parameters

param key

Key to find

returns

Found key/value

method Option<(K Key, V Value)> FindSuccessor (K key) Source #

Retrieve the value from next item to specified key

Parameters

param key

Key to find

returns

Found key/value

method Option<(K Key, V Value)> FindExactOrSuccessor (K key) Source #

Retrieve the value from exact key, or if not found, the next item

Parameters

param key

Key to find

returns

Found key/value

method (Map<K, V> Map, V Value) FindOrAdd (K key, Func<V> None) Source #

Try to find the key in the map, if it doesn't exist, add a new item by invoking the delegate provided.

Parameters

param key

Key to find

param None

Delegate to get the value

returns

Updated map and added value

method (Map<K, V>, V Value) FindOrAdd (K key, V value) Source #

Try to find the key in the map, if it doesn't exist, add a new item provided.

Parameters

param key

Key to find

param value

Delegate to get the value

returns

Updated map and added value

method (Map<K, V> Map, Option<V> Value) FindOrMaybeAdd (K key, Func<Option<V>> None) Source #

Try to find the key in the map, if it doesn't exist, add a new item by invoking the delegate provided.

Parameters

param key

Key to find

param None

Delegate to get the value

returns

Updated map and added value

method (Map<K, V> Map, Option<V> Value) FindOrMaybeAdd (K key, Option<V> None) Source #

Try to find the key in the map, if it doesn't exist, add a new item by invoking the delegate provided.

Parameters

param key

Key to find

param None

Delegate to get the value

returns

Updated map and added value

method Map<K, V> SetItem (K key, V value) Source #

Atomically updates an existing item

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<K, V> SetItem (K key, Func<V, V> Some) Source #

Retrieve a value from the map by key, map it to a new value, put it back.

Parameters

param key

Key to set

returns

New map with the mapped value

method Map<K, V> TrySetItem (K key, V value) Source #

Atomically updates an existing item, unless it doesn't exist, in which case it is ignored

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<K, V> TrySetItem (K key, Func<V, V> Some) Source #

Atomically sets an item by first retrieving it, applying a map, and then putting it back. Silently fails if the value doesn't exist

Parameters

param key

Key to set

param Some

delegate to map the existing value to a new one before setting

returns

New map with the item set

method Map<K, V> TrySetItem (K key, Func<V, V> Some, Func<Map<K, V>, Map<K, V>> None) Source #

Atomically sets an item by first retrieving it, applying a map, and then putting it back. Calls the None delegate to return a new map if the item can't be found

Null is not allowed for a Key or a Value

Parameters

param key

Key

param Some

delegate to map the existing value to a new one before setting

param None

delegate to return a new map if the item can't be found

returns

New map with the item set

method Map<K, V> AddOrUpdate (K key, V value) Source #

Atomically adds a new item to the map. If the key already exists, the new item replaces it.

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<K, V> AddOrUpdate (K key, Func<V, V> Some, Func<V> None) Source #

Retrieve a value from the map by key, map it to a new value, put it back. If it doesn't exist, add a new one based on None result.

Parameters

param key

Key to find

returns

New map with the mapped value

method Map<K, V> AddOrUpdate (K key, Func<V, V> Some, V None) Source #

Retrieve a value from the map by key, map it to a new value, put it back. If it doesn't exist, add a new one based on None result.

Parameters

param key

Key to find

returns

New map with the mapped value

method Iterable<V> FindRange (K keyFrom, K keyTo) Source #

Retrieve a range of values

Parameters

param keyFrom

Range start (inclusive)

param keyTo

Range to (inclusive)

returns

Range of values

method Iterable<(K Key, V Value)> FindRangePairs (K keyFrom, K keyTo) Source #

Retrieve a range of values

Parameters

param keyFrom

Range start (inclusive)

param keyTo

Range to (inclusive)

returns

Range of key, values

method Iterable<(K Key, V Value)> Skip (int amount) Source #

Skips 'amount' values and returns a new tree without the skipped values.

Parameters

param amount

Amount to skip

returns

New tree

method bool ContainsKey (K key) Source #

Checks for existence of a key in the map

Parameters

param key

Key to check

returns

True if an item with the key supplied is in the map

method bool Contains (K key, V value) Source #

Checks for existence of a key in the map

Parameters

param key

Key to check

returns

True if an item with the key supplied is in the map

method Map<K, V> Clear () Source #

Clears all items from the map

Functionally equivalent to calling Map.empty as the original structure is untouched

Parameters

returns

Empty map

method Map<K, V> AddRange (IEnumerable<KeyValuePair<K, V>> pairs) Source #

Atomically adds a range of items to the map

Parameters

param pairs

Range of KeyValuePairs to add

returns

New Map with the items added

method Map<K, V> SetItems (IEnumerable<KeyValuePair<K, V>> items) Source #

Atomically sets a series of items using the KeyValuePairs provided

Parameters

param items

Items to set

returns

New map with the items set

method Map<K, V> SetItems (IEnumerable<Tuple<K, V>> items) Source #

Atomically sets a series of items using the Tuples provided.

Parameters

param items

Items to set

returns

New map with the items set

method Map<K, V> SetItems (IEnumerable<(K, V)> items) Source #

Atomically sets a series of items using the Tuples provided.

Parameters

param items

Items to set

returns

New map with the items set

method Map<K, V> TrySetItems (IEnumerable<KeyValuePair<K, V>> items) Source #

Atomically sets a series of items using the KeyValuePairs provided. If any of the items don't exist then they're silently ignored.

Parameters

param items

Items to set

returns

New map with the items set

method Map<K, V> TrySetItems (IEnumerable<Tuple<K, V>> items) Source #

Atomically sets a series of items using the Tuples provided If any of the items don't exist then they're silently ignored.

Parameters

param items

Items to set

returns

New map with the items set

method Map<K, V> TrySetItems (IEnumerable<(K, V)> items) Source #

Atomically sets a series of items using the Tuples provided If any of the items don't exist then they're silently ignored.

Parameters

param items

Items to set

returns

New map with the items set

method Map<K, V> TrySetItems (IEnumerable<K> keys, Func<V, V> Some) Source #

Atomically sets a series of items using the keys provided to find the items and the Some delegate maps to a new value. If the items don't exist then they're silently ignored.

Parameters

param keys

Keys of items to set

param Some

Function map the existing item to a new one

returns

New map with the items set

method Map<K, V> RemoveRange (IEnumerable<K> keys) Source #

Atomically removes a set of keys from the map

Parameters

param keys

Keys to remove

returns

New map with the items removed

method bool Contains (KeyValuePair<K, V> pair) Source #

Returns true if a Key/Value pair exists in the map

Parameters

param pair

Pair to find

returns

True if exists, false otherwise

method IDictionary<KR, VR> ToDictionary <KR, VR> (Func<(K Key, V Value), KR> keySelector, Func<(K Key, V Value), VR> valueSelector) Source #

where KR : notnull

Map the map the a dictionary

method MapEnumerator<K, V> GetEnumerator () Source #

GetEnumerator - IEnumerable interface

method Seq<(K Key, V Value)> ToSeq () Source #

method string ToString () Source #

Format the collection as [(key: value), (key: value), (key: value), ...] The elipsis is used for collections over 50 items To get a formatted string with all the items, use ToFullString or ToFullArrayString.

method string ToFullString (string separator = ", ") Source #

Format the collection as (key: value), (key: value), (key: value), ...

method string ToFullArrayString (string separator = ", ") Source #

Format the collection as [(key: value), (key: value), (key: value), ...]

method Iterable<(K Key, V Value)> AsEnumerable () Source #

method Map<K, V> Combine (Map<K, V> y) Source #

method bool Equals (object? obj) Source #

Equality of keys and values with EqDefault<V> used for values

method bool Equals (Map<K, V> y) Source #

Equality of keys and values with EqDefault<V> used for values

method bool Equals <EqV> (Map<K, V> y) Source #

where EqV : Eq<V>

Equality of keys and values

method bool EqualsKeys (Map<K, V> y) Source #

Equality of keys only

method int GetHashCode () Source #

method int CompareTo (object? obj) Source #

method Map<K, V> Do (Action<V> f) Source #

Impure iteration of the bound values in the structure

Parameters

returns

Returns the original unmodified structure

method Map<K, U> Select <U> (Func<V, U> mapper) Source #

Atomically maps the map to a new map

Parameters

returns

Mapped items in a new map

method Map<K, U> Select <U> (Func<K, V, U> mapper) Source #

Atomically maps the map to a new map

Parameters

returns

Mapped items in a new map

method Map<K, V> Where (Func<V, bool> valuePred) Source #

Atomically filter out items that return false when a predicate is applied

Parameters

param valuePred

Predicate

returns

New map with items filtered

method Map<K, V> Where (Func<K, V, bool> keyValuePred) Source #

Atomically filter out items that return false when a predicate is applied

Parameters

param keyValuePred

Predicate

returns

New map with items filtered

method Map<K, V> Filter (Func<V, bool> valuePred) Source #

Atomically filter out items that return false when a predicate is applied

Parameters

param valuePred

Predicate

returns

New map with items filtered

method Map<K, V> Filter (Func<K, V, bool> keyValuePred) Source #

Atomically filter out items that return false when a predicate is applied

Parameters

param pred

Predicate

returns

New map with items filtered

method bool ForAll (Func<K, V, bool> pred) Source #

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool ForAll (Func<Tuple<K, V>, bool> pred) Source #

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool ForAll (Func<(K Key, V Value), bool> pred) Source #

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool ForAll (Func<KeyValuePair<K, V>, bool> pred) Source #

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool ForAll (Func<V, bool> pred) Source #

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool Exists (Func<K, V, bool> pred) Source #

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool Exists (Func<Tuple<K, V>, bool> pred) Source #

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool Exists (Func<(K, V), bool> pred) Source #

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool Exists (Func<KeyValuePair<K, V>, bool> pred) Source #

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool Exists (Func<V, bool> pred) Source #

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method Unit Iter (Action<K, V> action) Source #

Atomically iterate through all key/value pairs in the map (in order) and execute an action on each

Parameters

param action

Action to execute

returns

Unit

method Unit Iter (Action<V> action) Source #

Atomically iterate through all values in the map (in order) and execute an action on each

Parameters

param action

Action to execute

returns

Unit

method Unit Iter (Action<Tuple<K, V>> action) Source #

Atomically iterate through all key/value pairs (as tuples) in the map (in order) and execute an action on each

Parameters

param action

Action to execute

returns

Unit

method Unit Iter (Action<(K, V)> action) Source #

Atomically iterate through all key/value pairs (as tuples) in the map (in order) and execute an action on each

Parameters

param action

Action to execute

returns

Unit

method Unit Iter (Action<KeyValuePair<K, V>> action) Source #

Atomically iterate through all key/value pairs in the map (in order) and execute an action on each

Parameters

param action

Action to execute

returns

Unit

method Map<K, U> Choose <U> (Func<K, V, Option<U>> selector) Source #

Equivalent to map and filter but the filtering is done based on whether the returned Option is Some or None. If the item is None then it's filtered out, if not the the mapped Some value is used.

Parameters

param selector

Predicate

returns

Filtered map

method Map<K, U> Choose <U> (Func<V, Option<U>> selector) Source #

Equivalent to map and filter but the filtering is done based on whether the returned Option is Some or None. If the item is None then it's filtered out, if not the the mapped Some value is used.

Parameters

param selector

Predicate

returns

Filtered map

method S Fold <S> (S state, Func<S, K, V, S> folder) Source #

Atomically folds all items in the map (in order) using the folder function provided.

Parameters

type S

State type

param state

Initial state

param folder

Fold function

returns

Folded state

method S Fold <S> (S state, Func<S, V, S> folder) Source #

Atomically folds all items in the map (in order) using the folder function provided.

Parameters

type S

State type

param state

Initial state

param folder

Fold function

returns

Folded state

method Map<K, V> Union (Map<K, V> other, WhenMatched<K, V, V, V> Merge) Source #

Union two maps. The merge function is called when keys are present in both map.

method Map<K, V> Union <V2> (Map<K, V2> other, WhenMissing<K, V2, V> MapRight, WhenMatched<K, V, V2, V> Merge) Source #

Union two maps. The merge function is called when keys are present in both map.

method Map<K, V2> Union <V2> (Map<K, V2> other, WhenMissing<K, V, V2> MapLeft, WhenMatched<K, V, V2, V2> Merge) Source #

Union two maps. The merge function is called when keys are present in both map.

method Map<K, R> Union <V2, R> (Map<K, V2> other, WhenMissing<K, V, R> MapLeft, WhenMissing<K, V2, R> MapRight, WhenMatched<K, V, V2, R> Merge) Source #

Union two maps. The merge function is called when keys are present in both map.

method Map<K, R> Intersect <V2, R> (Map<K, V2> other, WhenMatched<K, V, V2, R> Merge) Source #

method Map<K, V> Except (Map<K, V> other) Source #

Map differencing based on key. this - other.

method Map<K, V> SymmetricExcept (Map<K, V> other) Source #

Keys that are in both maps are dropped and the remaining items are merged and returned.

method int CompareTo (Map<K, V> other) Source #

Compare keys and values (values use OrdDefault<V> for ordering)

method int CompareTo <OrdV> (Map<K, V> other) Source #

where OrdV : Ord<V>

Compare keys and values (values use OrdV for ordering)

method int CompareKeysTo (Map<K, V> other) Source #

Compare keys only

method Map<K, V> Slice (K keyFrom, K keyTo) Source #

Creates a new map from a range/slice of this map

Parameters

param keyFrom

Range start (inclusive)

param keyTo

Range to (inclusive)

returns

method bool TryGetValue (K key, out V value) Source #

Operators

operator == (Map<K, V> lhs, Map<K, V> rhs) Source #

operator != (Map<K, V> lhs, Map<K, V> rhs) Source #

operator < (Map<K, V> lhs, Map<K, V> rhs) Source #

operator <= (Map<K, V> lhs, Map<K, V> rhs) Source #

operator > (Map<K, V> lhs, Map<K, V> rhs) Source #

operator >= (Map<K, V> lhs, Map<K, V> rhs) Source #

operator + (Map<K, V> lhs, Map<K, V> rhs) Source #

operator - (Map<K, V> lhs, Map<K, V> rhs) Source #

struct MapKeyEnumerator <K, V> Source #

Properties

property K Current Source #

Methods

method void Dispose () Source #

method bool MoveNext () Source #

method void Reset () Source #

struct MapEnumerator <K, V> Source #

Properties

property (K Key, V Value) Current Source #

Methods

method void Dispose () Source #

method bool MoveNext () Source #

method void Reset () Source #

struct MapValueEnumerator <K, V> Source #

Properties

property V Current Source #

Methods

method void Dispose () Source #

method bool MoveNext () Source #

method void Reset () Source #

class MapExtensions Source #

Methods

method Map<Key, V> As <Key, V> (this K<Map<Key>, V> ma) Source #

method Map<K, V> ToMap <K, V> (this IEnumerable<(K, V)> items) Source #

Create an immutable map

method Map<K, V> ToMap <K, V> (this IEnumerable<Tuple<K, V>> items) Source #

Create an immutable map

method Map<K, V> ToMap <K, V> (this IEnumerable<KeyValuePair<K, V>> items) Source #

Create an immutable map

method Map<(K1, K2), V> ToMap <K1, K2, V> (this IEnumerable<(K1, K2, V)> items) Source #

Create an immutable map

method Map<(K1, K2, K3), V> ToMap <K1, K2, K3, V> (this IEnumerable<(K1, K2, K3, V)> items) Source #

Create an immutable map

method Map<(K1, K2, K3, K4), V> ToMap <K1, K2, K3, K4, V> (this IEnumerable<(K1, K2, K3, K4, V)> items) Source #

Create an immutable map

method Map<K, U> Map <K, V, U> (this Map<K, V> self, Func<V, U> mapper) Source #

Atomically maps the map to a new map

Parameters

returns

Mapped items in a new map

method Map<K, U> Map <K, V, U> (this Map<K, V> self, Func<K, V, U> mapper) Source #

Atomically maps the map to a new map

Parameters

returns

Mapped items in a new map

class MapExtensions Source #

Methods

method Map<Key, B> Map <Key, A, B> (this Func<A, B> f, K<Map<Key>, A> ma) Source #

Functor map operation

Unwraps the value within the functor, passes it to the map function f provided, and then takes the mapped value and wraps it back up into a new functor.

Parameters

param ma

Functor to map

param f

Mapping function

returns

Mapped functor

method Map<Key, B> Map <Key, A, B> (this Func<A, B> f, Map<Key, A> ma) Source #

Functor map operation

Unwraps the value within the functor, passes it to the map function f provided, and then takes the mapped value and wraps it back up into a new functor.

Parameters

param ma

Functor to map

param f

Mapping function

returns

Mapped functor

class MapOrdExtensions Source #

Methods

method Map<OrdK, K, U> Map <OrdK, K, V, U> (this Map<OrdK, K, V> self, Func<V, U> mapper) Source #

where OrdK : Ord<K>

Atomically maps the map to a new map

Parameters

returns

Mapped items in a new map

method Map<OrdK, K, U> Map <OrdK, K, V, U> (this Map<OrdK, K, V> self, Func<K, V, U> mapper) Source #

where OrdK : Ord<K>

Atomically maps the map to a new map

Parameters

returns

Mapped items in a new map

method int Count <OrdK, K, V> (this Map<OrdK, K, V> self) Source #

where OrdK : Ord<K>

Number of items in the map

method int Sum <OrdK, K> (this Map<OrdK, K, int> self) Source #

where OrdK : Ord<K>

class Map Source #

Immutable map module AVL tree implementation AVL tree is a self-balancing binary search tree. wikipedia.org/wiki/AVL_tree

Methods

method Map<K, V> empty <K, V> () Source #

Creates a new empty Map

method Map<K, V> singleton <K, V> ((K, V) value) Source #

Creates a new singleton Map

method Map<K, V> singleton <K, V> (K key, V value) Source #

Creates a new singleton Map

method Map<K, V> create <K, V> () Source #

Creates a new Map seeded with the keyValues provided

method Map<K, V> create <K, V> (Tuple<K, V> head, params Tuple<K, V>[] tail) Source #

Creates a new Map seeded with the keyValues provided

method Map<K, V> create <K, V> (KeyValuePair<K, V> head, params KeyValuePair<K, V>[] tail) Source #

Creates a new Map seeded with the keyValues provided

method Map<K, V> create <K, V> ((K, V) head, params (K, V)[] tail) Source #

Creates a new Map seeded with the keyValues provided

method Map<K, V> createRange <K, V> (IEnumerable<Tuple<K, V>> keyValues) Source #

Creates a new Map seeded with the keyValues provided

method Map<K, V> createRange <K, V> (IEnumerable<(K, V)> keyValues) Source #

Creates a new Map seeded with the keyValues provided

method Map<K, V> createRange <K, V> (ReadOnlySpan<(K, V)> keyValues) Source #

Creates a new Map seeded with the keyValues provided

method Map<K, V> createRange <K, V> (IEnumerable<KeyValuePair<K, V>> keyValues) Source #

Creates a new Map seeded with the keyValues provided

method Map<K, V> add <K, V> (Map<K, V> map, K key, V value) Source #

Atomically adds a new item to the map

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<K, V> tryAdd <K, V> (Map<K, V> map, K key, V value) Source #

Atomically adds a new item to the map. If the key already exists, then the new item is ignored

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<K, V> tryAdd <K, V> (Map<K, V> map, K key, V value, Func<Map<K, V>, V, Map<K, V>> Fail) Source #

Atomically adds a new item to the map. If the key already exists then the Fail handler is called with the unaltered map and the value already set for the key, it expects a new map returned.

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

param Fail

Delegate to handle failure, you're given the unaltered map and the value already set for the key

returns

New Map with the item added

method Map<K, V> addOrUpdate <K, V> (Map<K, V> map, K key, V value) Source #

Atomically adds a new item to the map. If the key already exists, the new item replaces it.

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<K, V> addOrUpdate <K, V> (Map<K, V> map, K key, Func<V, V> Some, Func<V> None) Source #

Retrieve a value from the map by key, map it to a new value, put it back. If it doesn't exist, add a new one based on None result.

Parameters

param key

Key to find

returns

New map with the mapped value

method Map<K, V> addOrUpdate <K, V> (Map<K, V> map, K key, Func<V, V> Some, V None) Source #

Retrieve a value from the map by key, map it to a new value, put it back. If it doesn't exist, add a new one based on None result.

Parameters

param key

Key to find

returns

New map with the mapped value

method Map<K, V> addRange <K, V> (Map<K, V> map, IEnumerable<Tuple<K, V>> keyValues) Source #

Atomically adds a range of items to the map.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<K, V> addRange <K, V> (Map<K, V> map, IEnumerable<(K, V)> keyValues) Source #

Atomically adds a range of items to the map.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<K, V> addRange <K, V> (Map<K, V> map, IEnumerable<KeyValuePair<K, V>> keyValues) Source #

Atomically adds a range of items to the map.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<K, V> tryAddRange <K, V> (Map<K, V> map, IEnumerable<Tuple<K, V>> keyValues) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're ignored.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<K, V> tryAddRange <K, V> (Map<K, V> map, IEnumerable<(K, V)> keyValues) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're ignored.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<K, V> tryAddRange <K, V> (Map<K, V> map, IEnumerable<KeyValuePair<K, V>> keyValues) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're ignored.

Null is not allowed for a Key or a Value

Parameters

param range

Range of KeyValuePairs to add

returns

New Map with the items added

method Map<K, V> addOrUpdateRange <K, V> (Map<K, V> map, IEnumerable<Tuple<K, V>> range) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're replaced.

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<K, V> addOrUpdateRange <K, V> (Map<K, V> map, IEnumerable<(K, V)> range) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're replaced.

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<K, V> addOrUpdateRange <K, V> (Map<K, V> map, IEnumerable<KeyValuePair<K, V>> range) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're replaced.

Null is not allowed for a Key or a Value

Parameters

param range

Range of KeyValuePairs to add

returns

New Map with the items added

method Map<K, V> remove <K, V> (Map<K, V> map, K key) Source #

Atomically removes an item from the map If the key doesn't exists, the request is ignored.

Parameters

param key

Key

returns

New map with the item removed

method bool containsKey <K, V> (Map<K, V> map, K key) Source #

Checks for existence of a key in the map

Parameters

param key

Key to check

returns

True if an item with the key supplied is in the map

method bool contains <K, V> (Map<K, V> map, KeyValuePair<K, V> kv) Source #

Checks for existence of a key in the map

Parameters

param key

Key to check

returns

True if an item with the key supplied is in the map

method bool contains <K, V> (Map<K, V> map, Tuple<K, V> kv) Source #

Checks for existence of a key in the map

Parameters

param key

Key to check

returns

True if an item with the key supplied is in the map

method bool contains <K, V> (Map<K, V> map, (K, V) kv) Source #

Checks for existence of a key in the map

Parameters

param key

Key to check

returns

True if an item with the key supplied is in the map

method Map<K, V> setItem <K, V> (Map<K, V> map, K key, V value) Source #

Atomically updates an existing item

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<K, V> trySetItem <K, V> (Map<K, V> map, K key, V value) Source #

Atomically updates an existing item, unless it doesn't exist, in which case it is ignored

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<K, V> trySetItem <K, V> (Map<K, V> map, K key, Func<V, V> Some) Source #

Atomically sets an item by first retrieving it, applying a map (Some), and then putting it back. Silently fails if the value doesn't exist.

Parameters

param key

Key to set

param Some

delegate to map the existing value to a new one before setting

returns

New map with the item set

method Map<K, V> trySetItem <K, V> (Map<K, V> map, K key, Func<V, V> Some, Func<Map<K, V>, Map<K, V>> None) Source #

Atomically sets an item by first retrieving it, applying a map, and then putting it back. Calls the None delegate to return a new map if the item can't be found

Null is not allowed for a Key or a Value

Parameters

param key

Key

param Some

delegate to map the existing value to a new one before setting

param None

delegate to return a new map if the item can't be found

returns

New map with the item set

method Map<K, V> setItems <K, V> (Map<K, V> map, IEnumerable<Tuple<K, V>> items) Source #

Atomically sets a series of items using the Tuples provided

Parameters

param items

Items to set

returns

New map with the items set

method Map<K, V> setItems <K, V> (Map<K, V> map, IEnumerable<(K, V)> items) Source #

Atomically sets a series of items using the Tuples provided

Parameters

param items

Items to set

returns

New map with the items set

method Map<K, V> setItems <K, V> (Map<K, V> map, IEnumerable<KeyValuePair<K, V>> items) Source #

Atomically sets a series of items using the KeyValuePairs provided

Parameters

param items

Items to set

returns

New map with the items set

method Map<K, V> trySetItems <K, V> (Map<K, V> map, IEnumerable<Tuple<K, V>> items) Source #

Atomically sets a series of items using the Tuples provided.

Parameters

param items

Items to set

returns

New map with the items set

method Map<K, V> trySetItems <K, V> (Map<K, V> map, IEnumerable<(K, V)> items) Source #

Atomically sets a series of items using the Tuples provided.

Parameters

param items

Items to set

returns

New map with the items set

method Map<K, V> trySetItems <K, V> (Map<K, V> map, IEnumerable<KeyValuePair<K, V>> items) Source #

Atomically sets a series of items using the KeyValuePairs provided. If any of the items don't exist then they're silently ignored.

Parameters

param items

Items to set

returns

New map with the items set

method Map<K, V> trySetItems <K, V> (Map<K, V> map, IEnumerable<K> keys, Func<V, V> Some) Source #

Atomically sets a series of items using the keys provided to find the items and the Some delegate maps to a new value. If the items don't exist then they're silently ignored.

Parameters

param keys

Keys of items to set

param Some

Function map the existing item to a new one

returns

New map with the items set

method Option<V> find <K, V> (Map<K, V> map, K key) Source #

Retrieve a value from the map by key

Parameters

param key

Key to find

returns

Found value

method IEnumerable<V> findSeq <K, V> (Map<K, V> map, K key) Source #

Retrieve a value from the map by key as an enumerable

Parameters

param key

Key to find

returns

Found value

method R find <K, V, R> (Map<K, V> map, K key, Func<V, R> Some, Func<R> None) Source #

Retrieve a value from the map by key and pattern match the result.

Parameters

param key

Key to find

returns

Found value

method Map<K, V> setItem <K, V> (Map<K, V> map, K key, Func<V, V> mapper) Source #

Retrieve a value from the map by key, map it to a new value, put it back.

Parameters

param key

Key to find

returns

New map with the mapped value

method IEnumerable<V> findRange <K, V> (Map<K, V> map, K keyFrom, K keyTo) Source #

Retrieve a range of values

Parameters

param keyFrom

Range start (inclusive)

param keyTo

Range to (inclusive)

returns

Range of values

method IEnumerable<(K Key, V Value)> skip <K, V> (Map<K, V> map, int amount) Source #

Skips 'amount' values and returns a new tree without the skipped values.

Parameters

param amount

Amount to skip

returns

Enumerable of map items

method Unit iter <K, V> (Map<K, V> map, Action<V> action) Source #

Atomically iterate through all key/value pairs in the map (in order) and execute an action on each

Parameters

param action

Action to execute

returns

Unit

method Unit iter <K, V> (Map<K, V> map, Action<K, V> action) Source #

Atomically iterate through all key/value pairs in the map (in order) and execute an action on each

Parameters

param action

Action to execute

returns

Unit

method bool forall <K, V> (Map<K, V> map, Func<V, bool> pred) Source #

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool forall <K, V> (Map<K, V> map, Func<K, V, bool> pred) Source #

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool forall <K, V> (Map<K, V> map, Func<Tuple<K, V>, bool> pred) Source #

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool forall <K, V> (Map<K, V> map, Func<(K Key, V Value), bool> pred) Source #

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool forall <K, V> (Map<K, V> map, Func<KeyValuePair<K, V>, bool> pred) Source #

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method Map<K, U> map <K, T, U> (Map<K, T> map, Func<T, U> f) Source #

Atomically maps the map to a new map

Parameters

returns

Mapped items in a new map

method Map<K, U> map <K, T, U> (Map<K, T> map, Func<K, T, U> f) Source #

Atomically maps the map to a new map

Parameters

returns

Mapped items in a new map

method Map<K, V> filter <K, V> (Map<K, V> map, Func<V, bool> predicate) Source #

Atomically filter out items that return false when a predicate is applied

Parameters

param pred

Predicate

returns

New map with items filtered

method Map<K, V> filter <K, V> (Map<K, V> map, Func<K, V, bool> predicate) Source #

Atomically filter out items that return false when a predicate is applied

Parameters

param pred

Predicate

returns

New map with items filtered

method Map<K, R> choose <K, T, R> (Map<K, T> map, Func<T, Option<R>> selector) Source #

Equivalent to map and filter but the filtering is done based on whether the returned Option is Some or None. If the item is None then it's filtered out, if not the the mapped Some value is used.

Parameters

param selector

Predicate

returns

Filtered map

method Map<K, R> choose <K, T, R> (Map<K, T> map, Func<K, T, Option<R>> selector) Source #

Equivalent to map and filter but the filtering is done based on whether the returned Option is Some or None. If the item is None then it's filtered out, if not the the mapped Some value is used.

Parameters

param selector

Predicate

returns

Filtered map

method int length <K, T> (Map<K, T> map) Source #

Number of items in the map

method S fold <S, K, V> (Map<K, V> map, S state, Func<S, K, V, S> folder) Source #

Atomically folds all items in the map (in order) using the folder function provided.

Parameters

type S

State type

param state

Initial state

param folder

Fold function

returns

Folded state

method S fold <S, K, V> (Map<K, V> map, S state, Func<S, V, S> folder) Source #

Atomically folds all items in the map (in order) using the folder function provided.

Parameters

type S

State type

param state

Initial state

param folder

Fold function

returns

Folded state

method bool exists <K, V> (Map<K, V> map, Func<K, V, bool> pred) Source #

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool exists <K, V> (Map<K, V> map, Func<Tuple<K, V>, bool> pred) Source #

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool exists <K, V> (Map<K, V> map, Func<(K Key, V Value), bool> pred) Source #

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool exists <K, V> (Map<K, V> map, Func<KeyValuePair<K, V>, bool> pred) Source #

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool exists <K, V> (Map<K, V> map, Func<V, bool> pred) Source #

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method Map<K, V> toMap <K, V> (IDictionary<K, V> dict) Source #

Convert any IDictionary into an immutable Map K V

method Map<K, V> ToMap <K, V> (this IDictionary<K, V> dict) Source #

Convert any IDictionary into an immutable Map K V

method HashMap<K, V> toHashMap <K, V> (IDictionary<K, V> dict) Source #

Convert any IDictionary into an immutable Map K V

method HashMap<K, V> ToHashMap <K, V> (this IDictionary<K, V> dict) Source #

Convert any IDictionary into an immutable Map K V

method Map<K, V> union <K, V> (Map<K, V> left, Map<K, V> right, WhenMatched<K, V, V, V> Merge) Source #

Union two maps. The merge function is called keys are present in both map.

method Map<K, A> union <K, A, B> (Map<K, A> left, Map<K, B> right, WhenMissing<K, B, A> MapRight, WhenMatched<K, A, B, A> Merge) Source #

Union two maps. The merge function is called keys are present in both map.

method Map<K, B> union <K, A, B> (Map<K, A> left, Map<K, B> right, WhenMissing<K, A, B> MapLeft, WhenMatched<K, A, B, B> Merge) Source #

Union two maps. The merge function is called keys are present in both map.

method Map<K, C> union <K, A, B, C> (Map<K, A> left, Map<K, B> right, WhenMissing<K, A, C> MapLeft, WhenMissing<K, B, C> MapRight, WhenMatched<K, A, B, C> Merge) Source #

Union two maps. The merge function is called keys are present in both map.

method Map<K, R> intersect <K, A, B, R> (Map<K, A> left, Map<K, B> right, WhenMatched<K, A, B, R> merge) Source #

method Map<K, V> except <K, V> (Map<K, V> left, Map<K, V> right) Source #

Map differencing based on key. this - other.

method Map<K, V> symmetricExcept <K, V> (Map<K, V> left, Map<K, V> right) Source #

Keys that are in both maps are dropped and the remaining items are merged and returned.

class Map Source #

Immutable map module AVL tree implementation AVL tree is a self-balancing binary search tree. en.wikipedia.org/wiki/AVL_tree

Methods

method Map<OrdK, K, V> empty <OrdK, K, V> () Source #

where OrdK : Ord<K>

Creates a new empty Map

method Map<OrdK, K, V> singleton <OrdK, K, V> ((K, V) value) Source #

where OrdK : Ord<K>

Creates a new empty Map

method Map<OrdK, K, V> singleton <OrdK, K, V> (K key, V value) Source #

where OrdK : Ord<K>

Creates a new empty Map

method Map<OrdK, K, V> create <OrdK, K, V> () Source #

where OrdK : Ord<K>

Creates a new empty Map

method Map<OrdK, K, V> create <OrdK, K, V> (Tuple<K,V> head, params Tuple<K, V>[] tail) Source #

where OrdK : Ord<K>

Creates a new Map seeded with the keyValues provided

method Map<OrdK, K, V> create <OrdK, K, V> ((K, V) head, params (K, V)[] tail) Source #

where OrdK : Ord<K>

Creates a new Map seeded with the keyValues provided

method Map<OrdK, K, V> createRange <OrdK, K, V> (IEnumerable<Tuple<K, V>> keyValues) Source #

where OrdK : Ord<K>

Creates a new Map seeded with the keyValues provided

method Map<OrdK, K, V> createRange <OrdK, K, V> (IEnumerable<(K, V)> keyValues) Source #

where OrdK : Ord<K>

Creates a new Map seeded with the keyValues provided

method Map<OrdK, K, V> createRange <OrdK, K, V> (ReadOnlySpan<(K, V)> keyValues) Source #

where OrdK : Ord<K>

Creates a new Map seeded with the keyValues provided

method Map<OrdK, K, V> add <OrdK, K, V> (Map<OrdK, K, V> map, K key, V value) Source #

where OrdK : Ord<K>

Atomically adds a new item to the map

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<OrdK, K, V> tryAdd <OrdK, K, V> (Map<OrdK, K, V> map, K key, V value) Source #

where OrdK : Ord<K>

Atomically adds a new item to the map. If the key already exists, then the new item is ignored

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<OrdK, K, V> tryAdd <OrdK, K, V> (Map<OrdK, K, V> map, K key, V value, Func<Map<OrdK, K, V>, V, Map<OrdK, K, V>> Fail) Source #

where OrdK : Ord<K>

Atomically adds a new item to the map. If the key already exists then the Fail handler is called with the unaltered map and the value already set for the key, it expects a new map returned.

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

param Fail

Delegate to handle failure, you're given the unaltered map and the value already set for the key

returns

New Map with the item added

method Map<OrdK, K, V> addOrUpdate <OrdK, K, V> (Map<OrdK, K, V> map, K key, V value) Source #

where OrdK : Ord<K>

Atomically adds a new item to the map. If the key already exists, the new item replaces it.

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<OrdK, K, V> addOrUpdate <OrdK, K, V> (Map<OrdK, K, V> map, K key, Func<V, V> Some, Func<V> None) Source #

where OrdK : Ord<K>

Retrieve a value from the map by key, map it to a new value, put it back. If it doesn't exist, add a new one based on None result.

Parameters

param key

Key to find

returns

New map with the mapped value

method Map<OrdK, K, V> addOrUpdate <OrdK, K, V> (Map<OrdK, K, V> map, K key, Func<V, V> Some, V None) Source #

where OrdK : Ord<K>

Retrieve a value from the map by key, map it to a new value, put it back. If it doesn't exist, add a new one based on None result.

Parameters

param key

Key to find

returns

New map with the mapped value

method Map<OrdK, K, V> addRange <OrdK, K, V> (Map<OrdK, K, V> map, IEnumerable<Tuple<K, V>> keyValues) Source #

where OrdK : Ord<K>

Atomically adds a range of items to the map.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<OrdK, K, V> addRange <OrdK, K, V> (Map<OrdK, K, V> map, IEnumerable<(K, V)> keyValues) Source #

where OrdK : Ord<K>

Atomically adds a range of items to the map.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<OrdK, K, V> tryAddRange <OrdK, K, V> (Map<OrdK, K, V> map, IEnumerable<Tuple<K, V>> keyValues) Source #

where OrdK : Ord<K>

Atomically adds a range of items to the map. If any of the keys exist already then they're ignored.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<OrdK, K, V> tryAddRange <OrdK, K, V> (Map<OrdK, K, V> map, IEnumerable<(K, V)> keyValues) Source #

where OrdK : Ord<K>

Atomically adds a range of items to the map. If any of the keys exist already then they're ignored.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<OrdK, K, V> tryAddRange <OrdK, K, V> (Map<OrdK, K, V> map, IEnumerable<KeyValuePair<K, V>> keyValues) Source #

where OrdK : Ord<K>

Atomically adds a range of items to the map. If any of the keys exist already then they're ignored.

Null is not allowed for a Key or a Value

Parameters

param range

Range of KeyValuePairs to add

returns

New Map with the items added

method Map<OrdK, K, V> addOrUpdateRange <OrdK, K, V> (Map<OrdK, K, V> map, IEnumerable<Tuple<K, V>> range) Source #

where OrdK : Ord<K>

Atomically adds a range of items to the map. If any of the keys exist already then they're replaced.

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<OrdK, K, V> addOrUpdateRange <OrdK, K, V> (Map<OrdK, K, V> map, IEnumerable<(K, V)> range) Source #

where OrdK : Ord<K>

Atomically adds a range of items to the map. If any of the keys exist already then they're replaced.

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<OrdK, K, V> addOrUpdateRange <OrdK, K, V> (Map<OrdK, K, V> map, IEnumerable<KeyValuePair<K, V>> range) Source #

where OrdK : Ord<K>

Atomically adds a range of items to the map. If any of the keys exist already then they're replaced.

Null is not allowed for a Key or a Value

Parameters

param range

Range of KeyValuePairs to add

returns

New Map with the items added

method Map<OrdK, K, V> remove <OrdK, K, V> (Map<OrdK, K, V> map, K key) Source #

where OrdK : Ord<K>

Atomically removes an item from the map If the key doesn't exists, the request is ignored.

Parameters

param key

Key

returns

New map with the item removed

method bool containsKey <OrdK, K, V> (Map<OrdK, K, V> map, K key) Source #

where OrdK : Ord<K>

Checks for existence of a key in the map

Parameters

param key

Key to check

returns

True if an item with the key supplied is in the map

method bool contains <OrdK, K, V> (Map<OrdK, K, V> map, KeyValuePair<K, V> kv) Source #

where OrdK : Ord<K>

Checks for existence of a key in the map

Parameters

param key

Key to check

returns

True if an item with the key supplied is in the map

method bool contains <OrdK, K, V> (Map<OrdK, K, V> map, Tuple<K, V> kv) Source #

where OrdK : Ord<K>

Checks for existence of a key in the map

Parameters

param key

Key to check

returns

True if an item with the key supplied is in the map

method bool contains <OrdK, K, V> (Map<OrdK, K, V> map, (K, V) kv) Source #

where OrdK : Ord<K>

Checks for existence of a key in the map

Parameters

param key

Key to check

returns

True if an item with the key supplied is in the map

method Map<OrdK, K, V> setItem <OrdK, K, V> (Map<OrdK, K, V> map, K key, V value) Source #

where OrdK : Ord<K>

Atomically updates an existing item

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<OrdK, K, V> trySetItem <OrdK, K, V> (Map<OrdK, K, V> map, K key, V value) Source #

where OrdK : Ord<K>

Atomically updates an existing item, unless it doesn't exist, in which case it is ignored

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<OrdK, K, V> trySetItem <OrdK, K, V> (Map<OrdK, K, V> map, K key, Func<V, V> Some) Source #

where OrdK : Ord<K>

Atomically sets an item by first retrieving it, applying a map (Some), and then putting it back. Silently fails if the value doesn't exist.

Parameters

param key

Key to set

param Some

delegate to map the existing value to a new one before setting

returns

New map with the item set

method Map<OrdK, K, V> trySetItem <OrdK, K, V> (Map<OrdK, K, V> map, K key, Func<V, V> Some, Func<Map<K, V>, Map<K, V>> None) Source #

where OrdK : Ord<K>

Atomically sets an item by first retrieving it, applying a map, and then putting it back. Calls the None delegate to return a new map if the item can't be found

Null is not allowed for a Key or a Value

Parameters

param key

Key

param Some

delegate to map the existing value to a new one before setting

param None

delegate to return a new map if the item can't be found

returns

New map with the item set

method Map<OrdK, K, V> setItems <OrdK, K, V> (Map<OrdK, K, V> map, IEnumerable<Tuple<K, V>> items) Source #

where OrdK : Ord<K>

Atomically sets a series of items using the Tuples provided

Parameters

param items

Items to set

returns

New map with the items set

method Map<OrdK, K, V> setItems <OrdK, K, V> (Map<OrdK, K, V> map, IEnumerable<(K, V)> items) Source #

where OrdK : Ord<K>

Atomically sets a series of items using the Tuples provided

Parameters

param items

Items to set

returns

New map with the items set

method Map<OrdK, K, V> setItems <OrdK, K, V> (Map<OrdK, K, V> map, IEnumerable<KeyValuePair<K, V>> items) Source #

where OrdK : Ord<K>

Atomically sets a series of items using the KeyValuePairs provided

Parameters

param items

Items to set

returns

New map with the items set

method Map<OrdK, K, V> trySetItems <OrdK, K, V> (Map<OrdK, K, V> map, IEnumerable<Tuple<K, V>> items) Source #

where OrdK : Ord<K>

Atomically sets a series of items using the Tuples provided.

Parameters

param items

Items to set

returns

New map with the items set

method Map<OrdK, K, V> trySetItems <OrdK, K, V> (Map<OrdK, K, V> map, IEnumerable<(K, V)> items) Source #

where OrdK : Ord<K>

Atomically sets a series of items using the Tuples provided.

Parameters

param items

Items to set

returns

New map with the items set

method Map<OrdK, K, V> trySetItems <OrdK, K, V> (Map<OrdK, K, V> map, IEnumerable<KeyValuePair<K, V>> items) Source #

where OrdK : Ord<K>

Atomically sets a series of items using the KeyValuePairs provided. If any of the items don't exist then they're silently ignored.

Parameters

param items

Items to set

returns

New map with the items set

method Map<OrdK, K, V> trySetItems <OrdK, K, V> (Map<OrdK, K, V> map, IEnumerable<K> keys, Func<V, V> Some) Source #

where OrdK : Ord<K>

Atomically sets a series of items using the keys provided to find the items and the Some delegate maps to a new value. If the items don't exist then they're silently ignored.

Parameters

param keys

Keys of items to set

param Some

Function map the existing item to a new one

returns

New map with the items set

method Option<V> find <OrdK, K, V> (Map<OrdK, K, V> map, K key) Source #

where OrdK : Ord<K>

Retrieve a value from the map by key

Parameters

param key

Key to find

returns

Found value

method IEnumerable<V> findSeq <OrdK, K, V> (Map<OrdK, K, V> map, K key) Source #

where OrdK : Ord<K>

Retrieve a value from the map by key as an enumerable

Parameters

param key

Key to find

returns

Found value

method R find <OrdK, K, V, R> (Map<OrdK, K, V> map, K key, Func<V, R> Some, Func<R> None) Source #

where OrdK : Ord<K>

Retrieve a value from the map by key and pattern match the result.

Parameters

param key

Key to find

returns

Found value

method Map<OrdK, K, V> setItem <OrdK, K, V> (Map<OrdK, K, V> map, K key, Func<V, V> mapper) Source #

where OrdK : Ord<K>

Retrieve a value from the map by key, map it to a new value, put it back.

Parameters

param key

Key to find

returns

New map with the mapped value

method IEnumerable<V> findRange <OrdK, K, V> (Map<OrdK, K, V> map, K keyFrom, K keyTo) Source #

where OrdK : Ord<K>

Retrieve a range of values

Parameters

param keyFrom

Range start (inclusive)

param keyTo

Range to (inclusive)

returns

Range of values

method IEnumerable<(K Key, V Value)> skip <OrdK, K, V> (Map<OrdK, K, V> map, int amount) Source #

where OrdK : Ord<K>

Skips 'amount' values and returns a new tree without the skipped values.

Parameters

param amount

Amount to skip

returns

Enumerable of map items

method Unit iter <OrdK, K, V> (Map<OrdK, K, V> map, Action<V> action) Source #

where OrdK : Ord<K>

Atomically iterate through all key/value pairs in the map (in order) and execute an action on each

Parameters

param action

Action to execute

returns

Unit

method Unit iter <OrdK, K, V> (Map<OrdK, K, V> map, Action<K, V> action) Source #

where OrdK : Ord<K>

Atomically iterate through all key/value pairs in the map (in order) and execute an action on each

Parameters

param action

Action to execute

returns

Unit

method bool forall <OrdK, K, V> (Map<OrdK, K, V> map, Func<V, bool> pred) Source #

where OrdK : Ord<K>

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool forall <OrdK, K, V> (Map<OrdK, K, V> map, Func<K, V, bool> pred) Source #

where OrdK : Ord<K>

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool forall <OrdK, K, V> (Map<OrdK, K, V> map, Func<Tuple<K, V>, bool> pred) Source #

where OrdK : Ord<K>

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool forall <OrdK, K, V> (Map<OrdK, K, V> map, Func<(K Key, V Value), bool> pred) Source #

where OrdK : Ord<K>

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool forall <OrdK, K, V> (Map<OrdK, K, V> map, Func<KeyValuePair<K, V>, bool> pred) Source #

where OrdK : Ord<K>

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method Map<OrdK, K, U> map <OrdK, K, T, U> (Map<OrdK, K, T> map, Func<T, U> f) Source #

where OrdK : Ord<K>

Atomically maps the map to a new map

Parameters

returns

Mapped items in a new map

method Map<OrdK, K, U> map <OrdK, K, T, U> (Map<OrdK, K, T> map, Func<K, T, U> f) Source #

where OrdK : Ord<K>

Atomically maps the map to a new map

Parameters

returns

Mapped items in a new map

method Map<OrdK, K, V> filter <OrdK, K, V> (Map<OrdK, K, V> map, Func<V, bool> predicate) Source #

where OrdK : Ord<K>

Atomically filter out items that return false when a predicate is applied

Parameters

param pred

Predicate

returns

New map with items filtered

method Map<OrdK, K, V> filter <OrdK, K, V> (Map<OrdK, K, V> map, Func<K, V, bool> predicate) Source #

where OrdK : Ord<K>

Atomically filter out items that return false when a predicate is applied

Parameters

param pred

Predicate

returns

New map with items filtered

method Map<OrdK, K, R> choose <OrdK, K, T, R> (Map<OrdK, K, T> map, Func<T, Option<R>> selector) Source #

where OrdK : Ord<K>

Equivalent to map and filter but the filtering is done based on whether the returned Option is Some or None. If the item is None then it's filtered out, if not the the mapped Some value is used.

Parameters

param selector

Predicate

returns

Filtered map

method Map<OrdK, K, R> choose <OrdK, K, T, R> (Map<OrdK, K, T> map, Func<K, T, Option<R>> selector) Source #

where OrdK : Ord<K>

Equivalent to map and filter but the filtering is done based on whether the returned Option is Some or None. If the item is None then it's filtered out, if not the the mapped Some value is used.

Parameters

param selector

Predicate

returns

Filtered map

method int length <OrdK, K, T> (Map<OrdK, K, T> map) Source #

where OrdK : Ord<K>

Number of items in the map

method S fold <OrdK, S, K, V> (Map<OrdK, K, V> map, S state, Func<S, K, V, S> folder) Source #

where OrdK : Ord<K>

Atomically folds all items in the map (in order) using the folder function provided.

Parameters

type S

State type

param state

Initial state

param folder

Fold function

returns

Folded state

method S fold <OrdK, S, K, V> (Map<OrdK, K, V> map, S state, Func<S, V, S> folder) Source #

where OrdK : Ord<K>

Atomically folds all items in the map (in order) using the folder function provided.

Parameters

type S

State type

param state

Initial state

param folder

Fold function

returns

Folded state

method bool exists <OrdK, K, V> (Map<OrdK, K, V> map, Func<K, V, bool> pred) Source #

where OrdK : Ord<K>

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool exists <OrdK, K, V> (Map<OrdK, K, V> map, Func<Tuple<K, V>, bool> pred) Source #

where OrdK : Ord<K>

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool exists <OrdK, K, V> (Map<OrdK, K, V> map, Func<(K Key, V Value), bool> pred) Source #

where OrdK : Ord<K>

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool exists <OrdK, K, V> (Map<OrdK, K, V> map, Func<KeyValuePair<K, V>, bool> pred) Source #

where OrdK : Ord<K>

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool exists <OrdK, K, V> (Map<OrdK, K, V> map, Func<V, bool> pred) Source #

where OrdK : Ord<K>

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method Map<OrdK, K, V> toMap <OrdK, K, V> (IDictionary<K, V> dict) Source #

where OrdK : Ord<K>

Convert any IDictionary into an immutable Map K V

method HashMap<OrdK, K, V> toHashMap <OrdK, K, V> (IDictionary<K, V> dict) Source #

where OrdK : Ord<K>

Convert any IDictionary into an immutable Map K V

method HashMap<OrdK, K, V> ToHashMap <OrdK, K, V> (this IDictionary<K, V> dict) Source #

where OrdK : Ord<K>

Convert any IDictionary into an immutable Map K V

method Map<OrdK, K, V> union <OrdK, K, V> (Map<OrdK, K, V> left, Map<OrdK, K, V> right, WhenMatched<K, V, V, V> Merge) Source #

where OrdK : Ord<K>

Union two maps. The merge function is called keys are present in both map.

method Map<OrdK, K, A> union <OrdK, K, A, B> (Map<OrdK, K, A> left, Map<OrdK, K, B> right, WhenMissing<K, B, A> MapRight, WhenMatched<K, A, B, A> Merge) Source #

where OrdK : Ord<K>

Union two maps. The merge function is called keys are present in both map.

method Map<OrdK, K, B> union <OrdK, K, A, B> (Map<OrdK, K, A> left, Map<OrdK, K, B> right, WhenMissing<K, A, B> MapLeft, WhenMatched<K, A, B, B> Merge) Source #

where OrdK : Ord<K>

Union two maps. The merge function is called keys are present in both map.

method Map<OrdK, K, C> union <OrdK, K, A, B, C> (Map<OrdK, K, A> left, Map<OrdK, K, B> right, WhenMissing<K, A, C> MapLeft, WhenMissing<K, B, C> MapRight, WhenMatched<K, A, B, C> Merge) Source #

where OrdK : Ord<K>

Union two maps. The merge function is called keys are present in both map.

method Map<OrdK, K, R> intersect <OrdK, K, A, B, R> (Map<OrdK, K, A> left, Map<OrdK, K, B> right, WhenMatched<K, A, B, R> merge) Source #

where OrdK : Ord<K>

method Map<OrdK, K, V> except <OrdK, K, V> (Map<OrdK, K, V> left, Map<OrdK, K, V> right) Source #

where OrdK : Ord<K>

Map differencing based on key. this - other.

method Map<OrdK, K, V> symmetricExcept <OrdK, K, V> (Map<OrdK, K, V> left, Map<OrdK, K, V> right) Source #

where OrdK : Ord<K>

Keys that are in both maps are dropped and the remaining items are merged and returned.

struct Map <OrdK, K, V> Source #

where OrdK : Ord<K>

Immutable map AVL tree implementation AVL tree is a self-balancing binary search tree. wikipedia.org/wiki/AVL_tree

Parameters

type K

Key type

type V

Value type

Indexers

this [ V ] Source #

'this' accessor

Parameters

param key

Key

returns

Optional value

Properties

property Map<OrdK, K, V> Empty Source #

property object? Case Source #

Reference version for use in pattern-matching

Empty collection     = null
Singleton collection = (K, V)
More                 = ((K, V), Seq<(K, V)>)   -- head and tail

var res = list.Case switch
{

   (var x, var xs) => ...,
   A value         => ...,
   _               => ...
}

property bool IsEmpty Source #

Is the map empty

property int Count Source #

Number of items in the map

property int Length Source #

Alias of Count

property Iterable<K> Keys Source #

Enumerable of map keys

property Iterable<V> Values Source #

Enumerable of map values

property Iterable<(K Key, V Value)> Pairs Source #

Enumerable of in-order tuples that make up the map

Parameters

returns

Tuples

property Iterable<(K Key, V Value)> ValueTuples Source #

Enumerable of in-order tuples that make up the map

Parameters

returns

Tuples

property Option<(K Key, V Value)> Min Source #

Find the lowest ordered item in the map

property Option<(K Key, V Value)> Max Source #

Find the highest ordered item in the map

property Map<OrdK, K, V> AdditiveIdentity Source #

Constructors

constructor Map (IEnumerable<(K Key, V Value)> items) Source #

constructor Map (ReadOnlySpan<(K Key, V Value)> items) Source #

constructor Map (IEnumerable<(K Key, V Value)> items, bool tryAdd) Source #

constructor Map (ReadOnlySpan<(K Key, V Value)> items, bool tryAdd) Source #

Methods

method Map<OrdK, K, V> Add (K key, V value) Source #

Atomically adds a new item to the map

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<OrdK, K, V> TryAdd (K key, V value) Source #

Atomically adds a new item to the map. If the key already exists, then the new item is ignored

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<OrdK, K, V> TryAdd (K key, V value, Func<Map<OrdK, K, V>, V, Map<OrdK, K, V>> Fail) Source #

Atomically adds a new item to the map. If the key already exists then the Fail handler is called with the unaltered map and the value already set for the key, it expects a new map returned.

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

param Fail

Delegate to handle failure, you're given the unaltered map and the value already set for the key

returns

New Map with the item added

method Map<OrdK, K, V> AddRange (IEnumerable<Tuple<K, V>> range) Source #

Atomically adds a range of items to the map.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<OrdK, K, V> AddRange (IEnumerable<(K, V)> range) Source #

Atomically adds a range of items to the map.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<OrdK, K, V> TryAddRange (IEnumerable<Tuple<K, V>> range) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're ignored.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<OrdK, K, V> TryAddRange (IEnumerable<(K, V)> range) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're ignored.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<OrdK, K, V> TryAddRange (IEnumerable<KeyValuePair<K, V>> range) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're ignored.

Null is not allowed for a Key or a Value

Parameters

param range

Range of KeyValuePairs to add

returns

New Map with the items added

method Map<OrdK, K, V> AddOrUpdateRange (IEnumerable<Tuple<K, V>> range) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're replaced.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<OrdK, K, V> AddOrUpdateRange (IEnumerable<(K, V)> range) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're replaced.

Null is not allowed for a Key or a Value

Parameters

param range

Range of tuples to add

returns

New Map with the items added

method Map<OrdK, K, V> AddOrUpdateRange (IEnumerable<KeyValuePair<K, V>> range) Source #

Atomically adds a range of items to the map. If any of the keys exist already then they're replaced.

Null is not allowed for a Key or a Value

Parameters

param range

Range of KeyValuePairs to add

returns

New Map with the items added

method Map<OrdK, K, V> Remove (K key) Source #

Atomically removes an item from the map If the key doesn't exists, the request is ignored.

Parameters

param key

Key

returns

New map with the item removed

method Option<V> Find (K key) Source #

Retrieve a value from the map by key

Parameters

param key

Key to find

returns

Found value

method Seq<V> FindSeq (K key) Source #

Retrieve a value from the map by key as an enumerable

Parameters

param key

Key to find

returns

Found value

method R Find <R> (K key, Func<V, R> Some, Func<R> None) Source #

Retrieve a value from the map by key and pattern match the result.

Parameters

param key

Key to find

returns

Found value

method Option<(K Key, V Value)> FindPredecessor (K key) Source #

Retrieve the value from previous item to specified key

Parameters

param key

Key to find

returns

Found key/value

method Option<(K Key, V Value)> FindExactOrPredecessor (K key) Source #

Retrieve the value from exact key, or if not found, the previous item

Parameters

param key

Key to find

returns

Found key/value

method Option<(K Key, V Value)> FindSuccessor (K key) Source #

Retrieve the value from next item to specified key

Parameters

param key

Key to find

returns

Found key/value

method Option<(K Key, V Value)> FindExactOrSuccessor (K key) Source #

Retrieve the value from exact key, or if not found, the next item

Parameters

param key

Key to find

returns

Found key/value

method (Map<OrdK, K, V> Map, V Value) FindOrAdd (K key, Func<V> None) Source #

Try to find the key in the map, if it doesn't exist, add a new item by invoking the delegate provided.

Parameters

param key

Key to find

param None

Delegate to get the value

returns

Updated map and added value

method (Map<OrdK, K, V>, V Value) FindOrAdd (K key, V value) Source #

Try to find the key in the map, if it doesn't exist, add a new item provided.

Parameters

param key

Key to find

param value

Delegate to get the value

returns

Updated map and added value

method (Map<OrdK, K, V> Map, Option<V> Value) FindOrMaybeAdd (K key, Func<Option<V>> None) Source #

Try to find the key in the map, if it doesn't exist, add a new item by invoking the delegate provided.

Parameters

param key

Key to find

param None

Delegate to get the value

returns

Updated map and added value

method (Map<OrdK, K, V> Map, Option<V> Value) FindOrMaybeAdd (K key, Option<V> None) Source #

Try to find the key in the map, if it doesn't exist, add a new item by invoking the delegate provided.

Parameters

param key

Key to find

param None

Delegate to get the value

returns

Updated map and added value

method Map<OrdK, K, V> SetItem (K key, V value) Source #

Atomically updates an existing item

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<OrdK, K, V> SetItem (K key, Func<V, V> Some) Source #

Retrieve a value from the map by key, map it to a new value, put it back.

Parameters

param key

Key to set

returns

New map with the mapped value

method Map<OrdK, K, V> TrySetItem (K key, V value) Source #

Atomically updates an existing item, unless it doesn't exist, in which case it is ignored

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<OrdK, K, V> TrySetItem (K key, Func<V, V> Some) Source #

Atomically sets an item by first retrieving it, applying a map, and then putting it back. Silently fails if the value doesn't exist

Parameters

param key

Key to set

param Some

delegate to map the existing value to a new one before setting

returns

New map with the item set

method Map<OrdK, K, V> TrySetItem (K key, Func<V, V> Some, Func<Map<K, V>, Map<K, V>> None) Source #

Atomically sets an item by first retrieving it, applying a map, and then putting it back. Calls the None delegate to return a new map if the item can't be found

Null is not allowed for a Key or a Value

Parameters

param key

Key

param Some

delegate to map the existing value to a new one before setting

param None

delegate to return a new map if the item can't be found

returns

New map with the item set

method Map<OrdK, K, V> AddOrUpdate (K key, V value) Source #

Atomically adds a new item to the map. If the key already exists, the new item replaces it.

Null is not allowed for a Key or a Value

Parameters

param key

Key

param value

Value

returns

New Map with the item added

method Map<OrdK, K, V> AddOrUpdate (K key, Func<V, V> Some, Func<V> None) Source #

Retrieve a value from the map by key, map it to a new value, put it back. If it doesn't exist, add a new one based on None result.

Parameters

param key

Key to find

returns

New map with the mapped value

method Map<OrdK, K, V> AddOrUpdate (K key, Func<V, V> Some, V None) Source #

Retrieve a value from the map by key, map it to a new value, put it back. If it doesn't exist, add a new one based on None result.

Parameters

param key

Key to find

returns

New map with the mapped value

method Iterable<V> FindRange (K keyFrom, K keyTo) Source #

Retrieve a range of values

Parameters

param keyFrom

Range start (inclusive)

param keyTo

Range to (inclusive)

returns

Range of values

method Iterable<(K Key, V Value)> FindRangePairs (K keyFrom, K keyTo) Source #

Retrieve a range of values

Parameters

param keyFrom

Range start (inclusive)

param keyTo

Range to (inclusive)

returns

Range of values

method Iterable<(K Key, V Value)> Skip (int amount) Source #

Skips 'amount' values and returns a new tree without the skipped values.

Parameters

param amount

Amount to skip

returns

New tree

method bool ContainsKey (K key) Source #

Checks for existence of a key in the map

Parameters

param key

Key to check

returns

True if an item with the key supplied is in the map

method bool Contains (K key, V value) Source #

Checks for existence of a key in the map

Parameters

param key

Key to check

returns

True if an item with the key supplied is in the map

method Map<OrdK, K, V> Clear () Source #

Clears all items from the map

Functionally equivalent to calling Map.empty as the original structure is untouched

Parameters

returns

Empty map

method Map<OrdK, K, V> SetItems (IEnumerable<KeyValuePair<K, V>> items) Source #

Atomically sets a series of items using the KeyValuePairs provided

Parameters

param items

Items to set

returns

New map with the items set

method Map<OrdK, K, V> SetItems (IEnumerable<Tuple<K, V>> items) Source #

Atomically sets a series of items using the Tuples provided.

Parameters

param items

Items to set

returns

New map with the items set

method Map<OrdK, K, V> SetItems (IEnumerable<(K, V)> items) Source #

Atomically sets a series of items using the Tuples provided.

Parameters

param items

Items to set

returns

New map with the items set

method Map<OrdK, K, V> TrySetItems (IEnumerable<KeyValuePair<K, V>> items) Source #

Atomically sets a series of items using the KeyValuePairs provided. If any of the items don't exist then they're silently ignored.

Parameters

param items

Items to set

returns

New map with the items set

method Map<OrdK, K, V> TrySetItems (IEnumerable<Tuple<K, V>> items) Source #

Atomically sets a series of items using the Tuples provided If any of the items don't exist then they're silently ignored.

Parameters

param items

Items to set

returns

New map with the items set

method Map<OrdK, K, V> TrySetItems (IEnumerable<(K, V)> items) Source #

Atomically sets a series of items using the Tuples provided If any of the items don't exist then they're silently ignored.

Parameters

param items

Items to set

returns

New map with the items set

method Map<OrdK, K, V> TrySetItems (IEnumerable<K> keys, Func<V, V> Some) Source #

Atomically sets a series of items using the keys provided to find the items and the Some delegate maps to a new value. If the items don't exist then they're silently ignored.

Parameters

param keys

Keys of items to set

param Some

Function map the existing item to a new one

returns

New map with the items set

method Map<OrdK, K, V> RemoveRange (IEnumerable<K> keys) Source #

Atomically removes a set of keys from the map

Parameters

param keys

Keys to remove

returns

New map with the items removed

method bool Contains (KeyValuePair<K, V> pair) Source #

Returns true if a Key/Value pair exists in the map

Parameters

param pair

Pair to find

returns

True if exists, false otherwise

method IDictionary<KR, VR> ToDictionary <KR, VR> (Func<(K Key, V Value), KR> keySelector, Func<(K Key, V Value), VR> valueSelector) Source #

where KR : notnull

Map the map the a dictionary

method IEnumerator<(K Key, V Value)> GetEnumerator () Source #

GetEnumerator - IEnumerable interface

method Seq<(K Key, V Value)> ToSeq () Source #

method string ToString () Source #

Format the collection as [(key: value), (key: value), (key: value), ...] The elipsis is used for collections over 50 items To get a formatted string with all the items, use ToFullString or ToFullArrayString.

method string ToFullString (string separator = ", ") Source #

Format the collection as (key: value), (key: value), (key: value), ...

method string ToFullArrayString (string separator = ", ") Source #

Format the collection as [(key: value), (key: value), (key: value), ...]

method Iterable<(K Key, V Value)> AsEnumerable () Source #

method Map<OrdK, K, V> Combine (Map<OrdK, K, V> y) Source #

method bool Equals (object? obj) Source #

Equality of keys and values with EqDefault<V> used for values

method bool Equals (Map<OrdK, K, V> y) Source #

Equality of keys and values with EqDefault<V> used for values

method bool Equals <EqV> (Map<OrdK, K, V> y) Source #

where EqV : Eq<V>

Equality of keys and values

method bool EqualsKeys (Map<OrdK, K, V> y) Source #

Equality of keys only

method int GetHashCode () Source #

method int CompareTo (object? obj) Source #

method Map<OrdK, K, V> Do (Action<V> f) Source #

Impure iteration of the bound values in the structure

Parameters

returns

Returns the original unmodified structure

method Map<OrdK, K, U> Select <U> (Func<V, U> mapper) Source #

Atomically maps the map to a new map

Parameters

returns

Mapped items in a new map

method Map<OrdK, K, U> Select <U> (Func<K, V, U> mapper) Source #

Atomically maps the map to a new map

Parameters

returns

Mapped items in a new map

method Map<OrdK, K, V> Where (Func<V, bool> valuePred) Source #

Atomically filter out items that return false when a predicate is applied

Parameters

param valuePred

Predicate

returns

New map with items filtered

method Map<OrdK, K, V> Where (Func<K, V, bool> keyValuePred) Source #

Atomically filter out items that return false when a predicate is applied

Parameters

param keyValuePred

Predicate

returns

New map with items filtered

method Map<OrdK, K, V> Filter (Func<V, bool> valuePred) Source #

Atomically filter out items that return false when a predicate is applied

Parameters

param valuePred

Predicate

returns

New map with items filtered

method Map<OrdK, K, V> Filter (Func<K, V, bool> keyValuePred) Source #

Atomically filter out items that return false when a predicate is applied

Parameters

param keyValuePred

Predicate

returns

New map with items filtered

method bool ForAll (Func<K, V, bool> pred) Source #

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool ForAll (Func<Tuple<K, V>, bool> pred) Source #

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool ForAll (Func<(K Key, V Value), bool> pred) Source #

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool ForAll (Func<KeyValuePair<K, V>, bool> pred) Source #

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool ForAll (Func<V, bool> pred) Source #

Return true if all items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool Exists (Func<K, V, bool> pred) Source #

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool Exists (Func<Tuple<K, V>, bool> pred) Source #

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool Exists (Func<(K, V), bool> pred) Source #

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool Exists (Func<KeyValuePair<K, V>, bool> pred) Source #

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method bool Exists (Func<V, bool> pred) Source #

Return true if any items in the map return true when the predicate is applied

Parameters

param pred

Predicate

returns

True if all items in the map return true when the predicate is applied

method Unit Iter (Action<K, V> action) Source #

Atomically iterate through all key/value pairs in the map (in order) and execute an action on each

Parameters

param action

Action to execute

returns

Unit

method Unit Iter (Action<V> action) Source #

Atomically iterate through all values in the map (in order) and execute an action on each

Parameters

param action

Action to execute

returns

Unit

method Unit Iter (Action<Tuple<K, V>> action) Source #

Atomically iterate through all key/value pairs (as tuples) in the map (in order) and execute an action on each

Parameters

param action

Action to execute

returns

Unit

method Unit Iter (Action<(K, V)> action) Source #

Atomically iterate through all key/value pairs (as tuples) in the map (in order) and execute an action on each

Parameters

param action

Action to execute

returns

Unit

method Unit Iter (Action<KeyValuePair<K, V>> action) Source #

Atomically iterate through all key/value pairs in the map (in order) and execute an action on each

Parameters

param action

Action to execute

returns

Unit

method Map<OrdK, K, U> Choose <U> (Func<K, V, Option<U>> selector) Source #

Equivalent to map and filter but the filtering is done based on whether the returned Option is Some or None. If the item is None then it's filtered out, if not the the mapped Some value is used.

Parameters

param selector

Predicate

returns

Filtered map

method Map<OrdK, K, U> Choose <U> (Func<V, Option<U>> selector) Source #

Equivalent to map and filter but the filtering is done based on whether the returned Option is Some or None. If the item is None then it's filtered out, if not the the mapped Some value is used.

Parameters

param selector

Predicate

returns

Filtered map

method S Fold <S> (S state, Func<S, K, V, S> folder) Source #

Atomically folds all items in the map (in order) using the folder function provided.

Parameters

type S

State type

param state

Initial state

param folder

Fold function

returns

Folded state

method S Fold <S> (S state, Func<S, V, S> folder) Source #

Atomically folds all items in the map (in order) using the folder function provided.

Parameters

type S

State type

param state

Initial state

param folder

Fold function

returns

Folded state

method Map<OrdK, K, V> Union (Map<OrdK, K, V> other, WhenMatched<K, V, V, V> Merge) Source #

Union two maps. The merge function is called keys are present in both map.

method Map<OrdK, K, V> Union <V2> (Map<OrdK, K, V2> other, WhenMissing<K, V2, V> MapRight, WhenMatched<K, V, V2, V> Merge) Source #

Union two maps. The merge function is called keys are present in both map.

method Map<OrdK, K, V2> Union <V2> (Map<OrdK, K, V2> other, WhenMissing<K, V, V2> MapLeft, WhenMatched<K, V, V2, V2> Merge) Source #

Union two maps. The merge function is called keys are present in both map.

method Map<OrdK, K, R> Union <V2, R> (Map<OrdK, K, V2> other, WhenMissing<K, V, R> MapLeft, WhenMissing<K, V2, R> MapRight, WhenMatched<K, V, V2, R> Merge) Source #

Union two maps. The merge function is called keys are present in both map.

method Map<OrdK, K, R> Intersect <V2, R> (Map<OrdK, K, V2> other, WhenMatched<K, V, V2, R> Merge) Source #

method Map<OrdK, K, V> Except (Map<OrdK, K, V> other) Source #

Map differencing based on key. this - other.

method Map<OrdK, K, V> SymmetricExcept (Map<OrdK, K, V> other) Source #

Keys that are in both maps are dropped and the remaining items are merged and returned.

method int CompareTo (Map<OrdK, K, V> other) Source #

Compare keys and values (values use OrdDefault<V> for ordering)

method int CompareTo <OrdV> (Map<OrdK, K, V> other) Source #

where OrdV : Ord<V>

Compare keys and values (values use OrdV for ordering)

method int CompareKeysTo (Map<OrdK, K, V> other) Source #

Compare keys only

method Map<OrdK, K, V> Slice (K keyFrom, K keyTo) Source #

Creates a new map from a range/slice of this map

Parameters

param keyFrom

Range start (inclusive)

param keyTo

Range to (inclusive)

returns

method bool TryGetValue (K key, out V value) Source #

Operators

operator == (Map<OrdK, K, V> lhs, Map<OrdK, K, V> rhs) Source #

operator != (Map<OrdK, K, V> lhs, Map<OrdK, K, V> rhs) Source #

operator < (Map<OrdK, K, V> lhs, Map<OrdK, K, V> rhs) Source #

operator <= (Map<OrdK, K, V> lhs, Map<OrdK, K, V> rhs) Source #

operator > (Map<OrdK, K, V> lhs, Map<OrdK, K, V> rhs) Source #

operator >= (Map<OrdK, K, V> lhs, Map<OrdK, K, V> rhs) Source #

operator + (Map<OrdK, K, V> lhs, Map<OrdK, K, V> rhs) Source #

operator - (Map<OrdK, K, V> lhs, Map<OrdK, K, V> rhs) Source #

class Prelude Source #

Methods

method Map<Key, B> map <Key, A, B> (Func<A, B> f, K<Map<Key>, A> ma) Source #

Functor map operation

Unwraps the value within the functor, passes it to the map function f provided, and then takes the mapped value and wraps it back up into a new functor.

Parameters

param ma

Functor to map

param f

Mapping function

returns

Mapped functor

class Map <Key> Source #