Lucy::Object::BitVector - An array of bits.
my $bit_vec = Lucy::Object::BitVector->new( capacity => 8 ); my $other = Lucy::Object::BitVector->new( capacity => 8 ); $bit_vec->set($_) for ( 0, 2, 4, 6 ); $other->set($_) for ( 1, 3, 5, 7 ); $bit_vec->or($other); print "$_\n" for @{ $bit_vec->to_array }; # prints 0 through 7.
BitVector is a growable array of bits. All bits are initially zero.
my $bit_vec = Lucy::Object::BitVector->new( capacity => $doc_max + 1, # default 0, );
Create a new BitVector.
my $bool = $bit_vector->get($tick);
Return true if the bit at tick
has been set,
false if it hasn’t (regardless of whether it lies within the bounds of the object’s capacity).
$bit_vector->set($tick);
Set the bit at tick
to 1.
my $int = $bit_vector->next_hit($tick);
Returns the next set bit equal to or greater than tick
,
or -1 if no such bit exists.
$bit_vector->clear($tick);
Clear the indicated bit. (i.e. set it to 0).
$bit_vector->clear_all();
Clear all bits.
$bit_vector->grow($capacity);
If the BitVector does not already have enough room to hold the indicated number of bits, allocate more memory so that it can.
$bit_vector->and($other);
Modify the BitVector so that only bits which remain set are those which 1) were already set in this BitVector, and 2) were also set in the other BitVector.
$bit_vector->or($other);
Modify the BitVector, setting all bits which are set in the other BitVector if they were not already set.
$bit_vector->xor($other);
Modify the BitVector, performing an XOR operation against the other.
$bit_vector->and_not($other);
Modify the BitVector, clearing all bits which are set in the other.
$bit_vector->flip($tick);
Invert the value of a bit.
$bit_vector->flip_block( offset => $offset # required length => $length # required );
Invert each bit within a contiguous block.
my $int = $bit_vector->count();
Return a count of the number of set bits.
my $i32_array = $bit_vector->to_array();
Return an array where each element represents a set bit.
my $result = $bit_vector->clone();
Return a clone of the object.
Lucy::Object::BitVector isa Clownfish::Obj.
Copyright © 2010-2015 The Apache Software Foundation, Licensed under the
Apache License, Version 2.0.
Apache Lucy, Lucy, Apache, the Apache feather logo, and the Apache Lucy project logo are trademarks of The
Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their
respective owners.