Tous Fini
please use "gcc Block*" to compile the code
This commit is contained in:
parent
57fb482c0a
commit
c1eef852db
@ -63,6 +63,10 @@ void DeleteList(SList *list)
|
|||||||
SCell *GetCellFromBlock(SList *list)
|
SCell *GetCellFromBlock(SList *list)
|
||||||
{
|
{
|
||||||
SCell *pcell;
|
SCell *pcell;
|
||||||
|
if ((pcell = GetCellFromRecycle(list)))
|
||||||
|
{
|
||||||
|
return pcell;
|
||||||
|
}
|
||||||
while (!(pcell = _GetCellFromBlock(list->block)))
|
while (!(pcell = _GetCellFromBlock(list->block)))
|
||||||
{
|
{
|
||||||
AddBlock(list->block);
|
AddBlock(list->block);
|
||||||
@ -97,6 +101,16 @@ SCell *_GetCellFromBlock(SBlock *bList)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCell *GetCellFromRecycle(SList *list)
|
||||||
|
{
|
||||||
|
SCell *pcell = list->recycle;
|
||||||
|
if (pcell != NULL)
|
||||||
|
{
|
||||||
|
list->recycle = pcell->next;
|
||||||
|
}
|
||||||
|
return pcell;
|
||||||
|
}
|
||||||
|
|
||||||
SCell *AddElementBegin(SList *list, int data)
|
SCell *AddElementBegin(SList *list, int data)
|
||||||
{
|
{
|
||||||
SCell *cell = GetCellFromBlock(list);
|
SCell *cell = GetCellFromBlock(list);
|
||||||
|
@ -16,7 +16,9 @@ SCell *AddElementEnd(SList *list, Data elem);
|
|||||||
SCell *AddElementAfter(SList *list, SCell *cell, Data elem);
|
SCell *AddElementAfter(SList *list, SCell *cell, Data elem);
|
||||||
void DeleteCell(SList *list, SCell *cell);
|
void DeleteCell(SList *list, SCell *cell);
|
||||||
void PrintRecycleList(SList *list);
|
void PrintRecycleList(SList *list);
|
||||||
SCell* RecycleCell(SCell *, SCell *cell);
|
SCell *RecycleCell(SCell *head, SCell *cell);
|
||||||
|
SCell *GetCellFromBlock(SList *list);
|
||||||
|
SCell *GetCellFromRecycle(SList *list);
|
||||||
|
|
||||||
SCell *GetFirstElement(SList *list);
|
SCell *GetFirstElement(SList *list);
|
||||||
SCell *GetLastElement(SList *list);
|
SCell *GetLastElement(SList *list);
|
||||||
|
@ -32,6 +32,11 @@ int main()
|
|||||||
PrintBlockList(list);
|
PrintBlockList(list);
|
||||||
PrintRecycleList(list);
|
PrintRecycleList(list);
|
||||||
|
|
||||||
|
AddElementEnd(list, 10);
|
||||||
|
PrintList(list);
|
||||||
|
PrintBlockList(list);
|
||||||
|
PrintRecycleList(list);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
// printf("Add 5, 3, 1\n");
|
// printf("Add 5, 3, 1\n");
|
||||||
|
BIN
TP3/List/a.out
BIN
TP3/List/a.out
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user