* 基于单链表链栈的出栈操作 * */
| 48 | * |
| 49 | */ |
| 50 | bool linkStackPopNode(LinkStack* linkStack,int *e){ |
| 51 | // 判断链栈是否存在及是否为空 |
| 52 | if (!linkStack || linkStack->count==0){ |
| 53 | //出栈失败,返回false |
| 54 | return false; |
| 55 | } |
| 56 | // 获取栈顶元素结点 |
| 57 | StackNode* node = stack->top; |
| 58 | |
| 59 | // 结点元素数据域赋值给变量e |
| 60 | *e = linkStack->data; |
| 61 | // 移动栈顶指向,栈顶指针指向待出栈结点的后继结点 |
| 62 | linkStack->top = node->next; |
| 63 | // 变量e已被赋值,释放链栈出栈元素的内存控件 |
| 64 | free(node); |
| 65 | // 链栈元素个数-1 |
| 66 | linkStack->count--; |
| 67 | // 出栈成功,返回true. |
| 68 | return true; |
| 69 | } |
nothing calls this directly
no outgoing calls
no test coverage detected