dataext

package
v0.0.550 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyStack = errors.New("stack is empty")

Functions

func ObjectMerge added in v0.0.20

func ObjectMerge[T1 any, T2 any](base T1, override T2) T1

func StructHash added in v0.0.32

func StructHash(dat any, opt ...StructHashOptions) (r []byte, err error)

Types

type BufferedReadCloser

type BufferedReadCloser interface {
	io.ReadCloser
	BufferedAll() ([]byte, error)
	Reset() error
}

func NewBufferedReadCloser

func NewBufferedReadCloser(sub io.ReadCloser) BufferedReadCloser

type CASMutex added in v0.0.446

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

CASMutex is the struct implementing RWMutex with CAS mechanism.

func NewCASMutex added in v0.0.446

func NewCASMutex() *CASMutex

func (*CASMutex) Lock added in v0.0.446

func (m *CASMutex) Lock()

Lock acquires the lock. If it is currently held by others, Lock will wait until it has a chance to acquire it.

func (*CASMutex) RLock added in v0.0.446

func (m *CASMutex) RLock()

RLock acquires the read lock. If it is currently held by others writing, RLock will wait until it has a chance to acquire it.

func (*CASMutex) RLocker added in v0.0.446

func (m *CASMutex) RLocker() sync.Locker

RLocker returns a Locker interface that implements the Lock and Unlock methods by calling CASMutex.RLock and CASMutex.RUnlock.

func (*CASMutex) RTryLock added in v0.0.446

func (m *CASMutex) RTryLock() bool

RTryLock attempts to acquire the read lock without blocking. Return false if someone is writing it now.

func (*CASMutex) RTryLockWithContext added in v0.0.446

func (m *CASMutex) RTryLockWithContext(ctx context.Context) bool

RTryLockWithContext attempts to acquire the read lock, blocking until resources are available or ctx is done (timeout or cancellation).

func (*CASMutex) RTryLockWithTimeout added in v0.0.446

func (m *CASMutex) RTryLockWithTimeout(duration time.Duration) bool

RTryLockWithTimeout attempts to acquire the read lock within a period of time. Return false if spending time is more than duration and no chance to acquire it.

func (*CASMutex) RUnlock added in v0.0.446

func (m *CASMutex) RUnlock()

RUnlock releases the read lock.

func (*CASMutex) TryLock added in v0.0.446

func (m *CASMutex) TryLock() bool

TryLock attempts to acquire the lock without blocking. Return false if someone is holding it now.

func (*CASMutex) TryLockWithContext added in v0.0.446

func (m *CASMutex) TryLockWithContext(ctx context.Context) bool

TryLockWithContext attempts to acquire the lock, blocking until resources are available or ctx is done (timeout or cancellation).

func (*CASMutex) TryLockWithTimeout added in v0.0.446

func (m *CASMutex) TryLockWithTimeout(duration time.Duration) bool

TryLockWithTimeout attempts to acquire the lock within a period of time. Return false if spending time is more than duration and no chance to acquire it.

func (*CASMutex) Unlock added in v0.0.446

func (m *CASMutex) Unlock()

Unlock releases the lock.

type JsonOpt added in v0.0.419

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

func EmptyJsonOpt added in v0.0.542

func EmptyJsonOpt[T any]() JsonOpt[T]

func NewJsonOpt added in v0.0.542

func NewJsonOpt[T any](v T) JsonOpt[T]

func (JsonOpt[T]) IfSet added in v0.0.516

func (m JsonOpt[T]) IfSet(fn func(v T)) bool

func (JsonOpt[T]) IsSet added in v0.0.419

func (m JsonOpt[T]) IsSet() bool

func (JsonOpt[T]) IsUnset added in v0.0.419

func (m JsonOpt[T]) IsUnset() bool

func (JsonOpt[T]) MarshalJSON added in v0.0.419

func (m JsonOpt[T]) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of m.

func (JsonOpt[T]) MustValue added in v0.0.419

func (m JsonOpt[T]) MustValue() T

func (*JsonOpt[T]) UnmarshalJSON added in v0.0.419

