ds

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SafeMap

type SafeMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

SafeMap is a thread-safe wrapper around a Map.

func NewSafeMap

func NewSafeMap[K comparable, V any]() *SafeMap[K, V]

New creates a new SafeMap.

func (*SafeMap[K, V]) Add

func (s *SafeMap[K, V]) Add(key K, value V)

Add inserts an key with value into the map.

func (*SafeMap[K, V]) Delete

func (s *SafeMap[K, V]) Delete(key K)

Delete removes an key from the map.

func (*SafeMap[K, V]) Get

func (s *SafeMap[K, V]) Get(key K) V

Get return an value with key from the map.

func (*SafeMap[K, V]) GetWithLookup

func (s *SafeMap[K, V]) GetWithLookup(key K) (V, bool)

GetWithLookup return an value and do lookup from the map.

func (*SafeMap[K, V]) Has

func (s *SafeMap[K, V]) Has(key K) bool

Has checks whether the key exists in the map.

func (*SafeMap[K, V]) Keys

func (s *SafeMap[K, V]) Keys() []K

Items returns all keys in the map as slices.

func (*SafeMap[K, V]) Len

func (s *SafeMap[K, V]) Len() int

Len returns the number of items in the map.

func (*SafeMap[K, V]) Values

func (s *SafeMap[K, V]) Values() []V

Items returns all values in the map as slices.

type SafeSet

type SafeSet[T comparable] struct {
	// contains filtered or unexported fields
}

SafeSet is a thread-safe wrapper around a Set.

func NewSafeSet

func NewSafeSet[T comparable]() *SafeSet[T]

New creates a new SafeSet.

func (*SafeSet[T]) Add

func (s *SafeSet[T]) Add(item T)

Add inserts an item into the set.

func (*SafeSet[T]) Delete

func (s *SafeSet[T]) Delete(item T)

Delete removes an item from the set.

func (*SafeSet[T]) Has

func (s *SafeSet[T]) Has(item T) bool

Has checks whether the item exists in the set.

func (*SafeSet[T]) Items

func (s *SafeSet[T]) Items() []T

Items returns all items in the set as a slice.

func (*SafeSet[T]) Len

func (s *SafeSet[T]) Len() int

Len returns the number of items in the set.

type Set

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

Set is a basic non-thread-safe generic set.

func NewSet

func NewSet[T comparable]() *Set[T]

New creates a new Set.

func (*Set[T]) Add

func (s *Set[T]) Add(item T)

Add inserts an item into the set.

func (*Set[T]) Delete

func (s *Set[T]) Delete(item T)

Delete removes an item from the set.

func (*Set[T]) Has

func (s *Set[T]) Has(item T) bool

Has checks whether the item exists in the set.

func (*Set[T]) Items

func (s *Set[T]) Items() []T

Items returns all items in the set as a slice.

func (*Set[T]) Len

func (s *Set[T]) Len() int

Len returns the number of items in the set.

Jump to

Keyboard shortcuts

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