Returns the index of the given element in the set, or `nil` if the element is not a member
of the set.
`MarkupOrderedSet` members are always unique, so the first index of an element is always the
same as its last index.
Removes the associated stroke for the given id from the set.
- Parameter id: The id of the stroke to remove.
- Returns: The associated stroke for `id` if the set contains `id`; otherwise, `nil`.
Removes the associated element for the given id from the set.
- Parameter id: The id of the element to remove.
- Returns: The associated element for `id` if the set contains `id`; otherwise, `nil`.
Adds the given element to the set unconditionally, either appending it to the set, or replacing
an existing value if one with the same id is present.
- Parameter item: The value to append or replace.
- Returns: The element this operation replaced, or `nil` if the operation appended the value to the end of the collection.
Appends a new member to the end of the set, if the set doesn’t already contain it.
- Parameter item: The element to add to the set.
- Returns: A pair (`inserted`, `index`), where inserted is a Boolean value indicating whether the
operation added a new element, and `index` is the index of `item` in the resulting set.
method · iOS 27.0+
insert
TypeScript
insert(item: SDKHandle, index: number): { "inserted": boolean; "index": number }
Inserts a new member at the specified index, if the set doesn’t already contain it.
- Parameters:
- item: The element to insert.
- index: The index to insert at.
- Returns: A pair (`inserted`, `index`), where `inserted` is a Boolean value indicating whether the
operation added a new element, and `index` is the index of item in the resulting set. If
`inserted` is false, then the returned `index` may be different from the index requested.
Removes and returns the element at the specified position.
- Parameter index: The position of the element to remove. `index` must be a valid index of the collection that is not equal to the collection’s end index.
- Returns: The removed element.
The operation moves all elements following the specified position to close the resulting gap.
Removes the given element from the set.
- Parameter member: The element of the set to remove.
- Returns: The element equal to `member` if `member` is contained in the set; otherwise, `nil`.
Returns a Boolean value that indicates whether the given element exists in the set.
- Parameter element: An element to look for in the set.
- Returns: `true` if member exists in the set; otherwise, `false`.
Removes all the elements that satisfy the given predicate.
- Parameter shouldBeRemoved: A closure that takes an element of the set as its argument and returns a Boolean value indicating whether to remove the element from the set.