Scoop API

scoop:scoop.std:0.1.0

src/collections/sorted.scoop

Selected production source · src/collections/sorted.scoop

1package scoop.collections
3import scoop.comparisons.Comparator
5/**
6 * A map ordered by its comparator, with nearest-key queries returning None when no bound exists.
7 */
8public interface SortedMap<K, V> : Map<K, V> {
9 /**
10 * The comparator used for ordering and, for ordered maps/sets, equivalence.
11 */
12 public val comparator: Comparator<K>
13 /**
14 * Returns the least-key entry, or None when empty.
15 */
16 public fun firstEntryOrNone(): Map.Entry<K, V>?
17 /**
18 * Returns the greatest-key entry, or None when empty.
19 */
20 public fun lastEntryOrNone(): Map.Entry<K, V>?
21 /**
22 * Returns the greatest entry strictly below the key, or None.
23 */
24 public fun lowerEntry(key: K): Map.Entry<K, V>?
25 /**
26 * Returns the greatest entry at or below the key, or None.
27 */
28 public fun floorEntry(key: K): Map.Entry<K, V>?
29 /**
30 * Returns the least entry at or above the key, or None.
31 */
32 public fun ceilingEntry(key: K): Map.Entry<K, V>?
33 /**
34 * Returns the least entry strictly above the key, or None.
35 */
36 public fun higherEntry(key: K): Map.Entry<K, V>?
39/**
40 * An ordered map supporting mutation while preserving its comparator-based key order.
41 */
42public interface MutableSortedMap<K, V> : SortedMap<K, V>, MutableMap<K, V> {}
44/**
45 * A set ordered by its comparator, with nearest-element queries returning None when no bound
46 * exists.
47 */
48public interface SortedSet<T> : Set<T> {
49 /**
50 * The comparator used for ordering and, for ordered maps/sets, equivalence.
51 */
52 public val comparator: Comparator<T>
53 /**
54 * Returns the least element, or None when empty.
55 */
56 public fun firstOrNone(): T?
57 /**
58 * Returns the greatest element, or None when empty.
59 */
60 public fun lastOrNone(): T?
61 /**
62 * Returns the greatest element strictly below the argument, or None.
63 */
64 public fun lower(element: T): T?
65 /**
66 * Returns the greatest element at or below the argument, or None.
67 */
68 public fun floor(element: T): T?
69 /**
70 * Returns the least element at or above the argument, or None.
71 */
72 public fun ceiling(element: T): T?
73 /**
74 * Returns the least element strictly above the argument, or None.
75 */
76 public fun higher(element: T): T?
79/**
80 * An ordered set supporting membership changes.
81 */
82public interface MutableSortedSet<T> : SortedSet<T>, MutableSet<T> {}