Skip to content

biggyspender/ts-hashmap

Repository files navigation

A hashtable-based implementation of Map<K,V> and Set<V>

An implementation of Map<TKey, TValue> and Set<TValue> that can use custom equals and getHashCode functions.

A case-insensitve set, using EqualityComparer<T> and getHashCode

const names = ["zebra", "antelope", "ardvaark", "tortoise", "turtle", "dog", "frog"]
const comparer: EqualityComparer<string> = {
    equals: (a, b) => a.toLowerCase() === b.toLowerCase(),
    getHashCode: (x) => getHashCode(x.toLowerCase())
}
const set = createComparerSet(comparer)
names.forEach(n => set.add(n))
expect(set.has("DOg")).toBeTruthy()

acknowledgements

Created using the wonderful https://github.com/alexjoverm/typescript-library-starter.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published