shadow:utility

Interface OrderedSet<E>

Interfaces

shadow:utility@Set<E>

interface OrderedSet<E is CanCompare<E>>

Interface OrderedSet<E> defines the operations that a class must implement to be an ordered set. An ordered set is used to store elements of type E. It should be possible to find elements quickly, allowing for efficient addition and retrieval. OrderedSet<E> differs from Set<E> in that elements must have some ordering defined by the CanCompare<E> interface. Because of this ordering, OrderedSet<E> is also able to define methods that manipulate ranges of element values.

See Also

Method Summary

Modifiers Return Types Method and Description
public readonly (nullable E) ceiling(E element)

Method should return the lowest-valued element whose value is greater than or equal to the given element.

public readonly (nullable E) floor(E element)

Method should return the highest-valued element whose value is less than or equal to the given element.

public readonly (E) max()

Method should return the highest-valued element in the ordered set or throw an exception if the ordered set is empty.

public readonly (E) min()

Method should return the lowest-valued element in the ordered set or throw an exception if the ordered set is empty.

public readonly (CanIterate<E>) values(E low, E high)

Method should return an iterable collection of all the elements in the ordered set whose values are in the inclusive range from the low element to the high element given.

Method Detail

ceiling

public readonly ceiling(E element) => (nullable E)

Method should return the lowest-valued element whose value is greater than or equal to the given element.

Parameters

element - element to find the floor of

Returns

ceiling of given element, or null if no such element exists

floor

public readonly floor(E element) => (nullable E)

Method should return the highest-valued element whose value is less than or equal to the given element.

Parameters

element - element to find the floor of

Returns

floor of given element, or null if no such element exists

max

public readonly max() => (E)

Method should return the highest-valued element in the ordered set or throw an exception if the ordered set is empty.

Returns

highest element

min

public readonly min() => (E)

Method should return the lowest-valued element in the ordered set or throw an exception if the ordered set is empty.

Returns

lowest element

values

public readonly values(E low, E high) => (CanIterate<E>)

Method should return an iterable collection of all the elements in the ordered set whose values are in the inclusive range from the low element to the high element given.

Parameters

low - lowest element to include in the range

high - highest element to include in the range

Returns

iterable collection of elements in the range