本文整理汇总了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);
}
示例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);
}
示例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 );
}
示例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;
}
示例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);
}
示例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 );
}
}
示例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;
}
示例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;
}
示例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 );
}
}
示例10: GdipDeleteRegion
/*****************************************************************************
* GdipDeleteRegion [[email protected]]
*/
GpStatus WINGDIPAPI GdipDeleteRegion(GpRegion *region)
{
TRACE("%p\n", region);
if (!region)
return InvalidParameter;
delete_element(®ion->node);
heap_free(region);
return Ok;
}
示例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;
}
示例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 );
}
示例13: GdipSetInfinite
GpStatus WINGDIPAPI GdipSetInfinite(GpRegion *region)
{
GpStatus stat;
TRACE("%p\n", region);
if (!region)
return InvalidParameter;
delete_element(®ion->node);
stat = init_region(region, RegionDataInfiniteRect);
return stat;
}
示例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;
}
示例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 );
}
}