API Docs for: 1.0.1

Grape.Bag Class

Extends

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

()

Item Index

Methods

Methods

add

(
  • item
)
Number

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 Number

    The index to remove at

Returns:

:

The moved item (which replaces the removed item)