DataNode& DataNode::operator[](const WString& nodePath) { if (auto node = GetNode(nodePath)) return *node; return *AddNode(nodePath); }
void dgBroadPhaseDefault::LinkAggregate(dgBroadPhaseAggregate* const aggregate) { AddNode(aggregate); aggregate->m_broadPhase = this; aggregate->m_updateNode = m_updateList.Append(aggregate); aggregate->m_myAggregateNode = m_aggregateList.Append(aggregate); }
//添加元素,即节点 BOOL AddItem(const Item * pi,Tree * ptree) { Node * new_node;//新节点 if(TreeIsFull(ptree))//判断树是否已满 { fprintf(stderr,"Tree is full.\n"); return FALSE; } if(SeekItem(pi,ptree).child != NULL)//在树中查找目标项目 { fprintf(stderr,"Attempted to add duplicate item\n"); return FALSE; } new_node = MakeNode(pi);//创建新节点,成功返回新节点,否则返回NULL if(new_node == NULL)//创建失败,返回false { fprintf(stderr,"Couldn't create node!\n"); return FALSE; } //节点创建成功,向树中添加节点 ptree->size++;//树的大小加1 if(ptree->root == NULL)//如果树为空 { ptree->root = new_node; } else { AddNode(new_node,ptree->root);//找到新节点应该添加到的位置 } return TRUE; }
/*----------------------------------------------------------------------------- * ReadTransforms * Read a set of transforms from a string and transfer it into a file *-----------------------------------------------------------------------------*/ void ReadTransforms(char* buf, TransformList *list) { char type = ' '; char axis = ' '; int value = 0; char* p = buf; /* Read the buffer */ while(p != NULL) { /* Read the contents of the buffer */ sscanf(p, "%c%c %d", &type, &axis, &value); /* Define a new Transform */ Transform* t; if((t = malloc(sizeof(Transform))) == NULL) { perror("2D"); exit(EXIT_FAILURE); } t->type = type; t->axis = axis; t->value = value; /* Add it to the list */ AddNode(list, t); /* Scan for the next item */ p = strstr(p, ","); if(p != NULL) p += 1; } }
void CZQCustomClient::SendBuffer(pBlock block) { AddNode(block); if (!m_IsSending) ReadySendNextData(&m_SendData, 0); }
int CLocalNav::FindDirectPath(Vector &vecStepStart, Vector &vecDest, float flTargetRadius, BOOL fNoMonsters) { Vector vecActualDest; Vector vecPathDir; Vector vecNodeLoc; int nindexLast; vecPathDir = (vecDest - vecStepStart).Normalize(); vecActualDest = vecDest - (vecPathDir * flTargetRadius); if (PathTraversable(vecStepStart, vecActualDest, fNoMonsters) == TRAVERSABLE_NO) return -1; nindexLast = -1; vecNodeLoc = vecStepStart; m_nindexAvailableNode = 0; while ((vecNodeLoc - vecActualDest).Length2D() >= HOSTAGE_STEPSIZE) { vecNodeLoc = vecNodeLoc + (vecPathDir * HOSTAGE_STEPSIZE); nindexLast = AddNode(nindexLast, vecNodeLoc, 0, 0, 0); if (nindexLast == -1) break; } return nindexLast; }
void List::InsertAfter(void* iterPtr, void* objectPtr) { Node* node = new Node(); node->m_Ptr = objectPtr; AddNode(node, (Node*)iterPtr, ((Node*)iterPtr)->m_NextNode); }
void IntersectionNodesInAirport::AddNodes( const std::vector<IntersectionNode> newNodes ) { for(int i=0;i <(int)newNodes.size();i++) { AddNode(newNodes[i]); } }
CNeighbour* CNeighboursConnections::OnAccept(CNetworkConnection* pConn) { // TODO: Make new CNeighbour deriviate for handshaking with Gnutella clients systemLog.postLog(LogSeverity::Debug, "CNeighbours::OnAccept"); //qDebug() << "CNeighbours::OnAccept"; if(!m_bActive) { pConn->Close(); return 0; } if(!m_pSection.tryLock(50)) { systemLog.postLog(LogSeverity::Debug, "Not accepting incoming connection. Neighbours overloaded"); pConn->Close(); return 0; } CG2Node* pNew = new CG2Node(); pNew->AttachTo(pConn); AddNode(pNew); pNew->moveToThread(&NetworkThread); m_pSection.unlock(); return pNew; }
int main() { char ch[10],num[5]; LinkList head; head=CreatList(); printlist(head); printf(" Delete node (y/n):"); scanf("%s",num); if(strcmp(num,"y")==0||strcmp(num,"Y")==0) { printf("Please input Delete_data:"); scanf("%s",ch); DeleteList(head,ch); printlist(head); } printf("Add node ? (y/n): "); scanf("%s",ch); if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0) { head=AddNode(head); } printlist(head); system("pause"); DeleteAll(head); }
dSceneGraph::dSceneGraph(const dSceneGraph& me) :dTree<dGraphNode, unsigned>(), m_lru (0) { // add all nodes from me, Iterator iter (me); for (iter.Begin(); iter; iter ++) { dGraphNode& srcNode = iter.GetNode()->GetInfo(); AddNode (srcNode.m_nodeInfo, NULL); } //now connect all edges for (iter.Begin(); iter; iter ++) { dGraphNode& srcNode = iter.GetNode()->GetInfo(); dGraphNode& myNode = Find(srcNode.m_nodeInfo->GetUniqueID())->GetInfo(); for (dGraphNode::dLink::dListNode* srcEdge = srcNode.m_children.GetFirst(); srcEdge; srcEdge = srcEdge->GetNext()) { dGraphNode& srcLinkNode = srcEdge->GetInfo()->GetInfo(); dTreeNode* myLinkNode = Find(srcLinkNode.m_nodeInfo->GetUniqueID()); //myNode.m_children.Append(srcEdge->GetInfo()); myNode.m_children.Append(myLinkNode); } for (dGraphNode::dLink::dListNode* srcEdge = srcNode.m_parents.GetFirst(); srcEdge; srcEdge = srcEdge->GetNext()) { dGraphNode& srcLinkNode = srcEdge->GetInfo()->GetInfo(); dTreeNode* myLinkNode = Find(srcLinkNode.m_nodeInfo->GetUniqueID()); //myNode.m_parents.Append(srcEdge->GetInfo()); myNode.m_parents.Append(myLinkNode); } } m_rootNode = Find(me.GetRootNode()->GetInfo().GetNode()->GetUniqueID()); }
int InitTireTree(trie_tree_t* pttt, const char* str_table[], int size) { if (!pttt) { return -1; } trie_node_t* root = &pttt->root; memset(root->childs, 0, sizeof(root->childs)); int i; for (i = 0; i < size; ++i) { trie_node_t* pn = root; const char *one = str_table[i]; int len = strlen(one); int j; for (j = 0; j < len; ++j) { int ch = char_map(one[j]); if (!pn->childs[ch]) { (void)AddNode(pn, ch); } pn = pn->childs[ch]; } pn->end = 1; } return 0; }
void CTreeBuilder::ReadConfig() { int depth = 0; CTreeNode* pParentNode = NULL; CTreeNode* pCurrentNode = NULL; CTreeNode* pSiblings = NULL; string xmlLine; ifstream infile; infile.open (m_sFileName.c_str(), ifstream::in); while(infile.good()) { string test; getline(infile,xmlLine); if ( !xmlLine.empty()) { NodeDetails nodeDetails; string nodeName = "", nodeText = ""; ValidateTag(xmlLine, nodeDetails); pCurrentNode = AddNode(pCurrentNode, nodeDetails); } } infile.close(); }
void MGADSMTrajectory::AddNodes(const std::vector<TrajectoryNodePtr>& nodes) { for (std::size_t i = 0; i < nodes.size(); ++i) { AddNode(nodes[i]); } }
DepCompAstRefDAG(const DepCompAstRefAnal& stmtorder, const DepCompAstRefGraphCreate* g) { DoublyLinkedListWrap <DepCompAstRefGraphNode*> nodelist; DepCompAstRefGraphCreate::NodeIterator nodes = g->GetNodeIterator(); for ( ; !nodes.ReachEnd(); nodes.Advance()) { DepCompAstRefGraphNode* n = nodes.Current(); AddNode(n); nodelist.AppendLast(n); } if (nodelist.size() <= 1) return; for (nodes.Reset(); !nodes.ReachEnd(); nodes.Advance()) { DepCompAstRefGraphNode* n = *nodes; DepCompAstRef& info = n->GetInfo(); for (DepInfoEdgeIterator edges = g->GetNodeEdgeIterator(n, GraphAccess::EdgeOut); !edges.ReachEnd(); ++edges) { DepInfoEdge* e = *edges; DepCompAstRefGraphNode* n1 = g->GetEdgeEndPoint(e, GraphAccess::EdgeIn); DepCompAstRef& info1 = n1->GetInfo(); int c = stmtorder.CompareAstRef(info,info1); if (c < 0) { AddEdge(n, n1, e); } else if (c > 0) { AddEdge(n1,n,e); } } } if (DebugRefFuse()) { std::cerr << GraphToString(*this) << std::endl; } }
void Snake::Clear(void) { SnakeNode.clear(); length = 0; AddNode(25, 25); director = 1; }
static void PopulateNodes() { WUTIL_FUNC(pGetNumaNodeProcessorMask, BOOL, (UCHAR, PULONGLONG)); WUTIL_IMPORT_KERNEL32(GetNumaNodeProcessorMask, pGetNumaNodeProcessorMask); if(!pGetNumaNodeProcessorMask) return; DWORD_PTR processAffinity, systemAffinity; { const BOOL ok = GetProcessAffinityMask(GetCurrentProcess(), &processAffinity, &systemAffinity); WARN_IF_FALSE(ok); } ENSURE(PopulationCount(processAffinity) <= PopulationCount(systemAffinity)); for(UCHAR nodeNumber = 0; nodeNumber <= HighestNodeNumber(); nodeNumber++) { ULONGLONG affinity; { const BOOL ok = pGetNumaNodeProcessorMask(nodeNumber, &affinity); WARN_IF_FALSE(ok); } if(!affinity) continue; // empty node, skip Node* node = AddNode(); node->nodeNumber = nodeNumber; node->processorMask = wcpu_ProcessorMaskFromAffinity(processAffinity, (DWORD_PTR)affinity); } }
/* <4867dc> ../cstrike/dlls/hostage/hostage_localnav.cpp:413 */ node_index_t CLocalNav::FindDirectPath(Vector &vecStart, Vector &vecDest, float flTargetRadius, int fNoMonsters) { Vector vecActualDest; Vector vecPathDir; Vector vecNodeLoc; node_index_t nindexLast; vecPathDir = NormalizeSubtract<float_precision, float, float, float_precision>(vecStart, vecDest); vecActualDest = vecDest - (vecPathDir * flTargetRadius); if (PathTraversable(vecStart, vecActualDest, fNoMonsters) == PATH_TRAVERSABLE_EMPTY) { return -1; } nindexLast = -1; vecNodeLoc = vecStart; m_nindexAvailableNode = 0; while ((vecNodeLoc - vecActualDest).Length2D() >= HOSTAGE_STEPSIZE) { node_index_t nindexCurrent = nindexLast; vecNodeLoc = vecNodeLoc + (vecPathDir * HOSTAGE_STEPSIZE); nindexLast = AddNode(nindexCurrent, vecNodeLoc); if (nindexLast == -1) break; } return nindexLast; }
static Status InitTopology() { PopulateNodes(); #if ARCH_X86_X64 const SRAT* srat = (const SRAT*)acpi_GetTable("SRAT"); if(srat && AreApicIdsReliable()) { const ProximityDomains proximityDomains = ExtractProximityDomainsFromSRAT(srat); PopulateNodesFromProximityDomains(proximityDomains); } #endif // neither OS nor ACPI information is available if(numNodes == 0) { // add dummy node that contains all system processors Node* node = AddNode(); node->nodeNumber = 0; node->proximityDomainNumber = 0; node->processorMask = os_cpu_ProcessorMask(); } return INFO::OK; }
void CFrontendDlg::AddHna(unsigned int NetAddr, unsigned int NetMask, unsigned int NodeAddr, unsigned int VTime) { class NodeEntry NewEntry; POSITION Pos; unsigned __int64 Timeout; Timeout = Now + (unsigned __int64)VTimeToInt(VTime) * (unsigned __int64)10000000; AddNode(NodeAddr, VTime); NewEntry.Addr = NodeAddr; Pos = NodeList.Find(NewEntry); if (Pos == NULL) return; class NodeEntry &OldEntry = NodeList.GetAt(Pos); OldEntry.AddHna(NetAddr, NetMask, Timeout); m_TabCtrl.m_Dialog3.UpdateNodeInfo(NodeList); }
//向writer中添加s对应的ASCII码 void AddASCII(List writer, LPSTR s) { int i,len=(int)strlen(s); for(i=0;i<len;i++){ AddNode(writer,(void*)s[i]); } }
void CFrontendDlg::HandleOlsrTc(struct OlsrTc *Msg, int UseLq) { int Size; unsigned int *Addr; Msg->Header.SeqNo = ::ntohs(Msg->Header.SeqNo); Msg->Ansn = ::ntohs(Msg->Ansn); AddNode(Msg->Header.Orig, Msg->Header.VTime); Size = Msg->Header.Size; Size -= sizeof (struct OlsrTc); Addr = (unsigned int *)(Msg + 1); while (Size > 0) { Size -= 4; AddMpr(*Addr, Msg->Header.Orig, Msg->Header.VTime); Addr++; if (UseLq != 0) { Size -= 4; Addr++; } } }
bool PlaylistPicker::AddToList( const char* name, int weight ) { bool addedSuccesfully; PLDoubleLinkedListNode<SimplePlayListElement>* node; SimplePlayListElement* element; node = NULL; addedSuccesfully = false; element = new SimplePlayListElement(name); if (mFirstElement == NULL) mFirstElement = element->mElementName; Assert( element ); if ( element ) { element->mElementWeight = weight; node = new PLDoubleLinkedListNode<SimplePlayListElement>(element); Assert( node ); } if ( node ) addedSuccesfully = AddNode(node); return addedSuccesfully; }
double CalcProbability(extmanager MyManager, DdNode *Current) { DdNode *h, *l; hisnode *Found; char *curnode; double lvalue, hvalue, tvalue; if (params.debug) { curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); fprintf(stderr, "%s\n", curnode); } if (Current == MyManager.t) return 1.0; if (Current == MyManager.f) return 0.0; if ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) != NULL) return Found->dvalue; l = LowNodeOf(MyManager.manager, Current); h = HighNodeOf(MyManager.manager, Current); if (params.debug) fprintf(stderr, "l(%s)->", curnode); lvalue = CalcProbability(MyManager, l); if (params.debug) fprintf(stderr, "h(%s)->", curnode); hvalue = CalcProbability(MyManager, h); tvalue = MyManager.varmap.dvalue[GetIndex(Current) - MyManager.varmap.varstart]; tvalue = tvalue * hvalue + lvalue * (1.0 - tvalue); AddNode(MyManager.his, MyManager.varmap.varstart, Current, tvalue, 0, NULL); return tvalue; }
void Cvfgk::Reset() { char Dict[]={'A','C','G','T','N','\n','M','S','H','D','I', 'W','P','V','Y','F','L','K','R','Q','E','B', 'Z','X',' ','>','0','1','2','3','4','5','6','7','8','9', '-','_','+','\t','@','#',',','.','"','(',')','[',']', ctChangeLettersMode}; //char Dict[]={'A','C','G','T','N','\n',ctChangeLettersMode}; for(int i=0;i<2*ctAlphabetSize;i++){ child[i]=weight[i]=parent[i]=0; } root = 1; iNextNode = 2; for(int i=0;i<ctAlphabetSize;i++) leaf[i] = 0; child[root] = 0; weight[root] = 1; parent[root] = 0; leaf[ctZeroNode] = root; iStackPtr = 0; nBits = 0; // if(fByteOut!=NULL) fclose(fByteOut); fByteOut = NULL; iBytesWritten = 0; // start adding the characters with high probability for(int i=0;i<sizeof(Dict);i++){ AddNode(Dict[i]); Update(Dict[i]); } // increase p for nucleotides for(int i=0;i<5;i++) Update(Dict[i]); // By default its starts with capital letters fCapitalLetters = true; }
/* Function name : CXML::CreateCommentNode Description : This helper function creates a comment for the node supplied as argumnet Return type : bool Argument : IXMLDOMNode **pParentNode Argument : CString csComment */ bool CXML::CreateCommentNode(IXMLDOMNode **ppParentNode,CString &rcsComment) { if(rcsComment.IsEmpty()) return false; if(!(*ppParentNode)) return false; IXMLDOMNode * pNode = NULL; _variant_t vtNodeType((long)VT_I4,NODE_COMMENT); _bstr_t bstrNameSpace(""); m_hr = m_pXMLDoc->createNode(vtNodeType,bstrNameSpace,bstrNameSpace,&pNode); if(!SUCCEEDED(m_hr)) return false; _variant_t vtComment(rcsComment); m_hr = pNode->put_nodeValue(vtComment); if(!SUCCEEDED(m_hr)) { pNode->Release(); return false; } IXMLDOMNode * pINewNode = NULL; bool bRet = AddNode(&m_pICurrentNode,&pNode,&pINewNode,NODE_COMMENT); if(pNode) pNode->Release(); if(pINewNode) pINewNode->Release(); return bRet; }
void Dictionary::InnerCompress(const std::vector<int>& uncompressed) { prdc_lzw::LzwNode<int>* current_node = root_int.get(); //初期位置 unsigned int string_length = 1; std::vector<int> w; //複数回の圧縮で共通数字を出力するため、元のテキストを保存しておく //数値→文字列変換のための配列のサイズ設定 contents_int.reserve(max_dicsize + 256); for (auto it : uncompressed) { int c = it; //未圧縮の文字列から一文字取り出す w.push_back(c); prdc_lzw::LzwNode<int>* q = current_node->FindChild(c); if (q != NULL) { //辞書に文字列が追加されていたら current_node = q; //探索ノードを一つ進める string_length++; } else { compressed.push_back(current_node->get_data()); if (dict_size < max_dicsize && string_length < max_length) { AddNode(current_node, c); //current_nodeの下に文字cのノードを作成 contents_int.push_back(w); } //NOTE:圧縮文字列に0以下、または256以上の文字コードが入っていた場合エラーになる current_node = root_int.get()->FindChild(c); //最初から検索し直す if (current_node == NULL) { AddNode(root_int.get(), c); current_node = root_int.get()->FindChild(c); } w.clear(); w.push_back(c); string_length = 1; } } std::vector<std::vector<int>>(contents_int).swap(contents_int); compressed.push_back(current_node->get_data()); compressed.number_of_type = contents.size(); }
Bool InitDict(SQLIECompressInfo *pInfo) { PByte pbBuffer, pbEnd; ULong MaskCount, Index, DictLength; UInt32 CurrentByte; #if 0 pbBuffer = pInfo->pbBuffer; pbEnd = pInfo->pbEnd; ZeroStruct(pInfo); pInfo->pbBuffer = pbBuffer; pInfo->pbEnd = pbEnd; #else ZeroStruct(&pInfo->dict_6000); ZeroStruct(&pInfo->dict_6100); #endif pbBuffer = pInfo->dict_6200; for (Int32 i = 0, j = 0x03020100; i < 0x100; i += 4) { *(PUInt32)pbBuffer = j; pbBuffer += 4; j += 0x04040404; } MaskCount = 0; DictLength = 0; pbBuffer = pInfo->pbBuffer; pbEnd = pInfo->pbEnd; while (DictLength < 0x2000 && MaskCount < 200 && pbBuffer < pbEnd) { CurrentByte = *pbBuffer++; if (DictLength != 0) { Index = AddNode(pInfo, pInfo->dict_820C[DictLength - 2], CurrentByte); if (pInfo->dict_6000[Index] < 0xFF) ++pInfo->dict_6000[Index]; } pInfo->dict_820C[DictLength - 1] = CurrentByte; ++DictLength; if (pInfo->dict_6100[CurrentByte] == 0) { pInfo->dict_6100[CurrentByte] = 1; ++MaskCount; } } pInfo->DictLength = DictLength; pInfo->pbBuffer = pbBuffer; pInfo->pbEnd = pbEnd; return pbBuffer >= pbEnd; }
int main() {struct node *start=NULL; int n,q; int ch,m; while(1) {printf("\nMENU\n"); printf("\n1.Enter the two data at beg\n"); printf("\n2.Enter the 2 data at end"); printf("\n3.Enter yhe 2 data at betwn"); printf("\n4.Display the data"); printf("\n5.Exit"); printf("\nEnter the choice\n"); scanf("%d",&ch); switch(ch) {case 1: printf("Enter the the value\n"); scanf("%d %d",&n,&q); AddNode(n); AddNode(q); break; case 3: printf("Enter the data after which u have to insert\n"); scanf("%d",&m); printf("Enter the the value\n"); scanf("%d %d",&n,&q); Addbetwn(m,n); Addbetwn(m,q); break; case 2: printf("Enter the the value\n"); scanf("%d %d",&n,&q); Addend(n); Addend(q); break; case 4: DisplayNode(); break; case 5: printf("%c%c%c Thank You %c%c%c",5,5,5,5,5,5); break; default: printf("Wrong choice\n"); } } return 0; }
void dgBroadPhaseDefault::Add(dgBody* const body) { // create a new leaf node; dgAssert (!body->GetCollision()->IsType (dgCollision::dgCollisionNull_RTTI)); dgBroadPhaseBodyNode* const newNode = new (m_world->GetAllocator()) dgBroadPhaseBodyNode(body); newNode->m_updateNode = m_updateList.Append(newNode); AddNode(newNode); }