• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ NODE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中NODE函数的典型用法代码示例。如果您正苦于以下问题:C++ NODE函数的具体用法?C++ NODE怎么用?C++ NODE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NODE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ACE_NEW_MALLOC_RETURN

template <class T, class C> int
ACE_Unbounded_Set_Ex<T, C>::insert_tail (const T &item)
{
  // ACE_TRACE ("ACE_Unbounded_Set_Ex<T, C>::insert_tail");
  NODE *temp = 0;

  // Insert <item> into the old dummy node location.
  this->head_->item_ = item;

  // Create a new dummy node.
  ACE_NEW_MALLOC_RETURN (temp,
                         static_cast<NODE*> (this->allocator_->malloc (sizeof (NODE))),
                         NODE (this->head_->next_),
                         -1);
  // Link this pointer into the list.
  this->head_->next_ = temp;

  // Point the head to the new dummy node.
  this->head_ = temp;

  ++this->cur_size_;
  return 0;
}
开发者ID:CCJY,项目名称:ACE,代码行数:23,代码来源:Unbounded_Set_Ex.cpp


示例2: node_stmt_new

struct Node * node_stmt_new(struct Node * first, ...)
{
    va_list args;
    va_start(args, first);

    va_list args_for_count;
    va_copy(args_for_count, args);
    size_t n_nodes = 0;
    struct Node *node = first;
    while(node) {
        ++ n_nodes;
        node = va_arg(args_for_count, struct Node *);
    }
    va_end(args_for_count);

    struct NodeStmt *self = node_new(NODE_STMT, sizeof(struct Node *) * n_nodes);
    self->n_nodes = n_nodes;
    for(; n_nodes >= 0; -- n_nodes) {
        self->nodes[self->n_nodes - n_nodes] = va_arg(args, struct Node *);
    }

    return NODE(self);
}
开发者ID:derekdai,项目名称:flex-n-bison,代码行数:23,代码来源:node.c


示例3: parse_pipeline

t_parser_result         parse_pipeline(t_token_list **list_pointer)
{
  t_parser_result       result;
  t_redir               redir;
  t_node                *first;
  t_hs                  error;

  parser_redir_init(&redir);
  result = parse_command(list_pointer);
  first = result.node;
  if (!first)
    return (result);
  result = parse_pipeline_end(first, list_pointer, &redir);
  if (!result.node)
    return (result);
  if (glist_voidp_length(&result.node->children) == 1)
    {
      return (NODE(first));
    }
  if (hs_length(error = parser_setup_pipeline(result.node)))
    return (ERROR(error));
  return (result);
}
开发者ID:baillyjamy,项目名称:360SH-NoScop3,代码行数:23,代码来源:parser_pipe.c


示例4: parse_id

static int parse_id(struct peg_grammar_parser *pgp, struct peg_cursor *pc,
                    int *idp)
{
	int id;
        struct peg_node *pn;
	struct peg_grammar *peg = pgp->peg;
        struct raw name;

        if ( !cset_contains(cs_id_start, CHAR(pgp, pc)) )
                return 0;

        name.data = (char *)STR(pgp, pc);
        name.len = 1 + str_spn(name.data + 1, cs_id_cont);
	pn = find_id(peg, &name);
        if ( pn != NULL ) {
		++pn->pi_refcnt;
        } else {
                id = peg_node_new(peg, PEG_IDENTIFIER, pc->line);
                if ( id < 0 ) {
                        pgp->err = PEG_ERR_NOMEM;
                        return -1;
                }
		pn = NODE(peg, id);
                if ( copy_str(pgp, pc, name.len, &pn->pi_name) < 0 ) {
                        pgp->err = PEG_ERR_NOMEM;
                        peg_node_free(peg, id);
                        return -1;
                }
                pn->pi_def = -1;
                pn->pi_refcnt = 1;
        }

        *idp = node2idx(peg, pn);
        pc->pos += name.len;
        skip_space(pgp, pc);
        return 1;
}
开发者ID:ctelfer,项目名称:catlib,代码行数:37,代码来源:peg.c


