package utils

import "github.com/intel/goresctrl/pkg/utils"

Index

Functions

func DumpJSON

func DumpJSON(r interface{}) string

DumpJSON dumps a json-compatible struct in human-readable form

func SortUint64s

func SortUint64s(a []uint64)

SortUint64s sorts a slice of uint64 in increasing order.

Types

type ID

type ID = int

ID is nn integer id, used to identify packages, CPUs, nodes, etc.

const (
	// Unknown represents an unknown id.
	Unknown ID = -1
)

type IDSet

type IDSet map[ID]struct{}

IDSet is an unordered set of integer ids.

func NewIDSet

func NewIDSet(ids ...ID) IDSet

NewIDSet creates a new unordered set of (integer) ids.

func NewIDSetFromIntSlice

func NewIDSetFromIntSlice(ids ...int) IDSet

NewIDSetFromIntSlice creates a new unordered set from an integer slice.

func (IDSet) Add

func (s IDSet) Add(ids ...ID)

Add adds the given ids into the set.

func (IDSet) Clone

func (s IDSet) Clone() IDSet

Clone returns a copy of this IdSet.

func (IDSet) Del

func (s IDSet) Del(ids ...ID)

Del deletes the given ids from the set.

func (IDSet) Has

func (s IDSet) Has(ids ...ID) bool

Has tests if all the ids are present in the set.

func (IDSet) MarshalJSON

func (s IDSet) MarshalJSON() ([]byte, error)

MarshalJSON is the JSON marshaller for IDSet.

func (IDSet) Members

func (s IDSet) Members() []ID

Members returns all ids in the set as a randomly ordered slice.

func (IDSet) Size

func (s IDSet) Size() int

Size returns the number of ids in the set.

func (IDSet) SortedMembers

func (s IDSet) SortedMembers() []ID

SortedMembers returns all ids in the set as a sorted slice.

func (IDSet) String

func (s IDSet) String() string

String returns the set as a string.

func (IDSet) StringWithSeparator

func (s IDSet) StringWithSeparator(args ...string) string

StringWithSeparator returns the set as a string, separated with the given separator.

func (*IDSet) UnmarshalJSON

func (s *IDSet) UnmarshalJSON(data []byte) error

UnmarshalJSON is the JSON unmarshaller for IDSet.

type Uint64Slice

type Uint64Slice []uint64

Uint64Slice implmenents sort.Interface for a slice of uint64.

func (Uint64Slice) Len

func (s Uint64Slice) Len() int

Len returns the length of an UintSlice

func (Uint64Slice) Less

func (s Uint64Slice) Less(i, j int) bool

Less returns true if element at 'i' is less than the element at 'j'

func (Uint64Slice) Swap

func (s Uint64Slice) Swap(i, j int)

Swap swaps the values of two elements

Source Files

idset.go json.go sort.go

Version
v0.2.0
Published
Sep 20, 2021
Platform
darwin/amd64
Imports
6 packages
Last checked
3 days ago

Tools for package owners.