@phroun/paged-buffer
Version:
High-performance buffer system for editing massive files with intelligent memory management and undo/redo capabilities
117 lines • 4.19 kB
TypeScript
/**
* @fileoverview Operation Distance Calculator
* Calculates logical distance between buffer operations for merge decisions
* @author Jeffrey R. Day
* @version 1.0.0
*/
/**
* Represents position information for an operation
*/
export class OperationPosition {
constructor(preExecution: any, postExecution?: null);
preExecution: any;
postExecution: number | null;
/**
* Set the post-execution position
* @param {number} position - Position after operation executed
*/
setPostExecution(position: number): void;
/**
* Check if this position info is complete (has both pre and post execution positions)
* @returns {boolean}
*/
isComplete(): boolean;
}
/**
* Lightweight operation descriptor for distance calculations
*/
export class OperationDescriptor {
/**
* Create from a BufferOperation
* @param {BufferOperation} bufferOp - Source operation
* @returns {OperationDescriptor}
*/
static fromBufferOperation(bufferOp: BufferOperation): OperationDescriptor;
constructor(type: any, position: any, dataLength?: number, originalDataLength?: number, operationNumber?: number);
type: any;
position: OperationPosition;
dataLength: number;
originalDataLength: number;
operationNumber: number;
/**
* Set post-execution position
* @param {number} position - Position after execution
*/
setPostExecutionPosition(position: number): void;
/**
* Get the length of content this operation adds to the final buffer
* @returns {number}
*/
getInsertedLength(): number;
}
/**
* Calculator for logical distance between operations
*/
export class OperationDistanceCalculator {
/**
* Calculate logical distance between two operations
* @param {OperationDescriptor} op1 - First operation
* @param {OperationDescriptor} op2 - Second operation
* @param {Object} options - Calculation options
* @param {boolean} options.debug - Enable debug logging
* @returns {number} - Logical distance (0 = adjacent/overlapping)
*/
static calculateDistance(op1: OperationDescriptor, op2: OperationDescriptor, options?: {
debug: boolean;
}): number;
/**
* Calculate the range affected by an operation in post-execution coordinates
* @param {OperationDescriptor} op - Operation that has executed
* @returns {{start: number, end: number}} - Affected range
* @private
*/
private static _calculateOperationRange;
/**
* Calculate distance from an operation to a range
* @param {OperationDescriptor} op - Operation to test
* @param {{start: number, end: number}} range - Target range
* @returns {number} - Distance to range
* @private
*/
private static _calculateDistanceToRange;
/**
* Calculate distance for insert operations
* @param {OperationDescriptor} op - Insert operation
* @param {{start: number, end: number}} range - Target range
* @returns {number} - Distance
* @private
*/
private static _calculateInsertDistance;
/**
* Calculate distance for delete operations
* @param {OperationDescriptor} op - Delete operation
* @param {{start: number, end: number}} range - Target range
* @returns {number} - Distance
* @private
*/
private static _calculateDeleteDistance;
/**
* Calculate distance for overwrite operations
* @param {OperationDescriptor} op - Overwrite operation
* @param {{start: number, end: number}} range - Target range
* @returns {number} - Distance
* @private
*/
private static _calculateOverwriteDistance;
/**
* Get debug distance calculation
* @param {OperationDescriptor} firstOp - First operation
* @param {OperationDescriptor} secondOp - Second operation
* @param {{start: number, end: number}} range - Calculated range
* @param {number} distance - Calculated distance
* @returns {{firstOp, secondOp, range, distance}} - Debugging descriptions
* @private
*/
private static _getDebugDistanceCalculation;
}
//# sourceMappingURL=operation-distance.d.ts.map