Go_Utils

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2023 License: MIT Imports: 4 Imported by: 0

README

Go-Utils

Go Some utilities I implemented myself for future uses in Go. Usually these are some data structures or algorithms that Go STL doesn't provide or I can't find a satisfying implementation of.

Package GMUtils/Maps includes some very-fast thread-safe concurrent hashmap implementations. Package GMUtils/Tress include a balanced BST implementation called SBTree. Package GMUtils/Queues includes a circular array queue and a concurrent non-blocking linked queue.

Documentation

Index

Constants

View Source
const LogUintSize int = 5 + (bits.UintSize >> 6) //2^5==32 or 2^6==64

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicInt

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

AtomicInt backed by uintptr

func (*AtomicInt) Add

func (u *AtomicInt) Add(d int) int

func (*AtomicInt) CompareAndSwap

func (u *AtomicInt) CompareAndSwap(exp, v int) bool

func (*AtomicInt) Load

func (u *AtomicInt) Load() int

func (*AtomicInt) Store

func (u *AtomicInt) Store(v int)

func (*AtomicInt) Swap

func (u *AtomicInt) Swap(v int) int

type AtomicUint

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

AtomicUint backed by uintptr

func (*AtomicUint) Add

func (u *AtomicUint) Add(d uint) uint

func (*AtomicUint) CompareAndSwap

func (u *AtomicUint) CompareAndSwap(exp, v uint) bool

func (*AtomicUint) Load

func (u *AtomicUint) Load() uint

func (*AtomicUint) Store

func (u *AtomicUint) Store(v uint)

func (*AtomicUint) Swap

func (u *AtomicUint) Swap(v uint) uint

type BitArray added in v0.4.0

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

func NewBitArray added in v0.4.0

func NewBitArray(size uint) BitArray

func (BitArray) Clr added in v0.4.0

func (u BitArray) Clr(i int)

func (BitArray) First added in v0.4.0

func (u BitArray) First() int

func (BitArray) Get added in v0.4.0

func (u BitArray) Get(i int) bool

func (BitArray) Invert added in v0.4.0

func (u BitArray) Invert(i int) bool

func (BitArray) Len added in v0.4.0

func (u BitArray) Len() int

func (BitArray) Set added in v0.4.0

func (u BitArray) Set(i int)

func (BitArray) Uints added in v0.4.0

func (u BitArray) Uints() []uint

type Hasher added in v0.4.0

type Hasher uint

Hasher is an ailas for maphash.Seed, create it using Hasher(maphash.MakeSeed()). The receivers are thread-safe, but the memory contents aren't read in a thread-safe way, so only use it on synchronized memory.

func (Hasher) HashAny added in v0.4.0

func (u Hasher) HashAny(v any) uint

HashAny hashes an interface value based on memory content of v. It uses internal struct's memory layout, which is unsafe practice. Avoid using it.

func (Hasher) HashBytes added in v0.4.0

func (u Hasher) HashBytes(b []byte) uint

HashBytes hashes the given byte slice.

func (Hasher) HashInt added in v0.4.0

func (u Hasher) HashInt(v int) uint

HashInt hashes v.

func (Hasher) HashMem added in v0.4.0

func (u Hasher) HashMem(addr unsafe.Pointer, size uintptr) uint

HashMem hashes the memory contents in the range [addr, addr+length) as bytes.

func (Hasher) HashString added in v0.4.0

func (u Hasher) HashString(v string) uint

HashString directly hashes a string, it's faster than HashAny(string).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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