func (m *JsonOpt[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *m to a copy of data.

func (JsonOpt[T]) Value added in v0.0.419

func (m JsonOpt[T]) Value() (T, bool)

func (JsonOpt[T]) ValueDblPtrOrNil added in v0.0.544

func (m JsonOpt[T]) ValueDblPtrOrNil() **T

func (JsonOpt[T]) ValueOrNil added in v0.0.419

func (m JsonOpt[T]) ValueOrNil() *T

type LRUMap

type LRUMap[TKey comparable, TData any] struct {
	// contains filtered or unexported fields
}

func NewLRUMap

func NewLRUMap[TKey comparable, TData any](size int) *LRUMap[TKey, TData]

func (*LRUMap[TKey, TData]) Put

func (c *LRUMap[TKey, TData]) Put(key TKey, value TData)

func (*LRUMap[TKey, TData]) Size

func (c *LRUMap[TKey, TData]) Size() int

func (*LRUMap[TKey, TData]) TryGet

func (c *LRUMap[TKey, TData]) TryGet(key TKey) (TData, bool)

type Nonuple added in v0.0.255

type Nonuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any, T8 any, T9 any] struct {
	V1 T1
	V2 T2
	V3 T3
	V4 T4
	V5 T5
	V6 T6
	V7 T7
	V8 T8
	V9 T9
}

func NewNonuple added in v0.0.517

func NewNonuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any, T8 any, T9 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5, v6 T6, v7 T7, v8 T8, v9 T9) Nonuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]

func NewTuple9 added in v0.0.517

func NewTuple9[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any, T8 any, T9 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5, v6 T6, v7 T7, v8 T8, v9 T9) Nonuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]

func (Nonuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]) TupleLength added in v0.0.255

func (t Nonuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]) TupleLength() int

func (Nonuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]) TupleValues added in v0.0.255

func (t Nonuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]) TupleValues() []any

type Octuple added in v0.0.255

type Octuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any, T8 any] struct {
	V1 T1
	V2 T2
	V3 T3
	V4 T4
	V5 T5
	V6 T6
	V7 T7
	V8 T8
}

func NewOctuple added in v0.0.517

func NewOctuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any, T8 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5, v6 T6, v7 T7, v8 T8) Octuple[T1, T2, T3, T4, T5, T6, T7, T8]

func NewTuple8 added in v0.0.517

func NewTuple8[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any, T8 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5, v6 T6, v7 T7, v8 T8) Octuple[T1, T2, T3, T4, T5, T6, T7, T8]

func (Octuple[T1, T2, T3, T4, T5, T6, T7, T8]) TupleLength added in v0.0.255

func (t Octuple[T1, T2, T3, T4, T5, T6, T7, T8]) TupleLength() int

func (Octuple[T1, T2, T3, T4, T5, T6, T7, T8]) TupleValues added in v0.0.255

func (t Octuple[T1, T2, T3, T4, T5, T6, T7, T8]) TupleValues() []any

type Quadruple added in v0.0.255

type Quadruple[T1 any, T2 any, T3 any, T4 any] struct {
	V1 T1
	V2 T2
	V3 T3
	V4 T4
}

func NewQuadruple added in v0.0.517

func NewQuadruple[T1 any, T2 any, T3 any, T4 any](v1 T1, v2 T2, v3 T3, v4 T4) Quadruple[T1, T2, T3, T4]

func NewTuple4 added in v0.0.517

func NewTuple4[T1 any, T2 any, T3 any, T4 any](v1 T1, v2 T2, v3 T3, v4 T4) Quadruple[T1, T2, T3, T4]

func (Quadruple[T1, T2, T3, T4]) TupleLength added in v0.0.255

func (t Quadruple[T1, T2, T3, T4]) TupleLength() int

func (Quadruple[T1, T2, T3, T4]) TupleValues added in v0.0.255

func (t Quadruple[T1, T2, T3, T4]) TupleValues() []any

type Quintuple added in v0.0.255

type Quintuple[T1 any, T2 any, T3 any, T4 any, T5 any] struct {
	V1 T1
	V2 T2
	V3 T3
	V4 T4
	V5 T5
}

func NewQuintuple added in v0.0.517

func NewQuintuple[T1 any, T2 any, T3 any, T4 any, T5 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5) Quintuple[T1, T2, T3, T4, T5]

func NewTuple5 added in v0.0.517

