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

C++ push_array函数代码示例

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

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



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

示例1: main

int main() {
	int i, j, s, sum=0;
	UNDIRECTED first=NULL, min;
	printf("Enter number of vertices\n");
	scanf("%d", &n);
	for(i=0;i<n;i++) {
		for(j=0;j<n;j++) {
			scanf("%d", &input[i][j]);
		}
	}
	printf("Enter source\n");
	scanf("%d", &s);
	reset_all();
	remove_element_array(vertex, &vindex, s);
	push_array(finished, &findex, s);
	while(findex<n-1) {
		for(i=0;i<=findex;i++) {
			for(j=0;j<=vindex;j++) {
				first=insert_ll(first, new_connection(finished[i], vertex[j]));
			
			}
		}
		min=find_minimum(first);
		push_array(finished, &findex, min->d);
		remove_element_array(vertex, &vindex, min->d);
		first=destroy_ll(first);
		sum+=distance(min->s, min->d);
		printf("%d->%d = %d\n", min->s, min->d, distance(min->s, min->d));
	}
	printf("Total distance = %d\n", sum);
	return 0;
}
开发者ID:tkshnwesper,项目名称:ada-sem4,代码行数:32,代码来源:prim.c


示例2: pr_parser_prepare

int pr_parser_prepare(pool *p, xaset_t **parsed_servers) {

  if (p == NULL) {
    if (parser_pool == NULL) {
      parser_pool = make_sub_pool(permanent_pool);
      pr_pool_tag(parser_pool, "Parser Pool");
    }

    p = parser_pool;
  }

  if (parsed_servers == NULL) {
    parser_server_list = &server_list;

  } else {
    parser_server_list = parsed_servers;
  }

  parser_servstack = make_array(p, 1, sizeof(server_rec *));
  parser_curr_server = (server_rec **) push_array(parser_servstack);
  *parser_curr_server = main_server;

  parser_confstack = make_array(p, 10, sizeof(config_rec *));
  parser_curr_config = (config_rec **) push_array(parser_confstack);
  *parser_curr_config = NULL;

  return 0;
}
开发者ID:proftpd,项目名称:proftpd,代码行数:28,代码来源:parser.c


示例3: parse_feat

/* Many FTP servers (e.g. IIS) use the semicolon delimiter syntax, as used
 * for listing the MLSD/MLST facts, for other FEAT values (e.g. AUTH, PROT,
 * etc).
 *
 * NOTE: Should this return a table rather than an array, for easier lookup
 * of parsed values by callers?
 */
static int parse_feat(pool *p, const char *feat, array_header **res) {
    char *ptr, *ptr2 = NULL;
    array_header *vals;
    size_t len;

    vals = make_array(p, 1, sizeof(char *));

    /* No semicolons in this value?  No work to do...*/
    ptr = strchr(feat, ';');
    if (ptr == NULL) {
        *((char **) push_array(vals)) = pstrdup(p, feat);
        *res = vals;
        return vals->nelts;
    }

    len = ptr - feat;
    if (len > 0) {
        *((char **) push_array(vals)) = pstrndup(p, feat, len);
    }

    /* Watch for any sequences of just semicolons. */
    while (*ptr == ';') {
        pr_signals_handle();
        ptr++;
    }

    ptr2 = strchr(ptr, ';');
    while (ptr2 != NULL) {
        pr_signals_handle();

        len = ptr2 - ptr;
        if (len > 0) {
            *((char **) push_array(vals)) = pstrndup(p, ptr, len);
        }

        ptr = ptr2;
        while (*ptr == ';') {
            pr_signals_handle();
            ptr++;
        }

        ptr2 = strchr(ptr, ';');
    }

    /* Since the semicolon delimiter syntax uses a trailing semicolon,
     * we shouldn't need to worry about something like "...;FOO".  Right?
     */

    *res = vals;
    return vals->nelts;
}
开发者ID:brownvin81,项目名称:proftpd-mod_proxy,代码行数:58,代码来源:sess.c


示例4: tokenize

