Javascript HashList

From Yate Documentation
Revision as of 14:58, 6 September 2024 by Marian (Talk | contribs)

Jump to: navigation, search

General

This object holds properties distributed by the hash of the property name.
Hash is calculated using the internal Yate String hash algorithm.


This object can be used when a script is holding a large number of values for fast retrieval (faster than the flat regular object properties list).


Data can be stored and retrieved using the common javascript instructions:

var hashList = new Engine.HashList;
// Assign
hashList.prop = 5;
hashList.obj = {a:3};
// Retrieve
var tmp = hashList.prop;
for (var tmp of hashList) {
    // tmp contains values in hash list
}
for (var tmp in hashList) {
    // tmp contains hash list key (property) name
}
// Delete
delete hashList.prop;

Constructor

  • new Engine.HashList([cnt])

Parameters:
cnt Numeric. Number of lists to distribute values. Clamped in interval [1..1024]. Default: 17


For a proper distribution of values cnt should be a prime number.


Methods

  • count()

Return:
The number of elements in list.

Personal tools
Namespaces

Variants
Actions
Preface
Configuration
Administrators
Developers