@tanishiking/aho-corasick
Version:
TypeScript implementation of the Aho-Corasick algorithm for efficient string matching
40 lines (39 loc) • 1.34 kB
TypeScript
import { Interval } from './interval';
/**
* Binary tree to find all intervals that overlaps with the given interval efficiently.
*/
export declare class IntervalNode {
private medianPoint;
private intervals;
private left;
private right;
/**
*
* @param intervals intervals, note that they should be sorted by size decending.
*/
constructor(intervals: Interval[]);
/**
* Find all intervals overlap with the given interval.
*
* @param interval - the interval object to find its overlaps.
*/
findOverlaps(interval: Interval): Interval[];
/**
* Find the intervals that overlaps with the given interval (which never contains median point)
* from the intervals of this node (which always contains median point).
* median
* ---------------------o---------------------
* given interval ------[xxxxxxx]--------------[xxxxx]-------
* current ------------[xxxxxxxxxxxxxxxxxxx]----------
*
* @param interval - the interval to find its overlaps.
* @param direction - the direction to search for.
*/
private checkForOverlaps;
/**
* Find a median point from left most start and right most ends.
*
* @param intervals
*/
private determineMedian;
}