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

C++ duplicate函数代码示例

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

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



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

示例1: dtrMatrix_as_dtpMatrix

SEXP dtrMatrix_as_dtpMatrix(SEXP from)
{
    SEXP val = PROTECT(NEW_OBJECT(MAKE_CLASS("dtpMatrix"))),
	uplo = GET_SLOT(from, Matrix_uploSym),
	diag = GET_SLOT(from, Matrix_diagSym),
	dimP = GET_SLOT(from, Matrix_DimSym);
    int n = *INTEGER(dimP);

    SET_SLOT(val, Matrix_DimSym, duplicate(dimP));
    SET_SLOT(val, Matrix_diagSym, duplicate(diag));
    SET_SLOT(val, Matrix_uploSym, duplicate(uplo));
    full_to_packed_double(
	REAL(ALLOC_SLOT(val, Matrix_xSym, REALSXP, (n*(n+1))/2)),
	REAL(GET_SLOT(from, Matrix_xSym)), n,
	*CHAR(STRING_ELT(uplo, 0)) == 'U' ? UPP : LOW,
	*CHAR(STRING_ELT(diag, 0)) == 'U' ? UNT : NUN);
    SET_SLOT(val, Matrix_DimNamesSym,
	     duplicate(GET_SLOT(from, Matrix_DimNamesSym)));
    UNPROTECT(1);
    return val;
}
开发者ID:bedatadriven,项目名称:renjin-matrix,代码行数:21,代码来源:dtrMatrix.c


示例2: string_dup

  String* String::string_dup(STATE) {
    String* ns;

    ns = as<String>(duplicate(state));
    ns->shared(state, Qtrue);
    shared(state, Qtrue);

    // Fix for subclassing
    ns->klass(state, class_object(state));

    return ns;
  }
开发者ID:wjdix,项目名称:rubinius,代码行数:12,代码来源:string.cpp


示例3: main

int main (void) {
  /* program to coordinate the menu options and calls the requested function */

  struct node * first = NULL;   /* pointer to the first list item */
  char option[strMax];          /* user response to menu selection */

  printf ("Program to Maintain a List of Names\n");

  while (1) {
    /* print menu options */
    printf ("Options available\n");
    printf ("I - Insert a name (from the keyboard) into the list\n");
    printf ("P - Print the names on the list\n");
    printf ("F - Read a sequence of names from a file onto the list\n");
    printf ("R - Remove duplicate names (leaving only the first occurence)\n");
    printf ("D - Duplicate each node\n");
    printf ("Q - Quit\n");

    /* determine user selection */
    printf ("Enter desired option: ");
    scanf ("%s", option);
    
    switch (option[0])
      { case 'I':
        case 'i': 
          addName(&first);
          break;
        case 'P':
        case 'p': 
          print(first);
          break;
        case 'F':
        case 'f': 
          addNamesFromFile(&first);
          break;
        case 'R':
        case 'r': 
          removeDuplicates(first);
          break;
        case 'D': 
        case 'd': 
          duplicate(first);
          break;
        case 'Q':
        case 'q':
          printf ("Program terminated\n");
          return 0;
          break;
        default: printf ("Invalid Option - Try Again!\n");
          continue;
      }
  }
}
开发者ID:VBashlovkina,项目名称:161sp15,代码行数:53,代码来源:namelist-2014-sp.c


示例4: _new

    // support for C++ new and delete
    void * MemMgrItf :: _new ( size_t bytes )
    {
        FUNC_ENTRY ();

        // allocate new object plus header size
        Refcount * obj = ( Refcount * ) _alloc ( bytes, true );
        obj -> mmgr = ( MemMgrItf * ) duplicate ();
        obj -> obj_size = bytes;

        // return allocation
        return ( void * ) obj;
    }
开发者ID:ImAWolf,项目名称:ncbi-vdb,代码行数:13,代码来源:memmgr.cpp


示例5: do_args