示例5: BTreePrint_

void BTreePrint_(btree_t t, index_t nidx)
{
  int j;
  node_t n;

  n = NODE(t, nidx);

  printf("btree(%zu, %d, %d,\n[", nidx, n->level, n->count);
  for (j = 0; j < n->count; j++)
    printf("%lf,",n->branch[j].key);
  for (; j < MAXCARD_(t) - 1; j++)
    printf("nil,");
  printf("],\n[");

  for (j = 0; j < n->count; j++)
    printf("%zu,",n->branch[j].child);
  for (; j < MAXCARD_(t); j++)
    printf("nil,");
  printf("]).\n\n");

  if (n->level > 0)
    for (j = 0; j < n->count; j++)
      BTreePrint_(t, n->branch[j].child);
}
开发者ID:davidvaz,项目名称:yap-udi,代码行数:24,代码来源:b+tree.c


示例6: parse_expr

static int parse_expr(struct peg_grammar_parser *pgp, struct peg_cursor *pc,
		      int *exprp)
{
	struct peg_grammar *peg = pgp->peg;
	struct peg_cursor npc = *pc;
	int expr = -1;
	int snn;
	int nn;
	int rv;

	rv = parse_seq(pgp, &npc, &expr);
	if ( rv <= 0 )
		return rv;

	snn = expr;
	while ( string_match(pgp, "/", &npc) ) {
		rv = parse_seq(pgp, &npc, &nn);
		if ( rv < 0 )
			goto err;
		if ( rv == 0 ) {
			pgp->err = PEG_ERR_BAD_EXPR;
			goto err;
		}
		NODE(peg, snn)->pn_next = nn;
		snn = nn;
	}

	*pc = npc;
	*exprp = expr;
	return 1;

err:
	pgp->eloc = npc;
	peg_node_free(peg, expr);
	return -1;
}
开发者ID:ctelfer,项目名称:catlib,代码行数:36,代码来源:peg.c


示例7: sugar_module

static ast_result_t sugar_module(ast_t* ast)
{
  ast_t* docstring = ast_child(ast);

  ast_t* package = ast_parent(ast);
  assert(ast_id(package) == TK_PACKAGE);

  if(strcmp(package_name(package), "$0") != 0)
  {
    // Every module not in builtin has an implicit use builtin command.
    // Since builtin is always the first package processed it is $0.
    BUILD(builtin, ast,
      NODE(TK_USE,
      NONE
      STRING(stringtab("builtin"))
      NONE));

    ast_add(ast, builtin);
  }

  if((docstring == NULL) || (ast_id(docstring) != TK_STRING))
    return AST_OK;

  ast_t* package_docstring = ast_childlast(package);

  if(ast_id(package_docstring) == TK_STRING)
  {
    ast_error(docstring, "the package already has a docstring");
    ast_error(package_docstring, "the existing docstring is here");
    return AST_ERROR;
  }

  ast_append(package, docstring);
  ast_remove(docstring);
  return AST_OK;
}
开发者ID:shepheb,项目名称:ponyc,代码行数:36,代码来源:sugar.c


示例8: sugar_as

static ast_result_t sugar_as(pass_opt_t* opt, ast_t** astp)
{
  typecheck_t* t = &opt->check;
  ast_t* ast = *astp;
  AST_GET_CHILDREN(ast, expr, type);

  ast_t* pattern_root = ast_from(type, TK_LEX_ERROR);
  ast_t* body_root = ast_from(type, TK_LEX_ERROR);
  add_as_type(t, type, pattern_root, body_root);

  ast_t* body = ast_pop(body_root);
  ast_free(body_root);

  if(body == NULL)
  {
    // No body implies all types are "don't care"
    ast_error(ast, "Cannot treat value as \"don't care\"");
    ast_free(pattern_root);
    return AST_ERROR;
  }

  // Don't need top sequence in pattern
  assert(ast_id(ast_child(pattern_root)) == TK_SEQ);
  ast_t* pattern = ast_pop(ast_child(pattern_root));
  ast_free(pattern_root);

  REPLACE(astp,
    NODE(TK_MATCH, AST_SCOPE
      NODE(TK_SEQ, TREE(expr))
      NODE(TK_CASES, AST_SCOPE
        NODE(TK_CASE, AST_SCOPE
          TREE(pattern)
          NONE
          TREE(body)))
      NODE(TK_SEQ, AST_SCOPE NODE(TK_ERROR, NONE))));

  return ast_visit(astp, pass_sugar, NULL, opt, PASS_SUGAR);
}
开发者ID:shepheb,项目名称:ponyc,代码行数:38,代码来源:sugar.c


