myPathStack::myPathStack()
{
head = (PPATHNODE)malloc(sizeof(PATHNODE));
memset(head,0,sizeof(PATHNODE));
head->next = NULL;
}
myPathStack::~myPathStack()
{
free(head);
head = NULL;
}
PPATHNODE myPathStack::Push(HTREEITEM item)
{
if(item == head->hItem)
return NULL;
PPATHNODE temp = NULL;
temp = (PPATHNODE)malloc(sizeof(PATHNODE));
if(temp == NULL)
return NULL;
temp->hItem = item;
temp->next = head->next;
head->next = temp;
head->hItem = temp->hItem;//指向栈顶
return temp;
}
PPATHNODE myPathStack::Pop()
{
if(head->next == NULL)
return NULL;
PPATHNODE temp;
temp = head->next;
head->next = temp->next;
head->hItem = temp->hItem;
free(temp);
return head; //返回栈顶
}
{
head = (PPATHNODE)malloc(sizeof(PATHNODE));
memset(head,0,sizeof(PATHNODE));
head->next = NULL;
}
myPathStack::~myPathStack()
{
free(head);
head = NULL;
}
PPATHNODE myPathStack::Push(HTREEITEM item)
{
if(item == head->hItem)
return NULL;
PPATHNODE temp = NULL;
temp = (PPATHNODE)malloc(sizeof(PATHNODE));
if(temp == NULL)
return NULL;
temp->hItem = item;
temp->next = head->next;
head->next = temp;
head->hItem = temp->hItem;//指向栈顶
return temp;
}
PPATHNODE myPathStack::Pop()
{
if(head->next == NULL)
return NULL;
PPATHNODE temp;
temp = head->next;
head->next = temp->next;
head->hItem = temp->hItem;
free(temp);
return head; //返回栈顶
}