OpenViSTAI · Agents · Blockchain · Crypto
Menu
Developer Tools

Bokkypoobahsredblacktreelibrary

A Solidity library implementing an iterative red-black binary search tree for maintaining sorted, nonzero uint keys that can index contract mapping data. It documents insertion, deletion and search in O(log n) time, and identifies on-chain order books as an application.

Independent OpenViST project profile, based on linked sources.

Bokkypoobahsredblacktreelibrary — OpenViST project profile in Developer Tools.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use it when a Solidity contract needs ordered numeric-key operations over records stored in mappings, such as the index component of an on-chain order book.

Who it is for

  • Solidity developers maintaining mapping-backed records that need ordered key access.
  • Smart-contract developers designing an on-chain order-book index.

Documented uses

  • Maintain an ordered index of numeric keys alongside contract records.
  • Insert or remove keys while preserving a balanced tree.
  • Search the indexed keys and use them to access mapping data in sorted order.
Before you choose

Requirements & limits

  • The library uses an iterative red-black tree and documents O(log n) insertion, deletion and search.
  • Key 0 is prohibited.
  • The README gives gas figures for specific tree sizes and test conditions; actual costs depend on integration and use.
  • The README warns that the library was still being tested and says not to use it in production without an audit.
  • The repository identifies the license as MIT.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Maintain a sorted uint-key index in Solidity

Use the library’s red-black tree to keep numeric keys in sorted order alongside mapping-backed contract data.

Before you start

  • A Solidity smart contract using the library’s iterative red-black tree.
  • Nonzero uint keys; key 0 is prohibited.
  • Data stored in mapping tables and associated with the tree’s keys.

Steps

  1. Use the tree to maintain the sorted uint-key index for the contract’s data.

  2. Insert keys as records are added and remove keys when records are deleted.

  3. Use the sorted keys to access the corresponding mapping data in order; use the library’s search support to look up keys.

Expected outcome

The contract can maintain and search a sorted key index, with insertions, deletions, and searches described as O(log n).

Guide limitations

  • The project README says the library is being tested and should not be used in production without an audit.
  • Key 0 is prohibited.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
15 October 2026
Original website title
bokkypoobah/BokkyPooBahsRedBlackTreeLibrary · Official homepage title · retained in its source language

Related options

Hitchen's Order Statistics Tree — The README identifies it as an extension built from this library.