Skip to content

Extra functionalities

Jean-Francois Baffier edited this page Mar 28, 2017 · 6 revisions

Extra functionalities for any Stack Algorithm run will add some overhead to the minimal code. As the aim of most of the users of this library is to optimize space efficiency while marginally reducing the execution time, we chose to provide some of those extra functionalities as options. Any such space-consuming option, current and future, can be found in the extras/ folder.

Classic Stack (as an optional functionality)

Some users might want to use a classic stack structure within our Stack Algorithm framework. The most obvious reason would be to fully beneficiate of the speed of the Classic Stack while ignoring the space consumption.

Another reason might be related to debugging purposes. Some bugs could be existing only through the Compressed Stack structure, and running the user's algorithm on the Classic Stack can confirm the origin of such bugs.

Finally, we also provide another Stack Algorithm in extras/stackAlgoExtras.hpp that possesses both a compressed stack and a classic stack. This class will run and compare the state of both stacks all along the execution of the algorithm. Specific errors are raised to signal any difference in behavior.

Counting functions

For debugging and analyzing purpose we propose simple counting functions inside any Stack Algorithm. All of them can be called anytime before, during, and after the execution of the Stack Algorithm.

  • Counting pops, pushes, and the number of elements currently in the stack
SomeStackAlgo instance;

instance.getPops();
instance.getPushes();
instance.countItems();
  • Counting the maximum number of elements that have been in the stack
SomeStackAlgo instance;

instance.getMaxItems();
Clone this wiki locally