Generic stack implementation using array