Overlapping rectangles.


R. Clayton (rclayton@monmouth.edu)
(no date)


  You mentioned that the source and destination rectangles may overlap: "The
  source and destination rectangles may overlap arbitrarily."

  In the case of an overlap do we need to be concerned with storing the data
  from the destination in a temp area before it is overwritten by our moves?

The code you generate is subject to two constraints: that it be correct (that
is, after the move instructions have been executed, that the original form of
the source rectangle be located at the destination rectangle) and that the
number of moves executed be as small as possible.

As you've discovered, some ways of overlapping the destination and source
rectangles can corrupt the source rectangle if you're not careful. Copying
(parts of) the source rectangle to a completely disjoint memory area is a way
around this problem, but you've got to keep your eye on the second constraint
too: does that technique lead to the smallest number of move statements
possible?

To answer your question: if copying (parts of) the source rectangle to a
disjoint area is the best way to solve this problem, then you need to be
concerned about it. If, however, there are correct and faster of solving the
problem using just the two original rectangles, then you can ignore it the
third, disjoint area technique. (You should not assume that it's an either-or
proposition. It may well be that the best answer depends on the way the source
and destination rectangles overlap.)



This archive was generated by hypermail 2.0b3 on Fri May 09 2003 - 15:30:05 EDT