Lucy::...tVector(3pm)
โจ Lucy::Object::BitVector โจ
okay bestie, welcome to the Lucy::...tVector(3pm) page ๐
yes the manual name is abbreviated like that, it's giving mysterious, we move. this is Lucy::Object::BitVector and she is exactly what she sounds like: an array of bits. let's get into it ๐
๐ SYNOPSIS ๐
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.
like. she's an icon, she's a legend, she ORs two bit vectors together and suddenly every bit is set. the way that works is so satisfying ๐ซถ
๐ธ DESCRIPTION ๐ธ
BitVector is a growable array of bits. and when we say growable, we mean it โ she can expand. every single bit starts out as zero, no cap. all zeros, all the time, until you say otherwise ๐
๐ CONSTRUCTORS ๐
๐ฆ new
my $bit_vec = Lucy::Object::BitVector->new(
capacity => $doc_max + 1, # default 0,
);
Create a new BitVector. brand new, fresh out the box, all bits zeroed out and ready to serve โจ
capacityโ The number of bits that the initial array should be able to hold.
๐ METHODS ๐
๐ get
my $bool = $bit_vector->get($tick);
Return true if the bit at tick has been set, false if it hasn't โ and this is the important part, bestie โ regardless of whether it lies within the bounds of the object's capacity. so like, out of bounds? still answers. no vibes check, no error, just truth ๐
tickโ The requested bit.
๐ set
$bit_vector->set($tick);
Set the bit at tick to 1. that's it. that's the whole thing. she's set, she's on, periodt ๐ฅ
tickโ The bit to be set.
๐ next_hit
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. like a little scout going "okay who's still awake past this point" ๐ and if literally nobody is, she hands you -1.
๐ clear
$bit_vector->clear($tick);
Clear the indicated bit. (i.e. set it to 0). respectfully turning it off ๐
tickโ The bit to be cleared.
๐ clear_all
$bit_vector->clear_all();
Clear all bits. every single one. mass reset. the whole vibe wiped clean ๐งนโจ
๐ grow
$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. she's expanding her horizons, we love growth ๐ฑ
capacityโ Least number of bits theBitVectorshould accomodate.
๐ and
$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. both conditions, no exceptions, it's giving strict ๐ฏ
otherโ AnotherBitVector.
๐ or
$bit_vector->or($other);
Modify the BitVector, setting all bits which are set in the other BitVector if they were not already set. generous queen, sharing her set bits ๐ซถ
otherโ AnotherBitVector.
๐ xor
$bit_vector->xor($other);
Modify the BitVector, performing an XOR operation against the other.
otherโ AnotherBitVector.
๐ and_not
$bit_vector->and_not($other);
Modify the BitVector, clearing all bits which are set in the other. okay so it's giving subtraction energy. whatever $other has going on, this one wants no part of it ๐
otherโ AnotherBitVector.
๐ flip
$bit_vector->flip($tick);
Invert the value of a bit. 1 becomes 0, 0 becomes 1, main character transformation arc ๐โจ
tickโ The bit to invert.
๐ flip_block
$bit_vector->flip_block(
offset => $offset, # required
length => $length, # required
);
Invert each bit within a contiguous block. not one bit, a whole block of them. glow-up for the entire friend group ๐
offsetโ Lower bound.lengthโ The number of bits to flip.
heads up bestie, bothoffsetandlengthare marked required in the synopsis. don't skip them ๐
๐ count
my $int = $bit_vector->count();
Return a count of the number of set bits. she's doing inventory, tallying up every bit that made it ๐งฎ๐
๐ to_array
my $i32_array = $bit_vector->to_array();
Return an array where each element represents a set bit. so like, the receipts, but as an array ๐
๐ clone
my $result = $bit_vector->clone();
Return a clone of the object. twin. identical. no notes ๐ฏโโ๏ธ
๐ INHERITANCE ๐
Lucy::Object::BitVector isa Clownfish::Obj. yeah she comes from a whole lineage, iykyk ๐งฌ๐
and that's the whole page, bestie ๐ this was Lucy::...tVector(3pm), from the User Contributed Perl Documentation, running on perl v5.42.0, dated 2025-07-25. slay, stay bitwise, and don't forget to clear_all on your way out ๐
โจ๐
๐ฆ where this page comes from
- fedora 43: perl-Lucy 0.6.2-26.fc43 ยท Apache-2.0 AND MIT AND Unicode-DFS-2015
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms