zephyr/include/misc
Andy Ross 193f4feb84 lib: Red/Black balanced tree data structure
A balanced tree implementation for Zephyr as we grow into bigger
regimes where simpler data structures aren't appropriate.

This implements an intrusive balanced tree that guarantees O(log2(N))
runtime for all operations and amortized O(1) behavior for creation
and destruction of whole trees.  The algorithms and naming are
conventional per existing academic and didactic implementations, c.f.:

https://en.wikipedia.org/wiki/Red%E2%80%93black_tree

The implementation is size-optimized to prioritize runtime memory
usage.  The data structure is intrusive, which is to say the struct
rbnode handle is intended to be placed in a separate struct the same
way other such structures (e.g. Zephyr's dlist list) and requires no
data pointer to be stored in the node.  The color bit is unioned with
a pointer (fairly common for such libraries).  Most notably, there is
no "parent" pointer stored in the node, the upper structure of the
tree being generated dynamically via a stack as the tree is recursed.
So the overall memory overhead of a node is just two pointers,
identical with a doubly-linked list.

Code size above dlist is about 2-2.5k on most architectures, which is
significant by Zephyr standards but probably still worthwhile in many
situations.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-04-10 12:31:51 -04:00
..
__assert.h misc: Add a FORCE_NO_ASSERT kconfig directive 2018-02-16 10:44:29 -05:00
byteorder.h include: improve compatibility with C++ apps. 2018-04-09 23:21:52 -04:00
dlist.h sys: slist, dlist: Improve "not thread safe" docstrings 2017-10-17 17:39:15 -04:00
mempool_base.h lib: user mode compatible mempools 2018-04-05 07:03:05 -07:00
mempool.h lib: user mode compatible mempools 2018-04-05 07:03:05 -07:00
printk.h printk: add vprintk() 2017-04-22 14:29:33 +00:00
rb.h lib: Red/Black balanced tree data structure 2018-04-10 12:31:51 -04:00
reboot.h license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
ring_buffer.h lib: move ring_buffer from misc/ to lib/ 2017-12-15 20:02:01 -05:00
slist.h sys: slist, dlist: Improve "not thread safe" docstrings 2017-10-17 17:39:15 -04:00
stack.h doc: do not show undocumented members 2018-03-20 14:01:30 -04:00
util.h include: improve compatibility with C++ apps. 2018-04-09 23:21:52 -04:00