Browse Source

Add `GetEntry()` method to `AssociativeArray`

pull/8/head
Anton Tarasenko 3 years ago
parent
commit
9b4652bed7
  1. 18
      sources/Data/Collections/AssociativeArray.uc

18
sources/Data/Collections/AssociativeArray.uc

@ -287,6 +287,24 @@ public final function AcediaObject GetItem(AcediaObject key)
return none;
}
/**
* Returns entry corresponding to a given key `key` in the caller
* `AssociativeArray`.
*
* @param key Key for which to return entry.
* @return Entry (key/value pair + indicator of whether values was managed
* by `AssociativeArray`) with the given key `key`.
*/
public final function Entry GetEntry(AcediaObject key)
{
local Entry emptyEntry;
local int bucketIndex, entryIndex;
if (!FindEntryIndices(key, bucketIndex, entryIndex)) {
return emptyEntry;
}
return hashTable[bucketIndex].entries[entryIndex];
}
/**
* Returns entry corresponding to a given key `key` in the caller
* `AssociativeArray`, removing it from the caller `AssociativeArray`.

Loading…
Cancel
Save