📄 sllist.h
字号:
////按权有序(从小到大)的链表类
#ifndef SLLIST_H
#define SLLIST_H
class node{
public:
HuffTree htree;
node *next;
};
class SLList{
node *head;
int listcount;
void init(){
head=new node;
head->next=NULL;
listcount=0;
}
void removeall(){
node * fence;
while(head!=NULL){
fence=head;
head=head->next;
delete fence;
}
}
public:
SLList(){
init();
}
SLList(HuffTree*){
}
~SLList(){
removeall();
}
void traverse(){
for(node*nptmp=head->next;nptmp!=NULL;nptmp=nptmp->next)
cout<<nptmp->htree.root()->weight()<<" ";
}
int Listcount(){
return listcount;
}
bool insert(HuffTree *htreein){
node *tmp=new node;
tmp->htree=*htreein;
for(node *nptmp=head;nptmp->next!=NULL&&(nptmp->next->htree.weight())<(htreein->weight());nptmp=nptmp->next);
tmp->next=nptmp->next;
nptmp->next=tmp;
listcount++;
return true;
};
bool remove(HuffTree *htreeout){
*htreeout=head->next->htree;
node* tmp=head->next;
head->next=tmp->next;
listcount--;
delete tmp;
return true;
};
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -