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


C++ MemoryBlock::Empty方法代码示例

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


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

示例1: Pop

/**
 * Remove bytes from the stack
 */
void IOStack::Pop(unsigned int bytes_to_remove) {
    unsigned int bytes_removed = 0;
    BlockVector::iterator iter = m_blocks.begin();
    while (iter != m_blocks.end() && bytes_removed != bytes_to_remove) {
        MemoryBlock *block = *iter;
        bytes_removed += block->PopFront(bytes_to_remove - bytes_removed);
        if (block->Empty()) {
            m_pool->Release(block);
            iter = m_blocks.erase(iter);
        } else {
            iter++;
        }
    }
}
开发者ID:dandaka,项目名称:ola,代码行数:17,代码来源:IOStack.cpp

示例2: Pop

/**
 * Remove the first n bytes from the buffer
 */
void IOQueue::Pop(unsigned int n) {
  unsigned int bytes_popped = 0;
  BlockVector::iterator iter = m_blocks.begin();
  while (iter != m_blocks.end() && bytes_popped != n) {
    MemoryBlock *block = *iter;
    bytes_popped += block->PopFront(n - bytes_popped);
    if (block->Empty()) {
      m_pool->Release(block);
      iter = m_blocks.erase(iter);
    } else {
      iter++;
    }
  }
}
开发者ID:Jazeido,项目名称:ola,代码行数:17,代码来源:IOQueue.cpp

示例3: Read

/**
 * Read up to n bytes into the string output.
 */
unsigned int IOStack::Read(string *output, unsigned int length) {
    unsigned int bytes_remaining = length;
    BlockVector::iterator iter = m_blocks.begin();
    while (iter != m_blocks.end() && bytes_remaining) {
        MemoryBlock *block = *iter;
        unsigned int bytes_to_copy = std::min(block->Size(), bytes_remaining);
        output->append(reinterpret_cast<char*>(block->Data()), bytes_to_copy);
        bytes_remaining -= bytes_to_copy;
        if (block->Empty()) {
            m_pool->Release(block);
            iter = m_blocks.erase(iter);
        } else {
            iter++;
        }
    }
    return length - bytes_remaining;
}
开发者ID:dandaka,项目名称:ola,代码行数:20,代码来源:IOStack.cpp

示例4: Read

/**
 * Read up to n bytes into the memory location data and shrink the IOQueue by
 * the amount read.
 */
unsigned int IOQueue::Read(uint8_t *data, unsigned int n) {
  unsigned int bytes_read = 0;
  BlockVector::iterator iter = m_blocks.begin();
  while (iter != m_blocks.end() && bytes_read != n) {
    MemoryBlock *block = *iter;
    unsigned int bytes_copied = block->Copy(data + bytes_read, n - bytes_read);
    block->PopFront(bytes_copied);
    bytes_read += bytes_copied;
    if (block->Empty()) {
      m_pool->Release(block);
      iter = m_blocks.erase(iter);
    } else {
      iter++;
    }
  }
  return bytes_read;
}
开发者ID:Jazeido,项目名称:ola,代码行数:21,代码来源:IOQueue.cpp


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