Example #1
0
/***************************************************************************
*									   *
* FUNCTION:	AppendList						   *
*									   *
*  PURPOSE:	Append a list to another one.				   *
*									   *
*   PARAMS:	The two lists to append.				   *
*									   *
*   RETURN:	The first list modified if successful.			   *
*		NULL else.						   *
*									   *
*  IMPORTS:	None							   *
*									   *
*    NOTES:	This function modify the first of lists passed,	appending  *
*		all the object of second list. It is assumed that the two  *
*		lists contain object of the same type.			   *
*		All the objects in L2 are inserted (if not presents) in L1.*
*									   *
***************************************************************************/
List AppendList(List L1, List L2)
{
 pointer object;

 if(!L1 || !L2) ErrorNULL("AppendList, not initialized List.\n");

 PushCurrList(L2);
 TailList(L2);
 while(NextList(&object, L2))
	if(!MemberList(object, L1)) InsertList(object, L2);
 PopCurrList(L2);
 return L1;
}
Example #2
0
List IntersectList(List L0, List L1)
{
 List InterList;
 pointer object;

 if(!L0 || !L1) ErrorNULL("IntersectList, not initialized List.\n");

 InterList=CopyList(L0);

 TailList(InterList);
 while(NextList(&object, InterList))
	if(!MemberList(object, L1)) DeleteList(object, InterList);

 return InterList;
}
Example #3
0
List UnionList(List L0, List L1)
{
 List UList;
 pointer object;

 if(!L0 || !L1) ErrorNULL("UnionList, not initialized List.\n");

 UList=CopyList(L0);

 TailList(L1);
 while(NextList(&object, L1))
	if(!MemberList(object, UList)) InsertList(object, UList);

 return UList;
}
Example #4
0
int AddNode(listPtr List, listnodePtr Node)
{
  if (List == NULL) return LLIST_NULL;

  switch (List->Flags & LISTADDMASK) 
    {
       case LISTADDCURR: return InsertList(List, Node); break;
       case LISTADDHEAD: return HeadList(List, Node); break;
       case LISTADDTAIL: return TailList(List, Node); break;
       case LISTADDSPLAY: return SplayInsertList(List, Node); break;
     default: return InsertList(List, Node); break; 
    }

  return LLIST_ERROR;
} /* AddNode() */
boolean oldMemberList(pointer object, List l)
{
 pointer scanobj;
 ListElem *TempCurrList=l->C;

 if(l->hash) return MemberHash(object, l);

 TailList(l);

 while(NextList(&scanobj, l))
   if(EqualObject(object, scanobj, l))
   {
    if(!PrevList(&scanobj, l)) HeadList(l);
    return TRUE;
   }

 l->C=TempCurrList;
 return FALSE;
}
boolean MemberList(pointer object, List l)     /* 10/Nov/92 */
{
 pointer scanobj;
 ListElem *TempCurrList=l->C;
 int i,n;

 if(l->hash) return MemberHash(object, l);

 TailList(l);
 n=CountList(l);
 for(i=0;i<n;i++)
  {
   NextList(&scanobj, l);
   if(EqualObject(object, scanobj, l))
   {
    if(!PrevList(&scanobj, l)) HeadList(l);    /* Take a step back for */
    return TRUE;			       /* right CurrList       */
   }
  }
 l->C=TempCurrList;
 return FALSE;
}