www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.dtl - "map": sorted or unsorted?

reply Ben Hinkle <bhinkle4 juno.com> writes:
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.
Aug 02 2004
next sibling parent "Matthew" <admin.hat stlsoft.dot.org> writes:
"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. :)
Aug 02 2004
prev sibling next sibling parent "Mickey Finn" <horizon blackhole.net> writes:
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.
Aug 02 2004
prev sibling next sibling parent Andy Friesen <andy ikagames.com> writes:
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
Aug 02 2004
prev sibling next sibling parent Sean Kelly <sean f4.ca> writes:
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
Aug 02 2004
prev sibling parent Ben Hinkle <bhinkle4 juno.com> writes:
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.
Aug 03 2004