-///////////////////////////////////////////
-// find_close(bp *b,int s)
-// returns the matching close parenthesis of s
-///////////////////////////////////////////
-int find_close(bp *b,int s)
-{
- return fwd_excess(b,s,-1);
-}
-
-///////////////////////////////////////////
-// find_open(bp *b,int s)
-// returns the matching open parenthesis of s
-///////////////////////////////////////////
-int find_open(bp *b,int s)
-{
- int r;
- r = bwd_excess(b,s,0);
- if (r >= -1) return r+1;
- return -1;
-}
-
-///////////////////////////////////////////
-// parent(bp *b,int s)
-// returns the parent of s
-// -1 if s is the root
-///////////////////////////////////////////
-int parent(bp *b,int s)
-{
- int r;
- r = bwd_excess(b,s,-2);
- if (r >= -1) return r+1;
- return -1;
-}
-
-int enclose(bp *b,int s)
-{
- return parent(b,s);
-}
-
-///////////////////////////////////////////
-// level_ancestor(bp *b,int s,int d)
-// returns the ancestor of s with relative depth d (d < 0)
-// -1 if no such node
-///////////////////////////////////////////
-int level_ancestor(bp *b,int s,int d)
-{
- int r;
- r = bwd_excess(b,s,d-1);
- if (r >= -1) return r+1;
- return -1;
-}
-
-///////////////////////////////////////////
-// lca(bp *b, int s, int t)
-// returns the lowest common ancestor of s and t
-///////////////////////////////////////////
-int lca(bp *b, int s, int t)
-{
- return parent(b,rmq(b,s,t,0)+1);
-}
-
-
-///////////////////////////////////////////
-// preorder_rank(bp *b,int s)
-// returns the preorder (>= 1) of node s (s >= 0)
-///////////////////////////////////////////
-int preorder_rank(bp *b,int s)
-{
- return darray_rank(b->da,s);
-}
-
-///////////////////////////////////////////
-// preorder_select(bp *b,int s)
-// returns the node with preorder s (s >= 1)
-// -1 if no such node
-///////////////////////////////////////////
-int preorder_select(bp *b,int s)
-{
- // no error handling
- if (b->opt & OPT_FAST_PREORDER_SELECT) {
- return darray_select(b->da,s,1);
- } else {
- return darray_select_bsearch(b->da,s,getpat_preorder);
- }
-}