Utils.Bag Class
Collection type a bit like ArrayList but does not preserve the order of its entities, speedwise it is very good, especially suited for games.
Item Index
Methods
Properties
Methods
add
-
Mixed
Adds the specified element to the end of this bag. if needed also increases the capacity of the bag.
Parameters:
-
Mixed
Objectelement to be added to this list
addAll
-
bag
Add all items into this bag.
Parameters:
-
bag
Bagadded
capacity
()
Number
Returns the number of elements the bag can hold without growing.
Returns:
clear
()
Removes all of the elements from this bag. The bag will be empty after this call returns.
contains
-
Mixed
Check if bag contains this element.
Parameters:
-
Mixed
Object
Returns:
ensureCapacity
-
index
Method verify the capacity of the bag
Parameters:
-
index
Number
get
-
index
Returns the element at the specified position in Bag.
Parameters:
-
index
Numberindex of the element to return
Returns:
isEmpty
()
Boolean
Returns true if this list contains no elements.
Returns:
isIndexWithinBounds
-
index
Checks if the internal storage supports this index.
Parameters:
-
index
Number
Returns:
remove
-
Mixed
Removes the element at the specified position in this Bag. does this by overwriting it was last element then removing last element
Parameters:
-
Mixed
Objectindex the index of element to be removed
Returns:
removeAll
-
Bag
Removes from this Bag all of its elements that are contained in the specified Bag.
Parameters:
-
Bag
Bagcontaining elements to be removed from this Bag
Returns:
removeLast
()
Remove and return the last object in the bag.
Returns:
set
-
index
-
Mixed
Set element at specified index in the bag.
Parameters:
-
index
Numberposition of element
-
Mixed
Objectthe element
size
()
Number
Returns the number of elements in this bag.
Returns:
Properties
data
Array
private
Contains all of the elements