home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnusmalltalk / array.st < prev    next >
Text File  |  1992-02-15  |  3KB  |  96 lines

  1. "======================================================================
  2. |
  3. |   Array Method Definitions
  4. |
  5.  ======================================================================"
  6.  
  7.  
  8. "======================================================================
  9. |
  10. | Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
  11. | Written by Steve Byrne.
  12. |
  13. | This file is part of GNU Smalltalk.
  14. |
  15. | GNU Smalltalk is free software; you can redistribute it and/or modify it
  16. | under the terms of the GNU General Public License as published by the Free
  17. | Software Foundation; either version 1, or (at your option) any later version.
  18. | GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
  19. | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  20. | FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  21. | details.
  22. | You should have received a copy of the GNU General Public License along with
  23. | GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
  24. | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  
  25. |
  26.  ======================================================================"
  27.  
  28.  
  29. "
  30. |     Change Log
  31. | ============================================================================
  32. | Author       Date       Change 
  33. |
  34. | sbb         16 Mar 91      Fixed class creation to be separate statement from
  35. |              class commenting.
  36. |
  37. | sbb         21 Sep 90      Added printOn: and storeOn: methods.
  38. |
  39. | sbyrne     25 Apr 89      created.
  40. |
  41. "
  42.  
  43. ArrayedCollection variableSubclass: #Array
  44.           instanceVariableNames: ''
  45.           classVariableNames: ''
  46.           poolDictionaries: ''
  47.           category: nil
  48. !
  49.  
  50. Array comment: 
  51. 'My instances are objects that have array-like properties: they are directly 
  52. indexable by integers starting at 1, and they are fixed in size.  I inherit
  53. object creation behavior messages such as #with:, as well as iteration
  54. and general access behavior from SequenceableCollection.' !
  55.  
  56. !Array methodsFor: 'basic'!
  57.  
  58.  
  59. !
  60.  
  61. !Array methodsFor: 'printing'!
  62.  
  63. printOn: aStream
  64.     aStream nextPut: $(.
  65.     self do:
  66.     [ :elt | elt printOn: aStream.
  67.          aStream space ].
  68.     aStream nextPut: $)
  69. ! !
  70.  
  71.  
  72.  
  73. !Array methodsFor: 'storing'!
  74.  
  75. storeOn: aStream
  76.     | index |
  77.     aStream nextPutAll: '((';
  78.     nextPutAll: self classNameString;
  79.     nextPutAll: ' basicNew: ';
  80.     print: self basicSize;
  81.     nextPut: $).
  82.     index _ 1.
  83.     self do:
  84.         [ :element | aStream nextPutAll: ' at: ';
  85.              print: index;
  86.              nextPutAll: ' put: ';
  87.              store: element; 
  88.              nextPut: $;.
  89.              index _ index + 1 ].
  90.     index > 1 ifTrue: [ aStream nextPutAll: ' yourself' ].
  91.     aStream nextPut: $)
  92. ! !
  93.  
  94.