export declare abstract class ValueComparator { /** * Implement an algorithm that sorts values in ascending order. * If it returns a negative number, a is less than b. If it returns 0, the two values are equal. If it returns a positive number, a is greater than b. * @param a Value a. * @param b Value b. */ abstract asc(a: V, b: V): number; /** * The `match` method is used for the **LIKE** operator. * This method specifies which value to test against a regular expression. * * For example, if you have a tree with values of the structure `{ country: string, capital: string }`, * and you want to perform a **LIKE** operation based on the **capital** value, the method should return **value.capital**. * In this case, you **CANNOT** perform a **LIKE** operation based on the **country** attribute. * The returned value must be a string. * * ``` * interface MyObject { * country: string * capital: string * } * * class CompositeComparator extends ValueComparator { * match(value: MyObject): string { * return value.capital * } * } * ``` * * For a tree with simple structure, without complex nesting, returning the value directly would be sufficient. * * ``` * class StringComparator extends ValueComparator { * match(value: string): string { * return value * } * } * ``` * * @param value The inserted value. * @returns The value to test against a regular expression. */ abstract match(value: V): string; isLower(value: V, than: V): boolean; isSame(value: V, than: V): boolean; isHigher(value: V, than: V): boolean; /** * This method is used for range queries with composite values. * By default, it calls the `asc` method, so existing code works without changes. * * When using composite values (e.g., `{ k: number, v: number }`), * override this method to compare only the primary sorting field (e.g., `v`), * ignoring the unique identifier field (e.g., `k`). * * This enables efficient range queries like `primaryEqual` that find all entries * with the same primary value regardless of their unique identifiers. * * @param a Value a. * @param b Value b. * @returns Negative if a < b, 0 if equal, positive if a > b (based on primary field only). */ primaryAsc(a: V, b: V): number; isPrimarySame(value: V, than: V): boolean; isPrimaryLower(value: V, than: V): boolean; isPrimaryHigher(value: V, than: V): boolean; } export declare class NumericComparator extends ValueComparator { asc(a: number, b: number): number; match(value: number): string; } export declare class StringComparator extends ValueComparator { asc(a: string, b: string): number; match(value: string): string; }