author | Claus Gittinger <cg@exept.de> |
Thu, 09 Jun 2016 12:36:55 +0200 | |
changeset 3898 | c90424dba938 |
parent 3881 | 16890fe7ef2e |
child 4033 | 369352e8b5a2 |
permissions | -rw-r--r-- |
565 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
||
12 |
This is a demo example: |
|
13 |
||
14 |
THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTOR ``AS IS'' AND |
|
15 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
16 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
17 |
ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTOR BE LIABLE |
|
18 |
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
19 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
20 |
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
21 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
22 |
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
23 |
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
24 |
SUCH DAMAGE. |
|
25 |
" |
|
893
823d2fa809e2
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
736
diff
changeset
|
26 |
"{ Package: 'stx:libbasic2' }" |
823d2fa809e2
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
736
diff
changeset
|
27 |
|
3534 | 28 |
"{ NameSpace: Smalltalk }" |
29 |
||
2094 | 30 |
ArrayedCollection variableByteSubclass:#BitArray |
31 |
instanceVariableNames:'tally' |
|
565 | 32 |
classVariableNames:'' |
33 |
poolDictionaries:'' |
|
34 |
category:'Collections-Arrayed' |
|
35 |
! |
|
36 |
||
37 |
!BitArray class methodsFor:'documentation'! |
|
38 |
||
39 |
copyright |
|
40 |
" |
|
41 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
42 |
All Rights Reserved |
|
43 |
||
44 |
This software is furnished under a license and may be used |
|
45 |
only in accordance with the terms of that license and with the |
|
46 |
inclusion of the above copyright notice. This software may not |
|
47 |
be provided or otherwise made available to, or used by, any |
|
48 |
other person. No title to or ownership of the software is |
|
49 |
hereby transferred. |
|
50 |
||
51 |
This is a demo example: |
|
52 |
||
53 |
THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTOR ``AS IS'' AND |
|
54 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
55 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
56 |
ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTOR BE LIABLE |
|
57 |
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
58 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
59 |
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
60 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
61 |
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
62 |
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
63 |
SUCH DAMAGE. |
|
64 |
" |
|
65 |
||
66 |
! |
|
67 |
||
68 |
documentation |
|
69 |
" |
|
3279 | 70 |
useful for bulk bit/boolean data |
3881 | 71 |
Requires only 1/32th (32bit machines) or 1/64th (64bit machines) of the memory |
72 |
compared to an array of booleans. |
|
2094 | 73 |
|
74 |
This one stores 8 bits per byte. Since instances store bits in multiples |
|
75 |
of 8, we have to keep the real size of the collection in an extra instance |
|
76 |
variable (tally). |
|
77 |
It may be useful if huge boolean arrays are to be used. |
|
78 |
||
3279 | 79 |
There are 10 types of people in this world: |
80 |
Those who understand binary, & those who don't. |
|
81 |
||
2107 | 82 |
ATTENTION: |
2094 | 83 |
Bits 1 to 8 of the BooleanArray are stored in bits 8 to 1 of the |
84 |
corresponding byte, to allow easy mapping to ASN.1 BIT STRING encoding |
|
2107 | 85 |
in the BER. (i.e. MSB-first) |
565 | 86 |
|
736 | 87 |
[memory requirements:] |
88 |
OBJ-HEADER + ((size + 7) // 8) |
|
89 |
||
565 | 90 |
[author:] |
91 |
Claus Gittinger |
|
92 |
||
93 |
[see also:] |
|
94 |
BooleanArray ByteArray WordArray Array |
|
95 |
" |
|
96 |
! |
|
97 |
||
98 |
examples |
|
99 |
" |
|
100 |
[exBegin] |
|
101 |
(BitArray new:7) inspect |
|
102 |
[exEnd] |
|
103 |
[exBegin] |
|
104 |
(BitArray new:7) basicInspect |
|
105 |
[exEnd] |
|
106 |
[exBegin] |
|
107 |
|bits| |
|
108 |
||
109 |
bits := BitArray new:1000000. |
|
1644
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
110 |
(bits at:9999) printCR. |
565 | 111 |
bits at:9999 put:1. |
1644
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
112 |
(bits at:9999) printCR. |
565 | 113 |
[exEnd] |
114 |
" |
|
115 |
! ! |
|
116 |
||
2094 | 117 |
!BitArray class methodsFor:'instance creation'! |
118 |
||
3172 | 119 |
fromBytes:aByteArray |
120 |
"return a new instance, capable of holding aByteArray size*8 bits, initialized from aByteArray" |
|
121 |
||
122 |
|a| |
|
123 |
||
124 |
a := self new: aByteArray size*8. |
|
125 |
1 to:aByteArray size do:[:i | a byteAt:i put:(aByteArray at:i)]. |
|
126 |
^ a |
|
127 |
||
128 |
" |
|
129 |
BitArray fromBytes:#[ 2r00001111 2r10101010 2r01010101] |
|
130 |
" |
|
131 |
! |
|
132 |
||
3823 | 133 |
new |
134 |
"return a new instance, capable of holding size bits" |
|
135 |
||
136 |
^ self new:0 |
|
137 |
||
138 |
" |
|
139 |
BitArray new |
|
140 |
" |
|
141 |
! |
|
142 |
||
2094 | 143 |
new:size |
144 |
"return a new instance, capable of holding size bits" |
|
145 |
||
146 |
|nBytes| |
|
147 |
||
3747 | 148 |
nBytes := (size + 7) // 8. |
2094 | 149 |
^ (super new:nBytes) setTally:size |
150 |
||
151 |
" |
|
152 |
BitArray new:10 |
|
153 |
" |
|
154 |
! ! |
|
155 |
||
3870 | 156 |
!BitArray class methodsFor:'queries'! |
157 |
||
158 |
maxVal |
|
3880 | 159 |
"the minimum value which can be stored in instances of me. |
160 |
For BitArrays, this is 1" |
|
3870 | 161 |
|
162 |
^ 1 |
|
163 |
! |
|
164 |
||
165 |
minVal |
|
3880 | 166 |
"the minimum value which can be stored in instances of me. |
167 |
For BitArrays, this is 0" |
|
3870 | 168 |
|
169 |
^ 0 |
|
170 |
! ! |
|
171 |
||
565 | 172 |
!BitArray methodsFor:'accessing'! |
173 |
||
174 |
at:index |
|
3278 | 175 |
"retrieve the bit at index (1..)" |
565 | 176 |
|
2094 | 177 |
|byte mask i0| |
178 |
||
179 |
(index between:1 and:tally) ifFalse:[ |
|
180 |
^ self subscriptBoundsError:index |
|
181 |
]. |
|
182 |
i0 := index - 1. |
|
183 |
byte := super basicAt:(i0 // 8)+1. |
|
184 |
mask := 1 bitShift:(7 - (i0 \\ 8)). |
|
2129 | 185 |
^ (byte bitTest:mask) ifTrue:[1] ifFalse:[0] |
565 | 186 |
|
187 |
" |
|
188 |
(BitArray new:1000) at:555 |
|
2094 | 189 |
(BitArray new:1000) at:400 put:1; at:400 |
565 | 190 |
" |
191 |
||
192 |
" |
|
193 |
|b| |
|
194 |
||
195 |
b := BitArray new:1000. |
|
196 |
b at:555 put:1. |
|
197 |
b at:555 |
|
198 |
" |
|
199 |
! |
|
200 |
||
2094 | 201 |
at:index put:aNumber |
3278 | 202 |
"store the argument, aNumber at index (1..); |
203 |
return the argument, aNumber (sigh)." |
|
565 | 204 |
|
2094 | 205 |
|byte mask idx i0| |
206 |
||
207 |
(index between:1 and:tally) ifFalse:[ |
|
208 |
^ self subscriptBoundsError:index |
|
565 | 209 |
]. |
2094 | 210 |
|
211 |
i0 := index - 1. |
|
212 |
idx := (i0 // 8) + 1. |
|
213 |
byte := super basicAt:idx. |
|
214 |
mask := 1 bitShift:(7 - (i0 \\ 8)). |
|
215 |
aNumber == 1 ifTrue:[ |
|
216 |
byte := byte bitOr:mask |
|
217 |
] ifFalse:[ |
|
218 |
aNumber == 0 ifTrue:[ |
|
219 |
byte := byte bitAnd:(mask bitInvert) |
|
220 |
] ifFalse:[ |
|
221 |
"/ not 0 or 1 |
|
222 |
^ self elementBoundsError:aNumber |
|
223 |
] |
|
565 | 224 |
]. |
2094 | 225 |
super basicAt:idx put:byte. |
226 |
^ aNumber. |
|
565 | 227 |
|
228 |
" |
|
229 |
|b| |
|
230 |
||
231 |
b := BitArray new:1000. |
|
232 |
b at:555 put:1. |
|
233 |
b at:555 |
|
234 |
" |
|
2093 | 235 |
! |
236 |
||
2319 | 237 |
byteAt:index |
238 |
"retrieve 8 bits at index; the index is 1 for the first 8 bits, 2 for the next 8 bits etc." |
|
239 |
||
240 |
^ self basicAt:index |
|
241 |
||
242 |
" |
|
243 |
((BitArray new:8) at:1 put:1); byteAt:1 |
|
244 |
" |
|
245 |
! |
|
246 |
||
247 |
byteAt:index put:aByte |
|
248 |
"store 8 bits at index; the index is 1 for the first 8 bits, 2 for the next 8 bits etc." |
|
249 |
||
250 |
^ self basicAt:index put:aByte |
|
251 |
||
252 |
" |
|
253 |
((BitArray new:8) byteAt:1 put:128); at:1 |
|
254 |
" |
|
255 |
! |
|
256 |
||
2093 | 257 |
occurrencesOf:anElement |
3278 | 258 |
"count the occurrences of the argument, anElement in the receiver" |
259 |
||
2107 | 260 |
|nOnes| |
261 |
||
262 |
nOnes := self countOnes. |
|
2093 | 263 |
anElement == 1 ifTrue:[ |
2107 | 264 |
^ nOnes |
2093 | 265 |
]. |
266 |
anElement == 0 ifTrue:[ |
|
2107 | 267 |
^ tally - nOnes |
2093 | 268 |
]. |
269 |
^ 0 |
|
3534 | 270 |
|
271 |
" |
|
272 |
(BitArray new:10) |
|
273 |
at:4 put:1; |
|
274 |
at:6 put:1; |
|
275 |
at:7 put:1; |
|
276 |
occurrencesOf:1 |
|
277 |
||
278 |
(BitArray new:10) |
|
279 |
at:4 put:1; |
|
280 |
at:6 put:1; |
|
281 |
at:7 put:1; |
|
282 |
occurrencesOf:0 |
|
283 |
" |
|
565 | 284 |
! ! |
285 |
||
1644
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
286 |
!BitArray methodsFor:'converting'! |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
287 |
|
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
288 |
bytes |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
289 |
"answer myself as a ByteArray containing my bytes" |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
290 |
|
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
291 |
|size bytes| |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
292 |
|
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
293 |
size := self basicSize. |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
294 |
bytes := ByteArray new:size. |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
295 |
1 to:size do:[:index| |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
296 |
bytes at:index put:(self byteAt:index) |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
297 |
]. |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
298 |
^ bytes |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
299 |
! ! |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
300 |
|
1176
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
301 |
!BitArray methodsFor:'filling & replacing'! |
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
302 |
|
2094 | 303 |
atAllPut:aNumber |
3278 | 304 |
"replace all elements of the collection by the argument, aNumber. |
305 |
The argument, aBoolean must be 0 or 1. |
|
306 |
Notice: This operation modifies the receiver, NOT a copy; |
|
307 |
therefore the change may affect all others referencing the receiver." |
|
308 |
||
2107 | 309 |
|v lastIndex| |
310 |
||
311 |
lastIndex := self basicSize. |
|
312 |
lastIndex == 0 ifTrue:[^ self]. |
|
2094 | 313 |
|
314 |
aNumber == 1 ifTrue:[ |
|
315 |
v := 255 |
|
316 |
] ifFalse:[ |
|
317 |
aNumber == 0 ifTrue:[ |
|
318 |
v := 0 |
|
319 |
] ifFalse:[ |
|
320 |
"/ |
|
321 |
"/ booleanArrays can only hold true and false |
|
322 |
"/ |
|
323 |
^ self elementBoundsError:aNumber |
|
324 |
] |
|
325 |
]. |
|
2107 | 326 |
1 to:lastIndex-1 do:[:i | |
327 |
self basicAt:i put:v |
|
1176
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
328 |
]. |
2107 | 329 |
|
330 |
"/ ensure 0-bits above tally |
|
331 |
v := #[ 2r11111111 |
|
332 |
2r10000000 |
|
333 |
2r11000000 |
|
334 |
2r11100000 |
|
335 |
2r11110000 |
|
336 |
2r11111000 |
|
337 |
2r11111100 |
|
338 |
2r11111110 ] at:(tally\\8)+1. |
|
339 |
self basicAt:lastIndex put:v. |
|
340 |
||
341 |
" |
|
342 |
((self new:10) atAllPut:1) countOnes |
|
343 |
((self new:8) atAllPut:1) countOnes |
|
344 |
" |
|
2094 | 345 |
! ! |
346 |
||
3748 | 347 |
!BitArray methodsFor:'logical operations'! |
348 |
||
349 |
bitOr:aBitArray |
|
350 |
|new mySize "{ Class: SmallInteger }" otherSize "{ Class: SmallInteger }"| |
|
351 |
||
352 |
mySize := self basicSize. |
|
353 |
otherSize := aBitArray basicSize. |
|
354 |
||
355 |
new := self class basicNew:(mySize max:otherSize). |
|
356 |
new setTally:(self size max:aBitArray size). |
|
357 |
||
358 |
1 to:mySize do:[:i| |
|
359 |
new basicAt:i put:(self basicAt:i). |
|
360 |
]. |
|
361 |
1 to:otherSize do:[:i| |
|
362 |
new basicAt:i put:((new basicAt:i) bitOr:(aBitArray basicAt:i)). |
|
363 |
]. |
|
364 |
||
365 |
^ new |
|
366 |
||
367 |
" |
|
368 |
((BitArray new:5) at:3 put:1; yourself) bitOr:((BitArray new:8) at:5 put:1; yourself) |
|
369 |
" |
|
370 |
! ! |
|
371 |
||
2094 | 372 |
!BitArray methodsFor:'private'! |
373 |
||
374 |
countOnes |
|
3278 | 375 |
"count the 1-bits in the receiver" |
376 |
||
2107 | 377 |
|sz bI count| |
2094 | 378 |
|
379 |
count := 0. |
|
2107 | 380 |
|
381 |
"/ because remaining bits in the highest byte are always 0, |
|
382 |
"/ we can simply count the 1-bits in ALL bytes... (see lastByte handling in atAllPut:) |
|
383 |
bI := 1. |
|
384 |
sz := self basicSize. |
|
385 |
[bI <= sz] whileTrue:[ |
|
386 |
count := count + (self basicAt:bI) bitCount. |
|
2094 | 387 |
bI := bI + 1. |
1176
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
388 |
]. |
2094 | 389 |
^ count |
390 |
||
2107 | 391 |
"/ |i nI bI bits count| |
392 |
"/ i := bI := 1. |
|
393 |
"/ [ |
|
394 |
"/ nI := i + 8. |
|
395 |
"/ nI <= tally |
|
396 |
"/ ] whileTrue:[ |
|
397 |
"/ bits := self basicAt:bI. |
|
398 |
"/ count := count + bits bitCount. |
|
399 |
"/ bI := bI + 1. |
|
400 |
"/ i := nI |
|
401 |
"/ ]. |
|
402 |
"/ [i <= tally] whileTrue:[ |
|
403 |
"/ (self at:i) ifTrue:[ count := count + 1]. |
|
404 |
"/ i := i + 1. |
|
405 |
"/ ]. |
|
406 |
"/ ^ count |
|
407 |
||
2094 | 408 |
" |
409 |
(BooleanArray new:100) |
|
410 |
at:14 put:true; |
|
411 |
at:55 put:true; |
|
412 |
countOnes |
|
413 |
||
414 |
(BooleanArray new:100) |
|
415 |
at:14 put:true; |
|
416 |
at:55 put:true; |
|
417 |
occurrencesOf:true |
|
418 |
||
419 |
(BooleanArray new:100) |
|
420 |
at:14 put:true; |
|
421 |
at:55 put:true; |
|
422 |
occurrencesOf:false |
|
423 |
" |
|
424 |
! |
|
425 |
||
2225 | 426 |
indexOfNth:n occurrenceOf:what |
427 |
"return the index of the nTh occurence of a value, or 0 if there are not that many" |
|
428 |
||
429 |
|sz byteIndex count countInByte| |
|
430 |
||
431 |
n > self size ifTrue:[^ 0]. |
|
432 |
||
433 |
count := 0. |
|
434 |
||
435 |
byteIndex := 1. |
|
436 |
sz := self basicSize. |
|
437 |
[byteIndex <= sz] whileTrue:[ |
|
438 |
countInByte := (self basicAt:byteIndex) bitCount. |
|
439 |
what = self defaultElement ifTrue:[ |
|
440 |
countInByte := 8-countInByte. |
|
441 |
]. |
|
442 |
count := count + countInByte. |
|
443 |
count >= n ifTrue:[ |
|
444 |
count := count - countInByte. |
|
445 |
(byteIndex-1)*8+1 to:(byteIndex-1)*8+8 do:[:bitIndex | |
|
446 |
(self at:bitIndex) = what ifTrue:[ |
|
447 |
count := count + 1. |
|
448 |
count = n ifTrue:[ |
|
449 |
^ bitIndex. |
|
450 |
] |
|
451 |
]. |
|
452 |
]. |
|
453 |
^ 0 |
|
454 |
]. |
|
455 |
byteIndex := byteIndex + 1. |
|
456 |
]. |
|
457 |
^ 0 |
|
458 |
||
459 |
" |
|
460 |
(BooleanArray new:100) |
|
461 |
at:1 put:true; |
|
462 |
at:2 put:true; |
|
463 |
at:4 put:true; |
|
464 |
at:5 put:true; |
|
465 |
at:6 put:true; |
|
466 |
at:7 put:true; |
|
467 |
at:8 put:true; |
|
468 |
at:10 put:true; |
|
469 |
indexOfNth:8 occurrenceOf:false |
|
470 |
" |
|
471 |
! |
|
472 |
||
2094 | 473 |
setTally:size |
3551 | 474 |
"set my tally - that is the actual number of bits in me |
475 |
(usually a little less than the number of bits in my byte array)" |
|
476 |
||
2094 | 477 |
tally := size |
1176
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
478 |
! ! |
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
479 |
|
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
480 |
!BitArray methodsFor:'queries'! |
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
481 |
|
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
482 |
defaultElement |
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
483 |
^ 0 |
2094 | 484 |
! |
485 |
||
486 |
size |
|
487 |
"return the size of the receiver" |
|
488 |
||
489 |
^ tally |
|
1176
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
490 |
! ! |
893
823d2fa809e2
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
736
diff
changeset
|
491 |
|
1459
914d762066f0
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
1241
diff
changeset
|
492 |
!BitArray methodsFor:'visiting'! |
914d762066f0
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
1241
diff
changeset
|
493 |
|
914d762066f0
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
1241
diff
changeset
|
494 |
acceptVisitor:aVisitor with:aParameter |
3319 | 495 |
"dispatch for visitor pattern; send #visitBitArray:with: to aVisitor" |
1459
914d762066f0
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
1241
diff
changeset
|
496 |
|
914d762066f0
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
1241
diff
changeset
|
497 |
^ aVisitor visitBitArray:self with:aParameter |
914d762066f0
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
1241
diff
changeset
|
498 |
! ! |
914d762066f0
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
1241
diff
changeset
|
499 |
|
565 | 500 |
!BitArray class methodsFor:'documentation'! |
501 |
||
502 |
version |
|
3747 | 503 |
^ '$Header$' |
2319 | 504 |
! |
505 |
||
506 |
version_CVS |
|
3747 | 507 |
^ '$Header$' |
565 | 508 |
! ! |
3172 | 509 |