Tous Fini

please use "gcc Block*" to compile the code
This commit is contained in:
MAO Dongyang 2023-03-20 18:08:09 +01:00
parent 57fb482c0a
commit c1eef852db
No known key found for this signature in database
4 changed files with 22 additions and 1 deletions

View File

@ -63,6 +63,10 @@ void DeleteList(SList *list)
SCell *GetCellFromBlock(SList *list)
{
SCell *pcell;
if ((pcell = GetCellFromRecycle(list)))
{
return pcell;
}
while (!(pcell = _GetCellFromBlock(list->block)))
{
AddBlock(list->block);
@ -97,6 +101,16 @@ SCell *_GetCellFromBlock(SBlock *bList)
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 *cell = GetCellFromBlock(list);

View File

@ -16,7 +16,9 @@ SCell *AddElementEnd(SList *list, Data elem);
SCell *AddElementAfter(SList *list, SCell *cell, Data elem);
void DeleteCell(SList *list, SCell *cell);
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 *GetLastElement(SList *list);

View File

@ -32,6 +32,11 @@ int main()
PrintBlockList(list);
PrintRecycleList(list);
AddElementEnd(list, 10);
PrintList(list);
PrintBlockList(list);
PrintRecycleList(list);
printf("\n");
// printf("Add 5, 3, 1\n");

Binary file not shown.