package zint
import "zgo.at/zstd/zint"
Package zint implements functions for ints.
Index ¶
- func DivideCeil(count int64, pageSize int64) int64
- func Fields(s string) ([]int64, error)
- func Join[T integer](ints []T, sep string) string
- func Range(start, end int) []int
- func RoundToPowerOf2(n uint64) uint64
- func Split(s string, sep string) ([]int64, error)
- func ToIntSlice(v any) ([]int64, bool)
- func ToUintSlice(v any) ([]uint64, bool)
- type Bitflag16
- func (f *Bitflag16) Clear(flag Bitflag16)
- func (f Bitflag16) Has(flag Bitflag16) bool
- func (f *Bitflag16) Set(flag Bitflag16)
- func (f *Bitflag16) Toggle(flag Bitflag16)
- func (f *Bitflag16) UnmarshalJSON(text []byte) error
- func (f *Bitflag16) UnmarshalText(text []byte) error
- type Bitflag32
- func (f *Bitflag32) Clear(flag Bitflag32)
- func (f Bitflag32) Has(flag Bitflag32) bool
- func (f *Bitflag32) Set(flag Bitflag32)
- func (f *Bitflag32) Toggle(flag Bitflag32)
- func (f *Bitflag32) UnmarshalJSON(text []byte) error
- func (f *Bitflag32) UnmarshalText(text []byte) error
- type Bitflag64
- func (f *Bitflag64) Clear(flag Bitflag64)
- func (f Bitflag64) Has(flag Bitflag64) bool
- func (f *Bitflag64) Set(flag Bitflag64)
- func (f *Bitflag64) Toggle(flag Bitflag64)
- func (f *Bitflag64) UnmarshalJSON(text []byte) error
- func (f *Bitflag64) UnmarshalText(text []byte) error
- type Bitflag8
- func (f *Bitflag8) Clear(flag Bitflag8)
- func (f Bitflag8) Has(flag Bitflag8) bool
- func (f *Bitflag8) Set(flag Bitflag8)
- func (f *Bitflag8) Toggle(flag Bitflag8)
- func (f *Bitflag8) UnmarshalJSON(text []byte) error
- func (f *Bitflag8) UnmarshalText(text []byte) error
- type Int
- func (s Int) Float32() float32
- func (s Int) Float64() float64
- func (s Int) Int() int
- func (s Int) Int64() int64
- func (s Int) String() string
- type Uint128
- func NewUint128(b []byte) (Uint128, error)
- func ParseUint128(s string, base int) (Uint128, error)
- func (i Uint128) Bytes() []byte
- func (i Uint128) Format(base int) string
- func (i Uint128) IsZero() bool
- func (i Uint128) MarshalText() ([]byte, error)
- func (i *Uint128) New(b []byte) error
- func (i *Uint128) Parse(str string, base int) error
- func (i *Uint128) Scan(v any) error
- func (i Uint128) String() string
- func (i Uint128) UUID() string
- func (i *Uint128) UnmarshalText(v []byte) error
- func (i Uint128) Value() (driver.Value, error)
Functions ¶
func DivideCeil ¶
DivideCeil divides two integers and rounds up, rather than down (which is what happens when you do int64/int64).
func Fields ¶
Fields splits a strings with strings.Fields() and parses each entry as an integer.
func Join ¶
Join a slice of ints to a comma separated string with the given separator.
func Range ¶
Range creates an []int counting at "start" up to (and including) "end".
func RoundToPowerOf2 ¶
RoundToPowerOf2 rounds up to the nearest power of 2.
https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
func Split ¶
Split a string to a slice of []int64.
func ToIntSlice ¶
ToIntSlice converts any []int type to an []int64.
func ToUintSlice ¶
ToUintSlice converts any []int type to an []uint64.
Types ¶
type Bitflag16 ¶
type Bitflag16 uint16
Bitflag16 is an uint16 with some extra methods to make bitmask/flag manipulation a bit more convenient.
func (*Bitflag16) Clear ¶
func (Bitflag16) Has ¶
func (*Bitflag16) Set ¶
func (*Bitflag16) Toggle ¶
func (*Bitflag16) UnmarshalJSON ¶
func (*Bitflag16) UnmarshalText ¶
type Bitflag32 ¶
type Bitflag32 uint32
Bitflag32 is an uint32 with some extra methods to make bitmask/flag manipulation a bit more convenient.
func (*Bitflag32) Clear ¶
func (Bitflag32) Has ¶
func (*Bitflag32) Set ¶
func (*Bitflag32) Toggle ¶
func (*Bitflag32) UnmarshalJSON ¶
func (*Bitflag32) UnmarshalText ¶
type Bitflag64 ¶
type Bitflag64 uint64
Bitflag64 is an uint64 with some extra methods to make bitmask/flag manipulation a bit more convenient.
func (*Bitflag64) Clear ¶
func (Bitflag64) Has ¶
func (*Bitflag64) Set ¶
func (*Bitflag64) Toggle ¶
func (*Bitflag64) UnmarshalJSON ¶
func (*Bitflag64) UnmarshalText ¶
type Bitflag8 ¶
type Bitflag8 uint8
Bitflag8 is an uint8 with some extra methods to make bitmask/flag manipulation a bit more convenient.
func (*Bitflag8) Clear ¶
func (Bitflag8) Has ¶
func (*Bitflag8) Set ¶
func (*Bitflag8) Toggle ¶
func (*Bitflag8) UnmarshalJSON ¶
func (*Bitflag8) UnmarshalText ¶
type Int ¶
type Int int
Int with various methods to make conversions easier; useful especially in templates etc.
func (Int) Float32 ¶
func (Int) Float64 ¶
func (Int) Int ¶
func (Int) Int64 ¶
func (Int) String ¶
type Uint128 ¶
type Uint128 [2]uint64
Uint128 is an unsigned 128-bit integer.
Mostly intended to store UUIDs; storing it as a []byte takes up 40 bytes, whereas storing it in two uint64s takes up 16 bytes.
It's stored in so-called "big endian" format; that is, the most significant bit is on the right.
func NewUint128 ¶
NewUint128 creates a new uint128 from a [16]byte.
func ParseUint128 ¶
func (Uint128) Bytes ¶
func (Uint128) Format ¶
Format according to the given base.
TODO: this is not really printin a number, but just printing the 2 numbers side-by-side, rather than actually adding up the bits.
func (Uint128) IsZero ¶
func (Uint128) MarshalText ¶
MarshalText converts the data to a human readable representation.
func (*Uint128) New ¶
New sets this uint128 from a [16]byte.
func (*Uint128) Parse ¶
func (*Uint128) Scan ¶
Scan converts the data from the DB.
func (Uint128) String ¶
func (Uint128) UUID ¶
UUID formats as a UUID.
func (*Uint128) UnmarshalText ¶
UnmarshalText parses text in to the Go data structure.
func (Uint128) Value ¶
Value determines what to store in the DB.
Source Files ¶
bitflag.go uint128.go zint.go
- Version
- v0.0.0-20240930202209-a63c3335042a (latest)
- Published
- Sep 30, 2024
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 2 days ago –
Tools for package owners.