Re: Iterating through an enum???

From: Simon Trew (noneofyour_at_business.guv)
Date: 04/26/04


Date: Mon, 26 Apr 2004 17:31:44 +0100


"muchan" <usenet@usenet.usenet> wrote in message
news:Jzajc.1608$37.234736@news.siol.net...
> >
> > The names of the enums don't exist at runtime, and no checking is done
that
> > the value is one of the defined values. So you can just use the enum as
a
> > number. The above example, using enums as a set of flags, is quite
common.
> >
>
> Interesting. And in this case, what ++ operator should do with enum? 8)

I think that is rather the point. Schobi defined a ++ operator which skipped
through the *defined* values of the enum. I did the same, only in a more
generic manner using a set to hold the values. (It would be better as a
template class and I have in fact templatized a version but I doubt it is
worth posting here.) A specialized iterator onto an underlying vector would
probably be a better choice; I coded up a set implementation as it avoided
the use of an iterator (in the style of STL iterators, anyway) so the
control variable could be of the enum type itself.

S.



Relevant Pages

  • Re: Iterating through an enum???
    ... A specialized iterator onto an underlying vector would ... I stand that "enum" stands for "enumeration", ... I don't know if such use of a and e is allowd in enum declaration... ...
    (microsoft.public.vc.language)
  • Re: Am I the only one who would love these extentions? - Python 3.0 proposals (long)
    ... global namespace implicitly/separately -- if it must go there at all costs). ... The main advantage the above has over custom enum types is that it's ... this would also be my preference. ... > rather often an iterator) you'd be able to use itertools.count ...
    (comp.lang.python)