func NewTuple5[T1 any, T2 any, T3 any, T4 any, T5 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5) Quintuple[T1, T2, T3, T4, T5]

func (Quintuple[T1, T2, T3, T4, T5]) TupleLength added in v0.0.255

func (t Quintuple[T1, T2, T3, T4, T5]) TupleLength() int

func (Quintuple[T1, T2, T3, T4, T5]) TupleValues added in v0.0.255

func (t Quintuple[T1, T2, T3, T4, T5]) TupleValues() []any

type RingBuffer added in v0.0.523

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

func NewRingBuffer added in v0.0.523

func NewRingBuffer[T any](capacity int) *RingBuffer[T]

func (*RingBuffer[T]) At added in v0.0.523

func (rb *RingBuffer[T]) At(i int) T

func (*RingBuffer[T]) Capacity added in v0.0.523

func (rb *RingBuffer[T]) Capacity() int

func (*RingBuffer[T]) Clear added in v0.0.523

func (rb *RingBuffer[T]) Clear()

func (*RingBuffer[T]) Get added in v0.0.523

func (rb *RingBuffer[T]) Get(i int) (T, bool)

func (*RingBuffer[T]) IsFull added in v0.0.523

func (rb *RingBuffer[T]) IsFull() bool

func (*RingBuffer[T]) Items added in v0.0.523

func (rb *RingBuffer[T]) Items() []T

func (*RingBuffer[T]) Iter added in v0.0.523

func (rb *RingBuffer[T]) Iter() iter.Seq[T]

func (*RingBuffer[T]) Iter2 added in v0.0.523

func (rb *RingBuffer[T]) Iter2() iter.Seq2[int, T]

func (*RingBuffer[T]) Peek added in v0.0.523

func (rb *RingBuffer[T]) Peek() (T, bool)

func (*RingBuffer[T]) Push added in v0.0.523

func (rb *RingBuffer[T]) Push(item T)

func (*RingBuffer[T]) PushPop added in v0.0.543

func (rb *RingBuffer[T]) PushPop(item T) *T

func (*RingBuffer[T]) Remove added in v0.0.543

func (rb *RingBuffer[T]) Remove(fnEqual func(v T) bool) int

func (*RingBuffer[T]) Size added in v0.0.523

func (rb *RingBuffer[T]) Size() int

type Septuple added in v0.0.255

type Septuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any] struct {
	V1 T1
	V2 T2
	V3 T3
	V4 T4
	V5 T5
	V6 T6
	V7 T7
}

func NewSeptuple added in v0.0.517

func NewSeptuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5, v6 T6, v7 T7) Septuple[T1, T2, T3, T4, T5, T6, T7]

func NewTuple7 added in v0.0.517

func NewTuple7[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5, v6 T6, v7 T7) Septuple[T1, T2, T3, T4, T5, T6, T7]

func (Septuple[T1, T2, T3, T4, T5, T6, T7]) TupleLength added in v0.0.255

func (t Septuple[T1, T2, T3, T4, T5, T6, T7]) TupleLength() int

func (Septuple[T1, T2, T3, T4, T5, T6, T7]) TupleValues added in v0.0.255

func (t Septuple[T1, T2, T3, T4, T5, T6, T7]) TupleValues() []any

type Sextuple added in v0.0.255

type Sextuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any] struct {
	V1 T1
	V2 T2
	V3 T3
	V4 T4
	V5 T5
	V6 T6
}

func NewSextuple added in v0.0.517

func NewSextuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5, v6 T6) Sextuple[T1, T2, T3, T4, T5, T6]

func NewTuple6 added in v0.0.517

func NewTuple6[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5, v6 T6) Sextuple[T1, T2, T3, T4, T5, T6]

func (Sextuple[T1, T2, T3, T4, T5, T6]) TupleLength added in v0.0.255

func (t Sextuple[T1, T2, T3, T4, T5, T6]) TupleLength() int

func (Sextuple[T1, T2, T3, T4, T5, T6]) TupleValues added in v0.0.255

func (t Sextuple[T1, T2, T3, T4, T5, T6]) TupleValues() []any

type Single added in v0.0.255

type Single[T1 any] struct {
	V1 T1
}

