Skip to content

Modern OrderedSet OrderedSet

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › OrderedSet › OrderedSet › OrderedSet

OrderedSet

Holds each value at most once, kept in sorted order.

Syntax

OrderedSet( of T )

Notes

  • Iteration is in ascending order, always -- and Items( ) comes back sorted, so it needs no sort afterwards.
  • The ordering contract is < on T, with no hash and no = required.
  • containers.Set unless the order is what you need: O(1) against O(log n).
  • It also offers what a hash set cannot: TryFirst, TryLast, TryFloor and TryCeiling.

Examples

#import "std/containers"
using containers

dim s as OrderedSet( of integer )
s.Add( 30 ) : s.Add( 10 ) : s.Add( 20 )

for each v in s
    print v;                 '' 10 20 30
next
print

'' The navigation a hash set cannot offer
dim as integer v
if s.TryCeiling( 15, v ) then print v         '' 20

Library: OrderedSet
Category: OrderedSet
Documented under: Members

Clone this wiki locally