Open vanodevium opened 1 year ago
Wouldn't a sorted array of objects be effectively that? Something like this:
class SortedMap<K, T> extends SortedArray<{ key: K, value: T}> {
static compare<K, T>(a: { key: K, value: T}, b: { key: K, value: T}): -1 | 0 | 1 {
if (a.key > b.key) return 1;
if (a.key < b.key) return -1;
if (a.key === b.key) return 0;
throw new RangeError("Unstable comparison.");
}
}
This is a good choice, but not for all tasks. I have a business logic where I have to store over 3M items and I really need a key-value structure for my business cases.
@zandaqo Thank you for your great work! These structures are awesome!
Could you please make a new data structure SortedMap? Or it is possible to do it from existing structures and I just didn't read it?