本文整理汇总了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);
}
}
示例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;
}
}
示例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_;
}
示例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);
}
示例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;
}
示例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);
}
示例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>();
}
示例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);
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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));
}
}
};
示例15: mComp
CAComponent::CAComponent (const AudioComponent& comp)
: mComp (comp),
mManuName(0),
mAUName(0),
mCompName(0)
{
AudioComponentGetDescription (Comp(), &mDesc);
}