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


C++ SiteList类代码示例

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


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

示例1: boundingBox

/*
 * calculate the bounding box of all specified sites
 */
Iso_rectangle_2 boundingBox(SiteList sites)
{
  double xmin, xmax, ymin, ymax;
  xmin = xmax = sites.front().point().x();
  ymin = ymax = sites.front().point().y();
  SiteList::iterator itr;
  for (itr = sites.begin(); itr != sites.end(); ++itr) {
    Site_2 site = *itr;
    Point_2 point = site.point();
    if (point.x() < xmin) {
      xmin = point.x();
    }
    if (point.x() > xmax) {
      xmax = point.x();
    }
    if (point.y() < ymin) {
      ymin = point.y();
    }
    if (point.y() > ymax) {
      ymax = point.y();
    }
  }
  Iso_rectangle_2 rect(xmin, ymin, xmax, ymax);
  return rect;
}
开发者ID:AmbatiRao,项目名称:swp12,代码行数:28,代码来源:create_polygons.cpp

示例2: handleDuplicate

bool UserAgentDlg::handleDuplicate (const QString& site,
                                    const QString& identity,
                                    const QString& alias)
{
    SiteList list = ui.sitePolicyTreeWidget->findItems (site, Qt::MatchExactly, 0);

    if (!list.isEmpty()) {
        QString msg = i18n ("<qt><center>Found an existing identification for"
                            "<br/><b>%1</b><br/>"
                            "Do you want to replace it?</center>"
                            "</qt>", site);
        int res = KMessageBox::warningContinueCancel (this, msg,
                  i18nc ("@title:window", "Duplicate Identification"),
                  KGuiItem (i18n ("Replace")));
        if (res == KMessageBox::Continue) {
            list[0]->setText (0, site);
            list[0]->setText (1, identity);
            list[0]->setText (2, alias);
            configChanged();
        }

        return true;
    }

    return false;
}
开发者ID:emmanuel099,项目名称:kio,代码行数:26,代码来源:useragentdlg.cpp

示例3: readSites

SiteList readSites(std::ifstream& ifs, double SF, double wc, double wt, double wv)
{
  SiteList sites;
  std::string line;
  while (std::getline(ifs, line)) {
    std::istringstream iss(line);
    std::string type;
    long id;
    double  lat, lon;
    iss >> id;
    iss >> lon;
    iss >> lat;
    iss >> type;
    double weight = 0;
    if (type == "city") {
      weight = wc;
    } else if (type == "town") {
      weight = wt;
    } else if (type == "village") {
      weight = wv;
    }
    Site_2 site(Point_2(lon*SF, lat*SF), weight*SF, id);
    sites.push_back(site);
  }
  return sites;
}
开发者ID:AmbatiRao,项目名称:swp12,代码行数:26,代码来源:create_polygons.cpp

示例4: free

/**
 * procesează o comandă de tip SITE
 *
 * intersecțiile se realizează similar cu cele de la GET
 */
void Algorithm::wordInSite(const std::string &row)
{
	char *row_tok=strdup(row.c_str());
	char *command=strtok(row_tok," ");
	if (strcmp(command,"SITE")!=0)
	{
		free(row_tok);
		return;
	}
	
	char *site=strtok(NULL," ");
	char *word=strtok(NULL," ");
	
    SiteList* intersection = NULL;

    if (word == NULL) {
        cout << "WORD_NOT_FOUND" << endl;
        free(row_tok);
        return;
    }

    if (h->get(word) == NULL) {
        cout << "WORD_NOT_FOUND" << endl;
        free(row_tok);
        return;
    }

    intersection = h->get(word)->duplicate();

	while(word)
	{
        if (h->get(word) == NULL) {
            cout << "WORD_NOT_FOUND" << endl;
            delete intersection;
            free(row_tok);
            return;
        }

        intersection->intersectWith(h->get(word));

		word=strtok(NULL," ");
	}

    SiteNode* p = intersection->first;
    while (p != NULL) {
        if (strcmp(p->site, site)==0) {
            cout << "WORD_FOUND" << endl;
            delete intersection;
            free(row_tok);
            return;
        }
        p = p->next;
    }

    cout << "WORD_NOT_FOUND" << endl;

    delete intersection;
	free(row_tok);
}
开发者ID:AndreiDuma,项目名称:school-files,代码行数:64,代码来源:algorithm.cpp