示例9: BTreeAddBranch

static int BTreeAddBranch(btree_t t, index_t nidx,
                          int idx,
                          double *k, index_t *ptr)
{
  int i,j;
  double key[MAXCARD];
  index_t branch[MAXCARD+1];
  int level;
  index_t nidx1;
  node_t n1;
  node_t n;

  n = NODE(t,nidx);

  if (n->count < MAXCARD - 1)
    {
      i = n->count;
      if (i > 0)
        /*shift to get space*/
        for(; n->branch[i-1].key > *k ; i--)
          {
            n->branch[i].key = n->branch[i-1].key;
            n->branch[i+1].child = n->branch[i].child;
          }
      n->branch[i].key = *k;
      n->branch[i+1].child = (index_t) *ptr;
      n->branch[i].child = n->branch[idx].child;
      n->count ++;
      return FALSE;
    }
  else
    {
      for(i = n->count, j = MAXCARD_(t);
          n->branch[i-1].key > *k;
          i--, j--)
        {
          key[j - 1] = n->branch[i-1].key;
          branch[j] = n->branch[i].child;
        }
      key[j - 1] = *k;
      branch[j - 1] = n->branch[idx].child;
      branch[j] = (index_t) *ptr;
      j--;
      for(; i > 0;i--,j--)
        {
          key[j-1] = n->branch[i-1].key;
          branch[j-1] = n->branch[i-1].child;
        }

      level = n->level;
      BTreeNodeInit(t,nidx);
      n->level = level;

      nidx1 = BTreeNewNode(t);
      /* account for possible node pointer change*/
      n = NODE(t,nidx);
      n1 = NODE(t,nidx1);

      n1->level = level;

      for (i = 0; i < MAXCARD / 2; i ++)
        {
          n->branch[i].key = key[i];
          n->branch[i].child = branch[i];
          n->count ++;
        }
      n->branch[i].child = branch[i];

      *k = key[i];
      *ptr = nidx1;

      for (j = 0, i++; i < MAXCARD; j ++, i ++)
        {
          n1->branch[j].key = key[i];
          n1->branch[j].child = branch[i];
          n1->count ++;
        }
      n1->branch[j].child = branch[i];

      return TRUE;
    }
}
开发者ID:davidvaz,项目名称:yap-udi,代码行数:82,代码来源:b+tree.c


示例10: expr_this

