Afficher un message
Vieux 18/10/2007, 08h22   #1
westlaker
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Initialize the HashTable

The declaration is:
1
2 struct ListNode;
3 typedef struct ListNode *Position;
4 typedef Position List;
5 struct HashTbl;
6 typedef struct HashTbl *HashTable;
7
8 struct ListNode{
9 char name[4];
10 int GroupID;
11 Position Next;
12 };
13
14 struct HashTbl
15 {
16 int TableSize;
17 List *TheLists;
18 };
19
20 //The Initialization Function:
21
22 struct HashTbl *InitializeTable(int TableSize)
23 {
24 HashTable H;
25 int i;
26
27 H->TableSize=TableSize+3;
28
29 /* Allocate Table */
30 H=(HashTable)malloc(sizeof(struct HashTbl));
31 if(H == NULL)
32 fprintf(stderr,"Out of space!!!");
33
34 /* Allocate array of lists */
35 H->TheLists=(List *)malloc(sizeof(List)*H-
>TableSize);

36 if(H->TheLists == NULL)
37 fprintf(stderr,"Out of space!!!");
38
39 for(i = 0; i < H->TableSize; i++)
40 H->TheLists[i]=NULL;
41 return H;
42 }
43
44


Function Call:
HashTable AllThePersons= InitializeTable(1000*1000);

My idea is to Initialize the hash table with nodes of type (struct
ListNode *=List) pointers, distribute1000*1000 unit spaces to store
pointers.

The routine passed through the compiling but shut off with excepting
when running.

Could you me?

  Réponse avec citation
 
Page generated in 0,05722 seconds with 9 queries