Re: Is there a sorted map?

2016-03-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/13/16 4:33 AM, Jonathan M Davis via Digitalmars-d-learn wrote: On Sunday, March 13, 2016 02:35:27 stunaep via Digitalmars-d-learn wrote: Is there any sorted map in D? I need a map and I need to be able to get the highest key in the map. In java I would use a TreeMap and use map.lastKey

Re: Is there a sorted map?

2016-03-13 Thread cym13 via Digitalmars-d-learn
On Sunday, 13 March 2016 at 14:11:14 UTC, Anonymouse wrote: On Sunday, 13 March 2016 at 13:44:35 UTC, cym13 wrote: Note that implementing an (admitedly not perfect) ordered associative array yourself really isn't much work: https://github.com/cym13/miscD/blob/master/ordered_aa.d Unsigned

Re: Is there a sorted map?

2016-03-13 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 13 March 2016 at 13:44:35 UTC, cym13 wrote: Note that implementing an (admitedly not perfect) ordered associative array yourself really isn't much work: https://github.com/cym13/miscD/blob/master/ordered_aa.d Unsigned integer comparison with -1 in the remove function, by the way.

Re: Is there a sorted map?

2016-03-13 Thread cym13 via Digitalmars-d-learn
On Sunday, 13 March 2016 at 10:06:24 UTC, stunaep wrote: On Sunday, 13 March 2016 at 08:33:43 UTC, Jonathan M Davis wrote: On Sunday, March 13, 2016 02:35:27 stunaep via Digitalmars-d-learn wrote: [...] The closest that we have in Phobos at the moment is RedBlackTree in std.container. Its

Re: Is there a sorted map?

2016-03-13 Thread stunaep via Digitalmars-d-learn
On Sunday, 13 March 2016 at 08:33:43 UTC, Jonathan M Davis wrote: On Sunday, March 13, 2016 02:35:27 stunaep via Digitalmars-d-learn wrote: [...] The closest that we have in Phobos at the moment is RedBlackTree in std.container. Its API is geared towards sets, not maps, but you can get it

Re: Is there a sorted map?

2016-03-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, March 13, 2016 02:35:27 stunaep via Digitalmars-d-learn wrote: > Is there any sorted map in D? I need a map and I need to be able > to get the highest key in the map. In java I would use a TreeMap > and use map.lastKey(), but since associative arrays are not > sorted that

Is there a sorted map?

2016-03-12 Thread stunaep via Digitalmars-d-learn
Is there any sorted map in D? I need a map and I need to be able to get the highest key in the map. In java I would use a TreeMap and use map.lastKey(), but since associative arrays are not sorted that would be O(n). I know about RedBlackTree, but that's a set and it must be a map.