4 ms·
> An "ordered map" is not a hash table. I think they want a tree. An ordered map is absolutely a hashmap. > But you can get the keys and sort them. That give
by masklinn 2y ago
> An "ordered map" is not a hash table. I think they want a tree.
An ordered map is absolutely a hashmap.
> But you can get the keys and sort them.
That gives you a sorted thing, which is completely different.
> Use a tree if order matters, Hash if not.
That is incorrect. “Ordered” in the context of maps generally denotes the preservation of insertion order, and more rarely the ability to change that order. Trees don’t help with that, quite the opposite.
- worik 2y ago> An ordered map is absolutely a hashmap I have never heard of O(1) insert and retrieval from anything ordered. So, no. An ordered map is not a hashmap
- masklinn 2y ago> I have never heard of O(1) insert and retrieval from anything ordered. Then you’ve not gotten out much. Here’s one: https://docs.python.org/3/library/stdtypes.html#dict https://docs.python.org/3/library/stdtypes.html#dict Here’s an other one: https://docs.python.org/3/library/collections.html#collections.OrderedDict https://docs.python.org/3/library/collections.html#collectio... Here’s a third one: https://docs.rs/indexmap/latest/indexmap/map/struct.IndexMap.html https://docs.rs/indexmap/latest/indexmap/map/struct.IndexMap... And a fourth: https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/util/LinkedHashMap.html https://docs.oracle.com/en/java/javase/22/docs/api/java.base... > So, no. An ordered map is not a hashmap Still wrong.
- worik 2y agoThat is not O(1) for insert and read Sort is O(log N) Insert into sorted list is O(log N) I am correct If you need sorted keys that is easy but you cannot get O(1) which HASH gets on a good day Not in this universe The person who wants a HASH table with sorted keys actually wants a tree. Maths
- masklinn 2y ago> That is not O(1) for insert and read Of course it is. > Sort is O(log N) Sort is irrelevant, as I already told you ordered != sorted. > I am correct No my dude, you’ve got no idea what you’re talking about and you apparently can’t read. > If you need sorted keys Then you’re in the wrong place because that’s not what ordered maps do. > The person who wants a HASH table with sorted keys Is not germane to the discussion. > Maths Maths have nothing to do with your apparent inability to understand basic English or intake new information.
- worik 2y agoHow are you maintaining a sorted list (required) O(1)?
- masklinn 2y agoAgain, for the fourth time, you are not. An ordered collection is not a sorted collection.
- worik 2y agoSO you want a HASH table and a stack? Wih the Hash table keep a stack of keys. How do you delete them? Oh. Same problem. You have O(1) insert and O(log N) deletion Or the stack grows for ever. When you ask for ordered keys, at zero cost, in a Hash it is like asking the Tooth Fairy. You can ask for anything you want, but you cannot have anything you want!
- masklinn 2y agoMan you’re a lost cause. It takes you two days to understand a simple idea and when you finally do you’re incapable of even acknowledging it, and instead have to move the goalposts to an irrelevant aside only to be wrong again. Is this a kink? Do you get off on appearing incompetent? If so good job.