head=head->next;
head->forward=NULL;
work=head;若图片无法显示请联系QQ752018766
delete point2;
return address;//分配成功,返回address
}
if(point1==rear)//如果是尾节点
{
address=rear->address;
point2=rear;
rear=rear->forward;
rear->next=NULL;
delete point2;
return address;//分配成功,返回address
}
if(point1!=head&&point1!=rear)
{
address=point1->address;
point2=point1->forward;
bestnode * point3=point1->next;
point2->next=point3;
point3->forward=point2;
delete point1;
return address;//分配成功,返回address
}
若图片无法显示请联系QQ752018766
}
}
if(point1==NULL)
{
return address;//没有合适的空间,分配不成功,返回1000
}
}
//按空间大小递增建立链表
{
if(head==NULL)
{
head=rear=work=new bestnode(size,address,NULL,NULL);
}
else
{
bestnode * point1=head;
bestnode * point2;
while(point1!=NULL)
{
if(size<=point1->size)
{
if(point1==head)//如果是首部,则改动头指针
{
point2->next=head;
head->forward=point2;
head=point2;
work=point2;
}
else//如果插入点在链中
{若图片无法显示请联系QQ752018766
point2->forward=point1->forward;
point2->next=point1;
point1->forward->next=point2;
point1->forward=point2;
}
break;//插入完成,退出
}
else
{
point1=point1->next;//寻找下一个位置
}
}
if(point1==NULL)//如果插入点在链尾,改动尾指针
{
rear->next=point2;
rear=point2;
}
}
}
//判断是否输出完节点
bool bestfit_link::over()
{
if(work==NULL)
{
work=head;
return true;
}
else
{
return false;
}
}
//返回链表元素
Job bestfit_link::returnjob()
{
bestnode * point1=work;
Job pointNum;
if(point1!=NULL)
{
pointNum.size=point1->size;
}若图片无法显示请联系QQ752018766
work=work->next;
return pointNum;
}
#endif