Class AbstractReferenceBigList<K>

java.lang.Object
java.util.AbstractCollection<K>
it.unimi.dsi.fastutil.objects.AbstractReferenceCollection<K>
it.unimi.dsi.fastutil.objects.AbstractReferenceBigList<K>
All Implemented Interfaces:
it.unimi.dsi.fastutil.BigList<K>, it.unimi.dsi.fastutil.objects.ObjectIterable<K>, ReferenceBigList<K>, ReferenceCollection<K>, it.unimi.dsi.fastutil.Size64, it.unimi.dsi.fastutil.Stack<K>, java.lang.Iterable<K>, java.util.Collection<K>
Direct Known Subclasses:
AbstractReferenceBigList.ReferenceSubList, ReferenceBigArrayBigList, ReferenceBigLists.ListBigList, ReferenceBigLists.Singleton

public abstract class AbstractReferenceBigList<K>
extends AbstractReferenceCollection<K>
implements ReferenceBigList<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.

  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  AbstractReferenceBigList.ReferenceRandomAccessSubList<K>  
    static class  AbstractReferenceBigList.ReferenceSubList<K>
    A class implementing a sublist view.
  • Method Summary

    Modifier and Type Method Description
    void add​(long index, K k)
    boolean add​(K k)
    boolean addAll​(long index, java.util.Collection<? extends K> c)
    Adds all of the elements in the specified collection to this list (optional operation).
    boolean addAll​(java.util.Collection<? extends K> c)
    void addElements​(long index, K[][] a)
    Add (hopefully quickly) elements to this type-specific big list.
    void addElements​(long index, K[][] a, long offset, long length)
    Add (hopefully quickly) elements to this type-specific big list.
    void clear()
    boolean contains​(java.lang.Object k)
    Returns true if this list contains the specified element.
    boolean equals​(java.lang.Object o)  
    void forEach​(java.util.function.Consumer<? super K> action)
    void getElements​(long from, java.lang.Object[][] a, long offset, long length)
    Copies (hopefully quickly) elements of this type-specific big list into the given big array.
    int hashCode()
    Returns the hash code for this big list, which is identical to List.hashCode().
    long indexOf​(java.lang.Object k)  
    it.unimi.dsi.fastutil.objects.ObjectBigListIterator<K> iterator()
    Returns a type-specific iterator on the elements of this collection.
    long lastIndexOf​(java.lang.Object k)  
    it.unimi.dsi.fastutil.objects.ObjectBigListIterator<K> listIterator()
    Returns a type-specific big-list iterator on this type-specific big list.
    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.
    K peek​(int i)  
    K pop()  
    void push​(K o)  
    K remove​(long i)
    void removeElements​(long from, long to)
    Removes (hopefully quickly) elements of this type-specific big list.
    K set​(long index, K k)
    void setElements​(long index, K[][] a, long offset, long length)
    Set (hopefully quickly) elements to match the array given.
    int size()
    Deprecated.
    Please use Size64.size64() instead.
    void size​(long size)  
    ReferenceBigList<K> subList​(long from, long to)
    Returns a type-specific view of the portion of this type-specific big list from the index from, inclusive, to the index to, exclusive.
    K top()  
    java.lang.String toString()  

    Methods inherited from class java.util.AbstractCollection

    containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface it.unimi.dsi.fastutil.BigList

    get

    Methods inherited from interface java.util.Collection

    containsAll, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, stream, toArray, toArray, toArray

    Methods inherited from interface it.unimi.dsi.fastutil.objects.ReferenceBigList

    addAll, addAll, addAll, addAll, setElements, setElements, spliterator

    Methods inherited from interface it.unimi.dsi.fastutil.Size64

    size64

    Methods inherited from interface it.unimi.dsi.fastutil.Stack

    isEmpty
  • Method Details

    • add

      public void add​(long index, K k)
      Specified by:
      add in interface it.unimi.dsi.fastutil.BigList<K>
      Implementation Specification:
      This implementation always throws an UnsupportedOperationException.
    • add

      public boolean add​(K k)
      Specified by:
      add in interface java.util.Collection<K>
      Overrides:
      add in class java.util.AbstractCollection<K>
      Implementation Specification:
      This implementation delegates to the type-specific version of BigList.add(long, Object).
    • remove

      public K remove​(long i)
      Specified by:
      remove in interface it.unimi.dsi.fastutil.BigList<K>
      Implementation Specification:
      This implementation always throws an UnsupportedOperationException.
    • set

      public K set​(long index, K k)
      Specified by:
      set in interface it.unimi.dsi.fastutil.BigList<K>
      Implementation Specification:
      This implementation always throws an UnsupportedOperationException.
    • addAll

      public boolean addAll​(long index, java.util.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​(java.util.Collection<? extends K> c)
      Specified by:
      addAll in interface java.util.Collection<K>
      Overrides:
      addAll in class java.util.AbstractCollection<K>
      Implementation Specification:
      This implementation delegates to the type-specific version of BigList.addAll(long, Collection).
    • iterator

      public it.unimi.dsi.fastutil.objects.ObjectBigListIterator<K> iterator()
      Returns a type-specific iterator on the elements of this collection.
      Specified by:
      iterator in interface java.util.Collection<K>
      Specified by:
      iterator in interface java.lang.Iterable<K>
      Specified by:
      iterator in interface it.unimi.dsi.fastutil.objects.ObjectIterable<K>
      Specified by:
      iterator in interface ReferenceBigList<K>
      Specified by:
      iterator in interface ReferenceCollection<K>
      Specified by:
      iterator in class AbstractReferenceCollection<K>
      Returns:
      a type-specific iterator on the elements of this collection.
      See Also:
      Collection.iterator()
      Implementation Specification:
      This implementation delegates to listIterator().
    • 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 ReferenceBigList<K>
      See Also:
      BigList.listIterator()
      Implementation Specification:
      This implementation delegates to listIterator(0).
    • 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 ReferenceBigList<K>
      See Also:
      BigList.listIterator(long)
      Implementation Specification:
      This implementation is based on the random-access methods.
    • contains

      public boolean contains​(java.lang.Object k)
      Returns true if this list contains the specified element.
      Specified by:
      contains in interface java.util.Collection<K>
      Overrides:
      contains in class java.util.AbstractCollection<K>
      See Also:
      Collection.contains(Object)
      Implementation Specification:
      This implementation delegates to indexOf().
    • indexOf

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

      public long lastIndexOf​(java.lang.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 ReferenceBigList<K> subList​(long from, long to)
      Description copied from interface: ReferenceBigList
      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 ReferenceBigList<K>
      See Also:
      BigList.subList(long,long)
    • forEach

      public void forEach​(java.util.function.Consumer<? super K> action)
      Specified by:
      forEach in interface java.lang.Iterable<K>
      Implementation Specification:
      If this list is RandomAccess, will iterate using a for loop and the type-specific List.get(int) method. Otherwise it will fallback to using the iterator based loop implementation from the superinterface.
    • 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 ReferenceBigList<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 ReferenceBigList<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 ReferenceBigList<K>
      Parameters:
      index - the index at which to add elements.
      a - the big array containing the elements.
      Implementation Specification:
      This implementation delegates to the analogous method for big-array fragments.
    • getElements

      public void getElements​(long from, java.lang.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 ReferenceBigList<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: ReferenceBigList
      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 ReferenceBigList<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 java.util.Collection<K>
      Overrides:
      clear in class java.util.AbstractCollection<K>
      Implementation Specification:
      This implementation delegates to removeElements(long, long).
    • 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 java.util.Collection<K>
      Specified by:
      size in interface it.unimi.dsi.fastutil.Size64
      Specified by:
      size in class java.util.AbstractCollection<K>
      Implementation Specification:
      This implementation delegates to Size64.size64().
    • hashCode

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

      public boolean equals​(java.lang.Object o)
      Specified by:
      equals in interface java.util.Collection<K>
      Overrides:
      equals in class java.lang.Object
    • 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 java.lang.String toString()
      Overrides:
      toString in class AbstractReferenceCollection<K>