SEXP attribute_hidden do_args(SEXP call, SEXP op, SEXP args, SEXP rho)
{
    SEXP s;

    checkArity(op,args);
    if (TYPEOF(CAR(args)) == STRSXP && length(CAR(args))==1) {
	PROTECT(s = installTrChar(STRING_ELT(CAR(args), 0)));
	SETCAR(args, findFun(s, rho));
	UNPROTECT(1);
    }

    if (TYPEOF(CAR(args)) == CLOSXP) {
	s = allocSExp(CLOSXP);
	SET_FORMALS(s, FORMALS(CAR(args)));
	SET_BODY(s, R_NilValue);
	SET_CLOENV(s, R_GlobalEnv);
	return s;
    }

    if (TYPEOF(CAR(args)) == BUILTINSXP || TYPEOF(CAR(args)) == SPECIALSXP) {
	char *nm = PRIMNAME(CAR(args));
	SEXP env, s2;
	PROTECT_INDEX xp;

	PROTECT_WITH_INDEX(env = findVarInFrame3(R_BaseEnv,
						 install(".ArgsEnv"), TRUE),
			   &xp);

	if (TYPEOF(env) == PROMSXP) REPROTECT(env = eval(env, R_BaseEnv), xp);
	PROTECT(s2 = findVarInFrame3(env, install(nm), TRUE));
	if(s2 != R_UnboundValue) {
	    s = duplicate(s2);
	    SET_CLOENV(s, R_GlobalEnv);
	    UNPROTECT(2);
	    return s;
	}
	UNPROTECT(1); /* s2 */
	REPROTECT(env = findVarInFrame3(R_BaseEnv, install(".GenericArgsEnv"),
					TRUE), xp);
	if (TYPEOF(env) == PROMSXP) REPROTECT(env = eval(env, R_BaseEnv), xp);
	PROTECT(s2 = findVarInFrame3(env, install(nm), TRUE));
	if(s2 != R_UnboundValue) {
	    s = allocSExp(CLOSXP);
	    SET_FORMALS(s, FORMALS(s2));
	    SET_BODY(s, R_NilValue);
	    SET_CLOENV(s, R_GlobalEnv);
	    UNPROTECT(2);
	    return s;
	}
	UNPROTECT(2);
    }
    return R_NilValue;
}
开发者ID:o-,项目名称:Rexperiments,代码行数:53,代码来源:builtin.c


示例6: tlocs2rlocs

SEXP tlocs2rlocs(SEXP tlocs, SEXP exonStarts, SEXP exonEnds,
		SEXP strand, SEXP decreasing_rank_on_minus_strand)
{
	SEXP ans, starts, ends, ans_elt;
	int decreasing_rank_on_minus_strand0, ans_length,
	    i, transcript_width, on_minus_strand, nlocs, j, tloc;

	decreasing_rank_on_minus_strand0 =
		LOGICAL(decreasing_rank_on_minus_strand)[0];
	ans_length = LENGTH(tlocs);
	PROTECT(ans = duplicate(tlocs));
	for (i = 0; i < ans_length; i++) {
		starts = VECTOR_ELT(exonStarts, i);
		ends = VECTOR_ELT(exonEnds, i);
		transcript_width = get_transcript_width(starts, ends, -1);
		if (transcript_width == -1) {
			UNPROTECT(1);
			error("%s", errmsg_buf);
		}
		on_minus_strand = strand_is_minus(strand, i);
		if (on_minus_strand == -1) {
			UNPROTECT(1);
			error("%s", errmsg_buf);
		}
		ans_elt = VECTOR_ELT(ans, i);
		if (ans_elt == R_NilValue) {
			nlocs = 0;
		} else if (IS_INTEGER(ans_elt)) {
			nlocs = LENGTH(ans_elt);
		} else {
			UNPROTECT(1);
			error("'tlocs' has invalid elements");
		}
		for (j = 0; j < nlocs; j++) {
			tloc = INTEGER(ans_elt)[j];
			if (tloc == NA_INTEGER)
				continue;
			if (tloc < 1 || tloc > transcript_width) {
				UNPROTECT(1);
				error("'tlocs[[%d]]' contains \"out of limits\" "
				      "transcript locations (length of "
				      "transcript is %d)", j + 1, transcript_width);
			}
			INTEGER(ans_elt)[j] = tloc2rloc(tloc,
				starts, ends,
				on_minus_strand,
				decreasing_rank_on_minus_strand0);
		}
	}
	UNPROTECT(1);
	return ans;
}
开发者ID:hcorrada,项目名称:GenomicRanges,代码行数:52,代码来源:transcript_utils.c


示例7: do_logic3

