GitHunt
SO

Sopiro/segment-tree

Templated segment tree in C++

Segment Tree

Templated segment tree implementaion in C++

Example

int Combine(int a, int b)
{
    return a + b;
}

int main()
{
    int data[8] = { 5, 8, 4, 3, 7, 2, 1, 6 };
    SegmentTree<int> tree{ data, Combine, 0 };

    int sum = tree.Query(2, 6); // 16

    return 0;
}

Building

  • Install CMake
  • Ensure CMake is in the system PATH
  • Clone the repository git clone https://github.com/Sopiro/segment-tree
  • Run CMake build script depend on your system
    • Visual Studio: Run build.bat
    • Otherwise: Run build.sh

Languages

C++99.7%CMake0.3%Batchfile0.0%Shell0.0%

Contributors

MIT License
Created March 15, 2023
Updated October 25, 2023