Esempio n. 1
0
void BNode::rebalance(BNode* current_c, size_t pos_c){
    if( !current_c->is_empty())
        return;

    if( pos_c < size_c-1 && !children[pos_c+1]->is_half() ){ //ie children[pos_c+1].size >= d+1
        BNode* sibling = children[pos_c+1];
        
        if( current_c->is_leaf() ){
            Block* tmp = sibling->lost_smallest_block();
            current_c ->win_block( tmp );//no rebalance needed because sibling.size >= d+1
        }else{
            BNode* tmp = sibling->lost_smallest_child();
            current_c->win_child( tmp );
        }
    }else if( pos_c > 0 && !children[pos_c-1]->is_half() ){ //ie children[pos_b-1].size >= d+1
        BNode* sibling = children[pos_c-1];
        if( current_c->is_leaf() ){
            Block* tmp = sibling->lost_greatest_block();
            current_c ->win_block( tmp );
        }else{
            BNode* tmp = sibling->lost_greatest_child();
            current_c->win_child( tmp );
        }
    }else{//merge
        if( pos_c < size_c-1 ){ //right fusion
            current_c->merge( children[pos_c+1] );
            children[pos_c+1]->clear();
            remove_child( pos_c+1 );
        }else if( pos_c > 0){ //left fusion
            children[pos_c-1]->merge( current_c );
            current_c->clear();
            remove_child( pos_c );
        }
    }
}
Esempio n. 2
0
static void check_for_exited_childs()
{
    int status, pid, ret, exit_status;
    exit_status = 0;
     while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
          ci_debug_printf(5, "Child %d died ...\n", pid);
          if (!WIFEXITED(status)) {
               ci_debug_printf(1, "Child %d did not exit normally.", pid);
               exit_status = 1;
               if (WIFSIGNALED(status))
                    ci_debug_printf(1, "signaled with signal:%d\n",
                                    WTERMSIG(status));
          }
          ret = remove_child(childs_queue, pid, exit_status);
          if (ret == 0 && old_childs_queue) {
               ci_debug_printf(5,
                               "Child %d will be removed from the old list ...\n",
                               pid);
               remove_child(old_childs_queue, pid, exit_status);
               if (childs_queue_is_empty(old_childs_queue)) {
                    ret = destroy_childs_queue(old_childs_queue);
                    /* if(!ret){} */
                    old_childs_queue = NULL;
               }
          }
     }
     if (pid < 0)
          ci_debug_printf(1, "Fatal error waiting for a child to exit .....\n");
}
Esempio n. 3
0
void MultiGrid::remove_child(GridObject* p, TChild* c)
{
	switch(p->base_object_id()){
	case VERTEX:	remove_child(static_cast<Vertex*>(p), c); break;
	case EDGE:		remove_child(static_cast<Edge*>(p), c); break;
	case FACE:		remove_child(static_cast<Face*>(p), c); break;
	case VOLUME:	remove_child(static_cast<Volume*>(p), c); break;
	}
}
Esempio n. 4
0
	void clear_kids()
	//{{{
	{
		for (int i=0; i<ITEMS; i++)
		{
			if (isa_child(caption[i]))
			{
				remove_child(caption[i]);
			}
			if (isa_child(input[i]))
			{
				remove_child(input[i]);
			}
		}
	}
