objeck / objeck-lang

Objeck is a modern object-oriented programming language with functional features tailored for machine learning. It emphasizes expression, simplicity, portability, and scalability. The programming environment consists of a compiler, virtual machine, REPL shell, and command line debugger with IDE plugins.
https://objeck.org
Other
154 stars 11 forks source link

`Collection.Hash` doesn't preserve the order of the elements #473

Closed ghost closed 7 months ago

ghost commented 7 months ago

Yes, it doesn't sort everything like Collection.Map. But it doesn't preserve the order of the elements. I used a for loop to initialize the Hash, so I know the order of the elements.

objeck commented 7 months ago

Consider something like

values := Collection.Vector->New()<Pair<String, IntRef>>;
values->AddBack(Collection.Pair->New("MC Eiht", 8)<String, IntRef>);

Last, hash tables are not designed to preserve order. This includes insert and sort order.