SignedWordArray.st
author Claus Gittinger <cg@exept.de>
Sat, 02 May 2020 21:40:13 +0200
changeset 5476 7355a4b11cb6
parent 3878 8c30e6e6d334
permissions -rw-r--r--
#FEATURE by cg class: Socket class added: #newTCPclientToHost:port:domain:domainOrder:withTimeout: changed: #newTCPclientToHost:port:domain:withTimeout:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
883
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
     1
"
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
     2
 COPYRIGHT (c) 1997 eXept Software AG
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
     3
              All Rights Reserved
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
     4
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
     5
 This software is furnished under a license and may be used
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
     6
 only in accordance with the terms of that license and with the
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
     8
 be provided or otherwise made available to, or used by, any
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
     9
 other person.  No title to or ownership of the software is
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    10
 hereby transferred.
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    11
"
1177
f81425b27be5 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 883
diff changeset
    12
"{ Package: 'stx:libbasic2' }"
f81425b27be5 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 883
diff changeset
    13
3733
0e828ae403ba #FEATURE
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
    14
"{ NameSpace: Smalltalk }"
0e828ae403ba #FEATURE
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
    15
1177
f81425b27be5 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 883
diff changeset
    16
UnboxedIntegerArray variableSignedWordSubclass:#SignedWordArray
557
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:''
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:''
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	category:'Collections-Arrayed'
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!SignedWordArray class methodsFor:'documentation'!
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
883
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    25
copyright
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    26
"
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    27
 COPYRIGHT (c) 1997 eXept Software AG
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    28
              All Rights Reserved
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    29
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    30
 This software is furnished under a license and may be used
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    31
 only in accordance with the terms of that license and with the
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    33
 be provided or otherwise made available to, or used by, any
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    34
 other person.  No title to or ownership of the software is
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    35
 hereby transferred.
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    36
"
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    37
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    38
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    39
!
af72d62dc635 copyrights
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    40
557
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
documentation
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
"
703
a0a2d6178de4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 557
diff changeset
    43
    SignedWordArrays store 16bit signed integers in the range -16r8000..16r7FFF.
557
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    They are much like WordArrays, but the values stored are signed.
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    In contrast to normal arrays (which store pointers to their elements),
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    signedWordArrays store the values in a dense & compact way. 
1177
f81425b27be5 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 883
diff changeset
    47
    Since the representation fits the underlying C-language systems representation
f81425b27be5 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 883
diff changeset
    48
    of signed int16's, this is also useful to pass bulk data to c primitive code.
f81425b27be5 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 883
diff changeset
    49
f81425b27be5 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 883
diff changeset
    50
    Therefore, SignedWordArrays can be used to hold bulk data in a more compact way.
736
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    51
        For example:
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    52
            Array new:100000 withAll:1
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    53
        requires 400k of object memory;
557
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
736
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    55
        in contrast,
1177
f81425b27be5 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 883
diff changeset
    56
            SignedWordArray new:100000 withAll:1
736
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    57
        only requires half of it.
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    58
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    59
    [memory requirements:]
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    60
        OBJ-HEADER + (size * 2)
557
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    [see also:]
736
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    63
        ByteArray WordArray BooleanArray FloatArray DoubleArray Array
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    64
        IntegerArray LongIntegerArray SignedLongIntegerArray
557
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    [author:]
736
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    67
        Claus Gittinger
557
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
"
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
! !
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
2642
e69731982fa9 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
    71
!SignedWordArray class methodsFor:'queries'!
e69731982fa9 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
    72
e69731982fa9 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
    73
elementByteSize
3334
473f4994e23a class: WordArray
Claus Gittinger <cg@exept.de>
parents: 2642
diff changeset
    74
    "for bit-like containers, return the number of bytes stored per element.
473f4994e23a class: WordArray
Claus Gittinger <cg@exept.de>
parents: 2642
diff changeset
    75
     Here, 2 is returned"
473f4994e23a class: WordArray
Claus Gittinger <cg@exept.de>
parents: 2642
diff changeset
    76
2642
e69731982fa9 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
    77
    ^ 2
e69731982fa9 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
    78
e69731982fa9 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
    79
    "Created: / 15-09-2011 / 14:11:18 / cg"
3733
0e828ae403ba #FEATURE
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
    80
!
0e828ae403ba #FEATURE
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
    81
0e828ae403ba #FEATURE
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
    82
maxVal
3878
8c30e6e6d334 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3867
diff changeset
    83
    "the maximum value which can be stored in instances of me.
8c30e6e6d334 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3867
diff changeset
    84
     For SignedWordArrays, this is 16r7FFF (largest 16bit signed int)"
3867
73820bfcbddc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3733
diff changeset
    85
3733
0e828ae403ba #FEATURE
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
    86
    ^ 16r7FFF
3867
73820bfcbddc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3733
diff changeset
    87
!
73820bfcbddc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3733
diff changeset
    88
73820bfcbddc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3733
diff changeset
    89
minVal
3878
8c30e6e6d334 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3867
diff changeset
    90
    "the minimum value which can be stored in instances of me.
8c30e6e6d334 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3867
diff changeset
    91
     For SignedWordArrays, this is -16r8000 (smallest 16bit signed int)"
3867
73820bfcbddc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3733
diff changeset
    92
73820bfcbddc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3733
diff changeset
    93
    ^ -16r8000
2642
e69731982fa9 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
    94
! !
e69731982fa9 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 1177
diff changeset
    95
557
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
!SignedWordArray class methodsFor:'documentation'!
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
version
3733
0e828ae403ba #FEATURE
Stefan Vogel <sv@exept.de>
parents: 3334
diff changeset
    99
    ^ '$Header$'
3878
8c30e6e6d334 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3867
diff changeset
   100
!
8c30e6e6d334 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3867
diff changeset
   101
8c30e6e6d334 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3867
diff changeset
   102
version_CVS
8c30e6e6d334 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3867
diff changeset
   103
    ^ '$Header$'
557
fb9679c8c054 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
! !
3334
473f4994e23a class: WordArray
Claus Gittinger <cg@exept.de>
parents: 2642
diff changeset
   105