|
Class: BooleanArray
Object
|
+--Collection
|
+--SequenceableCollection
|
+--ArrayedCollection
|
+--BitArray
|
+--BooleanArray
- Package:
- stx:libbasic
- Category:
- Collections-Arrayed
- Version:
- rev:
1.2
date: 2019/03/26 10:54:08
- user: cg
- file: BooleanArray.st directory: libbasic
- module: stx stc-classLibrary: libbasic
- Author:
- Claus Gittinger
BooleanArrays are specially tuned to store booleans (true and false),
and are useful for bulk bit/boolean data.
Instances require only 1/32th (32bit machines) or even 1/64th (64bit machines)
of memory compared to a regular array of booleans.
They store 8 booleans per byte.
Since instances store bits in multiples of 8,
the real size of the collection is kept in an extra instance variable (tally).
It may be useful if huge boolean arrays are to be used.
ATTENTION:
inheriting from BitArray, bits 1 to 8 of the BooleanArray are stored in bits 8 to 1
of the corresponding byte, to allow easy mapping to ASN.1 BIT STRING encoding
in the BER.
Do not change this.
[memory requirements:]
OBJ-HEADER + ((size + 7) // 8)
ByteArray
WordArray
Array
accessing
-
at: index
-
retrieve the boolean at index
usage example(s):
(BooleanArray new:1000) at:555
|
-
at: index put: aBoolean
-
store the argument, aBoolean at index; return aBoolean (sigh).
-
occurrencesOf: anElement
-
count the occurrences of the argument, anElement in the receiver
usage example(s):
(BooleanArray new:10)
at:4 put:true;
at:6 put:true;
at:7 put:true;
occurrencesOf:true
|
filling & replacing
-
atAllPut: aBoolean
-
replace all elements of the collection by the argument, aBoolean.
Return the receiver.
The argument, aBoolean must be true or false.
Notice: This operation modifies the receiver, NOT a copy;
therefore the change may affect all others referencing the receiver.
queries
-
defaultElement
-
-
isValidElement: anObject
-
return true, if I can hold this kind of object
(BooleanArray new:7) inspect
|
(BooleanArray new:7) basicInspect
|
|flags|
flags := BooleanArray new:1000000.
(flags at:9999) printNL.
flags at:9999 put:true.
(flags at:9999) printNL.
|
|