85 static char rcsid[]
MTR_UNUSED =
"$Id: mtrGroup.c,v 1.18 2009/02/20 02:03:47 fabio Exp $";
128 if (root == NULL)
return(NULL);
177 if (low < (
unsigned int) root->
low ||
178 low + size > (
unsigned int) (root->
low + root->
size))
183 if (root->
size == size && root->
low == low) {
193 if (root->
child == NULL) {
195 if (newn == NULL)
return(NULL);
210 while (first != NULL && low >= (
unsigned int) (first->
low + first->
size)) {
219 if (newn == NULL)
return(NULL);
224 newn->
elder = previous;
230 if (low >= (
unsigned int) first->
low &&
231 low + size <= (
unsigned int) (first->
low + first->
size)) {
235 }
else if (low + size <= first->low) {
239 if (newn == NULL)
return(NULL);
245 newn->
elder = previous;
248 if (previous != NULL) {
254 }
else if (low < (
unsigned int) first->
low &&
255 low + size < (
unsigned int) (first->
low + first->
size)) {
258 }
else if (low > first->
low) {
269 while (last != NULL &&
270 (
unsigned int) (last->
low + last->
size) < low + size) {
277 if (newn == NULL)
return(NULL);
283 newn->
elder = previous;
286 if (previous != NULL) {
292 while (last != NULL) {
300 if (low + size - 1 >= (
unsigned int) last->
low &&
301 low + size < (
unsigned int) (last->
low + last->
size)) {
313 if (newn == NULL)
return(NULL);
319 if (previous == NULL) {
324 newn->
elder = previous;
331 for (node = first; node != NULL; node = node->
younger) {
365 if (parent == NULL)
return(NULL);
381 if (group == parent->
child) {
422 if (size < 1)
return(NULL);
427 if (low < (
unsigned int) root->
low ||
428 low + size > (
unsigned int) (root->
low + root->
size))
431 if (root->
size == size && root->
low == low)
434 if (root->
child == NULL)
441 while (low >= (
unsigned int) (node->
low + node->
size)) {
444 if (low + size <= (
unsigned int) (node->
low + node->
size)) {
479 if (second->
younger == first) {
483 }
else if (first->
younger != second) {
487 sizeFirst = first->
size;
488 sizeSecond = second->
size;
492 if (parent == NULL || second->
parent != parent)
return(0);
493 if (parent->
child == first) {
494 parent->
child = second;
503 first->
elder = second;
508 if (!
mtrShiftHL(second,-sizeFirst))
return(0);
546 #if SIZEOF_VOID_P == 8
547 if (!silent) (void) printf(
"(%u",root->
low);
549 if (!silent) (void) printf(
"(%hu",root->
low);
552 if (!silent) (void) printf(
",");
555 while (node != NULL) {
563 #if SIZEOF_VOID_P == 8
564 (void) printf(
"%u", root->
low + root->
size - 1);
566 (void) printf(
"%hu", root->
low + root->
size - 1);
575 if (root->
parent == NULL) (void) printf(
"\n");
621 char attrib[8*
sizeof(
unsigned int)+1];
625 if (root == NULL)
return NULL;
629 err = fscanf(fp,
"%d %d %s", &low, &size, attrib);
632 }
else if (err != 3) {
635 }
else if (low < 0 || low+size > nleaves || size < 1) {
649 for (c=attrib; *c != 0; c++) {
713 low = (int) node->
low;
723 auxnode = node->
child;
727 }
while (auxnode != NULL);
MtrNode * Mtr_InitGroupTree(int lower, int size)
unsigned short MtrHalfWord
MtrNode * Mtr_DissolveGroup(MtrNode *group)
void Mtr_FreeTree(MtrNode *node)
void Mtr_PrintGroups(MtrNode *root, int silent)
#define MTR_TEST(node, flag)
int Mtr_SwapGroups(MtrNode *first, MtrNode *second)
MtrNode * Mtr_MakeGroup(MtrNode *root, unsigned int low, unsigned int size, unsigned int flags)
#define ABC_NAMESPACE_IMPL_END
MtrNode * Mtr_AllocNode(void)
MtrNode * Mtr_FindGroup(MtrNode *root, unsigned int low, unsigned int size)
void Mtr_DeallocNode(MtrNode *node)
#define ABC_NAMESPACE_IMPL_START
MtrNode * Mtr_InitTree(void)
MtrNode * Mtr_ReadGroups(FILE *fp, int nleaves)
static ABC_NAMESPACE_IMPL_START char rcsid[] MTR_UNUSED
static int mtrShiftHL(MtrNode *node, int shift)