You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
removing an element from a stack does not always work, since the
predecessor of a stack element is not (always) stored. this patch
merges the array head into next, so a top element in a stack can point
to the head of the stack it is in.
remarks:
- i am guessing the intended use (see test below), as it works like that
for elements deeper down in a stack
- the fix abuses pointers/iterators and infers offsets from address
differences. (yes it's a bit ugly.)
- memory needs and complexity are unaffected, size_type is probably big
enough.
test case. B is a bucketsorter operating on a vector V.
V[0]=0;
V[1]=1;
B.push(0);
B.push(1);
// now, stacks 0 and 1 are singletons.
// try to move 0 to stack #1, should result in
// head_1->0->1->end, but calls remove first, then
V[0]=1;
B.update(0); // <- BOOM
// the update calls remove, it "removes" 0 from stack #V[0]=1.
// it's not there yet (!).
// instead 1 (top of bucket #1) must die.
// the result is head_1->0->end, and wrong.
0 commit comments