Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Java does at least have ordered maps

Weird

An "ordered map" is not a hash table. I think they want a tree.

But you can get the keys and sort them.

I really do not see the problem

Use a tree if order matters, Hash if not.

(Since I am not a Go programmer, maybe I missed something)



Java’s LinkedHashMap is a hash table with an additional linked-list structure on the entries that records the insertion order. The map is thus ordered by insertion order, an order that is independent from the keys.

A map ordered by keys is a SortedMap in Java. While ordered, LinkedHashMap is not a SortedMap. In other words, unordered < ordered < sorted.


> 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.


> 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


> 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

Here’s an other one: https://docs.python.org/3/library/collections.html#collectio...

Here’s a third one: https://docs.rs/indexmap/latest/indexmap/map/struct.IndexMap...

And a fourth: https://docs.oracle.com/en/java/javase/22/docs/api/java.base...

> So, no. An ordered map is not a hashmap

Still wrong.


That 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


> 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.


How are you maintaining a sorted list (required) O(1)?


Again, for the fourth time, you are not. An ordered collection is not a sorted collection.


SO 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!


Man 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.


It is a kink of mine to argue with people who wish for the impossible

The goal post was a HASH table with ordered keys. ' Such a thing cannot exist and retain the desirable properties of a HASH tab=le

Do you think that statement is untrue?

Do you understand order analysis?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: