当前位置: 首页>>代码示例>>C++>>正文


C++ Comp函数代码示例

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


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

示例1: DBG_START_METH

 void CompoundVector::ScalImpl(Number alpha)
 {
   DBG_START_METH("CompoundVector::ScalImpl", dbg_verbosity);
   DBG_ASSERT(vectors_valid_);
   for (Index i=0; i<NComps(); i++) {
     DBG_ASSERT(Comp(i));
     Comp(i)->Scal(alpha);
   }
 }
开发者ID:RobotLocomotion,项目名称:ipopt-mirror,代码行数:9,代码来源:IpCompoundVector.cpp

示例2: siftDown

 void siftDown(int pos) {
   while (2*pos+1 < num_) {//!isLeaf(pos) ) {
     int l = leftChild(pos);
     int r = l + 1;
     if (r < num_ && Comp()(heap_[r], heap_[l]) ) {
       l = r;
     }
     if (Comp()(heap_[l], heap_[pos]) ) {
         std::swap(heap_[pos], heap_[l]);
     }
     pos = l;
   }
 }
开发者ID:kayw,项目名称:CareerInterview,代码行数:13,代码来源:heapsort.hpp

示例3: Q_Find

int Q_Find( queue *q, void *data, int(*Comp)( const void *, const void * ) )
{
    void *d;
    d = Q_First( q );
    do
    {
        if ( Comp( d, data ) == 0 ) return True_;
        d = Q_Next( q );
    }
    while ( !Q_End( q ) );

    if ( Comp( d, data ) == 0 ) return True_;

    return False_;
}
开发者ID:arebgun,项目名称:ap_scouts,代码行数:15,代码来源:queue.c

示例4: DeleteInternal

 Node<Key, Val>* DeleteInternal(Node<Key, Val>* h, Key key){
   if (h == NULL) return NULL;
   if (Comp()(key, h->key)){
     if (!IsRED(h->left) && 
         h->left != NULL &&
         !IsRED(h->left->left)){
       h = MoveREDLeft(h);
     }
     h->left = DeleteInternal(h->left, key);
   } else {
     if (IsRED(h->left)){
       h = RotateRight(h);
     }
     if ((key == h->key) && (h->right == NULL)){
       return NULL;
     }
     if (!IsRED(h->right) && 
         h->right != NULL && 
         !IsRED(h->right->left)){
       h = MoveREDRight(h);
     }
     if (key == h->key){
       Node<Key, Val>* min_node = GetMin(h->right);
       h->key = min_node->key;
       h->val = min_node->val;
       h->right = DeleteMin(h->right);
     } else {
       h->right = DeleteInternal(h->right, key);
     }
   }
   return FixUp(h);
 }
开发者ID:pombredanne,项目名称:llrbpp,代码行数:32,代码来源:llrbpp.hpp

示例5: InsertInternal

  Node<Key, Val>* InsertInternal(Node<Key, Val>* h, Key key, Val val){
    if (h == NULL){
      ++num_;
      return new Node<Key, Val>(key, val);
    }
    
    if (IsRED(h->left) && IsRED(h->right)){
      FlipColor(h);
    }

    if (key == h->key){
      h->val = val;
    } else if (Comp()(key, h->key)){
      h->left = InsertInternal(h->left, key, val);
    } else {
      h->right = InsertInternal(h->right, key, val);
    }
    
    if (IsRED(h->right)){
      h = RotateLeft(h);
    }

    if (IsRED(h->left) && IsRED(h->left->left)){
      h = RotateRight(h);
    }

    return h;
  }
开发者ID:pombredanne,项目名称:llrbpp,代码行数:28,代码来源:llrbpp.hpp

示例6: mDesc

CAComponent::CAComponent (OSType inType, OSType inSubtype, OSType inManu)
	: mDesc (inType, inSubtype, inManu),
	  mManuName(0), mAUName(0), mCompName(0)
{
	mComp = AudioComponentFindNext (NULL, &mDesc);
	AudioComponentGetDescription (Comp(), &mDesc);
}
开发者ID:AdamDiment,项目名称:CocoaSampleCode,代码行数:7,代码来源:CAComponent.cpp

示例7: lowestCost

	/**
	 * @param connections given a list of connections include two cities and cost
	 * @return a list of connections from results
	 */
	vector<Connection> lowestCost(vector<Connection>& connections) {
		sort(connections.begin(), connections.end(), Comp());
		unordered_map<string, int> labels;
		int n = 0;
		for (const auto & i : connections) {
			if (!labels.count(i.city1)) {
				labels[i.city1] = n;
				++n;
			}
			if (!labels.count(i.city2)) {
				labels[i.city2] = n;
				++n;
			}
		}
		vector<int> roots(n);
		iota(roots.begin(), roots.end(), 0);
		vector<Connection> result;
		for (const auto & i : connections) {
			int label1 = labels[i.city1], label2 = labels[i.city2];
			int root1 = getRoot(roots, label1), root2 = getRoot(roots, label2);
			if (root1 != root2) {
				roots[root1] = root2;
				--n;
				result.push_back(i);
			}
		}
		return n == 1 ? result : vector<Connection>();
	}
开发者ID:yuanhui-yang,项目名称:LintCode-Online-Judge,代码行数:32,代码来源:minimum-spanning-tree.cpp

示例8: mDesc

CAComponent::CAComponent (OSType inType, OSType inSubtype, OSType inManu)
	: mDesc (inType, inSubtype, inManu),
	  mManuName(0), mAUName(0), mCompName(0), mCompInfo (0)
{
	mComp = FindNextComponent (NULL, &mDesc);
	GetComponentInfo (Comp(), &mDesc, NULL, NULL, NULL);
}
开发者ID:DanielAeolusLaude,项目名称:ardour,代码行数:7,代码来源:CAComponent.cpp

