set

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package set provides OOP-style sets.

For better performance, all functions in this package and its subpackages are unsafe for concurrency unless otherwise specified.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set[Item any] interface {
	container.Container[Item]
	container.Filter[Item]

	// ContainsItem reports whether the item x is in the set.
	ContainsItem(x Item) bool

	// ContainsSet reports whether the set s is a subset of this set.
	ContainsSet(s Set[Item]) bool

	// ContainsAny reports whether any item in c is in this set.
	//
	// If c is nil or empty, it returns false.
	ContainsAny(c container.Container[Item]) bool

	// Add adds x to the set.
	Add(x ...Item)

	// Remove removes x from the set.
	//
	// It does nothing for the items in x that are not in the set.
	Remove(x ...Item)

	// Union adds the items in s to this set.
	// That is, perform the following assignment:
	//
	//	thisSet = thisSet ∪ s
	Union(s Set[Item])

	// Intersect removes the items not in s.
	// That is, perform the following assignment:
	//
	//	thisSet = thisSet ∩ s
	Intersect(s Set[Item])

	// Subtract removes the items in s.
	// That is, perform the following assignment:
	//
	//	thisSet = thisSet \ s
	Subtract(s Set[Item])

	// DisjunctiveUnion removes the items both in s and this set and
	// adds the items only in s.
	// That is, perform the following assignment:
	//
	//	thisSet = thisSet △ s
	DisjunctiveUnion(s Set[Item])

	// Clear removes all items in the set and asks to release the memory.
	Clear()
}

Set is an interface representing a set.

Set guarantees to contain no duplicate items.

Directories

Path Synopsis
Package mapset provides an implementation of interface github.com/donyori/container/set.Set based on Go map.
Package mapset provides an implementation of interface github.com/donyori/container/set.Set based on Go map.

Jump to

Keyboard shortcuts

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