Re: My idea for filtering an Enumeration or Iterator



> From: angrybaldguy@xxxxxxxxx
> Enumerations aren't available on the most common collection
> interfaces in java.util (List, Set, and Map).

That seems to be a rather moot point, considering that:
(1) Given any specific implementation of such an interface, it's rather
trivial to sub-class it to implement an enumeration for that class. So
then you declare your objects to be of that sub-class instead of the
API class.
(2) If you absolutely need a generic class that includes more than one
such sub-classed implementation class, with objects declared to be
ambiguously of the generic class instead of specifically of one of the
various implementation classes, and you absolutely need Enumeration to
be defined over that whole generic class instead of just over each
specific implementation, so that you can compile Enumeration code that
doesn't care which implementation class happens at runtime, you can
make a runtime interface as I demonstrated a few weeks ago.

Also, I prefer "weak enumerations" instead anyway. Single method
getNext or whatever which returns a default EOF value when it's reached
the end, otherwise returns the next item in the sequence, avoiding the
need to first test isNext and then somehow trust it when in fact it
sometimes lies and getNext then throws exception due to the bug.

> While I don't like the idea of "optional" members of interfaces
> (preferring subinterfaces), there is precedent for it in the Java APIs.

There's precedent for a whole lot of bad ideas. They should all be
deprecated rather than glorified as examples to emulate elsewhere.
.



Relevant Pages

  • Re: MprAdminInterfaceEnum
    ... > Trying to enumerate interfaces on RRAS. ... the enumeration cannot be continued. ... > public static extern int MprAdminInterfaceEnum( ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Question about Iteration and forEach
    ... I just defined a couple if interfaces; ... public static void DoTest() ... private MyListlist; ... If you want the ability to adjust your position within the enumeration, you can usually just use a normal "for" loop with an index to access individual items within the collection. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C# - Adding event delegate declarations to interfaces
    ... Do you mean that the declaration of the delegate type is lexically ... They are common in C++ for enumeration ... so nested types are generally only ... Since interfaces can only have public ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: CodeDom foreach
    ... IEnumerate is supported? ... If either of the generic interfaces are implemented, ... returned during enumeration using Type.GetGenericArgumentson the ... "Mubashir Khan" wrote: ...
    (microsoft.public.dotnet.framework)
  • values() of an Enumeration type that is a generic parameter?
    ... I'm trying to write a generic class using an enumeration as a type ... but I ran into trouble trying to iterate over the enumeration ... compiler had the same complaint. ...
    (comp.lang.java.programmer)