From 9b4652bed747e0a135c719e6128ac572d43d64bb Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Mon, 9 Aug 2021 21:31:24 +0700 Subject: [PATCH] Add `GetEntry()` method to `AssociativeArray` --- sources/Data/Collections/AssociativeArray.uc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sources/Data/Collections/AssociativeArray.uc b/sources/Data/Collections/AssociativeArray.uc index 9dd61b3..80a18e6 100644 --- a/sources/Data/Collections/AssociativeArray.uc +++ b/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`.