set

package module
v0.0.0-...-c0328d5 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2025 License: GPL-3.0 Imports: 0 Imported by: 4

Documentation

Overview

Example
package main

import (
	"fmt"

	"alon.kr/x/set"
)

func main() {
	s := set.New[int]()
	s.Add(1)
	s.Add(2)
	s.Add(3)
	s.Remove(2)

	if !s.Contains(2) {
		fmt.Println("does not contains 2")
	}

	if s.Contains(3) {
		fmt.Println("contains 3")
	}

	if len(s) == 2 {
		fmt.Println("length is 2")
	}

}
Output:

does not contains 2
contains 3
length is 2

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set[T comparable] map[T]struct{}

func FromSlice

func FromSlice[T comparable](slice []T) Set[T]

func New

func New[T comparable]() Set[T]

func (Set[T]) Add

func (s Set[T]) Add(value T)

func (Set[T]) Contains

func (s Set[T]) Contains(value T) bool

func (Set[T]) Copy

func (s Set[T]) Copy() Set[T]

func (Set[T]) Difference

func (s Set[T]) Difference(other Set[T]) Set[T]

func (Set[T]) Equals

func (s Set[T]) Equals(other Set[T]) bool

func (Set[T]) Intersection

func (s Set[T]) Intersection(other Set[T]) Set[T]

func (Set[T]) Remove

func (s Set[T]) Remove(value T)

func (Set[T]) ToSlice

func (s Set[T]) ToSlice() []T

func (Set[T]) Union

func (s Set[T]) Union(other Set[T]) Set[T]

Jump to

Keyboard shortcuts

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