Esempio n. 5
0
void remove_child(Agraph_t * graph, Agnode_t * node)
{
    Agedge_t *edge;
    Agedge_t *nexte;

    /* Avoid cycles */
    if MARKED
	(node) return;
    MARK(node);

    /* Skip nodes with more than one parent */
    edge = agfstin(node);
    if (edge && (agnxtin(edge) != NULL)) {
	UNMARK(node);
	return;
    }

    /* recursively remove children */
    for (edge = agfstout(node); edge; edge = nexte) {
	nexte = agnxtout(edge);
	if (aghead(edge) != node) {
	    if (verbose)
		fprintf(stderr, "Processing descendant: %s\n",
			agnameof(aghead(edge)));
	    remove_child(graph, aghead(edge));
	    agdeledge(edge);
	}
    }

    agdelnode(node);
    return;
}
Esempio n. 6
0
void config::clear_diff_track(const config& diff)
{
	remove_attribute(diff_track_attribute);
	for (const config &i : diff.child_range("delete_child"))
	{
		const size_t index = lexical_cast<size_t>(i["index"].str());
		for (const any_child &item : i.all_children_range()) {
			remove_child(item.key, index);
		}
	}

	for (const config &i : diff.child_range("change_child"))
	{
		const size_t index = lexical_cast<size_t>(i["index"].str());
		for (const any_child &item : i.all_children_range())
		{
			if (item.key.empty()) {
				continue;
			}

			const child_map::iterator itor = children.find(item.key);
			if(itor == children.end() || index >= itor->second.size()) {
				throw error("error in diff: could not find element '" + item.key + "'");
			}

			itor->second[index]->clear_diff_track(item.cfg);
		}
	}
	for (const any_child &value : all_children_range()) {
		const_cast<config *>(&value.cfg)->remove_attribute(diff_track_attribute);
	}
}
Esempio n. 7
0
abstract_group::~abstract_group(void)
{
    while (!child_nodes.empty()) {
        server_node & node = child_nodes.front();
        remove_child(&node);
    }
}
Esempio n. 8
0
File: daemon.c Progetto: Pistos/git
static void check_dead_children(void)
{
	unsigned spawned, reaped, deleted;

	spawned = children_spawned;
	reaped = children_reaped;
	deleted = children_deleted;

	while (deleted < reaped) {
		pid_t pid = dead_child[deleted % MAX_CHILDREN];
		const char *dead = pid < 0 ? " (with error)" : "";

		if (pid < 0)
			pid = -pid;

		/* XXX: Custom logging, since we don't wanna getpid() */
		if (verbose) {
			if (log_syslog)
				syslog(LOG_INFO, "[%d] Disconnected%s",
						pid, dead);
			else
				fprintf(stderr, "[%d] Disconnected%s\n",
						pid, dead);
		}
		remove_child(pid, deleted, spawned);
		deleted++;
	}
	children_deleted = deleted;
}
Esempio n. 9
0
void PlaceableObject::remove_children (void)
{
    std::list<PlaceableObject*> c = children();
    
    FOR_EACH (i,c) {
        remove_child(*i);
    }
Esempio n. 10
0
void Dictionary::remove_child( letter* child )
{
    if ( child->m_child )
    {
        remove_child( child->m_child );
    }

    letter* next = child->m_next;

    delete child;

    if ( next )
    {
        remove_child( next );
    }
}
Esempio n. 11
0
void move_container_to(swayc_t* container, swayc_t* destination) {
	if (container == destination || swayc_is_parent_of(container, destination)) {
		return;
	}
	swayc_t *parent = remove_child(container);
	// reset container geometry
	container->width = container->height = 0;

	// Send to new destination
	if (container->is_floating) {
		add_floating(swayc_active_workspace_for(destination), container);
	} else if (destination->type == C_WORKSPACE) {
		add_child(destination, container);
	} else {
		add_sibling(destination, container);
	}
	// Destroy old container if we need to
	parent = destroy_container(parent);
	// Refocus
	swayc_t *op1 = swayc_parent_by_type(destination, C_OUTPUT);
	swayc_t *op2 = swayc_parent_by_type(parent, C_OUTPUT);
	set_focused_container(get_focused_view(op1));
	arrange_windows(op1, -1, -1);
	update_visibility(op1);
	if (op1 != op2) {
		set_focused_container(get_focused_view(op2));
		arrange_windows(op2, -1, -1);
		update_visibility(op2);
	}
}
Esempio n. 12
0
static void free_swayc(swayc_t *cont) {
	if (!ASSERT_NONNULL(cont)) {
		return;
	}
	// TODO does not properly handle containers with children,
	// TODO but functions that call this usually check for that
	if (cont->children) {
		if (cont->children->length) {
			int i;
			for (i = 0; i < cont->children->length; ++i) {
				free_swayc(cont->children->items[i]);
			}
		}
		list_free(cont->children);
	}
	if (cont->floating) {
		if (cont->floating->length) {
			int i;
			for (i = 0; i < cont->floating->length; ++i) {
				free_swayc(cont->floating->items[i]);
			}
		}
		list_free(cont->floating);
	}
	if (cont->parent) {
		remove_child(cont);
	}
	if (cont->name) {
		free(cont->name);
	}
	free(cont);
}
Esempio n. 13
0
void adag::remove_dead_code() {
    for(nodeiter_t ni = nodes.begin(); ni!=nodes.end(); ++ni) {
	adag_node *n = (*ni).second;
	if(n->parents.size() == 0 && !n->is_target)
	    remove_child(NULL, n);
    }
}
Esempio n. 14
0
void append_child( mxml_node * to, mxml_node * n )
{
	if ( !n )
		return;
	else
	{
		mxml_node * nparent = n->parent;

		if ( nparent )
		{
			remove_child( nparent, n );
		}

		if ( !to->last_child && !to->first_child )
		{
			to->first_child = n;
			to->last_child = n;
			n->prev = NULL;
		}
		else if ( to->last_child )
		{
			to->last_child->next = n;
			n->prev = to->last_child;
			to->last_child = n;
		}

		n->parent = to;
		n->next = NULL;
		if ( !n->document )
			n->document = to->document;
	}		
}
Esempio n. 15
0
	void DomDocument::clear_all()
	{
		while (!get_first_child().is_null())
		{
			DomNode node = get_first_child();
			remove_child(node);
		}
	}
Esempio n. 16
0
/*
 * Remove all children (recursively) from the current token
 */
bool syn_tree::remove_children(void) {

	// iterate though all children
	while(cur->size())
		if(!remove_child(0))
			return false;
	return true;
}
Esempio n. 17
0
void Node::remove_and_delete_child(Node *p_child) {

	ERR_FAIL_NULL( p_child );
	ERR_FAIL_COND( p_child->get_parent()!=this );

	remove_child(p_child);
	memdelete(p_child);

}
Esempio n. 18
0
void adag::remove_child(adag_node *parent, adag_node *n) {
    if(n->parents.size() <= 1) {
	for(size_t i=0; i < n->src.size(); ++i) 
	    remove_child(n, n->src[i]);
	nodes.erase(n->c);
	delete n;
    }
    else n->remove_parent(parent);
}
Esempio n. 19
0
void
usf_reader_c::create_codec_private(mtx::xml::document_cptr &doc) {
  auto root = doc->document_element();
  while (auto subtitles = root.child("subtitles"))
    root.remove_child(subtitles);

  std::stringstream out;
  doc->save(out, "", pugi::format_default | pugi::format_raw);
  m_private_data = out.str();
}
Esempio n. 20
0
DirList::~DirList()
{
    // Erase all dir buttons
    for (std::vector <TextButton*> ::iterator itr = buttons.begin();
     itr != buttons.end(); ++itr) {
        remove_child(**itr);
        delete *itr;
    }
    buttons.clear();
}
Esempio n. 21
0
void abstract_group::replace_child(server_node * node, server_node * node_to_replace)
{
    assert (not has_child(node));
    assert (has_child(node_to_replace));

    server_node_list::iterator position_of_old_element = server_node_list::s_iterator_to(*node_to_replace);
    child_nodes.insert(position_of_old_element, *node);
    node->set_parent(this);
    remove_child(node_to_replace);
}
void AnalogAudioView::remove_options_widget() {
	if( options_widget ) {
		remove_child(options_widget.get());
		options_widget.reset();
	}

	field_lna.set_style(nullptr);
	options_modulation.set_style(nullptr);
	field_frequency.set_style(nullptr);
}
Esempio n. 23
0
void group::dettach_node(group_node *node) {
	group_node *n = (group_node *)get_child(node->name());

	if (n && n == node) {
		broadcast_source_interest_change(groupconf_with_sourcedisc(),
						 node, false);

		remove_child(node->name());
		node->dettached();
	}
}
Esempio n. 24
0
    void Root_widget::drop_child(Widget *child)
    {
        if (contains_widget( mouse_holder() ))
        {
            release_mouse();
        }

        remove_child(child); 

        invalidate();
    }
Esempio n. 25
0
void node::clear_childs() {
	properties::iterator i = m_properties.begin();

	while (i != m_properties.end()) {
		properties::iterator j = i;
		++i;

		if (j->second.is_child()) {
			remove_child(j->first.c_str());
		}
	}
}
Esempio n. 26
0
static void check_dead_children(void)
{
	int status;
	pid_t pid;

	while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
		const char *dead = "";
		remove_child(pid);
		if (!WIFEXITED(status) || (WEXITSTATUS(status) > 0))
			dead = " (with error)";
		loginfo("[%"PRIuMAX"] Disconnected%s", (uintmax_t)pid, dead);
	}
}
Esempio n. 27
0
void config::remove_child(const std::string &key, unsigned index)
{
	check_valid();

	child_map::iterator i = children.find(key);
	if (i == children.end() || index >= i->second.size()) {
		ERR_CF << "Error: attempting to delete non-existing child: "
			<< key << "[" << index << "]\n";
		return;
	}

	remove_child(i, index);
}
Esempio n. 28
0
void DirList::load_current_dir() {
    set_draw_required();
    dir_list.clear();

    // Erase all dir buttons
    for (std::vector <TextButton*> ::iterator itr = buttons.begin();
     itr != buttons.end(); ++itr) {
        remove_child(**itr);
        delete *itr;
    }
    buttons.clear();

    if (!Help::dir_exists(current_dir))
        current_dir = base_dir;

    if (current_dir.get_rootful().size() > base_dir.get_rootful().size()) {
        real_buttons_per_page = bottom_button - 1;
    } else {
        real_buttons_per_page = bottom_button;
    }

    Help::find_dirs(current_dir, static_put_to_dir_list, (void*) this);
    std::sort(dir_list.begin(), dir_list.end());

    // Hochwechsler
    if (current_dir != base_dir) {
        add_button(0, Language::dir_parent);
        (**--buttons.end()).set_hotkey(useR->key_me_up_dir);
    }
    // Verzeichnisbuttons erstellen
    unsigned int next_from_dir_list = page * real_buttons_per_page;
    // Die folgende While-Schleife macht, dass bei mehreren Seiten immer
    // alle Seiten voll gefuellt sind. Die letzte Seite wird dann ggf. oben
    // mit Eintraegen der vorletzten Seite aufgefuellt.
    while (page > 0 && next_from_dir_list + real_buttons_per_page
           > dir_list.size()) --next_from_dir_list;
    for (unsigned int i = buttons.size();
     i < bottom_button && next_from_dir_list < dir_list.size(); ++i) {
        add_button(i, dir_list[next_from_dir_list]);
        ++next_from_dir_list;
    }
    // Blaetter-Button anhaengen, es sei denn, es geht genau auf
    if (next_from_dir_list == dir_list.size() - 1 && page == 0) {
        add_button(bottom_button, dir_list[next_from_dir_list]);
        ++next_from_dir_list;
    }
    // Das hier ist der Blaetter-Button
    else if (next_from_dir_list < dir_list.size() || page > 0) {
        add_button(bottom_button, Language::dir_flip_page);
    }
}
Esempio n. 29
0
struct node *break_edge (int breakindex, struct node *breaknode)
// Break an edge by inserting a new node labelled with the first portion of the broken edge,
// Push the rest of the edge label as a child branch of the new node.
// Return a reference to the new internal node.
{
	struct node *newint;
	allocate_node (&newint, -1, breaknode -> starti, breakindex, breaknode -> parent);
	breaknode = remove_child (&(breaknode -> parent -> leftchild), breaknode);
	breaknode -> parent = newint;
	breaknode -> starti = newint -> endi;
	push_branch (&newint, breaknode);
	push_branch (&(newint -> parent), newint);
	return newint;
}
Esempio n. 30
0
void Dictionary::clear( void )
{
    letter* l = m_dict_tree;

    while ( l->m_next )
    {
        if ( l->m_child )
        {
            remove_child( l->m_child );
            l->m_child = NULL;
        }
        l = l->m_next;
    }
}