void HandleHeap::finalizeWeakHandles() { Node* end = m_weakList.end(); for (Node* node = m_weakList.begin(); node != end; node = m_nextToFinalize) { m_nextToFinalize = node->next(); #if ENABLE(GC_VALIDATION) if (!isValidWeakNode(node)) CRASH(); #endif JSCell* cell = node->slot()->asCell(); if (Heap::isMarked(cell)) continue; if (WeakHandleOwner* weakOwner = node->weakOwner()) { weakOwner->finalize(Handle<Unknown>::wrapSlot(node->slot()), node->weakOwnerContext()); if (m_nextToFinalize != node->next()) // Owner deallocated node. continue; } #if ENABLE(GC_VALIDATION) if (!isLiveNode(node)) CRASH(); #endif *node->slot() = JSValue(); SentinelLinkedList<Node>::remove(node); m_immediateList.push(node); } m_nextToFinalize = 0; }
// Metodo para la eliminacion de nodos // @param x ID del nodo a buscar bool Queue::supr(char x) { // Precondicion if(!empty()){ // Inicializamos el puntero p Node *p = start; Node *q = NULL; // Buscamos el item if((q = search(x))) p = q->next(); // Verificamos si encontramos el item if(p && p->id() == x){ if(p == start){ // Eliminamos por el frente start = p->next(); } else { // Eliminamos por en medio q->next(p->next()); } // Eliminamos p delete p; _s--; // Restamos el tamaño de la cola // Retornamos true por eliminar el nodo return true; } } // Retornamos false por no eliminar ningun nodo return false; }
void List::erase(std::size_t pos) { if(m_size == 0 || pos >= m_size){ std::cout << "Fail" << std::endl; return; } if(m_size - 1 == 0){ delete m_ptrRoot; m_ptrRoot = m_ptrBack = nullptr; } if(pos == m_size - 1){ m_ptrBack = m_ptrBack->pred(); delete m_ptrBack->next(); m_ptrBack->set_next(nullptr); } else if(pos == 0){ m_ptrRoot = m_ptrRoot->next(); delete m_ptrRoot->pred(); m_ptrRoot->set_pred(nullptr); } else{ Node * ptr = m_ptrRoot; for(std::size_t i = 0; i <= pos; ++i) { if(i == pos){ ptr->pred()->set_next(ptr->next()); ptr->next()->set_pred(ptr->pred()); delete ptr; break; } ptr = ptr->next(); } } }
void insert(const char str[]) { Node *p = root; for (int i = 0, idx; str[i]; i++) { idx = toIndex(str[i]); if (p->next(idx) == NULL) p->change(idx, getNode()); p = p->next(idx); } p->cnt = 1; }
bool Dfa::match(const string &str) { Node* u = get_start(); auto len = str.length(); decltype(len) i; for(i=0;i<len;++i){ char c = static_cast<char>(str[i]); if(nullptr == u->next(c)) return false; u = u->next(c); } return u->is_end_node(); }
void LinkedList::Insert(Node *new_node) { if(!head_) { head_ = new_node; return; } Node *temp = head_; while(temp->next()) temp = temp->next(); temp->SetNext(new_node); new_node->SetNext(NULL); }
void Queue:: enqueue(Node * node) { if(m_base) { Node * aux = m_base; while (aux->next() && aux->frequency() < node->frequency()) { aux = aux->next(); } node->setNext(aux->next()); aux->setNext(node); } else { m_base = node; } ++m_count; }
int query(const char str[]) { Node *u = root, *p; int matched = 0; for (int i = 0, idx; str[i]; i++) { idx = toIndex(str[i]); while (u->next(idx) == NULL && u != root) u = u->fail; u = u->next(idx); u = (u == NULL) ? root : u; p = u; matched += p->val; } return matched; }
bool SceneGraph::save(char *filename, void (*callbackFn)(int nNode, void *info), void *callbackFnInfo) { ofstream outputFile(filename); if (!outputFile) return false; uninitialize(); outputFile << "#VRML V2.0 utf8" << endl; int nNode = 0; for (Node *node = Parser::getNodes(); node; node = node->next()) { node->output(outputFile, 0); nNode++; if (callbackFn) callbackFn(nNode, callbackFnInfo); } for (Route *route = Parser::getRoutes(); route; route = route->next()) { route->output(outputFile); } initialize(); return true; }
// Sync method. void qtractorTimeScale::sync ( const qtractorTimeScale& ts ) { // Copy master parameters... m_iSampleRate = ts.m_iSampleRate; m_iTicksPerBeat = ts.m_iTicksPerBeat; m_iPixelsPerBeat = ts.m_iPixelsPerBeat; // Copy location markers... m_markers.clear(); Marker *pMarker = ts.m_markers.first(); while (pMarker) { m_markers.append(new Marker(*pMarker)); pMarker = pMarker->next(); } m_markerCursor.reset(); // Copy tempo-map nodes... m_nodes.clear(); Node *pNode = ts.nodes().first(); while (pNode) { m_nodes.append(new Node(this, pNode->frame, pNode->tempo, pNode->beatType, pNode->beatsPerBar, pNode->beatDivisor)); pNode = pNode->next(); } m_cursor.reset(); updateScale(); }
void List::insert(std::size_t pos, int value) { if((m_size == 0 && pos != 0) || pos > m_size){ std::cout << "List null. Return (0)" << std::endl; return; } Node * node = new Node(value); if(pos == 0){ node->set_next(m_ptrRoot); m_ptrRoot->set_pred(node); m_ptrRoot = node; } else if(pos == m_size){ node->set_pred(m_ptrBack); m_ptrBack->set_next(node); m_ptrBack = node; } else{ Node * ptr = m_ptrRoot; for(std::size_t i = 0; i <= pos; ++i){ if(i == pos){ ptr->pred()->set_next(node); node->set_pred(ptr->pred()); ptr->set_pred(node); node->set_next(ptr); } ptr = ptr->next(); } } ++m_size; }
void Node::output(ostream& printStream, int indentLevet) { char *indentString = getIndentLevelString(indentLevet); if (isInstanceNode() == false) { outputHead(printStream, indentString); outputContext(printStream, indentString); if (!isElevationGridNode() && !isShapeNode() && !isSoundNode() && !isPointSetNode() && !isIndexedFaceSetNode() && !isIndexedLineSetNode() && !isTextNode() && !isAppearanceNode()) { if (getChildNodes() != NULL) { if (isLodNode()) printStream << indentString << "\tlevel [" << endl; else if (isSwitchNode()) printStream << indentString << "\tchoice [" << endl; else printStream << indentString <<"\tchildren [" << endl; for (Node *node = getChildNodes(); node; node = node->next()) { if (node->isInstanceNode() == false) node->output(printStream, indentLevet+2); else node->output(printStream, indentLevet+2); } printStream << indentString << "\t]" << endl; } } outputTail(printStream, indentString); } else printStream << indentString << "USE " << getName() << endl; delete indentString; }
void BB::computeExposedBlocks(BlockPRegBList* l) { // add all escaping blocks to l for (Node* n = first; n != last->next(); n = n->next()) { if (n->deleted) continue; n->computeExposedBlocks(l); } }
BOOL DiagramNew::OnInitDialog() { CDialog::OnInitDialog(); // TODO: この位置に初期化の補足処理を追加してください Node *eventNode; SendDlgItemMessage(IDC_DIAGRAM_EVENTTYPENAME, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0L); int nEvent = 0; for (eventNode = GetWorld()->getEventNodes(); eventNode; eventNode=eventNode->next()) { char listboxName[CTB_EVENTNAME_MAXLEN]; CEvent event(eventNode); char *eventName = event.getEventTypeName(); char *optionName = event.getEventOptionName(); if (optionName == NULL) strcpy(listboxName, eventName); else sprintf(listboxName, "%s - %s", eventName, optionName); SendDlgItemMessage(IDC_DIAGRAM_EVENTTYPENAME, CB_ADDSTRING, 0, (LONG)(LPSTR)listboxName); setListBoxString(nEvent++, listboxName); } SendDlgItemMessage(IDC_DIAGRAM_EVENTTYPENAME, CB_SELECTSTRING,(WPARAM)-1, (LPARAM)(LPCSTR)"Start"); return TRUE; // コントロールにフォーカスを設定しないとき、戻り値は TRUE となります // 例外: OCX プロパティ ページの戻り値は FALSE となります }
bool Middleware::advertise(RemotePublisher * pub) { Node * node; LocalSubscriber * waiting_subscriber; if (_remote_publishers == NULL) { _remote_publishers = pub; } else { pub->next(_remote_publishers); _remote_publishers = pub; } node = _nodes; while (node) { waiting_subscriber = node->queue(); while (waiting_subscriber != NULL) { if (compareTopics(pub->topic(), waiting_subscriber->topic())) { node->unqueueSubscriber(waiting_subscriber); node->remoteSubscribe(pub, waiting_subscriber); } waiting_subscriber = (LocalSubscriber *) waiting_subscriber->next(); } node = node->next(); } chSysLock(); chSchRescheduleS(); chSysUnlock(); return true; }
void Middleware::newNode(Node * n) { Node * node; if (_nodes == NULL ) { _nodes = n; return; } node = _nodes; while (node->next() != NULL) { node = node->next(); } node->next(n); }
void Node::setSceneGraph(SceneGraph *sceneGraph) { mSceneGraph = sceneGraph; for (Node *node = getChildNodes(); node; node = node->next()) { node->setSceneGraph(sceneGraph); } }
typename List<Type>::Iterator List<Type>::erase(Iterator first, Iterator last) { if (first == last) { return last; } // remove the element from [first] to [last] Node *previous = first.location()->previous(); for (Iterator iter = first; iter != last; ) { delete (iter++).location(); } previous->next() = last.location(); previous->next()->previous() = previous; return last; }
int SceneGraph::getNNodes() { int nNode = 0; for (Node *node = Parser::getNodes(); node; node = node->next()) nNode++; return nNode; }
bool SceneGraph::saveXML(const wchar_t *filename, void (*callbackFn)(int nNode, void *info), void *callbackFnInfo) { char nonsense[100]; wcstombs(nonsense,filename,100); std::ofstream outputFile(nonsense); if (!outputFile) return false; uninitialize(); outputFile << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl; outputFile << "<X3D>" << std::endl; outputFile << "<Scene>" << std::endl; int nNode = 0; for (Node *node = getNodes(); node; node = node->next()) { node->outputXML(outputFile, 0); nNode++; if (callbackFn) callbackFn(nNode, callbackFnInfo); } for (Route *route = getRoutes(); route; route = route->next()) { route->outputXML(outputFile); } initialize(); outputFile << "</Scene>" << std::endl; outputFile << "</X3D>" << std::endl; return true; }
int SceneGraph::getNNodes() const { int nNode = 0; for (Node *node = getNodes(); node; node = node->next()) nNode++; return nNode; }
bool SceneGraph::save(const wchar_t *filename, void (*callbackFn)(int nNode, void *info), void *callbackFnInfo) { char nonsense[100]; wcstombs(nonsense, filename, 100); std::ofstream outputFile(nonsense); if (!outputFile) return false; uninitialize(); outputFile << "#VRML V2.0 utf8" << std::endl; int nNode = 0; for (Node *node = getNodes(); node; node = node->next()) { node->output(outputFile, 0); nNode++; if (callbackFn) callbackFn(nNode, callbackFnInfo); } for (Route *route = getRoutes(); route; route = route->next()) { route->output(outputFile); } initialize(); return true; }
void LinkedList::PrintList() { Node *temp = head_; while (temp) { printf("%d\n", temp->key()); temp = temp->next(); } }
Geometry3DNode *Node::getGeometry3DNode() const { for (Node *node = getChildNodes(); node != NULL; node = node->next()) { if (node->isGeometry3DNode()) return (Geometry3DNode *)node; } return NULL; }
/** * \brief Searches iteratively for the node at the given position (starts from 1) * \return The node at the given position */ Node* search_node(int pos) { Node* res = head_m; while (pos > 1 && res != nil) { --pos; res = res->next(); } return res; }
/** * \brief Iteratively prints the list. Print nil if empty or end of list */ void print_list(std::ostream& os = std::cout) { Node* cur = head_m; while (cur != nil) { os << cur->elem() << " <-> "; cur = cur->next(); } os << "nil <-> head" << endl; }
bool reachable(Node * bl) { for(Node * curr = head; curr != NULL; curr = curr->next()) { assert(curr->list() == this); if(bl == curr) return true; } return false; }
GroupingNode *Node::getGroupingNodes() const { for (Node *node = getChildNodes(); node != NULL; node = node->next()) { if (node->isGroupingNode()) return (GroupingNode *)node; } return NULL; }
TextureNode *Node::getTextureNode() const { for (Node *node = getChildNodes(); node != NULL; node = node->next()) { if (node->isTextureNode()) return (TextureNode *)node; } return NULL; }
inline void sanityCheckClosed() { #if (DEBUG_MERGE == 1) if(closed && _rc > 0 && AOMergeable<N>::_pop > 0 && AOMergeable<N>::_pop <= N/2) { assert(_fragListNode.list()); } for(Node * node = FragManager<N>::getHead(); node; node = node->next()) { if(!node->data->isClosed()) return; } if(!closed) { for(Node * node = FragManager<N>::getHead(); node; node = node->next()) { fprintf(stderr,"%p\n",node->data); } abort(); } #endif }