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


C++ clear_list函数代码示例

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


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

示例1: bl_append_list

void bl_append_list(bl* list1, bl* list2) {
	list1->last_access = NULL;
	list1->last_access_n = 0;
	if (list1->datasize != list2->datasize) {
		printf("Error: cannot append bls with different data sizes!\n");
		assert(0);
		exit(0);
	}
	if (list1->blocksize != list2->blocksize) {
		printf("Error: cannot append bls with different block sizes!\n");
		assert(0);
		exit(0);
	}

	// if list1 is empty, then just copy over list2's head and tail.
	if (list1->head == NULL) {
		list1->head = list2->head;
		list1->tail = list2->tail;
		list1->N = list2->N;
		// remove everything from list2 (to avoid sharing nodes)
		clear_list(list2);
		return;
	}

	// if list2 is empty, then do nothing.
	if (list2->head == NULL)
		return;

	// otherwise, append list2's head to list1's tail.
	list1->tail->next = list2->head;
	list1->tail = list2->tail;
	list1->N += list2->N;
	// remove everything from list2 (to avoid sharing nodes)
	clear_list(list2);
}
开发者ID:blackball,项目名称:an-test6,代码行数:35,代码来源:bl.c

示例2: main

int main( int argc, char** argv) {

    int ch = 0;
    char buf[STR_SIZE] = {};
    char* hisBuf = NULL;
    char str[STR_SIZE] = {};
    char historyArr[HISTORY_SIZE][STR_SIZE] = {};
    int inHistory = 0;
    int cmd = -1;

    List_t* list = new_list( );
    while( true) {
        getcwd( str, STR_SIZE);
        printf( "%s> ", str);

        fgets( buf, STR_SIZE, stdin);
        if( feof( stdin)) {
            printf( "logout\n");
            break;
        }
        if( buf[0] == '\n')
            continue;

        parse_program( list, buf);

        if( (cmd = commands( list->head->next->program)) >= 0) {
            switch( cmd) {
                case logout:
                    goto finish;
                    break;
                case cd:
                    if( chdir( list->head->next->program->arguments[0]) < 0)
                        warn( "Error while changing dir");
                    break;
                case history:
                    if( list->head->next->program->arguments[0][0]) {
                        hisBuf = get_history( historyArr, atoi( list->head->next->program->arguments[0]), inHistory);
                        if( hisBuf) {
                            strcpy( buf, hisBuf);
                            clear_list( list);
                            parse_program( list, buf);
                            printf( "%s\n", buf);
                            execute( list);
                        }
                    } else
                        dump_history( historyArr, inHistory);
                    break;
            }
        } else
            execute( list);
        if( cmd != history)
            inHistory = add_in_history( historyArr, buf, inHistory);
        clear_list( list);
    }

finish:
    destroy_list( list);
    return 0;
}
开发者ID:grafin,项目名称:my_shell,代码行数:59,代码来源:main.cpp

示例3: clear_inferiors

void
clear_inferiors (void)
{
  for_each_inferior (&all_threads, free_one_thread);
  for_each_inferior (&all_dlls, free_one_dll);

  clear_list (&all_threads);
  clear_list (&all_dlls);

  current_inferior = NULL;
}
开发者ID:Claruarius,项目名称:stblinux-2.6.37,代码行数:11,代码来源:inferiors.c

示例4: destroy_vm

int		destroy_vm(t_vm *vm, t_list **files)
{
  int		ret;

  apply_in_list(vm->warriors, &free);
  clear_list(&vm->warriors);
  free_registers(vm);
  apply_in_list(vm->processes, &free);
  clear_list(&vm->processes);
  if ((ret = close_files(*files)) != SUCCESS)
    return (ret);
  apply_in_list(*files, &free);
  clear_list(files);
  return (SUCCESS);
}
开发者ID:sabs231,项目名称:corewar,代码行数:15,代码来源:vm_destroy.c

示例5: lclear

// 释放 struct queue
// lua: 接受 1 个参数, userdata 类型, 表示 struct queue; 0 个返回值.
static int
lclear(lua_State *L) {
	struct queue * q = lua_touserdata(L, 1);
	if (q == NULL) {
		return 0;
	}

	// 释放 struct uncomplete
	int i;
	for (i = 0; i < HASHSIZE; i++) {
		clear_list(q->hash[i]);
		q->hash[i] = NULL;
	}

	// 方便后面的运算, 直接取余就好了
	if (q->head > q->tail) {
		q->tail += q->cap;
	}

	// 释放 netpack.buffer 指向的资源
	for (i=q->head;i<q->tail;i++) {
		struct netpack *np = &q->queue[i % q->cap];
		skynet_free(np->buffer);
	}
	q->head = q->tail = 0;

	return 0;
}
开发者ID:KAndQ,项目名称:skynet,代码行数:30,代码来源:lua-netpack.c

