src/cplib/collections/segtree

  Source   Edit

Types

SegmentTree[T] = ref object
  default: T
  merge: proc (x: T; y: T): T
  arr*: seq[T]
  lastnode: int
  length: int
  Source   Edit

Procs

proc `$`[T](self: SegmentTree[T]): string
  Source   Edit
proc `[]=`[T](self: SegmentTree[T]; index: Natural; val: T)
  Source   Edit
proc `[]`[T](self: SegmentTree[T]; index: Natural): T
  Source   Edit
proc `[]`[T](self: SegmentTree[T]; segment: HSlice[int, int]): T
  Source   Edit
proc get[T](self: SegmentTree[T]; q_left: Natural; q_right: Natural): T
半解区間[q_left,q_right)についての演算結果を返します。   Source   Edit
proc get[T](self: SegmentTree[T]; segment: HSlice[int, int]): T
  Source   Edit
proc get_all[T](self: SegmentTree[T]): T
[0,len(self))区間の演算結果をO(1)で返す   Source   Edit
proc initSegmentTree[T](n: int; merge: proc (x: T; y: T): T; default: T): SegmentTree[
    T]
セグメントツリーを生成します。 nにサイズ、mergeに二つの区間をマージする関数、デフォルトに単位元を与えてください。(全て単位元で構築されます)   Source   Edit
proc initSegmentTree[T](v: seq[T]; merge: proc (x: T; y: T): T; default: T): SegmentTree[
    T]
セグメントツリーを生成します。 vに元となるリスト、mergeに二つの区間をマージする関数、デフォルトに単位元を与えてください。   Source   Edit
proc len[T](self: SegmentTree[T]): int
  Source   Edit
proc max_right[T](self: SegmentTree[T]; l: int; f: proc (l: T): bool): int
  Source   Edit
proc min_left[T](self: SegmentTree[T]; r: int; f: proc (l: T): bool): int
  Source   Edit
proc update[T](self: SegmentTree[T]; x: Natural; val: T)
xの要素をvalに変更します。   Source   Edit

Templates

template newSegWith(V, merge, default: untyped): untyped
  Source   Edit