certik / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

map iterators go in alphabetical order #164

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I need to know the original order of the items in the map.

it does seem strange though, that lookups by key are O(n) if the items are 
already sorted...

I'm using version 0.3.0

Original issue reported on code.google.com by chan...@gmail.com on 18 Jul 2012 at 4:18

GoogleCodeExporter commented 9 years ago
According to the spec, "In the representation model, mapping keys do not have 
an order... In every case where node order is significant, a sequence must be 
used. For example, an ordered mapping can be represented as a sequence of 
mappings, where each mapping is a single key: value pair. YAML provides 
convenient compact notation for this case."

http://www.yaml.org/spec/1.2/spec.html#id2765608

Is your bug report then about lookups being O(n)? I plan, eventually, to make 
string key lookups O(log n), but in the general case (looking up an arbitrary 
node as a key), it has to be O(n), because those can't be sorted.

Original comment by jbe...@gmail.com on 18 Jul 2012 at 4:23

GoogleCodeExporter commented 9 years ago
well, crap. someone needs to hit Doctrine over the head with the spec, then.

honestly I don't mind about the speed of key lookups. it just struck me as odd. 
:)

Original comment by chan...@gmail.com on 18 Jul 2012 at 4:29

GoogleCodeExporter commented 9 years ago
Yeah, that's just laziness, not to make an exception for strings :)

Original comment by jbe...@gmail.com on 18 Jul 2012 at 4:34