Documentation
¶
Overview ¶
Package bisect implements common bisection algorithms.
Index ¶
- func BisectLeft(a Interface, x interface{}) int
- func BisectRight(a Interface, x interface{}) int
- type Float64Slice
- func (p *Float64Slice) BisectLeft(x float64)
- func (p *Float64Slice) BisectRight(x float64)
- func (p *Float64Slice) Insert(i int, x interface{})
- func (p *Float64Slice) InsortLeft(x float64)
- func (p *Float64Slice) InsortRight(x float64)
- func (p Float64Slice) Len() int
- func (p Float64Slice) Less(i int, with interface{}) bool
- type IntSlice
- type Interface
- type StringSlice
- func (p *StringSlice) BisectLeft(x string)
- func (p *StringSlice) BisectRight(x string)
- func (p *StringSlice) Insert(i int, x interface{})
- func (p *StringSlice) InsortLeft(x string)
- func (p *StringSlice) InsortRight(x string)
- func (p StringSlice) Len() int
- func (p StringSlice) Less(i int, with interface{}) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BisectLeft ¶
Return the index where to insert item x in a, assuming a is sorted. The return value i is such that all e in a[:i] have e < x, and all e in a[i:] have e >= x. So if x already appears in the list, a.insert(x) will insert just before the leftmost x already there.
func BisectRight ¶
Return the index where to insert item x in a, assuming a is sorted. The return value i is such that all e in a[:i] have e <= x, and all e in a[i:] have e > x. So if x already appears in the list, a.insert(x) will insert just after the rightmost x already there.
Types ¶
type Float64Slice ¶
type Float64Slice []float64
Float64Slice attaches the methods of items to []float64
func (*Float64Slice) BisectLeft ¶
func (p *Float64Slice) BisectLeft(x float64)
func (*Float64Slice) BisectRight ¶
func (p *Float64Slice) BisectRight(x float64)
func (*Float64Slice) Insert ¶
func (p *Float64Slice) Insert(i int, x interface{})
func (*Float64Slice) InsortLeft ¶
func (p *Float64Slice) InsortLeft(x float64)
func (*Float64Slice) InsortRight ¶
func (p *Float64Slice) InsortRight(x float64)
InsortRight is a convenience method.
func (Float64Slice) Len ¶
func (p Float64Slice) Len() int
func (Float64Slice) Less ¶
func (p Float64Slice) Less(i int, with interface{}) bool
type IntSlice ¶
type IntSlice []int
IntSlice attaches the methods of Items to []int
func (*IntSlice) BisectLeft ¶
func (*IntSlice) BisectRight ¶
func (*IntSlice) InsortLeft ¶
type Interface ¶
type Interface interface {
// Len is the number of elements in the collection.
Len() int
// Compares a given item with the element x at index i
// Should return a bool:
// negative , if a[i] < than
// positive , if a[i] > than
Less(i int, than interface{}) bool
}
Interface is a type, typically a collection can be sorted in-place by the routines in this package
type StringSlice ¶
type StringSlice []string
StringSlice attaches the methods of Items to []string
func (*StringSlice) BisectLeft ¶
func (p *StringSlice) BisectLeft(x string)
func (*StringSlice) BisectRight ¶
func (p *StringSlice) BisectRight(x string)
func (*StringSlice) Insert ¶
func (p *StringSlice) Insert(i int, x interface{})
func (*StringSlice) InsortLeft ¶
func (p *StringSlice) InsortLeft(x string)
func (StringSlice) Len ¶
func (p StringSlice) Len() int
func (StringSlice) Less ¶
func (p StringSlice) Less(i int, with interface{}) bool