www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13923] New: Specify guarantees on associative array iteration

https://issues.dlang.org/show_bug.cgi?id=13923

          Issue ID: 13923
           Summary: Specify guarantees on associative array iteration
                    order volatility
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: websites
          Assignee: nobody puremagic.com
          Reporter: peter.alexander.au gmail.com

Suppose I have an associative array:

string[int] a = [1:"a", 2:"b", 3:"c"];

Now, associative arrays have unspecified iteration order, but suppose I iterate
the array and it iterates in order {2, 1, 3}.

What guarantees are provided on subsequent iterations? Specifically:

* If I iterate the array again, without modifying any keys or values, or
inserting, removing, or rehashing; is the iteration order guaranteed to be the
same?

* If I iterate the array again, with only modifying values (not keys), is the
iteration order guaranteed to be the same?

The spec should specify what operations may alter the iteration order, and what
operations will leave it intact.

--
Jan 01 2015