here's a
stack:

        T[] stack;
        void push(elem) {
                stack ~= elem;
        }
        T pop() {
                T elem = stack[$-1];
                stack = stack[0..$-1];
                return elem;
        }

Won't this reallocate every time you pop an element and then push a new one?


Reply via email to