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


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

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


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

示例1: readPackAndWrite

void readPackAndWrite(
    uint64_t& writeSize, packet::Packet& pkt,
    cybozu::util::File& fileW, bool doWriteDiff, DiscardType discardType,
    uint64_t fsyncIntervalSize,
    std::vector<char>& zero, AlignedArray& buf)
{
    const char *const FUNC = __func__;
    size_t size;
    pkt.read(size);
    verifyDiffPackSize(size, FUNC);
    buf.resize(size);
    pkt.read(buf.data(), buf.size());

    verifyDiffPack(buf.data(), buf.size(), true);
    if (doWriteDiff) {
        fileW.write(buf.data(), buf.size());
    } else {
        MemoryDiffPack pack(buf.data(), buf.size());
        issueDiffPack(fileW, discardType, pack, zero);
    }
    writeSize += buf.size();
    if (writeSize >= fsyncIntervalSize) {
        fileW.fdatasync();
        writeSize = 0;
    }
}
开发者ID:walb-linux,项目名称:walb-tools,代码行数:26,代码来源:dirty_hash_sync.hpp

示例2: setRandomData

void setRandomData(AlignedArray& buf, Rand& rand)
{
    size_t off = 0;
    while (off < buf.size()) {
        const size_t size = std::min<size_t>(buf.size() - off, 16);
        rand.fill(buf.data() + off, size);
        off += 512;
    }
}
开发者ID:walb-linux,项目名称:walb-tools,代码行数:9,代码来源:fs-workload.cpp

示例3: swap

    // ------------------------------------------------------------------------
    void swap(int ID1, int ID2)
    {
        assert(ID1 > -1);
        assert((unsigned int)ID1 < m_contents_vector.size());
        assert(ID2 > -1);
        assert((unsigned int)ID2 < m_contents_vector.size());


        TYPE* temp = m_contents_vector[ID2];

        m_contents_vector[ID2] = m_contents_vector[ID1];
        m_contents_vector[ID1] = temp;
    }   // swap
开发者ID:krishnabm,项目名称:stk-code,代码行数:14,代码来源:ptr_vector.hpp

示例4: readAndSendHash

void readAndSendHash(
    uint64_t& hashLb,
    packet::Packet& pkt, packet::StreamControl2& ctrl, Reader &reader,
    uint64_t sizeLb, size_t bulkLb,
    cybozu::murmurhash3::Hasher& hasher, AlignedArray& buf)
{
    const uint64_t lb = std::min<uint64_t>(sizeLb - hashLb, bulkLb);
    buf.resize(lb * LOGICAL_BLOCK_SIZE);
    reader.read(buf.data(), buf.size());
    const cybozu::murmurhash3::Hash hash = hasher(buf.data(), buf.size());
    doRetrySockIo(2, "ctrl.send.next", [&]() { ctrl.sendNext(); });
    pkt.write(hash);
    hashLb += lb;
}
开发者ID:walb-linux,项目名称:walb-tools,代码行数:14,代码来源:dirty_hash_sync.hpp

示例5: get

    // ------------------------------------------------------------------------
    const TYPE* get(const int ID) const
    {
        assert(ID > -1);
        assert((unsigned int)ID < (unsigned int)m_contents_vector.size());

        return m_contents_vector[ID];
    }   // get
开发者ID:krishnabm,项目名称:stk-code,代码行数:8,代码来源:ptr_vector.hpp

示例6: erase

    // ------------------------------------------------------------------------
    void erase(const int ID)
    {
        assert(ID > -1);
        assert((unsigned int)ID < (unsigned int)m_contents_vector.size());

        delete ( TYPE *) m_contents_vector[ID];
#ifdef USE_ALIGNED
        const unsigned int amount = (unsigned int)m_contents_vector.size();
        for(unsigned int i=ID; i<amount-1; i++)
        {
            m_contents_vector[i]=m_contents_vector[i+1];
        }
        m_contents_vector.pop_back();
#else
        m_contents_vector.erase(m_contents_vector.begin()+ID);
#endif
    }   // erase
