bitmap

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: Apache-2.0 Imports: 6 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllDatas = regexp.MustCompile(`(\d+)`)

AllDatas what?

View Source
var BitMapBadExpression = regexp.MustCompile(`([^\^\d-,]+)|([^\d]+-.*(,|$))|` +
	`([^,]*-[^\d]+)|(\^[^\d]+)|((\,\s)?\^$)`)

BitMapBadExpression is the wrong expression

View Source
var HexMap = map[byte]int{
	'1': 1,
	'3': 2,
	'7': 3,
	'f': 4,
	'F': 4,
}

HexMap cbm are all consecutive bits

Functions

func CbmLen

func CbmLen(cbm string) int

CbmLen returns length of CBM

func GenCPUResString

func GenCPUResString(mapList []string, bitLen int) (string, error)

GenCPUResString {"2-8,^3-4,^7,9", "56-87,^86"}

func GenerateBitMap

func GenerateBitMap(coreids []string, num int) (string, error)

GenerateBitMap generate bit map

func IsZeroHexString

func IsZeroHexString(s string) bool

IsZeroHexString is zero hex string No verification for input s. Such as whitespace in "0x11, 22" and "g" in "0xg1111" Caller do verification.

func SetField

func SetField(obj interface{}, name string, value interface{}) error

SetField sets obj's 'name' field with proper type

func StringInSlice

func StringInSlice(val string, list []string) bool

StringInSlice string in slice O(n), maybe key in map is O(1) Not sure a good way for golang to check a string in slice

Types

type Bitmap

type Bitmap struct {
	Len  int
	Bits []int
}

Bitmap struct represents bit map

func NewBitmap

func NewBitmap(value ...interface{}) (*Bitmap, error)

NewBitmap create bit map from string, strings ... We can add a wraper for NewBitmap such as:

func NewCPUBitmap( value ...interface{}) (*Bitmap, error) {
    cpu_numbers := 88
    return NewBitmap(cpu_numbers, value)
}

func (*Bitmap) And

func (b *Bitmap) And(m *Bitmap) *Bitmap

And does intersection

func (*Bitmap) Axor

func (b *Bitmap) Axor(m *Bitmap) *Bitmap

Axor does asymmetric difference

func (*Bitmap) GetConnectiveBits

func (b *Bitmap) GetConnectiveBits(ways, offset uint32, fromLow bool) *Bitmap

GetConnectiveBits returns a connective bits for Bitmap by given ways, offset, and order

func (*Bitmap) IsEmpty

func (b *Bitmap) IsEmpty() bool

IsEmpty returns empty bit map or not

func (*Bitmap) MaxConnectiveBits

func (b *Bitmap) MaxConnectiveBits() *Bitmap

MaxConnectiveBits returns MaxConnectiveBits

func (*Bitmap) Maximum

func (b *Bitmap) Maximum() uint32

Maximum returns the highest position of the bit map

func (*Bitmap) Or

func (b *Bitmap) Or(m *Bitmap) *Bitmap

Or does union

func (*Bitmap) ToBinString

func (b *Bitmap) ToBinString() string

ToBinString binary string

func (*Bitmap) ToBinStrings

func (b *Bitmap) ToBinStrings() []string

ToBinStrings to binary string slice

func (*Bitmap) ToHumanString

func (b *Bitmap) ToHumanString() string

ToHumanString returns human string of the bitmap, e.g. 1-2,10-11

func (*Bitmap) ToString

func (b *Bitmap) ToString() string

ToString returns hex string

func (*Bitmap) Xor

func (b *Bitmap) Xor(m *Bitmap) *Bitmap

Xor does difference

Jump to

Keyboard shortcuts

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