segment_tree

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element[S Merger[S], T Initer[S]] struct {
	// contains filtered or unexported fields
}

type Initer added in v1.1.0

type Initer[T any] interface {
	Init(op Operate) T
}

type Int64 added in v1.1.0

type Int64 int64

func (Int64) Init added in v1.1.0

func (c Int64) Init(op Operate) Int64Schema

Init 初始化摘要结构

func (Int64) Value added in v1.1.0

func (c Int64) Value() int64

type Int64Schema added in v1.1.0

type Int64Schema struct {
	MaxValue int64
	MinValue int64
	Sum      int64
}

func (Int64Schema) Merge added in v1.1.0

func (c Int64Schema) Merge(d Int64Schema) Int64Schema

Merge 合并摘要信息

type Merger added in v1.1.0

type Merger[T any] interface {
	Merge(T) T
}

type Operate

type Operate uint8
const (
	OperateCreate Operate = 0
	OperateQuery  Operate = 1
	OperateUpdate Operate = 2
)

type SegmentTree

type SegmentTree[S Merger[S], T Initer[S]] struct {
	// contains filtered or unexported fields
}

func New

func New[S Merger[S], T Initer[S]](arr []T) *SegmentTree[S, T]

func (*SegmentTree[S, T]) Query

func (c *SegmentTree[S, T]) Query(begin int, end int) S

Query 查询 begin <= index < end 区间

func (*SegmentTree[S, T]) Update

func (c *SegmentTree[S, T]) Update(i int, v T)

Update 更新

Jump to

Keyboard shortcuts

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