concurrent

package
v0.0.0-...-24ca9bf Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultSliceCheck float64 = 0.20
	DefaultSliceAlloc float64 = 2.00
)
View Source
var (
	// Delay is used to set variable time delays for testing purposes.
	Delay int = 1e3
)

Functions

func RandString

func RandString(n int) string

RandString fast get rand string, time cost 200 ns

func RandomString

func RandomString(n int) string

func RandomlyTimedString

func RandomlyTimedString(msg string) <-chan string

Types

type Dict

type Dict[K constraints.Ordered, V any] interface {
	GetSetter[K, V]
	KVLister[K, V]
}

type GetSetter

type GetSetter[K constraints.Ordered, V any] interface {
	Get(key K) (value V, ok bool)
	Set(key K, value V) error
}

type GlobalVar

type GlobalVar[T any] struct {
	// contains filtered or unexported fields
}

func (*GlobalVar[T]) Get

func (v *GlobalVar[T]) Get() T

func (*GlobalVar[T]) Set

func (v *GlobalVar[T]) Set(t T)

func (*GlobalVar[T]) String

func (v *GlobalVar[T]) String() string

type KVLister

type KVLister[K constraints.Ordered, V any] interface {
	Keys() []K
	Values() []V
}

type Slc

type Slc[T any] []T // sorted in alphabetical order ...

func CheckSize

func CheckSize[T any](plist *Slc[T]) *Slc[T]

CheckSize accepts a pointer to a slice and checks to see if the len of a slice is within 20% of the capacity of the slice and reallocates if necessary.

If the capacity is still sufficient, it returns the initial pointer unchanged.

If the capacity is insufficient, it allocates a new slice, sets the old slice equal to the new slice, and returns a pointer to the new slice.

The default 20% warning and 200% allocation can be overridden by setting the config variables DefaultSliceCheck and DefaultSliceAlloc, respectively.

func NewList

func NewList[T any](n int) Slc[T]

func (*Slc[T]) Append

func (l *Slc[T]) Append(v T)

func (Slc[T]) Len

func (l Slc[T]) Len() int

func (Slc[T]) Less

func (l Slc[T]) Less(i, j int) bool

func (Slc[T]) Swap

func (l Slc[T]) Swap(i, j int)

Jump to

Keyboard shortcuts

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