Thread overview
"map": sorted or unsorted?
Aug 03, 2004
Ben Hinkle
Aug 03, 2004
Matthew
Aug 03, 2004
Mickey Finn
Aug 03, 2004
Andy Friesen
Re:
Aug 03, 2004
Sean Kelly
Aug 03, 2004
Ben Hinkle
August 03, 2004
Before the vocabulary gets too confusing, should
1) we try to use the word "map" in D to mean an STL-like map (ie sorted) or
2) have "map" mean a Java-like Map (not necessarily sorted) or
3) always use "sorted map" and "unsorted map" or
4) ignore the difference and let the context determine which is meant.

I ask because in MinTL a Map is sorted and in DTL it is unsorted. I'm tempted to rename the MinTL Map to SortedMap. Thoughts?

-Ben

ps - I say "STL-like" and "Java-like" out of ignorance of any other programming language out there that has sorted and/or unsorted maps.
August 03, 2004
"Ben Hinkle" <bhinkle4@juno.com> wrote in message news:cemuln$kv2$1@digitaldaemon.com...
> Before the vocabulary gets too confusing, should
> 1) we try to use the word "map" in D to mean an STL-like map (ie sorted) or
> 2) have "map" mean a Java-like Map (not necessarily sorted) or

I would say 2)

This is the one I generally mean when I say map. IMO, the sorted nature of STL's map is pretty unimportant.

> 3) always use "sorted map" and "unsorted map" or

I vote for 3). (Feel free to pick me up whenever I use the unadorned term.)

> 4) ignore the difference and let the context determine which is meant.
>
> I ask because in MinTL a Map is sorted and in DTL it is unsorted. I'm tempted to rename the MinTL Map to SortedMap. Thoughts?

I think that's a good idea. I'm open, in the future, to removing Map and having either SortedMap or UnsortedMap.

> -Ben
>
> ps - I say "STL-like" and "Java-like" out of ignorance of any other programming language out there that has sorted and/or unsorted maps.

I think STL-like and Java-like are apposite terms for our discussions, and we should adopt them as semi-official terminology. :)


August 03, 2004
FWIW, I think a Map should perhaps be somewhat abstract. Therefore a sorted version would be considered a specialization? I think SortedMap would be a better name for the sorted version. There again, I'm a firm believer in splitting a class into it's respective mutable and immutable versions (where feasible) ... so go figure :-)


"Ben Hinkle" <bhinkle4@juno.com> wrote in message news:cemuln$kv2$1@digitaldaemon.com...
> Before the vocabulary gets too confusing, should
> 1) we try to use the word "map" in D to mean an STL-like map (ie sorted)
or
> 2) have "map" mean a Java-like Map (not necessarily sorted) or
> 3) always use "sorted map" and "unsorted map" or
> 4) ignore the difference and let the context determine which is meant.
>
> I ask because in MinTL a Map is sorted and in DTL it is unsorted. I'm tempted to rename the MinTL Map to SortedMap. Thoughts?
>
> -Ben
>
> ps - I say "STL-like" and "Java-like" out of ignorance of any other programming language out there that has sorted and/or unsorted maps.


August 03, 2004
Ben Hinkle wrote:
> Before the vocabulary gets too confusing, should 1) we try to use the word "map" in D to mean an STL-like map (ie sorted) or
> 2) have "map" mean a Java-like Map (not necessarily sorted) or
> 3) always use "sorted map" and "unsorted map" or
> 4) ignore the difference and let the context determine which is meant.
> 
> I ask because in MinTL a Map is sorted and in DTL it is unsorted. I'm
> tempted to rename the MinTL Map to SortedMap. Thoughts?
> 
> -Ben
> 
> ps - I say "STL-like" and "Java-like" out of ignorance of any other
> programming language out there that has sorted and/or unsorted maps.

I would say that 'Map' is free to sort, but is not obligated to.  If you actually care about whether a given map sorts or not, use a SortedMap or an UnsortedMap.

(you could just alias one or the other to Map even)

 -- andy
August 03, 2004
In article <cemuln$kv2$1@digitaldaemon.com>, Ben Hinkle says...
>
>Before the vocabulary gets too confusing, should
>1) we try to use the word "map" in D to mean an STL-like map (ie sorted) or
>2) have "map" mean a Java-like Map (not necessarily sorted) or
>3) always use "sorted map" and "unsorted map" or
>4) ignore the difference and let the context determine which is meant.

Well, the STL has (or will have) map, multimap, and hash_map.  So there are provisions for sorted and unsorted maps in C++.  I'd say the term "map" is general and might have several different implementations, depending on need. I'd like to have both if possible.


Sean


August 03, 2004
Ben Hinkle wrote:

> Before the vocabulary gets too confusing, should
> 1) we try to use the word "map" in D to mean an STL-like map (ie sorted)
> or 2) have "map" mean a Java-like Map (not necessarily sorted) or
> 3) always use "sorted map" and "unsorted map" or
> 4) ignore the difference and let the context determine which is meant.
> 
> I ask because in MinTL a Map is sorted and in DTL it is unsorted. I'm tempted to rename the MinTL Map to SortedMap. Thoughts?
> 
> -Ben
> 
> ps - I say "STL-like" and "Java-like" out of ignorance of any other programming language out there that has sorted and/or unsorted maps.

After pondering this map thing some more, I'm also considering renaming
MinTL's Map to SortedAA (for sorted associative array) instead of
SortedMap. The reason is that
1) D uses the phrase "associative array" instead of "map"
2) MinTL also has a LinkedAA which is an associative array ordered by
insertion order.
The trouble with the term "associative array" is that it's a mouthful and it
doesn't lend itself to nice class names. "Map" is simpler to say and use in
names. oh well. I'll probably end up with SortedAA and LinkedAA and avoid
"map" entirely.