开发者ID:krishnabm,项目名称:stk-code,代码行数:18,代码来源:ptr_vector.hpp

示例7: getStartTransform

 /** Returns the start coordinates for a kart with a given index.
  *  \param index Index of kart ranging from 0 to kart_num-1. */
 btTransform        getStartTransform (unsigned int index) const
 {
     if (index >= m_start_transforms.size())
     {
         fprintf(stderr, "No start position for kart %i\n", index);
         abort();
     }
     return m_start_transforms[index];
 }
开发者ID:PalashBansal,项目名称:stk-code,代码行数:11,代码来源:track.hpp

示例8: contains

    // ------------------------------------------------------------------------
    bool contains( const TYPE* instance ) const
    {
        const unsigned int amount = (unsigned int)m_contents_vector.size();
        for (unsigned int n=0; n<amount; n++)
        {
            const TYPE * pointer = m_contents_vector[n];
            if (pointer == instance) return true;
        }

        return false;
    }   // contains
开发者ID:krishnabm,项目名称:stk-code,代码行数:12,代码来源:ptr_vector.hpp

示例9: insertionSort

 // ------------------------------------------------------------------------
 void insertionSort(unsigned int start=0, bool desc = false)
 {
     if (!desc)
     {
         // We should not used unsigned ints here, because if the vector is
         // empty j needs to be compared against -1
         for(int j=(int)start; j<(int)m_contents_vector.size()-1; j++)
         {
             if(*(m_contents_vector[j])<*(m_contents_vector[j+1])) continue;
             // Now search the proper place for m_contents_vector[j+1]
             // in the sorted section contentsVectot[start:j]
             TYPE* t=m_contents_vector[j+1];
             unsigned int i = j+1;
             do
             {
                 m_contents_vector[i] = m_contents_vector[i-1];
                 i--;
             } while (i>start && *t<*(m_contents_vector[i-1]));
             m_contents_vector[i]=t;
         }
     }
     else
     {
         for(int j=(int)start; j<(int)m_contents_vector.size()-1; j++)
          {
              if(*(m_contents_vector[j+1])<*(m_contents_vector[j])) continue;
              // Now search the proper place for m_contents_vector[j+1]
              // in the sorted section contentsVectot[start:j]
              TYPE* t=m_contents_vector[j+1];
              unsigned int i = j+1;
              do
              {
                  m_contents_vector[i] = m_contents_vector[i-1];
                  i--;
              } while (i>start && *(m_contents_vector[i-1]) <*t);
              m_contents_vector[i]=t;
          }
      }
 }   // insertionSort
开发者ID:krishnabm,项目名称:stk-code,代码行数:40,代码来源:ptr_vector.hpp

示例10: clearAndDeleteAll

    // ------------------------------------------------------------------------
    void clearAndDeleteAll()
    {
        for (unsigned int n=0; n<(unsigned int)m_contents_vector.size(); n++)
        {
            TYPE * pointer = m_contents_vector[n];
            delete pointer;
            m_contents_vector[n] = (TYPE*)0xDEADBEEF;

            // When deleting, it's important that the same pointer cannot be
            // twice in the vector, resulting in a double delete
            assert( !contains(pointer) );
        }
        m_contents_vector.clear();
    }  // clearAndDeleteAll
开发者ID:krishnabm,项目名称:stk-code,代码行数:15,代码来源:ptr_vector.hpp

示例11: internalSet

