Package gw.lang.reflect.interval
Class IterableInterval<E extends Comparable<E>,S,U,ME extends IterableInterval<E,S,U,ME>>
java.lang.Object
gw.lang.reflect.interval.AbstractInterval<E,ME>
gw.lang.reflect.interval.IterableInterval<E,S,U,ME>
- All Implemented Interfaces:
IInterval<E,
,ME> IIterableInterval<E,
,S, U, ME> Iterable<E>
- Direct Known Subclasses:
DateInterval
,NumberInterval
,SequenceableInterval
public abstract class IterableInterval<E extends Comparable<E>,S,U,ME extends IterableInterval<E,S,U,ME>>
extends AbstractInterval<E,ME>
implements IIterableInterval<E,S,U,ME>
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionIterableInterval
(E left, E right, S step) IterableInterval
(E left, E right, S step, U unit, boolean bLeftClosed, boolean bRightClosed, boolean bReverse) -
Method Summary
Methods inherited from class gw.lang.reflect.interval.AbstractInterval
contains, contains, getLeftEndpoint, getRightEndpoint, isLeftClosed, isReverse, isRightClosed
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface gw.lang.reflect.interval.IInterval
contains, contains, getLeftEndpoint, getRightEndpoint, isLeftClosed, isReverse, isRightClosed
Methods inherited from interface gw.lang.reflect.interval.IIterableInterval
getFromLeft, getFromRight, iterateFromLeft, iterateFromRight
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
_step
-
_unit
-
-
Constructor Details
-
IterableInterval
-
IterableInterval
-
-
Method Details
-
iterator
- Specified by:
iterator
in interfaceIIterableInterval<E extends Comparable<E>,
S, U, ME extends IterableInterval<E, S, U, ME>> - Specified by:
iterator
in interfaceIterable<E extends Comparable<E>>
- Returns:
- An iterator that visits the elements in this interval in order, from left to right. Returns null if this interval does not support iteration.
- See Also:
-
getStep
- Specified by:
getStep
in interfaceIIterableInterval<E extends Comparable<E>,
S, U, ME extends IterableInterval<E, S, U, ME>> - Returns:
- The step (or increment) by which this interval visits elements in its set. Returns null
if this interval cannot iterate its elements.
For instance, if the interval is a set of decimal values, say [1..10], the step might be a decimal increment, say 0.25. Similarly, if the interval is simply a set of integers the step might also be an integer value, typically 1. Considering a date interval, say [4/5/10..5/20/10], the step could be expressed in terms of a unit of time e.g., 10 seconds, 1 minute, 2 weeks, etc.
Note if non-null, the step is a positive (or absolute) increment. To iterate the interval in reverse order use iterateFromRight().
-
step
- Specified by:
step
in interfaceIIterableInterval<E extends Comparable<E>,
S, U, ME extends IterableInterval<E, S, U, ME>>
-
getUnit
- Specified by:
getUnit
in interfaceIIterableInterval<E extends Comparable<E>,
S, U, ME extends IterableInterval<E, S, U, ME>>
-
unit
- Specified by:
unit
in interfaceIIterableInterval<E extends Comparable<E>,
S, U, ME extends IterableInterval<E, S, U, ME>>
-
equals
- Overrides:
equals
in classAbstractInterval<E extends Comparable<E>,
ME extends IterableInterval<E, S, U, ME>>
-
hashCode
public int hashCode()- Overrides:
hashCode
in classAbstractInterval<E extends Comparable<E>,
ME extends IterableInterval<E, S, U, ME>>
-
toString
- Overrides:
toString
in classAbstractInterval<E extends Comparable<E>,
ME extends IterableInterval<E, S, U, ME>>
-