15-Nov-2014 01:16, IgorStepanov пишет:
Recently I encountered the following problem. I need a simple stack of uint. I want to push uints back and pop it. I don't want to copy this stack and I want it to work fast.In a first approximation, the problem seems easy. uint[] my_stack; my_stack.reserve(256); my_stack ~= 1; //push uint head = my_stack[$ - 1]; //top my_stack.length--; //pop
Just make push into: my_stack.assumeSafeAppend(); my_stack ~= value; To avoid relocations. -- Dmitry Olshansky
