Implementation of Range
and allows easy iteration between Time
types.
Provides all power of Iterable
features and complements with:
Period
Duration
TimeRange
typesTimeRange
typesUnitOfTime
casesRange
no subtypes hierarchy
Initializer |
TimeRange(Time from, Time to, UnitOfTime step = ...) Parameters:
|
Attributes | |
duration | Source Codeshared actual Duration duration Returns the Duration between from and to fields. Example: Given: today().to(tomorrow).duration then duration is 86400000 milliseconds. Given: tomorrow().to(today).duration then duration is -86400000 milliseconds. Refines Range.duration |
from | Source Codeshared actual Time from The first Element returned by the iterator, if any.
This should always produce the same value as
Example: today().to(tomorrow) -> in this case today() is the caller/creator of the range. Refines Range.from |
hash | Source Codeshared actual Integer hash This implementation respect the constraint that if |
period | Source Codeshared actual Period period Returns the Period between from and to fields. Example: Given: today().to(tomorrow).duration then duration is 1 day. Given: tomorrow().to(today).duration then duration is -1 day. Refines Range.period |
step | Source Codeshared actual UnitOfTime step Customized way to iterate over each element, it does not interfer in from and to fields, but it does not guarantee that to will be included in iterator. Refines Range.step |
to | Source Codeshared actual Time to The limit of the Range where. Example: Given: today().to(tomorrow) then tomorrow is the to element. Given: tomorrow.to(today()) then today() is the to element. Refines Range.to |
Inherited Attributes |
Attributes inherited from: Object |
Attributes inherited from: Iterable<Element,Absent> |
Attributes inherited from: Range<Element,StepBy> |
Methods | |
equals | Source Codeshared actual Boolean equals(Object other) Returns true if both: this and other are same type and have equal fields from and to. |
gap | Source Codeshared actual TimeRange|[] gap(Range<Time,UnitOfTime> other) Returns empty or a new Range:
Given: [A..B] gap [C..D] When: AB < CD [1..2] gap [5..6] = (2,5) [1..2] gap [6..5] = (2,5) [2..1] gap [5..6] = (2,5) [2..1] gap [6..5] = (2,5) Given: [A..B] gap [C..D] When: AB > CD [5..6] gap [1..2] = (2,5) [5..6] gap [2..1] = (2,5) [6..5] gap [1..2] = (2,5) [6..5] gap [2..1] = (2,5) Refines Range.gap |
iterator | Source Codeshared actual Iterator<Time> iterator() An iterator for the elements belonging to this container. where each jump is based on actual step of this Range. Refines Iterable.iterator |
overlap | Source Codeshared actual TimeRange|[] overlap(Range<Time,UnitOfTime> other) Returns empty or a new Range:
Given: [A..B] overlap [C..D] When: AB < CD [1..6] overlap [3..9] = [3,6] [1..6] overlap [9..3] = [3,6] [6..1] overlap [3..9] = [3,6] [6..1] overlap [9..3] = [3,6] Given: [A..B] overlap [C..D] When: AB > CD [3..9] overlap [1..6] = [3,6] [3..9] overlap [6..1] = [3,6] [9..3] overlap [1..6] = [3,6] [9..3] overlap [6..1] = [3,6] Refines Range.overlap |
stepBy | Source Codeshared actual TimeRange stepBy(UnitOfTime step) Define how this Range will get next or previous element while iterating. Refines Range.stepBy |
Inherited Methods |
Methods inherited from: Object |
Methods inherited from: Category<Element> |
Methods inherited from: Iterable<Element,Absent> any() , by() , chain() , collect() , contains() , count() , defaultNullElements() , each() , every() , filter() , find() , findLast() , flatMap() , fold() , follow() , frequencies() , getFromFirst() , group() , indexes() , interpose() , iterator() , locate() , locateLast() , locations() , longerThan() , map() , max() , narrow() , partition() , product() , reduce() , repeat() , scan() , select() , sequence() , shorterThan() , skip() , skipWhile() , sort() , spread() , summarize() , tabulate() , take() , takeWhile() |
Methods inherited from: Range<Element,StepBy> |