OrderedSet

package
v0.0.0-...-2010bc0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0

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
	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 an OrderedSet composite — a collection of unique items that remembers the order in which each item was first added. It is the insertion-ordered sibling of Set (and shares the Each/ToArray grammar with Array): iteration, ToArray and the set-algebra results are all emitted in a deterministic, first-insertion order rather than Go's unspecified map order.

Items are arbitrary comparable values (the OrderedSet is backed by a Go map for O(1) membership, so each item must be comparable, exactly like a Dictionary key). Membership tests return a plain bool, fallible iteration returns a Result, and every method honours the Null-Object invariant (never nil).

func New

func New(items ...interface{}) Interface

New creates an OrderedSet seeded with the given items, deduplicated and kept in first-seen order. Items must be comparable, since the OrderedSet is backed by a Go map for membership.

func Null

func Null() Interface

Null returns the Null-Object OrderedSet.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL