npm package: @structures/array-list
Description: ArrayList Data Structure
Author: Tyler Williams
Latest version: 0.1.3

## Classes

<dl>
<dt><a href="#ArrayList">ArrayList</a></dt>
<dd><p>Class storing elements in contiguous memory.  Allows precise control over resizing strategy.
Note: In most cases, the built-in JS Array will outperform this structure due to internal
      optimizations.</p>
</dd>
</dl>

## Constants

<dl>
<dt><a href="#DEFAULT_INITIAL_CAPACITY">DEFAULT_INITIAL_CAPACITY</a></dt>
<dd></dd>
<dt><a href="#DEFAULT_RESIZE_STRATEGY">DEFAULT_RESIZE_STRATEGY</a></dt>
<dd></dd>
</dl>

<a name="ArrayList"></a>

## ArrayList
Class storing elements in contiguous memory.  Allows precise control over resizing strategy.
Note: In most cases, the built-in JS Array will outperform this structure due to internal
      optimizations.

**Kind**: global class  

* [ArrayList](#ArrayList)
    * [new ArrayList([initialCapacity], [resizeStrategy])](#new_ArrayList_new)
    * [.add(...elements)](#ArrayList+add) ⇒ [<code>ArrayList</code>](#ArrayList)
    * [.addAll(iterable)](#ArrayList+addAll) ⇒ [<code>ArrayList</code>](#ArrayList)
    * [.clear()](#ArrayList+clear) ⇒ [<code>ArrayList</code>](#ArrayList)
    * [.contains(element, [comparator])](#ArrayList+contains) ⇒ <code>boolean</code>
    * [.get(index)](#ArrayList+get) ⇒ <code>\*</code>
    * [.indexOf(element, [comparator])](#ArrayList+indexOf) ⇒ <code>number</code>
    * [.insert(index, element)](#ArrayList+insert) ⇒ [<code>ArrayList</code>](#ArrayList)
    * [.isEmpty()](#ArrayList+isEmpty) ⇒ <code>boolean</code>
    * [.remove(index)](#ArrayList+remove) ⇒ <code>\*</code>
    * [.set(index, elemnet)](#ArrayList+set) ⇒ <code>\*</code>
    * [.size()](#ArrayList+size) ⇒ <code>number</code>
    * [.toString()](#ArrayList+toString) ⇒ <code>string</code>
    * [.iterator()](#ArrayList+iterator) ⇒ <code>iterator</code>

<a name="new_ArrayList_new"></a>

### new ArrayList([initialCapacity], [resizeStrategy])
Creates a new ArrayList


| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [initialCapacity] | <code>number</code> | <code>DEFAULT_INITIAL_CAPACITY</code> | Initial array capacity before resize required. |
| [resizeStrategy] | <code>function</code> | <code>DEFAULT_RESIZE_STRATEGY</code> | Function to resize array after capacity met. |

<a name="ArrayList+add"></a>

### arrayList.add(...elements) ⇒ [<code>ArrayList</code>](#ArrayList)
Adds the passed elements to the list.

**Kind**: instance method of [<code>ArrayList</code>](#ArrayList)  
**Returns**: [<code>ArrayList</code>](#ArrayList) - - This  

| Param | Type | Description |
| --- | --- | --- |
| ...elements | <code>\*</code> | Elements to be added. |

<a name="ArrayList+addAll"></a>

### arrayList.addAll(iterable) ⇒ [<code>ArrayList</code>](#ArrayList)
Adds each element in the passed array to the list.

**Kind**: instance method of [<code>ArrayList</code>](#ArrayList)  
**Returns**: [<code>ArrayList</code>](#ArrayList) - - This  
**Throws**:

- <code>Error</code> Will throw if `iterable` does not implement iterable protocol.


| Param | Type | Description |
| --- | --- | --- |
| iterable | <code>Array</code> | Iterable containing the elements to be added. |

<a name="ArrayList+clear"></a>

### arrayList.clear() ⇒ [<code>ArrayList</code>](#ArrayList)
Clears all elements from the list.

**Kind**: instance method of [<code>ArrayList</code>](#ArrayList)  
**Returns**: [<code>ArrayList</code>](#ArrayList) - - This  
<a name="ArrayList+contains"></a>

### arrayList.contains(element, [comparator]) ⇒ <code>boolean</code>
Checks if an element exists within the list, with the comparator if passed.

**Kind**: instance method of [<code>ArrayList</code>](#ArrayList)  
**Returns**: <code>boolean</code> - - Returns true if element exists, false if not.  

| Param | Type | Description |
| --- | --- | --- |
| element | <code>\*</code> | The element to check existence. |
| [comparator] | <code>function</code> | The function used to compare two elements. |

<a name="ArrayList+get"></a>

### arrayList.get(index) ⇒ <code>\*</code>
Returns the element at the specified index.

**Kind**: instance method of [<code>ArrayList</code>](#ArrayList)  
**Returns**: <code>\*</code> - - Returns the element at the index given.  
**Throws**:

- <code>Error</code> - Will throw if |index| is out of bounds for this list.


| Param | Type | Description |
| --- | --- | --- |
| index | <code>number</code> | The index to retrieve an element from.  Negatives allowed. |

<a name="ArrayList+indexOf"></a>

### arrayList.indexOf(element, [comparator]) ⇒ <code>number</code>
Returns the index of the element, or -1 if it is not in the list.

**Kind**: instance method of [<code>ArrayList</code>](#ArrayList)  
**Returns**: <code>number</code> - - Returns the index of the element, or else -1.  

| Param | Type | Description |
| --- | --- | --- |
| element | <code>\*</code> | The element to retrieve the index of. |
| [comparator] | <code>function</code> | The function used to compare two elements. |

<a name="ArrayList+insert"></a>

### arrayList.insert(index, element) ⇒ [<code>ArrayList</code>](#ArrayList)
Inserts the element at the specified index, shifting remaining elements down.

**Kind**: instance method of [<code>ArrayList</code>](#ArrayList)  
**Returns**: [<code>ArrayList</code>](#ArrayList) - - This  
**Throws**:

- <code>Error</code> - Will throw if |index| is out of bounds for this list.


| Param | Type | Description |
| --- | --- | --- |
| index | <code>number</code> | The index to insert the element at.  Negatives allowed. |
| element | <code>\*</code> | The element to insert. |

<a name="ArrayList+isEmpty"></a>

### arrayList.isEmpty() ⇒ <code>boolean</code>
Returns true if the list has no elements, or else false.

**Kind**: instance method of [<code>ArrayList</code>](#ArrayList)  
**Returns**: <code>boolean</code> - - Whether or not this list is empty  
<a name="ArrayList+remove"></a>

### arrayList.remove(index) ⇒ <code>\*</code>
Removes the element from the list, shifting remaining elements, and returns it.

**Kind**: instance method of [<code>ArrayList</code>](#ArrayList)  
**Returns**: <code>\*</code> - - The element that was removed.  
**Throws**:

- <code>Error</code> - Will throw if |index| is out of bounds for this list.


| Param | Type | Description |
| --- | --- | --- |
| index | <code>number</code> | The index of the element to remove.  Negatives allowed. |

<a name="ArrayList+set"></a>

### arrayList.set(index, elemnet) ⇒ <code>\*</code>
Replaces the element at the specified index.

**Kind**: instance method of [<code>ArrayList</code>](#ArrayList)  
**Returns**: <code>\*</code> - - The element that was replaced.  
**Throws**:

- <code>Error</code> - Will throw if |index| is out of bounds for this list.


| Param | Type | Description |
| --- | --- | --- |
| index | <code>number</code> | The index of the element to replace.  Negatives allowed. |
| elemnet | <code>\*</code> | The element to place in the list. |

<a name="ArrayList+size"></a>

### arrayList.size() ⇒ <code>number</code>
Returns the current number of elements in the list.

**Kind**: instance method of [<code>ArrayList</code>](#ArrayList)  
**Returns**: <code>number</code> - - The current list size.  
<a name="ArrayList+toString"></a>

### arrayList.toString() ⇒ <code>string</code>
Returns a string representation of this list.

**Kind**: instance method of [<code>ArrayList</code>](#ArrayList)  
**Returns**: <code>string</code> - - The string representation of this list.  
<a name="ArrayList+iterator"></a>

### arrayList.iterator() ⇒ <code>iterator</code>
Returns an object that implements the iterator protocol.

**Kind**: instance method of [<code>ArrayList</code>](#ArrayList)  
**Returns**: <code>iterator</code> - - An iterator for the list.  Not access safe.  
<a name="DEFAULT_INITIAL_CAPACITY"></a>

## DEFAULT_INITIAL_CAPACITY
**Kind**: global constant  
**Default**: <code>8</code>  
<a name="DEFAULT_RESIZE_STRATEGY"></a>

## DEFAULT_RESIZE_STRATEGY
**Kind**: global constant  
**Default**: <code>- Doubles array capacity once limit is reached</code>