treap 0.1.0 copy "treap: ^0.1.0" to clipboard
treap: ^0.1.0 copied to clipboard

A persistent treap for Dart. A heap balanced randomized binary tree with efficient value semantics. All operations are O(log n) worst case.

Treap #

main codecov

A package implementing a persistent (immutable) order statistic tree by means of the treap data structure (a kind of cartesian tree). Apart from the regular set operations, it allows for:

  • select(i) – find the i-th smallest element.
  • rank(x) – find the rank of element x, i.e. the number of elements smaller than x.

both in O(log(N)) time.

This particular implementation is made fully persistent by means of path copying. That is, any operation that would otherwise mutate the treap, instead produces a new treap, and does so using only O(log(N)) extra space.

Example #

A toy todo flutter app, that illustrates how to use persistent treaps to efficiently handle undo/redo and animate a list view.

If your browser supports WasmGC (such as Chrome 119+, or Firefox 120+), you can try out the app here

9
likes
0
points
120
downloads

Publisher

verified publisherbyolimit.com

Weekly Downloads

A persistent treap for Dart. A heap balanced randomized binary tree with efficient value semantics. All operations are O(log n) worst case.

Repository (GitHub)
View/report issues

Topics

#treap #data-structures #collections #functional

License

unknown (license)

More

Packages that depend on treap