implement stack_t

added shrink_to_fit as well.