示例6: free_list

void free_list(DataHeadNode *pHead) {
    clear_list(pHead);
    if(pHead != NULL)
        free(pHead);
    pHead = NULL;
    printf("free data list done\n");
}
开发者ID:WHUinTAMU,项目名称:MotionNetProject,代码行数:7,代码来源:DataNode.c

示例7: initCalibrator

//1. collect initial data in MAG_CALI_TIME seconds
//2. do calibration for initial data
//3. if calibrator is invalid, repeat step 1.
void initCalibrator(HANDLE hComm) {
    printf("\n=========================  Initialize Calibrator  =====================\n");
    PktData pktData;

    //Mag data list for initialization
    DataHeadNode *ptr = create_list_with_head();
    int len;

    while (true) {
        printf("\nCollect data in the next %d seconds!\n", MAG_CALI_TIME);

        //Before read, flush the buffer.
        purgePort(hComm);

        time_t timeBegin = time(NULL);

        while (true) {
            pktData = blockingReadOnePacket(hComm);

            if(equals(pktData, ZERO_PKT)) {
                continue;
            }
            add_to_list_head(ptr, pktData);

            if(time(NULL) - timeBegin >= MAG_CALI_TIME)
                break;
        }

        //Start prepare double array for calculate calibrator
        len = ptr->length;
        printf("Initialize data length: %d \n", len);

        double magDataX[len] ;
        double magDataY[len] ;
        double magDataZ[len] ;
        double heading[len];

        fillMagDataArray(ptr, magDataX, magDataY, magDataZ);

        //pass magData to calibrator
        calculateCalibrator(magDataX, magDataY, magDataZ, len);

        write_list_to_file("C:/Users/xing/Desktop/Raw_Initial_Data.txt", ptr);

        if(! calibrateMagData(magDataX, magDataY, magDataZ, heading, len))
            continue;

        write_mag_to_file("C:/Users/xing/Desktop/Corrected_Initial_Mag_Data.txt", magDataX, magDataY, magDataZ, heading, len);

        clear_list(ptr);

        if(isCalibratorValid(magDataX, magDataY, magDataZ, len))
            break;
    }

    //free all list data
    free_list(ptr);
    isCalibratorInitialized = true;
    printf("\n============================  Initialize Over  ========================\n");
}
开发者ID:Zziwei,项目名称:MotionNet,代码行数:63,代码来源:main.c

示例8: main

int main() {
    int n;
    scanf("%d", &n);

    list mylist;
    init_list(&mylist);
    while(n--) {
        char command[10];
        scanf("%s", command);

        // push, get, size, count, clear
        if(command[0] == 'p') {
            int value;
            scanf("%d", &value);
            push_back(&mylist, value);
        } else if(command[0] == 'g') {
            int idx;
            scanf("%d", &idx);
            printf("%d\n", get_idx(&mylist, idx));
        } else if(command[0] == 's') {
            printf("%d\n", mylist.size);
        } else if(command[1] == 'o') {
            int target;
            scanf("%d", &target);
            printf("%d\n", count_target(&mylist, target));
        } else {
            clear_list(&mylist);
        }
    }

    return 0;
}
开发者ID:showpointer,项目名称:Algorithm,代码行数:32,代码来源:List.c

示例9: stop_mobility_generator

/*stop sumo mobiity generator*/
void
stop_mobility_generator (omg_global_param * omg_param_list)
{
  int i;

  for (i = 0; i < MAX_NUM_NODE_TYPES; i++) {
    switch (omg_param_list[i].mobility_type) {

    case STATIC:
      break;

    case RWP:
      break;

    case RWALK:
      break;

    case TRACE:
      clear_list ();
      break;

    case STEADY_RWP:
      break;
#ifdef SUMO_IF
    case SUMO:
      stop_sumo_generator ();
      //LOG_D(OMG," --------OMG will interface with SUMO for mobility generation-------- \n");
      break;
#endif 
    default:
      LOG_N (OMG, "Unsupported generator\n");
    }
  }

}
开发者ID:ShibinMathew36,项目名称:OAI-step,代码行数:36,代码来源:omg.c

示例10: generate_validate_samples

