Package org.immutables.ordinal
Class OrdinalDomain<E extends OrdinalValue<E>>
java.lang.Object
org.immutables.ordinal.OrdinalDomain<E>
- Type Parameters:
E- type with ordinal values
- All Implemented Interfaces:
Iterable<E>
- Direct Known Subclasses:
InterningOrdinalDomain
@ThreadSafe
public abstract class OrdinalDomain<E extends OrdinalValue<E>>
extends Object
implements 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 Details
-
OrdinalDomain
public OrdinalDomain()
-
-
Method Details
-
get
Gets element from domain by corresponding ordinal value. It is guaranteed that returned element will haveOrdinalValue.ordinal()value equal to suppliedordinalparameter.- Parameters:
ordinal- ordinal value- Returns:
- the element by ordinal value
- Throws:
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
Iterator over all present inhabitants of ordinal domain.- Specified by:
iteratorin interfaceIterable<E extends OrdinalValue<E>>- Returns:
- snapshot iterator of elements in ordinal domain.
-