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


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

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


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

示例1:

TEST_F( TArrayTest, resizeTest ) {
    TArray<float> arrayInstance;
	EXPECT_EQ( 0, arrayInstance.size() );

	arrayInstance.resize( 5 );
	EXPECT_EQ( 5, arrayInstance.size() );
}
开发者ID:kimkulling,项目名称:cppcore,代码行数:7,代码来源:TArrayTest.cpp

示例2: tick_main

    bool tick_main(void)
    {
        if (! gThreadManager.isThreadRunning()) {
            return false;
        }

        jmp_buf hayatJmpBuf;
        if (setjmp(hayatJmpBuf) == 0) {

            hmd_halt_jmpbuf = & hayatJmpBuf;
        
            gThreadManager.exec1tick();

            hyu32 n = updateFuncArr.size();
            for (hyu32 i = 0; i < n; ++i)
                updateFuncArr[i]();

            n = drawFuncArr.size();
            for (hyu32 i = 0; i < n; ++i)
                drawFuncArr[i]();

            GC::incremental();

        } else {
#ifdef HMD_ALLOW_CPP_EXCEPTION
            throw "error on hayat script execution";
#else
            HMD_FATAL_ERROR(M_M("error on hayat script execution"));
#endif
        }

        return true;
    }
开发者ID:FUKUZAWA-Tadashi,项目名称:Hayat,代码行数:33,代码来源:EngineControl.cpp

示例3: init

void Frame::init(TArray<PassData*> &newPasses) {
    if (newPasses.isEmpty()) {
        return;
    }
    for (ui32 i = 0; i < newPasses.size(); ++i) {
        m_newPasses.add(newPasses[i]);
    }
    m_uniforBuffers = new UniformBuffer[newPasses.size()];
}
开发者ID:kimkulling,项目名称:osre,代码行数:9,代码来源:RenderCommon.cpp

示例4: ContainerClear

TEST_F( TArrayTest, ContainerClearTest ) {
    TArray<float*> arrayInstance;
    ContainerClear( arrayInstance );
    EXPECT_TRUE( arrayInstance.isEmpty() );

    arrayInstance.add( new float( 0.0f ) );
    arrayInstance.add( new float( 1.0f ) );
    arrayInstance.add( new float( 2.0f ) );

    EXPECT_EQ( arrayInstance.size(), 3U );
    ContainerClear( arrayInstance );
    EXPECT_EQ( arrayInstance.size(), 0U );
    EXPECT_TRUE( arrayInstance.isEmpty() );
}
开发者ID:kimkulling,项目名称:cppcore,代码行数:14,代码来源:TArrayTest.cpp

示例5: test_replace

 void test_replace(void)
 {
     TArray<int> arr;
     arr.initialize(10);
     for (int i = 0; i < 10; ++i)
         arr.add(i * 10);
     CPPUNIT_ASSERT_EQUAL(30, arr.replace(3, -10));
     CPPUNIT_ASSERT_EQUAL(50, arr.replace(5, -10));
     CPPUNIT_ASSERT_EQUAL(80, arr.replace(8, 800));
     CPPUNIT_ASSERT_EQUAL(-10, arr.replace(5, 10));
     CPPUNIT_ASSERT_EQUAL(-10, arr.replace(3, 10));
     CPPUNIT_ASSERT_EQUAL(800, arr.replace(8, 10));
     CPPUNIT_ASSERT_EQUAL((hyu32)10, arr.size());
     arr.deleteVal(10);
     CPPUNIT_ASSERT_EQUAL((hyu32)6, arr.size());
 }
开发者ID:FUKUZAWA-Tadashi,项目名称:Hayat,代码行数:16,代码来源:Test_hyArray.cpp

