Skip to content

Documentation / base / OrderedStringSet

Class: OrderedStringSet ​

Defined in: libs/base/src/orderedstringset.ts:7

The OrderedStringSet class is used to create and manage an ordered set of strings. It can be configured to allow or disallow duplicate strings based on a parameter passed to the constructor.

Constructors ​

Constructor ​

new OrderedStringSet(allowDuplicates?): OrderedStringSet

Defined in: libs/base/src/orderedstringset.ts:16

Creates a new instance of the OrderedStringSet class.

Parameters ​

allowDuplicates? ​

boolean = false

A boolean value indicating whether the set should allow duplicate strings.

Returns ​

OrderedStringSet

Accessors ​

items ​

Get Signature ​

get items(): string[]

Defined in: libs/base/src/orderedstringset.ts:24

An array of all strings in the set.

Returns ​

string[]

Methods ​

add() ​

add(str): void

Defined in: libs/base/src/orderedstringset.ts:32

Adds a new string to the set. If duplicates are not allowed and the string already exists, it is not added.

Parameters ​

str ​

string

The string to add to the set.

Returns ​

void


remove() ​

remove(str): void

Defined in: libs/base/src/orderedstringset.ts:46

Removes the first occurrence of a specified string from the set using binary search. If the string does not exist, no action is taken.

Parameters ​

str ​

string

The string to remove from the set.

Returns ​

void


removeAll() ​

removeAll(str): void

Defined in: libs/base/src/orderedstringset.ts:64

Removes all elements that match a specified string from the collection. This method first locates the first matching element, then continues to search forward until it finds the first non-matching element, thereby determining the range of all consecutive matching elements. Finally, it removes these elements in a single operation. If the collection does not contain any matching elements, no action is taken.

Parameters ​

str ​

string

The string to be removed from the collection.

Returns ​

void


has() ​

has(str): boolean

Defined in: libs/base/src/orderedstringset.ts:89

Checks if the specified string exists in the collection.

Parameters ​

str ​

string

The string to search for in the collection.

Returns ​

boolean

true if the string is found in the collection; otherwise, false.

Released under the MIT License.