当前位置: 首页>>代码示例>>C++>>正文


C++ delete_element函数代码示例

本文整理汇总了C++中delete_element函数的典型用法代码示例。如果您正苦于以下问题:C++ delete_element函数的具体用法?C++ delete_element怎么用?C++ delete_element使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了delete_element函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

chooser::pitem chooser::delete_element(pitem p) {
	pitem res = nullptr;
	if (!p->L && !p->R) {
		if (p->parent) {
			res = p->parent;
			if (is_left_child(p)) {
				res->L = nullptr;
			} else {
				res->R = nullptr;
			}
		}
		delete p;
	} else if (!p->L || !p->R) {
		if (p->parent) {
			res = p->parent;
			if (is_left_child(p)) {
				res->L = p->L ? p->L : p->R;
			} else {
				res->R = p->L ? p->L : p->R;
			}
			p->L = p->R = nullptr;
			delete p;
		} else {
			if (p->L) {
				right_rotale(p);
			} else {
				left_rotale(p);
			}
			return delete_element(p);
		}
	} else {
		pitem q = leftmost_child(p->R);
		if (q != p->R) {
			std::swap(p->L, q->L);
			std::swap(p->R, q->R);
			recalc(p);
			recalc(q);
			const pitem p_par = p->parent;
			make_parent(q->parent, p);
			make_parent(p_par, q);
		} else {
			left_rotale(p);
		}
		assert(!p->L || !p->R);
		delete_element(p);
		res = q->parent ? q->parent : q;
	}
	recalc(res);
	return splay(res);
}
开发者ID:Break-Neck,项目名称:ant_algo,代码行数:50,代码来源:chooser.cpp

示例2: main

int main()
{
  int option;
  printf("\n");
  printf(">>> c program to implement queue operations <<<");
  do
  {
   printf("\n\n 1.Insert an element");
   printf("\n 2.Delete an element");
   printf("\n 3.Display queue");
   printf("\n 4.Exit");
   printf("\n Enter your choice: ");
   scanf("%d",&option);
   switch(option)
   {
     case 1: insert_element();
              break;
     case 2: delete_element();
             break;
     case 3: display_queue();
             break;
     case 4: return 0;
   }
 
  }while(option!=4);
}
开发者ID:venugopalvishwanathula,项目名称:my-cprograms,代码行数:26,代码来源:queue.c

示例3: delete_match_entry

void
delete_match_entry( struct ofp_match *ofp_match ) {
  match_entry *delete_entry;
  list_element *list;

  pthread_mutex_lock( match_table_head.mutex );

  assert( ofp_match != NULL );
  if ( !ofp_match->wildcards ) {
    delete_entry = delete_hash_entry( match_table_head.exact_table, ofp_match );
    if ( delete_entry == NULL ) {
      pthread_mutex_unlock( match_table_head.mutex );
      return;
    }
  }
  else {
    for ( list = match_table_head.wildcard_table; list != NULL; list = list->next ) {
      delete_entry = list->data;
      if ( ( ( ( delete_entry->ofp_match.wildcards ^ ofp_match->wildcards ) & OFPFW_ALL ) == 0 )
          && compare_match( &delete_entry->ofp_match, ofp_match ) ) {
        break;
      }
    }
    if ( list == NULL ) {
      pthread_mutex_unlock( match_table_head.mutex );
      return;
    }
    delete_element( &match_table_head.wildcard_table, delete_entry );
  }
  free_match_entry( delete_entry );
  pthread_mutex_unlock( match_table_head.mutex );
}
开发者ID:n-tada,项目名称:trema,代码行数:32,代码来源:match_table.c

示例4: main

int main()
{
    Sant* santi=(Sant*)malloc(sizeof(Sant));
    initializeSent(santi);
    //santi->head=NULL;
    // santi->tail=NULL;
    char s[30];
    int x;
    out=fopen("out.txt","w");
    in=fopen("in.txt","r");
    int c;
    c=fscanf(in,"%s %d",s,&x);
    while(c>0)
    {
        //printf("%s %d\n",s,x);
        if(!strcmp(s,"AL"))addLast(santi,x);
        if(!strcmp(s,"AF"))addFirst(santi,x);
        if(!strcmp(s,"DE"))delete_element(santi,x);
        if(!strcmp(s,"PRINT_F"))print_first(santi,x);
        if(!strcmp(s,"PRINT_L"))print_last(santi,x);
        if(!strcmp(s,"PRINT_ALL"))printlist(santi);
        if(!strcmp(s,"DOOM_THE_LIST"))doom_the_list(santi);
        if(!strcmp(s,"DF"))delete_first(santi);
        if(!strcmp(s,"DL"))delete_last(santi);
        strcpy(s,"");
        c=fscanf(in,"%s %d",s,&x);

    }
    return 0;
}
开发者ID:Alecs94,项目名称:DSA-lab,代码行数:30,代码来源:main1.c

