/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
/**
 * A stamp that identifies provenance of an operation performed on the MergeTree.
 *
 * Stamps identify a point in time (`seq`/`localSeq`) as well as the source (`clientId`) for the operation.
 * This provides enough information to linearize all known applied operations: acked operations happen before
 * local+unacked ones, with acked operations ordered by their sequence numbers and local+unacked operations
 * ordered by their localSeq.
 *
 * By including `clientId`, it also provides enough information to resolve whether segments are visible
 * from alternative perspectives: a remote client will have seen all of its own previous operations as well as
 * those at or below the op's reference sequence number.
 *
 * @remarks - As the `readonly` identifies suggest, these stamps should be treated as immutable.
 * New operations applied to a merge-tree should create new stamps rather than modify existing ones (e.g. when
 * a change's ack happens).
 * @internal
 */
export interface OperationStamp {
    /**
     * The sequence number at which this operation was applied.
     */
    readonly seq: number;
    /**
     * Short clientId for the client that performed this operation.
     */
    readonly clientId: number;
    /**
     * Local seq at which this operation was applied.
     * This is defined if and only if the operation is pending an ack, i.e. `seq` is UnassignedSequenceNumber.
     *
     * @privateRemarks
     * See {@link CollaborationWindow.localSeq} for more information on the semantics of localSeq.
     */
    readonly localSeq?: number;
}
/**
 * {@link OperationStamp} for an 'insert' operation.
 */
export interface InsertOperationStamp extends OperationStamp {
    readonly type: "insert";
}
/**
 * {@link OperationStamp} for a 'set remove' operation. This aligns with the `markRangeRemoved` API in MergeTree.
 *
 * @remarks The terminology here comes from the fact that the removal should affect only the *set* of nodes that were
 * specified at the time the local client issued the remove, and not any nodes that were inserted concurrently.
 *
 * Not using "remove" and "obliterate" here allows us to unambiguously use the term "remove" elsewhere in code to mean
 * "removed from the tree, either by MergeTree.obliterateRange or MergeTree.removeRange". This is convenient as the vast majority
 * of merge-tree code only cares about segment visibility and not the specific operation that caused a segment to be removed.
 */
export interface SetRemoveOperationStamp extends OperationStamp {
    readonly type: "setRemove";
}
/**
 * {@link OperationStamp} for a 'set remove' operation. This aligns with the `obliterateRange` API in MergeTree.
 *
 * @remarks The terminology here comes from the fact that the removal should affect the *slice* of nodes between the
 * start and end point specified by the local client, which includes any nodes that were inserted concurrently.
 *
 * Not using "remove" and "obliterate" here allows us to unambiguously use the term "remove" elsewhere in code to mean
 * "removed from the tree, either by MergeTree.obliterateRange or MergeTree.removeRange". This is convenient as the vast majority
 * of merge-tree code only cares about segment visibility and not the specific operation that caused a segment to be removed.
 */
export interface SliceRemoveOperationStamp extends OperationStamp {
    readonly type: "sliceRemove";
}
export type RemoveOperationStamp = SetRemoveOperationStamp | SliceRemoveOperationStamp;
export declare function lessThan(a: OperationStamp, b: OperationStamp): boolean;
export declare function gte(a: OperationStamp, b: OperationStamp): boolean;
export declare function greaterThan(a: OperationStamp, b: OperationStamp): boolean;
export declare function lte(a: OperationStamp, b: OperationStamp): boolean;
export declare function equal(a: OperationStamp, b: OperationStamp): boolean;
export declare function isLocal(a: OperationStamp): boolean;
export declare function isAcked(a: OperationStamp): boolean;
/**
 * Inserts a stamp into a sorted list of stamps in the correct (sorted) position.
 *
 * Beware that this uses Array.splice, thus requires asymptotics considerations.
 * If inserting a variable number of timestamps, consider just pushing them and sorting the list
 * after using {@link compare} instead.
 */
export declare function spliceIntoList(list: OperationStamp[], stamp: OperationStamp): void;
export declare function hasAnyAckedOperation(list: OperationStamp[]): boolean;
export declare function compare(a: OperationStamp, b: OperationStamp): number;
//# sourceMappingURL=stamps.d.ts.map