## org.apache.mahout.math.list
Class SimpleLongArrayList

    java.lang.Object
      org.apache.mahout.math.PersistentObject
          org.apache.mahout.math.list.AbstractList
              org.apache.mahout.math.list.AbstractLongList
                  org.apache.mahout.math.list.SimpleLongArrayList

All Implemented Interfaces:
  Serializable, Cloneable, LongBufferConsumer

    public class SimpleLongArrayList

extends AbstractLongList

Resizable list holding `long` elements; implemented with arrays; not efficient; just to demonstrate which methods you must override to implement a fully functional list.

See Also:
  Serialized Form

Field Summary

Fields inherited from class org.apache.mahout.math.list.AbstractLongList
`size`

Constructor Summary
`SimpleLongArrayList()` Constructs an empty list.
`SimpleLongArrayList(long[] elements)` Constructs a list containing the specified elements.

Method Summary
`void` `ensureCapacity(int minCapacity)` Ensures that the receiver can hold at least the specified number of elements without needing to allocate new internal memory.
`protected long` `getQuick(int index)` Returns the element at the specified position in the receiver; WARNING: Does not check preconditions.
`protected void` `setQuick(int index, long element)` Replaces the element at the specified position in the receiver with the specified element; WARNING: Does not check preconditions.
`void` `trimToSize()` Trims the capacity of the receiver to be the receiver's current size.

Methods inherited from class org.apache.mahout.math.list.AbstractLongList

`add, addAllOf, addAllOf, addAllOfFromTo, beforeInsert, beforeInsertAllOfFromTo, beforeInsertDummies, binarySearch, binarySearchFromTo, clone, contains, delete, elements, elements, equals, fillFromToWith, forEach, get, indexOf, indexOfFromTo, lastIndexOf, lastIndexOfFromTo, mergeSortFromTo, mergeSortFromTo, partFromTo, quickSortFromTo, quickSortFromTo, removeAll, removeFromTo, replaceFromToWithFrom, replaceFromToWithFromTo, retainAll, reverse, set, setSizeRaw, size, times, toArray, toList, toString`

Methods inherited from class org.apache.mahout.math.list.AbstractList
`checkRange, checkRangeFromTo, clear, isEmpty, mergeSort, quickSort, remove, setSize, sort, sortFromTo`

Methods inherited from class java.lang.Object
`finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### SimpleLongArrayList

    public SimpleLongArrayList()

  Constructs an empty list.

### SimpleLongArrayList

    public SimpleLongArrayList(long[] elements)

  Constructs a list containing the specified elements. The initial size and capacity of the list is the length of the array. WARNING: For efficiency reasons and to keep memory usage low, the array is not copied. So if subsequently you modify the specified array directly via the [] operator, be sure you know what you're doing.

  Parameters:
    `elements` - the array to be backed by the the constructed list

Method Detail

### ensureCapacity

    public void ensureCapacity(int minCapacity)

  Ensures that the receiver can hold at least the specified number of elements without needing to allocate new internal memory. If necessary, allocates new internal memory and increases the capacity of the receiver.

  Specified by:
    `ensureCapacity` in class `AbstractLongList`
  Parameters:
    `minCapacity` - the desired minimum capacity.

### getQuick

    protected long getQuick(int index)

  Returns the element at the specified position in the receiver; WARNING: Does not check preconditions. Provided with invalid parameters this method may return invalid elements without throwing any exception! You should only use this method when you are absolutely sure that the index is within bounds. Precondition (unchecked): `index >= 0 && index < size()`.

  Specified by:
    `getQuick` in class `AbstractLongList`
  Parameters:
    `index` - index of element to return.

### setQuick

    protected void setQuick(int index,
                            long element)

  Replaces the element at the specified position in the receiver with the specified element; WARNING: Does not check preconditions. Provided with invalid parameters this method may access invalid indexes without throwing any exception! You should only use this method when you are absolutely sure that the index is within bounds. Precondition (unchecked): `index >= 0 && index < size()`.

  Specified by:
    `setQuick` in class `AbstractLongList`
  Parameters:
    `index` - index of element to replace.
    `element` - element to be stored at the specified position.

### trimToSize

    public void trimToSize()

  Trims the capacity of the receiver to be the receiver's current size. An application can use this operation to minimize the storage of the receiver.

  Overrides:
    `trimToSize` in class `AbstractList`

Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.