1969 #[1 2 3 4] startsWithAnyOf:#( #(1 3) #(1 2)) |
1969 #[1 2 3 4] startsWithAnyOf:#( #(1 3) #(1 2)) |
1970 " |
1970 " |
1971 ! ! |
1971 ! ! |
1972 |
1972 |
1973 !SequenceableCollection methodsFor:'converting'! |
1973 !SequenceableCollection methodsFor:'converting'! |
|
1974 |
|
1975 asCollectionOfSubCollectionsOfSize:pieceSize |
|
1976 "return a collection containing pieces of size pieceSite from the receiver. |
|
1977 The last piece may be smaller, if the receivers size is not a multiple of pieceSize." |
|
1978 |
|
1979 |pieces |
|
1980 start "{ Class:SmallInteger }" |
|
1981 stop "{ Class:SmallInteger }" |
|
1982 mySize "{ Class:SmallInteger }"| |
|
1983 |
|
1984 pieces := OrderedCollection new. |
|
1985 start := 1. stop := start + pieceSize - 1. |
|
1986 mySize := self size. |
|
1987 [stop <= mySize] whileTrue:[ |
|
1988 pieces add:(self copyFrom:start to:stop). |
|
1989 start := start + pieceSize. |
|
1990 stop := stop + pieceSize. |
|
1991 ]. |
|
1992 (start <= mySize) ifTrue:[ |
|
1993 pieces add:(self copyFrom:start to:mySize). |
|
1994 ]. |
|
1995 ^ pieces |
|
1996 |
|
1997 " |
|
1998 '123123123123123123' asCollectionOfSubCollectionsOfSize:3 |
|
1999 '12312312312312312312' asCollectionOfSubCollectionsOfSize:3 |
|
2000 " |
|
2001 ! |
1974 |
2002 |
1975 asCollectionOfSubCollectionsSeparatedBy:anElement |
2003 asCollectionOfSubCollectionsSeparatedBy:anElement |
1976 "return a collection containing the subcollections (separated by anElement) |
2004 "return a collection containing the subcollections (separated by anElement) |
1977 of the receiver. If anElement occurs multiple times in a row, |
2005 of the receiver. If anElement occurs multiple times in a row, |
1978 the result will contain empty collections. |
2006 the result will contain empty collections. |