/* all, any */
SEXP attribute_hidden do_logic3(SEXP call, SEXP op, SEXP args, SEXP env)
{
    SEXP ans, s, t, call2;
    int narm, has_na = 0;
    /* initialize for behavior on empty vector
       all(logical(0)) -> TRUE
       any(logical(0)) -> FALSE
     */
    Rboolean val = PRIMVAL(op) == _OP_ALL ? TRUE : FALSE;

    PROTECT(args = fixup_NaRm(args));
    PROTECT(call2 = duplicate(call));
    SETCDR(call2, args);

    if (DispatchGroup("Summary", call2, op, args, env, &ans)) {
	UNPROTECT(2);
	return(ans);
    }

    ans = matchArgExact(R_NaRmSymbol, &args);
    narm = asLogical(ans);

    for (s = args; s != R_NilValue; s = CDR(s)) {
	t = CAR(s);
	/* Avoid memory waste from coercing empty inputs, and also
	   avoid warnings with empty lists coming from sapply */
	if(xlength(t) == 0) continue;
	/* coerceVector protects its argument so this actually works
	   just fine */
	if (TYPEOF(t) != LGLSXP) {
	    /* Coercion of integers seems reasonably safe, but for
	       other types it is more often than not an error.
	       One exception is perhaps the result of lapply, but
	       then sapply was often what was intended. */
	    if(TYPEOF(t) != INTSXP)
		warningcall(call,
			    _("coercing argument of type '%s' to logical"),
			    type2char(TYPEOF(t)));
	    t = coerceVector(t, LGLSXP);
	}
	val = checkValues(PRIMVAL(op), narm, LOGICAL(t), XLENGTH(t));
        if (val != NA_LOGICAL) {
            if ((PRIMVAL(op) == _OP_ANY && val)
                || (PRIMVAL(op) == _OP_ALL && !val)) {
                has_na = 0;
                break;
            }
        } else has_na = 1;
    }
    UNPROTECT(2);
    return has_na ? ScalarLogical(NA_LOGICAL) : ScalarLogical(val);
}
开发者ID:nirvananoob,项目名称:r-source,代码行数:53,代码来源:logic.c


示例8: read_wifi

void read_wifi(struct params *p)
{
	char buf[4096];
	int rc;
	struct ieee80211_frame *wh;

	rc = sniff(p->rx, buf, sizeof(buf));
	if (rc == -1)
		err(1, "sniff()");
        
	wh = get_wifi(buf, &rc);
	if (!wh)
		return;

	/* filter my own shit */
	if (memcmp(wh->i_addr2, p->mac, 6) == 0) {
		/* XXX CTL frames */
		if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=
		    IEEE80211_FC0_TYPE_CTL)
			return;
	}

#if 1
	ack(p, wh);
#endif

	if (duplicate(p, wh, rc)) {
#if 0
		printf("Dup\n");
#endif		
		return;
	}

	switch (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) {
	case IEEE80211_FC0_TYPE_MGT:
		read_mgt(p, wh, rc);
		break;
		
	case IEEE80211_FC0_TYPE_CTL:
		read_ctl(p, wh, rc);
		break;
	
	case IEEE80211_FC0_TYPE_DATA:
		read_data(p, wh, rc);
		break;
	
	default:
		printf("wtf\n");
		abort();
		break;
	}
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:52,代码来源:ap.c


示例9: duplicate

void duplicate(node* head, node*& newHead)
{
	if(!head)
	{
		newHead = NULL;
		return;
	}

	newHead = new node;
	newHead->data = head->data;
	newHead->previous = head->previous;
	duplicate(head->next, newHead->next);
}
开发者ID:NeilSchlunegger,项目名称:CS,代码行数:13,代码来源:dlist.cpp


示例10: dtrMatrix_addDiag

SEXP dtrMatrix_addDiag(SEXP x, SEXP d) {
    int n = INTEGER(GET_SLOT(x, Matrix_DimSym))[0];
    SEXP ret = PROTECT(duplicate(x)),
	r_x = GET_SLOT(ret, Matrix_xSym);
    double *dv = REAL(d), *rv = REAL(r_x);

    if ('U' == diag_P(x)[0])
	error(_("cannot add diag() as long as 'diag = \"U\"'"));
    for (int i = 0; i < n; i++) rv[i * (n + 1)] += dv[i];

    UNPROTECT(1);
    return ret;
}
开发者ID:bedatadriven,项目名称:renjin-matrix,代码行数:13,代码来源:dtrMatrix.c


示例11: insert

/*------------------------------------嵌入------------------------------------*/
void insert(int s[])
{
    int i;
    srand(time(NULL));
    for(i=1;i<7;i++)
    {
        do
        {
            s[i]=1+rand()%49;
        }
        while(duplicate(s,i));
    }
}
开发者ID:HellBlazzar,项目名称:Learning,代码行数:14,代码来源:樂透(結構處理).cpp


