Logo Dicts

Dict<'K, 'V> Type

A thin wrapper over Collections.Generic.Dictionary<'K,'V> with nicer Error messages on accessing missing keys.

Constructors

Constructor Description

Dict(iEqualityComparer)

Full Usage: Dict(iEqualityComparer)

Parameters:
    iEqualityComparer : 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.

iEqualityComparer : IEqualityComparer<'K>

The comparer used to determine the equality of keys.

Returns: Dict<'K, 'V>

Dict()

Full Usage: Dict()

Returns: Dict<'K, 'V>

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.

Returns: Dict<'K, 'V>

Instance members

Instance member Description

this.Add

Full Usage: this.Add

Parameters:
    key : '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.

key : 'K

The key to add.

value : 'V

The value to add.

this.AddIfKeyAbsent

Full Usage: this.AddIfKeyAbsent

Parameters:
    key : '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 Dict.SetIfKeyAbsent key value

key : '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.

this.AsString

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.

Returns: string

this.Clear

Full Usage: this.Clear

Removes all keys and values from the Dict

this.ContainsKey

Full Usage: this.ContainsKey

Parameters:
    key : 'K - The key to look for.

Returns: bool

Determines whether the Dict contains the specified key.

key : 'K

The key to look for.

Returns: bool

this.ContainsValue

Full Usage: this.ContainsValue

Parameters:
    value : 'V - The value to look for.

Returns: bool

Determines whether the Dict contains a specific value.

value : 'V

The value to look for.

Returns: bool

this.Count

Full Usage: this.Count

Returns: int

Gets the number of key/value pairs contained in the Dict

Returns: int

this.DoesNotContainKey

Full Usage: this.DoesNotContainKey

Parameters:
    key : 'K - The key to look for.

Returns: bool

Determines whether the Dict does not contain the specified key. Same as not(dic.ContainsKey(key))

key : 'K

The key to look for.

Returns: bool

this.Get

Full Usage: this.Get

Parameters:
    key : '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.

key : 'K

The key to look up.

Returns: 'V

this.GetEnumerator

Full Usage: this.GetEnumerator

Returns: Enumerator<'K, 'V>

Returns an enumerator that iterates through the Dict.

Returns: Enumerator<'K, 'V>

this.GetOrSetDefault

Full Usage: this.GetOrSetDefault

Parameters:
    getDefault : '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.

getDefault : '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.

this.GetOrSetDefaultValue

Full Usage: this.GetOrSetDefaultValue

Parameters:
    defaultValue : '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.

defaultValue : '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.

this.InternalDictionary

Full Usage: this.InternalDictionary

Returns: Dictionary<'K, 'V>

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!

Returns: Dictionary<'K, 'V>

this.IsEmpty

Full Usage: this.IsEmpty

Returns: bool

Tests if the Dict is Empty.

Returns: bool

this.IsNotEmpty

Full Usage: this.IsNotEmpty

Returns: bool

Tests if the Dict is NOT Empty.

Returns: bool

this[k]

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.

Returns: 'K

this.Items

Full Usage: this.Items

Returns: ('K * 'V) seq

Returns a (lazy) sequence of key and value tuples

Returns: ('K * 'V) seq

this.Keys

Full Usage: this.Keys

Returns: KeyCollection<'K, 'V>

Gets a collection containing the keys in the Dict same as on System.Collections.Generic.Dict<'K,'V>

Returns: KeyCollection<'K, 'V>

this.KeysSeq

Full Usage: this.KeysSeq

Returns: 'K seq

Returns a (lazy) sequence of Keys

Returns: 'K seq

this.Pop

Full Usage: this.Pop

Parameters:
    key : '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.

key : 'K

The key to remove.

Returns: 'V

The value that was stored at the key.

this.Remove

Full Usage: this.Remove

Parameters:
    key : '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.

key : 'K

The key to remove.

Returns: bool

true if the key was found and removed, false if not.

this.Set

Full Usage: this.Set

Parameters:
    key : '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 Dict.set key value dict

key : 'K

The key to set.

value : 'V

The value to set.

this.SetIfKeyAbsent

Full Usage: this.SetIfKeyAbsent

Parameters:
    key : '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 Dict.AddIfKeyAbsent key value

key : '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.

this.ToString

Full Usage: this.ToString

Parameters:
    entriesToPrint : 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.

entriesToPrint : int

The maximum number of entries to show. Zero or less shows only the header.

Returns: string

this.TryGetValue

Full Usage: this.TryGetValue

Parameters:
    key : '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 refValue if the element is in the Dict and return true. Otherwise returning false .

key : 'K

The input key.

refValue : byref<'V>

A reference to the output value.

Returns: bool

true if the value is present, false if not.

this.TryPop

Full Usage: this.TryPop

Parameters:
    key : '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.

key : 'K

The key to remove.

Returns: 'V option

Some value if the key was found, None if not.

this.Values

Full Usage: this.Values

Returns: ValueCollection<'K, 'V>

Gets a collection containing the values in the Dict same as on System.Collections.Generic.Dict<'K,'V>

Returns: ValueCollection<'K, 'V>

this.ValuesSeq

Full Usage: this.ValuesSeq

Returns: 'V seq

Returns a (lazy) sequence of values

Returns: 'V seq

Static members

Static member Description

Dict.createDirectly dic

Full Usage: Dict.createDirectly dic

Parameters:
    dic : 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.

dic : Dictionary<'K, 'V>

The Dictionary to wrap. Changes to it show in the new Dict and the other way round.

Returns: Dict<'K, 'V>

Type something to start searching.