void generate_validate_samples(std::vector<std::string> &imgList, int WIDTH, int HEIGHT, std::list<float*> &validateSet, int size)
{
    assert(size < imgList.size());

    if(validateSet.size() > 0)
        clear_list(validateSet);

    for(int i = 0 ; i < size; i++)
    {
        cv::Mat img = cv::imread(imgList[i], 0);
        cv::Mat sImg;

        if(img.empty())
        {
            printf("Can't open image %s\n", imgList[i].c_str());
            exit(0);
        }

        cv::resize(img, sImg, cv::Size(WIDTH, HEIGHT));

        float *data = mat_to_float(sImg);

#ifdef USE_HAAR_FEATURE
        integral_image(data, WIDTH, HEIGHT);
#endif

        validateSet.push_back(data);
    }
}
开发者ID:zbxzc35,项目名称:my_adaboost,代码行数:29,代码来源:main.cpp

示例11: clear_list

void PrivPtr::set_ptr(priv_ptr assign_ptr, priv_ptr right_ptr, int threadID)
{
	clear_list(&(assign_ptr->list)); 
	copy_list(assign_ptr->list, right_ptr->list, right_ptr->level-1, assign_ptr->type);
	assign_ptr->size = right_ptr->size; 
	assign_ptr->level = right_ptr->level;  
}
开发者ID:PICCO-Team,项目名称:picco,代码行数:7,代码来源:PrivPtr.cpp

示例12: append_and_clear

static void append_and_clear( los_list_t *left, los_list_t *right )
{
  word *left_first = next( left->header );
  word *left_last = prev( left->header );
  word *right_first = next( right->header );
  word *right_last = prev( right->header );

  if (right_first == right->header) return;   /* Right is empty */

  /* Splice in the right list */
  if (left_first != left->header) {           /* Left is nonempty  */
    set_next( left_last, right_first );       /* Join lists */
    set_prev( right_first, left_last );
  }
  else {			              /* Left is empty */
    set_next( left->header, right_first );    /* Move right to left */
    set_prev( right_first, left->header );
  }

  /* Complete circle */
  set_next( right_last, left->header );
  set_prev( left->header, right_last );

  left->bytes += right->bytes;
  clear_list( right );
}
开发者ID:liutanyu,项目名称:larceny-0.97-src,代码行数:26,代码来源:los.c

示例13: packet_history_add

/* add an entry to the history list */
void packet_history_add(gint row) {

    if(row < 1) {
        /* Not a valid row number */
        return;
    }

    if(ignore_jump) {
        /* we jumping back and forward in history, so don't change list */
        return;
    }

    if (history_current) {
        /* clear list behind current position */
        clear_list(g_list_next(history_current));

        /* ignore duplicates */
        if(GPOINTER_TO_INT(history_current->data) == row) {
            adjust_menus();
            return;
        }
    }

    /* add row */
    history_list = g_list_append(history_list, GINT_TO_POINTER(row));
    history_current = g_list_last(history_list);

    adjust_menus();
}
开发者ID:P1sec,项目名称:LTE_monitor_c2xx,代码行数:30,代码来源:packet_history.c

示例14: display

void display(int needfile)
{
	if (needfile == 1)
	{
		read_from_file();
	}
	Node* tmp = root;
	int ind = 1;
	print_deco(75,'+');
	printf("\t\t|ID |Nume       |Pret       |Prescriptie medicala   |Tip medicament       |");
	printf("\n");
	print_deco(75,'+');
	while (root->next != NULL)
	{
		root = root->next;
		printf("\t\t|%-3d|%-10s |%-10d |%-22s |%-21s| \n", ind++, root->data.nume, root->data.pret, root->data.pr_med, root->data.tip);
		print_deco(75,'=');
	}	
	printf("\n");
	root = tmp;
	if (needfile==1)
	{
		clear_list();
	}
}
开发者ID:aodpi,项目名称:Pharmacy,代码行数:25,代码来源:Func.cpp

示例15: create_listnode

void PrivPtr::set_ptr(priv_ptr ptr, mpz_t* int_var_loc, mpz_t** float_var_loc, void* struct_var_loc, priv_ptr* ptr_loc, int threadID)
{
	listnode node = create_listnode(); 
	if(int_var_loc != NULL)
	{
		node->u.int_var_location = int_var_loc;
		ptr->level = 1; 
	}
	else if(float_var_loc != NULL)
	{
		node->u.float_var_location = float_var_loc; 
		ptr->level = 1;  
	}
	else if(struct_var_loc != NULL)
	{
		node->u.struct_var_location = struct_var_loc; 
		ptr->level = 1; 
	}
	else
	{
		node->u.ptr_location = *ptr_loc;
		ptr->level = (*ptr_loc)->level; 
	} 
	clear_list(&(ptr->list));
	node->if_index = -1;
	mpz_set_ui(node->priv_tag, 1); 
	insert_to_rear(ptr->list, node); 
	ptr->size = 1; 
}
开发者ID:PICCO-Team,项目名称:picco,代码行数:29,代码来源:PrivPtr.cpp


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