DefaultDict<'K, 'V> Type
A Collections.Generic.Dictionary<'K,'V> with default Values that get created upon accessing a missing key.
If accessing a non exiting key , the default function is called to create and set it.
Inspired by the defaultdict in Python.
If you need to provide a custom implementation of the default function depending on each key,
then use the Dict<'K,'V> type and it's method
Constructors
Constructor |
Description
|
Full Usage:
DefaultDict(defaultOfKeyFun)
Parameters:
'K -> 'V
-
('K->'V): The function to create a default value from the key
Returns: DefaultDict<'K, 'V>
|
A Collections.Generic.Dictionary with default Values that get created upon accessing a key. If accessing a non exiting key , the default function is called on the key to create the value and set it. Similar to defaultDic in Python
|
Instance members
Instance member |
Description
|
Full Usage:
this.Add
Parameters:
'K
v : 'V
|
Add the specified key and value to the DefaultDict.
|
Full Usage:
this.AsString
Returns: string
|
A string representation of the DefaultDict including the count of entries and the first 5 entries. When used in Fable this member is inlined for reflection to work.
|
Full Usage:
this.Clear
|
Removes all keys and values from the DefaultDict |
Full Usage:
this.ContainsKey
Parameters:
'K
Returns: bool
|
Determines whether the DefaultDict contains the specified key.
|
Full Usage:
this.ContainsValue
Parameters:
'V
Returns: bool
|
Determines whether the DefaultDict contains a specific value.
|
Full Usage:
this.Count
Returns: int
|
Gets the number of key/value pairs contained in the DefaultDict
|
Full Usage:
this.DoesNotContainKey
Parameters:
'K
Returns: bool
|
Determines whether the DefaultDict does not contains the specified key. not(dic.ContainsKey(key))
|
Full Usage:
this.Get
Parameters:
'K
Returns: 'V
|
Get value for given key. Calls defaultFun to get value if key not found. Also sets key to returned value. Use .TryGetValue(k) if you don't want a missing key to be created
|
|
Returns an enumerator that iterates through the DefaultDict.
|
|
Access the underlying Collections.Generic.Dictionary<'K,'V>. ATTENTION! This is not even a shallow copy, mutating it will also change this instance of DefaultDict!
|
Full Usage:
this[k]
Returns: 'K
|
For Index operator .[i]: get or set the value for a given key Calls defaultFun to get value if key not found. Also sets the key to returned value. Use dict.TryGetValue(k) if you don't want a missing key to be created on the DefaultDict
|
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 DefaultDict
|
Full Usage:
this.Pop
Parameters:
'K
Returns: 'V
|
Get a value and remove key and value it from Dictionary, like *.pop() in Python Will fail if key does not exist Does not set any new key if key is missing
|
Full Usage:
this.Remove
Parameters:
'K
Returns: bool
|
Removes the value with the specified key from the DefaultDict. See also .Pop(key) method to get the contained value too.
|
Full Usage:
this.Set
Parameters:
'K
value : 'V
|
Set value for given key, same as
|
Full Usage:
this.ToString
Parameters:
int
Returns: string
|
A string representation of the DefaultDict including the count of entries and the specified amount of entries. When used in Fable this member is inlined for reflection to work.
|
Full Usage:
this.TryGetValue
Parameters:
'K
Returns: bool * 'V
|
Gets the value associated with the specified key. As opposed to Get(key) this does not create a key if it is missing.
|
Full Usage:
this.TryPop
Parameters:
'K
Returns: 'V option
|
Get a value and remove key and value it from Dictionary, like *.pop() in Python Returns None if key does not exist Does not set any new key if key is missing
|
|
Gets a collection containing the values in the DefaultDict
|
Static members
Static member |
Description
|
Full Usage:
DefaultDict.create defaultOfKeyFun keysValues
Parameters:
'K -> 'V
keysValues : ('K * 'V) seq
Returns: DefaultDict<'K, 'V>
|
Constructs a new DefaultDict from seq of key and value pairs
|
Full Usage:
DefaultDict.createDirectly defaultOfKeyFun di
Parameters:
'K -> 'V
di : Dictionary<'K, 'V>
Returns: DefaultDict<'K, 'V>
|
Constructs a new DefaultDict by using the supplied Dictionary<'K,'V> directly, without any copying of items
|
|
|
|
Set value for given key, same as
|