counts

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2018 License: MIT Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BinaryPrefixes []Prefix
View Source
var MetricPrefixes []Prefix

Functions

func Human

func Human(n uint64, prefixes []Prefix, unit string) (string, string)

Format values, aligned, in `len(unit) + 10` or fewer characters (except for extremely large numbers).

Types

type Count32

type Count32 uint32

A count of something, capped at math.MaxUint32.

func NewCount32

func NewCount32(n uint64) Count32

func (*Count32) AdjustMaxIfNecessary

func (n1 *Count32) AdjustMaxIfNecessary(n2 Count32) bool

AdjustMaxIfNecessary adjusts `*n1` to be `max(*n1, n2)`. Return true iff `n2` was greater than `*n1`.

func (*Count32) AdjustMaxIfPossible

func (n1 *Count32) AdjustMaxIfPossible(n2 Count32) bool

AdjustMaxIfPossible adjusts `*n1` to be `max(*n1, n2)`. Return true iff `n2` was greater than or equal to `*n1`.

func (Count32) Human

func (n Count32) Human(prefixes []Prefix, unit string) (string, string)

func (*Count32) Increment

func (n1 *Count32) Increment(n2 Count32)

Increment `*n1` by `n2`, capped at math.MaxUint32.

func (Count32) Plus

func (n1 Count32) Plus(n2 Count32) Count32

Return the sum of two Count32s, capped at math.MaxUint32.

func (Count32) ToUint64

func (n Count32) ToUint64() uint64

type Count64

type Count64 uint64

A count of something, capped at math.MaxUint64.

func NewCount64

func NewCount64(n uint64) Count64

func (*Count64) AdjustMaxIfNecessary

func (n1 *Count64) AdjustMaxIfNecessary(n2 Count64) bool

AdjustMaxIfNecessary adjusts `*n1` to be `max(*n1, n2)`. Return true iff `n2` was greater than `*n1`.

func (*Count64) AdjustMaxIfPossible

func (n1 *Count64) AdjustMaxIfPossible(n2 Count64) bool

AdjustMaxIfPossible adjusts `*n1` to be `max(*n1, n2)`. Return true iff `n2` was greater than or equal to `*n1`.

func (Count64) Human

func (n Count64) Human(prefixes []Prefix, unit string) (string, string)

func (*Count64) Increment

func (n1 *Count64) Increment(n2 Count64)

Increment `*n1` by `n2`, capped at math.MaxUint64.

func (Count64) Plus

func (n1 Count64) Plus(n2 Count64) Count64

Return the sum of two Count64s, capped at math.MaxUint64.

func (Count64) ToUint64

func (n Count64) ToUint64() uint64

type Humaner

type Humaner interface {
	Human([]Prefix, string) (string, string)
	ToUint64() uint64
}

type Prefix

type Prefix struct {
	Name       string
	Multiplier uint64
}

Jump to

Keyboard shortcuts

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