Monkey Documentation

Class Set

A set is a container style object that provides a mechanism for keeping track of a number of objects. More...


Extended by:
Constructors:
  • New ( map:Map<T, Object> )
Methods:

Detailed Discussion

A set is a container style object that provides a mechanism for keeping track of a number of objects.

Each object in a set occurs exactly once - inserting the same object into a set multiple times does not result in the set containing multiple references to the same object.

Sets are implemented behind the scenes using Map objects, and are just as efficient at insertng, removing and finding objects.

Classes that extend Set must invoke Super.New with an instance of a map object.


Constructor Documentation

Method New ( map:Map<T, Object> )

Extending classes should invoke this method with a valid map object to be used to implement the set.


Method Documentation

Method Clear : Int ()

Removes all items from the set.

Method Contains : Bool ( value:T )

Return True if the specified value is contained in the set, else False.

Method Count : Int ()

Counts and returns the number of objects in the set.

Note that this method takes O(N) time - that is, it must visit each object in the set.

Method Insert : Int ( value:T )

Inserts value into the set.

Method IsEmpty : Bool ()

Returns True if the set is empty, ie: contains no items, else False.

Method ObjectEnumerator : Object ()

Returns an enumerator object that allows sets to be used with For Eachin loops.

Method Remove : Int ( value:T )

Removes value from the set.