Array.st
changeset 18267 3bc0c58cb8e9
parent 18246 d4d749c60f22
child 18274 042d13555f1f
child 18288 1232fc152674
equal deleted inserted replaced
18266:d2e1d1f33fae 18267:3bc0c58cb8e9
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1989 by Claus Gittinger
     4  COPYRIGHT (c) 1989 by Claus Gittinger
     3 	      All Rights Reserved
     5 	      All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
   298 
   300 
   299     ^ self == Array
   301     ^ self == Array
   300 
   302 
   301     "Modified: 23.4.1996 / 15:55:06 / cg"
   303     "Modified: 23.4.1996 / 15:55:06 / cg"
   302 ! !
   304 ! !
   303 
       
   304 
   305 
   305 !Array methodsFor:'accessing'!
   306 !Array methodsFor:'accessing'!
   306 
   307 
   307 at:index
   308 at:index
   308     "return the indexed instance variable with index, anInteger.
   309     "return the indexed instance variable with index, anInteger.
  1740 
  1741 
  1741 printOn:aStream
  1742 printOn:aStream
  1742     "append a printed representation of the receiver to aStream"
  1743     "append a printed representation of the receiver to aStream"
  1743 
  1744 
  1744     self isLiteral ifTrue:[
  1745     self isLiteral ifTrue:[
  1745 	|limit firstOne s|
  1746         |limit firstOne s|
  1746 
  1747 
  1747 	thisContext isRecursive ifTrue:[
  1748         thisContext isRecursive ifTrue:[
  1748 	    'Array [error]: printOn: of self referencing collection.' errorPrintCR.
  1749             'Array [error]: printOn: of self referencing collection.' errorPrintCR.
  1749 	    aStream nextPutAll:'#("recursive")'.
  1750             aStream nextPutAll:'#("recursive")'.
  1750 	    ^ self
  1751             ^ self
  1751 	].
  1752         ].
  1752 
  1753 
  1753 	aStream nextPutAll:'#('.
  1754         aStream nextPutAll:'#('.
  1754 	firstOne := true.
  1755         firstOne := true.
  1755 
  1756 
  1756 	"
  1757         "
  1757 	 if aStream is not positionable, create an temporary positionable stream
  1758          if aStream is not positionable, create an temporary positionable stream
  1758 	 (needed for limit calculation)
  1759          (needed for limit calculation)
  1759 	"
  1760         "
  1760 	aStream isPositionable ifTrue:[
  1761         aStream isPositionable ifTrue:[
  1761 	    s := aStream.
  1762             s := aStream.
  1762 	] ifFalse:[
  1763         ] ifFalse:[
  1763 	    s := WriteStream on:(String uninitializedNew:50).
  1764             s := CharacterWriteStream new:50.
  1764 	].
  1765         ].
  1765 	limit := s position + self maxPrint.
  1766         limit := s position + self maxPrint.
  1766 
  1767 
  1767 	self printElementsDo:[:element |
  1768         self printElementsDo:[:element |
  1768 	    firstOne ifFalse:[
  1769             firstOne ifFalse:[
  1769 		s space
  1770                 s space
  1770 	    ] ifTrue:[
  1771             ] ifTrue:[
  1771 		firstOne := false
  1772                 firstOne := false
  1772 	    ].
  1773             ].
  1773 	    (s position >= limit) ifTrue:[
  1774             (s position >= limit) ifTrue:[
  1774 		s ~~ aStream ifTrue:[
  1775                 s ~~ aStream ifTrue:[
  1775 		    aStream nextPutAll:(s contents).
  1776                     aStream nextPutAll:(s contents).
  1776 		].
  1777                 ].
  1777 		aStream nextPutAll:'...etc...)'.
  1778                 aStream nextPutAll:'...etc...)'.
  1778 		^ self
  1779                 ^ self
  1779 	    ] ifFalse:[
  1780             ] ifFalse:[
  1780 		element printOn:s.
  1781                 element printOn:s.
  1781 	    ].
  1782             ].
  1782 	].
  1783         ].
  1783 	s ~~ aStream ifTrue:[
  1784         s ~~ aStream ifTrue:[
  1784 	    aStream nextPutAll:(s contents).
  1785             aStream nextPutAll:(s contents).
  1785 	].
  1786         ].
  1786 	aStream nextPut:$)
  1787         aStream nextPut:$)
  1787     ] ifFalse:[
  1788     ] ifFalse:[
  1788 	super printOn:aStream
  1789         super printOn:aStream
  1789     ]
  1790     ]
  1790 
  1791 
  1791     "
  1792     "
  1792      #(1 2 $a 'hello' sym kewordSymbol:with: #'funny symbol') printString
  1793      #(1 2 $a $Š 'hello' sym kewordSymbol:with: #'funny symbol') printString
  1793      #(1 2 $a [1 2 3] true false nil #true #false #nil) printString
  1794      #(1 2 $a [1 2 3] true false nil #true #false #nil) printString
  1794     "
  1795     "
  1795 
  1796 
  1796     "Created: 20.11.1995 / 11:16:58 / cg"
  1797     "Created: 20.11.1995 / 11:16:58 / cg"
  1797 !
  1798 !
  2639 ! !
  2640 ! !
  2640 
  2641 
  2641 !Array class methodsFor:'documentation'!
  2642 !Array class methodsFor:'documentation'!
  2642 
  2643 
  2643 version
  2644 version
  2644     ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.166 2015-04-20 14:04:23 cg Exp $'
  2645     ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.167 2015-04-22 17:27:19 stefan Exp $'
  2645 !
  2646 !
  2646 
  2647 
  2647 version_CVS
  2648 version_CVS
  2648     ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.166 2015-04-20 14:04:23 cg Exp $'
  2649     ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.167 2015-04-22 17:27:19 stefan Exp $'
  2649 ! !
  2650 ! !
       
  2651