Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial jsdoc for mutliset #202

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion multi-set.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,52 @@
*/
export default class MultiSet<K> implements Iterable<K> {

// Members
/**
* Number of distinct items in the set.
*/
dimension: number;
/**
* Total number of items in the set.
*/
size: number;

// Methods
/**
* Method used to clear the structure.
*
* @return {undefined}
*/
clear(): void;
/**
* Adds the item to the set. Optionally, you can provide a number which is the number of times the same item is added.
*
* Adding an item 0 times is a no-op.
*
* Adding an item a negative number of times will remove items.
*
* @param {K} key item to add.
* @param {number} count optional count.
* @return {MultiSet}
*/
add(key: K, count?: number): this;
/**
* Sets the multiplicity of an item in the set.
*
* Setting the multiplicity of an item to be 0 or a negative number will remove said item from the set.
*
* @param {K} key item to set
* @param {number} count - desired multiplicity.
* @return {MultiSet}
*/
set(key: K, count: number): this;
/**
* Returns true when items are in the set.
*
* Equivalent to `set.count(item) > 0`.
*
* @param {any} key - Item to check.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be K instead of any?

* @return {boolan}
*/
has(key: K): boolean;
delete(key: K): boolean;
remove(key: K, count?: number): void;
Expand Down