1.0.0 • Published 11 months ago

namastey-hash-set v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

namastey-hash-set

Brief Description:

namastey-hash-set is a JavaScript package that implements a Hash Set data structure. It provides efficient methods to manage unique values.

Features:

  • add(value): Adds a value to the set if it is not already present.
  • remove(value): Removes a value from the set.
  • has(value): Checks if a value is present in the set.
  • size(): Returns the number of elements in the set.
  • values(): Returns an array of all elements in the set.
  • clear(): Removes all elements from the set.

Installation:

You can install namastey-hash-set globally using npm:

npm install -g namastey-hash-set

Examples

const HashSet = require('namastey-hash-set');

const mySet = new HashSet();

mySet.add('apple');
mySet.add('banana');
console.log(mySet.values()); // Output: [ 'apple', 'banana' ]

console.log(mySet.has('apple')); // Output: true
console.log(mySet.has('cherry')); // Output: false

mySet.remove('banana');
console.log(mySet.values()); // Output: [ 'apple' ]

console.log(mySet.size()); // Output: 1

mySet.clear();
console.log(mySet.values()); // Output: []