Lucy::...tVector(3pm)

๐Ÿ“ฆ
version 0.6.2 ยท 2 versions
, in fedora 43

โœจ 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 the BitVector should 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 โ€” Another BitVector.

๐Ÿ’œ 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 โ€” Another BitVector.

๐Ÿ’œ xor

$bit_vector->xor($other);

Modify the BitVector, performing an XOR operation against the other.

  • other โ€” Another BitVector.

๐Ÿ’œ 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 โ€” Another BitVector.

๐Ÿ’œ 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, both offset and length are 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