SetCnt

SetCnt

Set-like data structure built using Map with elements counter. Allows adding multiple occurrences of the same element.

Constructor

new SetCnt(iteropt)

Description:
  • Creates a new SetCnt instance.
Source:
Parameters:
Name Type Attributes Description
iter Iterable <optional>
An iterable object to initialize the set with.

Classes

SetCnt

Methods

add(el) → {SetCnt}

Description:
  • Adds an element to the set. Increments the counter for the element.
Source:
Parameters:
Name Type Description
el * The element to add.
Returns:
The SetCnt instance.
Type
SetCnt

cnt(el) → {number}

Description:
  • Gets the number of occurrences of an element.
Source:
Parameters:
Name Type Description
el * The element to check.
Returns:
The count of the element.
Type
number

delete(el) → {boolean}

Description:
  • Removes one occurrence of an element from the set. If the count reaches 0, the element is removed completely.
Source:
Parameters:
Name Type Description
el * The element to remove.
Returns:
True if the element was removed (or count decremented), false if it didn't exist.
Type
boolean

deleteAll(el) → {boolean}

Description:
  • Removes all occurrences of an element from the set.
Source:
Parameters:
Name Type Description
el * The element to remove.
Returns:
True if the element was removed, false otherwise.
Type
boolean

entries() → {SetCnt}

Description:
  • Returns the SetCnt instance itself (for compatibility with Map-like interfaces).
Source:
Returns:
The SetCnt instance.
Type
SetCnt

has(el) → {boolean}

Description:
  • Checks if an element exists in the set.
Source:
Parameters:
Name Type Description
el * The element to check.
Returns:
True if the element exists, false otherwise.
Type
boolean

(generator) keys() → {Iterator}

Description:
  • Returns an iterator over the counts of the elements.
Source:
Returns:
An iterator over the counts.
Type
Iterator

(generator) values() → {Iterator}

Description:
  • Returns an iterator over the unique elements in the set.
Source:
Returns:
An iterator over the unique elements.
Type
Iterator