static void tokenize( struct pike_string *s )
{
    int in_string = 0;
    unsigned int ts=0, i, len=s->len;
    const char *data = s->str;
    struct svalue *osp = Pike_sp;
    push_array( allocate_array_no_init( 0, 100 ) );
    for( i=0; i<len; i++ )
    {
        if( in_string )
        {
            if( (data[i]=='@') )
            {
                if( data[i+1]!='@' )
                {
                    push_token( data, ts, i-1 );
                    in_string=0;
                    ts=i+1;
                }
                else
                    i++;
            }
        }
        else
        {
            switch( data[i] )
            {
            case '@':
                ts=i+1;
                in_string=1;
                break;
            case ':':
            case ' ':
            case '\t':
            case '\n':
            case '\r':
                if( ts < i ) push_token( data, ts, i-1 );
                ts=i+1;
                break;
            case ';':
                if( ts < i ) push_token( data, ts, i-1 );
                ts=i+1;
                push_array( allocate_array_no_init( 0, 10 ) );
                break;
            }
        }
    }
    if( ts < len ) push_token( data, ts, len-1 );
    f_aggregate( Pike_sp-osp );
}
开发者ID:johan,项目名称:pike,代码行数:50,代码来源:rcs.c


示例5: pr_ctrls_parse_msg

