eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'SignedByteArray':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: SignedByteArray


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--ArrayedCollection
            |
            +--UninterpretedBytes
               |
               +--ByteArray
                  |
                  +--SignedByteArray

Package:
stx:libbasic
Category:
Collections-Arrayed
Version:
rev: 1.18 date: 2023/08/08 10:08:46
user: cg
file: SignedByteArray.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


Instances of this class hold signed bytes in the range -128 ... +127.

SignedByteArrays can be used as literals i.e. you can enter SignedByteArray-constants as: 
    #s8( element1 element2 .... elementN ) 
for example:
    #s8(-1 10 -128 127 )

Aliased as Int8Array.

[memory requirements:]
    OBJ-HEADER + size   (rounded up to next multiple of wordsize)

copyright

COPYRIGHT (c) 2016 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

queries
o  literalTokenPrefix

o  maxVal
the maximum value which can be stored in instances of me.
For SignedByteArrays, this is 127 (largest 8bit signed int)

o  minVal
the minimum value which can be stored in instances of me.
For SignedByteArrays, this is -128 (smallest 8bit signed int)


Instance protocol:

accessing
o  basicAt: index
return the indexed instance variable with index, anInteger
- redefined here to return a signed interger.

o  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
o  asSignedByteArray
return the receiver as a signed byteArray.
That is the receiver already

o  asUnsignedByteArray
Answer a unsigned byte array.
elements < 0 are converted to positive numbers.

Usage example(s):

     #(-1 -128 3 4) asSignedByteArray asUnsignedByteArray

o  beSigned
that's what I am

o  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
o  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
o  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
o  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     

testing
o  isByteArray
return true, if the receiver is some kind of bytearray;
false is returned here - the method is redefined from ByteArray.



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Tue, 18 Jun 2024 17:46:03 GMT