OrderedDictionaryTKey, TValueGetValueElseAdd Method |
Finds a key in the dictionary. If the dictionary already contains
a key equal to the passed key, then the existing value is returned via value. If the dictionary
doesn't contain that key, then value is associated with that key.
Namespace: X3Platform.CollectionsAssembly: X3Platform.Support (in X3Platform.Support.dll) Version: 1.0.0.0 (2.0.0.0)
Syntaxpublic bool GetValueElseAdd(
TKey key,
ref TValue value
)
public:
bool GetValueElseAdd(
TKey key,
TValue% value
)
Parameters
- key
- Type: TKey
The new key. - value
- Type: TValue
The new value to associated with that key, if the key isn't present. If the key was present,
returns the exist value associated with that key.
Return Value
Type:
BooleanTrue if key was already present, false if key wasn't present (and a new value was added).
Remarks between keys is determined by the comparison instance or delegate used
to create the dictionary.
This method takes time O(log N), where N is the number of keys in the dictionary. If a value is added, It is more efficient than
calling TryGetValue followed by Add, because the dictionary is not searched twice.
See Also