本文整理汇总了C++中ListInit函数的典型用法代码示例。如果您正苦于以下问题:C++ ListInit函数的具体用法?C++ ListInit怎么用?C++ ListInit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ListInit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RequestInit
void
RequestInit(TSession * const sessionP,
TConn * const connectionP) {
time_t nowtime;
sessionP->validRequest = false; /* Don't have valid request yet */
time(&nowtime);
sessionP->date = *gmtime(&nowtime);
sessionP->conn = connectionP;
sessionP->responseStarted = FALSE;
sessionP->chunkedwrite = FALSE;
sessionP->chunkedwritemode = FALSE;
ListInit(&sessionP->cookies);
ListInit(&sessionP->ranges);
TableInit(&sessionP->request_headers);
TableInit(&sessionP->response_headers);
sessionP->status = 0; /* No status from handler yet */
StringAlloc(&(sessionP->header));
}
示例2: InitParkingLot
ParkingLot * InitParkingLot( FILE * mapconfig, int col, int row, int floors, int accesses )
{
char *** matrix;
int *vertices, *ramps;
ParkingLot * parkinglot;
vertices = (int*)malloc(sizeof(int));
VerifyMalloc( (Item) vertices );
ramps = (int*)malloc(sizeof(int));
VerifyMalloc( (Item) ramps );
parkinglot = (ParkingLot*) malloc( sizeof(ParkingLot) );
VerifyMalloc((Item) parkinglot);
parkinglot->freespots = 0;
matrix = MatrixInit(vertices, ramps, mapconfig, col, row, floors); /*Creates string cointaining the map - its a 3d string */
parkinglot->graphdecoder = GraphDecoderInit(matrix, col, row, floors, *vertices, &(parkinglot->freespots) ); /*Creates array cointaining the Decoder for the graph positions*/
parkinglot->g = GraphInit(*vertices, matrix, parkinglot->graphdecoder, col, row);
parkinglot->accesseshead = InitAccesses(accesses, parkinglot->graphdecoder, *vertices);
parkinglot->parkedcarshead = ListInit();
parkinglot->queuehead = ListInit();
/**PrintGraph(GetGraph(parkinglot), *vertices); */ /*prints the graph in the parkinglot */
FreeMatrix(matrix, col, row);
free(vertices);
free(ramps);
return (parkinglot);
}
示例3: ParseBuildList
List* ParseBuildList(char* s, Err* err){
List* L=NULL,*Lold=NULL;
int i=0,iold=0; Str* S=NULL; Err* err2=ErrInit();
i=0;
while ((s!=NULL)&&(i<strlen(s))){
iold=i;
S=ParseLex(s, err,&i);
if (S==NULL && i<strlen(s)){
err->pres=err2->pres;
err->err=err2->err;
myfree(err2);
return NULL;
}
if (S==NULL && i>=strlen(s)){
break;
}
i=i;
if (L==NULL) { L=ListInit(); Lold=L;}
else { L->next=NULL; L->next=ListInit(); L=L->next;}
ListPutDataStr(L,S->s);
StrFree(S);
/*printf("%s\n",S->s);*/
}
myfree(err2->err);
myfree(err2);
return Lold;
}
示例4: RequestInit
void
RequestInit(TSession * const sessionP,
TConn * const connectionP) {
sessionP->validRequest = false; /* Don't have valid request yet */
time(&sessionP->date);
sessionP->connP = connectionP;
sessionP->responseStarted = FALSE;
sessionP->chunkedwrite = FALSE;
sessionP->chunkedwritemode = FALSE;
sessionP->continueRequired = FALSE;
ListInit(&sessionP->cookies);
ListInit(&sessionP->ranges);
TableInit(&sessionP->requestHeaderFields);
TableInit(&sessionP->responseHeaderFields);
sessionP->status = 0; /* No status from handler yet */
StringAlloc(&(sessionP->header));
}
示例5: printf
heap_t *heapCreate (size_t heapSize)
{
heap_t *new_heap;
sector_t *s0;
new_heap = (heap_t*)malloc(sizeof(heap_t));
if(new_heap == NULL)
{
printf("Error during heap allocation\n");
exit(EXIT_FAILURE);
}
new_heap->empty=ListInit();
new_heap->full=ListInit();
new_heap->dim=heapSize;
new_heap->base=malloc(heapSize);//memoria dello heap allocata
if(new_heap->base == NULL)
{
printf("Error during base allocation\n");
exit(EXIT_FAILURE);
}
s0=(sector_t*)malloc(sizeof(sector_t));
if(s0==NULL) return NULL;
s0->offset=(int)new_heap->base;
s0->dimen=heapSize;
new_heap->empty = OrderInsert(new_heap->empty,(void*)s0,NULL);//inserisco in empty la partizione intera
return(new_heap);
}
示例6: MediaSrvInit
////////////////////////////////////////////////////
// 功能:
// 输入:
// 输出:
// 返回:
// 说明:
////////////////////////////////////////////////////
void MediaSrvInit(void)
{
ListInit(&MediaObjList);
ListInit(&MediaCallbackList);
hMediaMutex = kMutexCreate();
JzSrvInit();
SaveMplayerVar();
}
示例7: TaskInit
// 说明:任务管理模块初始化
void TaskInit(void)
{
static uint32_t flag = FALSE;
if (flag) {
TEE_Printf("Task Module has been inited sometime before!\n");
return;
}
flag = TRUE;
current_task = NULL;
ListInit(&list_all_tasks);
ListInit(&list_ready_tasks);
ListInit(&list_suspud_tasks);
}
示例8: MIMETypeCreate
MIMEType *
MIMETypeCreate(void) {
MIMEType * MIMETypeP;
MALLOCVAR(MIMETypeP);
if (MIMETypeP) {
ListInit(&MIMETypeP->typeList);
ListInit(&MIMETypeP->extList);
PoolCreate(&MIMETypeP->pool, 1024);
}
return MIMETypeP;
}
示例9: main
int main(void)
{
// 양방향 연결 리스트의 생성 및 초기화 ///////
List list;
int data;
ListInit(&list);
// 8개의 데이터 저장 ///////
LInsert(&list, 1); LInsert(&list, 2);
LInsert(&list, 3); LInsert(&list, 4);
LInsert(&list, 5); LInsert(&list, 6);
LInsert(&list, 7); LInsert(&list, 8);
// 저장된 데이터의 조회 ///////
if(LFirst(&list, &data))
{
printf("%d ", data);
while(LNext(&list, &data))
printf("%d ", data);
while(LPrevious(&list, &data))
printf("%d ", data);
printf("\n\n");
}
return 0;
}
示例10: PointInitList
/* initialize a list point - sets it as an empty list */
static FSTATUS PointInitList(Point *point, PointType type)
{
DLIST *pList;
point->Type = POINT_TYPE_NONE;
switch (type) {
case POINT_TYPE_PORT_LIST:
pList = &point->u.portList;
break;
case POINT_TYPE_NODE_LIST:
pList = &point->u.nodeList;
break;
#if !defined(VXWORKS) || defined(BUILD_DMC)
case POINT_TYPE_IOC_LIST:
pList = &point->u.iocList;
break;
#endif
default:
ASSERT(0);
return FINVALID_OPERATION;
}
ListInitState(pList);
if (! ListInit(pList, MIN_LIST_ITEMS)) {
fprintf(stderr, "%s: unable to allocate memory\n", g_Top_cmdname);
return FINSUFFICIENT_MEMORY;
}
point->Type = type;
return FSUCCESS;
}
示例11: main
int main()
{
CommonDataStr commonDataStr;
CommonDataStr *commonDataPtr = &commonDataStr;
FILE *vertFilePtr;
fopen_s(&vertFilePtr, VERTEX_FILE, "r");
if (vertFilePtr == NULL)
{
printf("Fatal Error: Unable to open %s File\n", VERTEX_FILE);
return 1;
}
//Initialise the common data structure
ListInit(&commonDataPtr->vertDataHead);
commonDataPtr->numBits = 0;
commonDataPtr->numVerts = 0;
//Parse the vert file and create the vert data list
ParseVertFile(vertFilePtr, commonDataPtr);
//Decompress the bitstream file and find RMS error
DecompressFromBitStream(commonDataPtr);
//Free the vert data
FreeVertData(commonDataPtr);
fclose(vertFilePtr);
return 0;
}
示例12: TestIterator
void TestIterator()
{
List* list = ListInit();
/* Prepare the initial elements. */
CU_ASSERT(list->push_back(list, (void*)(intptr_t)1) == true);
CU_ASSERT(list->push_back(list, (void*)(intptr_t)2) == true);
CU_ASSERT(list->push_back(list, (void*)(intptr_t)3) == true);
CU_ASSERT(list->push_back(list, (void*)(intptr_t)4) == true);
/* Iterate through the list. */
void* element;
int check = 1;
list->first(list, false);
while (list->next(list, &element)) {
CU_ASSERT_EQUAL((int)(intptr_t)element, check);
++check;
}
/* Iterate through the list in reversed order. */
check = 4;
list->first(list, true);
while (list->reverse_next(list, &element)) {
CU_ASSERT_EQUAL((int)(intptr_t)element, check);
--check;
}
ListDeinit(list);
}
示例13: InitAccesses
ListNode * InitAccesses(int accesses, Array decoder, int vertices)
{
int i, *index, counter = 0;
char type;
ListNode* accesseshead = ListInit();
for(i = 0; i < vertices; i++) /*Goes through every vertice in the decoder to see if it is or not an access */
{
type = GetIP_Type(i, decoder);
if( type == 'R' || type == 'C' || type == 'H' || type == 'E' || type == 'L' ) /*If it is an access */
{
index = (int*) malloc( sizeof(int) );
VerifyMalloc((Item) index);
*index = i;
counter++;
accesseshead = AddNodeToListHead(accesseshead, (Item) index);
}
}
if(counter != accesses)
{
printf("Error. Number of read accesses doesnt match info from file.");
exit(0);
}
return accesseshead;
}
示例14: ListInit
List *ListCopy(List *in, int deep)
{
ListItem *item, *outitem;
List *out;
out = ListInit();
item = in->first;
while (item != NULL)
{
outitem = (ListItem *)lt_malloc_incontext(sizeof(ListItem), out->memory_context);
outitem->prev = out->last;
outitem->next = NULL;
outitem->DataSize = item->DataSize;
if (item->copyable != 0)
{
outitem->data = (void *)lt_malloc_incontext(outitem->DataSize, out->memory_context);
memcpy(outitem->data, item->data, outitem->DataSize);
} else {
if ((deep!=0)&&(item->DataType == DATATYPE_LIST)) outitem->data = ListCopy((List *)item->data,1);
else if ((deep!=0)&&(item->DataType == DATATYPE_DICT)) outitem->data = DictCopy((Dict *)item->data,1);
else outitem->data = item->data ;
}
outitem->copyable = item->copyable;
outitem->DataType = item->DataType;
if (out->first == NULL) out->first = outitem;
if (out->last != NULL) out->last->next = outitem;
out->last = outitem;
out->length++;
item = item->next;
}
return out;
}
示例15: TestInsert
void TestInsert()
{
List* list = ListInit();
/* Insert elements to the specified indexes. */
CU_ASSERT(list->insert(list, 1, (void*)(intptr_t)1) == false);
CU_ASSERT(list->insert(list, 0, (void*)(intptr_t)1) == true);
CU_ASSERT(list->insert(list, 1, (void*)(intptr_t)4) == true);
CU_ASSERT(list->insert(list, 1, (void*)(intptr_t)2) == true);
CU_ASSERT(list->insert(list, 2, (void*)(intptr_t)3) == true);
CU_ASSERT(list->insert(list, 0, (void*)(intptr_t)0) == true);
/* Check element insertion sequence. */
void* element;
CU_ASSERT(list->get_front(list, &element) == true);
CU_ASSERT_EQUAL(element, (void*)(intptr_t)0);
CU_ASSERT(list->get_back(list, &element) == true);
CU_ASSERT_EQUAL(element, (void*)(intptr_t)4);
CU_ASSERT(list->get_at(list, 0, &element) == true);
CU_ASSERT_EQUAL(element, (void*)(intptr_t)0);
CU_ASSERT(list->get_at(list, 1, &element) == true);
CU_ASSERT_EQUAL(element, (void*)(intptr_t)1);
CU_ASSERT(list->get_at(list, 2, &element) == true);
CU_ASSERT_EQUAL(element, (void*)(intptr_t)2);
CU_ASSERT(list->get_at(list, 3, &element) == true);
CU_ASSERT_EQUAL(element, (void*)(intptr_t)3);
CU_ASSERT(list->get_at(list, 4, &element) == true);
CU_ASSERT_EQUAL(element, (void*)(intptr_t)4);
CU_ASSERT_EQUAL(list->size(list), 5);
ListDeinit(list);
}