Class S2ShapeIndex.ShardedList<T>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<T>, java.util.Collection<T>, java.util.List<T>, java.util.RandomAccess
    Enclosing class:
    S2ShapeIndex

    private static final class S2ShapeIndex.ShardedList<T>
    extends java.util.AbstractList<T>
    implements java.util.RandomAccess, java.io.Serializable
    A more complex append-only RandomAccess List that allocates space in shards of 256 elements each, avoiding reallocation as the list grows, and avoiding single allocations larger than 2KB. This is about 1% faster than SimpleList with reserveEdges in use, but when the heap is anywhere near full, this approach is dramatically faster than any technique requiring a large contiguous allocation, since it will probably require a GC to supply one.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Object[][] elements  
      private static long serialVersionUID  
      private int size  
      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      ShardedList​(int maxItems)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(T item)  
      T get​(int index)  
      T set​(int index, T value)  
      int size()  
      • Methods inherited from class java.util.AbstractList

        add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, subList
      • Methods inherited from class java.util.AbstractCollection

        addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
    • Field Detail

      • elements

        private java.lang.Object[][] elements
      • size

        private int size
    • Constructor Detail

      • ShardedList

        public ShardedList​(int maxItems)
    • Method Detail

      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<T>
        Specified by:
        size in interface java.util.List<T>
        Specified by:
        size in class java.util.AbstractCollection<T>
      • add

        public boolean add​(T item)
        Specified by:
        add in interface java.util.Collection<T>
        Specified by:
        add in interface java.util.List<T>
        Overrides:
        add in class java.util.AbstractList<T>
      • get

        public T get​(int index)
        Specified by:
        get in interface java.util.List<T>
        Specified by:
        get in class java.util.AbstractList<T>
      • set

        public T set​(int index,
                     T value)
        Specified by:
        set in interface java.util.List<T>
        Overrides:
        set in class java.util.AbstractList<T>