Closed kavaro closed 3 years ago
Yes, there's a good way to do so. It's called HashFunction.
type hashFunction = (valueType: ValueType) => number;
const hash = hashFunction(somethingIWantToStore);
tree.insert(hash, somethingIWantToStore);
Here are a few hash functions for strings.
A hash would for sure be a solution.
However with the javascript version the hash would not be required. By providing a custom compare function to the tree constructor one can use any datatype as key. Unless I am missing something ...
Thanks for making this Typescript version available.
I would like to use the tree with a custom key type (e.g. string) and a comparator function that compares custom keys.
Is there a way to achieve this ?
Thanks ...