manager

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package manager provides a common object manager.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager[V any] struct {
	// contains filtered or unexported fields
}

Manager is used to manage a kind of objects.

func New

func New[V any]() *Manager[V]

New returns a new manager.

func (*Manager[V]) Add

func (m *Manager[V]) Add(id string, v V)

Add adds the value v with the id.

If exists, override it.

func (*Manager[V]) Adds

func (m *Manager[V]) Adds(vs map[string]V)

Add adds the value v with the id.

If exists, override it.

func (*Manager[V]) Clear

func (m *Manager[V]) Clear()

Clear clears all the values.

func (*Manager[V]) Del

func (m *Manager[V]) Del(id string) (v V, ok bool)

Del deletes and returns the value by the id.

If not exist, do nothing and return (ZERO, false).

func (*Manager[V]) Dels

func (m *Manager[V]) Dels(ids ...string)

Dels deletes and returns the value by the id.

func (*Manager[V]) Get

func (m *Manager[V]) Get(id string) (v V, ok bool)

Get returns the value by the id.

If not exist, return (ZERO, false).

func (*Manager[V]) Gets

func (m *Manager[V]) Gets() map[string]V

Gets returns all the values, which is read-only and must not be modified.

Jump to

Keyboard shortcuts

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