示例12: main

int main () {
	cout<<"\n=====================================\n";
	cout<<"\nProgram to Demonstrate Friend Functions\n";
	cout<<"\n=====================================\n";
	clrscr();
	Rectangle recta, rectb;
	recta.set_values (2,3);
	rectb = duplicate (recta);
	cout <<"\nArea of old Rectangle "<< recta.area();
	cout <<"\nArea of duplicated Rectangle "<< rectb.area();
	getch();
	return 0;
}
开发者ID:ppshobi,项目名称:CPlusPlusProgramsCollection,代码行数:13,代码来源:friendfunctions.cpp


示例13: duplicate

exprt ranking_synthesis_qbf_bitwiset::instantiate_conjunctive(void)
{
  std::pair<exprt,exprt> dlt = duplicate(affine_template(ID_and, ID_or),
                                         bitwise_width);

  if(bitwise_width<=1)
  {
    dlt.second.negate();
    return binary_relation_exprt(dlt.second, ID_and, dlt.first);
  }
  else
    return binary_relation_exprt(dlt.second, ID_lt, dlt.first);
}
开发者ID:olivo,项目名称:BP,代码行数:13,代码来源:ranking_qbf_bitwise.cpp


示例14: do_classgets

/* oldClass<-(), primitive */
SEXP attribute_hidden do_classgets(SEXP call, SEXP op, SEXP args, SEXP env)
{
    checkArity(op, args);
    check1arg(args, call, "x");

    if (NAMED(CAR(args)) == 2) SETCAR(args, duplicate(CAR(args)));
    if (length(CADR(args)) == 0) SETCADR(args, R_NilValue);
    if(IS_S4_OBJECT(CAR(args)))
      UNSET_S4_OBJECT(CAR(args));
    setAttrib(CAR(args), R_ClassSymbol, CADR(args));
    SET_NAMED(CAR(args), 0);
    return CAR(args);
}
开发者ID:KarolinaSkandy,项目名称:R-3-0-branch-alt,代码行数:14,代码来源:attrib.c


示例15: logit_link

SEXP logit_link(SEXP mu)
{
    int i, n = LENGTH(mu);
    SEXP ans = PROTECT(duplicate(mu));
    double *rans = REAL(ans), *rmu=REAL(mu);

    if (!n || !isReal(mu))
	error(_("Argument %s must be a nonempty numeric vector"), "mu");
    for (i = 0; i < n; i++)
	rans[i] = log(x_d_omx(rmu[i]));
    UNPROTECT(1);
    return ans;
}
开发者ID:FatManCoding,项目名称:r-source,代码行数:13,代码来源:family.c


示例16: PTR_CAST

ossimConnectableObject* ossimQtIgenController::duplicate(const ossimConnectableObject* obj) const
{
   if(!obj)
   {
      return NULL;
   }

   ossimKeywordlist kwl;
   obj->saveState(kwl);
   ossimObject* tempObj =
      ossimObjectFactoryRegistry::instance()->createObject(kwl);

   if (!tempObj)
   {
      return NULL;
   }
   
   ossimConnectableObject* connectable = PTR_CAST(ossimConnectableObject,
                                                  tempObj);

   if ( !connectable )
   {
      return NULL;
   }

   ossimConnectableContainerInterface* inter =
      PTR_CAST(ossimConnectableContainerInterface, connectable);

   if(inter)
   {
      inter->makeUniqueIds();
   }
   else
   {
      connectable->setId(ossimIdManager::instance()->generateId());
   }
   
   for(ossim_uint32 i = 0; i < obj->getNumberOfInputs(); ++i)
   {
      if(obj->getInput(i))
      {
         ossimConnectableObject* newInput = duplicate(obj->getInput(i));
         if(newInput)
         {
            connectable->connectMyInputTo(newInput);
         }
      }
   }
   
   return connectable;
}
开发者ID:star-labs,项目名称:star_ossim,代码行数:51,代码来源:ossimQtIgenController.cpp


示例17: Csparse_crossprod

/* Computes   x'x  or  x x' -- *also* for Tsparse (triplet = TRUE)
   see Csparse_Csparse_crossprod above for  x'y and x y' */
