strmap

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Str2Str

type Str2Str struct {
	// contains filtered or unexported fields
}

Str2Str uses StrMap and strstore.StrStore to store map[string]string

func NewStr2Str

func NewStr2Str() *Str2Str

func NewStr2StrFromMap

func NewStr2StrFromMap(m map[string]string) *Str2Str

NewStr2StrFromMap creates StrMapStr2Str from map.

func NewStr2StrFromSlice

func NewStr2StrFromSlice(kk, vv []string) *Str2Str

NewStr2StrFromSlice creates StrMapStr2Str from key, value slices.

func (*Str2Str) Get

func (sm *Str2Str) Get(k string) (string, bool)

Get ...

func (*Str2Str) Len

func (sm *Str2Str) Len() int

Len returns the size of map

func (*Str2Str) LoadFromMap

func (sm *Str2Str) LoadFromMap(m map[string]string) error

LoadFromMap resets Str2Str and loads from map.

func (*Str2Str) LoadFromSlice

func (sm *Str2Str) LoadFromSlice(kk, vv []string) error

LoadFromSlice resets Str2Str and loads from slices.

type StrMap

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

StrMap represents GC friendly readonly string map implementation. type V must NOT contain pointer for performance concern.

func New

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

New creates a StrMap instance,

func NewFromMap

func NewFromMap[V any](m map[string]V) *StrMap[V]

NewFromMap creates StrMap from map

func NewFromSlice

func NewFromSlice[V any](kk []string, vv []V) *StrMap[V]

NewFromSlice creates StrMap from slices, len(kk) must equal to len(vv)

func (*StrMap[V]) Get

func (m *StrMap[V]) Get(s string) (t V, ok bool)

Get ...

func (*StrMap[V]) Item

func (m *StrMap[V]) Item(i int) (string, V)

Item returns the i'th item in map. It panics if i is not in the range [0, Len()).

func (*StrMap[V]) Len

func (m *StrMap[V]) Len() int

Len returns the size of map

func (*StrMap[V]) LoadFromMap

func (p *StrMap[V]) LoadFromMap(m map[string]V) error

LoadFromMap resets StrMap and loads from map

func (*StrMap[V]) LoadFromSlice

func (m *StrMap[V]) LoadFromSlice(kk []string, vv []V) error

LoadFromSlice resets StrMap and loads from slices, len(kk) must equal to len(vv)

func (*StrMap[V]) String

func (m *StrMap[V]) String() string

String ...

Jump to

Keyboard shortcuts

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