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


C++ XRef::GetResult方法代码示例

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


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

示例1: TestSampleTimeout

void XStatisticsTest::TestSampleTimeout()
{
    // Add samples, wait half the expiration time, add more samples,
    // wait a little over half the expiration time, make sure half
    // the sample have been pruned.
    XRef<XStatistics<Average,double> > avg = new XStatistics<Average,double>(g_testLen*10, XDuration(XSDK::SECONDS, MAX_DURATION_SEC));
    UT_ASSERT( avg.IsValid() == true );
    for (size_t ii=0; ii<g_testLen; ++ii)
        avg->AddSample(g_test[ii]);

    x_sleep(MAX_DURATION_SEC / 2);

    for (size_t ii=0; ii<g_testLen; ++ii)
        avg->AddSample(g_test[ii]);

    x_sleep( (MAX_DURATION_SEC / 2) + (MAX_DURATION_SEC / 4) );

    double result = 0.0;
    UT_ASSERT_NO_THROW( avg->GetResult(result) );

    int count = -1;
    UT_ASSERT_NO_THROW( count = avg->GetNumSamples() );
    UT_ASSERT( count == (int)g_testLen );

    // "Hand-calculate" the average
    double answer = 0.0;
    for (size_t ii=0; ii<g_testLen; ++ii)
        answer += g_test[ii];
    answer /= g_testLen;

    UT_ASSERT( answer == result );
}
开发者ID:KennyDark,项目名称:opencvr,代码行数:32,代码来源:XStatisticsTest.cpp

示例2: TestMaxSamples

void XStatisticsTest::TestMaxSamples()
{
    XRef<XStatistics<Average,double> > avg = new XStatistics<Average,double>(MAX_SAMPLES);
    UT_ASSERT( avg.IsValid() == true );
    for (size_t ii=0; ii<g_testLen; ++ii)
        avg->AddSample(g_test[ii]);
    double result = 0.0;
    UT_ASSERT_NO_THROW( avg->GetResult(result) );

    // "Hand-calculate" the average
    double answer = 0.0;
    for (size_t ii=g_testLen-MAX_SAMPLES; ii<g_testLen; ++ii)
        answer += g_test[ii];
    answer /= MAX_SAMPLES;

    UT_ASSERT( answer == result );

    int count = -1;
    UT_ASSERT_NO_THROW( count = avg->GetNumSamples() );
    UT_ASSERT( count == MAX_SAMPLES );
    UT_ASSERT_NO_THROW( count = avg->GetMaxSamples() );
    UT_ASSERT( count == MAX_SAMPLES );

    UT_ASSERT_NO_THROW( avg->SetMaxSamples( MAX_SAMPLES + 1 ) );
    UT_ASSERT( count = avg->GetMaxSamples() );
    UT_ASSERT( count == MAX_SAMPLES + 1 );
    for (size_t ii=0; ii<g_testLen; ++ii)
        avg->AddSample(g_test[ii]);
    UT_ASSERT_NO_THROW( count = avg->GetNumSamples() );
    UT_ASSERT( count == MAX_SAMPLES + 1 );
}
开发者ID:KennyDark,项目名称:opencvr,代码行数:31,代码来源:XStatisticsTest.cpp

示例3: TestAverage

void XStatisticsTest::TestAverage()
{
    XRef<XStatistics<Average,double> > avg = new XStatistics<Average,double>;
    UT_ASSERT( avg.IsValid() == true );
    for (size_t ii=0; ii<g_testLen; ++ii)
        avg->AddSample(g_test[ii]);
    double result = 0.0;
    UT_ASSERT_NO_THROW( avg->GetResult(result) );

    // "Hand-calculate" the average
    double answer = 0.0;
    for (size_t ii=0; ii<g_testLen; ++ii)
        answer += g_test[ii];
    answer /= g_testLen;

    UT_ASSERT( answer == result );
}
开发者ID:KennyDark,项目名称:opencvr,代码行数:17,代码来源:XStatisticsTest.cpp

示例4: TestMedian

void XStatisticsTest::TestMedian()
{
    XRef<XStatistics<Median,double> > med = new XStatistics<Median,double>;
    UT_ASSERT( med.IsValid() == true );
    for (size_t ii=0; ii<g_testLen; ++ii)
        med->AddSample(g_test[ii]);
    double result = 0.0;
    UT_ASSERT_NO_THROW( med->GetResult(result) );

    // "Hand-calculate" the median
    vector<double> sorted(g_testLen);
    for (size_t ii=0; ii<g_testLen; ++ii)
        sorted[ii] = g_test[ii];
    sort(sorted.begin(), sorted.end());
    double answer = sorted[g_testLen/2];

    UT_ASSERT( answer == result );
}
开发者ID:KennyDark,项目名称:opencvr,代码行数:18,代码来源:XStatisticsTest.cpp


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