293 |
293 |
294 anElement |
294 anElement |
295 "return any element from the collection, or nil if there is none" |
295 "return any element from the collection, or nil if there is none" |
296 |
296 |
297 self do: [:each | ^ each]. |
297 self do: [:each | ^ each]. |
298 ^ nil |
298 self emptyCollectionError. |
|
299 "/ ^ nil |
299 ! |
300 ! |
300 |
301 |
301 atAll:indexCollection put:anObject |
302 atAll:indexCollection put:anObject |
302 "put anObject into all indexes from indexCollection in the receiver. |
303 "put anObject into all indexes from indexCollection in the receiver. |
303 This abstract implementation requires that the receiver supports |
304 This abstract implementation requires that the receiver supports |
1860 !Collection methodsFor:'printing & storing'! |
1861 !Collection methodsFor:'printing & storing'! |
1861 |
1862 |
1862 displayString |
1863 displayString |
1863 "return a printed representation of the receiver for display in inspectors etc." |
1864 "return a printed representation of the receiver for display in inspectors etc." |
1864 |
1865 |
1865 |thisString buffer count string noneYet total limit| |
1866 |thisString buffer noneYet total limit| |
1866 |
1867 |
1867 thisContext isRecursive ifTrue:[ |
1868 thisContext isRecursive ifTrue:[ |
1868 'Collection [error]: displayString of self referencing collection.' errorPrintCR. |
1869 'Collection [error]: displayString of self referencing collection.' errorPrintCR. |
1869 ^ '#("recursive")' |
1870 ^ '#("recursive")' |
1870 ]. |
1871 ]. |
1871 |
1872 |
1872 string := self displayStringName , '('. |
1873 buffer := '' writeStream. |
|
1874 buffer nextPutAll:(self displayStringName); nextPutAll:'('. |
1873 noneYet := true. |
1875 noneYet := true. |
1874 buffer := ''. |
|
1875 count := 0. |
|
1876 total := 0. |
1876 total := 0. |
1877 limit := self maxPrint. |
1877 limit := self maxPrint. |
1878 |
1878 |
1879 self printElementsDo: [:element | |
1879 self printElementsDo: [:element | |
1880 thisString := element displayString. |
1880 thisString := element displayString. |
1881 noneYet ifTrue:[ |
1881 noneYet ifTrue:[ |
1882 noneYet := false. |
1882 noneYet := false. |
1883 buffer := buffer , thisString |
|
1884 ] ifFalse:[ |
1883 ] ifFalse:[ |
1885 buffer := buffer , (' ' , thisString) |
1884 buffer space |
1886 ]. |
1885 ]. |
1887 count := count + 1. |
1886 buffer nextPutAll:thisString. |
1888 (count == 20) ifTrue:[ |
|
1889 string := string , buffer. |
|
1890 buffer := ''. |
|
1891 count := 0 |
|
1892 ]. |
|
1893 total := total + 1. |
1887 total := total + 1. |
1894 (total > limit) ifTrue:[ |
1888 (total > limit) ifTrue:[ |
1895 string := string , buffer , '... )'. |
1889 buffer nextPutAll:'... )'. |
1896 ^ string |
1890 ^ buffer contents |
1897 ] |
1891 ] |
1898 ]. |
1892 ]. |
1899 string := string , buffer , ')'. |
1893 buffer nextPutAll:')'. |
1900 ^ string |
1894 ^ buffer contents |
1901 |
1895 |
1902 " |
1896 " |
1903 #(1 2 3 'hello' $a) asOrderedCollection displayString |
1897 #(1 2 3 'hello' $a) asOrderedCollection displayString |
1904 |
1898 |
1905 (Dictionary new at:#hello put:'world'; |
1899 (Dictionary new at:#hello put:'world'; |