A fine collection of collection-classes and utilities written in CoffeScript.
CoffeeScript JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
src
test
.travis.yml
Cakefile
README.md
package.json

README.md

Coffee-CollectionBuild Status

A fine collection of collection-classes and utilities written in CoffeScript. Intended for Node- and client-side usage.

Currently contains

  • Set - each entry is singular, no duplicates allowed
  • Map - stores "entries" for provided "keys" like a dictionary
  • Graph - a set of nodes where each node max be conected with other nodes making a path

API

  • Set
    • !Important! If an element has an .equals-method it is used to determine if other items are treated as the same - otherwise the is-operator (===) is used
    • add element: Adds an element if it is not already contained
    • addAll ['a', 'b'] | otherSet: adds all elements from an array or other set
    • remove element: Removes an element
    • removeAll ['a', 'b'] | otherSet: removes all elements from an array or other set
    • clear(): Removes all elements
    • size(): Returns the number of elements contained in this set
    • isEmtpy(): Returns true if this set is empty
    • has element: Returns true if element.equals other returns true for any other element or - if element does not have a method equals - if an contained element is equal in terms of (===)

Examples

Set

fruit = new Set
fruit.add 'Apple'
fruit.add 'Banana'
fruit.add 'Cherry'
fruit.size() # => 3

fruit.add 'Apple' # adding the same entry twice
fruit.size() # => 3

fruit.has 'Cherry' # => true
fruit.has 'Raspberry' # => false

fruit.elements() # => ['Apple', 'Banana', 'Cherry']