示例5: printSites

void printSites(SiteList& sites)
{
  SiteList::iterator itr;
  for (itr = sites.begin(); itr != sites.end(); ++itr) {
    Site_2 site = *itr;
    Point_2 point = site.point();
    std::cerr << "site: " << site << std::endl;
  }
}
开发者ID:AmbatiRao,项目名称:swp12,代码行数:9,代码来源:create_polygons.cpp

示例6: on_deleteButton_clicked

void UserAgentDlg::on_deleteButton_clicked()
{
    SiteList selectedItems = ui.sitePolicyTreeWidget->selectedItems();
    SiteListIterator endIt = selectedItems.end();

    QString siteName;
    for (SiteListIterator it = selectedItems.begin(); it != endIt; ++it)
        delete (*it);

    updateButtons();
    configChanged();
}
开发者ID:emmanuel099,项目名称:kio,代码行数:12,代码来源:useragentdlg.cpp

示例7: createArtificialSites

SiteList createArtificialSites(SiteList& sites, Iso_rectangle_2 crect)
{
  SiteList artificialSites;
  // add artificial sites
  SiteList::iterator itr;
  for (itr = sites.begin(); itr != sites.end(); ++itr) {
    Site_2 site = *itr;
    Point_2 point = site.point();
    double weight = site.weight();
    Point_2 apoint1(2 * crect.xmin() - point.x(), point.y());
    Site_2 asite1(apoint1, weight);
    Point_2 apoint2(2 * crect.xmax() - point.x(), point.y());
    Site_2 asite2(apoint2, weight);
    Point_2 apoint3(point.x(), 2 * crect.ymin() - point.y());
    Site_2 asite3(apoint3, weight);
    Point_2 apoint4(point.x(), 2 * crect.ymax() - point.y());
    Site_2 asite4(apoint4, weight);
    artificialSites.push_back(asite1);
    artificialSites.push_back(asite2);
    artificialSites.push_back(asite3);
    artificialSites.push_back(asite4);
  }
  return artificialSites;
}
开发者ID:AmbatiRao,项目名称:swp12,代码行数:24,代码来源:create_polygons.cpp

示例8: main

