Skip to content

The default map should keep insertion order #41

@VinGarcia

Description

@VinGarcia

The current TokenMap class uses the std::map implementation. This map is alright but if you try to iterate over it, e.g.:

TokenMap vars;
calculator::calculate("a = map('c': 1, 'b': 2, 'a': 3)", vars);
std::cout << vars["a"] << std::endl; // { 'a': 3, 'b': 2, 'c': 1 } (alphanumerical order)

It shows the keys in alphanumerical order instead of the insertion order. This is undesired since Javascript or Ruby users would expect it to remember the insertion order.

This feature should be set either hardcoded or as an optional feature (but i think no one will really complain if its hardcoded, so it might be for the best)

The only drawback of the hardcoded approach is that it might be sightly less space efficient, I think.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions