Skip to main content

Crate sum_segment_tree

Crate sum_segment_tree 

Source
Expand description

A fixed-capacity sum tree for weighted sampling, the structure used in prioritized experience replay.

Priorities live in the leaves of a complete binary tree packed into a flat array. Every internal node stores the sum of its two children, so the total weight and “find the leaf at cumulative weight s” are both O(log capacity). Writes are a ring buffer: once full, the oldest leaf is overwritten.

Structs§

SumTree
A binary sum tree over capacity leaves. The capacity is rounded up to a power of two so the tree stays complete.