segmenttree

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SegmentTree

type SegmentTree struct {
	Array       []int
	SegmentTree []int
	LazyTree    []int
}

SegmentTree with original Array and the Segment Tree Array

func NewSegmentTree

func NewSegmentTree(Array []int) *SegmentTree

func (*SegmentTree) Build

func (s *SegmentTree) Build(node int, left int, right int)

Build Segment Tree node, leftNode and rightNode always should start with 1, 0 and len(Array)-1

func (*SegmentTree) Propagate

func (s *SegmentTree) Propagate(node int, leftNode int, rightNode int)

Propagate lazy tree node values

func (*SegmentTree) Query

func (s *SegmentTree) Query(node int, leftNode int, rightNode int, firstIndex int, lastIndex int) int

Query on interval [firstIndex, leftIndex] node, leftNode and rightNode always should start with 1, 0 and len(Array)-1

func (*SegmentTree) Update

func (s *SegmentTree) Update(node int, leftNode int, rightNode int, firstIndex int, lastIndex int, value int)

Update Segment Tree node, leftNode and rightNode always should start with 1, 0 and len(Array)-1 index is the Array index that you want to update value is the value that you want to override

Jump to

Keyboard shortcuts

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