Documentation ¶
Index ¶
- Variables
- type Float32Merger
- type Float32Optimization
- type Float32SegmentTree
- func (s *Float32SegmentTree) AddValueLazy(addLeft int, addRight int, value float32) error
- func (s *Float32SegmentTree) Get(idx int) (float32, error)
- func (s *Float32SegmentTree) Query(queryLeft int, queryRight int) (float32, error)
- func (s *Float32SegmentTree) QueryLazy(queryLeft int, queryRight int) (float32, error)
- func (s *Float32SegmentTree) Set(index int, e float32) error
- func (s *Float32SegmentTree) Size() int
- func (s *Float32SegmentTree) WithFloat32Optimization(f Float32Optimization)
- type Float64Merger
- type Float64Optimization
- type Float64SegmentTree
- func (s *Float64SegmentTree) AddValueLazy(addLeft int, addRight int, value float64) error
- func (s *Float64SegmentTree) Get(idx int) (float64, error)
- func (s *Float64SegmentTree) Query(queryLeft int, queryRight int) (float64, error)
- func (s *Float64SegmentTree) QueryLazy(queryLeft int, queryRight int) (float64, error)
- func (s *Float64SegmentTree) Set(index int, e float64) error
- func (s *Float64SegmentTree) Size() int
- func (s *Float64SegmentTree) WithFloat64Optimization(f Float64Optimization)
- type Int16Merger
- type Int16Optimization
- type Int16SegmentTree
- func (s *Int16SegmentTree) AddValueLazy(addLeft int, addRight int, value int16) error
- func (s *Int16SegmentTree) Get(idx int) (int16, error)
- func (s *Int16SegmentTree) Query(queryLeft int, queryRight int) (int16, error)
- func (s *Int16SegmentTree) QueryLazy(queryLeft int, queryRight int) (int16, error)
- func (s *Int16SegmentTree) Set(index int, e int16) error
- func (s *Int16SegmentTree) Size() int
- func (s *Int16SegmentTree) WithInt16Optimization(f Int16Optimization)
- type Int32Merger
- type Int32Optimization
- type Int32SegmentTree
- func (s *Int32SegmentTree) AddValueLazy(addLeft int, addRight int, value int32) error
- func (s *Int32SegmentTree) Get(idx int) (int32, error)
- func (s *Int32SegmentTree) Query(queryLeft int, queryRight int) (int32, error)
- func (s *Int32SegmentTree) QueryLazy(queryLeft int, queryRight int) (int32, error)
- func (s *Int32SegmentTree) Set(index int, e int32) error
- func (s *Int32SegmentTree) Size() int
- func (s *Int32SegmentTree) WithInt32Optimization(f Int32Optimization)
- type Int64Merger
- type Int64Optimization
- type Int64SegmentTree
- func (s *Int64SegmentTree) AddValueLazy(addLeft int, addRight int, value int64) error
- func (s *Int64SegmentTree) Get(idx int) (int64, error)
- func (s *Int64SegmentTree) Query(queryLeft int, queryRight int) (int64, error)
- func (s *Int64SegmentTree) QueryLazy(queryLeft int, queryRight int) (int64, error)
- func (s *Int64SegmentTree) Set(index int, e int64) error
- func (s *Int64SegmentTree) Size() int
- func (s *Int64SegmentTree) WithInt64Optimization(f Int64Optimization)
- type IntMerger
- type IntOptimization
- type IntSegmentTree
- func (s *IntSegmentTree) AddValueLazy(addLeft int, addRight int, value int) error
- func (s *IntSegmentTree) Get(idx int) (int, error)
- func (s *IntSegmentTree) Query(queryLeft int, queryRight int) (int, error)
- func (s *IntSegmentTree) QueryLazy(queryLeft int, queryRight int) (int, error)
- func (s *IntSegmentTree) Set(index int, e int) error
- func (s *IntSegmentTree) Size() int
- func (s *IntSegmentTree) WithIntOptimization(f IntOptimization)
- type InterfaceMerger
- type InterfaceOptimization
- type InterfaceSegmentTree
- func (s *InterfaceSegmentTree) AddValueLazy(addLeft int, addRight int, value interface{}) error
- func (s *InterfaceSegmentTree) Get(idx int) (interface{}, error)
- func (s *InterfaceSegmentTree) Query(queryLeft int, queryRight int) (interface{}, error)
- func (s *InterfaceSegmentTree) QueryLazy(queryLeft int, queryRight int) (interface{}, error)
- func (s *InterfaceSegmentTree) Set(index int, e interface{}) error
- func (s *InterfaceSegmentTree) Size() int
- func (s *InterfaceSegmentTree) WithInterfaceOptimization(f InterfaceOptimization)
- type StringMerger
- type StringOptimization
- type StringSegmentTree
- func (s *StringSegmentTree) AddValueLazy(addLeft int, addRight int, value string) error
- func (s *StringSegmentTree) Get(idx int) (string, error)
- func (s *StringSegmentTree) Query(queryLeft int, queryRight int) (string, error)
- func (s *StringSegmentTree) QueryLazy(queryLeft int, queryRight int) (string, error)
- func (s *StringSegmentTree) Set(index int, e string) error
- func (s *StringSegmentTree) Size() int
- func (s *StringSegmentTree) WithStringOptimization(f StringOptimization)
- type Uint16Merger
- type Uint16Optimization
- type Uint16SegmentTree
- func (s *Uint16SegmentTree) AddValueLazy(addLeft int, addRight int, value uint16) error
- func (s *Uint16SegmentTree) Get(idx int) (uint16, error)
- func (s *Uint16SegmentTree) Query(queryLeft int, queryRight int) (uint16, error)
- func (s *Uint16SegmentTree) QueryLazy(queryLeft int, queryRight int) (uint16, error)
- func (s *Uint16SegmentTree) Set(index int, e uint16) error
- func (s *Uint16SegmentTree) Size() int
- func (s *Uint16SegmentTree) WithUint16Optimization(f Uint16Optimization)
- type Uint32Merger
- type Uint32Optimization
- type Uint32SegmentTree
- func (s *Uint32SegmentTree) AddValueLazy(addLeft int, addRight int, value uint32) error
- func (s *Uint32SegmentTree) Get(idx int) (uint32, error)
- func (s *Uint32SegmentTree) Query(queryLeft int, queryRight int) (uint32, error)
- func (s *Uint32SegmentTree) QueryLazy(queryLeft int, queryRight int) (uint32, error)
- func (s *Uint32SegmentTree) Set(index int, e uint32) error
- func (s *Uint32SegmentTree) Size() int
- func (s *Uint32SegmentTree) WithUint32Optimization(f Uint32Optimization)
- type Uint64Merger
- type Uint64Optimization
- type Uint64SegmentTree
- func (s *Uint64SegmentTree) AddValueLazy(addLeft int, addRight int, value uint64) error
- func (s *Uint64SegmentTree) Get(idx int) (uint64, error)
- func (s *Uint64SegmentTree) Query(queryLeft int, queryRight int) (uint64, error)
- func (s *Uint64SegmentTree) QueryLazy(queryLeft int, queryRight int) (uint64, error)
- func (s *Uint64SegmentTree) Set(index int, e uint64) error
- func (s *Uint64SegmentTree) Size() int
- func (s *Uint64SegmentTree) WithUint64Optimization(f Uint64Optimization)
- type UintMerger
- type UintOptimization
- type UintSegmentTree
- func (s *UintSegmentTree) AddValueLazy(addLeft int, addRight int, value uint) error
- func (s *UintSegmentTree) Get(idx int) (uint, error)
- func (s *UintSegmentTree) Query(queryLeft int, queryRight int) (uint, error)
- func (s *UintSegmentTree) QueryLazy(queryLeft int, queryRight int) (uint, error)
- func (s *UintSegmentTree) Set(index int, e uint) error
- func (s *UintSegmentTree) Size() int
- func (s *UintSegmentTree) WithUintOptimization(f UintOptimization)
Constants ¶
This section is empty.
Variables ¶
var (
ErrIndexIllegal = errors.New("index is illegal")
)
Functions ¶
This section is empty.
Types ¶
type Float32SegmentTree ¶
type Float32SegmentTree struct {
// contains filtered or unexported fields
}
Float32SegmentTree 线段树
func NewFloat32SegmentTree ¶
func NewFloat32SegmentTree(array []float32, merge Float32Merger) *Float32SegmentTree
NewFloat32SegmentTree new Float32SegmentTree
func (*Float32SegmentTree) AddValueLazy ¶
func (s *Float32SegmentTree) AddValueLazy(addLeft int, addRight int, value float32) error
AddValueLazy 给[addLeft....addRight]位置的值都加上value 注意这里的更新值是在原来值的基础上增加或者减少,而不是把这个区间内的值都赋值为 x,区间更新和单点更新不同 这里的区间更新关注的是变化,单点更新关注的是定值 当然区间更新也可以都更新成定值,如果只区间更新成定值,那么 lazy 更新策略需要变化,merge 策略也需要变化,这里暂不详细讨论
func (*Float32SegmentTree) Get ¶
func (s *Float32SegmentTree) Get(idx int) (float32, error)
Get 索引原数组值
func (*Float32SegmentTree) Query ¶
func (s *Float32SegmentTree) Query(queryLeft int, queryRight int) (float32, error)
Query 区间查询
func (*Float32SegmentTree) QueryLazy ¶
func (s *Float32SegmentTree) QueryLazy(queryLeft int, queryRight int) (float32, error)
QueryLazy 懒惰查询
func (*Float32SegmentTree) Set ¶
func (s *Float32SegmentTree) Set(index int, e float32) error
Set 更新元素值
func (*Float32SegmentTree) WithFloat32Optimization ¶
func (s *Float32SegmentTree) WithFloat32Optimization(f Float32Optimization)
WithFloat32Optimization 指定Float32Optimization来自定义区间[left, right]更新value的计算操作
type Float64SegmentTree ¶
type Float64SegmentTree struct {
// contains filtered or unexported fields
}
Float64SegmentTree 线段树
func NewFloat64SegmentTree ¶
func NewFloat64SegmentTree(array []float64, merge Float64Merger) *Float64SegmentTree
NewFloat64SegmentTree new Float64SegmentTree
func (*Float64SegmentTree) AddValueLazy ¶
func (s *Float64SegmentTree) AddValueLazy(addLeft int, addRight int, value float64) error
AddValueLazy 给[addLeft....addRight]位置的值都加上value 注意这里的更新值是在原来值的基础上增加或者减少,而不是把这个区间内的值都赋值为 x,区间更新和单点更新不同 这里的区间更新关注的是变化,单点更新关注的是定值 当然区间更新也可以都更新成定值,如果只区间更新成定值,那么 lazy 更新策略需要变化,merge 策略也需要变化,这里暂不详细讨论
func (*Float64SegmentTree) Get ¶
func (s *Float64SegmentTree) Get(idx int) (float64, error)
Get 索引原数组值
func (*Float64SegmentTree) Query ¶
func (s *Float64SegmentTree) Query(queryLeft int, queryRight int) (float64, error)
Query 区间查询
func (*Float64SegmentTree) QueryLazy ¶
func (s *Float64SegmentTree) QueryLazy(queryLeft int, queryRight int) (float64, error)
QueryLazy 懒惰查询
func (*Float64SegmentTree) Set ¶
func (s *Float64SegmentTree) Set(index int, e float64) error
Set 更新元素值
func (*Float64SegmentTree) WithFloat64Optimization ¶
func (s *Float64SegmentTree) WithFloat64Optimization(f Float64Optimization)
WithFloat64Optimization 指定Float64Optimization来自定义区间[left, right]更新value的计算操作
type Int16SegmentTree ¶
type Int16SegmentTree struct {
// contains filtered or unexported fields
}
Int16SegmentTree 线段树
func NewInt16SegmentTree ¶
func NewInt16SegmentTree(array []int16, merge Int16Merger) *Int16SegmentTree
NewInt16SegmentTree new Int16SegmentTree
func (*Int16SegmentTree) AddValueLazy ¶
func (s *Int16SegmentTree) AddValueLazy(addLeft int, addRight int, value int16) error
AddValueLazy 给[addLeft....addRight]位置的值都加上value 注意这里的更新值是在原来值的基础上增加或者减少,而不是把这个区间内的值都赋值为 x,区间更新和单点更新不同 这里的区间更新关注的是变化,单点更新关注的是定值 当然区间更新也可以都更新成定值,如果只区间更新成定值,那么 lazy 更新策略需要变化,merge 策略也需要变化,这里暂不详细讨论
func (*Int16SegmentTree) Query ¶
func (s *Int16SegmentTree) Query(queryLeft int, queryRight int) (int16, error)
Query 区间查询
func (*Int16SegmentTree) QueryLazy ¶
func (s *Int16SegmentTree) QueryLazy(queryLeft int, queryRight int) (int16, error)
QueryLazy 懒惰查询
func (*Int16SegmentTree) WithInt16Optimization ¶
func (s *Int16SegmentTree) WithInt16Optimization(f Int16Optimization)
WithInt16Optimization 指定Int16Optimization来自定义区间[left, right]更新value的计算操作
type Int32SegmentTree ¶
type Int32SegmentTree struct {
// contains filtered or unexported fields
}
Int32SegmentTree 线段树
func NewInt32SegmentTree ¶
func NewInt32SegmentTree(array []int32, merge Int32Merger) *Int32SegmentTree
NewInt32SegmentTree new Int32SegmentTree
func (*Int32SegmentTree) AddValueLazy ¶
func (s *Int32SegmentTree) AddValueLazy(addLeft int, addRight int, value int32) error
AddValueLazy 给[addLeft....addRight]位置的值都加上value 注意这里的更新值是在原来值的基础上增加或者减少,而不是把这个区间内的值都赋值为 x,区间更新和单点更新不同 这里的区间更新关注的是变化,单点更新关注的是定值 当然区间更新也可以都更新成定值,如果只区间更新成定值,那么 lazy 更新策略需要变化,merge 策略也需要变化,这里暂不详细讨论
func (*Int32SegmentTree) Query ¶
func (s *Int32SegmentTree) Query(queryLeft int, queryRight int) (int32, error)
Query 区间查询
func (*Int32SegmentTree) QueryLazy ¶
func (s *Int32SegmentTree) QueryLazy(queryLeft int, queryRight int) (int32, error)
QueryLazy 懒惰查询
func (*Int32SegmentTree) WithInt32Optimization ¶
func (s *Int32SegmentTree) WithInt32Optimization(f Int32Optimization)
WithInt32Optimization 指定Int32Optimization来自定义区间[left, right]更新value的计算操作
type Int64SegmentTree ¶
type Int64SegmentTree struct {
// contains filtered or unexported fields
}
Int64SegmentTree 线段树
func NewInt64SegmentTree ¶
func NewInt64SegmentTree(array []int64, merge Int64Merger) *Int64SegmentTree
NewInt64SegmentTree new Int64SegmentTree
func (*Int64SegmentTree) AddValueLazy ¶
func (s *Int64SegmentTree) AddValueLazy(addLeft int, addRight int, value int64) error
AddValueLazy 给[addLeft....addRight]位置的值都加上value 注意这里的更新值是在原来值的基础上增加或者减少,而不是把这个区间内的值都赋值为 x,区间更新和单点更新不同 这里的区间更新关注的是变化,单点更新关注的是定值 当然区间更新也可以都更新成定值,如果只区间更新成定值,那么 lazy 更新策略需要变化,merge 策略也需要变化,这里暂不详细讨论
func (*Int64SegmentTree) Query ¶
func (s *Int64SegmentTree) Query(queryLeft int, queryRight int) (int64, error)
Query 区间查询
func (*Int64SegmentTree) QueryLazy ¶
func (s *Int64SegmentTree) QueryLazy(queryLeft int, queryRight int) (int64, error)
QueryLazy 懒惰查询
func (*Int64SegmentTree) WithInt64Optimization ¶
func (s *Int64SegmentTree) WithInt64Optimization(f Int64Optimization)
WithInt64Optimization 指定Int64Optimization来自定义区间[left, right]更新value的计算操作
type IntSegmentTree ¶
type IntSegmentTree struct {
// contains filtered or unexported fields
}
IntSegmentTree 线段树
func NewIntSegmentTree ¶
func NewIntSegmentTree(array []int, merge IntMerger) *IntSegmentTree
NewIntSegmentTree new IntSegmentTree
func (*IntSegmentTree) AddValueLazy ¶
func (s *IntSegmentTree) AddValueLazy(addLeft int, addRight int, value int) error
AddValueLazy 给[addLeft....addRight]位置的值都加上value 注意这里的更新值是在原来值的基础上增加或者减少,而不是把这个区间内的值都赋值为 x,区间更新和单点更新不同 这里的区间更新关注的是变化,单点更新关注的是定值 当然区间更新也可以都更新成定值,如果只区间更新成定值,那么 lazy 更新策略需要变化,merge 策略也需要变化,这里暂不详细讨论
func (*IntSegmentTree) Query ¶
func (s *IntSegmentTree) Query(queryLeft int, queryRight int) (int, error)
Query 区间查询
func (*IntSegmentTree) QueryLazy ¶
func (s *IntSegmentTree) QueryLazy(queryLeft int, queryRight int) (int, error)
QueryLazy 懒惰查询
func (*IntSegmentTree) WithIntOptimization ¶
func (s *IntSegmentTree) WithIntOptimization(f IntOptimization)
WithIntOptimization 指定IntOptimization来自定义区间[left, right]更新value的计算操作
type InterfaceMerger ¶
type InterfaceMerger func(interface{}, interface{}) interface{}
InterfaceMerger 用户自定义区间内操作逻辑
type InterfaceOptimization ¶
type InterfaceSegmentTree ¶
type InterfaceSegmentTree struct {
// contains filtered or unexported fields
}
InterfaceSegmentTree 线段树
func NewInterfaceSegmentTree ¶
func NewInterfaceSegmentTree(array []interface{}, merge InterfaceMerger) *InterfaceSegmentTree
NewInterfaceSegmentTree new InterfaceSegmentTree
func (*InterfaceSegmentTree) AddValueLazy ¶
func (s *InterfaceSegmentTree) AddValueLazy(addLeft int, addRight int, value interface{}) error
AddValueLazy 给[addLeft....addRight]位置的值都加上value 注意这里的更新值是在原来值的基础上增加或者减少,而不是把这个区间内的值都赋值为 x,区间更新和单点更新不同 这里的区间更新关注的是变化,单点更新关注的是定值 当然区间更新也可以都更新成定值,如果只区间更新成定值,那么 lazy 更新策略需要变化,merge 策略也需要变化,这里暂不详细讨论
func (*InterfaceSegmentTree) Get ¶
func (s *InterfaceSegmentTree) Get(idx int) (interface{}, error)
Get 索引原数组值
func (*InterfaceSegmentTree) Query ¶
func (s *InterfaceSegmentTree) Query(queryLeft int, queryRight int) (interface{}, error)
Query 区间查询
func (*InterfaceSegmentTree) QueryLazy ¶
func (s *InterfaceSegmentTree) QueryLazy(queryLeft int, queryRight int) (interface{}, error)
QueryLazy 懒惰查询
func (*InterfaceSegmentTree) Set ¶
func (s *InterfaceSegmentTree) Set(index int, e interface{}) error
Set 更新元素值
func (*InterfaceSegmentTree) WithInterfaceOptimization ¶
func (s *InterfaceSegmentTree) WithInterfaceOptimization(f InterfaceOptimization)
WithInterfaceOptimization 指定InterfaceOptimization来自定义区间[left, right]更新value的计算操作
type StringSegmentTree ¶
type StringSegmentTree struct {
// contains filtered or unexported fields
}
StringSegmentTree 线段树
func NewStringSegmentTree ¶
func NewStringSegmentTree(array []string, merge StringMerger) *StringSegmentTree
NewStringSegmentTree new StringSegmentTree
func (*StringSegmentTree) AddValueLazy ¶
func (s *StringSegmentTree) AddValueLazy(addLeft int, addRight int, value string) error
AddValueLazy 给[addLeft....addRight]位置的值都加上value 注意这里的更新值是在原来值的基础上增加或者减少,而不是把这个区间内的值都赋值为 x,区间更新和单点更新不同 这里的区间更新关注的是变化,单点更新关注的是定值 当然区间更新也可以都更新成定值,如果只区间更新成定值,那么 lazy 更新策略需要变化,merge 策略也需要变化,这里暂不详细讨论
func (*StringSegmentTree) Query ¶
func (s *StringSegmentTree) Query(queryLeft int, queryRight int) (string, error)
Query 区间查询
func (*StringSegmentTree) QueryLazy ¶
func (s *StringSegmentTree) QueryLazy(queryLeft int, queryRight int) (string, error)
QueryLazy 懒惰查询
func (*StringSegmentTree) Set ¶
func (s *StringSegmentTree) Set(index int, e string) error
Set 更新元素值
func (*StringSegmentTree) WithStringOptimization ¶
func (s *StringSegmentTree) WithStringOptimization(f StringOptimization)
WithStringOptimization 指定StringOptimization来自定义区间[left, right]更新value的计算操作
type Uint16SegmentTree ¶
type Uint16SegmentTree struct {
// contains filtered or unexported fields
}
Uint16SegmentTree 线段树
func NewUint16SegmentTree ¶
func NewUint16SegmentTree(array []uint16, merge Uint16Merger) *Uint16SegmentTree
NewUint16SegmentTree new Uint16SegmentTree
func (*Uint16SegmentTree) AddValueLazy ¶
func (s *Uint16SegmentTree) AddValueLazy(addLeft int, addRight int, value uint16) error
AddValueLazy 给[addLeft....addRight]位置的值都加上value 注意这里的更新值是在原来值的基础上增加或者减少,而不是把这个区间内的值都赋值为 x,区间更新和单点更新不同 这里的区间更新关注的是变化,单点更新关注的是定值 当然区间更新也可以都更新成定值,如果只区间更新成定值,那么 lazy 更新策略需要变化,merge 策略也需要变化,这里暂不详细讨论
func (*Uint16SegmentTree) Query ¶
func (s *Uint16SegmentTree) Query(queryLeft int, queryRight int) (uint16, error)
Query 区间查询
func (*Uint16SegmentTree) QueryLazy ¶
func (s *Uint16SegmentTree) QueryLazy(queryLeft int, queryRight int) (uint16, error)
QueryLazy 懒惰查询
func (*Uint16SegmentTree) Set ¶
func (s *Uint16SegmentTree) Set(index int, e uint16) error
Set 更新元素值
func (*Uint16SegmentTree) WithUint16Optimization ¶
func (s *Uint16SegmentTree) WithUint16Optimization(f Uint16Optimization)
WithUint16Optimization 指定Uint16Optimization来自定义区间[left, right]更新value的计算操作
type Uint32SegmentTree ¶
type Uint32SegmentTree struct {
// contains filtered or unexported fields
}
Uint32SegmentTree 线段树
func NewUint32SegmentTree ¶
func NewUint32SegmentTree(array []uint32, merge Uint32Merger) *Uint32SegmentTree
NewUint32SegmentTree new Uint32SegmentTree
func (*Uint32SegmentTree) AddValueLazy ¶
func (s *Uint32SegmentTree) AddValueLazy(addLeft int, addRight int, value uint32) error
AddValueLazy 给[addLeft....addRight]位置的值都加上value 注意这里的更新值是在原来值的基础上增加或者减少,而不是把这个区间内的值都赋值为 x,区间更新和单点更新不同 这里的区间更新关注的是变化,单点更新关注的是定值 当然区间更新也可以都更新成定值,如果只区间更新成定值,那么 lazy 更新策略需要变化,merge 策略也需要变化,这里暂不详细讨论
func (*Uint32SegmentTree) Query ¶
func (s *Uint32SegmentTree) Query(queryLeft int, queryRight int) (uint32, error)
Query 区间查询
func (*Uint32SegmentTree) QueryLazy ¶
func (s *Uint32SegmentTree) QueryLazy(queryLeft int, queryRight int) (uint32, error)
QueryLazy 懒惰查询
func (*Uint32SegmentTree) Set ¶
func (s *Uint32SegmentTree) Set(index int, e uint32) error
Set 更新元素值
func (*Uint32SegmentTree) WithUint32Optimization ¶
func (s *Uint32SegmentTree) WithUint32Optimization(f Uint32Optimization)
WithUint32Optimization 指定Uint32Optimization来自定义区间[left, right]更新value的计算操作
type Uint64SegmentTree ¶
type Uint64SegmentTree struct {
// contains filtered or unexported fields
}
Uint64SegmentTree 线段树
func NewUint64SegmentTree ¶
func NewUint64SegmentTree(array []uint64, merge Uint64Merger) *Uint64SegmentTree
NewUint64SegmentTree new Uint64SegmentTree
func (*Uint64SegmentTree) AddValueLazy ¶
func (s *Uint64SegmentTree) AddValueLazy(addLeft int, addRight int, value uint64) error
AddValueLazy 给[addLeft....addRight]位置的值都加上value 注意这里的更新值是在原来值的基础上增加或者减少,而不是把这个区间内的值都赋值为 x,区间更新和单点更新不同 这里的区间更新关注的是变化,单点更新关注的是定值 当然区间更新也可以都更新成定值,如果只区间更新成定值,那么 lazy 更新策略需要变化,merge 策略也需要变化,这里暂不详细讨论
func (*Uint64SegmentTree) Query ¶
func (s *Uint64SegmentTree) Query(queryLeft int, queryRight int) (uint64, error)
Query 区间查询
func (*Uint64SegmentTree) QueryLazy ¶
func (s *Uint64SegmentTree) QueryLazy(queryLeft int, queryRight int) (uint64, error)
QueryLazy 懒惰查询
func (*Uint64SegmentTree) Set ¶
func (s *Uint64SegmentTree) Set(index int, e uint64) error
Set 更新元素值
func (*Uint64SegmentTree) WithUint64Optimization ¶
func (s *Uint64SegmentTree) WithUint64Optimization(f Uint64Optimization)
WithUint64Optimization 指定Uint64Optimization来自定义区间[left, right]更新value的计算操作
type UintSegmentTree ¶
type UintSegmentTree struct {
// contains filtered or unexported fields
}
UintSegmentTree 线段树
func NewUintSegmentTree ¶
func NewUintSegmentTree(array []uint, merge UintMerger) *UintSegmentTree
NewUintSegmentTree new UintSegmentTree
func (*UintSegmentTree) AddValueLazy ¶
func (s *UintSegmentTree) AddValueLazy(addLeft int, addRight int, value uint) error
AddValueLazy 给[addLeft....addRight]位置的值都加上value 注意这里的更新值是在原来值的基础上增加或者减少,而不是把这个区间内的值都赋值为 x,区间更新和单点更新不同 这里的区间更新关注的是变化,单点更新关注的是定值 当然区间更新也可以都更新成定值,如果只区间更新成定值,那么 lazy 更新策略需要变化,merge 策略也需要变化,这里暂不详细讨论
func (*UintSegmentTree) Query ¶
func (s *UintSegmentTree) Query(queryLeft int, queryRight int) (uint, error)
Query 区间查询
func (*UintSegmentTree) QueryLazy ¶
func (s *UintSegmentTree) QueryLazy(queryLeft int, queryRight int) (uint, error)
QueryLazy 懒惰查询
func (*UintSegmentTree) WithUintOptimization ¶
func (s *UintSegmentTree) WithUintOptimization(f UintOptimization)
WithUintOptimization 指定UintOptimization来自定义区间[left, right]更新value的计算操作