Skip to main content
Version: v1

SortedSegmentSet Class

Stores a unique and sorted set of segments, or objects with segments

This differs from a normal sorted set in that the keys are not fixed. The segments are sorted via their ordinals which can change as the merge tree is modified. Even though the values of the ordinals can change their ordering and uniqueness cannot, so the order of a set of segments ordered by their ordinals will always have the same order even if the ordinal values on the segments changes. This invariant allows ensure the segments stay ordered and unique, and that new segments can be inserted into that order.

Signature

export declare class SortedSegmentSet<T extends ISegment | {
readonly segment: ISegment;
} = ISegment>

Type Parameters

Parameter Constraint Default Description
T ISegment | { readonly segment: ISegment ISegment

Properties

Property Type Description
items readonly T[]
segment ISegment
size number

Methods

Method Return Type Description
addOrUpdate(newItem, update) void
has(item) boolean
remove(item) boolean

Property Details

items

Signature
get items(): readonly T[];

Type: readonly T[]

segment

Signature
readonly segment: ISegment;

Type: ISegment

size

Signature
get size(): number;

Type: number

Method Details

addOrUpdate

Signature
addOrUpdate(newItem: T, update?: (existingItem: T, newItem: T) => T): void;

Parameters

Parameter Modifiers Type Description
newItem T
update optional (existingItem: T, newItem: T) => T

has

Signature
has(item: T): boolean;

Parameters

Parameter Type Description
item T

Returns

Return type: boolean

remove

Signature
remove(item: T): boolean;

Parameters

Parameter Type Description
item T

Returns

Return type: boolean