WordArray.st
author Stefan Vogel <sv@exept.de>
Wed, 21 Nov 2007 18:24:07 +0100
changeset 1917 61c602336f3d
parent 1414 e801d1248f10
child 2645 1950f0398db0
permissions -rw-r--r--
Clean up code and document differences between #add: and #addLast:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1414
e801d1248f10 printing code shared for 16- and 32bit arrays
Claus Gittinger <cg@exept.de>
parents: 1396
diff changeset
     1
"{ Encoding: iso8859-1 }"
e801d1248f10 printing code shared for 16- and 32bit arrays
Claus Gittinger <cg@exept.de>
parents: 1396
diff changeset
     2
376
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
 COPYRIGHT (c) 1989 by Claus Gittinger
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	      All Rights Reserved
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 This software is furnished under a license and may be used
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 hereby transferred.
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
1177
f81425b27be5 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    15
"{ Package: 'stx:libbasic2' }"
f81425b27be5 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    16
f81425b27be5 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    17
UnboxedIntegerArray variableWordSubclass:#WordArray
376
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	instanceVariableNames:''
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	classVariableNames:''
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	poolDictionaries:''
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	category:'Collections-Arrayed'
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
!WordArray class methodsFor:'documentation'!
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
copyright
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
"
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 COPYRIGHT (c) 1989 by Claus Gittinger
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
	      All Rights Reserved
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 This software is furnished under a license and may be used
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 only in accordance with the terms of that license and with the
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 inclusion of the above copyright notice.   This software may not
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 be provided or otherwise made available to, or used by, any
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 other person.  No title to or ownership of the software is
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 hereby transferred.
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
"
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
!
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
documentation
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
"
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    WordArrays store integers in the range 0..16rFFFF.
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    In contrast to normal arrays (which store pointers to their elements),
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    wordArrays store the values in a dense & compact way. 
1177
f81425b27be5 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    45
    Since the representation fits the underlying C-language systems representation
f81425b27be5 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    46
    of unsigned int16's, this is also useful to pass bulk data to c primitive code.
f81425b27be5 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    47
f81425b27be5 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 736
diff changeset
    48
    WordArrays can be used to hold bulk integer data in a more compact way.
736
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
    49
        For example:
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
    50
            Array new:100000 withAll:1
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
    51
        requires 400k of object memory;
376
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
736
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
    53
        in contrast,
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
    54
            WordArray new:100000 withAll:1
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
    55
        only requires half of it.
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
    56
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
    57
    [memory requirements:]
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
    58
        OBJ-HEADER + (size * 2)
376
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    [see also:]
736
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
    61
        ByteArray BooleanArray FloatArray DoubleArray Array
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
    62
        SignedWordArray
376
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    [author:]
736
db164846b078 documentation
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
    65
        Claus Gittinger
376
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
"
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
! !
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
!WordArray class methodsFor:'documentation'!
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
version
1414
e801d1248f10 printing code shared for 16- and 32bit arrays
Claus Gittinger <cg@exept.de>
parents: 1396
diff changeset
    72
    ^ '$Header: /cvs/stx/stx/libbasic2/WordArray.st,v 1.6 2004-03-03 20:49:21 cg Exp $'
376
ab5f177867ba moved from goodies
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
! !