region

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2015 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(a int) int

Abs return absolute a

func Max

func Max(a, b int) int

Max return bigger in a and b

func MaxByDir

func MaxByDir(a, b int, dir Direction) int

MaxByDir return maxium of a and b sorted by direction

func Mid

func Mid(a, b, c int) int

Mid return mid of three

func Min

func Min(a, b int) int

Min return smaller in a and b

func MinByDir

func MinByDir(a, b int, dir Direction) int

MinByDir return minimum of a and b sorted by direction

func Pow

func Pow(base, power uint) uint64

Pow return power of a base number

func Seq

func Seq(a, b int) (int, int)

Seq return sequenced a and b

func SeqByDir

func SeqByDir(a, b int, dir Direction) (int, int)

SeqByDir return the sequence of a and b sorted by direction if it's positive, a, b is returned, otherwise, b, a is returned

Types

type Direction

type Direction bool

Direction means positive or reverse

const (
	POSITIVE Direction = true
	REVERSE  Direction = false
)

type Region

type Region struct {
	From, To int
	Dir      Direction
}

Region from point From to To. From must be less than To, real direction is decide by the Dir field

func NewRegion

func NewRegion(from, to int) Region

New a Region

func (*Region) Adjust

func (r *Region) Adjust(position, delta int)

Adjust apply the change in the position with delta(the change) to the region if need if point is after changed position, it must change also else if point is before the changed position, if the delta do not affect the point, needn't change point else apply the change also

func (Region) Begin

func (r Region) Begin() int

Begin return start of Region

func (Region) Clip

func (r Region) Clip(r2 Region) Region

Clip return the cliped against another region if r is inside r2 or r2 inside r, return r, else return r that remove intesect part

func (Region) Combine

func (r Region) Combine(r2 Region) Region

Combine returns a region covering both regions, dir is same as r

func (Region) Contains

func (r Region) Contains(point int) bool

Contains returns whether the region contains the given point or not.

func (Region) Cover

func (r Region) Cover(r2 Region) bool

Cover returns whether the region fully covers the argument region

func (Region) Cut

func (r Region) Cut(r2 Region) (ret []Region)

Cuts remove the intersect part

func (Region) Empty

func (r Region) Empty() bool

Empty returns whether or not the region is empty

func (Region) End

func (r Region) End() int

End return end of Region

func (Region) Intersection

func (r Region) Intersection(r2 Region) (ret Region)

Intersection returns the region that is the intersection of the two

func (Region) Intersects

func (r Region) Intersects(r2 Region) bool

Intersects check whether the two regions intersects

func (Region) MidIn

func (r Region) MidIn(point int) bool

MidIn returns whether the point is in the reign and is't the begin and end

func (Region) RealFrom

func (r Region) RealFrom() int

RealFrom return region's real from

func (Region) RealTo

func (r Region) RealTo() int

RealTo return real's real to

func (Region) Size

func (r Region) Size() int

Returns the size of the region

func (Region) String

func (r Region) String() string

String return region's real (from,to)

Jump to

Keyboard shortcuts

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