C++ Container equivalents
Bill Baxter
dnewsgroup at billbaxter.com
Tue Aug 14 22:42:22 PDT 2007
Bruce Adams wrote:
> Hi,
> I'm sure these questions come up twice a day and yet there isn't a definitive page on the digital mars website or wiki4d that I can find.
> (I'd add it myself if I knew the answers and I could figure out how to use wiki4d).
> What are the best D equivalents to the STL containers?
> bearing in mind the algorithmic complexity of various kinds of
> operation. I haven't actually seen a statement of what complexity
> operations on D arrays is.
Yes the situation is pretty sad. D - the language with built-in arrays
and hashes, and meta-programming facilities that make little girls cry,
but forget it if you're looking for a simple Set type.
The closest thing to "official" container classes is what's in Tango.
Nothing is going to be added to Phobos as far as I know. Walter just
doesn't have time for it. But Walter is also unwilling to loosen the
reigns, so basically Phobos is going nowhere any time soon.
Hopefully discussions at the D conference will help point the way to a
solution to the library predicament D's in.
Anyway, here are some set-like things I have sitting around:
Arclib has a RedBlackTree class, and I made some changes to that for my
own purposes. It implements set and multiset.
(http://www.billbaxter.com/projects/d/redblacktree.d
http://www.billbaxter.com/projects/d/sets.d)
I also have a class wrapper around an associative array that adds things
to make it more set-like.
(http://www.billbaxter.com/projects/d/aa_set.d)
--bb
More information about the Digitalmars-d-learn
mailing list