Generic stack impl with arrays