Port a benchmark to D?
Jonathan M Davis
jmdavisProg at gmx.com
Fri Jun 3 14:37:39 PDT 2011
On 2011-06-03 14:30, Timon Gehr wrote:
> Jonathan M Davis wrote:
> > On 2011-06-03 14:08, Timon Gehr wrote:
> > > Andrei Alexandrescu wrote:
> > > > I noticed that the C++ code uses std::list without there being any
> > > > need for a linked list structure. See for example the data structure
> > > > used in FindSet. It's a list, but it's just appended too and then
> > > > used for one iteration.
> > > >
> > > > Andrei
> > >
> > > Yes, but the list in FindSet is unnecessary anyways. If I start
> > > changing the original implementation, the first thing I will do is to
> > > remove that.
> > >
> > > First however, I will port the code as closely as possible. Is there
> > > any associative version of RedBlackTree (I realize it could be made
> > > associative quite easily), or should I just use built-in hash maps?
> >
> > You give RedBlackTree a different predicate if you want to treat it as a
> > map. It defaults to "a < b" with allowDuplicates as false, which makes
> > it a multiset. But If you adjust its template parameters, you can make
> > it a set, map, multimap, or any other type of collection which uses a
> > red-black tree > as its data structure.
> >
> > - Jonathan M Davis
>
> Yes, thats what I had in mind, but I thought it is strange that there is no
> boilerplate map in std.container.
std.container provides data structures. It's up to you to decide how to use
the data structures. It does not attempt to create a wrapper or anything of
the sort to give you particular uses for a data structure (such as using
RedBlackTree as a map). Whether it should do that sort of thing is up for
debate, but its focus is on data structures not on "collections" which are
organized by how they're used.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list