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


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

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


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

示例1:

TEST_F( TArrayTest, moveTest ) {
    TArray<float> arrayInstance;
    arrayInstance.add( 1.0f );
    arrayInstance.add( 2.0f );
    arrayInstance.add( 3.0f );
    arrayInstance.move( 1, 3 );
}
开发者ID:kimkulling,项目名称:cppcore,代码行数:7,代码来源:TArrayTest.cpp

示例2: 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

示例3: JumpControlTbl

        JumpControlTbl(const hyu8** pCode)
            : tbl(0)
        {
            const hyu8* code = *pCode;
            hyu16 endOffs = Endian::unpack<hyu16>(code);
            const hyu8* endAddr = code + endOffs;
            code += 2;
            hyu8 numTbl = *code;
            code += 2;
            hyu16* tblOffs = (hyu16*) code;
            code += sizeof(hyu16) * numTbl;
            alignPtr<4>(&code);

            tbl.initialize(numTbl);
            for (hyu8 i = 0; i < numTbl; ++i) {
                HMD_ASSERTMSG(tblOffs[i] == code - *pCode, "offs=%x, code=%x, start=%x",tblOffs[i],code,*pCode);
                hyu8 numLabel = *code;
                code += 4;
                BMap<hys32, SymbolID_t>* addrLabel = new BMap<hys32, SymbolID_t>(numLabel);
                SymbolID_t* labels = (SymbolID_t*) code;
                hys32* addrs = (hys32*)(code + sizeof(SymbolID_t) * numLabel);
                alignPtr<4>(&addrs);
                for (hyu8 j = 0; j < numLabel; ++j) {
                    addrLabel->forceAdd(addrs[j], labels[j]);
                }
                tbl.add(addrLabel);
                code = (const hyu8*) (addrs + numLabel);
            }
            HMD_ASSERT(code == endAddr);
            *pCode = code;
        }
开发者ID:FUKUZAWA-Tadashi,项目名称:Hayat,代码行数:31,代码来源:htDisasm.cpp

示例4: 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

示例5: sizeof

    // バイトコードがメモリにロードされた直後のコールバック。
    // 対応するDLLがあればロードする
    static void cb4dll(const char* hybPath)
    {
        int len = HMD_STRLEN(hybPath);
        char* dllPath = (char*)HMD_ALLOCA(len + sizeof(dll_prefix)+sizeof(dll_ext));
        char* q = dllPath;
        char* q2 = q;

        const unsigned char* p = _mbsrchr((const unsigned char*)hybPath, PATH_DELIM);
        if (p == NULL) {
            p = (const unsigned char*)hybPath;
        } else {
            p += 1;
            size_t lp = p - (const unsigned char*)hybPath;
            memcpy(q, hybPath, lp);
            q += lp;
            q2 = q;
        }
        // pはhybPathのファイル名部分の先頭アドレス
        const unsigned char* p2 = _mbsstr((const unsigned char*)p, (const unsigned char*)".hyb");
        if ((p2 <= p) || (p2 >= (const unsigned char*)hybPath + len)) {
            p2 = (const unsigned char*)hybPath + len;
        }
        // p2は拡張子を抜いたファイル名部分の末尾アドレス

        memcpy(q, dll_prefix, sizeof(dll_prefix));
        q += sizeof(dll_prefix) - 1;
        size_t lp2 = p2 - p;
        memcpy(q, p, lp2);
        q += lp2;
        memcpy(q, dll_ext, sizeof(dll_ext));
        q += sizeof(dll_ext) - 1;
        *q = '\0';

#ifdef VERBOSE_LOAD_DLL
        HMD_PRINTF("try load dll: %s\n", dllPath);
#endif
		HMODULE hmod = LoadLibraryMB(dllPath);    // dllロード
#ifdef VERBOSE_LOAD_DLL
        if (hmod == NULL) printLastError();
#endif        
        if (hmod == NULL && q2 != dllPath) {
            // パス抜きのファイル名だけでロードしてみる
#ifdef VERBOSE_LOAD_DLL
            HMD_PRINTF("try load dll: %s\n", q2);
#endif        
            hmod = LoadLibraryMB(q2);
#ifdef VERBOSE_LOAD_DLL
            if (hmod == NULL) printLastError();
#endif        
        }

        if (hmod != NULL) {
            dllHandleArr.add(hmod);
#ifdef VERBOSE_LOAD_DLL
            HMD_PRINTF("DLL '%s' loaded.\n", q2);
#endif
        }
    }
开发者ID:FUKUZAWA-Tadashi,项目名称:Hayat,代码行数:60,代码来源:EngineControl.cpp

示例6: replaceSymbol

TArray<char>* replaceSymbol(const char* line)
{
    TArray<char>* buf = new TArray<char>(HMD_STRLEN(line)+1);
    const char* p = line;
    char c;
    while ('\0' != (c = *p)) {
        if (c == '{') {
            int n = getSymIDNum(&p);
            if (n >= 0) {
                const char* s = (const char*)gSymbolTable.id2str((SymbolID_t)n);
                if (s != NULL) {
                    hyu32 len = HMD_STRLEN(s);
                    memcpy(buf->addSpaces(len), s, len);
                    continue;
                }
            }
        }
        buf->add(c);
        ++p;
    }
    buf->add('\0');
    return buf;
}
开发者ID:FUKUZAWA-Tadashi,项目名称:Hayat,代码行数:23,代码来源:htGokou.cpp

