node->right->offset += node->offset;
node->offset = 0;
}
- /* The only thing that matters about `otick` is whether it's equal to
+ /* The only thing that matters about 'otick' is whether it's equal to
that of the tree. We could also "blindly" inherit from parent->otick,
- but we need to tree's `otick` anyway for when there's no parent. */
+ but we need to tree's 'otick' anyway for when there's no parent. */
if (node->parent == NULL || node->parent->otick == otick)
node->otick = otick;
}
struct itree_node *parent = NULL;
struct itree_node *child = tree->root;
uintmax_t otick = tree->otick;
- /* It's the responsibility of the caller to set `otick` on the node,
+ /* It's the responsibility of the caller to set 'otick' on the node,
to "confirm" that the begin/end fields are up to date. */
eassert (node->otick == otick);
link the tree root.
Warning: DEST is left unmodified. SOURCE's child links are
- unchanged. Caller is responsible for recalculation of `limit`.
- Requires both nodes to be using the same effective `offset`. */
+ unchanged. Caller is responsible for recalculation of 'limit'.
+ Requires both nodes to be using the same effective 'offset'. */
static void
itree_replace_child (struct itree_tree *tree,
struct itree_node *source,
parent, left and right in surrounding nodes to point to SOURCE.
Warning: DEST is left unmodified. Caller is responsible for
- recalculation of `limit`. Requires both nodes to be using the same
- effective `offset`. */
+ recalculation of 'limit'. Requires both nodes to be using the same
+ effective 'offset'. */
static void
itree_transplant (struct itree_tree *tree,
struct itree_node *source,
eassert (itree_contains (tree, node));
eassert (check_tree (tree, true)); /* FIXME: Too expensive. */
- /* Find `splice`, the leaf node to splice out of the tree. When
- `node` has at most one child this is `node` itself. Otherwise,
- it is the in order successor of `node`. */
+ /* Find 'splice', the leaf node to splice out of the tree. When
+ 'node' has at most one child this is 'node' itself. Otherwise,
+ it is the in order successor of 'node'. */
itree_inherit_offset (tree->otick, node);
struct itree_node *splice
= (node->left == NULL || node->right == NULL)
? node
: itree_subtree_min (tree->otick, node->right);
- /* Find `subtree`, the only child of `splice` (may be NULL). Note:
- `subtree` will not be modified other than changing its parent to
- `splice`. */
+ /* Find 'subtree', the only child of 'splice' (may be NULL). Note:
+ 'subtree' will not be modified other than changing its parent to
+ 'splice'. */
eassert (splice->left == NULL || splice->right == NULL);
struct itree_node *subtree
= (splice->left != NULL) ? splice->left : splice->right;
- /* Save a pointer to the parent of where `subtree` will eventually
- be in `subtree_parent`. */
+ /* Save a pointer to the parent of where 'subtree' will eventually
+ be in 'subtree_parent'. */
struct itree_node *subtree_parent
= (splice->parent != node) ? splice->parent : splice;
- /* If `splice` is black removing it may violate Red-Black
+ /* If 'splice' is black removing it may violate Red-Black
invariants, so note this for later. */
- /* Replace `splice` with `subtree` under subtree's parent. If
- `splice` is black, this creates a red-red violation, so remember
+ /* Replace 'splice' with 'subtree' under subtree's parent. If
+ 'splice' is black, this creates a red-red violation, so remember
this now as the field can be overwritten when splice is
transplanted below. */
itree_replace_child (tree, subtree, splice);
bool removed_black = !splice->red;
- /* Replace `node` with `splice` in the tree and propagate limit
+ /* Replace 'node' with 'splice' in the tree and propagate limit
upwards, if necessary. Note: Limit propagation can stabilize at
any point, so we must call from bottom to top for every node that
has a new child. */
/* Nodes with front_advance starting at pos may mess up the tree
order, so we need to remove them first. This doesn't apply for
- `before_markers` since in that case, all positions move identically
- regardless of `front_advance` or `rear_advance`. */
+ 'before_markers' since in that case, all positions move identically
+ regardless of 'front_advance' or 'rear_advance'. */
struct itree_stack *saved = itree_stack_create (0);
struct itree_node *node = NULL;
if (!before_markers)
Note that this should return all the nodes that we need to traverse
in order to traverse the nodes selected by the current narrowing (i.e.
- `ITER->begin..ITER->end`) so it will also return some nodes which aren't in
+ 'ITER->begin..ITER->end') so it will also return some nodes which aren't in
that narrowing simply because they may have children which are.
The code itself is very unsatisfactory because the code of each one
struct itree_iterator *iter)
{
/* FIXME: Like in the previous version of the iterator, we
- prune based on `limit` only when moving to a left child,
- but `limit` can also get smaller when moving to a right child
+ prune based on 'limit' only when moving to a left child,
+ but 'limit' can also get smaller when moving to a right child
It's actually fairly common, so maybe it would be worthwhile
to prune a bit more aggressively here. */
struct itree_node *next;
iter->end = end;
iter->otick = tree->otick;
iter->order = order;
- /* Beware: the `node` field always holds "the next" node to consider.
+ /* Beware: the 'node' field always holds "the next" node to consider.
so it's always "one node ahead" of what the iterator loop sees.
In most respects this makes no difference, but we depend on this
- detail in `delete_all_overlays` where this allows us to modify
+ detail in 'delete_all_overlays' where this allows us to modify
the current node knowing that the iterator will not need it to
find the next. */
iter->node = itree_iterator_first_node (tree, iter);
struct itree_node
{
/* The normal parent, left and right links found in binary trees.
- See also `red`, below, which completes the Red-Black tree
+ See also 'red', below, which completes the Red-Black tree
representation. */
struct itree_node *parent;
struct itree_node *left;
struct itree_node *node;
ptrdiff_t begin;
ptrdiff_t end;
- uintmax_t otick; /* A copy of the tree's `otick`. */
+ uintmax_t otick; /* A copy of the tree's 'otick'. */
enum itree_order order;
};
/* Iterate over the intervals between BEG and END in the tree T.
- N will hold successive nodes. ORDER can be one of : `ASCENDING`,
- `DESCENDING`, `POST_ORDER`, or `PRE_ORDER`.
+ N will hold successive nodes. ORDER can be one of : 'ASCENDING',
+ 'DESCENDING', 'POST_ORDER', or 'PRE_ORDER'.
It should be used as:
ITREE_FOREACH (n, t, beg, end, order)
- Don't modify the tree during the iteration.
*/
#define ITREE_FOREACH(n, t, beg, end, order) \
- /* FIXME: We'd want to declare `n` right here, but I can't figure out
- how to make that work here: the `for` syntax only allows a single
+ /* FIXME: We'd want to declare 'n' right here, but I can't figure out
+ how to make that work here: the 'for' syntax only allows a single
clause for the var declarations where we need 2 different types.
- We could use the `struct {foo x; bar y; } p;` trick to declare two
- vars `p.x` and `p.y` of unrelated types, but then none of the names
- of the vars matches the `n` we receive :-(. */ \
+ We could use the 'struct {foo x; bar y; } p;' trick to declare two
+ vars 'p.x' and 'p.y' of unrelated types, but then none of the names
+ of the vars matches the 'n' we receive :-(. */ \
if (!t) \
{ } \
else \