14#ifndef OR_TOOLS_ALGORITHMS_BINARY_INDEXED_TREE_H_
15#define OR_TOOLS_ALGORITHMS_BINARY_INDEXED_TREE_H_
19#include "absl/log/check.h"
38 DCHECK_LT(index, tree_.size() - 1);
41 while (index < tree_.size()) {
42 tree_[index] += value;
43 index += index & -index;
51 DCHECK_LT(index + 1, tree_.size());
56 prefix_sum += tree_[index];
57 index -= index & -index;
63 int size()
const {
return tree_.size() - 1; }
T GetPrefixSum(int index) const
int size() const
Returns the size of the tree.
void AddItem(int index, T value)
Adds value to index-th number.
In SWIG mode, we don't want anything besides these top-level includes.