After looking at the Lang 3 Range API, I realized an Iterator factory should be kept external to the Range class:

Range<Date> dateRange = Range.between(thisMonth, nextMonth);
Iterator<Date> dayIterator = RangeIteratorFactory.getInstance(dateRange, Calendar.DATE);

Range<Integer> intRange = Range.between(firstInt, lastInt);
Iterator<Integer> intSeqIterator = RangeIteratorFactory.getInstance(intRange, 3);

-Adrian

On 1/24/2012 9:10 PM, Bruno P. Kinoshita wrote:

Sounds great for me too :)


Cheers,


Bruno P. Kinoshita
http://kinoshita.eti.br
http://tupilabs.com


----- Mensagem original -----
De: Adrian Crum<adrian.c...@sandglass-software.com>
Para: Commons Developers List<dev@commons.apache.org>
Cc:
Enviadas: Terça-feira, 24 de Janeiro de 2012 18:30
Assunto: Re: [functor] CharacterRange, FloatRange, DoubleRange and open/closed 
intervals

On 1/24/2012 8:15 PM, Matt Benson wrote:
   Thanks for your interest, Adrian!  Comments inline:

   On Tue, Jan 24, 2012 at 1:58 PM, Adrian Crum
   <adrian.c...@sandglass-software.com>   wrote:
   On 1/24/2012 6:58 PM, Matt Benson wrote:
   IMO the difference between [lang]'s and [functor]'s range
concepts is that
   those in [lang] are intended to be able to say whether a given
value is in
   the Range, but, with the exception of CharRange (this class is not
even
   public), they make no provision for iterating over members of the
range. I
   would therefore design a [functor]-targeted Range builder API to
allow the
   user to specify how next values are obtained. Range may not even be
the best
   word to describe the behavior we are trying to model here, so
let's be open
   to reinterpretation as we proceed.
   From my perspective, Range + Step = Sequence.
   I'll buy that if noone else objects.  :)

   A Range iterator would be
   useful for implementing mathematical sets.
   e.g. integer range a..b step 3 yields the sequence of integers n
   greater than or equal to a and less than or equal to b where (n - a) %
   3 == 0 ?  Is this useful?

   Matt
It would be useful for a mathematician. Another possibility is a Range
of Dates, with a step of one hour, or one day or...

The Range class could accept an Iterator factory so various steps can be
implemented in client code.

-Adrian


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to