Grape.Bag Class
A bag class, ie. an unordered list. It is an array, but if you remove an item, and the bag contains at least one more item, the last item replaces the item, and length is reduced by 1.
Constructor
Grape.Bag
()
Methods
add
(
Number
-
item
Adds an element to the bag. Equivalent to push()
Parameters:
-
item
The item to add
Returns:
Number:
the new size of the bag
remove
(
-
index
Parameters:
-
index
NumberThe index to remove at
Returns:
:
The moved item (which replaces the removed item)