Add comment about using HashMap in future once available. (#3234)

* Add comment about using HashMap in future once available.

* [ci no changelog needed]

* More detail in ToDo comment.
This commit is contained in:
James Dunkerley 2022-01-25 15:31:31 +00:00 committed by GitHub
parent 8387375d83
commit f9e78a5caa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -755,6 +755,16 @@ type Vector
[Pair 1 "a", Pair 2 "b", Pair 1 "c"] . distinct (on = _.first) == [Pair 1 "a", Pair 2 "b"] [Pair 1 "a", Pair 2 "b", Pair 1 "c"] . distinct (on = _.first) == [Pair 1 "a", Pair 2 "b"]
distinct : (Any -> Any) -> Vector Any distinct : (Any -> Any) -> Vector Any
distinct (on = x->x) = distinct (on = x->x) =
## TODO [JD] This is based on the Map class until a HashMap is available.
Current implementation allows for a consistent distinct with the Enso `==` operator.
Using the Map, is less efficient than a HashMap based as requires searching the tree (O(Log N)).
A HashMap would allow for a O(1) operation to confirm if an item has been seen already.
There is no native HashMap within Enso at present, and the polyglot approach does not produce
consistent results with the `==` operator.
More details on the HashCode / HashMap ticket https://www.pivotaltracker.com/story/show/181027272.
recovered = Panic.recover recovered = Panic.recover
builder = here.new_builder builder = here.new_builder
this.fold Map.empty existing-> this.fold Map.empty existing->