Implementación de pila utilizando la clase en DART
class stack {
late int _maxSize;
late List<int> _stackArray;
late int _top;
stack(int size) {
_maxSize = size;
_stackArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
_top = -1;
}
void push(int newPush) {
_stackArray[++_top] = newPush;
}
int pop() {
return _stackArray[_top--];
}
int peek() {
return _stackArray[_top];
}
bool isEmpty() {
if (_top == -1) {
return true;
} else {
return false;
}
}
bool isFull() {
if (_maxSize == _top) {
return true;
} else {
return false;
}
}
}
Old-fashioned Okapi