#define HTMAX 1133
typedef struct node
{
int key;
char nodename[11];
struct node* last;
struct node* next;
}node_t;
node_t nodes[1000];
int nodeIdx = 0;
node_t* htnode[HTMAX];
node_t* cn()
{
node_t* nn = &nodes[nodeIdx];
nn->key = 0;
nn->last = 0;
return nn;
}
void an(node_t* addnode)
{
int key = addnode->key;
node_t* head = htnode[key];
htnode[key] = addnode;
addnode->next = head;
if (head != 0)
head->last = addnode;
}
void rn(node_t* delnode)
{
int key = delnode->key;
node_t* bef = delnode->last;
node_t* aft = delnode->next;
if (bef == 0)
{
htnode[key] = aft;
}
if (bef != 0)
bef->next = aft;
if (aft != 0)
aft->last = bef;
}
网友评论