示例6: test_insert_remove

    void test_insert_remove(void)
    {
        TArray<int> arr;

        arr.initialize(2);
        CPPUNIT_ASSERT_EQUAL((hyu32)0, arr.size());
        HMD_ASSERT_HALT(arr.insert(1));
        arr.insert(0) = 10;
        CPPUNIT_ASSERT_EQUAL((hyu32)1, arr.size());
        CPPUNIT_ASSERT_EQUAL(10, arr[0]);
        arr.insert(0) = 20;
        CPPUNIT_ASSERT_EQUAL((hyu32)2, arr.size());
        CPPUNIT_ASSERT_EQUAL(20, arr[0]);
        CPPUNIT_ASSERT_EQUAL(10, arr[1]);
        arr.insert(1) = 30;
        CPPUNIT_ASSERT_EQUAL((hyu32)3, arr.size());
        CPPUNIT_ASSERT_EQUAL(20, arr[0]);
        CPPUNIT_ASSERT_EQUAL(30, arr[1]);
        CPPUNIT_ASSERT_EQUAL(10, arr[2]);
        arr.insert(3) = 40;
        CPPUNIT_ASSERT_EQUAL((hyu32)4, arr.size());
        CPPUNIT_ASSERT_EQUAL(20, arr[0]);
        CPPUNIT_ASSERT_EQUAL(30, arr[1]);
        CPPUNIT_ASSERT_EQUAL(10, arr[2]);
        CPPUNIT_ASSERT_EQUAL(40, arr[3]);
        arr.insert(-1) = 50;
        CPPUNIT_ASSERT_EQUAL((hyu32)5, arr.size());
        CPPUNIT_ASSERT_EQUAL(20, arr[0]);
        CPPUNIT_ASSERT_EQUAL(30, arr[1]);
        CPPUNIT_ASSERT_EQUAL(10, arr[2]);
        CPPUNIT_ASSERT_EQUAL(50, arr[3]);
        CPPUNIT_ASSERT_EQUAL(40, arr[4]);

        arr.remove(2);
        CPPUNIT_ASSERT_EQUAL((hyu32)4, arr.size());
        CPPUNIT_ASSERT_EQUAL(20, arr[0]);
        CPPUNIT_ASSERT_EQUAL(30, arr[1]);
        CPPUNIT_ASSERT_EQUAL(50, arr[2]);
        CPPUNIT_ASSERT_EQUAL(40, arr[3]);
        arr.remove(-3);
        CPPUNIT_ASSERT_EQUAL((hyu32)3, arr.size());
        CPPUNIT_ASSERT_EQUAL(20, arr[0]);
        CPPUNIT_ASSERT_EQUAL(50, arr[1]);
        CPPUNIT_ASSERT_EQUAL(40, arr[2]);
        HMD_ASSERT_HALT(arr.remove(3));
        HMD_ASSERT_HALT(arr.remove(-4));

        int* p = arr.nthAddr(3);
        int* q = arr.addSpaces(2);
        CPPUNIT_ASSERT_EQUAL((hyu32)5, arr.size());
        CPPUNIT_ASSERT_EQUAL(p, q);
    }
开发者ID:FUKUZAWA-Tadashi,项目名称:Hayat,代码行数:52,代码来源:Test_hyArray.cpp

示例7: ElementsAre

TEST(TEST_FUNC, SortArrayWithTwoSameElements) {
    TArray arr {1, 1};
    EXPECT_FALSE(arr.empty());
    EXPECT_THAT(arr, ElementsAre(1, 1));
    TEST_FUNC(arr.data(), arr.size());
    EXPECT_FALSE(arr.empty());
    EXPECT_THAT(arr, ElementsAre(1, 1));
}
开发者ID:skhal,项目名称:algo,代码行数:8,代码来源:template.cpp

示例8: sizeof

TEST(TEST_FUNC, SortArrayWithElevenElements) {
    int source [] {15, 13, 11, 2, 7, 1, 18, 8, 10, 5, 4};
    const size_t size = sizeof(source) / sizeof(int);
    TArray arr {source, source + size};
    EXPECT_FALSE(arr.empty());
    EXPECT_THAT(arr, ElementsAreArray({15, 13, 11, 2, 7, 1, 18, 8, 10, 5, 4}));
    TEST_FUNC(arr.data(), arr.size());
    EXPECT_FALSE(arr.empty());
    EXPECT_THAT(arr, ElementsAreArray({1, 2, 4, 5, 7, 8, 10, 11, 13, 15, 18}));
}
开发者ID:skhal,项目名称:algo,代码行数:10,代码来源:template.cpp

示例9: i

TEST_F( TArrayTest, iterateTest ) {
    TArray<float> arrayInstance;
	createArray( ArrayData, ArraySize, arrayInstance );

	size_t i( 0 );
    for( TArray<float>::Iterator it = arrayInstance.begin( ); it != arrayInstance.end( ); ++it ) {
        ++i;
	}
	EXPECT_EQ( i, arrayInstance.size() );
}
开发者ID:kimkulling,项目名称:cppcore,代码行数:10,代码来源:TArrayTest.cpp