示例5: delete_texture

void delete_texture(void **texs, void *tex) {
	Texture *t = (Texture *)tex;
	free(t->name);
	glDeleteTextures(1, &t->gltex);
	
	delete_element((void **)texs, tex);
}
开发者ID:miton,项目名称:taisei,代码行数:7,代码来源:texture.c

示例6: handle_packet_in

static void
handle_packet_in( uint64_t datapath_id, uint32_t transaction_id,
                  uint32_t buffer_id, uint16_t total_len,
                  uint16_t in_port, uint8_t reason, const buffer *data,
                  void *user_data ) {
  services *services = user_data;
  list_element **list_head = &services->arp_or_unicast;

  packet_info *packet_info = data->user_data;
  if ( !packet_type_arp( data ) && ( packet_info->eth_macda[ 0 ] & 0x1 ) == 0x1 ) {
    list_head = &services->broadcast;
  }
  if ( *list_head == NULL ) {
    return;
  }
  buffer *buf = create_packet_in( transaction_id, buffer_id, total_len, in_port,
                                  reason, data );

  openflow_service_header_t *message;
  message = append_front_buffer( buf, sizeof( openflow_service_header_t ) );
  message->datapath_id = htonll( datapath_id );
  message->service_name_length = htons( 0 );
  char *service_name = ( *list_head )->data;
  if ( send_message( service_name, MESSENGER_OPENFLOW_MESSAGE, buf->data, buf->length ) ) {
    debug( "Sending a message to %s.", service_name );
  }
  free_buffer( buf );
  if ( ( *list_head )->next != NULL ) {
    //round robin
    delete_element( list_head, service_name );
    append_to_tail( list_head, service_name );
  }
}
开发者ID:iqm,项目名称:apps,代码行数:33,代码来源:packetin_dispatcher.c

示例7: delete_packetin_match_entry

static int
delete_packetin_match_entry( struct ofp_match match, uint16_t priority, const char *service_name ) {
  list_element *head = delete_match_strict_entry( match, priority );
  if ( head == NULL ) {
    return 0;
  }

  int n_deleted = 0;
  int n_remaining_services = 0;
  list_element *services = head;
  while ( services != NULL ) {
    char *service = services->data;
    services = services->next;
    if ( strcmp( service, service_name ) == 0 ) {
      delete_element( &head, service );
      xfree( service );
      n_deleted++;
    }
    else {
      n_remaining_services++;
    }
  }

  if ( n_remaining_services == 0 ) {
    if ( head != NULL ) {
      delete_list( head );
    }
  }
  else {
    insert_match_entry( match, priority, head );
  }

  return n_deleted;
}
开发者ID:Milstein,项目名称:trema,代码行数:34,代码来源:packetin_filter.c

示例8: loop_exit

int loop_exit(loop_handle *hd)
{
  int i;

  hd->running = FALSE;

  if(hd->svdst != NULL) {
    if (hd->fifodst != NULL) {
      sv_fifo_free(hd->svdst, hd->fifodst);
      hd->fifodst = NULL;
    }
    if(hd->svdst != hd->svsrc) {
      sv_close(hd->svdst);
      hd->svdst = NULL;
    }
  }

  if (hd->svsrc != NULL) {
    if (hd->fifosrc != NULL) {
      sv_fifo_free(hd->svsrc, hd->fifosrc);
      hd->fifosrc = NULL;
    }
    sv_close(hd->svsrc);
    hd->svsrc = NULL;
  }

  if(hd->nobuffer_org) {
    free(hd->nobuffer_org);
  }

  if(hd->blackbuffer_org) {
    free(hd->blackbuffer_org);
  }

  for(i = 0; i < MAX_ID; i++) {
    if(hd->ancbuffer_org[i]) {
      free(hd->ancbuffer_org[i]);
    }
    if(hd->livebuffer_org[i]) {
      free(hd->livebuffer_org[i]);
    }
    if(hd->banc) {
      //If there are valid packets delete them
      if( hd->anclist[i].next ) {
        //Delete all elements in list
        delete_element( i, hd->anclist[i].next );
      }
    }
  }

  dvs_mutex_free(&hd->common.lock);
  dvs_cond_free(&hd->common.ready);

  printf("exiting dma loop through\n");

  return 0;
}
开发者ID:elliotwoods,项目名称:SDICapture-Test,代码行数:57,代码来源:dmaloop.c

示例9: delete_element

void delete_element( int id, anc_element_t * anc_element )
{
  if( anc_element ) {
    if( anc_element->next ) {
      delete_element( id, anc_element->next );
    }
    free( anc_element );
  }
}
开发者ID:elliotwoods,项目名称:SDICapture-Test,代码行数:9,代码来源:dmaloop.c

