Generic LIFO stack, with a method to print the top n elements