//finds the next list with the first element being a value //with a string that matches the specified string. Updates //the position of the cursor to point to that node CLTANode* CLTANodeIterator::FindNextList(const char* pszValue) { //go through all the lists do { CLTANode* pCurr = NextList(); //make sure we didn't hit the end of the list if(pCurr == NULL) { return NULL; } //see if this list has elements if(pCurr->GetNumElements() > 0) { //see if this first element is a 0 CLTANode* pValue = pCurr->GetElement(0); if(pValue->IsAtom()) { //now we can see if the strings match if(stricmp(pValue->GetValue(), pszValue) == 0) { return pCurr; } } } }while(1); return NULL; }
/*************************************************************************** * * * 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; }
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; }
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; }
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; }