示例10: GdipDeleteRegion

/*****************************************************************************
 * GdipDeleteRegion [[email protected]]
 */
GpStatus WINGDIPAPI GdipDeleteRegion(GpRegion *region)
{
    TRACE("%p\n", region);

    if (!region)
        return InvalidParameter;

    delete_element(&region->node);
    heap_free(region);

    return Ok;
}
开发者ID:AndreRH,项目名称:wine,代码行数:15,代码来源:region.c

示例11: delete_meter_entry

OFDPE
delete_meter_entry( const uint32_t meter_id ) {
  assert( table != NULL );

  if ( meter_id == 0 && meter_id <= OFPM_MAX && meter_id != OFPM_CONTROLLER && meter_id != OFPM_ALL ) {
    return ERROR_OFDPE_METER_MOD_FAILED_INVALID_METER;
  }

  OFDPE ret = OFDPE_SUCCESS;
  if ( !lock_pipeline() ) {
    return ERROR_LOCK;
  }
  if ( meter_id == OFPM_ALL ) {
    delete_flow_entries_by_meter_id( meter_id );
    for ( list_element *e = table->entries; e != NULL; ) {
      list_element *next = e->next;
      meter_entry *entry = e->data;
      if ( entry->meter_id > 0 && entry->meter_id <= OFPM_MAX ) { // virtual meters won't be deleted by OFPM_ALL
        delete_element( &table->entries, entry );
        free_meter_entry( entry );
      }
      e = next;
    }
  } else {
    meter_entry *old_entry = lookup_meter_entry( meter_id );
    if ( NULL == old_entry ) {
      ret = ERROR_OFDPE_METER_MOD_FAILED_UNKNOWN_METER;
    } else {
      if ( old_entry->ref_count > 0 ) {
        delete_flow_entries_by_meter_id( meter_id );
      }
      delete_element( &table->entries, old_entry );
      free_meter_entry( old_entry );
    }
  }
  if ( !unlock_pipeline() ) {
    return ERROR_UNLOCK;
  }
  return ret;
}
开发者ID:cs470Group,项目名称:sdn-controller,代码行数:40,代码来源:meter_table.c

示例12: delete_outbound_switch

static void
delete_outbound_switch( list_element **switches, switch_info *delete_switch ) {
  list_element *ports = delete_switch->ports;

  // delete ports
  for ( list_element *p = ports; p != NULL; p = p->next ) {
    xfree( p->data );
  }
  delete_list( ports );

  // delete switch
  delete_element( switches, delete_switch );
  xfree( delete_switch );
}
开发者ID:n-tada,项目名称:trema,代码行数:14,代码来源:port.c

示例13: GdipSetInfinite

GpStatus WINGDIPAPI GdipSetInfinite(GpRegion *region)
{
    GpStatus stat;

    TRACE("%p\n", region);

    if (!region)
        return InvalidParameter;

    delete_element(&region->node);
    stat = init_region(region, RegionDataInfiniteRect);

    return stat;
}
开发者ID:AndreRH,项目名称:wine,代码行数:14,代码来源:region.c

示例14: remove_duplicate

int remove_duplicate(SLink **head)
{
	
	//to keep track of next next link for duplicate cases
	SLink *nextNext, *result;
	
	//if empty link
	if (NULL == (*head))
	{
		return EMPTYLIST;
	}

	//sort the given list
	insert_sort(head);
	
	/* take a local reference of head */
	SLink *temp;
	temp = *head;

	//if single node
	if((*head) -> link == NULL)
	{
		return SUCCESS;
	}

	{
	/* if list has multiple nodes then, iterate till tail node */
       	while (temp -> link)
      	{
		if (temp -> data != (temp -> link) -> data)
		{
			/* if no element is found at all then return */
               		if (((temp->link)-> link ) == NULL)
			{
				return SUCCESS;
			}
               		temp = temp -> link;
		}	
		else
		{
			nextNext = temp -> link;
			delete_element(head, temp -> data);
			temp = nextNext;
		}
	}
		return SUCCESS;
	}	
	return FAILURE;
}
开发者ID:nanditha16,项目名称:Emertxe,代码行数:49,代码来源:remove_duplicate.c

示例15: delete_flow_entry_from_table

static void
delete_flow_entry_from_table( flow_table *table, flow_entry *entry, uint8_t reason, bool notify ) {
  assert( table != NULL );
  assert( entry != NULL );

  bool ret = delete_element( &table->entries, entry );
  if ( ret ) {
    decrement_active_count( table->features.table_id );
    if ( notify ) {
      flow_deleted( entry, reason );
    }
    decrement_reference_counters_in_groups( entry->instructions );
    free_flow_entry( entry );
  }
}
开发者ID:kazuyas,项目名称:trema-edge,代码行数:15,代码来源:flow_table.c


注:本文中的delete_element函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。