static unsigned bubble_up(heap_t heap, unsigned long i) { while (i > 1 && heap->cmp(heap_get(heap, parent_node(i)), heap_get(heap, i)) < 0) { heap_swap(heap, parent_node(i), i); i = parent_node(i); } return i; }
static int bubble_up(struct ast_heap *h, int i) { while (i > 1 && h->cmp_fn(heap_get(h, parent_node(i)), heap_get(h, i)) < 0) { heap_swap(h, i, parent_node(i)); i = parent_node(i); } return i; }
void heap_increase_key(Heap h, unsigned int idx, Hnode value){ g_assert(value.val > h[idx].val); h[idx] = value; while(idx > 1 && h[parent_node(idx)].val < h[idx].val){ Hnode temp; temp = h[idx]; h[idx] = h[parent_node(idx)]; h[parent_node(idx)] = temp; idx = parent_node(idx); } }
int register_one_node(int nid) { int error = 0; int cpu; if (node_online(nid)) { int p_node = parent_node(nid); struct node *parent = NULL; if (p_node != nid) parent = node_devices[p_node]; node_devices[nid] = kzalloc(sizeof(struct node), GFP_KERNEL); if (!node_devices[nid]) return -ENOMEM; error = register_node(node_devices[nid], nid, parent); /* link cpu under this node */ for_each_present_cpu(cpu) { if (cpu_to_node(cpu) == nid) register_cpu_under_node(cpu, nid); } /* link memory sections under this node */ error = link_mem_sections(nid); /* initialize work queue for memory hot plug */ init_node_hugetlb_work(nid); } return error; }
//------------------------------------------------------------------------------ bool TreeModelWrapper::iter_nth_child_vfunc(const iterator& parent, int n, iterator& iter) const { // dprint("%s\n", __FUNCTION__); // Sets @a iter to be the child of @a parent using the given index. The first // index is 0. If @a n is too big, or @a parent has no children, @a iter is set // to an invalid iterator and false is returned. // See also iter_nth_root_child_vfunc() bool ret = false; bec::NodeId parent_node(node_for_iter(parent)); // Invalidate iter_next reset_iter(iter); if (tm()) { if (parent_node.is_valid()) { const int children_count = tm()->count_children(parent_node); if (n >= 0 && children_count > 0 && n < children_count) { bec::NodeId child(tm()->get_child(parent_node, n)); if (child.is_valid()) { init_gtktreeiter(iter.gobj(), child); ret = true; // dprint("%s(parent->'%s', int n = %i, iter->'%s')\n", __FUNCTION__, parent_node.repr().c_str(), n, // child.repr().c_str()); } } } } return ret; }
int register_one_node(int nid) { int error = 0; int cpu; if (node_online(nid)) { int p_node = parent_node(nid); struct node *parent = NULL; if (p_node != nid) parent = &node_devices[p_node]; error = register_node(&node_devices[nid], nid, parent); /* link cpu under this node */ for_each_present_cpu(cpu) { if (cpu_to_node(cpu) == nid) register_cpu_under_node(cpu, nid); } /* link memory sections under this node */ error = link_mem_sections(nid); } return error; }
QModelIndex ProtoTreeModel::index(int row, int, const QModelIndex &parent) const { ProtoNode parent_node(root_node_); if (parent.isValid()) { // index is not a top level item. parent_node = protoNodeFromIndex(parent); } if (! parent_node.isValid() ) return QModelIndex(); int cur_row = 0; ProtoNode::ChildIterator kids = parent_node.children(); while ( kids.element().isValid() ) { if ( cur_row == row ) break; cur_row++; kids.next(); } if ( ! kids.element().isValid() ) { return QModelIndex(); } return createIndex(row, 0, static_cast<void *>(kids.element().protoNode())); }
int ast_heap_push(struct ast_heap *h, void *elm) #endif { int i; if (h->cur_len == h->avail_len && grow_heap(h #ifdef MALLOC_DEBUG , file, lineno, func #endif )) { return -1; } heap_set(h, ++(h->cur_len), elm); for (i = h->cur_len; i > 1 && h->cmp_fn(heap_get(h, parent_node(i)), heap_get(h, i)) < 0; i = parent_node(i)) { heap_swap(h, i, parent_node(i)); } return 0; }
static void register_nodes(void) { int i; for (i = 0; i < MAX_NUMNODES; i++) { if (node_online(i)) { int p_node = parent_node(i); struct node *parent = NULL; if (p_node != i) parent = &node_devices[p_node]; register_node(&node_devices[i], i, parent); } } }
TPluginManagerParamTree* MakeParamTree(void) { string drv_name; #ifdef NCBI_OS_MSWIN drv_name = "odbc"; #else drv_name = "ftds"; #endif auto_ptr<TParamTree> parent_node( new TParamTree( TParamTree::TValueType("dbapi", kEmptyStr) ) ); parent_node->AddNode( TParamTree::TValueType("driver", drv_name) ); parent_node->AddNode( TParamTree::TValueType("server", "MSSQL10") ); parent_node->AddNode( TParamTree::TValueType("database", "NCBI_Cache") ); parent_node->AddNode( TParamTree::TValueType("login", "cwrite") ); parent_node->AddNode( TParamTree::TValueType("password", "allowed") ); return parent_node.release(); }
/*! @pre Parent Positioned View is init. */ void Positioned::onInit() { InternalMessage("Display","Entering Positioned::init") ; Positioned* parent_node(getAncestorView<Positioned>()) ; if (parent_node) { InternalMessage("Display", "creating scene node with parent " + parent_node->getNode()->getName()) ; m_node = static_cast<SceneNode*>(parent_node->getNode()->createChild()) ; InternalMessage("Display", "creating scene node " + m_node->getName() + " with parent " + parent_node->m_node->getName() + " with position " + ::Ogre::StringConverter::toString(m_node->getPosition())) ; setPosition() ; setOrientation() ; InternalMessage("Display", "modification of scene node " + m_node->getName() + " with position " + ::Ogre::StringConverter::toString(m_node->getPosition())) ; } else { InternalMessage("Display","root node") ; m_node = static_cast<SceneNode*>(this->getViewPoint()->getManager()->getRootSceneNode()->createChild()) ; getViewPoint()->setRootObject(getObject()) ; } InternalMessage("Display","Leaving Positioned::init") ; }
/** * Adds a sibbling for a node at the end of the list. * * @param id The id of the node definition to use for the * new node. * @param data The data to send to the set_members of the * widgets. If the member id is not an empty * string it is only send to the widget that has * the wanted id (if any). If the member id is an * empty string, it is send to all members. * Having both empty and non-empty id's gives * undefined behaviour. */ ttree_view_node& add_sibling(const std::string& id , const std::map<std::string /* widget id */, string_map>& data) { assert(!is_root_node()); return parent_node().add_child(id, data); }