HashSetJS
Loading...
Searching...
No Matches
HashSetJS v1.0.3

Niema's Hash Set implementation in JavaScript

Example

console.log("Creating new Hash Set...");
const hs = new HashSet();
const words = ['Alexander', 'Niema', 'Moshiri', 'Niema'];
console.log("Adding elements: " + words.join(' '));
for(const word of words) {
hs.add(word);
}
console.log(hs);
const has_check = 'Alexander';
console.log(`Checking if Hash Set has: ${has_check}`);
console.log(hs.has(has_check));
console.log(`Deleting and re-checking: ${has_check}`);
hs.delete(has_check);
console.log(hs);
console.log(hs.has(has_check));
console.log("Creating copy from raw bytes and checking equality...");
buf = hs.dump();
hs2 = HashSet.load(buf);
console.log(hs.equals(hs2));
console.log("Creating copy from file and checking equality...");
const fn = 'hashset.hsj';
hs.dump(fn);
hs3 = HashSet.load(fn);
console.log(hs.equals(hs3));
Definition HashSet.js:113
static load(fn)
Definition HashSet.js:193