thyCollection

This is the basic ThyAPI Collection Element.  With it, one can hold a collection of any Element.

Summary
This is the basic ThyAPI Collection Element.
Checks if the object is from the specified class type or from a class derivate from that.
Clears collection’s values.
Removes all elements from collection
Removes all elements from collection.
Populates a collection with the values of an array.
Returns an object with the contents of this thyCollection
Sets a default name for elements that are passed without name.
Adds a new element into the collection
Concatenate this collection with the one passed by parameter.
Removes an element of the collection
Removes an element of the collection
Removes an element of the collection
Gets the name of an element
Gets the index of an element
Returns a javascript object with the elements indexed by their names
Returns a javascript array with the elements indexed by their ids used internally
Returns the number of elements this collection has.
Returns the number of elements this collection has.
Returns an element by its index
Returns an element by its index (alias of getElementByIndex)
Returns an element by its name
Returns an element by its name (alias of getElementByName)
Gets the name of an element, given its index
Gets the name of an element, given its index (alias of getNameByIndex)
Gets the index of an element, given its name
Gets the index of an element, given its name (alias of getIndexByName)
Changes the name of an element
Changes the index of an element
Swaps the names and indexes of two elements
Swaps the names of two elements
Swaps the indexes of two elements
Returns a string representation of the collection

isFromClass

p.isFromClass = function (className)

Checks if the object is from the specified class type or from a class derivate from that.

Parameter

classNameThe name of the class to be checked

Returns

Boolean

clear

p.clear = function ()

Clears collection’s values.  DEPRECTED

Use cleanUp or reset

cleanUp

p.cleanUp = function ()

Removes all elements from collection

reset

Removes all elements from collection.

Now it is actually just an alias to cleanUp

populate

p.populate = function (data)

Populates a collection with the values of an array.

sweepOut

p.sweepOut = function()

Returns an object with the contents of this thyCollection

setDefaultName

p.setDefaultName = function (name)

Sets a default name for elements that are passed without name.

The name given is the default name plus an internal counter.

add

p.add = function (elm,
name,
index)

Adds a new element into the collection

concat

p.concat = function(collection)

Concatenate this collection with the one passed by parameter.

Parameter

collectionAnother thyCollection

removeByName

p.removeByName = function (name)

Removes an element of the collection

Parameters

namethe element name

removeByIndex

p.removeByIndex = function (index)

Removes an element of the collection

Parameters

indexthe element index

remove

p.remove = function (elm,
name,
index)

Removes an element of the collection

Parameters

elmthe element to be removed

getElementName

p.getElementName = function (elm)

Gets the name of an element

Parameters

elmthe element in question

getElementIndex

p.getElementIndex = function (elm)

Gets the index of an element

Parameters

elmthe element in question

getNamedElements

p.getNamedElements = function()

Returns a javascript object with the elements indexed by their names

getIndexedElements

p.getIndexedElements = function()

Returns a javascript array with the elements indexed by their ids used internally

getElementsCount

p.getElementsCount = function()

Returns the number of elements this collection has.

length

Returns the number of elements this collection has.  (alias of getElementsCount)

getElementByIndex

p.getElementByIndex = function (index)

Returns an element by its index

Parameters

index

i

Returns an element by its index (alias of getElementByIndex)

getElementByName

p.getElementByName = function (name)

Returns an element by its name

Parameters

name

n

Returns an element by its name (alias of getElementByName)

getNameByIndex

p.getNameByIndex = function(index)

Gets the name of an element, given its index

Parameters

index -

name2index

Gets the name of an element, given its index (alias of getNameByIndex)

Parameters

index -

getIndexByName

p.getIndexByName = function(name)

Gets the index of an element, given its name

Parameters

name -

index2name

Gets the index of an element, given its name (alias of getIndexByName)

Parameters

name -

Index and name changing

changeElementName

p.changeElementName = function (info)

Changes the name of an element

Parameters

infoobject with the following indexes:
oldNamethis or elm or index are obligatory
elmthis or oldName or index are obligatory
indexthis or oldName or elm are obligatory
name(obligatory)

changeElementIndex

p.changeElementIndex = function (info,
name_also)

Changes the index of an element

Parameters

infoobject with the following indexes:
oldNamethis or elm or index are obligatory
elmthis or oldName or index are obligatory
indexthis or oldName or elm are obligatory
name(obligatory)

Swapping

swapElements

p.swapElements = function (elm1,
elm2)

Swaps the names and indexes of two elements

Parameters

elm1 elm2

swapNames

p.swapNames = function (elm1,
elm2)

Swaps the names of two elements

Parameters

elm1 elm2

swapIndex

p.swapIndex = function (elm1,
elm2)

Swaps the indexes of two elements

Parameters

elm1 elm2

Miscelaneous

toString

p.toString = function ()

Returns a string representation of the collection

p.isFromClass = function (className)
Checks if the object is from the specified class type or from a class derivate from that.
p.clear = function ()
Clears collection’s values.
p.cleanUp = function ()
Removes all elements from collection
p.populate = function (data)
Populates a collection with the values of an array.
p.sweepOut = function()
Returns an object with the contents of this thyCollection
p.setDefaultName = function (name)
Sets a default name for elements that are passed without name.
p.add = function (elm,
name,
index)
Adds a new element into the collection
p.concat = function(collection)
Concatenate this collection with the one passed by parameter.
p.removeByName = function (name)
Removes an element of the collection
p.removeByIndex = function (index)
Removes an element of the collection
p.remove = function (elm,
name,
index)
Removes an element of the collection
p.getElementName = function (elm)
Gets the name of an element
p.getElementIndex = function (elm)
Gets the index of an element
p.getNamedElements = function()
Returns a javascript object with the elements indexed by their names
p.getIndexedElements = function()
Returns a javascript array with the elements indexed by their ids used internally
p.getElementsCount = function()
Returns the number of elements this collection has.
p.getElementByIndex = function (index)
Returns an element by its index
p.getElementByName = function (name)
Returns an element by its name
p.getNameByIndex = function(index)
Gets the name of an element, given its index
p.getIndexByName = function(name)
Gets the index of an element, given its name
p.changeElementName = function (info)
Changes the name of an element
p.changeElementIndex = function (info,
name_also)
Changes the index of an element
p.swapElements = function (elm1,
elm2)
Swaps the names and indexes of two elements
p.swapNames = function (elm1,
elm2)
Swaps the names of two elements
p.swapIndex = function (elm1,
elm2)
Swaps the indexes of two elements
p.toString = function ()
Returns a string representation of the collection
This is the basic ThyAPI Collection Element.