author | Claus Gittinger <cg@exept.de> |
Tue, 25 Jun 2019 14:28:51 +0200 | |
changeset 5050 | 44fa8672d102 |
parent 3878 | 8c30e6e6d334 |
permissions | -rw-r--r-- |
883 | 1 |
" |
2 |
COPYRIGHT (c) 1997 eXept Software AG |
|
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 |
" |
|
1177 | 12 |
"{ Package: 'stx:libbasic2' }" |
13 |
||
3733 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
1177 | 16 |
UnboxedIntegerArray variableSignedWordSubclass:#SignedWordArray |
557 | 17 |
instanceVariableNames:'' |
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'Collections-Arrayed' |
|
21 |
! |
|
22 |
||
23 |
!SignedWordArray class methodsFor:'documentation'! |
|
24 |
||
883 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 1997 eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
||
38 |
||
39 |
! |
|
40 |
||
557 | 41 |
documentation |
42 |
" |
|
703 | 43 |
SignedWordArrays store 16bit signed integers in the range -16r8000..16r7FFF. |
557 | 44 |
They are much like WordArrays, but the values stored are signed. |
45 |
In contrast to normal arrays (which store pointers to their elements), |
|
46 |
signedWordArrays store the values in a dense & compact way. |
|
1177 | 47 |
Since the representation fits the underlying C-language systems representation |
48 |
of signed int16's, this is also useful to pass bulk data to c primitive code. |
|
49 |
||
50 |
Therefore, SignedWordArrays can be used to hold bulk data in a more compact way. |
|
736 | 51 |
For example: |
52 |
Array new:100000 withAll:1 |
|
53 |
requires 400k of object memory; |
|
557 | 54 |
|
736 | 55 |
in contrast, |
1177 | 56 |
SignedWordArray new:100000 withAll:1 |
736 | 57 |
only requires half of it. |
58 |
||
59 |
[memory requirements:] |
|
60 |
OBJ-HEADER + (size * 2) |
|
557 | 61 |
|
62 |
[see also:] |
|
736 | 63 |
ByteArray WordArray BooleanArray FloatArray DoubleArray Array |
64 |
IntegerArray LongIntegerArray SignedLongIntegerArray |
|
557 | 65 |
|
66 |
[author:] |
|
736 | 67 |
Claus Gittinger |
557 | 68 |
" |
69 |
! ! |
|
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 | 74 |
"for bit-like containers, return the number of bytes stored per element. |
75 |
Here, 2 is returned" |
|
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 | 80 |
! |
81 |
||
82 |
maxVal |
|
3878 | 83 |
"the maximum value which can be stored in instances of me. |
84 |
For SignedWordArrays, this is 16r7FFF (largest 16bit signed int)" |
|
3867 | 85 |
|
3733 | 86 |
^ 16r7FFF |
3867 | 87 |
! |
88 |
||
89 |
minVal |
|
3878 | 90 |
"the minimum value which can be stored in instances of me. |
91 |
For SignedWordArrays, this is -16r8000 (smallest 16bit signed int)" |
|
3867 | 92 |
|
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 | 96 |
!SignedWordArray class methodsFor:'documentation'! |
97 |
||
98 |
version |
|
3733 | 99 |
^ '$Header$' |
3878 | 100 |
! |
101 |
||
102 |
version_CVS |
|
103 |
^ '$Header$' |
|
557 | 104 |
! ! |
3334 | 105 |