src/stringmap/split_l.cpp
static void RTreePigeonhole(struct PartitionVars *P)
{
	register struct PartitionVars *p = P;
	struct Rect newCover[2];
	register int i, group;
	RectReal newArea[2], increase[2];

	for (i=0; i<NODECARD+1; i++)
	{
		if (!p->taken[i])
		{
			/* if one group too full, put rect in the other */
			if (p->count[0] >= p->total - p->minfill)
			{
				RTreeClassify(i, 1, p);
				continue;
			}
			else if (p->count[1] >= p->total - p->minfill)
			{
				RTreeClassify(i, 0, p);
				continue;
			}

			/* find areas of the two groups' old and new covers */
			for (group=0; group<2; group++)
			{
				if (p->count[group]>0)
					newCover[group] = RTreeCombineRect(
						&BranchBuf[i].rect,
						&p->cover[group]);
				else
					newCover[group] = BranchBuf[i].rect;
				newArea[group] = RTreeRectSphericalVolume(
							&newCover[group]);
				increase[group] = newArea[group]-p->area[group];
			}

			/* put rect in group whose cover will expand less */
			if (increase[0] < increase[1])
				RTreeClassify(i, 0, p);
			else if (increase[1] < increase[0])
				RTreeClassify(i, 1, p);

			/* put rect in group that will have a smaller cover */
			else if (p->area[0] < p->area[1])
				RTreeClassify(i, 0, p);
			else if (p->area[1] < p->area[0])
				RTreeClassify(i, 1, p);

			/* put rect in group with fewer elements */
			else if (p->count[0] < p->count[1])
				RTreeClassify(i, 0, p);
			else
				RTreeClassify(i, 1, p);
		}
	}
	assert(p->count[0] + p->count[1] == NODECARD + 1);
}
/*-----------------------------------------------------------------------------
| Put each rect that is not already in a group into a group.
| Process one rect at a time, using the following hierarchy of criteria.
| In case of a tie, go to the next test.
| 1) If one group already has the max number of elements that will allow
| the minimum fill for the other group, put r in the other.
| 2) Put r in the group whose cover will expand less.  This automatically
| takes care of the case where one group cover contains r.
| 3) Put r in the group whose cover will be smaller.  This takes care of the
| case where r is contained in both covers.
| 4) Put r in the group with fewer elements.
| 5) Put in group 1 (arbitrary).
|
| Also update the covers for both groups.
-----------------------------------------------------------------------------*/
| Put each rect that is not already in a group into a group.
| Process one rect at a time, using the following hierarchy of criteria.
| In case of a tie, go to the next test.
| 1) If one group already has the max number of elements that will allow
| the minimum fill for the other group, put r in the other.
| 2) Put r in the group whose cover will expand less.  This automatically
| takes care of the case where one group cover contains r.
| 3) Put r in the group whose cover will be smaller.  This takes care of the
| case where r is contained in both covers.
| 4) Put r in the group with fewer elements.
| 5) Put in group 1 (arbitrary).
|
| Also update the covers for both groups.
| Put each rect that is not already in a group into a group . | Process one rect at a time using the following hierarchy of criteria . | In case of a tie go to the next test . | 1 ) If one group already has the max number of elements that will allow | the minimum fill for the other group put r in the other . | 2 ) Put r in the group whose cover will expand less . This automatically | takes care of the case where one group cover contains r . | 3 ) Put r in the group whose cover will be smaller . This takes care of the | case where r is contained in both covers . | 4 ) Put r in the group with fewer elements . | 5 ) Put in group 1 ( arbitrary ) . | | Also update the covers for both groups .
static void RTreePigeonhole(struct PartitionVars *P)
{
	register struct PartitionVars *p = P;
	struct Rect newCover[2];
	register int i, group;
	RectReal newArea[2], increase[2];
	for (i=0; i<NODECARD+1; i++)
	{
		if (!p->taken[i])
		{
			if (p->count[0] >= p->total - p->minfill)
			{
				RTreeClassify(i, 1, p);
				continue;
			}
			else if (p->count[1] >= p->total - p->minfill)
			{
				RTreeClassify(i, 0, p);
				continue;
			}
			for (group=0; group<2; group++)
			{
				if (p->count[group]>0)
					newCover[group] = RTreeCombineRect(
						&BranchBuf[i].rect,
						&p->cover[group]);
				else
					newCover[group] = BranchBuf[i].rect;
				newArea[group] = RTreeRectSphericalVolume(
							&newCover[group]);
				increase[group] = newArea[group]-p->area[group];
			}
			if (increase[0] < increase[1])
				RTreeClassify(i, 0, p);
			else if (increase[1] < increase[0])
				RTreeClassify(i, 1, p);
			else if (p->area[0] < p->area[1])
				RTreeClassify(i, 0, p);
			else if (p->area[1] < p->area[0])
				RTreeClassify(i, 1, p);
			else if (p->count[0] < p->count[1])
				RTreeClassify(i, 0, p);
			else
				RTreeClassify(i, 1, p);
		}
	}
	assert(p->count[0] + p->count[1] == NODECARD + 1);
}
static void RTreePigeonhole ( struct PartitionVars * P ) { register struct PartitionVars * p = P ; struct Rect newCover [ 2 ] ; register int i , group ; RectReal newArea [ 2 ] , increase [ 2 ] ; for ( i = 0 ; i < NODECARD + 1 ; i ++ ) { if ( ! p -> taken [ i ] ) { if ( p -> count [ 0 ] >= p -> total - p -> minfill ) { RTreeClassify ( i , 1 , p ) ; continue ; } else if ( p -> count [ 1 ] >= p -> total - p -> minfill ) { RTreeClassify ( i , 0 , p ) ; continue ; } for ( group = 0 ; group < 2 ; group ++ ) { if ( p -> count [ group ] > 0 ) newCover [ group ] = RTreeCombineRect ( & BranchBuf [ i ] . rect , & p -> cover [ group ] ) ; else newCover [ group ] = BranchBuf [ i ] . rect ; newArea [ group ] = RTreeRectSphericalVolume ( & newCover [ group ] ) ; increase [ group ] = newArea [ group ] - p -> area [ group ] ; } if ( increase [ 0 ] < increase [ 1 ] ) RTreeClassify ( i , 0 , p ) ; else if ( increase [ 1 ] < increase [ 0 ] ) RTreeClassify ( i , 1 , p ) ; else if ( p -> area [ 0 ] < p -> area [ 1 ] ) RTreeClassify ( i , 0 , p ) ; else if ( p -> area [ 1 ] < p -> area [ 0 ] ) RTreeClassify ( i , 1 , p ) ; else if ( p -> count [ 0 ] < p -> count [ 1 ] ) RTreeClassify ( i , 0 , p ) ; else RTreeClassify ( i , 1 , p ) ; } } assert ( p -> count [ 0 ] + p -> count [ 1 ] == NODECARD + 1 ) ; }
| Put each rect that is not already in a group into a group.
| Put each rect that is not already in a group into a group .
/* if one group too full, put rect in the other */ /* find areas of the two groups' old and new covers */ /* put rect in group whose cover will expand less */ /* put rect in group that will have a smaller cover */ /* put rect in group with fewer elements */