PVEC_OVERLAY);
Lisp_Object overlay = make_lisp_ptr (p, Lisp_Vectorlike);
struct itree_node *node = xmalloc (sizeof (*node));
- interval_node_init (node, front_advance, rear_advance, overlay);
+ itree_node_init (node, front_advance, rear_advance, overlay);
p->interval = node;
p->buffer = NULL;
set_overlay_plist (overlay, plist);
{
eassert (! ov->buffer);
if (! b->overlays)
- b->overlays = interval_tree_create ();
+ b->overlays = itree_create ();
ov->buffer = b;
- itree_insert_node (b->overlays, ov->interval, begin, end);
+ itree_insert (b->overlays, ov->interval, begin, end);
}
/* Copy overlays of buffer FROM to buffer TO. */
{
eassert (b->overlays);
eassert (ov->buffer == b);
- interval_tree_remove (ov->buffer->overlays, ov->interval);
+ itree_remove (ov->buffer->overlays, ov->interval);
ov->buffer = NULL;
}
/* Where are the nodes freed ? --ap */
XOVERLAY (node->data)->buffer = NULL;
}
- interval_tree_clear (b->overlays);
+ itree_clear (b->overlays);
}
static void
/* Actually this does not free any overlay, but the tree only. --ap */
if (b->overlays)
{
- interval_tree_destroy (b->overlays);
+ itree_destroy (b->overlays);
b->overlays = NULL;
}
}
struct itree_node **nodes = NULL;
struct itree_tree *tree = current_buffer->overlays;
- const intmax_t size = interval_tree_size (tree);
+ const intmax_t size = itree_size (tree);
/* We can't use `interval_node_set_region` at the same time
as we iterate over the itree, so we need an auxiliary storage
if (multibyte)
{
- ptrdiff_t begin = interval_node_begin (tree, node);
- ptrdiff_t end = interval_node_end (tree, node);
+ ptrdiff_t begin = itree_node_begin (tree, node);
+ ptrdiff_t end = itree_node_end (tree, node);
/* This models the behavior of markers. (The behavior of
text-intervals differs slightly.) */
while (end < Z_BYTE
&& !CHAR_HEAD_P (FETCH_BYTE (end)))
end++;
- interval_node_set_region (tree, node, BYTE_TO_CHAR (begin),
+ itree_node_set_region (tree, node, BYTE_TO_CHAR (begin),
BYTE_TO_CHAR (end));
}
else
{
- interval_node_set_region (tree, node, CHAR_TO_BYTE (node->begin),
+ itree_node_set_region (tree, node, CHAR_TO_BYTE (node->begin),
CHAR_TO_BYTE (node->end));
}
}
but we may need to update the value of the overlay center. */
if (! current_buffer->overlays)
return;
- interval_tree_insert_gap (current_buffer->overlays, pos, length);
+ itree_insert_gap (current_buffer->overlays, pos, length);
}
void
{
if (! current_buffer->overlays)
return;
- interval_tree_delete_gap (current_buffer->overlays, pos, length);
+ itree_delete_gap (current_buffer->overlays, pos, length);
}
\f
add_buffer_overlay (XBUFFER (buffer), XOVERLAY (overlay), n_beg, n_end);
}
else
- interval_node_set_region (b->overlays, XOVERLAY (overlay)->interval,
+ itree_node_set_region (b->overlays, XOVERLAY (overlay)->interval,
n_beg, n_end);
/* If the overlay has changed buffers, do a thorough redisplay. */
{
if (! ov->buffer)
return -1;
- return interval_node_begin (ov->buffer->overlays, ov->interval);
+ return itree_node_begin (ov->buffer->overlays, ov->interval);
}
INLINE ptrdiff_t
{
if (! ov->buffer)
return -1;
- return interval_node_end (ov->buffer->overlays, ov->interval);
+ return itree_node_end (ov->buffer->overlays, ov->interval);
}
/* Return the start of OV in its buffer, or -1 if OV is not associated
/* Initialize an allocated node. */
void
-interval_node_init (struct itree_node *node,
+itree_node_init (struct itree_node *node,
bool front_advance, bool rear_advance,
Lisp_Object data)
{
/* Return NODE's begin value, computing it if necessary. */
ptrdiff_t
-interval_node_begin (struct itree_tree *tree,
+itree_node_begin (struct itree_tree *tree,
struct itree_node *node)
{
interval_tree_validate (tree, node);
/* Return NODE's end value, computing it if necessary. */
ptrdiff_t
-interval_node_end (struct itree_tree *tree,
+itree_node_end (struct itree_tree *tree,
struct itree_node *node)
{
interval_tree_validate (tree, node);
/* Allocate an interval_tree. Free with interval_tree_destroy. */
struct itree_tree*
-interval_tree_create (void)
+itree_create (void)
{
/* FIXME? Maybe avoid the initialization of itree_null in the same
way that is used to call mem_init in alloc.c? It's not really
itree_init ();
struct itree_tree *tree = xmalloc (sizeof (*tree));
- interval_tree_clear (tree);
+ itree_clear (tree);
return tree;
}
/* Reset the tree TREE to its empty state. */
void
-interval_tree_clear (struct itree_tree *tree)
+itree_clear (struct itree_tree *tree)
{
tree->root = NULL;
tree->otick = 1;
/* Release a tree, freeing its allocated memory. */
void
-interval_tree_destroy (struct itree_tree *tree)
+itree_destroy (struct itree_tree *tree)
{
eassert (tree->root == NULL);
/* if (tree->iter)
/* Return the number of nodes in TREE. */
intmax_t
-interval_tree_size (struct itree_tree *tree)
+itree_size (struct itree_tree *tree)
{
return tree->size;
}
}
void
-itree_insert_node (struct itree_tree *tree, struct itree_node *node,
+itree_insert (struct itree_tree *tree, struct itree_node *node,
ptrdiff_t begin, ptrdiff_t end)
{
node->begin = begin;
/* Safely modify a node's interval. */
void
-interval_node_set_region (struct itree_tree *tree,
+itree_node_set_region (struct itree_tree *tree,
struct itree_node *node,
ptrdiff_t begin, ptrdiff_t end)
{
interval_tree_validate (tree, node);
if (begin != node->begin)
{
- interval_tree_remove (tree, node);
+ itree_remove (tree, node);
node->begin = min (begin, PTRDIFF_MAX - 1);
node->end = max (node->begin, end);
interval_tree_insert (tree, node);
/* Remove NODE from TREE and return it. NODE must exist in TREE. */
struct itree_node*
-interval_tree_remove (struct itree_tree *tree, struct itree_node *node)
+itree_remove (struct itree_tree *tree, struct itree_node *node)
{
eassert (interval_tree_contains (tree, node));
eassert (check_tree (tree, true)); /* FIXME: Too expensive. */
front_advance setting. */
void
-interval_tree_insert_gap (struct itree_tree *tree,
+itree_insert_gap (struct itree_tree *tree,
ptrdiff_t pos, ptrdiff_t length)
{
if (length <= 0 || tree->root == NULL)
interval_stack_push (saved, node);
}
for (int i = 0; i < saved->length; ++i)
- interval_tree_remove (tree, nav_nodeptr (saved->nodes[i]));
+ itree_remove (tree, nav_nodeptr (saved->nodes[i]));
/* We can't use an iterator here, because we can't effectively
narrow AND shift some subtree at the same time. */
intersecting it. */
void
-interval_tree_delete_gap (struct itree_tree *tree,
+itree_delete_gap (struct itree_tree *tree,
ptrdiff_t pos, ptrdiff_t length)
{
if (length <= 0 || tree->root == NULL)
adjustment before use as buffer positions.
NOTE: BEGIN and END must not be modified while the node is part
- of a tree. Use interval_tree_insert_gap and
- interval_tree_delete_gap instead.
+ of a tree. Use itree_insert_gap and itree_delete_gap instead.
- NOTE: The interval generators ensure nodes are clean before
+ NOTE: The interval iterators ensure nodes are clean before
yielding them, so BEGIN and END may be safely used as buffer
positions then.
*/
ITREE_PRE_ORDER,
};
-void interval_node_init (struct itree_node *, bool, bool, Lisp_Object);
-ptrdiff_t interval_node_begin (struct itree_tree *, struct itree_node *);
-ptrdiff_t interval_node_end (struct itree_tree *, struct itree_node *);
-void interval_node_set_region (struct itree_tree *, struct itree_node *, ptrdiff_t, ptrdiff_t);
-struct itree_tree *interval_tree_create (void);
-void interval_tree_destroy (struct itree_tree *);
-intmax_t interval_tree_size (struct itree_tree *);
-void interval_tree_clear (struct itree_tree *);
-void itree_insert_node (struct itree_tree *tree, struct itree_node *node,
- ptrdiff_t begin, ptrdiff_t end);
-struct itree_node *interval_tree_remove (struct itree_tree *, struct itree_node *);
-void interval_tree_insert_gap (struct itree_tree *, ptrdiff_t, ptrdiff_t);
-void interval_tree_delete_gap (struct itree_tree *, ptrdiff_t, ptrdiff_t);
+void itree_node_init (struct itree_node *, bool, bool, Lisp_Object);
+ptrdiff_t itree_node_begin (struct itree_tree *, struct itree_node *);
+ptrdiff_t itree_node_end (struct itree_tree *, struct itree_node *);
+void itree_node_set_region (struct itree_tree *, struct itree_node *,
+ ptrdiff_t, ptrdiff_t);
+struct itree_tree *itree_create (void);
+void itree_destroy (struct itree_tree *);
+intmax_t itree_size (struct itree_tree *);
+void itree_clear (struct itree_tree *);
+void itree_insert (struct itree_tree *tree, struct itree_node *node,
+ ptrdiff_t begin, ptrdiff_t end);
+struct itree_node *itree_remove (struct itree_tree *,
+ struct itree_node *);
+void itree_insert_gap (struct itree_tree *, ptrdiff_t, ptrdiff_t);
+void itree_delete_gap (struct itree_tree *, ptrdiff_t, ptrdiff_t);
/* Iteration functions. Almost all code should use ITREE_FOREACH
instead. */