xp_comm_proj/rd_dicom/Papyrus3/PapyList3.c
/********************************************************************************/
/*										*/
/*	InsertGroupInList : Create a new Item containing a group. The insertion	*/
/* 	criteria is that the group numbers are increasing.			*/
/*	return : The created cell if OK, NULL otherwise				*/
/*										*/
/********************************************************************************/
InsertGroupInList : Create a new Item containing a group. The insertion
criteria is that the group numbers are increasing.
return : The created cell if OK, NULL otherwise
InsertGroupInList : Create a new Item containing a group . The insertion criteria is that the group numbers are increasing . return : The created cell if OK NULL otherwise
Papy_List *
InsertGroupInList (Papy_List **ioListP, Object *inElemToInsertP)
{
  Papy_List	*theWrk1P, *theWrk2P, *theNewCellP;
  if (inElemToInsertP->whoAmI != papGroup) return NULL;
  if ((theNewCellP = (Papy_List *) emalloc3 ((PapyULong) sizeof (Papy_List))) == NULL)
    return NULL;
  theNewCellP->object = inElemToInsertP;
  theNewCellP->next   = NULL;
  if ((*ioListP == NULL) || 
      ((*ioListP)->object->group->group > theNewCellP->object->group->group))
  {
    theNewCellP->next = *ioListP;
    *ioListP          = theNewCellP;
  }
  else 
  {
    theWrk1P = *ioListP;
    theWrk2P = *ioListP;
    while ((theWrk1P != NULL) && 
    	   (theWrk1P->object->group->group < theNewCellP->object->group->group))
    {
      theWrk2P = theWrk1P;
      theWrk1P = theWrk1P->next;
    } 
    theNewCellP->next = theWrk1P;
    theWrk2P->next    = theNewCellP;
  } 
  return theNewCellP;
}
Papy_List * InsertGroupInList ( Papy_List * * ioListP , Object * inElemToInsertP ) { Papy_List * theWrk1P , * theWrk2P , * theNewCellP ; if ( inElemToInsertP -> whoAmI != papGroup ) return NULL ; if ( ( theNewCellP = ( Papy_List * ) emalloc3 ( ( PapyULong ) sizeof ( Papy_List ) ) ) == NULL ) return NULL ; theNewCellP -> object = inElemToInsertP ; theNewCellP -> next = NULL ; if ( ( * ioListP == NULL ) || ( ( * ioListP ) -> object -> group -> group > theNewCellP -> object -> group -> group ) ) { theNewCellP -> next = * ioListP ; * ioListP = theNewCellP ; } else { theWrk1P = * ioListP ; theWrk2P = * ioListP ; while ( ( theWrk1P != NULL ) && ( theWrk1P -> object -> group -> group < theNewCellP -> object -> group -> group ) ) { theWrk2P = theWrk1P ; theWrk1P = theWrk1P -> next ; } theNewCellP -> next = theWrk1P ; theWrk2P -> next = theNewCellP ; } return theNewCellP ; }
InsertGroupInList : Create a new Item containing a group.
InsertGroupInList : Create a new Item containing a group .
/* verify it is a group */ /* create the new cell and put the Object in */ /* if the ioListP is empty */ /* look for the insertion point, i.e. compares the group numbers */ /* while */ /* insert the new element */ /* else */