resizing array stack implementation with generics and custom iterator