Class Ord<E>

  • Type Parameters:
    E - Element type
    All Implemented Interfaces:
    java.util.Map.Entry<java.lang.Integer,​E>

    public class Ord<E>
    extends java.lang.Object
    implements java.util.Map.Entry<java.lang.Integer,​E>
    Pair of an element and an ordinal.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  Ord.OrdArrayList<E>
      List of Ord backed by an array of elements.
      private static class  Ord.OrdList<E>
      List of Ord backed by a list of elements.
      private static class  Ord.OrdRandomAccessList<E>
      List of Ord backed by a random-access list of elements.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      E e  
      int i  
    • Constructor Summary

      Constructors 
      Constructor Description
      Ord​(int i, E e)
      Creates an Ord.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Integer getKey()  
      E getValue()  
      static <E> Ord<E> of​(int n, E e)
      Creates an Ord.
      static <E> java.lang.Iterable<Ord<E>> reverse​(E... elements)
      Iterates over an array in reverse order.
      static <E> java.lang.Iterable<Ord<E>> reverse​(java.lang.Iterable<? extends E> elements)
      Iterates over a list in reverse order.
      E setValue​(E value)  
      static <E> java.util.List<Ord<E>> zip​(E[] elements)
      Returns a numbered list based on an array.
      static <E> java.lang.Iterable<Ord<E>> zip​(java.lang.Iterable<? extends E> iterable)
      Creates an iterable of Ords over an iterable.
      static <E> java.util.Iterator<Ord<E>> zip​(java.util.Iterator<? extends E> iterator)
      Creates an iterator of Ords over an iterator.
      static <E> java.util.List<Ord<E>> zip​(java.util.List<? extends E> elements)
      Returns a numbered list.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Map.Entry

        equals, hashCode
    • Field Detail

      • i

        public final int i
      • e

        public final E e
    • Constructor Detail

      • Ord

        public Ord​(int i,
                   E e)
        Creates an Ord.
    • Method Detail

      • of

        public static <E> Ord<E> of​(int n,
                                    E e)
        Creates an Ord.
      • zip

        public static <E> java.lang.Iterable<Ord<E>> zip​(java.lang.Iterable<? extends E> iterable)
        Creates an iterable of Ords over an iterable.
      • zip

        public static <E> java.util.Iterator<Ord<E>> zip​(java.util.Iterator<? extends E> iterator)
        Creates an iterator of Ords over an iterator.
      • zip

        public static <E> java.util.List<Ord<E>> zip​(E[] elements)
        Returns a numbered list based on an array.
      • zip

        public static <E> java.util.List<Ord<E>> zip​(java.util.List<? extends E> elements)
        Returns a numbered list.
      • reverse

        public static <E> java.lang.Iterable<Ord<E>> reverse​(E... elements)
        Iterates over an array in reverse order.

        Given the array ["a", "b", "c"], returns (2, "c") then (1, "b") then (0, "a").

      • reverse

        public static <E> java.lang.Iterable<Ord<E>> reverse​(java.lang.Iterable<? extends E> elements)
        Iterates over a list in reverse order.

        Given the list ["a", "b", "c"], returns (2, "c") then (1, "b") then (0, "a").

      • getKey

        public java.lang.Integer getKey()
        Specified by:
        getKey in interface java.util.Map.Entry<java.lang.Integer,​E>
      • getValue

        public E getValue()
        Specified by:
        getValue in interface java.util.Map.Entry<java.lang.Integer,​E>
      • setValue

        public E setValue​(E value)
        Specified by:
        setValue in interface java.util.Map.Entry<java.lang.Integer,​E>