No description
Find a file
2021-12-22 21:02:20 +01:00
.github/workflows Package structure change 2021-12-22 21:02:20 +01:00
src Package structure change 2021-12-22 21:02:20 +01:00
tests Package structure change 2021-12-22 21:02:20 +01:00
.gitignore Initial commit 2021-12-22 18:12:04 +01:00
LICENSE Create LICENSE 2021-12-22 19:14:41 +01:00
rangequeries.nimble Package structure change 2021-12-22 21:02:20 +01:00
README.md Lowered minimum nim version 2021-12-22 19:20:19 +01:00

RangeQueries

Documentation Generation Tests

This nim package implements "SegmentTree", a data structure that allows you to respond to "Range Queries" in O(log(n)) time.

More information about Segment Trees here: https://en.wikipedia.org/wiki/Segment_tree

Usage

var nbrs: seq[int] = @[]
for i in 1 .. 20:
  nbrs.add(i)
proc add(a, b: int): int =
  a + b

var st = toSegmentTree[int](nbrs, add)
echo st.query(3, 5) # 4 + 5 + 6 = 15

Complete documentation available here

Tests

Even more examples in tests.

Contributing

Feel free to implement more data structures to respond to range queries.