Here's a little benchmark of Associative Arrays and Dynamic Arrays. I'm showing
traversal and lookup speed. The `static this()` is used to create a random
collection of words which get stored in the two arrays:
https://gist.github.com/893340
Hash lookups are naturally very fast. So I am incline
== Quote from Andrej Mitrovic (n...@none.none)'s article
> Here's a little benchmark of Associative Arrays and Dynamic Arrays. I'm
> showing
traversal and lookup speed. The `static this()` is used to create a random
collection of words which get stored in the two arrays:
> https://gist.github.com/
Andrej Mitrovic wrote:
1. I'm wasting memory. I don't need the values, I only need the keys. But I
can't declare a void[string] hash.
But I don't know how to get rid of the values, which leaves the issue #1.
Maybe static array of zero length? From documentation:
"A static array with a dimensi
A use case for this could be a file system search:
void[string] names; // unique names to find
string[] results;
foreach (string name; dirEntries(curdir, SpanMode.deep))
{
if (name.basename in names)
results ~= name;
}
With string arrays the `if` check mi
Oh there's a container? I'll take a look, thanks guys.
Looks like not. I've misread Piotr'es post. :)
Piotr Szturmaj:
> void[0][string] aa;
> aa["key"] = [];
> assert("key" in aa);
Nice. I have done a benchmark, and it seems a void[0][int] uses the same amount
of memory as a int[int]. I have not tried a void[0][string].
Bye,
bearophile
"Andrej Mitrovic" wrote in message
news:imtirq$292g$1...@digitalmars.com...
> Here's a little benchmark of Associative Arrays and Dynamic Arrays. I'm
> showing traversal and lookup speed. The `static this()` is used to create
> a random collection of words which get stored in the two arrays:
>
On 03/29/2011 11:47 PM, Andrej Mitrovic wrote:
Looks like not. I've misread Piotr'es post. :)
There is one in Steven's dcollections.
Denis
--
_
vita es estrany
spir.wikidot.com
On 03/29/2011 11:43 PM, Andrej Mitrovic wrote:
A use case for this could be a file system search:
void[string] names; // unique names to find
string[] results;
foreach (string name; dirEntries(curdir, SpanMode.deep))
{
if (name.basename in names)
resul
On 3/30/11, spir wrote:
> On 03/29/2011 11:47 PM, Andrej Mitrovic wrote:
>> Looks like not. I've misread Piotr'es post. :)
>
> There is one in Steven's dcollections.
>
> Denis
Oh yes, I've been meaning to look at dcollections. The last time I saw
it I was still confused as to how templates work,
On 2011-03-29 14:34, dsimcha wrote:
> == Quote from Andrej Mitrovic (n...@none.none)'s article
>
> > Here's a little benchmark of Associative Arrays and Dynamic Arrays. I'm
> > showing
>
> traversal and lookup speed. The `static this()` is used to create a random
>
> collection of words which ge
On 3/29/2011 8:37 PM, Jonathan M Davis wrote:
We now have std.container.RedBlackTree, which can be used as a set, but it is
a tree rather than a hash table.
- Jonathan M Davis
This isn't a very good set. It doesn't even support basic set
primitives like intersection, difference, union, etc.
I had a look at dcollections, it seems to have a few different
implementations of a set. And it has intersection (not sure about
difference or union). It's boost licensed, I wonder if Steve will make
a push of his library to Phobos when its done..
On 2011-03-29 20:11, Andrej Mitrovic wrote:
> I had a look at dcollections, it seems to have a few different
> implementations of a set. And it has intersection (not sure about
> difference or union). It's boost licensed, I wonder if Steve will make
> a push of his library to Phobos when its done..
On 03/30/2011 05:02 AM, dsimcha wrote:
On 3/29/2011 8:37 PM, Jonathan M Davis wrote:
We now have std.container.RedBlackTree, which can be used as a set, but it is
a tree rather than a hash table.
- Jonathan M Davis
This isn't a very good set. It doesn't even support basic set primitives like
On Tue, 29 Mar 2011 23:02:35 -0400, dsimcha wrote:
On 3/29/2011 8:37 PM, Jonathan M Davis wrote:
We now have std.container.RedBlackTree, which can be used as a set, but
it is
a tree rather than a hash table.
- Jonathan M Davis
This isn't a very good set. It doesn't even support basic set
On Tue, 29 Mar 2011 23:11:53 -0400, Andrej Mitrovic
wrote:
I had a look at dcollections, it seems to have a few different
implementations of a set. And it has intersection (not sure about
difference or union). It's boost licensed, I wonder if Steve will make
a push of his library to Phobos wh
On Tue, 29 Mar 2011 18:42:59 -0400, bearophile
wrote:
Piotr Szturmaj:
void[0][string] aa;
aa["key"] = [];
assert("key" in aa);
Nice. I have done a benchmark, and it seems a void[0][int] uses the same
amount of memory as a int[int]. I have not tried a void[0][string].
Each node in the
On 3/30/11 5:02 AM, dsimcha wrote:
[…] Furthermore, most programs will probably want a hash set.
First of all, I agree that we really want to have a hash set in Phobos.
I think that a first implementation wouldn't even need to support
advanced operations like union, intersection, etc., but we
== Quote from David Nadlinger (s...@klickverbot.at)'s article
> On 3/30/11 5:02 AM, dsimcha wrote:
> > […] Furthermore, most programs will probably want a hash set.
> First of all, I agree that we really want to have a hash set in Phobos.
> I think that a first implementation wouldn't even need to
On 3/30/11 3:59 PM, dsimcha wrote:
== Quote from David Nadlinger (s...@klickverbot.at)'s article
On 3/30/11 5:02 AM, dsimcha wrote:
[…] Furthermore, most programs will probably want a hash set.
First of all, I agree that we really want to have a hash set in Phobos.
I think that a first impleme
On 2011-03-30 07:42, David Nadlinger wrote:
> On 3/30/11 3:59 PM, dsimcha wrote:
> > == Quote from David Nadlinger (s...@klickverbot.at)'s article
> >
> >> On 3/30/11 5:02 AM, dsimcha wrote:
> >>> […] Furthermore, most programs will probably want a hash set.
> >>
> >> First of all, I agree that w
23 matches
Mail list logo