Dict<'K, 'V> Type
A thin wrapper over Collections.Generic.Dictionary<'K,'V> with nicer Error messages on accessing missing keys.
Constructors
| Constructor |
Description
|
Full Usage:
Dict(iEqualityComparer)
Parameters:
IEqualityComparer<'K>
-
The comparer used to determine the equality of keys.
Returns: Dict<'K, 'V>
|
Create a new empty Dict<'K,'V> with an IEqualityComparer like HashIdentity.Structural. A Dict is a thin wrapper over System.Collections.Generic.Dictionary<'K,'V> with nicer Error messages on accessing missing keys.
|
Create a new empty Dict<'K,'V> . A Dict is a thin wrapper over System.Collections.Generic.Dictionary<'K,'V> ) with nicer Error messages on accessing missing keys.
|
Instance members
| Instance member |
Description
|
Full Usage:
this.Add
Parameters:
'K
-
The key to add.
value : 'V
-
The value to add.
|
Add the specified key and value to the Dict. Like Dictionary.Add, it throws an ArgumentException if the key already exists. Use .Set(key, value) or the indexer to add or replace a value.
|
Full Usage:
this.AddIfKeyAbsent
Parameters:
'K
-
The key to set.
value : 'V
-
The value to set if the key is missing.
Returns: bool
true if the value was set, false if the key already existed and nothing was changed.
|
Set value only if key does not exist yet.
Same as
|
Full Usage:
this.AsString
Returns: string
|
A string representation of the Dict including the count of entries, the first 5 entries and the last entry. When used in Fable this member is inlined for reflection to work.
|
Full Usage:
this.Clear
|
Removes all keys and values from the Dict |
Full Usage:
this.ContainsKey
Parameters:
'K
-
The key to look for.
Returns: bool
|
Determines whether the Dict contains the specified key.
|
Full Usage:
this.ContainsValue
Parameters:
'V
-
The value to look for.
Returns: bool
|
Determines whether the Dict contains a specific value.
|
Full Usage:
this.Count
Returns: int
|
Gets the number of key/value pairs contained in the Dict
|
Full Usage:
this.DoesNotContainKey
Parameters:
'K
-
The key to look for.
Returns: bool
|
Determines whether the Dict does not contain the specified key.
Same as
|
Full Usage:
this.Get
Parameters:
'K
-
The key to look up.
Returns: 'V
|
Get value for given key. Throws a KeyNotFoundException with a descriptive message if the key is not found.
|
|
Returns an enumerator that iterates through the Dict.
|
Full Usage:
this.GetOrSetDefault
Parameters:
'K -> 'V
-
The function to create the value from the key, only called if the key is missing.
key : 'K
-
The key to look up.
Returns: 'V
The existing or the newly created value.
|
If the key is not present calls the default function, sets its result as value at the key and returns it. This function is an alternative to the DefaultDict type. Use it if you need to provide a custom implementation of the default function depending on the key.
|
Full Usage:
this.GetOrSetDefaultValue
Parameters:
'V
-
The value to set if the key is missing.
key : 'K
-
The key to look up.
Returns: 'V
The existing value or the default value.
|
If the key is not present sets the default value at the key and returns it.
|
|
Access the underlying Collections.Generic.Dictionary<'K,'V>. ATTENTION! This is not even a shallow copy, mutating it will also change this instance of Dict!
|
Full Usage:
this.IsEmpty
Returns: bool
|
Tests if the Dict is Empty.
|
Full Usage:
this.IsNotEmpty
Returns: bool
|
Tests if the Dict is NOT Empty.
|
Full Usage:
this[k]
Returns: 'K
|
For Index operator .[i]: get or set the value for given key Throws a nice exception if the key is not found.
|
Full Usage:
this.Items
Returns: ('K * 'V) seq
|
Returns a (lazy) sequence of key and value tuples
|
|
Gets a collection containing the keys in the Dict same as on System.Collections.Generic.Dict<'K,'V>
|
Full Usage:
this.KeysSeq
Returns: 'K seq
|
Returns a (lazy) sequence of Keys
|
Full Usage:
this.Pop
Parameters:
'K
-
The key to remove.
Returns: 'V
The value that was stored at the key.
|
Get a value and remove the key and value from the Dict, like *.pop() in Python. Throws a KeyNotFoundException if the key does not exist.
|
Full Usage:
this.Remove
Parameters:
'K
-
The key to remove.
Returns: bool
true if the key was found and removed, false if not.
|
Removes the value with the specified key from the Dict. See also the .Pop(key) method that returns the removed value.
|
Full Usage:
this.Set
Parameters:
'K
-
The key to set.
value : 'V
-
The value to set.
|
Set value for given key, adds the key if it is missing.
Same as
|
Full Usage:
this.SetIfKeyAbsent
Parameters:
'K
-
The key to set.
value : 'V
-
The value to set if the key is missing.
Returns: bool
true if the value was set, false if the key already existed and nothing was changed.
|
Set value only if key does not exist yet.
Same as
|
Full Usage:
this.ToString
Parameters:
int
-
The maximum number of entries to show. Zero or less shows only the header.
Returns: string
|
A string representation of the Dict including the count of entries, the specified amount of entries and the last entry. When used in Fable this member is inlined for reflection to work.
|
Full Usage:
this.TryGetValue
Parameters:
'K
-
The input key.
refValue : byref<'V>
-
A reference to the output value.
Returns: bool
true if the value is present, false if not.
|
Lookup an element in the Dict, assigning it to
|
Full Usage:
this.TryPop
Parameters:
'K
-
The key to remove.
Returns: 'V option
Some value if the key was found, None if not.
|
Try to get a value and remove the key and value from the Dict.
|
|
Gets a collection containing the values in the Dict same as on System.Collections.Generic.Dict<'K,'V>
|
Full Usage:
this.ValuesSeq
Returns: 'V seq
|
Returns a (lazy) sequence of values
|
Static members
| Static member |
Description
|
Full Usage:
Dict.createDirectly dic
Parameters:
Dictionary<'K, 'V>
-
The Dictionary to wrap. Changes to it show in the new Dict and the other way round.
Returns: Dict<'K, 'V>
|
Constructs a new Dict by using the supplied Dictionary<'K,'V> directly, without any copying of items.
|
Dicts