|
Class: SignedByteArray
Object
|
+--Collection
|
+--SequenceableCollection
|
+--ArrayedCollection
|
+--UninterpretedBytes
|
+--ByteArray
|
+--SignedByteArray
- Package:
- stx:libbasic
- Category:
- Collections-Arrayed
- Version:
- rev:
1.8
date: 2019/06/09 13:31:25
- user: cg
- file: SignedByteArray.st directory: libbasic
- module: stx stc-classLibrary: libbasic
- Author:
- Stefan Vogel
Instances of this class hold signed bytes in the range -128 ... +127.
ByteArray
queries
-
maxVal
-
the maximum value which can be stored in instances of me.
For SignedByteArrays, this is 127 (largest 8bit signed int)
-
minVal
-
the minimum value which can be stored in instances of me.
For SignedByteArrays, this is -128 (smallest 8bit signed int)
accessing
-
basicAt: index
-
return the indexed instance variable with index, anInteger
- redefined here to return a signed interger.
-
basicAt: index put: value
-
set the indexed instance variable with index, anInteger to value.
Returns value (sigh).
- redefined here to allow value to be a signed integer
usage example(s):
(self new:5) basicAt:1 put:-1; yourself
|
converting
-
asSignedByteArray
-
return the receiver as a signed byteArray.
That is the receiver already
-
asUnsignedByteArray
-
Answer a unsigned byte array.
elements < 0 are converted to positive numbers.
usage example(s):
#(-1 -128 3 4) asSignedByteArray asUnsignedByteArray
|
-
beSigned
-
that's what I am
-
beUnsigned
-
destructively make myself unsigned.
elements < 0 are converted to positive numbers.
WARNING: this changes the receiver itself - use this only for initialization of new instances
usage example(s):
#(-1 -128 3 4) asSignedByteArray beUnsigned
|
filling & replacing
-
from: start to: stop put: aNumber
-
fill part of the receiver with aNumber.
- reimplemented here for speed
usage example(s):
(self new:10) from:1 to:10 put:-5
(self new:20) from:10 to:20 put:-5
(self new:20) from:1 to:10 put:-5
|
queries
-
max
-
return the maximum value in the receiver -
redefined to speedup image processing and sound-player
(which need a fast method for this on byteArrays)
usage example(s):
#[1 2 3 -11 2 3 1 2 19] max
#(-1 -2 -3 -4) asSignedByteArray max
#() asSignedByteArray max
#[] max
#() max
|
searching
-
indexOf: aByte startingAt: start
-
return the index of the first occurrence of the argument, aByte
in the receiver starting at start, anInteger; return 0 if not found.
- reimplemented here for speed
usage example(s):
#(-1 2 3 -4 5 6 7 8 9 0 1 2 3 4 5) asSignedByteArray indexOf:0 startingAt:1
#(-1 2 3 -4 5 6 7 8 9 0 1 2 3 4 5) asSignedByteArray indexOf:-4 startingAt:1
#() asSignedByteArray indexOf:-4 startingAt:1
#() indexOf:-4 startingAt:1
|
|