Anyone else want these in trunk? Anyone not want these in trunk?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Anyone else want these in trunk? Anyone not want these in trunk?

Eliot Miranda-2

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


Reply | Threaded
Open this post in threaded view
|

Re: Anyone else want these in trunk? Anyone not want these in trunk?

Chris Muller-3
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 <[hidden email]> 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 + 1) = 0] whileFalse:
[s nextPut: index]]
_,,,^..^,,,_
best, Eliot



Reply | Threaded
Open this post in threaded view
|

Re: Anyone else want these in trunk? Anyone not want these in trunk?

Ron Teitelbaum
'this is great' indicesOfSubCollection: 'is' #(3 6)

:)
Ron

On Fri, Jul 31, 2020 at 4:59 PM Chris Muller <[hidden email]> 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 <[hidden email]> 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 + 1) = 0] whileFalse:
[s nextPut: index]]
_,,,^..^,,,_
best, Eliot