{
}
-DeltaVector::DeltaVector(DeltaEncoder& encoder, usint universe_size) :
+DeltaVector::DeltaVector(std::FILE * file) :
+ BitVector(file)
+{
+}
+
+
+DeltaVector::DeltaVector(Encoder& encoder, usint universe_size) :
BitVector(encoder, universe_size)
{
}
//--------------------------------------------------------------------------
usint
-DeltaVector::rank(usint value, bool at_least)
+DeltaVector::reportSize() const
+{
+ usint bytes = sizeof(*this);
+ bytes += BitVector::reportSize();
+ return bytes;
+}
+
+//--------------------------------------------------------------------------
+
+DeltaVector::Iterator::Iterator(const DeltaVector& par) :
+ BitVector::Iterator(par)
{
- if(value >= this->size) { return this->items; }
+}
+
+DeltaVector::Iterator::~Iterator()
+{
+}
+
+usint
+DeltaVector::Iterator::rank(usint value, bool at_least)
+{
+ const DeltaVector& par = (const DeltaVector&)(this->parent);
+
+ if(value >= par.size) { return par.items; }
this->getSample(this->sampleForValue(value));
while(this->cur < this->block_items && this->val < value)
{
- this->val += this->buffer->readDeltaCode();
+ this->val += this->buffer.readDeltaCode();
this->cur++;
}
}
usint
-DeltaVector::select(usint index)
+DeltaVector::Iterator::select(usint index)
{
- if(index >= this->items) { return this->size; }
+ const DeltaVector& par = (const DeltaVector&)(this->parent);
+
+ if(index >= par.items) { return par.size; }
this->getSample(this->sampleForIndex(index));
usint lim = index - this->sample.first;
for(; this->cur < lim; this->cur++)
{
- this->val += this->buffer->readDeltaCode();
+ this->val += this->buffer.readDeltaCode();
}
return this->val;
}
usint
-DeltaVector::selectNext()
+DeltaVector::Iterator::selectNext()
{
if(this->cur >= this->block_items)
{
}
this->cur++;
- this->val += this->buffer->readDeltaCode();
+ this->val += this->buffer.readDeltaCode();
return this->val;
}
pair_type
-DeltaVector::valueAfter(usint value)
+DeltaVector::Iterator::valueAfter(usint value)
{
- if(value >= this->size) { return pair_type(this->size, this->items); }
+ const DeltaVector& par = (const DeltaVector&)(this->parent);
+
+ if(value >= par.size) { return pair_type(par.size, par.items); }
this->getSample(this->sampleForValue(value));
while(this->cur < this->block_items && this->val < value)
{
- this->val += this->buffer->readDeltaCode();
+ this->val += this->buffer.readDeltaCode();
this->cur++;
}
if(this->val < value)
}
pair_type
-DeltaVector::nextValue()
+DeltaVector::Iterator::nextValue()
{
if(this->cur >= this->block_items)
{
}
this->cur++;
- this->val += this->buffer->readDeltaCode();
+ this->val += this->buffer.readDeltaCode();
return pair_type(this->val, this->sample.first + this->cur);
}
pair_type
-DeltaVector::selectRun(usint index, usint max_length)
+DeltaVector::Iterator::selectRun(usint index, usint max_length)
{
return pair_type(this->select(index), 0);
}
pair_type
-DeltaVector::selectNextRun(usint max_length)
+DeltaVector::Iterator::selectNextRun(usint max_length)
{
return pair_type(this->selectNext(), 0);
}
bool
-DeltaVector::isSet(usint value)
+DeltaVector::Iterator::isSet(usint value)
{
- if(value >= this->size) { return false; }
+ const DeltaVector& par = (const DeltaVector&)(this->parent);
+
+ if(value >= par.size) { return false; }
this->getSample(this->sampleForValue(value));
while(this->cur < this->block_items && this->val < value)
{
- this->val += this->buffer->readDeltaCode();
+ this->val += this->buffer.readDeltaCode();
this->cur++;
}
//--------------------------------------------------------------------------
-usint
-DeltaVector::reportSize()
-{
- usint bytes = sizeof(*this);
- bytes += BitVector::reportSize();
- return bytes;
-}
-
-//--------------------------------------------------------------------------
-
DeltaEncoder::DeltaEncoder(usint block_bytes, usint superblock_size) :
VectorEncoder(block_bytes, superblock_size)
{
this->addNewBlock();
}
+void
+DeltaEncoder::setRun(usint start, usint len)
+{
+ for(usint i = start; i < start + len; i++)
+ {
+ this->setBit(i);
+ }
+}
+
+void
+DeltaEncoder::addBit(usint value)
+{
+ this->setBit(value);
+}
+
+void
+DeltaEncoder::addRun(usint start, usint len)
+{
+ this->setRun(start, len);
+}
+
+void
+DeltaEncoder::flush()
+{
+}
} // namespace CSA