Class OrdinalDomain<E extends OrdinalValue<E>>

  • Type Parameters:
    E - type with ordinal values
    All Implemented Interfaces:
    java.lang.Iterable<E>
    Direct Known Subclasses:
    InterningOrdinalDomain

    @ThreadSafe
    public abstract class OrdinalDomain<E extends OrdinalValue<E>>
    extends java.lang.Object
    implements java.lang.Iterable<E>
    Ordinal domain represent (potentially growing) set of objects of some kind (among E) which has distinct and contiguous range of ordinal values. Equal objects expected to have same ordinal value. Usually, ordinal values will be interned in OrdinalDomain, but it is not strictly required.

    Implementations must be thread safe.

    • Constructor Summary

      Constructors 
      Constructor Description
      OrdinalDomain()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract E get​(int ordinal)
      Gets element from domain by corresponding ordinal value.
      java.util.Iterator<E> iterator()
      Iterator over all present inhabitants of ordinal domain.
      abstract int length()
      Current length of ordinal domain.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • OrdinalDomain

        public OrdinalDomain()
    • Method Detail

      • get

        public abstract E get​(int ordinal)
        Gets element from domain by corresponding ordinal value. It is guaranteed that returned element will have OrdinalValue.ordinal() value equal to supplied ordinal parameter.
        Parameters:
        ordinal - ordinal value
        Returns:
        the element by ordinal value
        Throws:
        java.lang.IndexOutOfBoundsException - if no such element exists
      • length

        public abstract int length()
        Current length of ordinal domain. Be caution that length is not required to be stable and could grow, as such it could be used as a hint.
        Returns:
        the domain length: current max ordinal value plus one
      • iterator

        public java.util.Iterator<E> iterator()
        Iterator over all present inhabitants of ordinal domain.
        Specified by:
        iterator in interface java.lang.Iterable<E extends OrdinalValue<E>>
        Returns:
        snapshot iterator of elements in ordinal domain.