bool expr_this(pass_opt_t* opt, ast_t* ast)
{
  typecheck_t* t = &opt->check;

  if(t->frame->def_arg != NULL)
  {
    ast_error(ast, "can't reference 'this' in a default argument");
    return false;
  }

  sym_status_t status;
  ast_get(ast, stringtab("this"), &status);

  if(status == SYM_CONSUMED)
  {
    ast_error(ast, "can't use a consumed 'this' in an expression");
    return false;
  }

  assert(status == SYM_NONE);
  token_id cap = cap_for_this(t);

  if(!cap_sendable(cap) && (t->frame->recover != NULL))
    cap = TK_TAG;

  bool make_arrow = false;

  if(cap == TK_BOX)
  {
    cap = TK_REF;
    make_arrow = true;
  }

  ast_t* type = type_for_this(opt, ast, cap, TK_NONE, false);

  if(make_arrow)
  {
    BUILD(arrow, ast, NODE(TK_ARROW, NODE(TK_THISTYPE) TREE(type)));
    type = arrow;
  }

  // Get the nominal type, which may be the right side of an arrow type.
  ast_t* nominal;
  bool arrow;

  if(ast_id(type) == TK_NOMINAL)
  {
    nominal = type;
    arrow = false;
  } else {
    nominal = ast_childidx(type, 1);
    arrow = true;
  }

  ast_t* typeargs = ast_childidx(nominal, 2);
  ast_t* typearg = ast_child(typeargs);

  while(typearg != NULL)
  {
    if(!expr_nominal(opt, &typearg))
    {
      ast_error(ast, "couldn't create a type for 'this'");
      ast_free(type);
      return false;
    }

    typearg = ast_sibling(typearg);
  }

  if(!expr_nominal(opt, &nominal))
  {
    ast_error(ast, "couldn't create a type for 'this'");
    ast_free(type);
    return false;
  }

  if(arrow)
    type = ast_parent(nominal);
  else
    type = nominal;

  ast_settype(ast, type);
  return true;
}
开发者ID:Preetam,项目名称:ponyc,代码行数:84,代码来源:reference.c


示例11: is_pdag_acyclic