func NewSingle added in v0.0.517

func NewSingle[T1 any](v1 T1) Single[T1]

func NewTuple1 added in v0.0.517

func NewTuple1[T1 any](v1 T1) Single[T1]

func (Single[T1]) TupleLength added in v0.0.255

func (s Single[T1]) TupleLength() int

func (Single[T1]) TupleValues added in v0.0.255

func (s Single[T1]) TupleValues() []any

type Stack added in v0.0.61

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

func NewStack added in v0.0.61

func NewStack[T any](threadsafe bool, initialCapacity int) *Stack[T]

func (*Stack[T]) Empty added in v0.0.63

func (s *Stack[T]) Empty() bool

func (*Stack[T]) Length added in v0.0.62

func (s *Stack[T]) Length() int

func (*Stack[T]) OptPeek added in v0.0.61

func (s *Stack[T]) OptPeek() *T

func (*Stack[T]) OptPop added in v0.0.61

func (s *Stack[T]) OptPop() *T

func (*Stack[T]) Peek added in v0.0.61

func (s *Stack[T]) Peek() (T, error)

func (*Stack[T]) Pop added in v0.0.61

func (s *Stack[T]) Pop() (T, error)

func (*Stack[T]) Push added in v0.0.61

func (s *Stack[T]) Push(v T)

type StructHashOptions added in v0.0.32

type StructHashOptions struct {
	HashAlgo    hash.Hash
	Tag         *string
	SkipChannel bool
	SkipFunc    bool
}

type SyncMap added in v0.0.362

type SyncMap[TKey comparable, TData any] struct {
	// contains filtered or unexported fields
}

func NewSyncMap added in v0.0.543

func NewSyncMap[TKey comparable, TData any]() *SyncMap[TKey, TData]

func (*SyncMap[TKey, TData]) Contains added in v0.0.362

func (s *SyncMap[TKey, TData]) Contains(key TKey) bool

func (*SyncMap[TKey, TData]) Delete added in v0.0.362

func (s *SyncMap[TKey, TData]) Delete(key TKey) bool

func (*SyncMap[TKey, TData]) Get added in v0.0.362

func (s *SyncMap[TKey, TData]) Get(key TKey) (TData, bool)

func (*SyncMap[TKey, TData]) GetAllKeys added in v0.0.362

func (s *SyncMap[TKey, TData]) GetAllKeys() []TKey

func (*SyncMap[TKey, TData]) GetAllValues added in v0.0.362

func (s *SyncMap[TKey, TData]) GetAllValues() []TData

func (*SyncMap[TKey, TData]) GetAndSetIfNotContains added in v0.0.446

func (s *SyncMap[TKey, TData]) GetAndSetIfNotContains(key TKey, data TData) TData

func (*SyncMap[TKey, TData]) GetAndSetIfNotContainsFunc added in v0.0.447

func (s *SyncMap[TKey, TData]) GetAndSetIfNotContainsFunc(key TKey, data func() TData) TData

func (*SyncMap[TKey, TData]) Set added in v0.0.362

func (s *SyncMap[TKey, TData]) Set(key TKey, data TData)

func (*SyncMap[TKey, TData]) SetIfNotContains added in v0.0.362

func (s *SyncMap[TKey, TData]) SetIfNotContains(key TKey, data TData) bool

func (*SyncMap[TKey, TData]) SetIfNotContainsFunc added in v0.0.447

func (s *SyncMap[TKey, TData]) SetIfNotContainsFunc(key TKey, data func() TData) bool

type SyncRingSet added in v0.0.543

type SyncRingSet[TData comparable] struct {
	// contains filtered or unexported fields
}

func NewSyncRingSet added in v0.0.543

func NewSyncRingSet[TData comparable](capacity int) *SyncRingSet[TData]

func (*SyncRingSet[TData]) Add added in v0.0.543

func (s *SyncRingSet[TData]) Add(value TData) bool

Add adds `value` to the set returns true if the value was actually inserted (value did not exist beforehand) returns false if the value already existed

func (*SyncRingSet[TData]) AddAll added in v0.0.543

func (s *SyncRingSet[TData]) AddAll(values []TData)

func (*SyncRingSet[TData]) AddIfNotContains added in v0.0.543

