SequenceableCollection methods for accessing indicesOfSubCollection: aSubCollection "Answer an Array (possibly empty) of all the indices of aSubCollection in the receiver."
^self indicesOfSubCollection: aSubCollection startingAt: 1
indicesOfSubCollection: aSubCollection startingAt: initialIndex "Answer an Array (possibly empty) of all the indices of aSubCollection in the receiver starting at initialIndex. N.B. This does not (yet) use Boyer-Moore to skip over unnecessary alignments."
^Array streamContents: [:s| | index | index := initialIndex - 1. [(index := self indexOfSubCollection: aSubCollection startingAt: index + 1) = 0] whileFalse: [s nextPut: index]] _,,,^..^,,,_ best, Eliot
Hi Eliot,
I have no opinion about the inclusion of the methods, only about the variable name "aSubCollection". Anytime I see a variable named with prefix "a" or "an", I consider what follows to be a class in the system. In fact, the IDE does, too, which is why you can simply double-click on the argument and it'll open a browser on that class. Since "SubCollection" is already part of the selector, "aCollection" seems like it should be a fine argument. Otherwise, "subCollection" (as in the legacy method you're calling) or "aSequenceableCollection".
Best, Chris
On Fri, Jul 31, 2020 at 1:57 PM Eliot Miranda eliot.miranda@gmail.com wrote:
SequenceableCollection methods for accessing indicesOfSubCollection: aSubCollection "Answer an Array (possibly empty) of all the indices of aSubCollection in the receiver."
^self indicesOfSubCollection: aSubCollection startingAt: 1
indicesOfSubCollection: aSubCollection startingAt: initialIndex "Answer an Array (possibly empty) of all the indices of aSubCollection in the receiver starting at initialIndex. N.B. This does not (yet) use Boyer-Moore to skip over unnecessary alignments."
^Array streamContents: [:s| | index | index := initialIndex - 1. [(index := self indexOfSubCollection: aSubCollection startingAt: index +
- = 0] whileFalse:
[s nextPut: index]] _,,,^..^,,,_ best, Eliot
'this is great' indicesOfSubCollection: 'is' #(3 6)
:) Ron
On Fri, Jul 31, 2020 at 4:59 PM Chris Muller asqueaker@gmail.com wrote:
Hi Eliot,
I have no opinion about the inclusion of the methods, only about the variable name "aSubCollection". Anytime I see a variable named with prefix "a" or "an", I consider what follows to be a class in the system. In fact, the IDE does, too, which is why you can simply double-click on the argument and it'll open a browser on that class. Since "SubCollection" is already part of the selector, "aCollection" seems like it should be a fine argument. Otherwise, "subCollection" (as in the legacy method you're calling) or "aSequenceableCollection".
Best, Chris
On Fri, Jul 31, 2020 at 1:57 PM Eliot Miranda eliot.miranda@gmail.com wrote:
SequenceableCollection methods for accessing indicesOfSubCollection: aSubCollection "Answer an Array (possibly empty) of all the indices of aSubCollection in the receiver."
^self indicesOfSubCollection: aSubCollection startingAt: 1
indicesOfSubCollection: aSubCollection startingAt: initialIndex "Answer an Array (possibly empty) of all the indices of aSubCollection in the receiver starting at initialIndex. N.B. This does not (yet) use Boyer-Moore to skip over unnecessary alignments."
^Array streamContents: [:s| | index | index := initialIndex - 1. [(index := self indexOfSubCollection: aSubCollection startingAt: index +
- = 0] whileFalse:
[s nextPut: index]] _,,,^..^,,,_ best, Eliot
squeak-dev@lists.squeakfoundation.org