CTSTR LocaleStringLookup::LookupString(CTSTR lookupVal) { StringLookupNode *child = FindNode(lookupVal); if(!child) return TEXT("(string not found)"); if(!child->leaf) return TEXT("(lookup error)"); return child->leaf->strValue; }
VOID Map<K,V,KeyElementTraits, ValueElementTraits, ThreadingModel>::Add( CONST K& Key, CONST V& Value ) { Node* pNode = FindNode(Key); if( pNode == 0 ) { m_NodeCount++; Insert( Key, Value ); } else pNode->m_Value = Value; }
string XMLFile::Get( const string& path ) { xmlNodePtr cur; // Look for the Node cur = FindNode( path ); if( cur ) { // Found the path return NodeToString(xmlPtr,cur);; } else { return ""; } }
BOOL Map<K,V,KeyElementTraits, ValueElementTraits, ThreadingModel>::Remove( CONST K& Key ) { Node* pNode = FindNode(Key); if (pNode == 0) return false; m_NodeCount--; Delete(pNode); return true; }
MySensorsBase::_tMySensorNode* MySensorsBase::InsertNode(const int nodeID) { _tMySensorNode mNode; mNode.nodeID = nodeID; mNode.SketchName = "Unknown"; mNode.SketchVersion = "1.0"; mNode.lastreceived = time(NULL); m_nodes[mNode.nodeID] = mNode; Add2Database(mNode.nodeID, mNode.SketchName, mNode.SketchVersion); return FindNode(nodeID); }
void * AllocNodeIdx( nodearray *list, unsigned index ) /***********************************************************/ { if( list->num < index ) { list->num = index; while( ARRAY_NUM(index - 1) > list->arraymax ) { AllocNewArray( list ); } } return FindNode( list, index ); }
void CTopologyNodeList::Delete (CTopologyNode *pNode) // Delete // // Delete the given node { int iIndex; if (FindNode(pNode, &iIndex)) m_List.Delete(iIndex); }
void XMLFile::Set( const string& path, const int value ) { // Convert the int to a string before saving it. string stringvalue; stringstream val_ss; val_ss << value; val_ss >> stringvalue; LogMsg(INFO,"Overriding Option['%s'] from '%s' to '%s'",path.c_str(),Get(path).c_str(),stringvalue.c_str()); xmlNodePtr p = FindNode(path,true); xmlNodeSetContent(p, BAD_CAST stringvalue.c_str() ); assert( stringvalue == Get(path)); }
BOOL Set<K,ElementTraits>::Remove( CONST K& Key ) { Node* pNode = FindNode(Key); if (pNode == 0) return false; m_NodeCount--; Delete(pNode); return true; }
Node* FindValue(HashTable* hashTable, char* key) { if(hashTable != NULL) { int hashOffset = GenerateHash((char*)key) % hashTable->totalBucketCount; if(hashTable->nodeTable[hashOffset] != NULL) { return FindNode(hashTable->nodeTable[hashOffset], key); } } return NULL; }
//----------------------------------------------------------------------------- bool ConicModel::Read(TiXmlNode* node) { TiXmlNode* sensor = FindNode(node,"sensor"); TiXmlNode* image_size = FindNode(sensor,"image_size"); m_width = ReadNodeAs<unsigned int>(image_size,"width"); m_height= ReadNodeAs<unsigned int>(image_size,"height"); TiXmlNode* ppa = FindNode(sensor,"ppa"); m_cPPA = ReadNodeAs<double>(ppa,"c"); m_lPPA = ReadNodeAs<double>(ppa,"l"); m_focal= ReadNodeAs<double>(ppa,"focale"); TiXmlNode* disto = FindNode(sensor,"distortion"); if(m_distortion) delete m_distortion; if(disto) { m_distortion = new DistortionPolynom; m_distortion->Read(disto); } return true; }
node* Script::FindNode(block_type nodeType, node* start) const { if (start == NULL) start = fRootNode; if (start->type == nodeType) return const_cast<node*>(start); node_list::const_iterator i; for (i = start->children.begin(); i != start->children.end(); i++) { node *n = FindNode(nodeType, *i); if (n != NULL) return n; } if (start->next != NULL) return FindNode(nodeType, start->next); return NULL; }
SpatialGraphKDNode* SpatialGraph::FindNode(SpatialGraphKDNode* node, const BoundingBox& bbox) { if (node == NULL) return NULL; //check if this bbox fits entirely within our node if (node->BBox.Contains(bbox) == Within) { //Check our children SpatialGraphKDNode* retVal = FindNode(node->LHC, bbox ); if (retVal != NULL) return retVal; retVal = FindNode(node->RHC, bbox); if( retVal != NULL ) return retVal; //otherwise, return ourselves return node; } return NULL; }
SpatialGraphKDNode* SpatialGraph::FindNode(SpatialGraphKDNode* node, const Vector2& point) { if (node == NULL) return NULL; //check if this bbox fits entirely within our node if (node->BBox.Contains(point)) { //Check our children SpatialGraphKDNode* retVal = FindNode(node->LHC, point ); if (retVal != NULL) return retVal; retVal = FindNode(node->RHC, point); if( retVal != NULL ) return retVal; //otherwise, return ourselves return node; } return NULL; }
node* FullFindNode(HWND hwnd) { unsigned short tag; node *found; for (tag=0; tag<TAGS; tag++) { found = FindNode(hwnd, tag); if (found) return found; } return NULL; }
void PCB_TEXT::Parse( XNODE* aNode, int aLayer, wxString aDefaultMeasurementUnit, wxString aActualConversion ) { XNODE* lNode; wxString str; m_PCadLayer = aLayer; m_KiCadLayer = GetKiCadLayer(); m_positionX = 0; m_positionY = 0; m_name.mirror = 0; // Normal, not mirrored lNode = FindNode( aNode, wxT( "pt" ) ); if( lNode ) SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_positionX, &m_positionY, aActualConversion ); lNode = FindNode( aNode, wxT( "rotation" ) ); if( lNode ) { str = lNode->GetNodeContent(); str.Trim( false ); m_rotation = StrToInt1Units( str ); } aNode->GetAttribute( wxT( "Name" ), &m_name.text ); str = FindNodeGetContent( aNode, wxT( "isFlipped" ) ); if( str == wxT( "True" ) ) m_name.mirror = 1; lNode = FindNode( aNode, wxT( "textStyleRef" ) ); if( lNode ) SetFontProperty( lNode, &m_name, aDefaultMeasurementUnit, aActualConversion ); }
void SetFontProperty( XNODE* aNode, TTEXTVALUE* aTextValue, wxString aDefaultMeasurementUnit, wxString aActualConversion ) { wxString n, propValue; aNode->GetAttribute( wxT( "Name" ), &n ); while( aNode->GetName() != wxT( "www.lura.sk" ) ) aNode = aNode->GetParent(); aNode = FindNode( aNode, wxT( "library" ) ); if( aNode ) aNode = FindNode( aNode, wxT( "textStyleDef" ) ); if( aNode ) { while( true ) { aNode->GetAttribute( wxT( "Name" ), &propValue ); propValue.Trim( false ); propValue.Trim( true ); if( propValue == n ) break; aNode = aNode->GetNext(); } if( aNode ) { aNode = FindNode( aNode, wxT( "font" ) ); if( aNode ) { if( FindNode( aNode, wxT( "fontHeight" ) ) ) // // SetWidth(iNode.ChildNodes.FindNode('fontHeight').Text, // // DefaultMeasurementUnit,tv.TextHeight); // Fixed By Lubo, 02/2008 SetHeight( FindNode( aNode, wxT( "fontHeight" ) )->GetNodeContent(), aDefaultMeasurementUnit, &aTextValue->textHeight, aActualConversion ); if( FindNode( aNode, wxT( "strokeWidth" ) ) ) SetWidth( FindNode( aNode, wxT( "strokeWidth" ) )->GetNodeContent(), aDefaultMeasurementUnit, &aTextValue->textstrokeWidth, aActualConversion ); } } } }
/************************************************************************** //Function: DelData //Description: 根据关键字删除一条记录 //Calls: //Called by: //Input: tKey 记录关键字 //Output: //Return: 返回值 说明 0 成功 负值 失败 //Others: //Author: fanyh Email: [email protected] //Date: 2008-06-16 **************************************************************************/ int DelData(CMiniCache *cache, map_key_t tKey) { pthread_mutex_lock(&cache->lock); CMiniCacheNode *pOldNode = NULL; if(0==FindNode(cache, tKey, &pOldNode)) { DelNode(cache, pOldNode, 1); } pthread_mutex_unlock(&cache->lock); return 0; }
GUIProgressBar::GUIProgressBar(xml_node<>* node) : GUIObject(node) { xml_attribute<>* attr; xml_node<>* child; mEmptyBar = NULL; mFullBar = NULL; mLastPos = 0; mSlide = 0.0; mSlideInc = 0.0; if (!node) { LOGERR("GUIProgressBar created without XML node\n"); return; } child = FindNode(node, "resource"); if (child) { mEmptyBar = LoadAttrImage(child, "empty"); mFullBar = LoadAttrImage(child, "full"); } // Load the placement LoadPlacement(FindNode(node, "placement"), &mRenderX, &mRenderY); // Load the data child = FindNode(node, "data"); if (child) { mMinValVar = LoadAttrString(child, "min"); mMaxValVar = LoadAttrString(child, "max"); mCurValVar = LoadAttrString(child, "name"); } mRenderW = mEmptyBar->GetWidth(); mRenderH = mEmptyBar->GetHeight(); }
int Trees::BuildTree(int start, int end, Node* &proot, Node* parent) { int tmp = 0; proot = NodesofTheTrees[CurTree]->at(start); proot->Parent = parent; tmp = FindNode(start+2,end,proot->Depth+1); if(tmp != -1) { BuildTree(start+1, tmp-1, proot->LeftC, proot); BuildTree(tmp, end, proot->RightC, proot); } return 0; }
unsigned long Trie_Get(TTrie *hTrie, unsigned long key) { LOG("[%s():%d] key=%08X\n", __func__, __LINE__, key); assert(hTrie->isDead == false); TNode *root = hTrie->root; const unsigned int dir = key & 0x1; assert(root->childNode[dir] != NULL); TNode *node = FindNode(root->childNode[dir], key, KEY_LEN); assert(node != NULL); return node->value; }
void BomKeyNode::addComponent(MapNode *pNode) { MapNode *mn; KeyValNode *kvn; StringNode *svn; mn = FindNode(pNode, "pid"); if(mn->nodeType() == 2) { kvn = (KeyValNode *) mn; svn = (StringNode*) kvn->value(); //printf("Bom: %s\n", svn->value()); buildItem(svn->value(),(KeyValNode*) pNode); } mList->append(pNode); }
BOOL CTxParamString::SetSubNodeString( LPCTSTR szRoot, CTxParamString& subParamIn ) { if (!subParamIn.m_bInited) { ASSERT(FALSE); return FALSE; } BOOL bRet = FALSE; if (szRoot == NULL) { //return all m_kvData = subParamIn.m_kvData; m_bInited = TRUE; bRet = TRUE; } else { std::vector<std::string> vOut; SplitteStrings(szRoot, vOut, '\\'); if (vOut.size() == 0 || vOut[0].compare(".") != 0) { _RPT1(0, TEXT("path not illegual, %s"), szRoot); } else { VECSTRINGS tmpPath; for (size_t i = 0; i < vOut.size(); ++i) { tmpPath.push_back(vOut[i].c_str()); } ST_MARKITEM* pItem =FindNode(tmpPath); if (pItem) { MAPKEYVALUE& mapchild = pItem->mapChildItem; MAPKEYVALUE& subChild = subParamIn.m_kvData.mapChildItem; MAPKEYVALUE::iterator itcb = subChild.begin(); MAPKEYVALUE::iterator itce = subChild.end(); for (; itcb != itce; ++itcb) { mapchild[itcb->first] = itcb->second; } m_bInited = TRUE; bRet = TRUE; } } } return bRet; }
void ERSHdrNode::Set( const char *pszPath, const char *pszValue ) { CPLString osPath = pszPath; size_t iDot = osPath.find_first_of('.'); /* -------------------------------------------------------------------- */ /* We have an intermediate node, find or create it and */ /* recurse. */ /* -------------------------------------------------------------------- */ if( iDot != std::string::npos ) { CPLString osPathFirst = osPath.substr(0,iDot); CPLString osPathRest = osPath.substr(iDot+1); ERSHdrNode *poFirst = FindNode( osPathFirst ); if( poFirst == nullptr ) { poFirst = new ERSHdrNode(); MakeSpace(); papszItemName[nItemCount] = CPLStrdup(osPathFirst); papszItemValue[nItemCount] = nullptr; papoItemChild[nItemCount] = poFirst; nItemCount++; } poFirst->Set( osPathRest, pszValue ); return; } /* -------------------------------------------------------------------- */ /* This is the final item name. Find or create it. */ /* -------------------------------------------------------------------- */ for( int i = 0; i < nItemCount; i++ ) { if( EQUAL(osPath,papszItemName[i]) && papszItemValue[i] != nullptr ) { CPLFree( papszItemValue[i] ); papszItemValue[i] = CPLStrdup( pszValue ); return; } } MakeSpace(); papszItemName[nItemCount] = CPLStrdup(osPath); papszItemValue[nItemCount] = CPLStrdup(pszValue); papoItemChild[nItemCount] = nullptr; nItemCount++; }
/* ==================== exportSkin ==================== */ bool G3DAExport::exportSkin(INode* i_node) { // get the modifier Modifier *modifier = getModifier(i_node,SKIN_CLASSID); if(modifier==NULL)return false; // get the skin interface ISkin* i_skin = (ISkin*)modifier->GetInterface(I_SKIN); if(i_skin == NULL) return false; // get the skin context data ISkinContextData* i_skin_context_data = i_skin->GetContextInterface(i_node); if(i_skin_context_data == NULL) return false; // process the bones std::vector<INode*>bones; int num_points = i_skin_context_data->GetNumPoints(); for (int i = 0; i < num_points; i++) { // get the number of bones that control this vertex int num_bones = i_skin_context_data->GetNumAssignedBones(i); for (int j = 0; j < num_bones; j++) { // get the assigned bone of the point INode* i_bone_node = i_skin->GetBone(i_skin_context_data->GetAssignedBone(i, j)); MAX_CHECK(i_bone_node != NULL); // add the bone node to the table std::vector<INode*>::iterator it = std::find(bones.begin(), bones.end(), i_bone_node); if(it==bones.end())bones.push_back(i_bone_node); } } // include all of the bone for (int i = 0; i < bones.size(); i++) { NODE *x = FindNode(mRoot, bones[i]) ; x->include = true; if(x->include) { NODE* parent = x->parent; while(parent) { parent->include = true; parent = parent->parent; } } } return true; }
void SetTextParameters( XNODE* aNode, TTEXTVALUE* aTextValue, wxString aDefaultMeasurementUnit, wxString aActualConversion ) { XNODE* tNode; wxString str; tNode = FindNode( aNode, wxT( "pt" ) ); if( tNode ) SetPosition( tNode->GetNodeContent(), aDefaultMeasurementUnit, &aTextValue->textPositionX, &aTextValue->textPositionY, aActualConversion ); tNode = FindNode( aNode, wxT( "rotation" ) ); if( tNode ) { str = tNode->GetNodeContent(); str.Trim( false ); aTextValue->textRotation = StrToInt1Units( str ); } str = FindNodeGetContent( aNode, wxT( "isVisible" ) ); if( str == wxT( "True" ) ) aTextValue->textIsVisible = 1; else if( str == wxT( "False" ) ) aTextValue->textIsVisible = 0; tNode = FindNode( aNode, wxT( "textStyleRef" ) ); if( tNode ) SetFontProperty( tNode, aTextValue, aDefaultMeasurementUnit, aActualConversion ); }
int main() { memset(used,false,sizeof(used)); for (int i=2;i<=100000;i++) if (!used[i]) { prime[++prime[0]]=i; int j=i+i; while (j<=100000) {used[j]=true;j+=i;} } for (int i=1;i<=prime[0];i++) CreateNode(); int n,m; scanf("%d%d",&n,&m); for (int pos=1;pos<=n;pos++) { int x,y;scanf("%d",&x);y=x; for (int i=1;(i<=prime[0])&&(prime[i]*prime[i]<=y);i++) if ((x%prime[i])==0) { while ((x%prime[i])==0) x/=prime[i]; InsertNode(i,1,n,pos,y); } if (x>1) InsertNode(FindPrimePos(x),1,n,pos,y); } while (m--) { int G,x,y,Ans_Max=-1,Ans_Occur=-1,Ans_Current=-1;scanf("%d%d%d",&G,&x,&y);int g=G; for (int i=1;(i<=prime[0])&&(prime[i]*prime[i]<=g);i++) if ((G%prime[i])==0) { while ((G%prime[i])==0) G/=prime[i]; FindNode(i,1,n,x,y,Ans_Max,Ans_Occur,Ans_Current,i); } if (G>1) FindNode(FindPrimePos(G),1,n,x,y,Ans_Max,Ans_Occur,Ans_Current,FindPrimePos(G)); printf("%d %d\n",Ans_Max,Ans_Occur); } return 0; }
bool RemoveNode(char name[], List head_node) { List previous_node = FindNode(name, head_node); // Verifies if the node that should be removed doesn't exist. if(previous_node->next && strcmp(name, previous_node->next->student.name) == 0) { List remove_auxiliar = previous_node->next; previous_node->next = previous_node->next->next; free(remove_auxiliar); return true; } else { printf("Nome inexistente: \"%s\"\n", name); return false; } }
/* get next item from list */ MemPtr ListNext ( LinkedList list, /* list handler */ MemPtr item /* list item */ ) { ListNode* node; node = FindNode( list, item ); if ( node != NULL && node->next != NULL ) return node->next->data; else return NULL; }
static segnode *FindSegNode( orl_sec_handle sechdl ) /***************************************************/ { orl_table_index idx; if( sechdl == NULL ) return( NULL ); idx = ORLCvtSecHdlToIdx( sechdl ); if( idx == 0 ) { return( NULL ); } else { return( FindNode( SegNodes, idx ) ); } }