www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.dtl - Multimap construct in DTL ?

reply C <qbert atari-soldiers.com> writes:
Is this planned ?

When can we expect DTL in the distro ?

Thanks,
Charles
May 04 2004
next sibling parent reply "Matthew" <matthew.hat stlsoft.dot.org> writes:
"C" <qbert atari-soldiers.com> wrote in message
news:opr7iej8g8aoygh6 news.digitalmars.com...
 Is this planned ?
I don't plan to write a multi-map, but I do plan to be able to advise/help anyone who wishes to contribute one. You see, my intention is that the stuff in DTL can be contributed by many people, as long as it's efficient+robust+flexible+etc.etc. I'm hoping that once we get the first version - which is still some way away because I'm waiting for a "method-hidable" mixins from Walter, and he's understandably wrestling with some serious design/implementation issues on it -
 When can we expect DTL in the distro ?
I don't know whether we can ever _expect_ it, <G>, but I hope to release something very soon. See the other post. As to when/if it gets into Phobos, that's down to all you to share your opinions, and big-W to give the yeah or nay. Assuming it's not embarrassingly bad, I would expect it to enter the Martian gravitational pull this month.
May 04 2004
parent Kevin Bealer <Kevin_member pathlink.com> writes:
If I wanted a multi-map from string to string, I could use a map-to-list:

char[][][char[]] multi;

What additional functionality would I need for a true multimap?

Kevin


In article <c79qqd$2k4r$2 digitaldaemon.com>, Matthew says...
"C" <qbert atari-soldiers.com> wrote in message
news:opr7iej8g8aoygh6 news.digitalmars.com...
 Is this planned ?
I don't plan to write a multi-map, but I do plan to be able to advise/help anyone who wishes to contribute one. You see, my intention is that the stuff in DTL can be contributed by many people, as long as it's efficient+robust+flexible+etc.etc. I'm hoping that once we get the first version - which is still some way away because I'm waiting for a "method-hidable" mixins from Walter, and he's understandably wrestling with some serious design/implementation issues on it -
 When can we expect DTL in the distro ?
I don't know whether we can ever _expect_ it, <G>, but I hope to release something very soon. See the other post. As to when/if it gets into Phobos, that's down to all you to share your opinions, and big-W to give the yeah or nay. Assuming it's not embarrassingly bad, I would expect it to enter the Martian gravitational pull this month.
May 05 2004
prev sibling parent reply "Ben Hinkle" <bhinkle4 juno.com> writes:
Have you tried using an assoc array of dynamic arrays? I'd be curious to see
how that performs. It would probably be pretty fast in the cases when the
map only has a few duplicates per key. If there are lots of duplicates and
you remove often then something that doesn't use dynamic arrays would
probably be better.

For example, a multi-map where the keys are strings and the values are ints
would look like
  int[][char[]] map;
  map["hello"] ~= 10;
  map["world"] ~= 20;
  map["hello"] ~= 30;
  printf("number of unique keys: %d\n", map.length);
  printf("number of duplicates of hello: %d\n", map["hello"].length);
  foreach(char[] key; map.keys) {
    foreach(int val; map[key])
     printf(" %.*s: %d\n",key,val);
  }
  delete map["world"]; // remove all values for key "world"

A few helper functions to delete individual items or count up the total
number of items in the array would probably be nice, too.
May 05 2004
next sibling parent "Ben Hinkle" <bhinkle4 juno.com> writes:
 If there are lots of duplicates and
 you remove often then something that doesn't use dynamic arrays would
 probably be better.
actually if you have lots of duplicates for a key an assoc array of assoc arrays would probably be fine: void[int][char[]] map2; // multi-map of ints indexed by strings map2["hello"][10]; map2["world"][20]; map2["hello"][30]; printf("number of unique keys: %d\n", map2.length); printf("number of duplicates of hello: %d\n", map2["hello"].length); foreach(char[] key; map2.keys) { foreach(int val; map2[key].keys) printf(" %.*s: %d\n",key,val); } delete map2["world"]; // remove all values for key "world" delete map2["hello"][30]; // remove entry 30 for key "world" printf("number of duplicates of hello after deletion: %d\n", map2["hello"].length);
May 05 2004
prev sibling parent C <qbert atari-soldiers.com> writes:
Hmm good call, ill try this thanks.

C

On Wed, 5 May 2004 10:54:10 -0400, Ben Hinkle <bhinkle4 juno.com> wrote:

 Have you tried using an assoc array of dynamic arrays? I'd be curious to 
 see
 how that performs. It would probably be pretty fast in the cases when the
 map only has a few duplicates per key. If there are lots of duplicates 
 and
 you remove often then something that doesn't use dynamic arrays would
 probably be better.

 For example, a multi-map where the keys are strings and the values are 
 ints
 would look like
   int[][char[]] map;
   map["hello"] ~= 10;
   map["world"] ~= 20;
   map["hello"] ~= 30;
   printf("number of unique keys: %d\n", map.length);
   printf("number of duplicates of hello: %d\n", map["hello"].length);
   foreach(char[] key; map.keys) {
     foreach(int val; map[key])
      printf(" %.*s: %d\n",key,val);
   }
   delete map["world"]; // remove all values for key "world"

 A few helper functions to delete individual items or count up the total
 number of items in the array would probably be nice, too.
May 05 2004