Stack - LIFO



examples/dart-intro/stack.dart
import 'dart:collection';

main() {
  Queue dentist = new Queue();

  dentist.addLast("Foo");
  dentist.addLast("Bar");
  print(dentist.removeLast()); // Bar
  print(dentist.removeLast()); // Foo
}

The same Queue class can be also used to implement a Stack. Apparently adding at both ends and removing from both ends of a Queue class is fast and thus this class is optimal for both FIFO and LIFO data structures.