示例10: term_main

    void term_main(void)
    {
        hyu32 n = termFuncArr.size();
        for (hyu32 i = 0; i < n; ++i)
            termFuncArr[i]();

        finalizeAll();
        finalizeDebug();

        loadPathArr.finalize();
        updateFuncArr.finalize();
        drawFuncArr.finalize();
        termFuncArr.finalize();
        for (hyu32 i = dllHandleArr.size(); i > 0; ) {
            AfxFreeLibrary(dllHandleArr[--i]);
        }
        dllHandleArr.finalize();

        HMD_FREE(mainMem);
        HMD_FREE(debugMem);
    }
开发者ID:FUKUZAWA-Tadashi,项目名称:Hayat,代码行数:21,代码来源:EngineControl.cpp

示例11: test_deleteVal

    void test_deleteVal(void)
    {
        TArray<int> arr;

        arr.initialize(10);
        for (int i = 0; i < 10; ++i)
            arr.add(i * 10);
        arr[3] = 80;
        arr[6] = 80;
        CPPUNIT_ASSERT_EQUAL((hyu32)10, arr.size());
        arr.deleteVal(20);
        CPPUNIT_ASSERT_EQUAL((hyu32)9, arr.size());
        arr.deleteVal(80);
        CPPUNIT_ASSERT_EQUAL((hyu32)6, arr.size());
        CPPUNIT_ASSERT_EQUAL(0, arr[0]);
        CPPUNIT_ASSERT_EQUAL(10, arr[1]);
        CPPUNIT_ASSERT_EQUAL(40, arr[2]);
        CPPUNIT_ASSERT_EQUAL(50, arr[3]);
        CPPUNIT_ASSERT_EQUAL(70, arr[4]);
        CPPUNIT_ASSERT_EQUAL(90, arr[5]);
    }
开发者ID:FUKUZAWA-Tadashi,项目名称:Hayat,代码行数:21,代码来源:Test_hyArray.cpp

示例12: addLoadPath

 // ロードパスを追加する
 void    addLoadPath(const char* path)
 {
     //printf("addLoadPath(%s)\n", path);
     hyu32 n = loadPathArr.size();
     if (n == 0) {
         loadPathArr.add(NULL);
         n = 1;
     }
     hyu32 len = HMD_STRLEN(path);
     char* apath = gMemPool->allocT<char>(len+1);
     HMD_STRNCPY(apath, path, len+1);
     loadPathArr[n-1] = apath;  // end mark に上書き
     loadPathArr.add(NULL);     // 新しい end mark
     HMD_LOADPATH = loadPathArr.top();
     // n=0;for(const char** p = HMD_LOADPATH; *p != NULL; ++p)HMD_PRINTF("path %d:'%s'\n",n++,*p);
 }
开发者ID:FUKUZAWA-Tadashi,项目名称:Hayat,代码行数:17,代码来源:EngineControl.cpp

示例13: fwriteDebugInfo

void Context::fwriteDebugInfo(FILE* fp, hyu32 offs)
{
    TArray<const char*> paths;

    m_fwriteDebugInfo(fp, paths, offs);

    // SourceInfo終了マーク
    hyu8 buf[4];
    memset(buf, 0, 4);
    fwrite(buf, sizeof(hyu32), 1, fp);

    // パス情報書き出し
    hyu32 n = paths.size();
    Endian::pack<hyu16>(buf, (hyu16)n);
    fwrite(buf, sizeof(hyu16), 1, fp);
    for (hyu32 i = 0; i < n; i++) {
        const char* p = paths[i];
        fwrite(p, 1, HMD_STRLEN(p)+1, fp);
    }
}
开发者ID:FUKUZAWA-Tadashi,项目名称:Hayat,代码行数:20,代码来源:hyCContext.cpp

示例14: tokenize

ui32 Tokenizer::tokenize( const String& str, TArray<String>& tokens, const String& delimiters ) {
    // Skip delimiters at beginning.
    String::size_type lastPos = str.find_first_not_of( delimiters, 0 );
    
    // find first "non-delimiter".
    String::size_type pos = str.find_first_of( delimiters, lastPos );
    while( String::npos != pos || String::npos != lastPos ) {
        // Found a token, add it to the vector.
        String tmp = str.substr( lastPos, pos - lastPos );
        if ( !tmp.empty() && ' ' != tmp[ 0 ] ) {
            tokens.add( tmp );
        }
        
        // Skip delimiters.  Note the "not_of"
        lastPos = str.find_first_not_of( delimiters, pos );
        
        // Find next "non-delimiter"
        pos = str.find_first_of( delimiters, lastPos );
    }

    return static_cast<ui32>( tokens.size() );
}
开发者ID:kimkulling,项目名称:osre,代码行数:22,代码来源:Tokenizer.cpp

