Re: Can the order in associative array change when keys are not midified?

2015-01-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/1/15 7:32 AM, Idan Arye wrote: If I have an associative array and I only modify it's values, without changing the keys, can I assume that the order won't change? I would never make that assumption. An AA is free to rehash at any time, for whatever reason. What I would say is that you

Re: Can the order in associative array change when keys are not midified?

2015-01-02 Thread Tobias Pankrath via Digitalmars-d-learn
On Thursday, 1 January 2015 at 18:58:04 UTC, Andrej Mitrovic via Digitalmars-d-learn wrote: On 1/1/15, Tobias Pankrath via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: You could implement an OrderedMap!(Key, Value) via RedBlackTree!(Tuple!(Key, Value), (a,b) = a[0] b[0]). We

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Peter Alexander via Digitalmars-d-learn
On Thursday, 1 January 2015 at 13:13:10 UTC, Andrej Mitrovic via Digitalmars-d-learn wrote: On 1/1/15, Idan Arye via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: If I have an associative array and I only modify it's values, without changing the keys, can I assume that the order

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Andrej Mitrovic via Digitalmars-d-learn
On 1/1/15, Peter Alexander via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: The order is unspecified, but an iteration must iterate in *some* order. The question (if I've understood it correctly), is whether that order of iteration changes when the keys aren't changed. Hmm

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Andrej Mitrovic via Digitalmars-d-learn
On 1/1/15, Idan Arye via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: If I have an associative array and I only modify it's values, without changing the keys, can I assume that the order won't change? Associative arrays are not ordered at all. See the first note here:

Can the order in associative array change when keys are not midified?

2015-01-01 Thread Idan Arye via Digitalmars-d-learn
If I have an associative array and I only modify it's values, without changing the keys, can I assume that the order won't change?

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Laeeth Isharc via Digitalmars-d-learn
On Thursday, 1 January 2015 at 18:58:04 UTC, Andrej Mitrovic via Digitalmars-d-learn wrote: On 1/1/15, Tobias Pankrath via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: You could implement an OrderedMap!(Key, Value) via RedBlackTree!(Tuple!(Key, Value), (a,b) = a[0] b[0]). We

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread ketmar via Digitalmars-d-learn
On Thu, 01 Jan 2015 12:32:33 + Idan Arye via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: If I have an associative array and I only modify it's values, without changing the keys, can I assume that the order won't change? please, don't: this is implementation-specific.

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Idan Arye via Digitalmars-d-learn
On Thursday, 1 January 2015 at 13:39:57 UTC, Peter Alexander wrote: On Thursday, 1 January 2015 at 13:13:10 UTC, Andrej Mitrovic via Digitalmars-d-learn wrote: On 1/1/15, Idan Arye via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: If I have an associative array and I only modify

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Tobias Pankrath via Digitalmars-d-learn
On Thursday, 1 January 2015 at 18:08:52 UTC, Andrej Mitrovic via Digitalmars-d-learn wrote: On 1/1/15, H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: If you need consistent ordering of values, you probably want a different data structure, like an ordered map This

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Andrej Mitrovic via Digitalmars-d-learn
On 1/1/15, H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: If you need consistent ordering of values, you probably want a different data structure, like an ordered map This one works nicely on D1, I'd imagine the D2 port works just the same:

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Andrej Mitrovic via Digitalmars-d-learn
On 1/1/15, Tobias Pankrath via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: You could implement an OrderedMap!(Key, Value) via RedBlackTree!(Tuple!(Key, Value), (a,b) = a[0] b[0]). We could add this as an alias into Phobos or perhaps as just a documentation line on the website.

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 01, 2015 at 04:17:39PM +, Idan Arye via Digitalmars-d-learn wrote: [...] My use case is that I have a large AA where the values are numbers and the keys are strings, and I need to send it over network again and again. The values constantly change but the keys should remain the