Commit 5f36cd85 authored by JP Rosevear's avatar JP Rosevear Committed by JP Rosevear

change interface to take a range pointer for the result and return a

1999-12-22  JP Rosevear  <jpr@arcavia.com>

	* src/ranges.c (range_intersection): change interface to take a
 	range pointer for the  result and return a boolean dictating
	whether or not the ranges actually intersect

	* src/ranges.h : update for new range_intersection interface
parent dbe9f33b
1999-12-22 JP Rosevear <jpr@arcavia.com>
* src/ranges.c (range_intersection): change interface to take a range
pointer for the result and return a boolean dictating whether or not
the ranges actually intersect
* src/ranges.h : update for new range_intersection interface
1999-12-22 JP Rosevear <jpr@arcavia.com>
* src/ranges.c (range_intersection): Clean to meet coding specs.
......
1999-12-22 JP Rosevear <jpr@arcavia.com>
* src/ranges.c (range_intersection): change interface to take a range
pointer for the result and return a boolean dictating whether or not
the ranges actually intersect
* src/ranges.h : update for new range_intersection interface
1999-12-22 JP Rosevear <jpr@arcavia.com>
* src/ranges.c (range_intersection): Clean to meet coding specs.
......
......@@ -717,30 +717,31 @@ range_fragment_free (GList *fragments)
/**
* range_intersection:
* @r: intersection range
* @a: range a
* @b: range b
*
* This computes the intersection; on a Venn
* diagram this would be A (upside down U) B
* NB. totally commutative.
*
* Return value: the intersection
* This computes the intersection of two ranges; on a Venn
* diagram this would be A (upside down U) B.
* If the ranges do not intersect, false is returned an the
* values of r are unpredictable.
*
* NB. totally commutative
*
* Return value: True if the ranges intersect, false otherwise
**/
Range
range_intersection (Range const *a, Range const *b)
gboolean
range_intersection (Range *r, Range const *a, Range const *b)
{
Range ans;
g_return_if_fail (range_overlap (a, b));
g_return_val_if_fail (range_overlap (a, b), FALSE);
ans.start.col = MAX (a->start.col, b->start.col);
ans.start.row = MAX (a->start.row, b->start.row);
r->start.col = MAX (a->start.col, b->start.col);
r->start.row = MAX (a->start.row, b->start.row);
ans.end.col = MIN (a->end.col, b->end.col);
ans.end.row = MIN (a->end.row, b->end.row);
r->end.col = MIN (a->end.col, b->end.col);
r->end.row = MIN (a->end.row, b->end.row);
/* Make sure this is an actual intersection */
return ans;
return TRUE;
}
/**
......
......@@ -55,7 +55,9 @@ gboolean range_overlap (Range const *a, Range const *b);
gboolean range_contained (Range const *a, Range const *b);
gboolean range_adjacent (Range const *a, Range const *b);
Range range_merge (Range const *a, Range const *b);
Range range_intersection (Range const *a, Range const *b);
gboolean range_intersection (Range *r,
Range const *a,
Range const *b);
Range range_union (Range const *a, Range const *b);
gboolean range_translate (Range *range, int col_offset, int row_offset);
gboolean range_expand (Range *range, int d_tlx, int d_tly, int d_brx, int d_bry);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment