MCPcopy Create free account
hub / github.com/142vip/408CSFamily / linkStackPopNode

Function linkStackPopNode

code/ds/LinkStack.cpp:50–69  ·  view source on GitHub ↗

* 基于单链表链栈的出栈操作 * */

Source from the content-addressed store, hash-verified

48 *
49 */
50bool 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected