Class FlatLists.Flat3List<T>

  • Type Parameters:
    T - Element type
    All Implemented Interfaces:
    java.lang.Comparable<java.util.List>, java.lang.Iterable<T>, java.util.Collection<T>, java.util.List<T>, java.util.RandomAccess, FlatLists.ComparableList<T>
    Enclosing class:

    protected static class FlatLists.Flat3List<T>
    extends FlatLists.AbstractFlatList<T>
    implements FlatLists.ComparableList<T>
    List that stores its three elements in the three members of the class. Unlike ArrayList or Arrays.asList(Object[]) there is no array, only one piece of memory allocated, therefore is very compact and cache and CPU efficient.

    The list is read-only, cannot be modified or re-sized. The elements may be null.

    The list is created via FlatLists.of(java.util.List).

    • Field Detail

      • t0

        private final T t0
      • t1

        private final T t1
      • t2

        private final T t2
    • Constructor Detail

      • Flat3List

        Flat3List​(T t0,
                  T t1,
                  T t2)
    • Method Detail

      • toString

        public java.lang.String toString()
        toString in class java.lang.Object
      • get

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

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

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.util.Collection<T>
        Specified by:
        iterator in interface java.lang.Iterable<T>
        Specified by:
        iterator in interface java.util.List<T>
        iterator in class AbstractImmutableList<T>
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Collection<T>
        Specified by:
        equals in interface java.util.List<T>
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<T>
        Specified by:
        hashCode in interface java.util.List<T>
        hashCode in class java.lang.Object
      • indexOf

        public int indexOf​(java.lang.Object o)
        Specified by:
        indexOf in interface java.util.List<T>
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object o)
        Specified by:
        lastIndexOf in interface java.util.List<T>
      • toArray

        public <T2> T2[] toArray​(T2[] a)
        Specified by:
        toArray in interface java.util.Collection<T>
        Specified by:
        toArray in interface java.util.List<T>
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<T>
        Specified by:
        toArray in interface java.util.List<T>
      • compareTo

        public int compareTo​(java.util.List o)
        Specified by:
        compareTo in interface java.lang.Comparable<T>