void GFXGLShaderConstBuffer::internalSet(GFXShaderConstHandle* handle, const AlignedArray<ConstType>& fv)
{
   AssertFatal(handle, "GFXGLShaderConstBuffer::internalSet - Handle is NULL!" );
   AssertFatal(handle->isValid(), "GFXGLShaderConstBuffer::internalSet - Handle is not valid!" );
   AssertFatal(dynamic_cast<GFXGLShaderConstHandle*>(handle), "GFXGLShaderConstBuffer::set - Incorrect const buffer type");

   GFXGLShaderConstHandle* _glHandle = static_cast<GFXGLShaderConstHandle*>(handle);
   AssertFatal(mShader == _glHandle->mShader, "GFXGLShaderConstBuffer::set - Should only set handles which are owned by our shader");
   const U8* fvBuffer = static_cast<const U8*>(fv.getBuffer());
   for(U32 i = 0; i < fv.size(); ++i)
   {
      dMemcpy(mBuffer + _glHandle->mOffset + i * sizeof(ConstType), fvBuffer, sizeof(ConstType));
      fvBuffer += fv.getElementSize();
   }
}
开发者ID:Adhdcrazzy,项目名称:Torque3D,代码行数:15,代码来源:gfxGLShader.cpp

示例12: remove

    /**
    * Removes without deleting
    */
    void remove(TYPE* obj)
    {
        for(unsigned int n=0; n<(unsigned int)m_contents_vector.size(); n++)
        {

            TYPE * pointer = m_contents_vector[n];
            if(pointer == obj)
            {
#ifdef USE_ALIGNED
                const unsigned int amount =
                    (unsigned int)m_contents_vector.size();
                for(unsigned int i=n; i<amount-1; i++)
                {
                    m_contents_vector[i]=m_contents_vector[i+1];
                }
                m_contents_vector.pop_back();
#else
                m_contents_vector.erase(m_contents_vector.begin()+n);
#endif
                return;
            }
        }   // for n < size()

    }   // remove
开发者ID:krishnabm,项目名称:stk-code,代码行数:27,代码来源:ptr_vector.hpp

示例13: readAndValidateLogPackIo

uint64_t readAndValidateLogPackIo(cybozu::util::File& file, const device::SuperBlock& super, const LogPackHeader& logh)
{
    const uint32_t pbs = super.getPhysicalBlockSize();
    assert(logh.isValid());
    AlignedArray buf;
    for (size_t i = 0; i < logh.nRecords(); i++) {
        const WlogRecord &rec = logh.record(i);
        if (!rec.hasDataForChecksum()) continue;
        const uint64_t pb = super.getOffsetFromLsid(rec.lsid);
        const size_t ioSize = rec.ioSizeLb() * LBS;
        buf.resize(ioSize);
        file.pread(buf.data(), ioSize, pb * pbs);
        const uint32_t csum = cybozu::util::calcChecksum(buf.data(), buf.size(), logh.salt());
        if (csum == rec.checksum) continue;
        LOGs.info() << "INVALID_LOGPACK_IO" << rec << csum;
    }
    return logh.nextLogpackLsid();
}
开发者ID:walb-linux,项目名称:walb-tools,代码行数:18,代码来源:search-invalid-logpack.cpp

示例14: setupRTTScene

