This commit is contained in:
krahets
2024-03-31 03:53:04 +08:00
parent 87af663929
commit c23e576da4
68 changed files with 2139 additions and 22 deletions

View File

@@ -1068,6 +1068,12 @@ Below is an example code for implementing a stack based on a linked list:
}
```
=== "Ruby"
```ruby title="linkedlist_stack.rb"
[class]{LinkedListStack}-[func]{}
```
=== "Zig"
```zig title="linkedlist_stack.zig"
@@ -1621,10 +1627,7 @@ Since the elements to be pushed onto the stack may continuously increase, we can
/* 出栈 */
fn pop(&mut self) -> Option<T> {
match self.stack.pop() {
Some(num) => Some(num),
None => None,
}
self.stack.pop()
}
/* 访问栈顶元素 */
@@ -1745,6 +1748,12 @@ Since the elements to be pushed onto the stack may continuously increase, we can
}
```
=== "Ruby"
```ruby title="array_stack.rb"
[class]{ArrayStack}-[func]{}
```
=== "Zig"
```zig title="array_stack.zig"