SEXP is_pdag_acyclic(SEXP arcs, SEXP nodes, SEXP return_nodes, 
    SEXP directed, SEXP debug) {

int i = 0, j = 0, z = 0;
int nrows = LENGTH(nodes);
int check_status = nrows, check_status_old = nrows;
int *rowsums = NULL, *colsums = NULL, *crossprod = NULL, *a = NULL;
int *debuglevel = NULL;
short int *status = NULL;
SEXP amat;

  /* dereference the debug parameter. */
  debuglevel = LOGICAL(debug);

  /* build the adjacency matrix from the arc set.  */
  if (*debuglevel > 0)
    Rprintf("* building the adjacency matrix.\n");

  PROTECT(amat = arcs2amat(arcs, nodes));
  a = INTEGER(amat);

  /* should we consider only directed arcs? */
  if (isTRUE(directed)) {

    /* removing undirected arcs, so that only cycles made only of directed
     * arcs will make the function return TRUE. */

    for (i = 0; i < nrows; i++)
      for (j = 0; j < nrows; j++)
        if ((a[CMC(i, j, nrows)] == 1) && (a[CMC(j, i, nrows)] == 1))
          a[CMC(i, j, nrows)] = a[CMC(j, i, nrows)] = 0;

  }/*THEN*/

  /* initialize the status, {row,col}sums and crossprod arrays. */
  status = allocstatus(nrows);
  rowsums = alloc1dcont(nrows);
  colsums = alloc1dcont(nrows);
  crossprod = alloc1dcont(nrows);

  if (*debuglevel > 0)
    Rprintf("* checking whether the partially directed graph is acyclic.\n");

  /* even in the worst case scenario at least two nodes are marked as
   * good at each iteration, so even ceil(nrows/2) iterations should be
   * enough. */
  for (z = 0; z < nrows; z++) {

start:

    if (*debuglevel > 0)
      Rprintf("* beginning iteration %d.\n", z + 1);

    for (i = 0; i < nrows; i++) {

      /* skip known-good nodes. */
      if (status[i] == GOOD) continue;

      /* reset and update row and column totals. */
      rowsums[i] = colsums[i] = crossprod[i] = 0;

      /* compute row and column totals for the i-th node. */
      for (j = 0; j < nrows; j++) {

        rowsums[i] += a[CMC(i, j, nrows)];
        colsums[i] += a[CMC(j, i, nrows)];
        crossprod[i] += a[CMC(i, j, nrows)] * a[CMC(j, i, nrows)];

      }/*FOR*/

there:

      if (*debuglevel > 0)
        Rprintf("  > checking node %s (%d child(ren), %d parent(s), %d neighbours).\n",
          NODE(i), rowsums[i], colsums[i], crossprod[i]);

      /* if either total is zero, the node is either a root node or a
       * leaf node, and is not part of any cycle. */
      if (((rowsums[i] == 0) || (colsums[i] == 0)) ||
          ((crossprod[i] == 1) && (rowsums[i] == 1) && (colsums[i] == 1))) {

        if (*debuglevel > 0)
          Rprintf("  @ node %s is cannot be part of a cycle.\n", NODE(i));

        /* update the adjacency matrix and the row/column totals. */
        for (j = 0; j < nrows; j++)
          a[CMC(i, j, nrows)] = a[CMC(j, i, nrows)] = 0;

        rowsums[i] = colsums[i] = crossprod[i] = 0;

        /* mark the node as good. */
        status[i] = GOOD;
        check_status--;

      }/*THEN*/
      else if (crossprod[i] == 1) {

        /* find the other of the undirected arc. */
        for (j = 0; j < i; j++)
          if (a[CMC(i, j, nrows)] * a[CMC(j, i, nrows)] == 1)
//.........这里部分代码省略.........
开发者ID:gasse,项目名称:bnlearn-clone-3.4,代码行数:101,代码来源:acyclic.c


示例12: is_fun_sub_fun

static bool is_fun_sub_fun(ast_t* sub, ast_t* super,
  ast_t* isub, ast_t* isuper)
{
  token_id tsub = ast_id(sub);
  token_id tsuper = ast_id(super);

  switch(tsub)
  {
    case TK_NEW:
    case TK_BE:
    case TK_FUN:
      break;

    default:
      return false;
  }

  switch(tsuper)
  {
    case TK_NEW:
    case TK_BE:
    case TK_FUN:
      break;

    default:
      return false;
  }

  // A constructor can only be a subtype of a constructor.
  if(((tsub == TK_NEW) || (tsuper == TK_NEW)) && (tsub != tsuper))
    return false;

  AST_GET_CHILDREN(sub, sub_cap, sub_id, sub_typeparams, sub_params);
  AST_GET_CHILDREN(super, super_cap, super_id, super_typeparams, super_params);

  // Must have the same name.
  if(ast_name(sub_id) != ast_name(super_id))
    return false;

  // Must have the same number of type parameters and parameters.
  if((ast_childcount(sub_typeparams) != ast_childcount(super_typeparams)) ||
    (ast_childcount(sub_params) != ast_childcount(super_params)))
    return false;

  ast_t* r_sub = sub;

  if(ast_id(super_typeparams) != TK_NONE)
  {
    // Reify sub with the type parameters of super.
    BUILD(typeargs, super_typeparams, NODE(TK_TYPEARGS));
    ast_t* super_typeparam = ast_child(super_typeparams);

    while(super_typeparam != NULL)
    {
      AST_GET_CHILDREN(super_typeparam, super_id, super_constraint);
      token_id cap = cap_from_constraint(super_constraint);

      BUILD(typearg, super_typeparam,
        NODE(TK_TYPEPARAMREF, TREE(super_id) NODE(cap) NONE));

      ast_t* def = ast_get(super_typeparam, ast_name(super_id), NULL);
      ast_setdata(typearg, def);
      ast_append(typeargs, typearg);

      super_typeparam = ast_sibling(super_typeparam);
    }

    r_sub = reify(sub, sub, sub_typeparams, typeargs);
    ast_free_unattached(typeargs);
  }

  bool ok = is_reified_fun_sub_fun(r_sub, super, isub, isuper);

  if(r_sub != sub)
    ast_free_unattached(r_sub);

  return ok;
}
开发者ID:pengzj,项目名称:ponyc,代码行数:78,代码来源:subtype.c


示例13: naivepred


//.........这里部分代码省略.........
  /* initialize the random seed, just in case we need it for tie breaking. */
  GetRNGstate();

  /* for each observation... */
  for (i = 0; i < n; i++) {

    /* ... reset the scratch space and the indexes array... */
    for (k = 0; k < tr_nlevels; k++) {

      scratch[k] = log(pr[k]);
      iscratch[k] = k + 1;

    }/*FOR*/

    if (*debuglevel > 0)
      Rprintf("* predicting the value of observation %d.\n", i + 1);

    /* ... and for each conditional probability table... */
    for (j = 0; j < nvars; j++) {

      /* ... skip the training variable... */
      if (*tr_id == j + 1)
        continue;

      /* ... (this is the root node of the Chow-Liu tree) ... */
      if (prn[j] == NA_INTEGER) {

        /* ... and for each row of the conditional probability table... */
        for (k = 0; k < tr_nlevels; k++) {

          if (*debuglevel > 0) {

            Rprintf("  > node %s: picking cell %d (%d, %d) from the CPT (p = %lf).\n",
              NODE(j), CMC(ex[j][i] - 1, k, ex_nlevels[j]), ex[j][i], k + 1,
              cpt[j][CMC(ex[j][i] - 1, k, ex_nlevels[j])]);

          }/*THEN*/

          /* ... update the posterior probability. */
          scratch[k] += log(cpt[j][CMC(ex[j][i] - 1, k, ex_nlevels[j])]);

        }/*FOR*/

      }/*THEN*/
      else {

        /* ... and for each row of the conditional probability table... */
        for (k = 0; k < tr_nlevels; k++) {

          /* (the first dimension corresponds to the current node [X], the second
           * to the training node [Y], the third to the only parent of the current
           * node [Z]; CMC coordinates are computed as X + Y * NX + Z * NX * NY. */
          idx = (ex[j][i] - 1) + k * ex_nlevels[j] + 
                  (ex[prn[j] - 1][i] - 1) * ex_nlevels[j] * tr_nlevels;

          if (*debuglevel > 0) {

            Rprintf("  > node %s: picking cell %d (%d, %d, %d) from the CPT (p = %lf).\n",
              NODE(j), idx, ex[j][i], k + 1, ex[prn[j] - 1][i], cpt[j][idx]);

          }/*THEN*/

          /* ... update the posterior probability. */
          scratch[k] += log(cpt[j][idx]);

        }/*FOR*/
开发者ID:gasse,项目名称:bnlearn-clone-3.1,代码行数:67,代码来源:predict.c


示例14: parse_literal

static int parse_literal(struct peg_grammar_parser *pgp, struct peg_cursor *pc,
			 int *litp)
{
	struct peg_grammar *peg = pgp->peg;
	struct peg_cursor npc = *pc;
	int nn;
	struct peg_node *pn;
	int c;
	int rv;
	uint i;
	char quote;
	struct raw value;

	quote = CHAR(pgp, &npc);
	if ( quote != '"' && quote != '\'' )
		return 0;
	npc.pos += 1;

	value.len = 0;
	do {
		rv = parse_char(pgp, &npc, &c);
		if ( rv < 0 )
			goto err;
		if ( rv == 0 ) {
			pgp->err = PEG_ERR_BAD_LITERAL;
			goto err;
		}
		value.len += 1;
	} while ( c != quote );

	nn = peg_node_new(peg, PEG_LITERAL, pc->line);
	if ( nn < 0 ) {
		pgp->err = PEG_ERR_NOMEM;
		return -1;
	}
	value.data = malloc(value.len);
	if ( value.data == NULL ) {
		pgp->err = PEG_ERR_NOMEM;
		peg_node_free(peg, nn);
		return -1;
	}

	/* now copy/translate the string for real since we know */
	/* its true length and that it decodes correctly. */
	npc.pos = pc->pos + 1;
	npc.line = pc->line;
	for ( i = 0; i < value.len - 1; ++i ) {
		rv = parse_char(pgp, &npc, &c);
		abort_unless(rv > 0); /* tested above */
		value.data[i] = c;
	}
	value.data[i] = '\0';

	pn = NODE(peg, nn);
	pn->pl_value = value;
	pn->pl_value.len -= 1;

	pc->pos = npc.pos + 1; /* skip last quote */
	pc->line = npc.line;
	*litp = nn;
	skip_space(pgp, pc);
	return 1;

err:
	pgp->eloc = npc;
	return -1;
}
开发者ID:ctelfer,项目名称:catlib,代码行数:67,代码来源:peg.c


示例15: NODE

/**
 * Get the text of this node.
 * @return	Node text.
 */
String Comment::getText(void) {
	return NODE(node)->content;
}
开发者ID:alexjordan,项目名称:otawa,代码行数:7,代码来源:xom_Comment.cpp


示例16: Node

/**
 * Build a new text node by cloning an existing one.
 * @param text	Text node to clone.
 */
Comment::Comment(const Comment *comment): Node(xmlCopyNode(NODE(comment->node), 1)) {
	ASSERT(node);
}
开发者ID:alexjordan,项目名称:otawa,代码行数:7,代码来源:xom_Comment.cpp


示例17: exchange

static inline void exchange(heap_t h, size_t i, size_t j)
{
   struct node tmp = NODE(h, j);
   NODE(h, j) = NODE(h, i);
   NODE(h, i) = tmp;
}
开发者ID:SnookEE,项目名称:nvc,代码行数:6,代码来源:heap.c


示例18: addentry

void addentry(char *dir,char *file,uint32_t type,struct Node4D *boss,bool flow)
{
   struct osFileEntry *fe;
   struct fileentry *entry;
   struct Node4D n4d;
   char buf[200];
   char buf2[200];
   uint32_t hex;

   hex=hextodec(file);

   if(boss)
   {
      Copy4D(&n4d,boss);
      n4d.Point = hex;
   }
   else
   {
      n4d.Zone = cfg_Zone;
      n4d.Net = NET(hex);
      n4d.Node = NODE(hex);
      n4d.Point = 0;
   }

   if(Compare4DPat(&cfg_Pattern,&n4d)!=0)
      return;

   if(dir) MakeFullPath(dir,file,buf,200);
   else    mystrncpy(buf,file,200);

   MakeFullPath(cfg_Dir,buf,buf2,200);

   if(!(fe=osGetFileEntry(buf2)))
   {
      return;
   }

   if(!(entry=osAlloc(sizeof(struct fileentry))))
   {
      osFree(fe);
      return;
   }

   Copy4D(&entry->Node,&n4d);

   if(dir)
   {
      MakeFullPath(dir,file,entry->file,100);
      MakeFullPath(cfg_Dir,dir,entry->dir,100);
   }
   else
   {
      mystrncpy(entry->file,file,100);
      mystrncpy(entry->dir,cfg_Dir,100);
   }

   mystrncpy(entry->file,buf,100);
   entry->size=fe->Size;
   entry->date=fe->Date;
   entry->type=type;
   entry->flow=flow;

   jbAddNode(&list,(struct jbNode *)entry);
   osFree(fe);
}
开发者ID:evil-deus-ex,项目名称:crashmail,代码行数:65,代码来源:crashlistout.c


示例19: parse_primary

static int parse_primary(struct peg_grammar_parser *pgp, struct peg_cursor *pc,
			 int *prip)
{
	struct peg_grammar *peg = pgp->peg;
	int pri;
	int rv;
	int match = -1;
	struct peg_cursor npc = *pc;
	int prefix = PEG_ATTR_NONE;
	int suffix = PEG_ATTR_NONE;
	int action = PEG_ACT_NONE;
	struct raw r = { 0, NULL };
	struct peg_node *pn;

	if ( string_match(pgp, "&", &npc) )
		prefix = PEG_ATTR_AND;
	else if ( string_match(pgp, "!", &npc) )
		prefix = PEG_ATTR_NOT;

	if ( (rv = parse_id_and_not_arrow(pgp, &npc, &match)) != 0 ) {
		if ( rv < 0 )
			goto err;
	} else if ( (rv = parse_paren_expr(pgp, &npc, &match)) != 0 ) {
		if ( rv < 0 )
			goto err;
	} else if ( (rv = parse_literal(pgp, &npc, &match)) != 0 ) {
		if ( rv < 0 )
			goto err;
	} else if ( (rv = parse_class(pgp, &npc, &match)) != 0 ) {
		if ( rv < 0 )
			goto err;
	} else {
		if ( prefix == PEG_ATTR_NONE )
			return 0;
		pgp->err = PEG_ERR_BAD_PRIMARY;
		pgp->eloc = *pc;
		return -1;
	}

	pri = peg_node_new(peg, PEG_PRIMARY, pc->line);
	if ( pri < 0 ) {
		pgp->err = PEG_ERR_NOMEM;
		goto err;
	}

	if ( string_match(pgp, "?", &npc) )
		suffix = PEG_ATTR_QUESTION;
	else if ( string_match(pgp, "*", &npc) )
		suffix = PEG_ATTR_STAR;
	else if ( string_match(pgp, "+", &npc) )
		suffix = PEG_ATTR_PLUS;
	else
		suffix = PEG_ATTR_NONE;

	rv = parse_code(pgp, &npc, &r);
	if ( rv < 0 )
		goto err;
	if ( rv > 0 ) {
		action = PEG_ACT_CODE;
	} else {
		rv = parse_action_label(pgp, &npc, &r);
		if ( rv < 0 )
			goto err;
		if ( rv > 0 )
			action = PEG_ACT_LABEL;
	}

	pn = NODE(peg, pri);
	pn->pn_next = -1;
	pn->pp_match = match;
	pn->pp_prefix = prefix;
	pn->pp_suffix = suffix;
	pn->pp_action = action;
	pn->pn_action_cb = NULL;
	pn->pp_code = r;

	*pc = npc;
	*prip = pri;
	return 1;

err:
	peg_node_free(peg, match);
	return -1;
}
开发者ID:ctelfer,项目名称:catlib,代码行数:84,代码来源:peg.c


示例20: BTreeAddLeaf

static int BTreeAddLeaf(btree_t t, index_t nidx,
                        double *k, index_t *ptr)
{
  int i,j;
  double key[MAXCARD];
  index_t branch[MAXCARD];
  node_t n;
  index_t nidx1;
  node_t n1;

  n = NODE(t, nidx);
  assert(n);

  if (n->count < MAXCARD_(t) - 1) /*split not necessary*/
    {
      i = n->count;
      if (i > 0)
        for (; n->branch[i-1].key > *k; i--)
          {
            n->branch[i].key = n->branch[i-1].key;
            n->branch[i].child = n->branch[i-1].child;
          }
      n->branch[i].key = *k;
      n->branch[i].child = (index_t) *ptr;
      n->count ++;
      return FALSE;
    }
  else /*needs to split*/
    {
      for(i = n->count - 1, j = MAXCARD - 1;
          n->branch[i].key > *k;
          i--, j--)
        {
          key[j] = n->branch[i].key;
          branch[j] = n->branch[i].child;
        }
      key[j] = *k;
      branch[j] = (index_t) *ptr;
      j--;
      for(; i >= 0;i--,j--)
        {
          key[j] = n->branch[i].key;
          branch[j] = n->branch[i].child;
        }

      n->count = 0;

      nidx1 = BTreeNewNode(t);
      /* account for possible node pointer change*/
      n = NODE(t,nidx);
      n1 = NODE(t,nidx1);

      n1->level = n->level;

      for (i = 0; i <= MAXCARD_(t) / 2; i ++)
        {
          n->branch[i].key = key[i];
          n->branch[i].child = branch[i];
          n->count ++;
        }
      *k = key[i-1];
      *ptr = nidx1;
      for (j = 0; i < MAXCARD; j ++, i ++)
        {
          n1->branch[j].key = key[i];
          n1->branch[j].child = branch[i];
          n1->count ++;
        }

      /*linked list*/
      n1->branch[MAXCARD_(t)-1].child = n->branch[MAXCARD_(t)-1].child;
      n->branch[MAXCARD_(t)-1].child = nidx1;

    return TRUE;
    }
}
开发者ID:davidvaz,项目名称:yap-udi,代码行数:76,代码来源:b+tree.c



注:本文中的NODE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NODELET_DEBUG函数代码示例发布时间:2022-05-30
下一篇:
C++ NN_ASSERT函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap