Typeberry by Fluffy Labs - v0.4.0
    Preparing search index...

    Class SortedSet<V>

    Collection of elements of type V that has some strict ordering and does not have duplicates.

    The items are stored sorted, which allows logarithmic insertion & lookup and obviously in-order iteration.

    Duplicates are not allowed. Inserting an existing item is no-op.

    Type Parameters

    • V

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    array: V[]
    comparator: Comparator<V>

    Accessors

    Methods

    • Return the exact (in terms of comparator) element that's in the array if present.

      Note this API might look redundant on a first glance, but it really depends on the comparator. We might have a complex object inside the array, yet the comparator will consider two objects equal just by looking at the id. With this API we are able to retrieve the exact object that's stored.

      Parameters

      Returns V | undefined

    • Insert given element to the sorted set EVEN IF it's already present.

      Putting another value that's equal via comparator will replace the current one.

      Parameters

      Returns void