BOOL push (TSNODE_p_t *stack, TNODE_p_t data) { TSNODE_p_t temp = initTSNode(data); if (*stack == NULL) { *stack = temp; return YES; } TSNODE_p_t head = *stack; TSNODE_p_t last = head->prev; last->next = temp; temp->next = head; head->prev = temp; temp->prev = last; return YES; }
BOOL insertListRear (TSNODE_p_t *list, TNODE_p_t data) { TSNODE_p_t temp = initTSNode(data); if (*list == NULL) { *list = temp; return YES; } TSNODE_p_t head = *list; TSNODE_p_t last = head->prev; temp->prev = last; last->next = temp; temp->next = head; head->prev = temp; return YES; }