示例15: main

int main()
{
   // test 1
   Tensor<double> T(2,2,2); T.fill(0.0);

   T(1,0,1) = -0.5;

   T.at(1,1,0) = 0.5;

   cout << "printing T: size = " << T.size() << " objsize = " << sizeof(T) << endl;
   for(double x : T) cout << x << endl;

   // test 2
   typedef Tensor<float, CblasRowMajor, varray<float>> MyTensor;
   MyTensor::shape_type shape = { 4, 4 };
   MyTensor Q(shape); Q.fill(2.0);

   MyTensor::shape_type index = { 1, 2 };

   Q(index) = -0.5;
   ++index[0];
   Q.at(index) = 0.5;

   cout << "printing Q: size = " << Q.size() << " objsize = " << sizeof(Q) << endl;
   for(double x : Q) cout << x << endl;

   Q = T;
   cout << "printing Q (=T): size = " << Q.size() << " objsize = " << sizeof(Q) << endl;
   for(double x : Q) cout << x << endl;

   // test 3
   Tensor<double> S(2,2,2); S.fill(1.0);
   axpy(0.5, T, S);

   cout << "printing S: size = " << S.size() << " objsize = " << sizeof(S) << endl;
   for(double x : S) cout << x << endl;

   Tensor<double> U;
   axpy(0.5, S, U);

   cout << "printing U: size = " << U.size() << " objsize = " << sizeof(U) << endl;
   for(double x : U) cout << x << endl;

   // test 4
   Tensor<double> V(0, 0);
   gemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 1.0, T, S, 1.0, V);

   cout << "printing V: size = " << V.size() << " objsize = " << sizeof(V) << endl;
   for(double x : V) cout << x << endl;

   // test 5
   cout << boolalpha;
   cout << "is_tensor<Tensor<double>> = " << is_tensor<Tensor<double>>::value << endl;
   cout << "is_tensor<Tensor<Tensor<double>>> = " << is_tensor<Tensor<Tensor<double>>>::value << endl;
   cout << "is_tensor<vector<double>> = " << is_tensor<vector<double>>::value << endl;

   // test 6
   Tensor<Tensor<double>> A(4,4); A.fill(Tensor<double>(0,0));
   A(0,0) = Tensor<double>(2,2);
   A(1,1) = Tensor<double>(2,2);
   A(2,2) = Tensor<double>(2,2);
   A(3,3) = Tensor<double>(2,2);

   Tensor<Tensor<double>> B(4,4); B.fill(Tensor<double>(0,0));
   B(0,0) = Tensor<double>(2,2);
   B(1,1) = Tensor<double>(2,2);
   B(2,2) = Tensor<double>(2,2);
   B(3,3) = Tensor<double>(2,2);

   Tensor<Tensor<double>> C(4,4); C.fill(Tensor<double>(0,0)); // rank info is required to determine contraction ranks at gemm
   gemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 1.0, A, B, 1.0, C);

   // test 7

   Tensor<double> a(4,4); a.fill(1.0);
// gemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 1.0, A, a, 1.0, C); // this will give a compile-time error, since gemm for "tensor of tensor" and "tensor" is not supported

   // test 8
   TArray<double,3> t(2,2,2); t.fill(0.0);

   t(1,0,1) = -0.5;

   t.at(1,1,0) = 0.5;

   cout << "printing t: size = " << t.size() << " objsize = " << sizeof(t) << endl;
   for(double x : t) cout << x << endl;

   TArray<double,3> s(S);

   cout << "printing s: size = " << s.size() << " objsize = " << sizeof(s) << endl;
   for(double x : s) cout << x << endl;

   TArray<double,2> v;
   gemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 1.0, t, s, 1.0, v);

   cout << "printing v: size = " << v.size() << " objsize = " << sizeof(v) << endl;
   for(double x : v) cout << x << endl;

   TArray<double,3,CblasRowMajor,std::set<double>> u;

//.........这里部分代码省略.........
开发者ID:naokin,项目名称:BTAS-TWG,代码行数:101,代码来源:test.C


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