Esempio n. 1
0
int
ptvequal(Ptv_t* a, Ptv_t* b)
{
	Ptvprefix_t*	ap;
	Ptvprefix_t*	bp;

	if (a == b)
		return 1;
	ap = (Ptvprefix_t*)dtfirst(a->dict);
	bp = (Ptvprefix_t*)dtfirst(b->dict);
	while (ap && bp)
	{
		if (fvcmp(a->size, ap->min, bp->min))
			return 0;
		if (fvcmp(a->size, ap->max, bp->max))
			return 0;
		ap = (Ptvprefix_t*)dtnext(a->dict, ap);
		bp = (Ptvprefix_t*)dtnext(b->dict, bp);
	}
	return !ap && !bp;
}
Esempio n. 2
0
Ptv_t*
ptvcover(Ptv_t* a, Ptv_t* b)
{
	Ptv_t*		t;
	Ptvprefix_t*	ap;
	Ptvprefix_t*	bp;

	if (!(t = ptvopen(a->disc, a->size)))
		return 0;
	ap = (Ptvprefix_t*)dtfirst(a->dict);
	bp = (Ptvprefix_t*)dtfirst(b->dict);
	while (ap && bp)
	{
		if (fvcmp(a->size, ap->min, bp->max) > 0)
			bp = (Ptvprefix_t*)dtnext(b->dict, bp);
		else
		{
			if (fvcmp(a->size, ap->max, bp->min) >= 0 && !ptvinsert(t, ap->min, ap->max))
				break;
			ap = (Ptvprefix_t*)dtnext(a->dict, ap);
		}
	}
	return t;
}