Topic: Reuse within STL
Author: Andrei Alexandrescu <andrewalex@hotmail.com>
Date: 1999/06/07 Raw View
There are some potential reuse opportunities inside STL. I haven't seen
them exploited and I wonder whether there is a reason for this.
Two that come to mind are using vector for holding the map of pointers
inside deque, and using set<list<Element> > and map<list<Element> > for
implementing multiset, respectively multimap.
Would this be valid in an STL implementation?
Andrei
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Valentin Bonnard <Bonnard.V@wanadoo.fr>
Date: 1999/06/08 Raw View
Andrei Alexandrescu wrote:
> There are some potential reuse opportunities inside STL. I haven't seen
> them exploited and I wonder whether there is a reason for this.
>
> Two that come to mind are using vector for holding the map of pointers
> inside deque, and using set<list<Element> > and map<list<Element> > for
> implementing multiset, respectively multimap.
>
> Would this be valid in an STL implementation?
HP STL and implementations based on it do it another
way: set, map, multiset and multimap are warpers for
rb_tree.
And yes, it's probably a way to implement multiset.
Of course you would not write set<list<Element> >, nor
map<list<Element> > (which is a syntax error).
But writing multiset<T> in term of set<list<Element>, ...>
is really a lot of work.
I would rather implement set in term of multiset !
--
Valentin Bonnard
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]