Last updated at 3:04 am UTC on 24 July 2005
Work in progress please be patient (wiz).
Reverse provides a way to reorder a list.
The idea behind FlipRotate is to provide a way to generate any reordering of a list that can be produced by a combination of rotations and reversals.
So for a list of size n there are 2n reorderings.
The basic implementation of this is in SequentialCollection>flipRotated: aReorderingIndex.
- Mathamatically two reversals will give a rotation so the lsb is the filp index.
- The basic implemention wishes to work for all numbers at indexes so it wraps.
- 2n=0 is the identity element.
- When no change is called for the original receiver is returned.
- All other fliprotations return a modified copy (of the species) of the object.
- 2n-1=-1 is the index equivalent to reverse.
- 2i is the ith rotation and give a list that starts with the ith element.
Why FlipRotate is needed.
There are several places in Squeak where you have a list in one order and you want it in another.
- The rotation and reflection of rectanges require rearranging the order of the corners for the benifit of warpblt.
- Balloon help needs flexibility in where to add the speach tail around the text rectangle. Corners need to be rearranged.
- Color wheels. The very name suggests they want to be rotated.
- Closed polygons are like wheels they want to be rotated too.
- (Especially once fixed to be truly closed curves.)
- Then it is possible to easily open them anywhere.
- Integers have shift operations this is a shift operation for collections and lists.
- Trust me once its in squeak you'll be able to find dozens of uses for it.
The programming goal that lead to the discovery of a need for fliprotate was a desire to create kaleidoscopes.
FlipRotate greatly simplified getting all the rotations and reflections of a rectangle and clarified the code in many places.
Coming soon - where to get the changeset.