Array.st
changeset 15607 0dd001402209
parent 15061 fea9df1c613a
child 15608 de5bfe8d3a42
equal deleted inserted replaced
15606:96e492f47ec0 15607:0dd001402209
   277 
   277 
   278     ^ self == Array
   278     ^ self == Array
   279 
   279 
   280     "Modified: 23.4.1996 / 15:55:06 / cg"
   280     "Modified: 23.4.1996 / 15:55:06 / cg"
   281 ! !
   281 ! !
   282 
       
   283 
   282 
   284 !Array methodsFor:'accessing'!
   283 !Array methodsFor:'accessing'!
   285 
   284 
   286 at:index
   285 at:index
   287     "return the indexed instance variable with index, anInteger.
   286     "return the indexed instance variable with index, anInteger.
  1687 
  1686 
  1688 printOn:aStream
  1687 printOn:aStream
  1689     "append a printed representation of the receiver to aStream"
  1688     "append a printed representation of the receiver to aStream"
  1690 
  1689 
  1691     self isLiteral ifTrue:[
  1690     self isLiteral ifTrue:[
  1692 	|limit firstOne s|
  1691         |limit firstOne s|
  1693 
  1692 
  1694 	thisContext isRecursive ifTrue:[
  1693         thisContext isRecursive ifTrue:[
  1695 	    'Array [error]: printOn: of self referencing collection.' errorPrintCR.
  1694             'Array [error]: printOn: of self referencing collection.' errorPrintCR.
  1696 	    aStream nextPutAll:'#("recursive")'.
  1695             aStream nextPutAll:'#("recursive")'.
  1697 	    ^ self
  1696             ^ self
  1698 	].
  1697         ].
  1699 
  1698 
  1700 	aStream nextPutAll:'#('.
  1699         aStream nextPutAll:'#('.
  1701 	firstOne := true.
  1700         firstOne := true.
  1702 
  1701 
  1703 	"
  1702         "
  1704 	 if aStream is not positionable, create an temporary positionable stream
  1703          if aStream is not positionable, create an temporary positionable stream
  1705 	 (needed for limit calculation)
  1704          (needed for limit calculation)
  1706 	"
  1705         "
  1707 	aStream isPositionable ifTrue:[
  1706         aStream isPositionable ifTrue:[
  1708 	    s := aStream.
  1707             s := aStream.
  1709 	] ifFalse:[
  1708         ] ifFalse:[
  1710 	    s := WriteStream on:(String uninitializedNew:50).
  1709             s := WriteStream on:(String uninitializedNew:50).
  1711 	].
  1710         ].
  1712 	limit := s position1Based + self maxPrint.
  1711         limit := s position0Based + self maxPrint.
  1713 
  1712 
  1714 	self printElementsDo:[:element |
  1713         self printElementsDo:[:element |
  1715 	    firstOne ifFalse:[
  1714             firstOne ifFalse:[
  1716 		s space
  1715                 s space
  1717 	    ] ifTrue:[
  1716             ] ifTrue:[
  1718 		firstOne := false
  1717                 firstOne := false
  1719 	    ].
  1718             ].
  1720 	    (s position1Based >= limit) ifTrue:[
  1719             (s position0Based >= limit) ifTrue:[
  1721 		s ~~ aStream ifTrue:[
  1720                 s ~~ aStream ifTrue:[
  1722 		    aStream nextPutAll:(s contents).
  1721                     aStream nextPutAll:(s contents).
  1723 		].
  1722                 ].
  1724 		aStream nextPutAll:'...etc...)'.
  1723                 aStream nextPutAll:'...etc...)'.
  1725 		^ self
  1724                 ^ self
  1726 	    ] ifFalse:[
  1725             ] ifFalse:[
  1727 		element printOn:s.
  1726                 element printOn:s.
  1728 	    ].
  1727             ].
  1729 	].
  1728         ].
  1730 	s ~~ aStream ifTrue:[
  1729         s ~~ aStream ifTrue:[
  1731 	    aStream nextPutAll:(s contents).
  1730             aStream nextPutAll:(s contents).
  1732 	].
  1731         ].
  1733 	aStream nextPut:$)
  1732         aStream nextPut:$)
  1734     ] ifFalse:[
  1733     ] ifFalse:[
  1735 	super printOn:aStream
  1734         super printOn:aStream
  1736     ]
  1735     ]
  1737 
  1736 
  1738     "
  1737     "
  1739      #(1 2 $a 'hello' sym kewordSymbol:with: #'funny symbol') printString
  1738      #(1 2 $a 'hello' sym kewordSymbol:with: #'funny symbol') printString
  1740      #(1 2 $a [1 2 3] true false nil #true #false #nil) printString
  1739      #(1 2 $a [1 2 3] true false nil #true #false #nil) printString
  2578 ! !
  2577 ! !
  2579 
  2578 
  2580 !Array class methodsFor:'documentation'!
  2579 !Array class methodsFor:'documentation'!
  2581 
  2580 
  2582 version
  2581 version
  2583     ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.158 2013-04-04 07:55:57 cg Exp $'
  2582     ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.159 2013-08-10 09:38:41 stefan Exp $'
  2584 !
  2583 !
  2585 
  2584 
  2586 version_CVS
  2585 version_CVS
  2587     ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.158 2013-04-04 07:55:57 cg Exp $'
  2586     ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.159 2013-08-10 09:38:41 stefan Exp $'
  2588 ! !
  2587 ! !
  2589 
  2588