This commit is contained in:
krahets
2023-10-03 03:49:55 +08:00
parent 256ce30a95
commit 49ad0a6422
12 changed files with 166 additions and 16 deletions

View File

@@ -288,20 +288,16 @@ comments: true
stack.push(4);
/* 访问栈顶元素 */
if let Some(top) = stack.get(stack.len() - 1) {
}
if let Some(top) = stack.last() {
}
let top = stack[stack.len() - 1];
/* 元素出栈 */
if let Some(pop) = stack.pop() {
}
let pop = stack.pop().unwrap();
/* 获取栈的长度 */
let size = stack.len();
/* 判断是否为空 */
let isEmpty = stack.is_empty();
let is_empty = stack.is_empty();
```
=== "C"