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


C++ set::size方法代码示例

本文整理汇总了C++中set::size方法的典型用法代码示例。如果您正苦于以下问题:C++ set::size方法的具体用法?C++ set::size怎么用?C++ set::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在set的用法示例。


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

示例1: Dictionary

 //constructor for a pre-fab set of words,  primarily for using error version
 //in a polymorphic manner.
 Dictionary ( set<string> PreFabSet ) :
       wordSet( PreFabSet ), constructionWasSuccesfull( true ) {
    if(wordSet.size()==0) constructionWasSuccesfull = false;
    DetermineLongestWord();
 }
开发者ID:swanyriver,项目名称:SwansonObjects,代码行数:7,代码来源:Dictionary.hpp

示例2: AddTimeData

void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
{
    LOCK(cs_nTimeOffset);
    // Ignore duplicates
    static set<CNetAddr> setKnown;
    if (setKnown.size() == BITCOIN_TIMEDATA_MAX_SAMPLES)
        return;
    if (!setKnown.insert(ip).second)
        return;

    // Add data
    static CMedianFilter<int64_t> vTimeOffsets(BITCOIN_TIMEDATA_MAX_SAMPLES, 0);
    vTimeOffsets.input(nOffsetSample);
    LogPrint("net","added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60);

    // There is a known issue here (see issue #4521):
    //
    // - The structure vTimeOffsets contains up to 200 elements, after which
    // any new element added to it will not increase its size, replacing the
    // oldest element.
    //
    // - The condition to update nTimeOffset includes checking whether the
    // number of elements in vTimeOffsets is odd, which will never happen after
    // there are 200 elements.
    //
    // But in this case the 'bug' is protective against some attacks, and may
    // actually explain why we've never seen attacks which manipulate the
    // clock offset.
    //
    // So we should hold off on fixing this and clean it up as part of
    // a timing cleanup that strengthens it in a number of other ways.
    //
    if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1)
    {
        int64_t nMedian = vTimeOffsets.median();
        std::vector<int64_t> vSorted = vTimeOffsets.sorted();
        // Only let other nodes change our time by so much
        if (abs64(nMedian) <= std::max<int64_t>(0, GetArg("-maxtimeadjustment", DEFAULT_MAX_TIME_ADJUSTMENT)))
        {
            nTimeOffset = nMedian;
        }
        else
        {
            nTimeOffset = 0;

            static bool fDone;
            if (!fDone)
            {
                // If nobody has a time different than ours but within 5 minutes of ours, give a warning
                bool fMatch = false;
                BOOST_FOREACH(int64_t nOffset, vSorted)
                    if (nOffset != 0 && abs64(nOffset) < 5 * 60)
                        fMatch = true;

                if (!fMatch)
                {
                    fDone = true;
                    string strMessage = strprintf(_("Please check that your computer's date and time are correct! If your clock is wrong, %s will not work properly."), _(PACKAGE_NAME));
                    strMiscWarning = strMessage;
                    uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING);
                }
            }
        }
开发者ID:1000000000001,项目名称:bitcoin,代码行数:63,代码来源:timedata.cpp

示例3: union_find

vector<int> HDBScan::do_labelling(vector<CondensedTree*>& tree, set<int>& clusters,
                                  boost::unordered_map<int, int>& cluster_label_map,
                                  bool allow_single_cluster,
                                  bool match_reference_implementation)
{
    int root_cluster = tree[0]->parent;  //root_cluster = parent_array.min()
    int parent_array_max = tree[0]->parent;
    for (int i=1; i<tree.size(); i++) {
        if (tree[i]->parent < root_cluster) {
            root_cluster = tree[i]->parent;
        }
        if (tree[i]->parent > parent_array_max) {
            parent_array_max = tree[i]->parent;
        }
    }
    vector<int> result(root_cluster);
    
    TreeUnionFind union_find(parent_array_max + 1);
    
    for (int n=0; n<tree.size(); n++) {
        int child = tree[n]->child;
        int parent = tree[n]->parent;
        if (clusters.find(child) ==clusters.end() ) {
            union_find.union_(parent, child);
        }
    }
    
    for (int n=0; n<root_cluster; n++) {
        int cluster = union_find.find(n);
        if ( cluster < root_cluster) {
            result[n] = -1;
            
        } else if (cluster == root_cluster) {
            result[n] = -1;
            if (clusters.size()==1 && allow_single_cluster) {
                double c_lambda = -1;
                double p_lambda = -1;
                for (int j=0; j<tree.size(); j++) {
                    if (tree[j]->child == n) {
                        c_lambda = tree[j]->lambda_val;
                    }
                    if (tree[j]->parent == cluster) {
                        if (tree[j]->lambda_val > p_lambda) {
                            p_lambda = tree[j]->lambda_val;
                        }
                    }
                }
                if (c_lambda >= p_lambda && p_lambda > -1) {
                    result[n] = cluster_label_map[cluster];
                }
            }
            
        } else {
            if (match_reference_implementation) {
                double point_lambda=-1, cluster_lambda=-1;
                for (int j=0; j<tree.size(); j++) {
                    if (tree[j]->child == n) {
                        point_lambda = tree[j]->lambda_val;
                        break;
                    }
                }
                for (int j=0; j<tree.size(); j++) {
                    if (tree[j]->child == cluster) {
                        cluster_lambda = tree[j]->lambda_val;
                        break;
                    }
                }
                if (point_lambda > cluster_lambda && cluster_lambda > -1) {
                    result[n] = cluster_label_map[cluster];
                } else {
                    result[n] = -1;
                }
            } else {
                result[n] = cluster_label_map[cluster];
            }
        }
    }
    return result;
}
开发者ID:lixun910,项目名称:geoda,代码行数:79,代码来源:hdbscan.cpp

示例4: CreatTree

/*
* @function CreatTree 递归DFS创建并输出决策树
* @param: treeHead 为生成的决定树
* @param: statTree 为状态树,此树动态更新,但是由于是DFS对数据更新,所以不必每次新建状态树
* @param: infos 数据信息
* @param: readLine 当前在infos中所要进行统计的行数,由函数外给出
* @param: deep 决定树的深度,用于打印
* @return void
*/
void DecisionTree::CreatTree(TreeNode* treeHead, vector<attributes*>& statTree, vector<vector<string>>& infos, 
							 set<int>& readLine, vector<int>& readClumNum, int deep)
{
	//有可统计的行
	if (readLine.size() != 0)
	{
		string treeLine = "";
		for (int i = 0; i < deep; i++)
		{
			treeLine += "--";
		}
		//清空其他属性子树,进行递归
		resetStatTree(statTree, readClumNum);
		//统计当前readLine中的数据:包括统计哪几个属性、哪些行,
		//并生成statTree(由于公用一个statTree,所有用引用代替),并返回目的信息数
		int deciNum = statister(getInfos(), statTree, readLine, readClumNum);
		int lineNum = readLine.size();
		int attr_node = compuDecisiNote(statTree, deciNum, lineNum, readClumNum);//本条复制为局部变量
		//该列被锁定
		readClumNum[attr_node] = 1;
		//建立树根
		TreeNode* treeNote = new TreeNode();
		treeNote->m_sAttribute = statTree[attr_node]->attriName;
		treeNote->m_iDeciNum = deciNum;
		treeNote->m_iUnDecinum = lineNum - deciNum;
		if (treeHead == nullptr)
		{
			treeHead = treeNote; //树根
		}
		else
		{
			treeHead->m_vChildren.push_back(treeNote); //子节点
		}
		cout << "节点-"<< treeLine << ">" << statTree[attr_node]->attriName << " " << deciNum << " " << lineNum - deciNum << endl;
		
		//从孩子分支进行递归
		for(map<string, attrItem*>::iterator map_iterator = statTree[attr_node]->attriItem.begin();
			map_iterator != statTree[attr_node]->attriItem.end(); ++map_iterator)
		{
			//打印分支
			int sum = map_iterator->second->itemNum[0];
			int deci_Num = map_iterator->second->itemNum[1];
			cout << "分支--"<< treeLine << ">" << map_iterator->first << endl;
			//递归计算、创建
			if (deci_Num != 0 && sum != deci_Num )
			{
				//计算有效行数
				set<int> newReadLineNum = map_iterator->second->itemLine;
				//DFS
				CreatTree(treeNote, statTree, infos, newReadLineNum, readClumNum, deep + 1);
			}
			else
			{
				//建立叶子节点
				TreeNode* treeEnd = new TreeNode();
				treeEnd->m_sAttribute = statTree[attr_node]->attriName;
				treeEnd->m_iDeciNum = deci_Num;
				treeEnd->m_iUnDecinum = sum - deci_Num;
				treeNote->m_vChildren.push_back(treeEnd);
				//打印叶子
				if (deci_Num == 0)
				{
					cout << "叶子---"<< treeLine << ">no" << " " << sum << endl;
				}
				else
				{
					cout << "叶子---"<< treeLine << ">yes" << " " << deci_Num <<endl;
				}
			}
		}
		//还原属性列可用性
		readClumNum[attr_node] = 0;
	}
}
开发者ID:DevilGragon,项目名称:Decision-Tree,代码行数:83,代码来源:DecisionTree.cpp

示例5: led

    void buildBottomUpPhases2And3( bool dupsAllowed,
                                   IndexDescriptor* idx,
                                   BSONObjExternalSorter& sorter,
                                   bool dropDups,
                                   set<DiskLoc>& dupsToDrop,
                                   CurOp* op,
                                   SortPhaseOne* phase1,
                                   ProgressMeterHolder& pm,
                                   Timer& t,
                                   bool mayInterrupt ) {
        BtreeBuilder<V> btBuilder(dupsAllowed, idx->getOnDisk());
        BSONObj keyLast;
        auto_ptr<BSONObjExternalSorter::Iterator> i = sorter.iterator();
        // verifies that pm and op refer to the same ProgressMeter
        verify(pm == op->setMessage("index: (2/3) btree bottom up",
                                    "Index: (2/3) BTree Bottom Up Progress",
                                    phase1->nkeys,
                                    10));
        while( i->more() ) {
            RARELY killCurrentOp.checkForInterrupt( !mayInterrupt );
            ExternalSortDatum d = i->next();

            try {
                if ( !dupsAllowed && dropDups ) {
                    LastError::Disabled led( lastError.get() );
                    btBuilder.addKey(d.first, d.second);
                }
                else {
                    btBuilder.addKey(d.first, d.second);                    
                }
            }
            catch( AssertionException& e ) {
                if ( dupsAllowed ) {
                    // unknown exception??
                    throw;
                }

                if( e.interrupted() ) {
                    killCurrentOp.checkForInterrupt();
                }

                if ( ! dropDups )
                    throw;

                /* we could queue these on disk, but normally there are very few dups, so instead we
                    keep in ram and have a limit.
                */
                dupsToDrop.insert(d.second);
                uassert( 10092 , "too may dups on index build with dropDups=true", dupsToDrop.size() < 1000000 );
            }
            pm.hit();
        }
        pm.finished();
        op->setMessage("index: (3/3) btree-middle", "Index: (3/3) BTree Middle Progress");
        LOG(t.seconds() > 10 ? 0 : 1 ) << "\t done building bottom layer, going to commit" << endl;
        btBuilder.commit( mayInterrupt );
        if ( btBuilder.getn() != phase1->nkeys && ! dropDups ) {
            warning() << "not all entries were added to the index, probably some "
                         "keys were too large" << endl;
        }
    }
开发者ID:Convey-Compliance,项目名称:mongo,代码行数:61,代码来源:btree_based_builder.cpp

示例6: inner_vertex_cnt

 size_t inner_vertex_cnt() const {
     return inner_vertices_.size();
 }
开发者ID:fw1121,项目名称:Pandoras-Toolbox-for-Bioinformatics,代码行数:3,代码来源:relative_coverage_remover.hpp

示例7: main

int main( int argc, const char** argv )
{
  // splash

  printf("hello, trail!\n");

  // initialize for LINEAR trail approximation (quadrilateral)

  trailEdgeRow.push_back(IMAGE_ROW_FAR);
  trailEdgeRow.push_back(IMAGE_ROW_NEAR);

  add_all_images_from_file("imagedirs.txt");

  // create initial, ordered indices 

  int i;

  for (i = 0; i < dir_image_filename.size(); i++)      
    Random_idx.push_back(i);
  printf("%i total images\n", (int) Random_idx.size());

  // shuffle indices (this should be optional)

  struct timeval tp;
  
  gettimeofday(&tp, NULL); 
  //  srand48(tp.tv_sec);
  srand(tp.tv_sec);
  random_shuffle(Random_idx.begin(), Random_idx.end());

  Nonrandom_idx.resize(Random_idx.size());
  for (i = 0; i < Random_idx.size(); i++)
    Nonrandom_idx[Random_idx[i]] = i;

  loadBad();
  printf("%i bad\n", (int) Bad_idx_set.size());

  Vert.resize(Random_idx.size());
  ClosestVert_dist.resize(Random_idx.size());   

  num_saved_verts = loadVert();
  printf("%i with verts\n", num_saved_verts);

  set_current_index(ZERO_INDEX);

  // display

  char c;

  do {
    
    // load image

    current_imname = dir_image_filename[current_index];

    current_im = imread(current_imname.c_str());
    draw_im = current_im.clone();

    // show image 

    draw_overlay();
    //draw_output_window();
    //draw_training_images();


    imshow("trailGT", draw_im);
    if (!callbacks_set) {
      setMouseCallback("trailGT", onMouse);
    }

    c = waitKey(0);

    onKeyPress(c);

  } while (c != (int) 'q');

  return 0;
}
开发者ID:jiayi1246,项目名称:trailGT,代码行数:78,代码来源:trailGT.cpp

示例8: main

#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define check(x) cerr << #x << " = "; REP(q,(x).size()) cerr << (x)[q] << " "; cerr << endl;
#define checkn(x,n) cerr << #x << " = "; for(int i=0;i<(x).size()&&i<(n);++i) cerr << (x)[i] << " "; cerr << endl;

int main() {
  int P; cin >> P;
  vector<int> pages(P);
  REP(i, P) {
    int temp;
    scanf("%d", &temp);
    pages[i] = temp;
  }

  set<int> all;
  REP(i, P) all.insert(pages[i]);
  int n = all.size();

  int s = 0, t = 0, num = 0;
  map<int, int> count;
  int res = P;
  for (;;) {
    while (t < P && num < n) {
      if (count[pages[t]] == 0) {
        num++;
      }
      count[pages[t]]++;
      t++;
    }
    if (num < n) break;
    res = min(res, t - s);
    count[pages[s]]--;
开发者ID:dayu321,项目名称:POJ-1,代码行数:31,代码来源:main.cpp

示例9: _tmain

int _tmain(int argc, _TCHAR* argv[])
{
	long pmax = 10000000;
	vector<long> primes = sieve_of_eratosthenes(pmax);

	long long sum = 0;

	for (vector<long>::iterator it=primes.begin(); it!= primes.end(); it++)
	{
		long p = *it;

		// every 1 digit prime is a relative
		if (p<10) {
			relatives.insert(*it);
			continue;
		}

		bool condition_met = false;

		// condition 1
		// change all digits possible
		int len = findn(*it);
		for (long exponent=1; exponent < p ; exponent *= 10) {
			long limit = p/exponent % 10;
			long newp = p;
			for (int n=0; n<limit; n++) {
				newp -= exponent;
				if (relatives.find(newp) != relatives.end() && findn(newp) + 1 >= len) {
					relatives.insert(*it);
					exponent=p;
					n=limit;
					condition_met=true;
				}
			}
		}

		// condition 2
		// remove leftmost digit
		if ( condition_met == false ) {
			long newp = p % getexp(p);
			if (relatives.find(newp) != relatives.end() && findn(newp) + 1 >= len) {
				relatives.insert(*it);
				condition_met=true;
			}
		}

		if (condition_met) {
			if ( no_relatives.size() > 0 ) {
				set<long> erased = recheck_non_relatives(p);
				set<long> erased2;
				set<long> new_erased;

				while (erased.size() > 0) {
					erased2.clear();
					new_erased.clear();
					for (set<long>::iterator sit=erased.begin(); sit != erased.end(); sit++) {
						erased2 = recheck_non_relatives(*sit);
						for (set<long>::iterator sit2=erased2.begin(); sit2 != erased2.end(); sit2++) {
							new_erased.insert(*sit2);
						}
					}
					erased = new_erased;
				}
			}
		}
		else {
			no_relatives.insert(*it);
			sum += *it;
			cout << *it << endl;
		}
	}

	
	cout << "--------------" << endl << sum << endl;

	system("PAUSE");
	return 0;
}
开发者ID:edlerd,项目名称:projectEulerCpp,代码行数:78,代码来源:peuler425.cpp

示例10: main

int main()
{
	freopen("/home/qitaishui/code/out.txt","r",stdin);
	freopen("/home/qitaishui/code/out2.txt","w",stdout);
	int ca = 0;
	while(~scanf("%d", &n))
	{
		for(int i = 0; i < n; i++)
			d[i].input();

		for(int i = 0; i < n; i++)
			root[i] = i;

		for(int i = 0; i < n; i++)
			for(int j = 0; j < i; j++)
			if(check(d[i], d[j]))
			{
				int x = find(i), y = find(j);
				if(x != y)
					root[x] = y;
			}

		for(int i = 0; i < n; i++)
			find(i);

		for(int i = 0; i < n; i++)
		{
			int x1, y1, x2, y2;
			int j = find(i);
			x1 = min(d[i].x1, d[i].x2, d[j].x1, d[j].x2);
			x2 = max(d[i].x1, d[i].x2, d[j].x1, d[j].x2);
			y1 = min(d[i].y1, d[i].y2, d[j].y1, d[j].y2);
			y2 = max(d[i].y1, d[i].y2, d[j].y1, d[j].y2);

			if((ll)(d[j].y2 - d[j].y1) * (d[j].x2 - d[j].x1) >= 0)
				d[j] = Data(x1, y1, x2, y2);
			else
				d[j] = Data(x1, y2, x2, y1);
		}

		int cnt = 0;
		for(int i = 0; i < n; i++)
		if(i == find(i))
			d[cnt++] = d[i];

		n = cnt;
		all.clear();
		tset.clear();
		ll ans = 0;

		for(int i = 0; i < n; i++)
		{
			ans += 1 + gcd(abs(d[i].x1 - d[i].x2), abs(d[i].y1 - d[i].y2));
			tset.clear();
			if(i != j)
			{
				cal(d[i], d[j]);

			}
			ans -= (ll)tset.size();
		}

		ans += (ll)all.size();
		printf("%d %d\n", ++ca,(int)ans);
	}
	return 0;
}
开发者ID:philokey,项目名称:Algorithm-Problems,代码行数:67,代码来源:duipai.cpp

示例11: lca_from_ids

uint64_t Config::lca_from_ids(unordered_map<uint64_t,unsigned int> & node2depth, set<uint64_t> & ids) {

	if(ids.size() == 1) {
		return *(ids.begin());
	}
	size_t num_ids = ids.size();
	uint64_t * leafs = (uint64_t *) calloc(num_ids,sizeof(uint64_t));
	unsigned int shallowest_depth = 100000;
	unsigned int index = 0;
	for(auto it = ids.begin() ; it != ids.end(); ++it) {
		uint64_t id = *it;	

		if(nodes->count(id)==0) {
			if(verbose) cerr << "Warning: Taxon ID " << id << " in database is not contained in taxonomic tree.\n";
			num_ids--;
			continue;
		}

		// check if this id was already seen, then skip it
		leafs[index++] = id;

		//if id is alrady in the depth map then do not add it.
		if(node2depth.count(id)==0) {
			unsigned int depth = 1;
			while(nodes->count(id)>0 && id != nodes->at(id)) {
				depth++;
				id = nodes->at(id);	
			}
			node2depth.insert(pair<uint64_t,unsigned int>(*it,depth));
			//cerr << "Inserting to depth map: " << *it <<" -> " << depth << endl;
			if(depth < shallowest_depth) { shallowest_depth = depth; }
		}
		else if(node2depth.at(*it) < shallowest_depth) {
			shallowest_depth = node2depth.at(*it);
		}
	}

	if(num_ids<=0) {
		free(leafs);
		return 0;
	}

	//cerr << "shallowest depth = " << shallowest_depth << endl;

	// bring all IDs up to the same depth
	/*for (auto it=leafs.begin(); it != leafs.end(); ++it) {
		//cerr << "Bringing leaf " << *it << " to depth " << shallowest_depth <<" from depth " << node2depth->at(*it) << endl;
		for(int i = node2depth.at(*it) - shallowest_depth; i > 0; i--) {
			*it = nodes->at(*it);
		}
	}*/
	for(size_t index = 0; index < num_ids; ++index) {
		for(int i = node2depth.at(leafs[index]) - shallowest_depth; i > 0; i--) {
			leafs[index]	= nodes->at(leafs[index]);
		}
	}

	while(true) {
		//foreach element in the list, check if id is the same, otherwise go one level up in tree, i.e. one more iteration 
		uint64_t first = leafs[0];
		bool found = true;
		//for (auto it=leafs.begin(); it != leafs.end(); ++it) {
		for(size_t index = 0; index < num_ids; ++index) {
			if(first != leafs[index]) {
				found = false;
			}
			leafs[index] = nodes->at(leafs[index]);
		}
		if(found) {
			free(leafs);
			return first;
		}
	}
	free(leafs);

}
开发者ID:binma,项目名称:kaiju,代码行数:76,代码来源:Config.cpp

示例12: compare_length

bool compare_length (set<int> &first, set<int> &second)
{
	return (first.size() < second.size());
}
开发者ID:chenthillrulz,项目名称:ctci,代码行数:4,代码来源:disjoint_sets.cpp

示例13: vd

/* ******************************************************************************************** */
void vd () {

	// Process the site and circle events 
	while(!eventQueue.empty()) {

		// avl.draw();
		getchar2();

		// Check if it is a site event
		Event* event = eventQueue.top();
		eventQueue.pop();
		SiteEvent* siteEvent = dynamic_cast <SiteEvent*> (event);
		if(siteEvent != NULL) {

			printf("\n--- site --------------------------------------------------\n");
			
			// Update the sweep line location
			sweepLine = siteEvent->point(1) - 0.0001;
			printf("sweepLine: %lf\n", sweepLine);
			printf("new site: (%lf, %lf)\n", siteEvent->point(0), siteEvent->point(1));
			//avl.draw();
			getchar2();

			// Locate the existing arc information
			pair <bool, AVL<TreeNode*>::Node*> searchRes = 
				avl.search_candidateLoc(new TreeNode(siteEvent->pi, -1, true));

			// The tree is empty. Temporarily add the site information as a dummy node
			if(searchRes.second == NULL) {
				avl.insert(new TreeNode(siteEvent->pi, -1, true));
				printf("Tree empty!\n");
				continue;
			}

			// The tree still doesn't have a break point, but just a dummy site node information
			TreeNode* parentNode = searchRes.second->value;
			if(parentNode->dummy) {
				avl.remove(parentNode);
				avl.insert(new TreeNode(parentNode->p0i, siteEvent->pi));
				avl.insert(new TreeNode(siteEvent->pi, parentNode->p0i));
				printf("Tree dummy!\n");
				continue;
			}
			
			// Determine the site by comparing it with the found node value
			int prevSiteIdx = 0;
			if(parentNode->value() < siteEvent->point(0)) prevSiteIdx = parentNode->p1i;
			else prevSiteIdx = parentNode->p0i;
			printf("Previous site idx: (%d)\n", prevSiteIdx);
			
			// Create the new break points
			TreeNode* newNode1 = new TreeNode(siteEvent->pi, prevSiteIdx);
			TreeNode* newNode2 = new TreeNode(prevSiteIdx, siteEvent->pi);
 			avl.insert(newNode1);
 			avl.insert(newNode2);

			// Check for "false alarms" for circle events
			set <pair<CircleEvent*, Vector2d>, Vector2dComp>::iterator it =  allCircles.begin();
			printf("# parent circles: %d\n", parentNode->circleEvents.size());
//			for(size_t c_i = 0; c_i < parentNode->circleEvents.size(); c_i++) {
			for(; it != allCircles.end(); it++) {
//				CircleEvent* ce = parentNode->circleEvents[c_i];
				CircleEvent* ce = it->first;
				printf("\tTriplet (%d,%d,%d)\n", ce->points(0), ce->points(1), ce->points(2)); 
				if((ce->center - siteEvent->point).norm() < ce->radius) {
					printf("\tRemoving triplet: (%d,%d,%d)\n", ce->points(0),ce->points(1),ce->points(2));
					ce->falseAlarm = true;
				}
			}
			
			// Get the leaf information to check for circles
			vector <pair<int, AVL<TreeNode*>::Node*> > leafParents;
			avl.traversal_leaves(leafParents);
			printf("Traversal: {");
			vector <pair<int, TreeNode*> > sites;
			for(int i = 0; i < leafParents.size(); i++) {
				TreeNode* node = leafParents[i].second->value;
				int type = leafParents[i].first;
				if(type == 2) {
					printf("(%d,%d), ", node->p0i, node->p1i);
					sites.push_back(make_pair(node->p0i, node));
					sites.push_back(make_pair(node->p1i, node));
				}
				if(type == 0) {
					printf("%d, ", node->p0i);
					sites.push_back(make_pair(node->p0i, node));
				}
				if(type == 1) {
					printf("%d, ", node->p1i);
					sites.push_back(make_pair(node->p1i, node));
				}
			}
			printf("\b\b}\n");

			// Check for circles in triplets
			for(int s_i = 0; s_i < sites.size()-2; s_i++) {

				// Skip newly generated centers
				int i0 = sites[s_i].first, i1 = sites[s_i+1].first, i2 = sites[s_i+2].first;
//.........这里部分代码省略.........
开发者ID:cerdogan,项目名称:Job,代码行数:101,代码来源:vd.cpp

示例14: NumWords

 //returns number of words
 long int NumWords () {
    return wordSet.size();
 }
开发者ID:swanyriver,项目名称:SwansonObjects,代码行数:4,代码来源:Dictionary.hpp

示例15: main

int main(int argc, char **argv) {

    stringstream nullStream;
    nullStream.clear(ios::failbit);

    const char *dev = NULL;
    char errbuf[PCAP_ERRBUF_SIZE];
    pcap_t *handle;

    struct bpf_program fp;
    bpf_u_int32 mask;
    bpf_u_int32 net;

    bool source = false;
    bool replay = false;
    bool diaglog = false;
    const char *file = 0;

    vector< const char * > args;
    for( int i = 1; i < argc; ++i )
        args.push_back( argv[ i ] );

    try {
        for( unsigned i = 0; i < args.size(); ++i ) {
            const char *arg = args[ i ];
            if ( arg == string( "--help" ) ) {
                usage();
                return 0;
            }
            else if ( arg == string( "--forward" ) ) {
                forwardAddress = args[ ++i ];
            }
            else if ( arg == string( "--source" ) ) {
                uassert( 10266 ,  "can't use --source twice" , source == false );
                uassert( 10267 ,  "source needs more args" , args.size() > i + 2);
                source = true;
                replay = ( args[ ++i ] == string( "FILE" ) );
                diaglog = ( args[ i ] == string( "DIAGLOG" ) );
                if ( replay || diaglog )
                    file = args[ ++i ];
                else
                    dev = args[ ++i ];
            }
            else if ( arg == string( "--objcheck" ) ) {
                objcheck = true;
                outPtr = &nullStream;
            }
            else {
                serverPorts.insert( atoi( args[ i ] ) );
            }
        }
    }
    catch ( ... ) {
        usage();
        return -1;
    }

    if ( !serverPorts.size() )
        serverPorts.insert( 27017 );

    if ( diaglog ) {
        processDiagLog( file );
        return 0;
    }
    else if ( replay ) {
        handle = pcap_open_offline(file, errbuf);
        if ( ! handle ) {
            cerr << "error opening capture file!" << endl;
            return -1;
        }
    }
    else {
        if ( !dev ) {
            dev = pcap_lookupdev(errbuf);
            if ( ! dev ) {
                cerr << "error finding device: " << errbuf << endl;
                return -1;
            }
            cout << "found device: " << dev << endl;
        }
        if (pcap_lookupnet(dev, &net, &mask, errbuf) == -1) {
            cerr << "can't get netmask: " << errbuf << endl;
            return -1;
        }
        handle = pcap_open_live(dev, SNAP_LEN, 1, 1000, errbuf);
        if ( ! handle ) {
            cerr << "error opening device: " << errbuf << endl;
            return -1;
        }
    }

    switch ( pcap_datalink( handle ) ) {
    case DLT_EN10MB:
        captureHeaderSize = 14;
        break;
    case DLT_NULL:
        captureHeaderSize = 4;
        break;
    default:
        cerr << "don't know how to handle datalink type: " << pcap_datalink( handle ) << endl;
//.........这里部分代码省略.........
开发者ID:LsRbls,项目名称:mongo,代码行数:101,代码来源:sniffer.cpp


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