Write a generic Stack implementation.