示例#1
0
int main() {
    HasPtr hp1("hello"), hp2("world"), *ph = new HasPtr("world");
    hp1 = hp2;
    hp1 = move(*ph);

    return 0;
}
示例#2
0
void main(void)
{
  hp1();
  hp2();
  hp3();
  hp4();
}
示例#3
0
  int Meshing2OCCSurfaces :: TransformFromPlain (Point2d & planepoint,
						 Point3d & locpoint,
						 PointGeomInfo & gi,
						 double h)
  {
    Point<3> hp;
    Point<2> hp2 (planepoint.X(), planepoint.Y());
    surface.FromPlane (hp2, hp, gi, h);
    locpoint = hp;
    return 0;
  }
示例#4
0
void TestHasPtr()
{
    HasPtr hp1("Zhangsan");
    HasPtr hp2(hp1); // 拷贝构造函数
    HasPtr hp3;
    hp3 = hp1; // 拷贝赋值运算符
	// 我们在HasPtr中添加了一个重载的operator=(const std::string& rhs),使得这里可以直接将一个string赋给一个HasPtr对象
	// 而且它仅仅修改HasPtr的string成员*ps,int i成员和use成员不改变。
    hp2 = "Lisi";
    hp3 = "Wangwu";

    std::cout << "hp1: " << *hp1 << std::endl;
    std::cout << "hp2: " << *hp2 << std::endl;
    std::cout << "hp3: " << *hp3 << std::endl;
}
示例#5
0
文件: main.cpp 项目: icopavan/hachoir
uint64_t scenario2(uint64_t hoppingPeriod, uint64_t beaconningPeriod,
		       size_t /*beaconCount*/, float /*senseBW*/)
{
	uint64_t band_start = 2.3995e9;
	uint64_t band_end = 2.5125e9;

	float band1 = band_start + (rand_cmwc() % ((band_end - band_start) / 1000000)) * 1e6;
	float band2 = band_start + (rand_cmwc() % ((band_end - band_start) / 1000000)) * 1e6;

	/*std::cout << "Band1: " << band1 / 1e6;
	std::cout << ", Band2: " << band2 / 1e6 << std::endl;*/

	HoppingPattern hp1(1000e3, Band(band_start, band_end), 1.1e6, HoppingPattern::LINEAR, 1e3);
	hp1.addAvailableEntry(Band(band1, band1+1e6), 0.0, 0.4);
	hp1.addAvailableEntry(Band(band2, band2+1e6), 0.5, 0.4);
	CogNode n1(42, 0, 0, beaconningPeriod, hp1, 1);

	HoppingPattern hp2(60e6, Band(band_start, band_end), 1.1e6, HoppingPattern::RANDOM,
			   hoppingPeriod, 1e6);
	CogNode n2(43, 0, 0, 10e3, hp2, 1);

	CogNode *nodes[] = { &n1, &n2 };
	size_t nodesCount = sizeof(nodes) / sizeof(CogNode *);

	while (true) {
		uint64_t next = -1;

		for (size_t i = 0; i < nodesCount; i++) {
			uint64_t nodeNext = nodes[i]->usUntilNextOperation();
			if (nodeNext < next)
				next = nodeNext;
		}

		//std::cout << "next = " << next << std::endl;

		// FIXME? If a node jumps to a frequency, it won't be able to
		// receive a message until the next tick change. That's pretty
		// much what we get in real life though :s
		for (size_t i = 0; i < nodesCount; i++) {
			nodes[i]->addTicks(next);
			if (n2.hasNeighbour(42)) {
				return n2.ticksSinceStart();
			}
		}
	}

	//std::cout << std::endl;
}
示例#6
0
void DrawTContact(QPainter *p,pigalePaint *paint)
  {GeometricGraph G(paint->GCP);
  Prop<Tpoint> hp1(G.Set(tvertex()),PROP_DRAW_POINT_1);
  Prop<Tpoint> hp2(G.Set(tvertex()),PROP_DRAW_POINT_2);
  Prop<Tpoint> vp1(G.Set(tvertex()),PROP_DRAW_POINT_3);
  Prop<Tpoint> vp2(G.Set(tvertex()),PROP_DRAW_POINT_4);
  Prop<Tpoint> postxt(G.Set(tvertex()),PROP_DRAW_POINT_5);
  Prop1<double> sizetext(G.Set(),PROP_DRAW_DBLE_1);
  tvertex v;	
  // Draw horizontals and verticals
  for(v = 1;v <= G.nv();v++)
      {if(hp1[v].x() > .0)paint->DrawSeg(p,hp1[v],hp2[v],Black);
      if(vp1[v].x() > .0)paint->DrawSeg(p,vp1[v],vp2[v],Black);
      }
  // Draw text
  p->setFont(QFont("sans",Min((int)(sizetext() * Min(paint->xscale,paint->yscale) + .5),13)));
  for(v=1; v <= G.nv();v++)
      paint->DrawText(p,postxt[v],v,G.vcolor[v],0);
  }
示例#7
0
void Surface :: CalcHesse (const Point<3> & point, Mat<3> & hesse) const
{
  double dx = 1e-5;
  Point<3> hp1, hp2;
  Vec<3> g1, g2;

  for (int i = 0; i < 3; i++)
    {
      hp1 = point;
      hp2 = point;

      hp1(i) += dx;
      hp2(i) -= dx;

      CalcGradient (hp1, g1);
      CalcGradient (hp2, g2);
      	
      for (int j = 0; j < 3; j++)
	hesse(i, j) = (g1(j) - g2(j)) / (2 * dx);
    }
}
示例#8
0
文件: hotpatch-20.c 项目: 0day-ci/gcc
void hp1(void)
{
  hp2();
}