Skip to content

Commit

Permalink
Update the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-kirienko committed Oct 12, 2021
1 parent a74608a commit 6890e1c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ The usage instructions are provided in the comments.
A complete test suite is provided in `test.cpp`; it includes an exhaustive randomized test.

For development-related instructions please refer to the CI configuration file.
To release a new version, simply create a new tag.

![Tree](randomized_test_tree.png "Random tree generated by the test suite")
4 changes: 2 additions & 2 deletions cavl.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// Source: https://github.com/pavel-kirienko/cavl
///
/// Cavl is a single-header C library providing an implementation of AVL tree suitable for deeply embedded systems.
/// To integrate it into your project, simply copy this file into your source tree.
/// To integrate it into your project, simply copy this file into your source tree. Read the API docs below.
///
/// See also O1Heap <https://github.com/pavel-kirienko/o1heap> -- a deterministic memory manager for hard-real-time
/// high-integrity embedded systems.
Expand Down Expand Up @@ -39,7 +39,7 @@ extern "C" {

/// The tree node/root. The user data is to be added through composition/inheritance.
/// The memory layout of this type is compatible with void*[4], which is useful if this type cannot be exposed in API.
/// Per standard convention, nodes that compare smaLLer are put on the Left; those that are laRgeR are on the Right.
/// Per standard convention, nodes that compare smaller are put on the left.
typedef struct Cavl Cavl;
struct Cavl
{
Expand Down
Binary file modified randomized_test_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,23 @@ void printGraphviz(const Node<T>* const nd)
std::puts("digraph {");
std::puts(
"node [style=filled,shape=circle,fontcolor=white,penwidth=0,fontname=\"monospace\",fixedsize=1,fontsize=18];");
std::puts("nodesep=0.1;ranksep=0.3;");
std::puts("edge [arrowhead=none,penwidth=2];");
std::puts("nodesep=0.0;ranksep=0.3;splines=false;");
traverse<true>(nd, [](const Node<T>* const x) {
const char* const fill_color = (x->bf == 0) ? "black" : ((x->bf > 0) ? "orange" : "blue");
std::printf("\"%u\"[fillcolor=%s];", unsigned(x->value), fill_color);
std::printf("%u[fillcolor=%s];", unsigned(x->value), fill_color);
});
std::puts("");
traverse<true>(nd, [](const Node<T>* const x) {
if (x->lr[0] != nullptr)
{
std::printf("\"%u\":w->\"%u\":n;",
std::printf("%u:sw->%u:n;",
unsigned(x->value),
unsigned(reinterpret_cast<Node<T>*>(x->lr[0])->value));
}
if (x->lr[1] != nullptr)
{
std::printf("\"%u\":e->\"%u\":n;",
std::printf("%u:se->%u:n;",
unsigned(x->value),
unsigned(reinterpret_cast<Node<T>*>(x->lr[1])->value));
}
Expand Down

0 comments on commit 6890e1c

Please sign in to comment.