NKeyMap
NKeyMap is a multi-key map where each stored value can be accessed thanks to a set of distinct keys. NKeyMap does not duplicate values and allows you to quickly access your stored objects.
Example
// Require libraryconst NKeyMap = ; // Instanciate mapconst nKeyMap = ; // Push values you want to store with multiple keys for eachnKeyMap; nKeyMap;nKeyMap; // Access stored values thanks to keysnKeyMap; // === 12nKeyMap; // === 12nKeyMap; // === 12 nKeyMap; // === 'myStoredString' nKeyMap; // === { myProp1: 52, myProp2: true }nKeyMap; // === { myProp1: 52, myProp2: true } // Get current map sizenKeyMapsize; // === 3 // Clear values from mapnKeyMap; nKeyMapsize; // === 0 // When removed or not existing valuenKeyMap; // === nullnKeyMap; // === null
Functions
constructor
Create a new multi-key map
number maxElements (optional) : Maximum length of the map. If the size of the map exceeds the fixed limit, the first added elements are removed from the map (FIFO)
By default, the map does not have a defined limit
get
Get your stored value thanks to one of the keys you had specified when you called the 'set' function
string key : One of the keys that is referred to your stored value
set
Push a new value into the map with some keys to access it later
Array<string> keys : Array of keys that will allow you to access to your value later
Object value : Value you want store into map
clean
Remove all values from the map
size
Get current count of elements available in the map