void SList::applyL(void f(void*)) { SListElem* nexte; // to permit removing during iteration for (SListElem* e = headL(); e; e = nexte) { nexte = e->nextL(); f(e->dataL()); } }
void SList::removeL(void* p) { SListElem *e, *prev = NULL; for (e = headL(); e && e->dataL() != p; prev = e, e = e->nextL()) ; if (e == NULL) fatal("not in list"); removeAfterL(prev); assert(!includesL(p), "remove doesn't work"); }
list<double> Pst:: wordPlistConstruct(const ECString& head, int word_num) { list<double> ans; char temp[1024]; ECString headL(langAwareToLower(head.c_str(), temp)); const WordInfo* wi = useHeadC( headL ); if( wi ) { int sz = wi->stSize(); for( int i = 0 ; i < sz ; i ++ ) { Phsgt& wti = wi->st_[i]; int tInt = wti.term; if(tInt > Term::lastTagInt()) continue; double prob = psktt(head,tInt,word_num); ans.push_back(tInt); ans.push_back(prob); if(prob == 0) cerr << "Warning, prob = 0 for word = " << head << " and pos = " << tInt << endl; //cerr << "wordPlist: " << word << "\t" << tInt // << "\t" << prob << endl; } } else { for(int i = 0 ; i <= Term::lastTagInt() ; i++) { double phut = pHugt(i); if(phut == 0) continue; double prob = psutt(head,i,word_num); ans.push_back(i); ans.push_back(prob); } } return ans; }
void* SList::nthL(fint n) { assert(n < length(), "non-existing element"); SListElem* e = headL(); for (fint i = 0; i < n; i++, e = e->nextL()) ; return e->dataL(); }
SListElem* SList::findL(void* token, slistFindFn f) { for (SListElem* e = headL(); e; e = e->nextL()) { if (f(token, e->dataL())) return e; } return NULL; }
SListElem* SList::findL(void* p) { for (SListElem* e = headL(); e; e = e->nextL()) { if (e->dataL() == p) return e; } return NULL; }
void* removeHeadL() { assert(nonEmpty(), "removing from an empty list"); void* d = firstL(); _head = headL()->nextL(); if (--_len == 0) _tail = _head; return d; }
void* secondL() const { return headL()->nextL()->dataL(); }
void* firstL() const { return headL()->dataL(); }