The Inbox: Collections-pre.679.mcz

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

The Inbox: Collections-pre.679.mcz

commits-2
A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-pre.679.mcz

==================== Summary ====================

Name: Collections-pre.679
Author: pre
Time: 26 February 2016, 4:04:56.205127 pm
UUID: 2ac5821c-d6f5-418c-ab07-ed3c2b9de62c
Ancestors: Collections-eem.678

This is a new iteration method which allows the iteration over asymmetric pairs. I have found this useful in game collision detections or duplicate detections. Alternatively we might want to take a second collection as input and create asymmetric pairs from self and this second collection.

=============== Diff against Collections-eem.678 ===============

Item was added:
+ ----- Method: Collection>>asymmetricPairsDo: (in category 'accessing') -----
+ asymmetricPairsDo: aBlock
+
+ | iterationCollection currentElement |
+ iterationCollection := self copy.
+
+ [currentElement := iterationCollection anyOne.
+ iterationCollection remove: currentElement.
+ iterationCollection isEmpty not]
+ whileTrue: [ iterationCollection
+ do: [:element | aBlock value: currentElement value: element]].!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Collections-pre.679.mcz

Nicolas Cellier
But this already exist, at least for SequenceableCollection, try:

(1 to: 4) combinations: 2 atATimeDo: [:e | Transcript cr; show: e printString]

2016-02-26 16:05 GMT+01:00 <[hidden email]>:
A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-pre.679.mcz

==================== Summary ====================

Name: Collections-pre.679
Author: pre
Time: 26 February 2016, 4:04:56.205127 pm
UUID: 2ac5821c-d6f5-418c-ab07-ed3c2b9de62c
Ancestors: Collections-eem.678

This is a new iteration method which allows the iteration over asymmetric pairs. I have found this useful in game collision detections or duplicate detections. Alternatively we might want to take a second collection as input and create asymmetric pairs from self and this second collection.

=============== Diff against Collections-eem.678 ===============

Item was added:
+ ----- Method: Collection>>asymmetricPairsDo: (in category 'accessing') -----
+ asymmetricPairsDo: aBlock
+
+       | iterationCollection currentElement |
+       iterationCollection := self copy.
+
+       [currentElement := iterationCollection anyOne.
+       iterationCollection remove: currentElement.
+       iterationCollection isEmpty not]
+               whileTrue: [ iterationCollection
+                       do: [:element | aBlock value: currentElement value: element]].!





Reply | Threaded
Open this post in threaded view
|

AW: [squeak-dev] The Inbox: Collections-pre.679.mcz

Patrick R.

Oh! Cool. :)


Well then the only proposition I have is adding it to the abstract collection class as iterating over combinations is not specific to a sequenceable collection. Or am I missing something here?


Von: [hidden email] <[hidden email]> im Auftrag von Nicolas Cellier <[hidden email]>
Gesendet: Freitag, 26. Februar 2016 19:31
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] The Inbox: Collections-pre.679.mcz
 
But this already exist, at least for SequenceableCollection, try:

(1 to: 4) combinations: 2 atATimeDo: [:e | Transcript cr; show: e printString]

2016-02-26 16:05 GMT+01:00 <[hidden email]>:
A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-pre.679.mcz

==================== Summary ====================

Name: Collections-pre.679
Author: pre
Time: 26 February 2016, 4:04:56.205127 pm
UUID: 2ac5821c-d6f5-418c-ab07-ed3c2b9de62c
Ancestors: Collections-eem.678

This is a new iteration method which allows the iteration over asymmetric pairs. I have found this useful in game collision detections or duplicate detections. Alternatively we might want to take a second collection as input and create asymmetric pairs from self and this second collection.

=============== Diff against Collections-eem.678 ===============

Item was added:
+ ----- Method: Collection>>asymmetricPairsDo: (in category 'accessing') -----
+ asymmetricPairsDo: aBlock
+
+       | iterationCollection currentElement |
+       iterationCollection := self copy.
+
+       [currentElement := iterationCollection anyOne.
+       iterationCollection remove: currentElement.
+       iterationCollection isEmpty not]
+               whileTrue: [ iterationCollection
+                       do: [:element | aBlock value: currentElement value: element]].!





Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Collections-pre.679.mcz

Nicolas Cellier


2016-02-27 16:36 GMT+01:00 Rein, Patrick <[hidden email]>:

Oh! Cool. :)


Well then the only proposition I have is adding it to the abstract collection class as iterating over combinations is not specific to a sequenceable collection. Or am I missing something here?


Yes, you are right, but current implementation rely on indexing from 1 to self size...
Generalization is trivial if we tolerate storing subcollections in an Array even if we iterate on a Set,
   ^self asArray combinations: n atATimeDo: aBlock
If we insist on storing subcollections in self species, that may require a greater effort.


Von: [hidden email] <[hidden email]> im Auftrag von Nicolas Cellier <[hidden email]>
Gesendet: Freitag, 26. Februar 2016 19:31
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] The Inbox: Collections-pre.679.mcz
 
But this already exist, at least for SequenceableCollection, try:

(1 to: 4) combinations: 2 atATimeDo: [:e | Transcript cr; show: e printString]

2016-02-26 16:05 GMT+01:00 <[hidden email]>:
A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-pre.679.mcz

==================== Summary ====================

Name: Collections-pre.679
Author: pre
Time: 26 February 2016, 4:04:56.205127 pm
UUID: 2ac5821c-d6f5-418c-ab07-ed3c2b9de62c
Ancestors: Collections-eem.678

This is a new iteration method which allows the iteration over asymmetric pairs. I have found this useful in game collision detections or duplicate detections. Alternatively we might want to take a second collection as input and create asymmetric pairs from self and this second collection.

=============== Diff against Collections-eem.678 ===============

Item was added:
+ ----- Method: Collection>>asymmetricPairsDo: (in category 'accessing') -----
+ asymmetricPairsDo: aBlock
+
+       | iterationCollection currentElement |
+       iterationCollection := self copy.
+
+       [currentElement := iterationCollection anyOne.
+       iterationCollection remove: currentElement.
+       iterationCollection isEmpty not]
+               whileTrue: [ iterationCollection
+                       do: [:element | aBlock value: currentElement value: element]].!









Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Collections-pre.679.mcz

Karl Ramberg
In reply to this post by commits-2
I experimented with a bouncing atoms kind of system where atoms could collide and change direction. 
I sorted atoms based on vertical position and tested collisions with a subset based on vertical position.
Then I could keep the collision testing to only a small number of atoms.

Best,
Karl

On Fri, Feb 26, 2016 at 4:05 PM, <[hidden email]> wrote:
A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-pre.679.mcz

==================== Summary ====================

Name: Collections-pre.679
Author: pre
Time: 26 February 2016, 4:04:56.205127 pm
UUID: 2ac5821c-d6f5-418c-ab07-ed3c2b9de62c
Ancestors: Collections-eem.678

This is a new iteration method which allows the iteration over asymmetric pairs. I have found this useful in game collision detections or duplicate detections. Alternatively we might want to take a second collection as input and create asymmetric pairs from self and this second collection.

=============== Diff against Collections-eem.678 ===============

Item was added:
+ ----- Method: Collection>>asymmetricPairsDo: (in category 'accessing') -----
+ asymmetricPairsDo: aBlock
+
+       | iterationCollection currentElement |
+       iterationCollection := self copy.
+
+       [currentElement := iterationCollection anyOne.
+       iterationCollection remove: currentElement.
+       iterationCollection isEmpty not]
+               whileTrue: [ iterationCollection
+                       do: [:element | aBlock value: currentElement value: element]].!