mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 14:04:27 +01:00
Add new stack data structure
This commit is contained in:
20
frontend/lib/utils/stack.dart
Normal file
20
frontend/lib/utils/stack.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
class Stack<T> {
|
||||
final List<T> _list = [];
|
||||
|
||||
void push(T element) {
|
||||
_list.add(element);
|
||||
}
|
||||
|
||||
T pop() {
|
||||
var element = _list.last;
|
||||
_list.removeLast();
|
||||
return element;
|
||||
}
|
||||
|
||||
T peek() {
|
||||
return _list.last;
|
||||
}
|
||||
|
||||
bool get isEmpty => _list.isEmpty;
|
||||
bool get isNotEmpty => _list.isNotEmpty;
|
||||
}
|
||||
Reference in New Issue
Block a user