collections

package
v0.0.0-...-51300c0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MapEntry

type MapEntry[T1 comparable, T2 any] struct {
	Key   T1
	Value T2
}

type SyncMap

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

SyncMap classic synchronized map through RWMutex implementation

func NewSyncMap

func NewSyncMap[T1 comparable, T2 any]() SyncMap[T1, T2]

func (*SyncMap[T1, T2]) Clear

func (sm *SyncMap[T1, T2]) Clear()

Clear clears all entries by recreating internal map

func (*SyncMap[T1, T2]) Delete

func (sm *SyncMap[T1, T2]) Delete(key T1)

Delete key from map with write locking

func (*SyncMap[T1, T2]) Get

func (sm *SyncMap[T1, T2]) Get(key T1) (T2, bool)

Get value from map. Returns bool to check is value exists

func (*SyncMap[T1, T2]) GetSlice

func (sm *SyncMap[T1, T2]) GetSlice() []*MapEntry[T1, T2]

GetSlice returns key-value entry slice of map

func (*SyncMap[T1, T2]) Put

func (sm *SyncMap[T1, T2]) Put(key T1, value T2)

Put or replace key in the map

func (*SyncMap[T1, T2]) Size

func (sm *SyncMap[T1, T2]) Size() int

Size returns len from internal map result

type TList

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

TList Struct is to keep buffer with required time interval of incoming data in memory May be used to keep data for calculating moving average

func NewTList

func NewTList[T any](d time.Duration) TList[T]

func (*TList[T]) Append

func (t *TList[T]) Append(data T, tm time.Time) bool

Append data to the end of list and remove first elements out of data Returns true if at least one element was removed

func (TList[T]) First

func (t TList[T]) First() *TListNode[T]

func (TList[T]) GetSize

func (t TList[T]) GetSize() uint

func (TList[T]) IsEmpty

func (t TList[T]) IsEmpty() bool

func (TList[T]) Last

func (t TList[T]) Last() *TListNode[T]

func (*TList[T]) RemoveFirst

func (t *TList[T]) RemoveFirst() bool

RemoveFirst removes first element from TList

func (TList[T]) String

func (t TList[T]) String() string

type TListNode

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

func (TListNode[T]) GetData

func (n TListNode[T]) GetData() T

func (TListNode[T]) GetTime

func (n TListNode[T]) GetTime() time.Time

func (TListNode[T]) Next

func (n TListNode[T]) Next() *TListNode[T]

Jump to

Keyboard shortcuts

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