int main(int argc , char* argv[])
{
  if (argc < 7) {
    std::cerr << "usage: test <input file> <output folder> "
      "<format (wkt | geojson | sql)> <weight city> <weight town> <weight village>" << std::endl;
    exit(1);
  }

  char* input = argv[1];
  char* outdir = argv[2];
  char* format = argv[3];

  char* swc = argv[4];
  char* swt = argv[5];
  char* swv = argv[6];

  std::ifstream ifs(input);
  assert( ifs );

  double wc, wt, wv;
  std::istringstream stmc, stmt, stmv;
  stmc.str(swc);
  stmc >> wc;
  stmt.str(swt);
  stmt >> wt;
  stmv.str(swv);
  stmv >> wv;

  std::cerr << "using weights: city: " << wc << ", town: " << wt << ", village: " << wv << std::endl;

  /*
   * prepare data
   */

  // we use a ScalingFactor(SF) here to stretch input values at the
  // beginning, and divide by SF in the end. This is used because the
  // point-generation of the hyperbola class is using some arbitrary
  // internal decision thresholds to decide how many points to generate for
  // a certain part of the curve. Rule of thumb is: the higher SF the more
  // detail is used in approximation of the hyperbolas.
  double SF = 4000;

  // read in sites from input file
  SiteList sites = readSites(ifs, SF, wc, wt, wv);

  printSites(sites);

  // calculate bounding box of all input sites (and extend it a little).
  // Extension is important, because we later add artificial sites which are
  // actually mirrored on the bounds of this rectangle. If we did not extend
  // some points would lie on the boundary of the bounding box and so would
  // their artificial clones. This would complicate the whole stuff a lot :)
  Iso_rectangle_2 crect = extend(boundingBox(sites), 0.1*SF);
  std::cerr << "rect: " << crect << std::endl;

  // a number of artificial sites
  SiteList artificialSites = createArtificialSites(sites, crect);

  /*
   * create Apollonius graph
   */

  Apollonius_graph ag;

  SiteList::iterator itr;
  // add all original sites to the apollonius graph
  for (itr = sites.begin(); itr != sites.end(); ++itr) {
    Site_2 site = *itr;
    ag.insert(site);
  }
  // add all artificial sites to the apollonius graph
  for (itr = artificialSites.begin(); itr != artificialSites.end(); ++itr) {
    Site_2 site = *itr;
    ag.insert(site);
  }

  // validate the Apollonius graph
  assert( ag.is_valid(true, 1) );
  std::cerr << std::endl;

  /*
   * create polygons from cells
   */

  // we want an identifier for each vertex within the iteration.
  // this is a loop iteration counter
  int vertexIndex = 0;

  // for each vertex in the apollonius graph (this are the sites)
  for (All_vertices_iterator viter = ag.all_vertices_begin ();
      viter != ag.all_vertices_end(); ++viter) {
    // get the corresponding site
    Site_2 site = viter->site();
    Point_2 point = site.point();
    // ignore artifical sites, detect them by their position
    if (!CGAL::do_intersect(crect, point)) {
      continue;
    }
    std::cerr << "vertex " << ++vertexIndex << std::endl;

//.........这里部分代码省略.........
开发者ID:AmbatiRao,项目名称:swp12,代码行数:101,代码来源:create_polygons.cpp

示例9: invade_bond

bool invade_bond(Bond & inv_bond)
{
	Site invSite = inv_bond.second.second;
	if (invadedSites.count(invSite) > 0){
		trapped.push_back(inv_bond);
		return true;
	}


	double newStrength;
	Site newNeighbor;
	Bond newBond;
	growth.push_back(inv_bond);
	invadedSites.insert(invSite);
    for (int dir=0; dir<6; dir++)
    {
    	newNeighbor = get_neighbor(invSite, dir);
    	if (invadedSites.count(newNeighbor) == 0)
    	{
    		newStrength = drand48();
       		newBond = std::make_pair(newStrength, std::make_pair(invSite, newNeighbor));
        	accessibleBonds.insert(std::make_pair(newStrength, newBond));
    	}
    }
    return false;
}
开发者ID:jqnorris,项目名称:InvasionPercolation,代码行数:26,代码来源:IP_3D.cpp

示例10: invade_bond

bool invade_bond(Bond & inv_bond, double strength)
{
	Site invSite = inv_bond.second;
	if (invadedSites.count(invSite) > 0){
		removed.push_back(std::make_pair(strength,inv_bond));
		return true;
	}


	double newStrength;
	Site newNeighbor;
	Bond newBond;
	growth.push_back(std::make_pair(strength,inv_bond));
	invadedSites.insert(invSite);
	for (int dir=0;dir<4;++dir)
	{
		newNeighbor = get_neighbor(invSite, dir);
		if (invadedSites.count(newNeighbor) == 0)
		{
			newStrength = get_new_strength(dir);
			if(newStrength < 1.0 || accessibleBonds.size() < 10000)
			{
				newBond = std::make_pair(invSite, newNeighbor);
				accessibleBonds.insert(std::make_pair(newStrength, newBond));
			}
		}
	}
	return false;
}
开发者ID:jqnorris,项目名称:Misc,代码行数:29,代码来源:simulation.cpp

示例11: invade_bond

void invade_bond(Bond & inv_bond)
{
	Site invSite = inv_bond.second.second;

	double newStrength;
	double tempWeight = inv_bond.first;
	Site newNeighbor;
	Bond newBond;
	growth.push_back(inv_bond);

	std::deque<Bond> tempList;

    for (int dir=0;dir<4;++dir)
    {
    	newNeighbor = get_neighbor(invSite, dir);
    	if (invadedSites.count(newNeighbor) == 0)
    	{
    		newStrength = drand48();
    		tempWeight += newStrength;
        	newBond = std::make_pair(newStrength, std::make_pair(invSite, newNeighbor));
        	tempList.push_back(newBond);
    	}
    }

    invSite.weight = tempWeight;
    invadedSites.insert(invSite);
    if(invSite.weight < threshold)
    {
    	while (!tempList.empty())
		{
    		newBond = tempList.front();
    		tempList.pop_front();
    		accessibleBonds.insert(std::make_pair(newBond.first, newBond));
		}
    }
    else
    {
    	while (!tempList.empty())
    	{
    	    newBond = tempList.front();
    	    tempList.pop_front();
    	    trapped.push_back(newBond);
    	}
    };
}
开发者ID:jqnorris,项目名称:InvasionPercolation,代码行数:45,代码来源:simulation.cpp

示例12: clear_sim

void clear_sim(void)
{
	invadedSites.clear();
	accessibleBonds.clear();
	growth.clear();
	removed.clear();
	r_squared_array.clear();
	counter = 0;
	chem_level_list.clear();
	burst_list.clear();
}
开发者ID:jqnorris,项目名称:Misc,代码行数:11,代码来源:simulation.cpp

示例13: initialize_sim

void initialize_sim(void)
{
	Site start = std::make_pair(0, 0);
	invadedSites.insert(start);
	for (int neigh=0;neigh<4; neigh++)
	{
		Bond newBond;
		double newStrength =get_new_strength(neigh);
		newBond = std::make_pair(start, get_neighbor(start, neigh));
		accessibleBonds.insert(std::make_pair(newStrength, newBond));
	}
}
开发者ID:jqnorris,项目名称:Misc,代码行数:12,代码来源:simulation.cpp

示例14: main

int main(int argc, char **argv)
{
	long int i, N;
	bool already_invaded;

	z = atoi(argv[1]);
	N = atoi(argv[2]);

    Site start = -1;
    invadedSites.insert(start);
    for (int dir=0; dir<z; ++dir)
    {
    		double newStrength = drand48();
			Site newNeighbor = 3*(start+1)+dir;
       		Bond newBond = std::make_pair(newStrength, std::make_pair(start, newNeighbor));
        	accessibleBonds.insert(std::make_pair(newStrength, newBond));
    }

    for (i=0; i<N;)
    {
    	BondMap::iterator weakest;
    	weakest = accessibleBonds.begin();
    	already_invaded = invade_bond(weakest->second);
    	if(!already_invaded)
    	{
    		i++;
    	}
    	accessibleBonds.erase(weakest);
    }

	std::ofstream toFile1("fractures.txt", std::ios::trunc);
	toFile1 << growth.size() << "\n";
	toFile1 << "Invasion for: temp" << "\n";
	toFile1.precision(17);

	Bond current_Line;
	while (!growth.empty())
	{
		current_Line = growth.front();
		growth.pop_front();
		toFile1 << current_Line.first << "\t";
		toFile1 << current_Line.second.first << "\t";
		toFile1 << current_Line.second.second<< "\n";
	}

	  toFile1.close();

    return 0;
}
开发者ID:jqnorris,项目名称:InvasionPercolation,代码行数:49,代码来源:IP_BetheLattice.cpp

示例15: invade_bond

bool invade_bond(Bond & inv_bond)
{
	Site invSite = inv_bond.second.second;

	double newStrength;
	Site newNeighbor;
	Bond newBond;
	growth.push_back(inv_bond);
	invadedSites.insert(invSite);
    for (int dir=0; dir<z-1; ++dir)
    {
    		newStrength = drand48();
			newNeighbor = 3*(invSite+1)+dir;
       		newBond = std::make_pair(newStrength, std::make_pair(invSite, newNeighbor));
        	accessibleBonds.insert(std::make_pair(newStrength, newBond));
    }
    return false;
}
开发者ID:jqnorris,项目名称:InvasionPercolation,代码行数:18,代码来源:IP_BetheLattice.cpp


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