author | Claus Gittinger <cg@exept.de> |
Sun, 05 Jun 2016 09:53:36 +0200 | |
changeset 3880 | 981c4604c1ce |
parent 3870 | 467b4e336955 |
child 3881 | 16890fe7ef2e |
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 |
71 |
(requires only 1/32th the memory compared to an array of booleans). |
|
2094 | 72 |
|
73 |
This one stores 8 bits per byte. Since instances store bits in multiples |
|
74 |
of 8, we have to keep the real size of the collection in an extra instance |
|
75 |
variable (tally). |
|
76 |
It may be useful if huge boolean arrays are to be used. |
|
77 |
||
3279 | 78 |
There are 10 types of people in this world: |
79 |
Those who understand binary, & those who don't. |
|
80 |
||
2107 | 81 |
ATTENTION: |
2094 | 82 |
Bits 1 to 8 of the BooleanArray are stored in bits 8 to 1 of the |
83 |
corresponding byte, to allow easy mapping to ASN.1 BIT STRING encoding |
|
2107 | 84 |
in the BER. (i.e. MSB-first) |
565 | 85 |
|
736 | 86 |
[memory requirements:] |
87 |
OBJ-HEADER + ((size + 7) // 8) |
|
88 |
||
565 | 89 |
[author:] |
90 |
Claus Gittinger |
|
91 |
||
92 |
[see also:] |
|
93 |
BooleanArray ByteArray WordArray Array |
|
94 |
" |
|
95 |
! |
|
96 |
||
97 |
examples |
|
98 |
" |
|
99 |
[exBegin] |
|
100 |
(BitArray new:7) inspect |
|
101 |
[exEnd] |
|
102 |
[exBegin] |
|
103 |
(BitArray new:7) basicInspect |
|
104 |
[exEnd] |
|
105 |
[exBegin] |
|
106 |
|bits| |
|
107 |
||
108 |
bits := BitArray new:1000000. |
|
1644
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
109 |
(bits at:9999) printCR. |
565 | 110 |
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
|
111 |
(bits at:9999) printCR. |
565 | 112 |
[exEnd] |
113 |
" |
|
114 |
! ! |
|
115 |
||
2094 | 116 |
!BitArray class methodsFor:'instance creation'! |
117 |
||
3172 | 118 |
fromBytes:aByteArray |
119 |
"return a new instance, capable of holding aByteArray size*8 bits, initialized from aByteArray" |
|
120 |
||
121 |
|a| |
|
122 |
||
123 |
a := self new: aByteArray size*8. |
|
124 |
1 to:aByteArray size do:[:i | a byteAt:i put:(aByteArray at:i)]. |
|
125 |
^ a |
|
126 |
||
127 |
" |
|
128 |
BitArray fromBytes:#[ 2r00001111 2r10101010 2r01010101] |
|
129 |
" |
|
130 |
! |
|
131 |
||
3823 | 132 |
new |
133 |
"return a new instance, capable of holding size bits" |
|
134 |
||
135 |
^ self new:0 |
|
136 |
||
137 |
" |
|
138 |
BitArray new |
|
139 |
" |
|
140 |
! |
|
141 |
||
2094 | 142 |
new:size |
143 |
"return a new instance, capable of holding size bits" |
|
144 |
||
145 |
|nBytes| |
|
146 |
||
3747 | 147 |
nBytes := (size + 7) // 8. |
2094 | 148 |
^ (super new:nBytes) setTally:size |
149 |
||
150 |
" |
|
151 |
BitArray new:10 |
|
152 |
" |
|
153 |
! ! |
|
154 |
||
3870 | 155 |
!BitArray class methodsFor:'queries'! |
156 |
||
157 |
maxVal |
|
3880 | 158 |
"the minimum value which can be stored in instances of me. |
159 |
For BitArrays, this is 1" |
|
3870 | 160 |
|
161 |
^ 1 |
|
162 |
! |
|
163 |
||
164 |
minVal |
|
3880 | 165 |
"the minimum value which can be stored in instances of me. |
166 |
For BitArrays, this is 0" |
|
3870 | 167 |
|
168 |
^ 0 |
|
169 |
! ! |
|
170 |
||
565 | 171 |
!BitArray methodsFor:'accessing'! |
172 |
||
173 |
at:index |
|
3278 | 174 |
"retrieve the bit at index (1..)" |
565 | 175 |
|
2094 | 176 |
|byte mask i0| |
177 |
||
178 |
(index between:1 and:tally) ifFalse:[ |
|
179 |
^ self subscriptBoundsError:index |
|
180 |
]. |
|
181 |
i0 := index - 1. |
|
182 |
byte := super basicAt:(i0 // 8)+1. |
|
183 |
mask := 1 bitShift:(7 - (i0 \\ 8)). |
|
2129 | 184 |
^ (byte bitTest:mask) ifTrue:[1] ifFalse:[0] |
565 | 185 |
|
186 |
" |
|
187 |
(BitArray new:1000) at:555 |
|
2094 | 188 |
(BitArray new:1000) at:400 put:1; at:400 |
565 | 189 |
" |
190 |
||
191 |
" |
|
192 |
|b| |
|
193 |
||
194 |
b := BitArray new:1000. |
|
195 |
b at:555 put:1. |
|
196 |
b at:555 |
|
197 |
" |
|
198 |
! |
|
199 |
||
2094 | 200 |
at:index put:aNumber |
3278 | 201 |
"store the argument, aNumber at index (1..); |
202 |
return the argument, aNumber (sigh)." |
|
565 | 203 |
|
2094 | 204 |
|byte mask idx i0| |
205 |
||
206 |
(index between:1 and:tally) ifFalse:[ |
|
207 |
^ self subscriptBoundsError:index |
|
565 | 208 |
]. |
2094 | 209 |
|
210 |
i0 := index - 1. |
|
211 |
idx := (i0 // 8) + 1. |
|
212 |
byte := super basicAt:idx. |
|
213 |
mask := 1 bitShift:(7 - (i0 \\ 8)). |
|
214 |
aNumber == 1 ifTrue:[ |
|
215 |
byte := byte bitOr:mask |
|
216 |
] ifFalse:[ |
|
217 |
aNumber == 0 ifTrue:[ |
|
218 |
byte := byte bitAnd:(mask bitInvert) |
|
219 |
] ifFalse:[ |
|
220 |
"/ not 0 or 1 |
|
221 |
^ self elementBoundsError:aNumber |
|
222 |
] |
|
565 | 223 |
]. |
2094 | 224 |
super basicAt:idx put:byte. |
225 |
^ aNumber. |
|
565 | 226 |
|
227 |
" |
|
228 |
|b| |
|
229 |
||
230 |
b := BitArray new:1000. |
|
231 |
b at:555 put:1. |
|
232 |
b at:555 |
|
233 |
" |
|
2093 | 234 |
! |
235 |
||
2319 | 236 |
byteAt:index |
237 |
"retrieve 8 bits at index; the index is 1 for the first 8 bits, 2 for the next 8 bits etc." |
|
238 |
||
239 |
^ self basicAt:index |
|
240 |
||
241 |
" |
|
242 |
((BitArray new:8) at:1 put:1); byteAt:1 |
|
243 |
" |
|
244 |
! |
|
245 |
||
246 |
byteAt:index put:aByte |
|
247 |
"store 8 bits at index; the index is 1 for the first 8 bits, 2 for the next 8 bits etc." |
|
248 |
||
249 |
^ self basicAt:index put:aByte |
|
250 |
||
251 |
" |
|
252 |
((BitArray new:8) byteAt:1 put:128); at:1 |
|
253 |
" |
|
254 |
! |
|
255 |
||
2093 | 256 |
occurrencesOf:anElement |
3278 | 257 |
"count the occurrences of the argument, anElement in the receiver" |
258 |
||
2107 | 259 |
|nOnes| |
260 |
||
261 |
nOnes := self countOnes. |
|
2093 | 262 |
anElement == 1 ifTrue:[ |
2107 | 263 |
^ nOnes |
2093 | 264 |
]. |
265 |
anElement == 0 ifTrue:[ |
|
2107 | 266 |
^ tally - nOnes |
2093 | 267 |
]. |
268 |
^ 0 |
|
3534 | 269 |
|
270 |
" |
|
271 |
(BitArray new:10) |
|
272 |
at:4 put:1; |
|
273 |
at:6 put:1; |
|
274 |
at:7 put:1; |
|
275 |
occurrencesOf:1 |
|
276 |
||
277 |
(BitArray new:10) |
|
278 |
at:4 put:1; |
|
279 |
at:6 put:1; |
|
280 |
at:7 put:1; |
|
281 |
occurrencesOf:0 |
|
282 |
" |
|
565 | 283 |
! ! |
284 |
||
1644
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
285 |
!BitArray methodsFor:'converting'! |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
286 |
|
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
287 |
bytes |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
288 |
"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
|
289 |
|
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
290 |
|size bytes| |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
291 |
|
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
292 |
size := self basicSize. |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
293 |
bytes := ByteArray new:size. |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
294 |
1 to:size do:[:index| |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
295 |
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
|
296 |
]. |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
297 |
^ bytes |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
298 |
! ! |
540979f371b3
Allow to access the bytes of a BitArray: #bytes
Stefan Vogel <sv@exept.de>
parents:
1459
diff
changeset
|
299 |
|
1176
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
300 |
!BitArray methodsFor:'filling & replacing'! |
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
301 |
|
2094 | 302 |
atAllPut:aNumber |
3278 | 303 |
"replace all elements of the collection by the argument, aNumber. |
304 |
The argument, aBoolean must be 0 or 1. |
|
305 |
Notice: This operation modifies the receiver, NOT a copy; |
|
306 |
therefore the change may affect all others referencing the receiver." |
|
307 |
||
2107 | 308 |
|v lastIndex| |
309 |
||
310 |
lastIndex := self basicSize. |
|
311 |
lastIndex == 0 ifTrue:[^ self]. |
|
2094 | 312 |
|
313 |
aNumber == 1 ifTrue:[ |
|
314 |
v := 255 |
|
315 |
] ifFalse:[ |
|
316 |
aNumber == 0 ifTrue:[ |
|
317 |
v := 0 |
|
318 |
] ifFalse:[ |
|
319 |
"/ |
|
320 |
"/ booleanArrays can only hold true and false |
|
321 |
"/ |
|
322 |
^ self elementBoundsError:aNumber |
|
323 |
] |
|
324 |
]. |
|
2107 | 325 |
1 to:lastIndex-1 do:[:i | |
326 |
self basicAt:i put:v |
|
1176
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
327 |
]. |
2107 | 328 |
|
329 |
"/ ensure 0-bits above tally |
|
330 |
v := #[ 2r11111111 |
|
331 |
2r10000000 |
|
332 |
2r11000000 |
|
333 |
2r11100000 |
|
334 |
2r11110000 |
|
335 |
2r11111000 |
|
336 |
2r11111100 |
|
337 |
2r11111110 ] at:(tally\\8)+1. |
|
338 |
self basicAt:lastIndex put:v. |
|
339 |
||
340 |
" |
|
341 |
((self new:10) atAllPut:1) countOnes |
|
342 |
((self new:8) atAllPut:1) countOnes |
|
343 |
" |
|
2094 | 344 |
! ! |
345 |
||
3748 | 346 |
!BitArray methodsFor:'logical operations'! |
347 |
||
348 |
bitOr:aBitArray |
|
349 |
|new mySize "{ Class: SmallInteger }" otherSize "{ Class: SmallInteger }"| |
|
350 |
||
351 |
mySize := self basicSize. |
|
352 |
otherSize := aBitArray basicSize. |
|
353 |
||
354 |
new := self class basicNew:(mySize max:otherSize). |
|
355 |
new setTally:(self size max:aBitArray size). |
|
356 |
||
357 |
1 to:mySize do:[:i| |
|
358 |
new basicAt:i put:(self basicAt:i). |
|
359 |
]. |
|
360 |
1 to:otherSize do:[:i| |
|
361 |
new basicAt:i put:((new basicAt:i) bitOr:(aBitArray basicAt:i)). |
|
362 |
]. |
|
363 |
||
364 |
^ new |
|
365 |
||
366 |
" |
|
367 |
((BitArray new:5) at:3 put:1; yourself) bitOr:((BitArray new:8) at:5 put:1; yourself) |
|
368 |
" |
|
369 |
! ! |
|
370 |
||
2094 | 371 |
!BitArray methodsFor:'private'! |
372 |
||
373 |
countOnes |
|
3278 | 374 |
"count the 1-bits in the receiver" |
375 |
||
2107 | 376 |
|sz bI count| |
2094 | 377 |
|
378 |
count := 0. |
|
2107 | 379 |
|
380 |
"/ because remaining bits in the highest byte are always 0, |
|
381 |
"/ we can simply count the 1-bits in ALL bytes... (see lastByte handling in atAllPut:) |
|
382 |
bI := 1. |
|
383 |
sz := self basicSize. |
|
384 |
[bI <= sz] whileTrue:[ |
|
385 |
count := count + (self basicAt:bI) bitCount. |
|
2094 | 386 |
bI := bI + 1. |
1176
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
387 |
]. |
2094 | 388 |
^ count |
389 |
||
2107 | 390 |
"/ |i nI bI bits count| |
391 |
"/ i := bI := 1. |
|
392 |
"/ [ |
|
393 |
"/ nI := i + 8. |
|
394 |
"/ nI <= tally |
|
395 |
"/ ] whileTrue:[ |
|
396 |
"/ bits := self basicAt:bI. |
|
397 |
"/ count := count + bits bitCount. |
|
398 |
"/ bI := bI + 1. |
|
399 |
"/ i := nI |
|
400 |
"/ ]. |
|
401 |
"/ [i <= tally] whileTrue:[ |
|
402 |
"/ (self at:i) ifTrue:[ count := count + 1]. |
|
403 |
"/ i := i + 1. |
|
404 |
"/ ]. |
|
405 |
"/ ^ count |
|
406 |
||
2094 | 407 |
" |
408 |
(BooleanArray new:100) |
|
409 |
at:14 put:true; |
|
410 |
at:55 put:true; |
|
411 |
countOnes |
|
412 |
||
413 |
(BooleanArray new:100) |
|
414 |
at:14 put:true; |
|
415 |
at:55 put:true; |
|
416 |
occurrencesOf:true |
|
417 |
||
418 |
(BooleanArray new:100) |
|
419 |
at:14 put:true; |
|
420 |
at:55 put:true; |
|
421 |
occurrencesOf:false |
|
422 |
" |
|
423 |
! |
|
424 |
||
2225 | 425 |
indexOfNth:n occurrenceOf:what |
426 |
"return the index of the nTh occurence of a value, or 0 if there are not that many" |
|
427 |
||
428 |
|sz byteIndex count countInByte| |
|
429 |
||
430 |
n > self size ifTrue:[^ 0]. |
|
431 |
||
432 |
count := 0. |
|
433 |
||
434 |
byteIndex := 1. |
|
435 |
sz := self basicSize. |
|
436 |
[byteIndex <= sz] whileTrue:[ |
|
437 |
countInByte := (self basicAt:byteIndex) bitCount. |
|
438 |
what = self defaultElement ifTrue:[ |
|
439 |
countInByte := 8-countInByte. |
|
440 |
]. |
|
441 |
count := count + countInByte. |
|
442 |
count >= n ifTrue:[ |
|
443 |
count := count - countInByte. |
|
444 |
(byteIndex-1)*8+1 to:(byteIndex-1)*8+8 do:[:bitIndex | |
|
445 |
(self at:bitIndex) = what ifTrue:[ |
|
446 |
count := count + 1. |
|
447 |
count = n ifTrue:[ |
|
448 |
^ bitIndex. |
|
449 |
] |
|
450 |
]. |
|
451 |
]. |
|
452 |
^ 0 |
|
453 |
]. |
|
454 |
byteIndex := byteIndex + 1. |
|
455 |
]. |
|
456 |
^ 0 |
|
457 |
||
458 |
" |
|
459 |
(BooleanArray new:100) |
|
460 |
at:1 put:true; |
|
461 |
at:2 put:true; |
|
462 |
at:4 put:true; |
|
463 |
at:5 put:true; |
|
464 |
at:6 put:true; |
|
465 |
at:7 put:true; |
|
466 |
at:8 put:true; |
|
467 |
at:10 put:true; |
|
468 |
indexOfNth:8 occurrenceOf:false |
|
469 |
" |
|
470 |
! |
|
471 |
||
2094 | 472 |
setTally:size |
3551 | 473 |
"set my tally - that is the actual number of bits in me |
474 |
(usually a little less than the number of bits in my byte array)" |
|
475 |
||
2094 | 476 |
tally := size |
1176
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
477 |
! ! |
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 |
!BitArray methodsFor:'queries'! |
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
480 |
|
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
481 |
defaultElement |
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
482 |
^ 0 |
2094 | 483 |
! |
484 |
||
485 |
size |
|
486 |
"return the size of the receiver" |
|
487 |
||
488 |
^ tally |
|
1176
8224efd15c5a
elementBoundsError -> elementBoundsError:
Claus Gittinger <cg@exept.de>
parents:
893
diff
changeset
|
489 |
! ! |
893
823d2fa809e2
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
736
diff
changeset
|
490 |
|
1459
914d762066f0
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
1241
diff
changeset
|
491 |
!BitArray methodsFor:'visiting'! |
914d762066f0
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
1241
diff
changeset
|
492 |
|
914d762066f0
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
1241
diff
changeset
|
493 |
acceptVisitor:aVisitor with:aParameter |
3319 | 494 |
"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
|
495 |
|
914d762066f0
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
1241
diff
changeset
|
496 |
^ aVisitor visitBitArray:self with:aParameter |
914d762066f0
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
1241
diff
changeset
|
497 |
! ! |
914d762066f0
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
1241
diff
changeset
|
498 |
|
565 | 499 |
!BitArray class methodsFor:'documentation'! |
500 |
||
501 |
version |
|
3747 | 502 |
^ '$Header$' |
2319 | 503 |
! |
504 |
||
505 |
version_CVS |
|
3747 | 506 |
^ '$Header$' |
565 | 507 |
! ! |
3172 | 508 |