import type * as RDF from '@rdfjs/types'; import type { ITermDictionary } from './dictionary/ITermDictionary'; /** * A total order over RDF terms, used when no other comparator is given. * Orders on term type first, then on value, then on datatype, language, and base direction. * Two terms compare as equal exactly if they are equal RDF terms. * @param left A term. * @param right A term. */ export declare function defaultTermComparator(left: RDF.Term, right: RDF.Term): number; /** * Keeps every term that an ordered index holds in a sorted order, and gives each a numeric label * that increases along it, so that indexes can compare encoded terms without decoding them. * * Labels only ever keep their relative order, never their value: a term that is added between two * others takes the midpoint of their labels, and when no midpoint is left, all terms are relabelled. * Indexes therefore store encodings rather than labels, and look the labels up when comparing. * * Only dictionaries that encode to non-negative integers, optionally with the high bit set for * quoted triples, are supported. All bundled number dictionaries do. */ export declare class TermOrder { readonly dictionary: ITermDictionary; readonly comparator: (left: RDF.Term, right: RDF.Term) => number; private plainLabels; private quotedLabels; /** * All known encodings in sorted order, split into chunks so that inserting one stays cheap. */ private chunks; private termCount; /** * If every label is exactly its rank plus one, times the spacing, which is what a relabel produces. */ private uniform; constructor(dictionary: ITermDictionary, comparator?: (left: RDF.Term, right: RDF.Term) => number); /** * The number of terms in this order. */ get size(): number; /** * The label of an encoding, or 0 if it is not in this order. * @param encoding An encoded term. */ label(encoding: number): number; /** * The rank of a known encoding, which is only valid right after {@link TermOrder#makeUniform}. * @param encoding An encoded term. */ rank(encoding: number): number; private setLabel; private static grow; /** * Compare two distinct encodings. Terms that the comparator considers equal are ordered on their * encoding, so that the order is total. * @param left An encoded term. * @param right An encoded term. */ compareEncodings(left: number, right: number): number; /** * Add a single encoding to this order, if it is not in it yet. * @param encoding An encoded term. */ add(encoding: number): void; /** * Add many encodings at once, which sorts the new ones a single time and merges them in, * instead of inserting them one by one. * @param encodings Encoded terms, possibly with duplicates and with terms already in this order. * @param length The number of entries of `encodings` to consider. */ addAll(encodings: ArrayLike, length: number): void; /** * Make sure that every label is its rank plus one, times the spacing, so that {@link TermOrder#rank} holds. */ makeUniform(): void; private relabel; /** * The label of the first known term that is not before the given term, or Infinity if there is none. * The term does not have to be known, so a key `k` is before `term` exactly if `label(k)` is lower. * @param term A term. */ lowerBound(term: RDF.Term): number; }