func (s *SyncRingSet[TData]) AddIfNotContains(key TData) bool

AddIfNotContains returns true if the value was actually added (value did not exist beforehand) returns false if the value already existed

func (*SyncRingSet[TData]) Contains added in v0.0.543

func (s *SyncRingSet[TData]) Contains(value TData) bool

func (*SyncRingSet[TData]) Get added in v0.0.543

func (s *SyncRingSet[TData]) Get() []TData

func (*SyncRingSet[TData]) Remove added in v0.0.543

func (s *SyncRingSet[TData]) Remove(value TData) bool

func (*SyncRingSet[TData]) RemoveAll added in v0.0.543

func (s *SyncRingSet[TData]) RemoveAll(values []TData)

func (*SyncRingSet[TData]) RemoveIfContains added in v0.0.543

func (s *SyncRingSet[TData]) RemoveIfContains(key TData) bool

RemoveIfContains returns true if the value was actually removed (value did exist beforehand) returns false if the value did not exist in the set

type SyncSet added in v0.0.43

type SyncSet[TData comparable] struct {
	// contains filtered or unexported fields
}

func NewSyncSet added in v0.0.543

func NewSyncSet[TData comparable]() *SyncSet[TData]

func (*SyncSet[TData]) Add added in v0.0.43

func (s *SyncSet[TData]) Add(value TData) bool

Add adds `value` to the set returns true if the value was actually inserted (value did not exist beforehand) returns false if the value already existed

func (*SyncSet[TData]) AddAll added in v0.0.43

func (s *SyncSet[TData]) AddAll(values []TData)

func (*SyncSet[TData]) AddIfNotContains added in v0.0.543

func (s *SyncSet[TData]) AddIfNotContains(key TData) bool

AddIfNotContains returns true if the value was actually added (value did not exist beforehand) returns false if the value already existed

func (*SyncSet[TData]) Contains added in v0.0.43

func (s *SyncSet[TData]) Contains(value TData) bool

func (*SyncSet[TData]) Get added in v0.0.43

func (s *SyncSet[TData]) Get() []TData

func (*SyncSet[TData]) Remove added in v0.0.543

func (s *SyncSet[TData]) Remove(value TData) bool

func (*SyncSet[TData]) RemoveAll added in v0.0.543

func (s *SyncSet[TData]) RemoveAll(values []TData)

func (*SyncSet[TData]) RemoveIfContains added in v0.0.543

func (s *SyncSet[TData]) RemoveIfContains(key TData) bool

RemoveIfContains returns true if the value was actually removed (value did exist beforehand) returns false if the value did not exist in the set

type Triple added in v0.0.255

type Triple[T1 any, T2 any, T3 any] struct {
	V1 T1
	V2 T2
	V3 T3
}

func NewTriple added in v0.0.517

func NewTriple[T1 any, T2 any, T3 any](v1 T1, v2 T2, v3 T3) Triple[T1, T2, T3]

func NewTuple3 added in v0.0.517

func NewTuple3[T1 any, T2 any, T3 any](v1 T1, v2 T2, v3 T3) Triple[T1, T2, T3]

func (Triple[T1, T2, T3]) TupleLength added in v0.0.255

func (t Triple[T1, T2, T3]) TupleLength() int

func (Triple[T1, T2, T3]) TupleValues added in v0.0.255

func (t Triple[T1, T2, T3]) TupleValues() []any

type Tuple added in v0.0.255

type Tuple[T1 any, T2 any] struct {
	V1 T1
	V2 T2
}

func NewTuple added in v0.0.517

func NewTuple[T1 any, T2 any](v1 T1, v2 T2) Tuple[T1, T2]

func NewTuple2 added in v0.0.517

func NewTuple2[T1 any, T2 any](v1 T1, v2 T2) Tuple[T1, T2]

func (Tuple[T1, T2]) TupleLength added in v0.0.255

func (t Tuple[T1, T2]) TupleLength() int

func (Tuple[T1, T2]) TupleValues added in v0.0.255

func (t Tuple[T1, T2]) TupleValues() []any

type ValueGroup added in v0.0.255

type ValueGroup interface {
	TupleLength() int
	TupleValues() []any
}

Jump to

Keyboard shortcuts

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