Class Index | File Index

Classes


Class createjs.ObjectList


Defined in: object_list.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
A class that encapsulates an array that is safe to be modified in a loop.
Field Summary
Field Attributes Field Name and Description
 
A clone of this list.
 
A list of objects.
 
Whether this list is locked.
Method Summary
Method Attributes Method Name and Description
 
Returns a clone of this list.
 
findItem(item)
Finds an item from this list.
 
getItemAt(index)
Returns an item at the specified index.
 
Retrieves the editable items of this list.
 
Returns the number of items in this list.
 
insertItem(index, item)
Adds an item to the specified position of this list.
 
Returns whether this list is locked.
 
lock()
Locks this list for iteration.
 
pushItem(item)
Adds an item to the end of this list.
 
Adds an item to the end of this list only if this list does not have it.
 
Removes all items from this list.
 
removeItem(item)
Removes an item from this list.
 
removeItemAt(index)
Removes an item from this list.
 
swapItems(item1, item2)
Swaps two items in this list.
 
swapItemsAt(index1, index2)
Finds an item from this list.
 
Unlocks this list.
 
Adds an item to the beginning of this list.
Class Detail
createjs.ObjectList()
A class that encapsulates an array that is safe to be modified in a loop. It is not safe to modify an array in a loop, e.g. the following loop does not iterate the second item 'b'. var list = ['a', 'b', 'c']; for (var i = 0; i < list.length; ++i) { console.log(list[i]); if (list[i] == 'a') { list.splice(i, 1); } } Even though iterating a clone solves this problem, it is an overkill to create a clone every time when an application iterates an array. var list = ['a', 'b', 'c']; var clone = list.slice(); for (var i = 0; i < clone.length; ++i) { console.log(clone[i]); if (clone[i] == 'a') { list.splice(i, 1); } } This class lazily creates a clone of its array for the first time when an application either adds an item to the array or removes one in a loop. var list = object_list.lock(); for (var i = 0; i < list.length; ++i) { console.log(list[i]); if (list[i] == 'a') { object_list.removeItemAt(i); } } object_list.unlock();
Field Detail
clone_
A clone of this list.

items_
A list of objects.

locked_
Whether this list is locked.
Method Detail
{Array.<*>} cloneItems()
Returns a clone of this list.
Returns:
{Array.<*>}

{number} findItem(item)
Finds an item from this list.
Parameters:
{*} item
Returns:
{number}

{*} getItemAt(index)
Returns an item at the specified index.
Parameters:
{number} index
Returns:
{*}

{Array.<*>} getItems()
Retrieves the editable items of this list.
Returns:
{Array.<*>}

{number} getLength()
Returns the number of items in this list.
Returns:
{number}

insertItem(index, item)
Adds an item to the specified position of this list.
Parameters:
{number} index
{*} item

{boolean} isLocked()
Returns whether this list is locked.
Returns:
{boolean}

{Array.<*>} lock()
Locks this list for iteration. This method changes the state of this list to 'locked' to apply succeeding add operations and remove ones to its clone.
Returns:
{Array.<*>}

pushItem(item)
Adds an item to the end of this list.
Parameters:
{*} item

pushUniqueItem(item)
Adds an item to the end of this list only if this list does not have it.
Parameters:
{*} item

removeAllItems()
Removes all items from this list.

removeItem(item)
Removes an item from this list.
Parameters:
{*} item

removeItemAt(index)
Removes an item from this list.
Parameters:
{number} index

swapItems(item1, item2)
Swaps two items in this list.
Parameters:
{*} item1
{*} item2

swapItemsAt(index1, index2)
Finds an item from this list.
Parameters:
{number} index1
{number} index2

unlock()
Unlocks this list. This method changes the stage of this list to 'unlocked' and copies its clone if an application edits the list while it is locked.

unshiftItem(item)
Adds an item to the beginning of this list.
Parameters:
{*} item

Documentation generated by JsDoc Toolkit 2.4.0 on Tue Oct 04 2016 17:11:29 GMT+0900 (JST)