コード例 #1
0
int main ()
{
	Stock st1( "Company A", 5.12 );
	Stock st2( "Company B", 7.13 );
	Stock st3( "Company C", 50.00 );

	StockLogger logger( std::cout );
	st1.addChangeListener( logger );
	st2.addChangeListener( logger );

	BiggestChangeRecorder recorder;
	st1.addChangeListener( recorder );
	st2.addChangeListener( recorder );

	StockChangeImportanceFilter filteredLogger( 10.00, logger );
	StockChangeImportanceFilter filteredRecorder( 20.00, recorder );
	st3.addChangeListener( filteredLogger );
	st3.addChangeListener( filteredRecorder );

	st1.updatePrice( 6.21 );
	st2.updatePrice( 7.09 );
	st1.updatePrice( 6.01 );
	st3.updatePrice( 55.00 );
	st3.updatePrice( 44.00 );

	std::cout << "Biggest positive change : "
		<< recorder.getMaxPositiveChange ()
		<< std::endl;

	std::cout << "Biggest negative change : "
		<< recorder.getMaxNegativeChange ()
		<< std::endl;
}
コード例 #2
0
ファイル: StatSvcAlg.cpp プロジェクト: atlas-org/gaudi
// ============================================================================
// the main execution method 
// ============================================================================
StatusCode GaudiExamples::StatSvcAlg::execute    () 
{
  Stat st1 ( m_stat , "counter1" ) ;
  Stat st2 ( m_stat , "counter2" ) ;
  Stat st3 ( m_stat , "counter3" , 0.3 ) ;
  
  Stat eff ( m_stat , "eff" , 0 < sin( 10 * st1->flag() ) ) ;
  //
  st1 += 0.1     ;
  st1 -= 0.1000452  ;
  st2 += st1 ;
  ++st3 ;
  st2-- ;
  
  eff += 0 < cos ( 20 * st2->flag() ) ;
  
  //
  return StatusCode::SUCCESS ;
}
コード例 #3
0
ファイル: Driver.cpp プロジェクト: rukumar333/cs240
int main() {
    Word w1, w2, w3, w4, w5(w4), w6=w5;
    Sentence s1, s2, s3, s4, s5(s4), s6=s5;
    Paragraph p1, p2, p3(p2), p4=p3;
    Story st1, st2, st3(st2), st4=st3;
    w1++;
    w1--;
    --w1;
    ++w1;
    s1++;
    s1--;
    ++s1;
    --s1;
    s1 = w1 + w2 + w3;
    s2 = w2 + w4;
    p1 = (s1 + s2);
    st1 = st1 + p2 + ((p1 + p1 + p1) + 1);
    // Word w1;
    // std::cout << w1 << std::endl;
    // std::cout << "End of code" << std::endl;
}
コード例 #4
0
ファイル: testUtils.cpp プロジェクト: mrudtf/rvtests
int main(int argc, char *argv[])
{
  {
    std::string s = "a b\"MID\" c d";
    std::vector<std::string> result;
    unsigned int ret = stringTokenize(s, ' ', &result);
    assert(ret == 4);    
    assert(result.size() == 4);
    assert(result[0] == "a");
    assert(result[1] == "b\"MID\"");
    assert(result[2] == "c");
    assert(result[3] == "d");

    ret = stringTokenize(s, "\" ", &result);
    assert(result.size() == 6);
    assert(result[0] == "a");
    assert(result[1] == "b");
    assert(result[2] == "MID");
    assert(result[3] == "");
    assert(result[4] == "c");
    assert(result[5] == "d");

    s = "";
    ret = stringTokenize(s, " ", &result);
    assert(result.size() == 1);
    assert(result[0] == "");
  }
  {
    std::string s = "a b\"MID\" c d";
    std::string piece;
    std::vector <std::string> result;
    StringTokenizer st1(s, ' ');
    while (st1.next(&piece)) {
      //printf("piece = %s\n", piece.c_str());
      result.push_back(piece);
    }
    assert(result.size() == 4);
    assert(result[0] == "a");
    assert(result[1] == "b\"MID\"");
    assert(result[2] == "c");
    assert(result[3] == "d");

    result.clear();
    StringTokenizer st2(s, "\" ");
    while (st2.next(&piece)) {
      printf("piece = %s\n", piece.c_str());
      result.push_back(piece);
    }
    assert(result.size() == 6);
    assert(result[0] == "a");
    assert(result[1] == "b");
    assert(result[2] == "MID");
    assert(result[3] == "");
    assert(result[4] == "c");
    assert(result[5] == "d");

    result.clear();
    s = "";
    StringTokenizer st3(s, " ");
    while (st3.next(&piece)) {
      result.push_back(piece);
    }
    assert(result.size() == 1);
    assert(result[0] == "");
  }  
  {
      std::string s = "";
      std::string res = stringStrip(s);
      assert(res.size() == 0);

      s = "  ";
      res = stringStrip(s);
      assert(res.size() == 0);
  }

  return 0;
}