void ModelViewWidget::setupRTTScene(PtrVector<scene::IMesh, REF>& mesh,
                                    AlignedArray<Vec3>& mesh_location,
                                    AlignedArray<Vec3>& mesh_scale,
                                    const std::vector<int>& model_frames)
{
    irr_driver->suppressSkyBox();
    
    if (m_rtt_main_node != NULL) m_rtt_main_node->remove();
    if (m_light != NULL) m_light->remove();
    if (m_camera != NULL) m_camera->remove();
    
    m_rtt_main_node = NULL;
    m_camera = NULL;
    m_light = NULL;
    
    irr_driver->clearLights();
    
    if (model_frames[0] == -1)
    {
        scene::ISceneNode* node = irr_driver->addMesh(mesh.get(0), "rtt_mesh", NULL);
        node->setPosition(mesh_location[0].toIrrVector());
        node->setScale(mesh_scale[0].toIrrVector());
        node->setMaterialFlag(video::EMF_FOG_ENABLE, false);
        m_rtt_main_node = node;
    }
    else
    {
        scene::IAnimatedMeshSceneNode* node =
        irr_driver->addAnimatedMesh((scene::IAnimatedMesh*)mesh.get(0), "rtt_mesh", NULL);
        node->setPosition(mesh_location[0].toIrrVector());
        node->setFrameLoop(model_frames[0], model_frames[0]);
        node->setAnimationSpeed(0);
        node->setScale(mesh_scale[0].toIrrVector());
        node->setMaterialFlag(video::EMF_FOG_ENABLE, false);
        
        m_rtt_main_node = node;
    }
    
    assert(m_rtt_main_node != NULL);
    assert(mesh.size() == mesh_location.size());
    assert(mesh.size() == model_frames.size());
    
    const int mesh_amount = mesh.size();
    for (int n = 1; n<mesh_amount; n++)
    {
        if (model_frames[n] == -1)
        {
            scene::ISceneNode* node =
            irr_driver->addMesh(mesh.get(n), "rtt_node", m_rtt_main_node);
            node->setPosition(mesh_location[n].toIrrVector());
            node->updateAbsolutePosition();
            node->setScale(mesh_scale[n].toIrrVector());
        }
        else
        {
            scene::IAnimatedMeshSceneNode* node =
            irr_driver->addAnimatedMesh((scene::IAnimatedMesh*)mesh.get(n),
                                        "modelviewrtt", m_rtt_main_node);
            node->setPosition(mesh_location[n].toIrrVector());
            node->setFrameLoop(model_frames[n], model_frames[n]);
            node->setAnimationSpeed(0);
            node->updateAbsolutePosition();
            node->setScale(mesh_scale[n].toIrrVector());
            //Log::info("ModelViewWidget", "Set frame %d", model_frames[n]);
        }
    }
    
    irr_driver->getSceneManager()->setAmbientLight(video::SColor(255, 35, 35, 35));
    
    const core::vector3df &spot_pos = core::vector3df(0, 30, 40);
    m_light = irr_driver->addLight(spot_pos, 0.3f /* energy */, 10 /* distance */, 1.0f /* r */, 1.0f /* g */, 1.0f /* g*/, true, NULL);
    
    m_rtt_main_node->setMaterialFlag(video::EMF_GOURAUD_SHADING, true);
    m_rtt_main_node->setMaterialFlag(video::EMF_LIGHTING, true);
    
    const int materials = m_rtt_main_node->getMaterialCount();
    for (int n = 0; n<materials; n++)
    {
        m_rtt_main_node->getMaterial(n).setFlag(video::EMF_LIGHTING, true);
        
        // set size of specular highlights
        m_rtt_main_node->getMaterial(n).Shininess = 100.0f;
        m_rtt_main_node->getMaterial(n).SpecularColor.set(255, 50, 50, 50);
        m_rtt_main_node->getMaterial(n).DiffuseColor.set(255, 150, 150, 150);
        
        m_rtt_main_node->getMaterial(n).setFlag(video::EMF_GOURAUD_SHADING,
                                                true);
    }
    
    m_camera = irr_driver->getSceneManager()->addCameraSceneNode();
    m_camera->setAspectRatio(1.0f);
    
    m_camera->setPosition(core::vector3df(0.0, 20.0f, 70.0f));
    m_camera->setUpVector(core::vector3df(0.0, 1.0, 0.0));
    m_camera->setTarget(core::vector3df(0, 10, 0.0f));
    m_camera->setFOV(DEGREE_TO_RAD*50.0f);
    m_camera->updateAbsolutePosition();
}
开发者ID:Charence,项目名称:stk-code,代码行数:98,代码来源:model_view_widget.cpp

示例15: assert

    // ------------------------------------------------------------------------
    const TYPE& operator[](const unsigned int ID) const
    {
        assert((unsigned int)ID < (unsigned int)m_contents_vector.size());

        return *(m_contents_vector[ID]);
    }   // operator[]
开发者ID:krishnabm,项目名称:stk-code,代码行数:7,代码来源:ptr_vector.hpp


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