Algorithms: fixed size stack with templates