1Lucy::Object::BitVectorU(s3eprm)Contributed Perl DocumenLtuactyi:o:nObject::BitVector(3pm)
2
3
4

NAME

6       Lucy::Object::BitVector - An array of bits.
7

SYNOPSIS

9           my $bit_vec = Lucy::Object::BitVector->new( capacity => 8 );
10           my $other   = Lucy::Object::BitVector->new( capacity => 8 );
11           $bit_vec->set($_) for ( 0, 2, 4, 6 );
12           $other->set($_)   for ( 1, 3, 5, 7 );
13           $bit_vec->or($other);
14           print "$_\n" for @{ $bit_vec->to_array };    # prints 0 through 7.
15

DESCRIPTION

17       BitVector is a growable array of bits.  All bits are initially zero.
18

CONSTRUCTORS

20   new
21           my $bit_vec = Lucy::Object::BitVector->new(
22               capacity => $doc_max + 1,   # default 0,
23           );
24
25       Create a new BitVector.
26
27capacity - The number of bits that the initial array should be able
28           to hold.
29

METHODS

31   get
32           my $bool = $bit_vector->get($tick);
33
34       Return true if the bit at "tick" has been set, false if it hasn’t
35       (regardless of whether it lies within the bounds of the object’s
36       capacity).
37
38tick - The requested bit.
39
40   set
41           $bit_vector->set($tick);
42
43       Set the bit at "tick" to 1.
44
45tick - The bit to be set.
46
47   next_hit
48           my $int = $bit_vector->next_hit($tick);
49
50       Returns the next set bit equal to or greater than "tick", or -1 if no
51       such bit exists.
52
53   clear
54           $bit_vector->clear($tick);
55
56       Clear the indicated bit. (i.e. set it to 0).
57
58tick - The bit to be cleared.
59
60   clear_all
61           $bit_vector->clear_all();
62
63       Clear all bits.
64
65   grow
66           $bit_vector->grow($capacity);
67
68       If the BitVector does not already have enough room to hold the
69       indicated number of bits, allocate more memory so that it can.
70
71capacity - Least number of bits the BitVector should accomodate.
72
73   and
74           $bit_vector->and($other);
75
76       Modify the BitVector so that only bits which remain set are those which
77       1) were already set in this BitVector, and 2) were also set in the
78       other BitVector.
79
80other - Another BitVector.
81
82   or
83           $bit_vector->or($other);
84
85       Modify the BitVector, setting all bits which are set in the other
86       BitVector if they were not already set.
87
88other - Another BitVector.
89
90   xor
91           $bit_vector->xor($other);
92
93       Modify the BitVector, performing an XOR operation against the other.
94
95other - Another BitVector.
96
97   and_not
98           $bit_vector->and_not($other);
99
100       Modify the BitVector, clearing all bits which are set in the other.
101
102other - Another BitVector.
103
104   flip
105           $bit_vector->flip($tick);
106
107       Invert the value of a bit.
108
109tick - The bit to invert.
110
111   flip_block
112           $bit_vector->flip_block(
113               offset => $offset,  # required
114               length => $length,  # required
115           );
116
117       Invert each bit within a contiguous block.
118
119offset - Lower bound.
120
121length - The number of bits to flip.
122
123   count
124           my $int = $bit_vector->count();
125
126       Return a count of the number of set bits.
127
128   to_array
129           my $i32_array = $bit_vector->to_array();
130
131       Return an array where each element represents a set bit.
132
133   clone
134           my $result = $bit_vector->clone();
135
136       Return a clone of the object.
137

INHERITANCE

139       Lucy::Object::BitVector isa Clownfish::Obj.
140
141
142
143perl v5.38.0                      2023-07-20      Lucy::Object::BitVector(3pm)
Impressum