You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stephen Colebourne <sc...@btopenworld.com> on 2003/11/08 21:11:55 UTC

[collections] Resetable iterators

The ResetableIterator interface is causing hassles as I try to tidy the code
up ready for release. Out current design requires that there is a
ResetableIterator interface for each iterator type. And there are now 5
iterator types (normal, List, Map, Ordered, OrderedMap).

I would like to remove the Resetable*Iterator interfaces and replace with a
Resetable interface. The main impact is that an instanceof/cast check will
be required to check for resetability.

Iterator it = list.iterator();
it.next();
if (it instanceof Resetable) {
  ((Resetable) it).reset();
}

But this is not any different to how it would be anyway, as users would have
had to check for ResetableIterator.

Any objections to me making this change?

Stephen


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


Re: [collections] Resetable iterators

Posted by Stephen Colebourne <sc...@btopenworld.com>.
From: "Lee Crawford" <cr...@weaselworks.com>
> On the one hand, there's nothing Iterator-specific about a reset()
> method which supports a Resetable interface. However, there may be many
> times where a single reference is appropriate for something that is both
> Iterator and Resetable. What about providing both:
>
>   public interface ResetableIterator
>     extends Iterator, Resetable
>   {
>   }
This is what we have now, and I'm arguing against.....

> I know this can lead to a combinatoric explosion on interfaces if
> carried to the extreme but I think you can make a reasonable case here.
...because of the explosion of interfaces. We now have 5 basic iterator
types, doing resettable this way leads to 10 interfaces. It all works, but
is is desirable?

Stephen

> The big issue, though, is that the proper spelling is Resettable. :)
>
>   http://www.m-w.com/cgi-bin/dictionary?va=resettable
>
> --lee
>
> -----Original Message-----
> From: Stephen Colebourne [mailto:scolebourne@btopenworld.com]
> Sent: Saturday, November 08, 2003 3:12 PM
> To: Jakarta Commons Developers List
> Subject: [collections] Resetable iterators
>
>
> The ResetableIterator interface is causing hassles as I try to tidy the
> code up ready for release. Out current design requires that there is a
> ResetableIterator interface for each iterator type. And there are now 5
> iterator types (normal, List, Map, Ordered, OrderedMap).
>
> I would like to remove the Resetable*Iterator interfaces and replace
> with a Resetable interface. The main impact is that an instanceof/cast
> check will be required to check for resetability.
>
> Iterator it = list.iterator();
> it.next();
> if (it instanceof Resetable) {
>   ((Resetable) it).reset();
> }
>
> But this is not any different to how it would be anyway, as users would
> have had to check for ResetableIterator.
>
> Any objections to me making this change?
>
> Stephen
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


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


RE: [collections] Resetable iterators

Posted by Lee Crawford <cr...@weaselworks.com>.
A few things. 

On the one hand, there's nothing Iterator-specific about a reset()
method which supports a Resetable interface. However, there may be many
times where a single reference is appropriate for something that is both
Iterator and Resetable. What about providing both: 

  public interface ResetableIterator
    extends Iterator, Resetable
  {
  }

I know this can lead to a combinatoric explosion on interfaces if
carried to the extreme but I think you can make a reasonable case here. 

The big issue, though, is that the proper spelling is Resettable. :)

  http://www.m-w.com/cgi-bin/dictionary?va=resettable

--lee

-----Original Message-----
From: Stephen Colebourne [mailto:scolebourne@btopenworld.com] 
Sent: Saturday, November 08, 2003 3:12 PM
To: Jakarta Commons Developers List
Subject: [collections] Resetable iterators


The ResetableIterator interface is causing hassles as I try to tidy the
code up ready for release. Out current design requires that there is a
ResetableIterator interface for each iterator type. And there are now 5
iterator types (normal, List, Map, Ordered, OrderedMap).

I would like to remove the Resetable*Iterator interfaces and replace
with a Resetable interface. The main impact is that an instanceof/cast
check will be required to check for resetability.

Iterator it = list.iterator();
it.next();
if (it instanceof Resetable) {
  ((Resetable) it).reset();
}

But this is not any different to how it would be anyway, as users would
have had to check for ResetableIterator.

Any objections to me making this change?

Stephen


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



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