Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ManagedConcurrentDictionary<TKey, TValue>

A ConcurrentDictonary that maps to the appropriate platform version.

Type parameters

  • TKey

  • TValue

Hierarchy

  • ManagedConcurrentDictionary

Index

Constructors

constructor

  • Creates a new ManagedConcurrentDictionary.

    Parameters

    • hashCallback: IFunction1<TKey, string>

      The hash function to use when the backing dictionary requires the key to be a string.

    Returns ManagedConcurrentDictionary

  • Creates a new instance.

    Returns ManagedConcurrentDictionary

Properties

Private __dictionary

__dictionary: InternalConcurrentDictionary<TKey, TValue>
internal

Methods

addOrUpdate

  • addOrUpdate(key: TKey, addValue: TValue, updateValueFactory: IFunction2<TKey, TValue, TValue>): TValue
  • Updates a value in the dictionary or adds it if it does not exist.

    Parameters

    • key: TKey

      The key to use for updating for adding.

    • addValue: TValue

      The value to be added for an absent key.

    • updateValueFactory: IFunction2<TKey, TValue, TValue>

      The function to use for generating a value based on an existing key.

    Returns TValue

clear

  • clear(): void
  • Clears the dictionary of all items.

    Returns void

containsKey

  • containsKey(key: TKey): boolean
  • True if the dictionary contains the key.

    Parameters

    • key: TKey

      The key to check.

    Returns boolean

getCount

  • getCount(): number
  • Gets the number of items in the dictionary.

    Returns number

getIsEmpty

  • getIsEmpty(): boolean
  • Gets true if dictionary is empty.

    Returns boolean

getKeys

  • getKeys(): Array<TKey>
  • Gets an array of keys.

    Returns Array<TKey>

getOrAdd

  • getOrAdd(key: TKey, valueFactory: IFunction1<TKey, TValue>): TValue
  • Gets the value from the dictionary or adds a new one if it does not exist.

    Parameters

    • key: TKey

      The key to use when adding to the dictionary.

    • valueFactory: IFunction1<TKey, TValue>

      The Func that will create a value if needed.

    Returns TValue

    The dictionary value if exist, the value returned by the Func if not.

getTypeString

  • getTypeString(): string
  • Returns string

getValues

  • getValues(): Array<TValue>
  • Gets an array of Values.

    Returns Array<TValue>

tryAdd

  • tryAdd(key: TKey, value: TValue): boolean
  • Tries to add a new value to the dictionary.

    Parameters

    • key: TKey

      The key to use when adding.

    • value: TValue

      The value to be added to the dictionary.

    Returns boolean

    True if added, false if key already exists.

tryGetValue

  • tryGetValue(key: TKey, value: Holder<TValue>): boolean
  • Tries to get a value from the dictionary.

    Parameters

    • key: TKey

      They key of the item to get form the dictionary.

    • value: Holder<TValue>

      The value that was just received or null if failed.

    Returns boolean

    True if succeeded.

tryRemove

  • tryRemove(key: TKey, value: Holder<TValue>): boolean
  • Tries and removes a value from the dictionary.

    Parameters

    • key: TKey

      The key of the item to remove.

    • value: Holder<TValue>

      The value that was just removed.

    Returns boolean

    True if successful.

tryUpdate

  • tryUpdate(key: TKey, newValue: TValue, comparisonValue: TValue): boolean
  • Tries to update the value in the dictionary.

    Parameters

    • key: TKey

      The key to use when updating.

    • newValue: TValue

      The new value.

    • comparisonValue: TValue

      The value to compare with the current value in the dictionary.

    Returns boolean

    True if succeeded.