int pr_ctrls_parse_msg(pool *msg_pool, char *msg, unsigned int *msgargc,
    char ***msgargv) {
  char *tmp = msg, *str = NULL;
  pool *tmp_pool = NULL;
  array_header *msgs = NULL;

  /* Sanity checks */
  if (!msg_pool || !msgargc || !msgargv) {
    errno = EINVAL;
    return -1;
  }

  tmp_pool = make_sub_pool(msg_pool);

  /* Allocate an array_header, and push each space-delimited string
   * (respecting quotes and escapes) into the array.  Once done,
   * destroy the array.
   */
 
  msgs = make_array(tmp_pool, 0, sizeof(char *));

  while ((str = ctrls_sep(&tmp)) != NULL)
    *((char **) push_array(msgs)) = pstrdup(msg_pool, str);

  *msgargc = msgs->nelts;
  *msgargv = (char **) msgs->elts;

  destroy_pool(tmp_pool);

  return 0;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:31,代码来源:ctrls.c


示例6: pr_fs_virtual_path

static array_header *path_split(pool *p, const char *path) {
  char buf[PR_TUNABLE_PATH_MAX+1], *full_path;
  size_t full_pathlen;
  array_header *first, *components;

  pr_fs_virtual_path(path, buf, sizeof(buf)-1);
  full_path = buf;
  full_pathlen = strlen(full_path);

  /* If the path ENDS in '/', append '.' to it. */
  if (full_path[full_pathlen-1] == '/' &&
      full_pathlen < (sizeof(buf)-1)) {
    full_path[full_pathlen] = '.';
  }

  first = make_array(p, 1, sizeof(char *));

  /* The first component is ALWAYS '/'. */
  *((char **) push_array(first)) = pstrdup(p, "/");

  if (full_pathlen == 1) {
    return first;
  }

  components = pr_str_text_to_array(p, full_path, '/');
  if (components != NULL) {
    components = append_arrays(p, first, components);
  }

  pr_trace_msg(trace_channel, 19, "split path '%s' into %u components", path,
    components->nelts);
  return components;
}
开发者ID:Castaglia,项目名称:proftpd-mod_explain,代码行数:33,代码来源:path.c


示例7: make_sub_pool

pr_regex_t *pr_regexp_alloc(module *m) {
  pr_regex_t *pre = NULL;
  pool *re_pool = NULL;

  /* If no regex-tracking list has been allocated, create one.  Register a
   * cleanup handler for this pool, to free up the data in the list.
   */
  if (regexp_pool == NULL) {
    regexp_pool = make_sub_pool(permanent_pool);
    pr_pool_tag(regexp_pool, "Regexp Pool");
    regexp_list = make_array(regexp_pool, 0, sizeof(pr_regex_t *));
  }

  re_pool = pr_pool_create_sz(regexp_pool, 128);
  pr_pool_tag(re_pool, "regexp pool");

  pre = pcalloc(re_pool, sizeof(pr_regex_t));
  pre->regex_pool = re_pool;
  pre->m = m;

  /* Add this pointer to the array. */
  *((pr_regex_t **) push_array(regexp_list)) = pre;

  return pre;
}
开发者ID:netdna,项目名称:proftpd,代码行数:25,代码来源:regexp.c


示例8: regexp_split

/*! @decl array(string) split(string s)
 *! Works as @[match], but returns an array of the strings that
 *! matched the subregexps. Subregexps are those contained in "( )" in
 *! the regexp. Subregexps that were not matched will contain zero.
 *! If the total regexp didn't match, zero is returned.
 *!
 *! @bugs
 *!   You can currently only have 39 subregexps.
 *!
 *! @bugs
 *!   The current implementation doesn't support searching
 *!   in strings containing the NUL character or any
 *!   wide character.
 *!
 *! @seealso
 *!   @[match]
 */
static void regexp_split(INT32 args)
{
  struct pike_string *s;
  struct regexp *r;

  get_all_args("Regexp.SimpleRegexp->split", args, "%S", &s);

  if(pike_regexec(r=THIS->regexp, s->str))
  {
    int i,j;
    add_ref(s);
    pop_n_elems(args);
    for(j=i=1;i<NSUBEXP;i++)
    {
      if(!r->startp[i] || !r->endp[i])
      {
	push_int(0);
      }else{
	push_string(make_shared_binary_string(r->startp[i],
					      r->endp[i]-r->startp[i]));
	j=i;
      }
    }
    if(j<i-1) pop_n_elems(i-j-1);
    push_array(aggregate_array(j));
    free_string(s);
  }else{
    pop_n_elems(args);
    push_int(0);
  }
}
开发者ID:ajinkya007,项目名称:pike-1,代码行数:48,代码来源:glue.c


示例9: f_ldap_explode_dn

/*
 **| method: array(string) explode_dn ( string dn );
 **| alt: array(string) explode_dn ( string dn, int notypes );
 **|  Takes a DN and converts it into an array of its components,
 **|  called RDN (Relative Distinguished Name).
 **
 **| arg: string dn
 **|  The DN to explode.
 **
 **| arg: int notypes
 **|  If != 0 then the types of the DN components will be ignored and
 **|  *not present in the output. Defaults to 1.
 **
 **| returns: an array of RDN entries.
 */
static void
f_ldap_explode_dn(INT32 args)
{
    struct pike_string       *dn;
    char                    **edn;
    int                       notypes = 1;    

    switch (args) {
        case 2:
            if (ARG(2).type != T_INT)
                Pike_error("OpenLDAP.Client->explode_dn(): argument 2 must be an integer\n");
            notypes = ARG(2).u.integer;
            /* fall through */
            
        case 1:
            if (ARG(1).type != T_STRING)
                Pike_error("OpenLDAP.Client->explode_dn(): argument 1 must be an integer\n");
            dn = ARG(1).u.string;
            break;
            
        default:
            Pike_error("OpenLDAP.Client->explode_dn(): expects at most 2 and at least 1 argument\n");
            break;
    }

    pop_n_elems(args);
    edn = ldap_explode_dn(dn->str, notypes);
    if (!edn) {
        push_int(0);
        return;
    }

    push_array(make_pike_array(edn));
    ldap_value_free(edn);
}
开发者ID:hww3,项目名称:pexts,代码行数:50,代码来源:ol_ldap.c


示例10: pr_ctrls_add_response

int pr_ctrls_add_response(pr_ctrls_t *ctrl, char *fmt, ...) {
  char buf[PR_TUNABLE_BUFFER_SIZE] = {'\0'};
  va_list resp;

  /* Sanity check */
  if (!ctrl || !fmt) {
    errno = EINVAL;
    return -1;
  }

  /* Make sure the pr_ctrls_t has a temporary pool, from which the responses
   * will be allocated
   */
  if (!ctrl->ctrls_tmp_pool) {
    ctrl->ctrls_tmp_pool = make_sub_pool(ctrls_pool);
    pr_pool_tag(ctrl->ctrls_tmp_pool, "ctrls tmp pool");
  }

  if (!ctrl->ctrls_cb_resps)
    ctrl->ctrls_cb_resps = make_array(ctrl->ctrls_tmp_pool, 0,
      sizeof(char *));

  /* Affix the message */
  va_start(resp, fmt);
  vsnprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), fmt, resp);
  va_end(resp);

  buf[sizeof(buf) - 1] = '\0';

  /* add the given response */
  *((char **) push_array(ctrl->ctrls_cb_resps)) =
    pstrdup(ctrl->ctrls_tmp_pool, buf);

  return 0;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:35,代码来源:ctrls.c


示例11: make_array

/* Return an array of all supported/known configuration directives. */
static array_header *get_all_directives(pool *p) {
  array_header *names;
  conftable *tab;
  int idx;
  unsigned int hash;

  names = make_array(p, 1, sizeof(const char *));

  idx = -1;
  hash = 0;
  tab = pr_stash_get_symbol2(PR_SYM_CONF, NULL, NULL, &idx, &hash);
  while (idx != -1) {
    pr_signals_handle();

    if (tab != NULL) {
      *((const char **) push_array(names)) = pstrdup(p, tab->directive);

    } else {
      idx++;
    }

    tab = pr_stash_get_symbol2(PR_SYM_CONF, NULL, tab, &idx, &hash);
  }

  return names;
}
开发者ID:proftpd,项目名称:proftpd,代码行数:27,代码来源:parser.c


