ssize_t VectorImpl::removeItemsAt(size_t index, size_t count)
{
    ALOG_ASSERT((index+count)<=size(),
        "[%p] remove: index=%d, count=%d, size=%d",
               this, (int)index, (int)count, (int)size());

    if ((index+count) > size())
        return BAD_VALUE;
   _shrink(index, count);
   return index;
}
//Removes user specified int from set if it is an element.
void Set::remove(const int rem){
  for(int i=0;i<_cardinality;i++){
    if(_element[i]==rem){
      _element[i]=_element[_cardinality-1];
      _cardinality--;
      if(_array_size-_cardinality==_chunk_size){
	_shrink();	
      }
      break;
    }
  }
}
示例#3
0
void Vocabulary::parse(istream& is, uint64_t min_cnt) {
    string word;
    while (is >> word) {
        unordered_map<string, uint64_t>::const_iterator iter = _word2id.find(word);
        if (iter == _word2id.end()) {
            _vocab.push_back(Word(word, 1));
            _word2id[word] = _vocab.size() - 1;
        }
        else {
            ++_vocab[iter->second].cnt;
        }
    }
    _shrink(min_cnt);
}
void VectorImpl::clear()
{
    _shrink(0, mCount);
}
//Clears a set.
void Set::clear(){
  _cardinality = 0;
  while(_array_size>_chunk_size){
    _shrink();
    }
}