You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The default `BitSet` constructor accepts a single value of one the following types :
94
94
@@ -106,117 +106,117 @@ The default `BitSet` constructor accepts a single value of one the following typ
106
106
- A BitSet object, which get copied over
107
107
108
108
109
-
##Functions
109
+
##Functions
110
110
111
111
112
112
The data type Mixed can be either a BitSet object, a String or an integer representing a native bitset with 31 bits.
113
113
114
114
115
-
###BitSet set(ndx[, value=1])
115
+
###BitSet set(ndx[, value=1])
116
116
117
117
Mutable; Sets value 0 or 1 to index `ndx` of the bitset
118
118
119
119
int get(ndx)
120
120
---
121
121
Gets the value at index ndx
122
122
123
-
###BitSet setRange(from, to[, value=1])
123
+
###BitSet setRange(from, to[, value=1])
124
124
125
125
Mutable; Helper function for set, to set an entire range to a given value
126
126
127
-
###BitSet clear([from[, to]])
127
+
###BitSet clear([from[, to]])
128
128
129
129
Mutable; Sets a portion of a given bitset to zero
130
130
131
131
- If no param is given, the whole bitset gets cleared
132
132
- If one param is given, the bit at this index gets cleared
133
133
- If two params are given, the range is cleared
134
134
135
-
###BitSet slice([from[, to]])
135
+
###BitSet slice([from[, to]])
136
136
137
137
Immutable; Extracts a portion of a given bitset as a new bitset
138
138
139
139
- If no param is given, the bitset is getting cloned
140
140
- If one param is given, the index is used as offset
141
141
- If two params are given, the range is returned as new BitSet
142
142
143
-
###BitSet flip([from[, to]])
143
+
###BitSet flip([from[, to]])
144
144
145
145
Mutable; Toggles a portion of a given bitset
146
146
147
147
- If no param is given, the bitset is inverted
148
148
- If one param is given, the bit at the index is toggled
149
149
- If two params are given, the bits in the given range are toggled
150
150
151
-
###BitSet not()
151
+
###BitSet not()
152
152
153
153
Immutable; Calculates the bitwise complement
154
154
155
-
###BitSet and(Mixed x)
155
+
###BitSet and(Mixed x)
156
156
157
157
Immutable; Calculates the bitwise intersection of two bitsets
158
158
159
-
###BitSet or(Mixed x)
159
+
###BitSet or(Mixed x)
160
160
161
161
Immutable; Calculates the bitwise union of two bitsets
162
162
163
-
###BitSet xor(Mixed x)
163
+
###BitSet xor(Mixed x)
164
164
165
165
Immutable; Calculates the bitwise xor between two bitsets
166
166
167
-
###BitSet andNot(Mixed x)
167
+
###BitSet andNot(Mixed x)
168
168
169
169
Immutable; Calculates the bitwise difference of two bitsets (this is not the nand operation!)
170
170
171
-
###BitSet clone()
171
+
###BitSet clone()
172
172
173
173
Immutable; Clones the actual object
174
174
175
-
###Array toArray()
175
+
###Array toArray()
176
176
177
177
Returns an array with all indexes set in the bitset
178
178
179
-
###String toString([base=2])
179
+
###String toString([base=2])
180
180
181
181
Returns a string representation with respect to the base
182
182
183
-
###int cardinality()
183
+
###int cardinality()
184
184
185
185
Calculates the number of bits set
186
186
187
-
###int msb()
187
+
###int msb()
188
188
189
189
Calculates the most significant bit (the left most)
190
190
191
-
###int ntz()
191
+
###int ntz()
192
192
193
193
Calculates the number of trailing zeros (zeros on the right). If all digits are zero, `Infinity` is returned, since BitSet.js is an arbitrary large bit vector implementation.
194
194
195
-
###int lsb()
195
+
###int lsb()
196
196
197
197
Calculates the least significant bit (the right most)
198
198
199
-
###bool isEmpty()
199
+
###bool isEmpty()
200
200
201
201
Checks if the bitset has all bits set to zero
202
202
203
-
###bool equals()
203
+
###bool equals()
204
204
205
205
Checks if two bitsets are the same
206
206
207
-
###BitSet.fromBinaryString(str)
207
+
###BitSet.fromBinaryString(str)
208
208
209
209
Alternative constructor to pass with a binary string
210
210
211
-
###BitSet.fromHexString(str)
211
+
###BitSet.fromHexString(str)
212
212
213
213
Alternative constructor to pass a hex string
214
214
215
-
###BitSet.Random([n=32])
215
+
###BitSet.Random([n=32])
216
216
217
217
Create a random BitSet with a maximum length of n bits
218
218
219
-
##Iterator Interface
219
+
##Iterator Interface
220
220
221
221
A `BitSet` object is iterable. The iterator gets all bits up to the most significant bit. If no bits are set, the iteration stops immediately.
222
222
@@ -230,11 +230,11 @@ for (let b of bs) {
230
230
Note: If the bitset is inverted so that all leading bits are 1, the iterator must be stopped by the user!
231
231
232
232
233
-
##Coding Style
233
+
##Coding Style
234
234
235
235
As every library I publish, BitSet.js is also built to be as small as possible after compressing it with Google Closure Compiler in advanced mode. Thus the coding style orientates a little on maxing-out the compression rate. Please make sure you keep this style if you plan to extend the library.
236
236
237
-
##Building the library
237
+
##Building the library
238
238
239
239
After cloning the Git repository run:
240
240
@@ -243,7 +243,7 @@ npm install
243
243
npm run build
244
244
```
245
245
246
-
##Run a test
246
+
##Run a test
247
247
248
248
Testing the source against the shipped test suite is as easy as
0 commit comments