示例12: add_lmd_allow_from

MODRET add_lmd_allow_from(cmd_rec *cmd) {
    config_rec *c;
    int i;
    array_header *allowed_acls;

    if(cmd->argc < 2 )
        CONF_ERROR(cmd, "argument missing");

    CHECK_CONF(cmd, CONF_ROOT|CONF_GLOBAL);

    /* argv => LMDMemcachedHost 127.0.0.1 192.168.0.1 ... */
    c = find_config(main_server->conf, CONF_PARAM, "LMDBAllow", FALSE);
    if(c && c->argv[0]) {
        allowed_acls = c->argv[0];
    } else {
        c = add_config_param(cmd->argv[0], 0, NULL);
        c->argv[0] = allowed_acls =
          make_array(cmd->server->pool, 0, sizeof(char *));
    }

    for(i=1; i < cmd->argc; i++) {
        char *entry = cmd->argv[i];
        if (strcasecmp(entry, "all") == 0 ||
            strcasecmp(entry, "none") == 0) {
            break;
        }
        pr_netacl_t *acl = pr_netacl_create(cmd->server->pool, entry);
        *((pr_netacl_t **) push_array(allowed_acls)) = acl;
        pr_log_debug(DEBUG2,
            "%s: add LMDBAllow[%d] %s", MODULE_NAME, i, entry);
    }

    return PR_HANDLED(cmd);
}
开发者ID:hiboma,项目名称:proftpd-mod_libmemcached_deny_blacklist,代码行数:34,代码来源:mod_libmemcached_deny_blacklist.c


示例13: pr_ctrls_add_arg

