# createHashMap ## Category HashMap ## Arity **Nular** — `createHashMap`. ``` createHashMap ``` ## Description Creates a new empty hashmap (dictionary). HashMaps store key-value pairs with fast O(1) lookup. Keys and values can be of any type. Keys are compared by value — two equal numbers or strings are considered the same key. ## How It Works Allocates a new `Dictionary` with the SQ# equality comparer. The hashmap is mutable and owned by the current scheduler. ## Usage ### Create and populate ```sqf _map = createHashMap; _map set ["health", 100]; _map set ["name", "player"]; _map set ["alive", true]; ``` ### Read values ```sqf _hp = _map get "health"; // 100 _name = _map get "name"; // "player" _missing = _map get "xyz"; // nil (key not found) ``` ### Check key existence ```sqf if (!isNil {_map get "health"}) then { systemChat f"Health: {_map get "health"}"; }; ``` ### As configuration store ```sqf _config = createHashMap; _config set ["maxPlayers", 32]; _config set ["difficulty", "hard"]; _config set ["timeLimit", 900]; ``` ### Nested maps ```sqf _player = createHashMap; _player set ["name", "John"]; _stats = createHashMap; _stats set ["hp", 100]; _stats set ["xp", 500]; _player set ["stats", _stats]; ``` ## Thread Safety **Not thread-safe**. HashMap must be owned by the current scheduler. Use [freeze](freeze.md) pattern for cross-scheduler sharing, or transfer ownership with [sendTo](sendTo.md). ## See Also - [createHashMapFromArray](createHashMapFromArray.md) — create from key-value array - [get](get.md) — retrieve value by key - [set](set.md) — store key-value pair