Topic: hat container class


Author: AngleWyrm <no_spam_anglewyrm@hotmail.com>
Date: Fri, 25 Jun 2004 15:44:51 +0000 (UTC)
Raw View
"Florian Cauvin" <fcauvin@yahoo.fr> wrote in message
news:b9afcbf0.0406201233.473327a2@posting.google.com...
 >
 > 2- one thing you could do is to replace the current pull with
 >         void hat::pull(iterator)
 > pull hasn't exactly the same sense as before and actually it looks so
 > similar to
 > the erase method of a sequences and associative containers. Probably
 > then the best choice is to forget about the name pull and implement:
 >         iterator hat::erase(iterator)
 >
 > => The solution to the previous problem now is:
 >         hat::iterator iter = hat.peek();
 >         if (condition(*iter))
 >             hat.erase(iter);
 > There's no copy anymore and the erase method is also probably much
 > simpler than your original pull method.

Good usage points; Version 1.13 is now up, with erase(iter) implemented for
situations which require conditional delete. It may be that the proper way is to
peek() and then erase(). This two-step process is similar to DOS's move command,
which first copies, then deletes.

The pull() function will be getting an update next version.The explicit
expression of sampling with replacement (rolling a dice) vs sampling without
replacement (drawing cards from a deck) becomes implicit in the process of using
peek()/erase(), and thus the inclusion in the interface.

--
AngleWyrm
The C++ hat random selection container:
http://home.comcast.net/~anglewyrm/hat.html


      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]