import { DifferenceStreamWriter, UnaryOperator, DifferenceStreamReader } from '../graph.js'; import { IndexedValue, TopK } from './topKArray.js'; import { PipedOperator } from '../types.js'; export interface TopKWithFractionalIndexOptions { limit?: number; offset?: number; setSizeCallback?: (getSize: () => number) => void; setWindowFn?: (windowFn: (options: { offset?: number; limit?: number; }) => void) => void; } /** * Operator for fractional indexed topK operations * This operator maintains fractional indices for sorted elements * and only updates indices when elements move position */ export declare class TopKWithFractionalIndexOperator extends UnaryOperator<[K, T], [K, IndexedValue]> { #private; constructor(id: number, inputA: DifferenceStreamReader<[K, T]>, output: DifferenceStreamWriter<[K, IndexedValue]>, comparator: (a: T, b: T) => number, options: TopKWithFractionalIndexOptions); protected createTopK(offset: number, limit: number, comparator: (a: [K, T], b: [K, T]) => number): TopK<[K, T]>; /** * Moves the topK window based on the provided offset and limit. * Any changes to the topK are sent to the output. */ moveTopK({ offset, limit }: { offset?: number; limit?: number; }): void; run(): void; processElement(key: K, value: T, multiplicity: number, result: Array<[[K, IndexedValue], number]>): void; } /** * Limits the number of results based on a comparator, with optional offset. * Uses fractional indexing to minimize the number of changes when elements move positions. * Each element is assigned a fractional index that is lexicographically sortable. * When elements move, only the indices of the moved elements are updated, not all elements. * * @param comparator - A function that compares two elements * @param options - An optional object containing limit and offset properties * @returns A piped operator that orders the elements and limits the number of results */ export declare function topKWithFractionalIndex(comparator: (a: T, b: T) => number, options?: TopKWithFractionalIndexOptions): PipedOperator<[KType, T], [KType, IndexedValue]>;