SEXP Csparse_crossprod(SEXP x, SEXP trans, SEXP triplet)
{
    int trip = asLogical(triplet),
	tr   = asLogical(trans); /* gets reversed because _aat is tcrossprod */
#ifdef AS_CHM_DIAGU2N_FIXED_FINALLY
    CHM_TR cht = trip ? AS_CHM_TR(x) : (CHM_TR) NULL;
#else /* workaround needed:*/
    SEXP xx = PROTECT(Tsparse_diagU2N(x));
    CHM_TR cht = trip ? AS_CHM_TR__(xx) : (CHM_TR) NULL;
#endif
    CHM_SP chcp, chxt,
	chx = (trip ?
	       cholmod_l_triplet_to_sparse(cht, cht->nnz, &c) :
	       AS_CHM_SP(x));
    SEXP dn = PROTECT(allocVector(VECSXP, 2));
    R_CheckStack();

    if (!tr) chxt = cholmod_l_transpose(chx, chx->xtype, &c);
    chcp = cholmod_l_aat((!tr) ? chxt : chx, (int *) NULL, 0, chx->xtype, &c);
    if(!chcp) {
	UNPROTECT(1);
	error(_("Csparse_crossprod(): error return from cholmod_l_aat()"));
    }
    cholmod_l_band_inplace(0, chcp->ncol, chcp->xtype, chcp, &c);
    chcp->stype = 1;
    if (trip) cholmod_l_free_sparse(&chx, &c);
    if (!tr) cholmod_l_free_sparse(&chxt, &c);
    SET_VECTOR_ELT(dn, 0,	/* establish dimnames */
		   duplicate(VECTOR_ELT(GET_SLOT(x, Matrix_DimNamesSym),
					(tr) ? 0 : 1)));
    SET_VECTOR_ELT(dn, 1, duplicate(VECTOR_ELT(dn, 0)));
#ifdef AS_CHM_DIAGU2N_FIXED_FINALLY
    UNPROTECT(1);
#else
    UNPROTECT(2);
#endif
    return chm_sparse_to_SEXP(chcp, 1, 0, 0, "", dn);
}
开发者ID:rforge,项目名称:matrix,代码行数:40,代码来源:Csparse.c


示例18: R_FixupRHS

/* duplicate RHS value of complex assignment if necessary to prevent cycles */
INLINE_FUN SEXP R_FixupRHS(SEXP x, SEXP y)
{
    if( y != R_NilValue && MAYBE_REFERENCED(y) ) {
	if (R_cycle_detected(x, y)) {
#ifdef WARNING_ON_CYCLE_DETECT
	    warning("cycle detected");
	    R_cycle_detected(x, y);
#endif
	    y = duplicate(y);
	}
	else if (NAMED(y) < 2) SET_NAMED(y, 2);
    }
    return y;
}
开发者ID:graalvm,项目名称:fastr,代码行数:15,代码来源:inlined_fastr.c


示例19: permute

void PermutationsII::permute(vector<int>& nums, int head, int tail, vector<vector<int>>& ret)
{
  if (head == tail) {
    ret.push_back(nums);
  } else {
    for (int i = head; i <= tail; i++) {
      if (!duplicate(nums, head, i)) {
        swap(nums[head], nums[i]);
        permute(nums, head + 1, tail, ret);
        swap(nums[head], nums[i]);
      }
    }
  }
}
开发者ID:SaberQ,项目名称:leetcode,代码行数:14,代码来源:PermutationsII.cpp


示例20: duplicate

void RowFilter::init()
{
	_comparisons.insert(Comparisons::value_type("<", VALUE_LESS_THAN));
	_comparisons.insert(Comparisons::value_type("<=", VALUE_LESS_THAN_OR_EQUAL));
	_comparisons.insert(Comparisons::value_type("=", VALUE_EQUAL));
	_comparisons.insert(Comparisons::value_type("==", VALUE_EQUAL));
	_comparisons.insert(Comparisons::value_type(">", VALUE_GREATER_THAN));
	_comparisons.insert(Comparisons::value_type(">=", VALUE_GREATER_THAN_OR_EQUAL));
	_comparisons.insert(Comparisons::value_type("<>", VALUE_NOT_EQUAL));
	_comparisons.insert(Comparisons::value_type("!=", VALUE_NOT_EQUAL));
	_comparisons.insert(Comparisons::value_type("IS NULL", VALUE_IS_NULL));

	duplicate();
}
开发者ID:12307,项目名称:poco,代码行数:14,代码来源:RowFilter.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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