Jump to page: 1 2
Thread overview
dcollections version 0.02
Aug 05, 2008
dsimcha
Aug 05, 2008
dsimcha
Aug 05, 2008
dsimcha
Aug 05, 2008
bearophile
Aug 06, 2008
Lars Ivar Igesund
Aug 06, 2008
maelp
Aug 06, 2008
Lars Ivar Igesund
Aug 06, 2008
bearophile
Aug 06, 2008
bearophile
Aug 06, 2008
Bill Baxter
August 04, 2008
changes:

 * utilizes chunk allocator for more efficient memory management (Tango
only)
 * includes a script to build as a library to make setting up your
environment easier
 * fix to hash implementation for efficiency
 * other bug fixes

-Steve


August 04, 2008
"Steven Schveighoffer" wrote
> changes:
>
> * utilizes chunk allocator for more efficient memory management (Tango
> only)
> * includes a script to build as a library to make setting up your
> environment easier
> * fix to hash implementation for efficiency
> * other bug fixes
>

And the link :)

http://www.dsource.org/projects/dcollections

-Steve


August 05, 2008
Nice work.  This brings to the table a lot of stuff that I really felt was missing in D2.  One quick question, though.  Given that associative arrays are built-in and implemented as hash tables, are there any tradeoffs dcollections makes differently than the builtins that would make me choose one over the other?  As a hypothetical example, is the dcollections HashMap more tuned for space at the expense of speed, or vice-versa than the builtin?
August 05, 2008
"dsimcha" wrote
> Nice work.  This brings to the table a lot of stuff that I really felt was
> missing
> in D2.  One quick question, though.  Given that associative arrays are
> built-in
> and implemented as hash tables, are there any tradeoffs dcollections makes
> differently than the builtins that would make me choose one over the
> other?  As a
> hypothetical example, is the dcollections HashMap more tuned for space at
> the
> expense of speed, or vice-versa than the builtin?

Two main reasons you might choose HashMap over the builtin.

1. customizable.  You can customize down to the hash implementation. 2. api.  HashMap offers a lot more features than the builtin, such as removal while traversing, or keeping a cursor to a specific element for later use and possible removal.

The ArrayList only really exists to implement the list interface as an array-style container.  I made it really easy to switch between using the builtin array type and the ArrayList.

There is the performance benefit, but you must be using Tango (and therefore D1), as Phobos does not provide a necessary GC function needed for the custom allocator.  At that point, you can just use the Tango containers (although there are some features that the tango containers don't have).

On a side note, have you used dcollections with D2?  I haven't tested it. And it's not const-ified.

-Steve


August 05, 2008
== Quote from Steven Schveighoffer (schveiguy@yahoo.com)'s article
> On a side note, have you used dcollections with D2?  I haven't tested it.
> And it's not const-ified.
> -Steve

Actually, yes, I thought that was part of the point of the release was D2 support.
 I've tried it very little, but it at least compiles seems to work.  One small
hitch:  You have to do a find/replace, find all instances of "int opEquals" and
replace with "bool opEquals".  This can be done perfectly as an automated search.
 Anyhow, D2 support is the reason I'm not using Tango.
August 05, 2008
"dsimcha" wrote
> == Quote from Steven Schveighoffer article
>> On a side note, have you used dcollections with D2?  I haven't tested it.
>> And it's not const-ified.
>> -Steve
>
> Actually, yes, I thought that was part of the point of the release was D2
> support.
> I've tried it very little, but it at least compiles seems to work.  One
> small
> hitch:  You have to do a find/replace, find all instances of "int
> opEquals" and
> replace with "bool opEquals".  This can be done perfectly as an automated
> search.

Yeah, it should work (with the opEquals change) as long as you don't need a const container to work :)

Good to know that it builds at least.  The only thing is that just because the library 'builds' doesn't mean it all works :)  The classes/structs are all templates and so won't really 'compile' until you use them.

But if you could just build the examples, and let me know if they work, I'd appreciate it!

And BTW, the point of the release was to add the library building scripts, and fix some bugs (as discussed in the start of this thread).

> Anyhow, D2 support is the reason I'm not using Tango.

I'm on the opposite side, not using D2 because Tango can't build with it (yet) :)  As soon as Tango builds with D2, I'll be switching over.  And then I'll probably migrate dcollections to D2.

-Steve


August 05, 2008
> But if you could just build the examples, and let me know if they work, I'd appreciate it!

Actually, they all work with only very minor tweaks to the test files and no tweaks to the library files except the int opEquals/bool opEquals I mentioned previously.  The tweaks are little things like:

1.  Use writefln instead of Stdout, since I can't use Tango w/ D2 yet.

2.  Explicitly cast some classes to their base class before passing to template functions b/c apparently (IDK why) D2 template instantiation has some quirks when used w/ inheritance that D1 doesn't have.

I've attached the slightly tweaked test files.  I did all the tweaks quick and dirty b/c I didn't want to waste too much time, for example, formatting the printing, but you can diff them against the origninals and see that almost nothing has changed.
August 05, 2008
"dsimcha" wrote
>> But if you could just build the examples, and let me know if they work,
>> I'd
>> appreciate it!
>
> Actually, they all work with only very minor tweaks to the test files and
> no
> tweaks to the library files except the int opEquals/bool opEquals I
> mentioned
> previously.  The tweaks are little things like:

Cool thanks!

>
> 1.  Use writefln instead of Stdout, since I can't use Tango w/ D2 yet.

Right, I forgot about that...

>
> 2.  Explicitly cast some classes to their base class before passing to
> template
> functions b/c apparently (IDK why) D2 template instantiation has some
> quirks when
> used w/ inheritance that D1 doesn't have.

That's odd... There probably should be a bug filed on that.  I'll investigate further.

>
> I've attached the slightly tweaked test files.  I did all the tweaks quick
> and
> dirty b/c I didn't want to waste too much time, for example, formatting
> the
> printing, but you can diff them against the origninals and see that almost
> nothing
> has changed.

Yes, looks good, thanks again!

-Steve


August 05, 2008
Steven Schveighoffer:
> The only thing is that just because the library 'builds' doesn't mean it all works :)  The classes/structs are all templates and so won't really 'compile' until you use them.

But D unittests exists to test all templates too!

Is an efficient deque too included? I often find the need for it (or just a stack). I have partially written a deque data structure (implemented as dynamic array of pointers to fixed size arrays, it's not an unrolled linked list), I may finish it to add it to your collections...

Bye,
bearophile
August 06, 2008
bearophile wrote:

> Steven Schveighoffer:
>> The only thing is that just because
>> the library 'builds' doesn't mean it all works :)  The classes/structs
>> are all templates and so won't really 'compile' until you use them.
> 
> But D unittests exists to test all templates too!
> 
> Is an efficient deque too included? I often find the need for it (or just a stack). I have partially written a deque data structure (implemented as dynamic array of pointers to fixed size arrays, it's not an unrolled linked list), I may finish it to add it to your collections...
> 
> Bye,
> bearophile

You can find a very efficient stack in the new Tango containers.

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource, #d.tango & #D: larsivi
Dancing the Tango
« First   ‹ Prev
1 2