Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface {
Add(item interface{}) Interface
Delete(item interface{}) Interface
Has(item interface{}) bool
Len() int
IsEmpty() bool
Each(fn func(item interface{}) Result.Interface) Result.Interface
ToArray() Array.Interface
First() Result.Interface
Last() Result.Interface
Union(other Interface) Interface
Intersection(other Interface) Interface
Difference(other Interface) Interface
IsSubset(other Interface) bool
Equal(other Interface) bool
IsNull() bool
}
Interface is the public contract of a SortedSet composite — a collection of unique items kept permanently sorted by a caller-supplied comparator (TreeSet-like). It is the comparator-ordered sibling of Set (unordered) and OrderedSet (first-insertion order), and shares the Each/ToArray grammar with Array: iteration, ToArray and the set-algebra results are all emitted in ascending comparator order rather than Go's unspecified map order.
Items must satisfy TWO constraints, which the caller must guarantee:
- comparable, because the SortedSet is backed by a Go map for O(1) membership and dedup (exactly like a Dictionary key); and
- orderable by the less comparator passed to New, which defines a strict weak ordering used to keep items in sorted position.
Membership tests return a plain bool, fallible iteration returns a Result, First/Last return a Result (the minimum/maximum by the comparator, or an error Result when the set is empty), and every method honours the Null-Object invariant (never nil).