Class: oList

$. oList

The base class for the $.oList.
Provides a list of values similar to an array, but with simpler filtering and sorting functions provided.
It can have any starting index and so can implement lists with a first index of 1 like the $.oColumn.frames returned value.

new $.oList(initArray, startIndex, length, getFunction, setFunction, sizeFunction)

openHarmony/openHarmony_list.js, line 56
Constructor to generate an $.oList type object.
Name Type Default Description
initArray Array.<object> An array to initialize the list.
startIndex int 0 optional The first index exposed in the list.
length int 0 optional The length of the list -- the max between this value and the initial array's length is used.
getFunction function null optional The function used to initialize the list when accessing an uninitiated element in the list.
In form function( listItem, index ){ return value; }
setFunction function null optional The function run when setting an entry in the list.
In form function( listItem, index, value ){ return resolvedValue; } -- must return a resolved value.
sizeFunction function null optional The function run when resizing the list.
In form function( listItem, length ){ }

Members

lastIndexint

The index of the last valid element of the list

startIndexint

The startIndex of the list.

Methods

extractProperty(property){$.oList}

openHarmony/openHarmony_list.js, line 413
Returns an oList object containing only the values of the specified property.
Name Type Description
property string The property to find.
Returns:
Type Description
$.oList The newly created oList object containing the property values.

filterByFunction(func){$.oList}

openHarmony/openHarmony_list.js, line 356
Returns an oList object containing only the elements that passed the provided filter function.
Name Type Description
func function A function that is used to filter, returns true if it is to be kept in the list.
Returns:
Type Description
$.oList The list represented as an array, filtered given the function.

filterByProperty(property, search){$.oList}

openHarmony/openHarmony_list.js, line 379
Returns an oList object containing only the elements that have the same property value as provided.
Name Type Description
property string The property to find.
search string The value to search for in the property.
Returns:
Type Description
$.oList The list represented as an array, filtered given its properties.
Example
var doc = $.s // grab the scene object
var nodeList = new $.oList(doc.nodes, 1) // get a list of all the nodes, with a first index of 1

$.log(nodeList) // outputs the list of all the node paths

var readNodes = nodeList.filterByProperty("type", "READ") // get a new list of only the nodes of type 'READ'

$.log(readNodes.extractProperty("name"))  // prints the names of the result

first(){object}

openHarmony/openHarmony_list.js, line 256
The first item in the list, resets the iterator to the first entry.
Returns:
Type Description
object The first item in the list.

length(){int}

openHarmony/openHarmony_list.js, line 230
The length of the list.
Returns:
Type Description
int The length of the list, considering the startIndex.

next(){object}

openHarmony/openHarmony_list.js, line 270
The next item in the list, undefined if reaching the end of the list.
Returns:
Type Description
object Grabs the next item using the property $.oList.currentIndex, and increase the iterator
Example
var myList = new $.oList([1,2,3], 1)

var item = myList.first();  // 1

while( item != undefined ){
  $.log(item)               // traces the whole array one item at a time : 1,2,3   
  item = myList.next();   
}

pop(){int}

openHarmony/openHarmony_list.js, line 332
Similar to Array.pop. Removes the last value from the array and returns it. It is then removed from the array.
Returns:
Type Description
int The item popped from the back of the array.

push(newElement){int}

openHarmony/openHarmony_list.js, line 313
Similar to Array.push. Adds the value given as parameter to the end of the oList
Name Type Description
newElement various The value to add at the end of the oList
Returns:
Type Description
int Returns the new length of the oList.

sortByFunction(func){$.oList}

openHarmony/openHarmony_list.js, line 461
Returns an oList object sorted according to the sorting function provided.
Name Type Description
func function A function that is used to sort, in form function (a,b){return a - b}. (A positive a-b value will put the element b before a)
Returns:
Type Description
$.oList The sorted $oList.

sortByProperty(property, ascending){$.oList}

openHarmony/openHarmony_list.js, line 434
Returns an oList object sorted according to the values of the specified property.
Name Type Default Description
property string The property to find.
ascending bool true optional Whether the sort is ascending/descending.
Returns:
Type Description
$.oList The sorted $oList.

toArray(){Array.<object>}

openHarmony/openHarmony_list.js, line 482
Converts the oList to an array
Returns:
Type Description
Array.<object> The list represented as an array.

toString(){string}

openHarmony/openHarmony_list.js, line 503
outputs the list to a string for easy logging
Returns:
Type Description
string