Module Bag

Class for a bag.

This is an open structure, to make it easilly extensible. That is, the queue can be abused by manipulating it as an ordinary table. Items can be added to a bag, but not removed. See also Wikipedias page on multiset.

Functions

bag.new () Create a new instance.
bag:add () Add an item to the bag.
bag:find () Find an item in the bag.
bag:isEmpty () Is the bag empty.
bag:count () Count number of entries in bag.


Functions

bag.new ()
Create a new instance.

Parameters:

  • ... vararg arguments to be passed on

Returns:

self
bag:add ()
Add an item to the bag. This method can be called as a function.

Parameters:

  • item any

Returns:

self
bag:find ()
Find an item in the bag. There might be several items. Equality is shallow. This method can be called as a function.

Nicknames:

    has

Parameters:

  • item any

Returns:

any
bag:isEmpty ()
Is the bag empty. Checks by counting items whether bag is empty. This method can be called as a function.

Returns:

boolean
bag:count ()
Count number of entries in bag. This method can be called as a function.

Returns:

number
generated by LDoc TESTING