xmath

package
v1.48.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2021 License: MPL-2.0 Imports: 3 Imported by: 17

Documentation

Overview

Package xmath provides math-related utilities.

Index

Constants

View Source
const (
	// DegreesToRadians converts a value in degrees to radians when multiplied
	// with the value.
	DegreesToRadians = math.Pi / 180
	// RadiansToDegrees converts a value in radians to degrees when multiplied
	// with the value.
	RadiansToDegrees = 180 / math.Pi
)

Variables

This section is empty.

Functions

func AbsInt

func AbsInt(x int) int

AbsInt returns the absolute value of x.

func MaxInt

func MaxInt(a, b int) int

MaxInt returns the larger of a or b.

func MinInt

func MinInt(a, b int) int

MinInt returns the smaller of a or b.

Types

type BitSet

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

BitSet contains a set of bits.

func (*BitSet) Clear

func (b *BitSet) Clear(index int)

Clear the bit at 'index'.

func (*BitSet) ClearRange

func (b *BitSet) ClearRange(start, end int)

ClearRange clears the bits from 'start' to 'end', inclusive.

func (*BitSet) Clone

func (b *BitSet) Clone() *BitSet

Clone this BitSet.

func (*BitSet) Copy

func (b *BitSet) Copy(other *BitSet)

Copy the content of 'other' into this BitSet, making them equal.

func (*BitSet) Count

func (b *BitSet) Count() int

Count returns the number of set bits.

func (*BitSet) Data

func (b *BitSet) Data() []uint64

Data returns a copy of the underlying storage.

func (*BitSet) EnsureCapacity

func (b *BitSet) EnsureCapacity(words int)

EnsureCapacity ensures that the BitSet has enough underlying storage to accommodate setting a bit as high as index position 'words' x 64 - 1 without needing to allocate more storage.

func (*BitSet) Equal

func (b *BitSet) Equal(other *BitSet) bool

Equal returns true if this BitSet is equal to 'other'.

func (*BitSet) FirstSet

func (b *BitSet) FirstSet() int

FirstSet returns the first set bit. If no bits are set, then -1 is returned.

func (*BitSet) Flip

func (b *BitSet) Flip(index int)

Flip the bit at 'index'.

func (*BitSet) FlipRange

func (b *BitSet) FlipRange(start, end int)

FlipRange flips the bits from 'start' to 'end', inclusive.

func (*BitSet) LastSet

func (b *BitSet) LastSet() int

LastSet returns the last set bit. If no bits are set, then -1 is returned.

func (*BitSet) Load

func (b *BitSet) Load(data []uint64)

Load replaces the current data with the bits set in 'data'.

func (*BitSet) NextClear

func (b *BitSet) NextClear(start int) int

NextClear returns the next clear bit starting from 'start'.

func (*BitSet) NextSet

func (b *BitSet) NextSet(start int) int

NextSet returns the next set bit starting from 'start'. If no bits are set at or beyond 'start', then -1 is returned.

func (*BitSet) PreviousClear

func (b *BitSet) PreviousClear(start int) int

PreviousClear returns the previous clear bit starting from 'start'. If no bits are clear at or before 'start', then -1 is returned.

func (*BitSet) PreviousSet

func (b *BitSet) PreviousSet(start int) int

PreviousSet returns the previous set bit starting from 'start'. If no bits are set at or before 'start', then -1 is returned.

func (*BitSet) Reset

func (b *BitSet) Reset()

Reset the BitSet back to an empty state.

func (*BitSet) Set

func (b *BitSet) Set(index int)

Set the bit at 'index'.

func (*BitSet) SetRange

func (b *BitSet) SetRange(start, end int)

SetRange sets the bits from 'start' to 'end', inclusive.

func (*BitSet) State

func (b *BitSet) State(index int) bool

State returns the state of the bit at 'index'.

func (*BitSet) Trim

func (b *BitSet) Trim()

Trim the BitSet down to the minimum required to store the set bits.

Directories

Path Synopsis
Package fixed provides fixed-point values that can be added, subtracted, multiplied and divided.
Package fixed provides fixed-point values that can be added, subtracted, multiplied and divided.
Package geom provides geometry primitives.
Package geom provides geometry primitives.
Package geom32 provides geometry primitives.
Package geom32 provides geometry primitives.
Package rand provides a Randomizer based upon the crypto/rand package.
Package rand provides a Randomizer based upon the crypto/rand package.

Jump to

Keyboard shortcuts

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