sortedset

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

README

sortedset

?

License

GPL-3


Documentation

Overview

Copyright © 2024 Mark Summerfield. All rights reserved.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comparable

type Comparable interface {
	~string | ~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

Comparable allows only string or integer elements.

type SortedSet

type SortedSet[E Comparable] struct {
	// contains filtered or unexported fields
}

SortedSet zero value is usable. Create with statements like these: var set SortedSet[string] set := SortedSet[int]{}

func (*SortedSet[E]) All

func (me *SortedSet[E]) All() iter.Seq[E]

All returns a for .. range iterable of the set's elements, e.g., for element := range tree.All()

func (*SortedSet[E]) Clear

func (me *SortedSet[E]) Clear()

Clear deletes the entire tree. See also [Delete]

func (*SortedSet[E]) Contains

func (me *SortedSet[E]) Contains(element E) bool

Contains returns true if the element is in the tree; otherwise false. For example:

ok := set.Contains(element).

func (*SortedSet[E]) Delete

func (me *SortedSet[E]) Delete(element E) bool

Delete deletes the element-value with the given element from the set and returns true, or does nothing and returns false if there is no element-value with the given element. For example:

deleted := set.Delete(element).

See also [Clear]

func (*SortedSet[E]) Insert

func (me *SortedSet[E]) Insert(element E) bool

Insert inserts a new element into the Tree and returns true; or does nothing and returns false if the element is already present. For example:

ok := tree.Insert(element).

func (*SortedSet[E]) Len

func (me *SortedSet[E]) Len() int

Len returns the number of items in the tree.

Jump to

Keyboard shortcuts

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