Header menu 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:
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>
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
    value : 'V

Add the specified key and value to the Dict.

key : 'K
value : 'V

this.AddIfKeyAbsent

Full Usage: this.AddIfKeyAbsent

Parameters:
    key : 'K
    value : 'V

Returns: bool

Set value only if key does not exist yet. Returns false if key already exist, does not set value in this case. Same as Dict.SetIfKeyAbsent key value

key : 'K
value : 'V
Returns: bool

this.AsString

Full Usage: this.AsString

Returns: string

A string representation of the Dict including the count of entries and the first 5 entries. 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

Returns: bool

Determines whether the Dict contains the specified key.

key : 'K
Returns: bool

this.ContainsValue

Full Usage: this.ContainsValue

Parameters:
    value : 'V

Returns: bool

Determines whether the Dict contains a specific value.

value : 'V
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

Returns: bool

Determines whether the Dict does not contains the specified key. not(dic.ContainsKey(key))

key : 'K
Returns: bool

this.Get

Full Usage: this.Get

Parameters:
    key : 'K

Returns: 'V

Get value for given key

key : 'K
Returns: 'V

this.GetOrSetDefault

Full Usage: this.GetOrSetDefault

Parameters:
    getDefault : 'K -> 'V
    key : 'K

Returns: 'V

If the key ist not present calls the default function, set it as value at the key and return the value. This function is an alternative to the DefaultDic type. Use it if you need to provide a custom implementation of the default function depending on the key.

getDefault : 'K -> 'V
key : 'K
Returns: 'V

this.GetOrSetDefaultValue

Full Usage: this.GetOrSetDefaultValue

Parameters:
    defaultValue : 'V
    key : 'K

Returns: 'V

If the key ist not present set it as value at the key and return the value.

defaultValue : 'V
key : 'K
Returns: 'V

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

Returns: 'V

Get a value and remove key and value it from Dict. Will fail if key does not exist

key : 'K
Returns: 'V

this.Remove

Full Usage: this.Remove

Parameters:
    key : 'K

Returns: bool

Removes the value with the specified key from the Dict. See also .Pop(key) method that return the contained value.

key : 'K
Returns: bool

this.Set

Full Usage: this.Set

Parameters:
    key : 'K
    value : 'V

Set value for given key, same as Dict.add key value

key : 'K
value : 'V

this.SetIfKeyAbsent

Full Usage: this.SetIfKeyAbsent

Parameters:
    key : 'K
    value : 'V

Returns: bool

Set value only if key does not exist yet. Returns false if key already exist, does not set value in this case. Same as Dict.AddIfKeyAbsent key value

key : 'K
value : 'V
Returns: bool

this.ToString

Full Usage: this.ToString

Parameters:
    entriesToPrint : int

Returns: string

A string representation of the Dict including the count of entries and the specified amount of entries. /// When used in Fable this member is inlined for reflection to work.

entriesToPrint : int
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.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.create pairs

Full Usage: Dict.create pairs

Parameters:
    pairs : ('K * 'V) seq

Returns: Dict<'K, 'V>

Constructs a new Dict from a sequence of key-value tuples.

pairs : ('K * 'V) seq
Returns: Dict<'K, 'V>

Dict.createDirectly dic

Full Usage: Dict.createDirectly dic

Parameters:
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>
Returns: Dict<'K, 'V>

Dict.get dd key

Full Usage: Dict.get dd key

Parameters:
    dd : Dict<'K, 'V>
    key : 'K

Returns: 'V

Get value for given key.

dd : Dict<'K, 'V>
key : 'K
Returns: 'V

Dict.set dd key value

Full Usage: Dict.set dd key value

Parameters:
    dd : Dict<'K, 'V>
    key : 'K
    value : 'V

Set value for given key, same as Dicts.Add(key, value)

dd : Dict<'K, 'V>
key : 'K
value : 'V

Type something to start searching.