Topic: remove/erase not working in one case
Author: micha@aishdas.org
Date: 1997/10/07 Raw View
On 01 Oct 97 17:13:21 GMT, Peter Mancini <peter_mancini@Sp-am-blo-ck.onesource.com> wrote:
: If I use remove(first, last, green) and then do erase( ) I end up with the
: following:
: red
: orange
: yellow
: blue
: indigo
: violet
: violet
Are you using a new value of vector<color>::end()? My guess is that the second
reference to violet is beyond the new end(), and so they just didn't bother
removing it.
-mi
--
Micha Berger (973) 916-0287 Help free Ron Arad, held by Syria 3931 days!
micha@aishdas.org (16-Oct-86 - 6-Oct-97)
For a mitzvah is a candle, and the Torah its light.
http://aishdas.org -- Orthodox Judaism: Torah, Avodah, Chessed
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: "Peter Mancini" <peter_mancini@Sp-am-blo-ck.onesource.com>
Date: 1997/10/01 Raw View
I have been using the STL for about 2 months now and have really enjoyed
it. But recently I came across an issue when using a vector container.
Imagine a vector container with several objects, two of which are
identical. Let's use color names to represent the objects:
red
orange
yellow
green
green
blue
indigo
violet
If I use remove(first, last, green) and then do erase( ) I end up with the
following:
red
orange
yellow
blue
indigo
violet
violet
If the two green objects had been at the end, then everything would work
out as expected. If I try to remove and erase non-doubles those also work
out fine. It is this one case that is a problem.
Can someone give me a hint so I can figure out what I am doing wrong?
Aren't duplicates allowed in vectors and other types of containers?
--Pete Mancini
actual address below
peter_mancini @ onesource.com
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]