int pr_ctrls_add_arg(pr_ctrls_t *ctrl, char *ctrls_arg) {

  /* Sanity checks */
  if (!ctrl || !ctrls_arg) {
    errno = EINVAL;
    return -1;
  }

  /* Make sure the pr_ctrls_t has a temporary pool, from which the args will
   * be allocated.
   */
  if (!ctrl->ctrls_tmp_pool) {
    ctrl->ctrls_tmp_pool = make_sub_pool(ctrls_pool);
    pr_pool_tag(ctrl->ctrls_tmp_pool, "ctrls tmp pool");
  }

  if (!ctrl->ctrls_cb_args)
    ctrl->ctrls_cb_args = make_array(ctrl->ctrls_tmp_pool, 0, sizeof(char *));

  /* Add the given argument */
  *((char **) push_array(ctrl->ctrls_cb_args)) = pstrdup(ctrl->ctrls_tmp_pool,
    ctrls_arg);

  return 0;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:25,代码来源:ctrls.c


示例14: reset_all

void reset_all() {
	int i;
	vindex=-1;
	for(i=0;i<n;i++) {
		push_array(vertex, &vindex, i);
	}
	findex=-1;
}
开发者ID:tkshnwesper,项目名称:ada-sem4,代码行数:8,代码来源:prim.c


示例15: make_array

static array_header *sqltab_fetch_daemons_cb(wrap2_table_t *sqltab,
    const char *name) {
  array_header *daemons_list = make_array(sqltab->tab_pool, 1, sizeof(char *));

  /* Simply return the service name we're given. */
  *((char **) push_array(daemons_list)) = pstrdup(sqltab->tab_pool, name);

  return daemons_list;
}
开发者ID:WiseMan787,项目名称:ralink_sdk,代码行数:9,代码来源:mod_wrap2_sql.c


示例16: add_config_ctxt

static void add_config_ctxt(config_rec *c) {
  if (!*parser_curr_config) {
    *parser_curr_config = c;

  } else {
    parser_curr_config = (config_rec **) push_array(parser_confstack);
    *parser_curr_config = c;
  }
}
开发者ID:SangramSahuFIS,项目名称:proftpd,代码行数:9,代码来源:parser.c


示例17: START_TEST

END_TEST

START_TEST (expr_eval_group_and_test) {
  char *names1[3] = { "foo", "bar", NULL }, *names2[2] = { "test", NULL },
    *names3[2] = { "!baz", NULL };
  int res;

  res = pr_expr_eval_group_and(NULL);
  fail_unless(res == -1, "Failed to handle null argument");
  fail_unless(errno == EINVAL, "Failed to set errno to EINVAL");

  session.group = NULL;
  session.groups = NULL;

  res = pr_expr_eval_group_and(names1);
  fail_unless(res == FALSE, "Expected FALSE, got TRUE");

  session.group = "test";

  res = pr_expr_eval_group_and(names1);
  fail_unless(res == FALSE, "Expected FALSE, got TRUE");

  res = pr_expr_eval_group_and(names2);
  fail_unless(res == TRUE, "Expected TRUE, got FALSE");

  res = pr_expr_eval_group_and(names3);
  fail_unless(res == TRUE, "Expected TRUE, got FALSE");

  session.group = NULL;
  session.groups = make_array(p, 2, sizeof(char *));
  *((char **) push_array(session.groups)) = "test";
  *((char **) push_array(session.groups)) = NULL;
  *((char **) push_array(session.groups)) = "spank";

  res = pr_expr_eval_group_and(names1);
  fail_unless(res == FALSE, "Expected FALSE, got TRUE");

  res = pr_expr_eval_group_and(names2);
  fail_unless(res == TRUE, "Expected TRUE, got FALSE");

  res = pr_expr_eval_group_and(names3);
  fail_unless(res == TRUE, "Expected TRUE, got FALSE");
}
开发者ID:Nakor78,项目名称:proftpd,代码行数:43,代码来源:expr.c


示例18: exec_parse_cmds

static void exec_parse_cmds(config_rec *c, char *cmds) {
  char *cmd = NULL;
  array_header *cmd_array = NULL;

  /* Allocate an array_header. */
  cmd_array = make_array(c->pool, 0, sizeof(char *));

  /* Add each command to the array. */
  while ((cmd = exec_get_cmd(&cmds)) != NULL)
    *((char **) push_array(cmd_array)) = pstrdup(c->pool, cmd);

  /* Terminate the array with a NULL. */
  *((char **) push_array(cmd_array)) = NULL;

  /* Store the array of commands in the config_rec. */
  c->argv[1] = cmd_array;

  return;
}
开发者ID:swarco,项目名称:swarco-linux-v2,代码行数:19,代码来源:mod_exec.c


示例19: get_enclosure_ranges

static Range_Array
get_enclosure_ranges(Application_Links *app, Partition *part,
                     Buffer_Summary *buffer, int32_t pos, uint32_t flags){
    Range_Array array = {0};
    array.ranges = push_array(part, Range, 0);
    for (;;){
        Range range = {0};
        if (find_scope_range(app, buffer, pos, &range, flags)){
            Range *r = push_array(part, Range, 1);
            *r = range;
            pos = range.first;
        }
        else{
            break;
        }
    }
    array.count = (int32_t)(push_array(part, Range, 0) - array.ranges);
    return(array);
}
开发者ID:felpzOliveira,项目名称:Fluids,代码行数:19,代码来源:4coder_default_hooks.cpp


示例20: pr_ctrls_set_user_acl

void pr_ctrls_set_user_acl(pool *usr_acl_pool, ctrls_usr_acl_t *usr_acl,
    const char *allow, char *userlist) {
  char *user = NULL, **users = NULL;
  array_header *uid_list = NULL;
  uid_t uid = 0;
  pool *tmp_pool = NULL;

  /* Sanity checks */
  if (usr_acl_pool == NULL ||
      usr_acl == NULL ||
      allow == NULL ||
      userlist == NULL) {
    return;
  }

  tmp_pool = make_sub_pool(usr_acl_pool);

  if (strncmp(allow, "allow", 6) == 0) {
    usr_acl->allow = TRUE;

  } else {
    usr_acl->allow = FALSE;
  }

  /* Parse the given expression into an array, then retrieve the UID
   * for each given name.
   */
  users = pr_ctrls_parse_acl(usr_acl_pool, userlist);

  /* Allocate an array of uid_t's */
  uid_list = make_array(usr_acl_pool, 0, sizeof(uid_t));

  for (user = *users; user != NULL; user = *++users) {

    /* Handle a user name of "*" differently. */
    if (strncmp(user, "*", 2) == 0) {
      usr_acl->nuids = 1;
      usr_acl->uids = NULL;
      destroy_pool(tmp_pool);
      return;

    } else {
      uid = pr_auth_name2uid(tmp_pool, user);
      if (uid == (uid_t) -1)
        continue;
    }

    *((uid_t *) push_array(uid_list)) = uid;
  }

  usr_acl->nuids = uid_list->nelts;
  usr_acl->uids = (uid_t *) uid_list->elts;

  destroy_pool(tmp_pool);
}
开发者ID:flxflx,项目名称:weasel,代码行数:55,代码来源:ctrls.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ push_call函数代码示例发布时间:2022-05-30
下一篇:
C++ pushValue函数代码示例发布时间: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