示例9: CA_STEP3_check_pcd_pubkey

int
CA_STEP3_check_pcd_pubkey(const EAC_CTX *ctx,
        const BUF_MEM *comp_pubkey, const BUF_MEM *pubkey)
{
    BUF_MEM *my_comp_pubkey = NULL;
    int r = -1;

    check((ctx && ctx->ca_ctx && comp_pubkey && ctx->ca_ctx->ka_ctx),
           "Invalid arguments");

    /* Compress own public key */
    my_comp_pubkey = Comp(ctx->ca_ctx->ka_ctx->key, pubkey, ctx->bn_ctx, ctx->md_ctx);
    check(my_comp_pubkey, "Failed to compress public key");

    /* Check whether or not the received data fits the own data */
    if (my_comp_pubkey->length != comp_pubkey->length
            || memcmp(my_comp_pubkey->data, comp_pubkey->data, comp_pubkey->length) != 0) {
        log_err("Wrong public key");
        r = 0;
    } else
        r = 1;

err:
    if (my_comp_pubkey)
        BUF_MEM_free(my_comp_pubkey);

    return r;
}
开发者ID:RushOnline,项目名称:openpace,代码行数:28,代码来源:eac_ca.c

示例10: AudioComponentCopyName

void 		CAComponent::SetCompNames () const
{
	if (!mCompName) {
	
		CFStringRef compName;
		OSStatus result = AudioComponentCopyName (Comp(), &compName);
		if (result) return;
		
		const_cast<CAComponent*>(this)->mCompName = compName;
		if (compName)
		{
			CFArrayRef splitStrArray = CFStringCreateArrayBySeparatingStrings(NULL, compName, CFSTR(":"));
			
			// we need to retain these values so the strings are not lost when the array is released
			const_cast<CAComponent*>(this)->mManuName = (CFStringRef)CFArrayGetValueAtIndex(splitStrArray, 0);
            CFRetain(this->mManuName);
			if (CFArrayGetCount(splitStrArray) > 1)
			{
				CFStringRef str = (CFStringRef)CFArrayGetValueAtIndex(splitStrArray, 1);
				
				CFMutableStringRef mstr = CFStringCreateMutableCopy (NULL, CFStringGetLength(str), str);

				// this needs to trim out white space:
				
				CFStringTrimWhitespace (mstr);
			
				const_cast<CAComponent*>(this)->mAUName = mstr;
			} else
				const_cast<CAComponent*>(this)->mAUName = NULL;
			
			CFRelease(splitStrArray);
		}
	}
}
开发者ID:AdamDiment,项目名称:CocoaSampleCode,代码行数:34,代码来源:CAComponent.cpp

示例11: auc

double auc(const dvec_t& dec_values, const ivec_t& ty){
	double roc  = 0;
	size_t size = dec_values.size();
	size_t i;
	std::vector<size_t> indices(size);

	for(i = 0; i < size; ++i) indices[i] = i;

	std::sort(indices.begin(), indices.end(), Comp(&dec_values[0]));

	int tp = 0,fp = 0;
	for(i = 0; i < size; i++) {
		if(ty[indices[i]] == 1) tp++;
		else if(ty[indices[i]] == -1) {
			roc += tp;
			fp++;
		}
	}

	if(tp == 0 || fp == 0)
	{
		fprintf(stderr, "warning: Too few postive true labels or negative true labels\n");
		roc = 0;
	}
	else
		roc = roc / tp / fp;

	printf("AUC = %g\n", roc);

	return roc;
}
开发者ID:Joelone,项目名称:MLEA,代码行数:31,代码来源:eval.cpp

示例12: fprintf

void		CAAudioUnit::Print (FILE* file) const
{
	fprintf (file, "AudioUnit:%p\n", AU());
	if (IsValid()) {
		fprintf (file, "\tnode=%ld\t", (long)GetAUNode()); Comp().Print (file);
	}
}
开发者ID:63n,项目名称:ardour,代码行数:7,代码来源:CAAudioUnit.cpp

示例13: Q_BSearch

static int Q_BSearch( queue *q, void *key,
                      int (*Comp)(const void *, const void*))
{
      int low, mid, hi, val;

      low = 0;
      hi = q->size - 1;

      while (low <= hi)
      {
            mid = (low + hi) / 2;
            val = Comp(key, Q_index[ mid ]);

            if (val < 0)
                  hi = mid - 1;

            else if (val > 0)
                  low = mid + 1;

            else /* Success */
                  return mid;
      }

      /* Not Found */

      return -1;
}
开发者ID:h4ck3rm1k3,项目名称:gw6c-debian,代码行数:27,代码来源:deque.c

示例14: bubble_sort

 void bubble_sort(const Iterator& first, const Iterator& last, const Comp& comp = Comp()) {
     if(first == last) return;
     for(Iterator it = first; it != last - 1; ++it) {
         for(Iterator forward_it = last - 1; forward_it != it; --forward_it) {
             if(comp(*forward_it, *(forward_it - 1))) std::swap(*forward_it, *(forward_it-1));
         }
     }
 };
开发者ID:xmfbit,项目名称:CLRS,代码行数:8,代码来源:bubble_sort.hpp

示例15: mComp

CAComponent::CAComponent (const AudioComponent& comp) 
	: mComp (comp),
	  mManuName(0), 
	  mAUName(0), 
	  mCompName(0)
{
	AudioComponentGetDescription (Comp(), &mDesc);
}
开发者ID:AdamDiment,项目名称:CocoaSampleCode,代码行数:8,代码来源:CAComponent.cpp


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