void Lexicon::findStatus(const char*& letter, LexNode*& pNode, Lexicon::Status& status) { ++letter; //look at next letter int index = *letter - A_IN_ASCII; //find new index if(pNode->children_[index] != NULL) //if that letter exists as a child of current node { ++letter; //move to next letter if((*letter) == '\000') //if that letter is a null character { --letter; //move to previous letter if(!pNode->children_[(*letter) - A_IN_ASCII]->isWord_) //if child node is not a word { status = Lexicon::WORD_PREFIX; //then its a word prefix } else { status = Lexicon::WORD; //otherwise its a word } } else //if it isnt a null character { --letter; //move to previous letter findStatus(letter, pNode->children_[index], status);//and recurse on it, and its parent node } } }
void clearStatus(afs_uint32 taskId, afs_uint32 flags) { statusP ptr; ObtainWriteLock(&statusQueueLock); ptr = findStatus(taskId); if (ptr == 0) { ReleaseWriteLock(&statusQueueLock); return; } ptr->flags &= ~flags; ReleaseWriteLock(&statusQueueLock); }
void EditStatus(List &L,status x) { address p=L.first; string s; if(L.first==NULL) { cout<<"Data Kosong"<<endl; } else if (p!=NULL) { findStatus(L,x); cout<<"Masukkan Status: "; cin>>s; p->infos.stats=s; cout<<"Status Berhasil Diedit"; }
Lexicon::Status Lexicon::wordStatus(string word) { const char* charWord = word.c_str(); //convert word to char string Lexicon::Status retval = Lexicon::NOT_WORD; //set retval to NOT_WORD int index = *charWord - A_IN_ASCII; //find index if((*charWord) <= 'z' && (*charWord) >= 'a') { if(word.size() == 1) //if a single letter is played { if(lexicon_[index] != NULL) //check if any words begin with that letter { retval = WORD_PREFIX; //if so, return word prefix } } else if(lexicon_[index] != NULL) //if a character exists at that index { findStatus(charWord, lexicon_[index], retval);//find the status of the word } } return retval; }