A generic stack implementation.