Complete stack_queue implementation