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 pData, String sFieldToCompare)

Method Summary

Attributes Name and Description
boolean add(Object oElement, Number nIndex)

Adds an item into this set.

void addAll(Array pData)

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

void clear()

Clears all items from the set.

boolean contains(Object oElement)

Tests to see if an item is in this set

Object get(Number nIndex)

Gets the element at a specified index.

Object getByKey(oKey oKey)

Gets the element by a defined key

Array getContents()

Returns an Array with the same contents as the Set.

boolean remove(Object oElement)

Removes an item from this set.

void removeAll(Array pData)

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 pData, String sFieldToCompare)

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

Method Detail

boolean add(Object oElement, Number nIndex)

Adds an item into this set.

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

void addAll(Array pData)

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

Parameters
Array pData the items to add to this set.

void clear()

Clears all items from the set.

boolean contains(Object oElement)

Tests to see if an item is in this set

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

Object get(Number nIndex)

Gets the element at a specified index.

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

Object getByKey(oKey oKey)

Gets the element by a defined key

Parameters
oKey oKey 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.

boolean remove(Object oElement)

Removes an item from this set.

Parameters
Object oElement the item to remove.
Returns
true if the item had been in the set, false if it was not.

void removeAll(Array pData)

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

Parameters
Array pData 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.