예제 #1
0
    /**
     * @brief Loads the next chunk.
     *
     * If the current chunk was the last chunk in the array a new chunk is created.
     * Otherwise the old chunk is reset and loaded as current chunk.
     *
     * Always the position of the nested chunk vector is stored.
     */
    CODI_NO_INLINE void nextChunk() {
      curChunk->store();

      curChunkIndex += 1;
      if(chunks.size() == curChunkIndex) {
        curChunk = new ChunkData(chunkSize);
        chunks.push_back(curChunk);
        positions.push_back(nested->getPosition());
      } else {
        curChunk = chunks[curChunkIndex];
        curChunk->reset();
        positions[curChunkIndex] = nested->getPosition();
      }
    }
예제 #2
0
    /**
     * @brief Ensures that enough chunks are allocated so that totalSize data items can be stored.
     * @param totalSize   The number of data items which should be available.
     */
    void resize(const size_t& totalSize) {
      size_t noOfChunks = totalSize / chunkSize;
      if(0 != totalSize % chunkSize) {
        noOfChunks += 1;
      }

      for(size_t i = chunks.size(); i < noOfChunks; ++i) {
        chunks.push_back(new ChunkData(chunkSize));
        positions.push_back(nested->getPosition());
      }
    }
예제 #3
0
 /**
  * @brief Creates one chunk and loads it.
  * @param chunkSize   The size for the chunks.
  * @param    nested   The nested chunk vector.
  */
 ChunkVector(const size_t& chunkSize, NestedVector& nested) :
   chunks(),
   positions(),
   curChunk(NULL),
   curChunkIndex(0),
   chunkSize(chunkSize),
   nested(nested)
 {
   curChunk = new ChunkData(chunkSize);
   chunks.push_back(curChunk);
   positions.push_back(nested.getPosition());
 }
예제 #4
0
 /**
  * @brief Get the position of the chunk vector and the nested vectors.
  * @return The position of the chunk vector.
  */
 CODI_INLINE Position getPosition() const {
   return Position(curChunkIndex, curChunk->getUsedSize(), nested->getPosition());
 }