Class: List

List

new tart.List()

List data structure

Extends

Methods

addItem(value){boolean}

Adds a new item to list .

Name Type Description
value *

Value for the pair.

Returns:
Type Description
boolean .

Returns active item as JSON object.

Returns:
Type Description
tart.JSON returns the active key-value pair from the collection.

inherited getActiveItemIndex(){number}

Returns active item's index.

Returns:
Type Description
number returns the active index in the collection.

inherited getActiveItemKey(){string|number}

Returns active item's key.

Returns:
Type Description
string | number returns the active key from the collection.

inherited getActiveItemValue(){*}

Returns active item's value.

Returns:
Type Description
* returns the active value from the collection.

inherited getAll(){Array}

Dumps all items in an array.

Returns:
Type Description
Array returns all pairs as an array.

inherited getByIndex(index){tart.JSON|boolean|undefined}

Returns item by given index.

Name Type Description
index number

Index to search in the collection.

Returns:
Type Description
tart.JSON | boolean | undefined returns the key-value pair given an index.

Returns item by given key. If not found, returns boolean false.

Name Type Description
key string | number

key to search for.

Returns:
Type Description
tart.JSON returns the key-value pair given a specific key.

Returns item by given value. If not found, returns boolean false.

Name Type Description
val string | number

value to search for.

Returns:
Type Description
tart.JSON returns the key-value pair given a specific value.

Returns all items in a kvp format.

Returns:
Type Description
tart.JSON obj returns an object that contains keys as its keys and values as its values.

inherited getKeys(){Array}

Returns all keys in an array.

Returns:
Type Description
Array returns all keys in an array.

inherited getValues(){Array}

Returns all values in an array.

Returns:
Type Description
Array returns all values in an array.

inherited removeByIndex(index){number|boolean|undefined}

Removes an item from collection which given by index and rebuilds the item collection. Returns new activeItemIndex if item successfully removed or FALSE if not.

Name Type Description
index number

Index to remove.

Returns:
Type Description
number | boolean | undefined Condition of the operation or the active item index.

inherited removeByKey(key)

Removes items by key.

Name Type Description
key string

Game items key.

inherited setActiveItemIndex(newIndex){boolean}

Sets active item index.

Name Type Description
newIndex number

index to set as the new active item.

Returns:
Type Description
boolean Whether the method was able to set the item.