java.lang.Object
java.util.AbstractCollection<Long>
java.util.AbstractList<Long>
org.gvsig.fmap.dal.feature.impl.indexes.memorybasictypes.ArrayListOfLong
All Implemented Interfaces:
Cloneable, Iterable<Long>, Collection<Long>, List<Long>, RandomAccess, SequencedCollection<Long>, ListOfLong

public class ArrayListOfLong extends AbstractList<Long> implements ListOfLong, RandomAccess, Cloneable
Author:
jjdelcerro
  • Constructor Details

    • ArrayListOfLong

      public ArrayListOfLong(int initialCapacity)
      Constructs an empty list with the specified initial capacity.
      Parameters:
      initialCapacity - the initial capacity of the list
      Throws:
      IllegalArgumentException - if the specified initial capacity is negative
    • ArrayListOfLong

      public ArrayListOfLong()
      Constructs an empty list with an initial capacity of ten.
    • ArrayListOfLong

      public ArrayListOfLong(Collection<? extends Long> c)
      Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.
      Parameters:
      c - the collection whose elements are to be placed into this list
      Throws:
      NullPointerException - if the specified collection is null
  • Method Details

    • trimToSize

      public void trimToSize()
      Trims the capacity of this ArrayList instance to be the list's current size. An application can use this operation to minimize the storage of an ArrayList instance.
    • ensureCapacity

      public void ensureCapacity(int minCapacity)
      Increases the capacity of this ArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
      Parameters:
      minCapacity - the desired minimum capacity
    • size

      public int size()
      Returns the number of elements in this list.
      Specified by:
      size in interface Collection<Long>
      Specified by:
      size in interface List<Long>
      Specified by:
      size in class AbstractCollection<Long>
      Returns:
      the number of elements in this list
    • isEmpty

      public boolean isEmpty()
      Returns true if this list contains no elements.
      Specified by:
      isEmpty in interface Collection<Long>
      Specified by:
      isEmpty in interface List<Long>
      Overrides:
      isEmpty in class AbstractCollection<Long>
      Returns:
      true if this list contains no elements
    • contains

      public boolean contains(Object o)
      Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that (o==null ? e==null : o.equals(e)).
      Specified by:
      contains in interface Collection<Long>
      Specified by:
      contains in interface List<Long>
      Overrides:
      contains in class AbstractCollection<Long>
      Parameters:
      o - element whose presence in this list is to be tested
      Returns:
      true if this list contains the specified element
    • indexOf

      public int indexOf(Object o)
      Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
      Specified by:
      indexOf in interface List<Long>
      Overrides:
      indexOf in class AbstractList<Long>
    • lastIndexOf

      public int lastIndexOf(Object o)
      Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
      Specified by:
      lastIndexOf in interface List<Long>
      Overrides:
      lastIndexOf in class AbstractList<Long>
    • clone

      public Object clone()
      Returns a shallow copy of this ArrayList instance. (The elements themselves are not copied.)
      Overrides:
      clone in class Object
      Returns:
      a clone of this ArrayList instance
    • toArray

      public Long[] toArray()
      Specified by:
      toArray in interface Collection<Long>
      Specified by:
      toArray in interface List<Long>
      Overrides:
      toArray in class AbstractCollection<Long>
    • toArray

      public Long[] toArray(Long[] a)
    • get

      public Long get(int index)
      Specified by:
      get in interface List<Long>
      Specified by:
      get in class AbstractList<Long>
    • getLong

      public long getLong(int index)
      Specified by:
      getLong in interface ListOfLong
    • set

      public Long set(int index, Long element)
      Replaces the element at the specified position in this list with the specified element.
      Specified by:
      set in interface List<Long>
      Overrides:
      set in class AbstractList<Long>
      Parameters:
      index - index of the element to replace
      element - element to be stored at the specified position
      Returns:
      the element previously at the specified position
    • add

      public boolean add(Long e)
      Specified by:
      add in interface Collection<Long>
      Specified by:
      add in interface List<Long>
      Overrides:
      add in class AbstractList<Long>
    • add

      public boolean add(long e)
      Specified by:
      add in interface ListOfLong
    • add

      public void add(int index, Long element)
      Specified by:
      add in interface List<Long>
      Overrides:
      add in class AbstractList<Long>
    • add

      public void add(int index, long element)
    • remove

      public Long remove(int index)
      Specified by:
      remove in interface List<Long>
      Overrides:
      remove in class AbstractList<Long>
    • remove

      public boolean remove(Object o)
      Specified by:
      remove in interface Collection<Long>
      Specified by:
      remove in interface List<Long>
      Overrides:
      remove in class AbstractCollection<Long>
    • removeLong

      public boolean removeLong(long o)
      Specified by:
      removeLong in interface ListOfLong
    • clear

      public void clear()
      Removes all of the elements from this list. The list will be empty after this call returns.
      Specified by:
      clear in interface Collection<Long>
      Specified by:
      clear in interface List<Long>
      Overrides:
      clear in class AbstractList<Long>
    • addAll

      public boolean addAll(Collection<? extends Long> c)
      Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's Iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this list, and this list is nonempty.)
      Specified by:
      addAll in interface Collection<Long>
      Specified by:
      addAll in interface List<Long>
      Overrides:
      addAll in class AbstractCollection<Long>
      Parameters:
      c - collection containing elements to be added to this list
      Returns:
      true if this list changed as a result of the call
      Throws:
      NullPointerException - if the specified collection is null
    • addAll

      public boolean addAll(int index, Collection<? extends Long> c)
      Inserts all of the elements in the specified collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the list in the order that they are returned by the specified collection's iterator.
      Specified by:
      addAll in interface List<Long>
      Overrides:
      addAll in class AbstractList<Long>
      Parameters:
      index - index at which to insert the first element from the specified collection
      c - collection containing elements to be added to this list
      Returns:
      true if this list changed as a result of the call
    • removeRange

      protected void removeRange(int fromIndex, int toIndex)
      Removes from this list all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive. Shifts any succeeding elements to the left (reduces their index). This call shortens the list by (toIndex - fromIndex) elements. (If toIndex==fromIndex, this operation has no effect.)
      Overrides:
      removeRange in class AbstractList<Long>
      Throws:
      IndexOutOfBoundsException - if fromIndex or toIndex is out of range (fromIndex < 0 || fromIndex >= size() || toIndex > size() || toIndex < fromIndex)
    • removeAll

      public boolean removeAll(Collection<?> c)
      Removes from this list all of its elements that are contained in the specified collection.
      Specified by:
      removeAll in interface Collection<Long>
      Specified by:
      removeAll in interface List<Long>
      Overrides:
      removeAll in class AbstractCollection<Long>
      Parameters:
      c - collection containing elements to be removed from this list
      Returns:
      true if this list changed as a result of the call
      Throws:
      ClassCastException - if the class of an element of this list is incompatible with the specified collection (optional)
      NullPointerException - if this list contains a null element and the specified collection does not permit null elements (optional), or if the specified collection is null
      See Also:
    • retainAll

      public boolean retainAll(Collection<?> c)
      Retains only the elements in this list that are contained in the specified collection. In other words, removes from this list all of its elements that are not contained in the specified collection.
      Specified by:
      retainAll in interface Collection<Long>
      Specified by:
      retainAll in interface List<Long>
      Overrides:
      retainAll in class AbstractCollection<Long>
      Parameters:
      c - collection containing elements to be retained in this list
      Returns:
      true if this list changed as a result of the call
      Throws:
      ClassCastException - if the class of an element of this list is incompatible with the specified collection (optional)
      NullPointerException - if this list contains a null element and the specified collection does not permit null elements (optional), or if the specified collection is null
      See Also:
    • listIterator

      public ListIterator<Long> listIterator(int index)
      Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list. The specified index indicates the first element that would be returned by an initial call to next. An initial call to previous would return the element with the specified index minus one.

      The returned list iterator is fail-fast.

      Specified by:
      listIterator in interface List<Long>
      Overrides:
      listIterator in class AbstractList<Long>
    • listIterator

      public ListIterator<Long> listIterator()
      Returns a list iterator over the elements in this list (in proper sequence).

      The returned list iterator is fail-fast.

      Specified by:
      listIterator in interface List<Long>
      Overrides:
      listIterator in class AbstractList<Long>
      See Also:
    • iterator

      public Iterator<Long> iterator()
      Returns an iterator over the elements in this list in proper sequence.

      The returned iterator is fail-fast.

      Specified by:
      iterator in interface Collection<Long>
      Specified by:
      iterator in interface Iterable<Long>
      Specified by:
      iterator in interface List<Long>
      Overrides:
      iterator in class AbstractList<Long>
      Returns:
      an iterator over the elements in this list in proper sequence
    • subList

      public List<Long> subList(int fromIndex, int toIndex)
      Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. The returned list supports all of the optional list operations.

      This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:

            list.subList(from, to).clear();
       
      Similar idioms may be constructed for indexOf(Object) and lastIndexOf(Object), and all of the algorithms in the Collections class can be applied to a subList.

      The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)

      Specified by:
      subList in interface List<Long>
      Overrides:
      subList in class AbstractList<Long>
    • forEach

      public void forEach(Consumer<? super Long> action)
      Specified by:
      forEach in interface Iterable<Long>
    • spliterator

      public Spliterator<Long> spliterator()
      Creates a late-binding and fail-fast Spliterator over the elements in this list.

      The Spliterator reports Spliterator.SIZED, Spliterator.SUBSIZED, and Spliterator.ORDERED. Overriding implementations should document the reporting of additional characteristic values.

      Specified by:
      spliterator in interface Collection<Long>
      Specified by:
      spliterator in interface Iterable<Long>
      Specified by:
      spliterator in interface List<Long>
      Returns:
      a Spliterator over the elements in this list
      Since:
      1.8
    • removeIf

      public boolean removeIf(Predicate<? super Long> filter)
      Specified by:
      removeIf in interface Collection<Long>
    • replaceAll

      public void replaceAll(UnaryOperator<Long> operator)
      Specified by:
      replaceAll in interface List<Long>
    • sort

      public void sort(Comparator<? super Long> c)
      Specified by:
      sort in interface List<Long>