util

package
v0.0.0-...-6fbfe6d Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2015 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package util provides some commonly used functions.

Index

Constants

View Source
const (
	MaxUint = ^uint(0)                                                     // The maximum uint value.
	MinUint = uint(0)                                                      // The minimum uint value.
	MaxInt  = int(^uint(0) >> 1)                                           // The maximum int value.
	MinInt  = -MaxInt - 1                                                  // The minimum int value.
	Ln4     = 1.3862943611198906188344642429163531361510002687205105082413 // The natural log of 4.
)

Variables

This section is empty.

Functions

func DeBruijn

func DeBruijn(k, n byte) (s []byte)

Return a deBruijn sequence for a n-words with k letters.

func Hash

func Hash(h hash.Hash, f *os.File) (sum []byte, err error)

Hash returns the h hash sum of file f and any error. The hash is not reset on return, so if individual files are to be hashed with the same h, it should be reset.

func Log4

func Log4(x float64) float64

Returns the log base 4 of x.

func Max

func Max(a ...int) (max int)

Returns the maximum int of a...

func Min

func Min(a ...int) (min int)

Returns the minimum int of a...

func Pow

func Pow(base int, exp byte) (r int)

Return the exp'th power of base.

func Pow4

func Pow4(n int) uint

Returns the nth power of 4.

func UMax

func UMax(a ...uint) (max uint)

Returns the maximum uint of a...

func UMin

func UMin(a ...uint) (min uint)

Returns the minimum uint of a...

Types

type Caller

type Caller struct {
	Package  string
	Function string
	File     string
	Line     int
}

func GetCaller

func GetCaller(skip int) *Caller

type Debug

type Debug bool

func (Debug) Printf

func (d Debug) Printf(format string, args ...interface{})

func (Debug) Println

func (d Debug) Println(args ...interface{})

type Timer

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

func NewTimer

func NewTimer() (t *Timer)

func (*Timer) Interval

func (t *Timer) Interval() (l time.Duration)

Start and return a time interval.

func (*Timer) Reset

func (t *Timer) Reset()

Reset stops the timer and sets the elapsed time to zero.

func (*Timer) Start

func (t *Timer) Start()

Start starts timing. This function is called automatically when a timer is created, but it can also used to resume timing after a call to StopTimer.

func (*Timer) Stop

func (t *Timer) Stop() time.Duration

Stop stops timing. This can be used to pause the timer while performing complex initialization that you don't want to measure.

func (*Timer) Time

func (t *Timer) Time() time.Duration

Time returns the measured time.

type Wrapper

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

A Wrapper provides hard line wrapping and output limits to an io.Writer.

func NewWrapper

func NewWrapper(w io.Writer, width, limit int) *Wrapper

NewWrapper returns a Wrapper that causes wraps lines at width bytes and limits the number of bytes written to the provided limit.

func (*Wrapper) Write

func (w *Wrapper) Write(p []byte) (n int, err error)

Write writes the lesser of len(p) or the Writer's limit bytes from p to the underlying data stream. It returns the number of bytes written from p (0 <= n <= len(p)) and any error encountered that caused the write to stop early, except the Writer's own limit.

Jump to

Keyboard shortcuts

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