diff --git a/sources/Data/Collections/CollectionsAPI.uc b/sources/Data/Collections/CollectionsAPI.uc index 070426d..8aa141e 100644 --- a/sources/Data/Collections/CollectionsAPI.uc +++ b/sources/Data/Collections/CollectionsAPI.uc @@ -54,6 +54,43 @@ public final function ArrayList EmptyArrayList() return ArrayList(_.memory.Allocate(class'ArrayList')); } +/** + * Creates a new `HashTable`, optionally filling it with entries + * (key/value pairs) from a given native array. + * + * @param entriesArray Entries (key/value pairs) to place inside created + * `HashTable`; if empty (by default) - new, + * empty `HashTable` will be returned. + * @param managed Flag that indicates whether values from + * `entriesArray` argument should be added as managed. + * By default `false` - they would not be managed. + * @return New `HashTable`, optionally filled with contents of + * `entriesArray`. Guaranteed to be not `none` and to not contain any items + * outside of `entriesArray`. + */ +public final function HashTable NewHashTable( + array entriesArray) +{ + local int i; + local HashTable result; + + result = HashTable(_.memory.Allocate(class'HashTable')); + for (i = 0; i < entriesArray.length; i += 1) { + result.SetItem(entriesArray[i].key, entriesArray[i].value); + } + return result; +} + +/** + * Creates a new empty `HashTable`. + * + * @return New empty instance of `HashTable`. + */ +public final function HashTable EmptyHashTable() +{ + return HashTable(_.memory.Allocate(class'HashTable')); +} + /** * Creates a new `DynamicArray`, optionally filling it with objects from * a given native array.