Skip to content

Explain a bit more the difference between Hashtbl and Maps#3631

Open
LordPatate wants to merge 2 commits into
ocaml:mainfrom
LordPatate:LordPatate-hashtbl-vs-maps
Open

Explain a bit more the difference between Hashtbl and Maps#3631
LordPatate wants to merge 2 commits into
ocaml:mainfrom
LordPatate:LordPatate-hashtbl-vs-maps

Conversation

@LordPatate
Copy link
Copy Markdown
Contributor

The current Hashtbl introduction mentions multiple differences to chose one or the other, but only gives one advantage to Hashtbl.
It is not obvious why would one chose Maps over Hashtbl.
The advantages of Maps were never mentioned, while the main advantage of Hashtbl was present in their own page.
Unless the reader dived into the library or did their own research on self-balancing binary search trees, Maps could seem like a "worse" Hash Table; or only exist for the functional interface.

I tried adding a little more information without going into too much detail and referenced Wikipedia for more.

The current introduction mentions multiple differences to chose one or the other but only gives one advantage to Hashtbl.
It is not obvious why would one chose Maps over Hashtbl.
Discuss a little bit more the differences, especially the advantages over Hashtbl, without going too much into the details.
The advantages of Maps were never mentioned, while the main advantage of Hashtbl was present in their own page.
Unless the reader dived into the library or did their own research on self-balancing binary search trees, Maps could seem like a "worse" Hash Table; or only exist for the functional interface.
Copy link
Copy Markdown
Collaborator

@cuihtlauac cuihtlauac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @LordPatate. Make sure to only use capitals for standard library module names or tutorial titles, data structures don't need them

on [Hash Tables](/docs/hash-tables).
Maps offer a functional interface that Hash Tables do not
and maintain total ordering of the keys, allowing more operations;
while Hash Tables have better search performance on average.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
while Hash Tables have better search performance on average.
while hash tables have better search performance on average.


For a different implementation of an association table in OCaml's Standard Library, see the tutorial
on [Hash Tables](/docs/hash-tables).
Maps offer a functional interface that Hash Tables do not
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Maps offer a functional interface that Hash Tables do not
`Map` offer a functional interface that `Hashtbl` do not

table`](https://en.wikipedia.org/wiki/Hash_table) is able to retrieve
information at a nearly instantaneous constant time complexity (O(1)).

**Note:** For more details on the differences between Hash Tables and Maps,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**Note:** For more details on the differences between Hash Tables and Maps,
**Note:** For more details on the differences between hash tables and associative maps,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants