FastKeyedMap

Data Structures View source
FastKeyedMap
public class FastKeyedMap<K:, V:>

High-performance map for handle or string keys and native int or class-reference values. Jass uses Warcraft’s hashtable with full-string collision checks; Lua uses a native table and stores V directly, without boxing.

This deliberately narrow API avoids key hashing and handle-id conversions on Lua. It is not a general-purpose replacement for HashMap: only handle and string keys are supported, keys are not iterable, and there is no size counter. Use remove() for absence; reference values must be non-null because Lua represents nil as a missing table entry. Keep class-reference values alive while stored, and remove or replace them before destroy: both targets store their integer object IDs, which can be reused. The same holds for handle keys: remove a key’s entry before you destroy that handle. Jass stores the entry under the handle id, which Warcraft hands to a later handle, so the new handle would read the old value; Lua would keep the destroyed handle referenced. This requires the compiler’s keyed-map intrinsic lowering. Jass string operations hash the key and scan its collision bucket; destroy is O(n). Each stored string key uses one entry from the shared StringMapEntry allocator, subject to the target’s class-instance limit. Lua allocates no entries and uses native table lookup. The intrinsic source bodies fail loudly if a compiler understands the generic declarations but lacks that lowering; they never silently discard writes or return defaults.

Constructors

construct()

Methods

put(K key, V value)

Stores a value. Null keys are ignored; reference values should not be null.

get(K key) returns V

Returns the value or the Wurst default for V when the key is absent.

has(K key) returns boolean

Returns whether the key has a stored value.

remove(K key)

Removes a key and its value.