Class
caplin.core

OrderedSet

A set that is ordered based on time of insertion. This set may contain only Strings or Numbers unless a field name is provided which can be used to retrieve a value from an object to make a comparison.

Constructor Summary

Attributes Name and Description
caplin.core.OrderedSet(Array elements, String fieldToCompare)

Method Summary

Attributes Name and Description
boolean add(Object element, Number index)

Adds an item into this set.

void addAll(Array elements)

Adds all the items in the passed array to this set.

void clear()

Clears all items from the set.

boolean contains(Object element)

Tests to see if an item is in this set

Object get(Number index)

Gets the element at a specified index.

Object getByKey(key key)

Gets the element by a defined key

Array getContents()

Returns an Array with the same contents as the Set.

void getFieldToCompare()

void getIndexOf(Object element)

Returns the index of the given element in the order.

boolean remove(Object element)

Removes an item from this set.

void removeAll(Array elements)

Removes all the items in the passed array from this set.

int size()

Returns the number of elements contained in the set.

Constructor Detail

caplin.core.OrderedSet(Array elements, String fieldToCompare)

Parameters
Array elements (Optional) an array whose elements are to be placed into this set.
String fieldToCompare (Optional) the field name to use when comparing objects.

Method Detail

boolean add(Object element, Number index)

Adds an item into this set.

Parameters
Object element the item to add.
Number index (Optional) the index at which the item will be added. If not included, element will be added to the end of the set.
Returns
{boolean} true if the item was added, false if it was already present.

void addAll(Array elements)

Adds all the items in the passed array to this set.

Parameters
Array elements the items to add to this set.

void clear()

Clears all items from the set.

boolean contains(Object element)

Tests to see if an item is in this set

Parameters
Object element the item to test.
Returns
boolean, true if the item is in the set, false if it is not.

Object get(Number index)

Gets the element at a specified index.

Parameters
Number index the index to get.
Returns
the object at the specified index.

Object getByKey(key key)

Gets the element by a defined key

Parameters
key key the key used to retrieve item.
Returns
the object with the specified key, otherwise undefined.

Array getContents()

Returns an Array with the same contents as the Set.

Returns
An array representation of the Set.

void getFieldToCompare()

Returns
the field name used when comparing objects.

void getIndexOf(Object element)

Returns the index of the given element in the order.

Parameters
Object element

boolean remove(Object element)

Removes an item from this set.

Parameters
Object element the item to remove.
Returns
{boolean} true if the item had been in the set, false if it was not.

void removeAll(Array elements)

Removes all the items in the passed array from this set.

Parameters
Array elements the items to remove from this set.

int size()

Returns the number of elements contained in the set.

Returns
the number of elements contained in the set.