Class AbstractObjectBigList<K>

java.lang.Object
java.util.AbstractCollection<K>
it.unimi.dsi.fastutil.objects.AbstractObjectCollection<K>
it.unimi.dsi.fastutil.objects.AbstractObjectBigList<K>
All Implemented Interfaces:
it.unimi.dsi.fastutil.BigList<K>, ObjectBigList<K>, it.unimi.dsi.fastutil.objects.ObjectCollection<K>, it.unimi.dsi.fastutil.objects.ObjectIterable<K>, it.unimi.dsi.fastutil.Size64, it.unimi.dsi.fastutil.Stack<K>, Comparable<it.unimi.dsi.fastutil.BigList<? extends K>>, Iterable<K>, Collection<K>
Direct Known Subclasses:
AbstractObjectBigList.ObjectSubList, ObjectBigArrayBigList, ObjectBigLists.ListBigList, ObjectBigLists.Singleton

public abstract class AbstractObjectBigList<K> extends it.unimi.dsi.fastutil.objects.AbstractObjectCollection<K> implements ObjectBigList<K>, it.unimi.dsi.fastutil.Stack<K>
An abstract class providing basic methods for big lists implementing a type-specific big list interface.

Most of the methods in this class are optimized with the assumption that the List will have have constant-time random access. If this is not the case, you should probably at least override listIterator(long) and the xAll() methods (such as addAll(long, java.util.Collection<? extends K>)) with a more appropriate iteration scheme. Note the subList(long, long) method is cognizant of random-access or not, so that need not be reimplemented.

  • Constructor Details

    • AbstractObjectBigList

      protected AbstractObjectBigList()
  • Method Details

    • ensureIndex

      protected void ensureIndex(long index)
      Ensures that the given index is nonnegative and not greater than this big-list size.
      Parameters:
      index - an index.
      Throws:
      IndexOutOfBoundsException - if the given index is negative or greater than this big-list size.
    • ensureRestrictedIndex

      protected void ensureRestrictedIndex(long index)
      Ensures that the given index is nonnegative and smaller than this big-list size.
      Parameters:
      index - an index.
      Throws:
      IndexOutOfBoundsException - if the given index is negative or not smaller than this big-list size.
    • add

      public void add(long index, K k)
      Specified by:
      add in interface it.unimi.dsi.fastutil.BigList<K>
    • add

      public boolean add(K k)
      Specified by:
      add in interface Collection<K>
      Overrides:
      add in class AbstractCollection<K>
    • remove

      public K remove(long i)
      Specified by:
      remove in interface it.unimi.dsi.fastutil.BigList<K>
    • set

      public K set(long index, K k)
      Specified by:
      set in interface it.unimi.dsi.fastutil.BigList<K>
    • addAll

      public boolean addAll(long index, Collection<? extends K> c)
      Adds all of the elements in the specified collection to this list (optional operation).
      Specified by:
      addAll in interface it.unimi.dsi.fastutil.BigList<K>
    • addAll

      public boolean addAll(Collection<? extends K> c)
      Specified by:
      addAll in interface Collection<K>
      Overrides:
      addAll in class AbstractCollection<K>
    • iterator

      public it.unimi.dsi.fastutil.objects.ObjectBigListIterator<K> iterator()
      Returns a type-specific iterator on the elements of this list.
      Specified by:
      iterator in interface Collection<K>
      Specified by:
      iterator in interface Iterable<K>
      Specified by:
      iterator in interface ObjectBigList<K>
      Specified by:
      iterator in interface it.unimi.dsi.fastutil.objects.ObjectCollection<K>
      Specified by:
      iterator in interface it.unimi.dsi.fastutil.objects.ObjectIterable<K>
      Specified by:
      iterator in class it.unimi.dsi.fastutil.objects.AbstractObjectCollection<K>
      See Also:
    • listIterator

      public it.unimi.dsi.fastutil.objects.ObjectBigListIterator<K> listIterator()
      Returns a type-specific big-list iterator on this type-specific big list.
      Specified by:
      listIterator in interface it.unimi.dsi.fastutil.BigList<K>
      Specified by:
      listIterator in interface ObjectBigList<K>
      See Also:
      • BigList.listIterator()
    • listIterator

      public it.unimi.dsi.fastutil.objects.ObjectBigListIterator<K> listIterator(long index)
      Returns a type-specific list iterator on this type-specific big list starting at a given index.
      Specified by:
      listIterator in interface it.unimi.dsi.fastutil.BigList<K>
      Specified by:
      listIterator in interface ObjectBigList<K>
      See Also:
      • BigList.listIterator(long)
    • contains

      public boolean contains(Object k)
      Returns true if this list contains the specified element.
      Specified by:
      contains in interface Collection<K>
      Overrides:
      contains in class AbstractCollection<K>
      See Also:
    • indexOf

      public long indexOf(Object k)
      Specified by:
      indexOf in interface it.unimi.dsi.fastutil.BigList<K>
    • lastIndexOf

      public long lastIndexOf(Object k)
      Specified by:
      lastIndexOf in interface it.unimi.dsi.fastutil.BigList<K>
    • size

      public void size(long size)
      Specified by:
      size in interface it.unimi.dsi.fastutil.BigList<K>
    • subList

      public ObjectBigList<K> subList(long from, long to)
      Description copied from interface: ObjectBigList
      Returns a type-specific view of the portion of this type-specific big list from the index from, inclusive, to the index to, exclusive.
      Specified by:
      subList in interface it.unimi.dsi.fastutil.BigList<K>
      Specified by:
      subList in interface ObjectBigList<K>
      See Also:
      • BigList.subList(long,long)
    • forEach

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

      public void removeElements(long from, long to)
      Removes (hopefully quickly) elements of this type-specific big list.

      This is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.

      Specified by:
      removeElements in interface ObjectBigList<K>
      Parameters:
      from - the start index (inclusive).
      to - the end index (exclusive).
    • addElements

      public void addElements(long index, K[][] a, long offset, long length)
      Add (hopefully quickly) elements to this type-specific big list.

      This is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.

      Specified by:
      addElements in interface ObjectBigList<K>
      Parameters:
      index - the index at which to add elements.
      a - the big array containing the elements.
      offset - the offset of the first element to add.
      length - the number of elements to add.
    • addElements

      public void addElements(long index, K[][] a)
      Add (hopefully quickly) elements to this type-specific big list.
      Specified by:
      addElements in interface ObjectBigList<K>
      Parameters:
      index - the index at which to add elements.
      a - the big array containing the elements.
    • getElements

      public void getElements(long from, Object[][] a, long offset, long length)
      Copies (hopefully quickly) elements of this type-specific big list into the given big array.

      This is a trivial iterator-based implementation. It is expected that implementations will override this method with a more optimized version.

      Specified by:
      getElements in interface ObjectBigList<K>
      Parameters:
      from - the start index (inclusive).
      a - the destination big array.
      offset - the offset into the destination big array where to store the first element copied.
      length - the number of elements to be copied.
    • setElements

      public void setElements(long index, K[][] a, long offset, long length)
      Description copied from interface: ObjectBigList
      Set (hopefully quickly) elements to match the array given. Sets each in this list to the corresponding elements in the array, as if by
       ListIterator iter = listIterator(index);
       long i = 0;
       while (i < length) {
         iter.next();
         iter.set(BigArrays.get(a, offset + i++);
       }
       
      However, the exact implementation may be more efficient, taking into account whether random access is faster or not, or at the discretion of subclasses, abuse internals.
      Specified by:
      setElements in interface ObjectBigList<K>
      Parameters:
      index - the index at which to start setting elements.
      a - the big array containing the elements.
      offset - the offset of the first element to add.
      length - the number of elements to add.
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<K>
      Overrides:
      clear in class AbstractCollection<K>
    • size

      @Deprecated public int size()
      Deprecated.
      Please use Size64.size64() instead.
      Specified by:
      size in interface it.unimi.dsi.fastutil.BigList<K>
      Specified by:
      size in interface Collection<K>
      Specified by:
      size in interface it.unimi.dsi.fastutil.Size64
      Specified by:
      size in class AbstractCollection<K>
    • hashCode

      public int hashCode()
      Returns the hash code for this big list, which is identical to List.hashCode().
      Specified by:
      hashCode in interface Collection<K>
      Overrides:
      hashCode in class Object
      Returns:
      the hash code for this big list.
    • equals

      public boolean equals(Object o)
      Specified by:
      equals in interface Collection<K>
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(it.unimi.dsi.fastutil.BigList<? extends K> l)
      Compares this big list to another object. If the argument is a BigList, this method performs a lexicographical comparison; otherwise, it throws a ClassCastException.
      Specified by:
      compareTo in interface Comparable<K>
      Parameters:
      l - a big list.
      Returns:
      if the argument is a BigList, a negative integer, zero, or a positive integer as this list is lexicographically less than, equal to, or greater than the argument.
      Throws:
      ClassCastException - if the argument is not a big list.
    • push

      public void push(K o)
      Specified by:
      push in interface it.unimi.dsi.fastutil.Stack<K>
    • pop

      public K pop()
      Specified by:
      pop in interface it.unimi.dsi.fastutil.Stack<K>
    • top

      public K top()
      Specified by:
      top in interface it.unimi.dsi.fastutil.Stack<K>
    • peek

      public K peek(int i)
      Specified by:
      peek in interface it.unimi.dsi.fastutil.Stack<K>
    • toString

      public String toString()
      Overrides:
      toString in class it.unimi.dsi.fastutil.objects.AbstractObjectCollection<K>