summaryrefslogtreecommitdiffstats
path: root/src/util/rb_tree.h
Commit message (Collapse)AuthorAgeFilesLines
* util: rb_tree: add safe iteratorsLionel Landwerlin2018-08-221-0/+58
| | | | | | | | v2: Add helper to make iterators more readable (Rafael) Fix rev iterator bug (Rafael) Signed-off-by: Lionel Landwerlin <[email protected]> Reviewed-by: Rafael Antognolli <[email protected]>
* util/rb_tree: Fix a compiler warningJason Ekstrand2018-07-121-1/+1
| | | | | | | Gcc 8 warns "cast to pointer from integer of different size" in 32-bit builds. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
* util: rb-tree: A simple, invasive, red-black treeJason Ekstrand2018-07-051-0/+269
This is a simple, invasive, liberally licensed red-black tree implementation. It's an invasive data structure similar to the Linux kernel linked-list where the intention is that you embed a rb_node struct the data structure you intend to put into the tree. The implementation is mostly based on the one in "Introduction to Algorithms", third edition, by Cormen, Leiserson, Rivest, and Stein. There were a few other key design points: * It's an invasive data structure similar to the [Linux kernel linked list]. * It uses NULL for leaves instead of a sentinel. This means a few algorithms differ a small bit from the ones in "Introduction to Algorithms". * All search operations are inlined so that the compiler can optimize away the function pointer call. Reviewed-by: Lionel Landwerlin <[email protected]>