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

ParameterConstraintDefaultDescription
TISegment | { readonly segment: ISegmentISegment

Properties

PropertyTypeDescription
itemsreadonly T[]
segmentISegment
sizenumber

Methods

MethodReturn TypeDescription
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

ParameterModifiersTypeDescription
newItemT
updateoptional(existingItem: T, newItem: T) => T

has

Signature

has(item: T): boolean;

Parameters

ParameterTypeDescription
itemT

Returns

Return type: boolean

remove

Signature

remove(item: T): boolean;

Parameters

ParameterTypeDescription
itemT

Returns

Return type: boolean