set

package
v0.0.0-...-8bd0779 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

README

From: https://github.com/weedge/lib/tree/main/container

Tips: use go1.13 +

invalid operation: 1 << i (signed shift count type int) requires go1.13 or later (-lang was set to go1.12; check go.mod)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitSet

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

func NewBitSet

func NewBitSet(len uint64) *BitSet

创建BitSet

func (*BitSet) And

func (set *BitSet) And(compare *BitSet) (res *BitSet)

& operator (set&compare -> res)

func (*BitSet) Clone

func (set *BitSet) Clone() *BitSet

Clone this BitSet

func (*BitSet) Count

func (set *BitSet) Count() uint64

https://en.wikipedia.org/wiki/Hamming_weight use variable-precision SWAR

func (*BitSet) Diff

func (set *BitSet) Diff(compare *BitSet) (res *BitSet)

diff operator (&^) return new bitset (diff(set,compare) set not compare)

func (*BitSet) Get

func (set *BitSet) Get(pos uint64) int

get in LittleEndian order (test) notice: 0<= pos < len

func (*BitSet) InPlaceDiff

func (set *BitSet) InPlaceDiff(compare *BitSet)

self diff operator (&^) return set diff compare(set~compare)

func (*BitSet) LeftShift

func (set *BitSet) LeftShift(n int)

<< operator

func (*BitSet) Not

func (set *BitSet) Not() (res *BitSet)

~ operator(golang option ^self)

func (*BitSet) Or

func (set *BitSet) Or(compare *BitSet) (res *BitSet)

| operator (set|compare -> res)

func (*BitSet) RightShift

func (set *BitSet) RightShift(n int)

>> operator

func (*BitSet) Set

func (set *BitSet) Set(pos uint64, value int) int

set in LittleEndian order notice: 0<= pos < len

func (*BitSet) String

func (set *BitSet) String() string

func (*BitSet) StringAsc

func (set *BitSet) StringAsc() string

func (*BitSet) StringBit

func (set *BitSet) StringBit() string

func (*BitSet) StringDesc

func (set *BitSet) StringDesc() string

func (*BitSet) Xor

func (set *BitSet) Xor(compare *BitSet) (res *BitSet)

^ operator (set^compare -> res)

type Error

type Error string

Error is used to distinguish errors (panics) generated in this package.

type HashSet

type HashSet struct {
	Items map[interface{}]struct{}
}

func NewSet

func NewSet(values ...interface{}) *HashSet

func (*HashSet) Add

func (set *HashSet) Add(items ...interface{})

func (*HashSet) Clear

func (set *HashSet) Clear()

func (*HashSet) Contains

func (set *HashSet) Contains(items ...interface{}) bool

func (*HashSet) Empty

func (set *HashSet) Empty() bool

func (*HashSet) Remove

func (set *HashSet) Remove(items ...interface{})

func (*HashSet) Size

func (set *HashSet) Size() int

func (*HashSet) String

func (set *HashSet) String() string

func (*HashSet) Values

func (set *HashSet) Values() []interface{}

Jump to

Keyboard shortcuts

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