Beispiel #1
0
node  Delete_Element(tree t, node Parent, void * data, int *H, int * found, void * found_data)
{
    node Temp;
    if(!Parent)
    {
        printf("\n datarmation does not exist");
        return(Parent);
    }
    else
    {
        if (t->comp(data, Parent->data) < 0)
        {
            Parent->left = Delete_Element(t, Parent->left, data, H, found, found_data);
            if(*H)
                Parent = Balance_Right_Heavy(Parent, H);
        }
        else if(t->comp(data, Parent->data) > 0)
        {
            Parent->right = Delete_Element(t, Parent->right, data, H, found, found_data);
            if(*H)
                Parent = Balance_Left_Heavy(Parent, H);
        }
        else
        {
            *found = 1;
            *((int*)found_data) = (int) Parent->data;
            Temp= Parent;

            if(Temp->right == NULL)
            {
                Parent = Temp->left;
                *H = T;
                free(Temp);
            }
            else if(Temp->left == NULL)
            {
                Parent = Temp->right;
                *H = T;
                free(Temp);
            }
            else
            {
                Temp->left = DELETE(Temp->left, Temp, H);
                if(*H)
                    Parent = Balance_Right_Heavy(Parent, H);
            }
        }
    }
    return(Parent);
}
Beispiel #2
0
/*	void
**	Do_Delete(Widget w, XtPointer cl_data, XtPointer ca_data)
**	Actually does the deletion.
*/
static void
Do_Delete(Widget w, XtPointer cl_data, XtPointer ca_data)
{
	InstanceList		elmt;
	InstanceList		victim;
	ObjectInstancePtr	obj;

	XtPopdown(deletion_shell);

	for ( elmt = current_window->selected_instances ; elmt ; elmt = elmt->next )
	{
		victim = Find_Object_In_Instances(elmt->the_instance,
											current_window->all_instances);
		if ( current_window->all_instances == victim )
			current_window->all_instances = victim->next;
		Delete_Element(victim);

		obj = victim->the_instance;
		free(victim);

		/* Check for the victim in the edit lists. */
		if ( ( victim = Find_Object_In_Instances(obj,
											current_window->edit_instances) ) )
			Delete_Edit_Instance(current_window, victim);

		Destroy_Instance(obj);
	}

	Free_Selection_List(current_window->selected_instances);
	current_window->selected_instances = NULL;

	View_Update(current_window, current_window->all_instances, ViewNone);
}
Beispiel #3
0
void * tree_delete(tree t, void * e)
{
    int boolean = 0;
    void * data = (void *) malloc(sizeof(void *));
    t->header = Delete_Element(t, t->header, e, t->H, &boolean, (void *)data);
    if (boolean) {
        t->size--;
        int ret = (int)(*((int*)data));
        free(data);
        return (void *)ret;
    }
    else {
        free(data);
        return NULL;
    }

}
Beispiel #4
0
static void
Layer_Check_Instance_Visibility(LayerPtr layer, ObjectInstancePtr inst)
{
	InstanceList victim;

	if ( ! layer->state )
	{
		inst->o_flags &= ( ObjAll ^ ( ObjVisible & ObjSelected ) );

		/* Look for it in the edit and selected lists. */
		if ( ( victim = Find_Object_In_Instances(inst,
										current_window->edit_instances) ) )
		Delete_Edit_Instance(current_window, victim);
		if ( ( victim = Find_Object_In_Instances(inst,
									current_window->selected_instances) ) )
		{
			if ( victim == current_window->selected_instances )
				current_window->selected_instances =
					current_window->selected_instances->next;
			Delete_Element(victim);
		}
	}
}