示例7: getDebInfo

DebugInfos* getDebInfo(const char* package)
{
    SymbolID_t pkgid = gSymbolTable.symbolID(package);
    DebugInfos** pdsi = m_debInfos.find(pkgid);
    if (pdsi != NULL)
        return *pdsi;
    hyu32 len = HMD_STRLEN(package);
    TArray<char>* fname = new TArray<char>(len + HMD_STRLEN(DEBUGINFO_EXT) + 1);
    memcpy(fname->addSpaces(len), package, len);
    len = HMD_STRLEN(DEBUGINFO_EXT);
    memcpy(fname->addSpaces(len), DEBUGINFO_EXT, len);
    fname->add('\0');

    return new DebugInfos(fname->top());
}
开发者ID:FUKUZAWA-Tadashi,项目名称:Hayat,代码行数:15,代码来源:htGokou.cpp

示例8: 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

示例9: 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

示例10: 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

示例11: writeByteCodes

void Context::writeByteCodes(TArray<hyu8>* out)
{
    TArray<hyu8> classInitializer;
    m_bytecode.write(&classInitializer);
    TArray< TArray<hyu8>* > binaries;
    TArray< TArray<hyu8>* > needDeleteBin;
    //innerClassSyms = @innerClasses.keys.sort
    TArray<SymbolID_t>& innerClassSyms = m_innerClasses.keys();

    hyu16 flags = 0;
    if (classInfo()->isPrimitive())
        flags |= 0x0001;

    hyu32 numInnerClass = innerClassSyms.size();
    HMD_ASSERT(numInnerClass < 65536);

    TArray<SymbolID_t>& methodSyms = m_classInfo->m_methods.keys();
    TArray<ClassInfo::m_SigCode_t>& methodSigCodes = m_classInfo->m_methods.values();
    hyu32 numMethod = methodSyms.size();
    HMD_ASSERT(numMethod < 65536);
    hyu32 numClosure = m_classInfo->numClosure();
    HMD_ASSERT(numClosure < 65536);

    packOut<hyu16>(out,flags);                // フラグ hyu16
    packOut<hyu16>(out,(hyu16)numMethod);      // メソッド数 hyu16
    packOut<hyu16>(out,(hyu16)numInnerClass);   // インナークラス数 hyu16
    packOut<hyu16>(out,m_classInfo->numSuper());    // スーパークラス数 hyu16
    packOut<hyu16>(out,m_classInfo->numClassVar()); // クラス変数数 hyu16
    packOut<hyu16>(out,m_classInfo->numMembVar()); // メンバ変数数 hyu16
    packOut<hyu16>(out,m_classInfo->numConstVar());    // 定数数 hyu16
    packOut<hyu16>(out,m_classInfo->numDefaultVal()); // デフォルト値数
    packOut<hyu16>(out,(hyu16)numClosure);            // クロージャ数 hyu16
    packOut<hyu16>(out,0xf9f9); // 未使用

    for (hyu32 i = 0; i < numMethod; i++)
        packOut<SymbolID_t>(out,methodSyms[i]); // メソッドシンボル
    for (hyu32 i = 0; i < numInnerClass; i++)
        packOut<SymbolID_t>(out,innerClassSyms[i]);    // クラス名シンボル


    m_classInfo->writeClassVarSyms(out); // クラス変数シンボル
    m_classInfo->writeMembVarSyms(out); // メンバ変数シンボル
    m_classInfo->writeConstVarSyms(out); // 定数シンボル


    out->align(4, 0xfb);


    hyu32 pos = classInitializer.size();

    for (hyu32 i = 0; i < numMethod; i++) {
        packOut<hyu32>(out, pos);     // メソッドオフセット
        Bytecode* bc = methodSigCodes[i].pBytecode;
        TArray<hyu8>* bin = new TArray<hyu8>(128);
        needDeleteBin.add(bin);
        bc->setOffset(pos);
        bc->write(bin);
        binaries.add(bin);
        pos += bin->size();
        HMD_DEBUG_ASSERT((pos & 3) == 0);
    }
    for (hyu32 i = 0; i < numClosure; i++) {
        packOut<hyu32>(out, pos);     // クロージャオフセット
        Bytecode* bc = m_classInfo->m_closures[i];
        TArray<hyu8>* bin = new TArray<hyu8>(128);
        needDeleteBin.add(bin);
        bc->setOffset(pos);
        bc->write(bin);
        binaries.add(bin);
        pos += bin->size();
        HMD_DEBUG_ASSERT((pos & 3) == 0);
    }

    for (hyu32 i = 0; i < numInnerClass; i++) {
        packOut<hyu32>(out, pos);     // クラスオフセット
        Context* inner = m_innerClasses[innerClassSyms[i]];
        TArray<hyu8>* bin = new TArray<hyu8>(128);
        needDeleteBin.add(bin);
        inner->bytecode().setOffset(pos);
        inner->writeByteCodes(bin);
        bin->align(4, 0xfa);
        binaries.add(bin);
        pos += bin->size();
    }

    packOut<hyu32>(out, pos); // インナークラスバイトコードの終了位置オフセット

    m_classInfo->writeSuperLinks(out); // スーパークラス
    m_classInfo->writeUsingPaths(out); // usingパス情報

    //printf("classInitializer addr=%x\n",out->size());
    m_bytecode.setOffset(m_bytecode.getOffset() + out->size());
    out->add(classInitializer);
    hyu32 n = binaries.size();
    for (hyu32 i = 0; i < n; i++) {
        out->add(*binaries[i]);
    }
    n = needDeleteBin.size();
    for (hyu32 i = 0; i < n; i++) {
        delete needDeleteBin[i];
//.........这里部分代码省略.........
开发者ID:FUKUZAWA-Tadashi,项目名称:Hayat,代码行数:101,代码来源:hyCContext.cpp

示例12: createArray

    void createArray( const float *pOrig, size_t numItems, TArray<float> &arrayInstance ) {
		for ( size_t i=0; i<numItems; ++i ) {
			arrayInstance.add( pOrig[ i ] );
		}
	}
开发者ID:kimkulling,项目名称:cppcore,代码行数:5,代码来源:TArrayTest.cpp

示例13: onCreate

bool AppBase::onCreate( Properties::Settings *config ) {
    if ( m_state != State::Uninited ) {
        osre_debug( Tag, "AppBase::State not in proper state: Uninited." );
        return false;
    }

    // create the platform abstraction
    if( nullptr != config && config != m_settings ) {
        delete m_settings;
        m_settings = config;
    }

    // create the asset registry
    Assets::AssetRegistry *registry( Assets::AssetRegistry::create() );
    OSRE_ASSERT( nullptr!=registry );
    if ( nullptr==registry ) {
        osre_debug( Tag, "Cannot create asset registry." );
    }

    // create the platform interface instance
    m_platformInterface = Platform::PlatformInterface::create( m_settings );
	if (nullptr == m_platformInterface) {
		osre_error(Tag, "Pointer to platform interface is nullptr.");
		return false;
	}

    if( !m_platformInterface->open() ) {
		osre_error(Tag, "Error while opening platform interface.");
		return false;
    }

    // register any available platform-specific log streams
    Common::AbstractLogStream *stream = Platform::PlatformPluginFactory::createPlatformLogStream();
    if( nullptr != stream ) {
        Logger::getInstance()->registerLogStream( stream );
    }

    // create the render back-end
    m_rbService = new RenderBackend::RenderBackendService();
    m_rbService->setSettings(m_settings, false);
    if( !m_rbService->open() ) {
        m_rbService->release();
        m_rbService = nullptr;
        return false;
    }
    m_platformInterface->getPlatformEventHandler()->setRenderBackendService( m_rbService );
    
    // enable render-back-end
    if( m_platformInterface ) {
        RenderBackend::CreateRendererEventData *data = new RenderBackend::CreateRendererEventData( m_platformInterface->getRootWindow() );
        data->m_pipeline = createDefaultPipeline();
        m_rbService->sendEvent( &RenderBackend::OnCreateRendererEvent, data );
    }
    m_timer = Platform::PlatformInterface::getInstance()->getTimer();

    // create our world
    Scene::RenderMode mode = static_cast<Scene::RenderMode>( m_settings->get( Properties::Settings::RenderMode ).getInt() );
    m_world = new Scene::World( "world", mode );
    
    ServiceProvider::create( m_rbService );

    // Setup onMouse event-listener
    AbstractPlatformEventQueue *evHandler = m_platformInterface->getPlatformEventHandler();
    if ( nullptr != evHandler ) {
        TArray<const Common::Event*> eventArray;
        eventArray.add( &MouseButtonDownEvent );
        eventArray.add( &MouseButtonUpEvent );
        m_mouseEvListener = new MouseEventListener;
        evHandler->registerEventListener( eventArray, m_mouseEvListener );
    }

    IO::IOService::create();

    m_uiRenderer = new UI::UiRenderer;

    // set application state to "Created"
    osre_debug( Tag, "Set application state to Created." );
    m_state = State::Created;
    
    return true;
}
开发者ID:kimkulling,项目名称:osre,代码行数:81,代码来源:AppBase.cpp

示例14: addTermFunc

 // 終了時処理関数を登録する
 void    addTermFunc(RFunc_t func)
 {
     termFuncArr.add(func);
 }
开发者ID:FUKUZAWA-Tadashi,项目名称:Hayat,代码行数:5,代码来源:EngineControl.cpp

示例15: addDrawFunc

 // 1フレームに1回呼ばれる描画関数を登録する
 void    addDrawFunc(RFunc_t func)
 {
     drawFuncArr.add(func);
 }
开发者ID:FUKUZAWA-Tadashi,项目名称:Hayat,代码行数:5,代码来源:EngineControl.cpp


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