Class FloatObjBigList

All Implemented Interfaces:
Serializable, Cloneable, Iterable<Float>, Collection<Float>, List<Float>, RandomAccess, SequencedCollection<Float>, ICollection<Float>, IListable<Float>
Direct Known Subclasses:
FloatObjBigList.ImmutableFloatObjBigList

public class FloatObjBigList extends IList<Float>
FloatObjBigList implements the List interface and uses an instance of FloatBigList for storage. It therefore allows to use the advantages of primitive collections like saved memory and improved execution speed when standard list collections are expected.

Note that this implementation is not synchronized.

Version:
$Id: FloatObjBigList.java 2200 2014-03-21 10:46:29Z origo $
See Also:
  • Field Details

  • Constructor Details

    • FloatObjBigList

      public FloatObjBigList()
    • FloatObjBigList

      public FloatObjBigList(int capacity)
    • FloatObjBigList

      public FloatObjBigList(Collection<? extends Float> elems)
  • Method Details

    • toWrapper

      static Float[] toWrapper(float[] elems)
    • toPrimitive

      static float[] toPrimitive(Float[] elems)
    • toPrimitive

      static float[] toPrimitive(BigList<? extends Float> list2)
    • toPrimitive

      static float[] toPrimitive(Collection<? extends Float> list)
    • create

      public static FloatObjBigList create()
    • create

      public static FloatObjBigList create(Float... elems)
    • create

      public static FloatObjBigList create(Collection<? extends Float> elems)
    • init

      public void init()
    • init

      public void init(Float... elems)
    • init

      public void init(Collection<? extends Float> elems)
    • doClone

      protected void doClone(IList<Float> that)
      Description copied from class: IList
      Initialize this object after the bitwise copy has been made by Object.clone().
      Specified by:
      doClone in class IList<Float>
      Parameters:
      that - source object
    • doAssign

      protected void doAssign(IList<Float> that)
      Description copied from class: IList
      Assign this list the content of the that list. This is done by bitwise copying so the that list should not be used afterwards.
      Specified by:
      doAssign in class IList<Float>
      Parameters:
      that - list to copy content from
    • isReadOnly

      public boolean isReadOnly()
      Description copied from class: IList
      Returns true if this list is either unmodifiable or immutable, false otherwise.
      Specified by:
      isReadOnly in class IList<Float>
    • copy

      public FloatObjBigList copy()
      Description copied from class: IList
      Returns a shallow copy of this list. The new list will contain the same elements as the source list, i.e. the elements themselves are not copied. The capacity of the list will be set to the number of elements, i.e. size and capacity are equal. This returned list will be modifiable, i.e. a read-only list will be copied and be modifiable again.
      Specified by:
      copy in interface ICollection<Float>
      Specified by:
      copy in class IList<Float>
      Returns:
      a modifiable copy of this list
    • clone

      public FloatObjBigList clone()
      Description copied from class: IList
      Returns a shallow copy of this list. The new list will contain the same elements as the source list, i.e. the elements themselves are not copied. The capacity of the list will be set to the number of elements, i.e. size and capacity are equal. If the list is read-only, the same list is returned without change. Use IList.copy() to .
      Overrides:
      clone in class IList<Float>
      Returns:
      a modifiable copy of this list
    • getDefaultElem

      public Float getDefaultElem()
      Specified by:
      getDefaultElem in class IList<Float>
    • doCreate

      public IList<Float> doCreate(int capacity)
      Description copied from class: IList
      Create list with specified capacity.
      Specified by:
      doCreate in class IList<Float>
      Parameters:
      capacity - initial capacity (use -1 for default capacity)
      Returns:
      created list
    • size

      public int size()
      Description copied from interface: IListable
      Return size of list
      Specified by:
      size in interface Collection<Float>
      Specified by:
      size in interface IListable<Float>
      Specified by:
      size in interface List<Float>
      Specified by:
      size in class IList<Float>
    • capacity

      public int capacity()
      Returns capacity of this BigList. Note that two BigLists are considered equal even if they have a distinct capacity. Also the capacity can be changed by operations like clone() etc.
      Specified by:
      capacity in class IList<Float>
      Returns:
      capacity of this BigList
    • get

      public Float get(int index)
      Description copied from interface: IListable
      Return element at specified position
      Specified by:
      get in interface IListable<Float>
      Specified by:
      get in interface List<Float>
      Overrides:
      get in class IList<Float>
    • doGet

      protected Float doGet(int index)
      Description copied from class: IList
      Helper method for getting an element from the list. This is the only method which really gets an element. Override if you need to validity checks before getting.
      Specified by:
      doGet in class IList<Float>
      Parameters:
      index - index of element to return
      Returns:
      the element at the specified position in this list
    • doGetAll

      protected void doGetAll(Object[] elems, int index, int len)
      Description copied from class: IList
      Helper method to fill the specified elements in an array.
      Overrides:
      doGetAll in class IList<Float>
      Parameters:
      elems - array to store the list elements
      index - index of first element to copy
      len - number of elements to copy
    • doAdd

      protected boolean doAdd(int index, Float elem)
      Description copied from class: IList
      Helper method for adding an element to the list. This is the only method which really adds an element. Override if you need to validity checks before adding.
      Specified by:
      doAdd in class IList<Float>
      Parameters:
      index - index where element should be added (-1 means it is up to the implementation to choose the index)
      elem - element to add
      Returns:
      true if element has been added, false otherwise
    • doSet

      protected Float doSet(int index, Float elem)
      Description copied from class: IList
      Helper method for setting an element in the list. This is the only method which really sets an element. Override if you need to validity checks before setting.
      Specified by:
      doSet in class IList<Float>
      Parameters:
      index - index where element will be placed
      elem - element to set
      Returns:
      old element which was at the position
    • doRemove

      protected Float doRemove(int index)
      Description copied from class: IList
      Helper method to remove an element. This is the only method which really removes an element. Override if you need to validity checks before removing.
      Specified by:
      doRemove in class IList<Float>
      Parameters:
      index - index of element to remove
      Returns:
      removed element
    • doRemoveAll

      protected void doRemoveAll(int index, int len)
      Description copied from class: IList
      Remove specified range of elements from list.
      Overrides:
      doRemoveAll in class IList<Float>
      Parameters:
      index - index of first element to remove
      len - number of elements to remove
    • doReSet

      protected Float doReSet(int index, Float elem)
      Description copied from class: IList
      Sets an element at specified position. This method is used internally if existing elements will be moved etc. Override if you need to validity checks.
      Specified by:
      doReSet in class IList<Float>
      Parameters:
      index - index where element will be placed
      elem - element to set
      Returns:
      old element which was at the position
    • move

      public void move(int srcIndex, int dstIndex, int len)
      Description copied from class: IList
      Move specified elements. Source and destination ranges may overlap. The elements which are moved away are set to null, so the size of the list does not change.
      Overrides:
      move in class IList<Float>
      Parameters:
      srcIndex - index of first source element to move
      dstIndex - index of first destination element to move
      len - number of elements to move
    • doEnsureCapacity

      protected void doEnsureCapacity(int minCapacity)
      Description copied from class: IList
      Increases the capacity of this list instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
      Specified by:
      doEnsureCapacity in class IList<Float>
      Parameters:
      minCapacity - the desired minimum capacity
    • trimToSize

      public void trimToSize()
      Description copied from class: IList
      An application can use this operation to minimize the storage of an instance.
      Specified by:
      trimToSize in class IList<Float>
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Collection<Float>
      Specified by:
      equals in interface List<Float>
      Overrides:
      equals in class IList<Float>
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Collection<Float>
      Specified by:
      hashCode in interface List<Float>
      Overrides:
      hashCode in class IList<Float>
    • toString

      public String toString()
      Overrides:
      toString in class IList<Float>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Collection<Float>
      Specified by:
      isEmpty in interface List<Float>
      Overrides:
      isEmpty in class IList<Float>
    • indexOf

      public int indexOf(Object elem)
      Specified by:
      indexOf in interface List<Float>
      Overrides:
      indexOf in class IList<Float>
    • lastIndexOf

      public int lastIndexOf(Object elem)
      Specified by:
      lastIndexOf in interface List<Float>
      Overrides:
      lastIndexOf in class IList<Float>
    • remove

      public boolean remove(Object elem)
      Specified by:
      remove in interface Collection<Float>
      Specified by:
      remove in interface List<Float>
      Overrides:
      remove in class IList<Float>
    • contains

      public boolean contains(Object elem)
      Specified by:
      contains in interface Collection<Float>
      Specified by:
      contains in interface List<Float>
      Overrides:
      contains in class IList<Float>
    • containsAny

      public boolean containsAny(Collection<?> coll)
      Description copied from class: IList
      Returns true if any of the elements of the specified collection is contained in the list.
      Overrides:
      containsAny in class IList<Float>
      Parameters:
      coll - collection with elements to be contained
      Returns:
      true if any element is contained, false otherwise
    • containsAll

      public boolean containsAll(Collection<?> coll)
      Specified by:
      containsAll in interface Collection<Float>
      Specified by:
      containsAll in interface List<Float>
      Overrides:
      containsAll in class IList<Float>
    • removeAll

      public boolean removeAll(Collection<?> coll)
      Specified by:
      removeAll in interface Collection<Float>
      Specified by:
      removeAll in interface List<Float>
      Overrides:
      removeAll in class IList<Float>
    • removeAll

      public boolean removeAll(IList<?> coll)
      Overrides:
      removeAll in class IList<Float>
      See Also:
    • retainAll

      public boolean retainAll(Collection<?> coll)
      Specified by:
      retainAll in interface Collection<Float>
      Specified by:
      retainAll in interface List<Float>
      Overrides:
      retainAll in class IList<Float>
    • retainAll

      public boolean retainAll(IList<?> coll)
      Overrides:
      retainAll in class IList<Float>
      See Also:
    • toArray

      public Object[] toArray(int index, int len)
      Returns an array containing the specified elements in this list.
      Overrides:
      toArray in class IList<Float>
      Parameters:
      index - index of first element to copy
      len - number of elements to copy
      Returns:
      array containing the specified elements
      See Also:
      • invalid reference
        List#toArray()
    • toArray

      public <T> T[] toArray(T[] array, int index, int len)
      Returns an array containing the specified elements in this list.
      Overrides:
      toArray in class IList<Float>
      Parameters:
      array - the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose
      index - index of first element to copy
      len - number of elements to copy
      Returns:
      array containing the specified elements
      See Also:
      • invalid reference
        List#toArray(Object[])
    • toArray

      public <T> T[] toArray(Class<T> clazz, int index, int len)
      Returns an array containing the specified elements in this list.
      Overrides:
      toArray in class IList<Float>
      Parameters:
      clazz - class for array elements
      index - index of first element to copy
      len - number of elements to copy
      Returns:
      array containing the specified elements
    • addAll

      public boolean addAll(Collection<? extends Float> coll)
      Description copied from class: IList
      Adds all of the elements in the specified collection into this list. 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 Collection<Float>
      Specified by:
      addAll in interface List<Float>
      Overrides:
      addAll in class IList<Float>
      Parameters:
      coll - collection containing elements to be added to this list
      Returns:
      true if this list changed as a result of the call
    • addAll

      public boolean addAll(int index, Collection<? extends Float> coll)
      Description copied from class: IList
      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<Float>
      Overrides:
      addAll in class IList<Float>
      Parameters:
      index - index at which to insert the first element from the specified collection
      coll - collection containing elements to be inserted into this list
      Returns:
      true if this list changed as a result of the call
    • addArray

      public boolean addArray(Float... elems)
      Description copied from class: IList
      Adds all specified elements into this list.
      Overrides:
      addArray in class IList<Float>
      Parameters:
      elems - elements to be added to this list
      Returns:
      true if this list changed as a result of the call
    • addArray

      public boolean addArray(int index, Float... elems)
      Description copied from class: IList
      Inserts the specified elements 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).
      Overrides:
      addArray in class IList<Float>
      Parameters:
      index - index at which to insert the first element from the specified collection
      elems - elements to be inserted into this list
      Returns:
      true if this list changed as a result of the call
    • addAll

      public boolean addAll(IList<? extends Float> list2)
      Description copied from class: IList
      Adds all of the elements in the specified list into this list.
      Overrides:
      addAll in class IList<Float>
      Parameters:
      list2 - collection containing elements to be added to this list
      Returns:
      true if this list changed as a result of the call
    • addAll

      public boolean addAll(int index, IList<? extends Float> list2)
      Description copied from class: IList
      Inserts all of the elements in the specified list 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).
      Overrides:
      addAll in class IList<Float>
      Parameters:
      index - index at which to insert the first element from the specified collection
      list2 - list containing elements to be inserted into this list
      Returns:
      true if this list changed as a result of the call
    • removeFirstOccurrence

      public boolean removeFirstOccurrence(Object elem)
      Description copied from class: IList
      Overrides:
      removeFirstOccurrence in class IList<Float>
    • removeLastOccurrence

      public boolean removeLastOccurrence(Object elem)
      Description copied from class: IList
      Overrides:
      removeLastOccurrence in class IList<Float>
    • getAll

      public BigList<Float> getAll(int index, int len)
      Description copied from class: IList
      Returns specified range of elements from list.
      Overrides:
      getAll in class IList<Float>
      Parameters:
      index - index of first element to retrieve
      len - number of elements to retrieve
      Returns:
      list containing the specified range of elements
    • setAll

      public void setAll(int index, IList<? extends Float> list2)
      Description copied from class: IList
      Sets the specified elements.
      Overrides:
      setAll in class IList<Float>
      Parameters:
      index - index of first element to set
      list2 - list with elements to set
    • setAll

      public void setAll(int index, Collection<? extends Float> coll)
      Description copied from class: IList
      Sets the specified elements.
      Overrides:
      setAll in class IList<Float>
      Parameters:
      index - index of first element to set
      coll - collection with elements to set
    • setArray

      public void setArray(int index, Float... elems)
      Description copied from class: IList
      Sets the specified elements.
      Overrides:
      setArray in class IList<Float>
      Parameters:
      index - index of first element to set
      elems - array with elements to set
    • sort

      public void sort(int index, int len, Comparator comparator)
      Description copied from class: IList
      Sort specified elements in the list using the specified comparator.
      Specified by:
      sort in class IList<Float>
      Parameters:
      index - index of first element to sort
      len - number of elements to sort
      comparator - comparator to use for sorting (null means the elements natural ordering should be used)
      See Also:
    • binarySearch

      public <K> int binarySearch(int index, int len, K key, Comparator<? super K> comparator)
      Description copied from class: IList
      Searches the specified range for an object using the binary search algorithm.

      Note that the method is defined to work with an arbitrary type <K>. This allows to search directly for a key field in the object without the need to construct an object containing the key:

      
       persons.binarySearch("john", new SearchByName());
       
       class SearchByName implements Comparator<Object> {
      	 public int compare(Object o1, Object o2) {
      	   String s1 = (o1 instanceof String) ? (String) o1 : ((Name) o1).getName();
      	   String s2 = (o2 instanceof String) ? (String) o2 : ((Name) o2).getName();
      	   return s1.compareTo(s2);
      	 }
       }
       /
      Specified by:
      binarySearch in class IList<Float>
      Parameters:
      index - index of first element to search
      len - number of elements to search
      key - the value to be searched for
      comparator - the comparator by which the list is ordered. A null value indicates that the elements' natural ordering should be used.
      Returns:
      index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found.
      See Also:
    • unmodifiableList

      public FloatObjBigList unmodifiableList()
      Description copied from class: IList
      Returns an unmodifiable view of this list. This method allows modules to provide users with "read-only" access to internal lists, where changes made to the original list are visible as query operations on the returned list "read through" to the specified list. Attempts to modify the returned list, whether direct or via its iterator, result in an UnsupportedOperationException. If this list is already unmodifiable, it is returned unchanged. See IList.immutableList() to get an immutable copy of a list.
      Specified by:
      unmodifiableList in class IList<Float>
      Returns:
      an unmodifiable view of the specified list
    • immutableList

      public FloatObjBigList immutableList()
      Description copied from class: IList
      Returns an immutable copy of this list. The returned list is independent from the original list, i.e. changes done later are not seen. Attempts to modify the returned list, whether direct or via its iterator, result in an UnsupportedOperationException. If this list is already immutable, it is returned unchanged. See IList.unmodifiableList() to get unmodifiable view of a list.
      Specified by:
      immutableList in class IList<Float>
      Returns:
      an immutable copy of the specified list