Closed scotts closed 3 years ago
Consider this example for Two-Stacks Lite, from page 7 of the arXiv paper:
When we pop "c", the data structure does not contain anything that is just "c". And returning "cd..g" is arbitrary as well as inconsistent with how other algorithms would behave.
Yes, agreed, I understand now. I will submit a PR soon which changes the trait so that pop does not return a value.
@hirzel brought this up in a PR:
I had a similar reaction when @segeljakt first designed
FifoWindow
. The main reason for doing it is that is lines up with Rust conventions. Regarding point 1, I don't think it's a major concern: if the return value ofpop
is unused, and the call topop
itself is inlined, dead-code elimination should avoid any overhead (even the call to lower should go away).Point 2 is more of a concern, but I admit I don't fully follow it. Is the problem that in some cases, the partial result from the thing being evicted is nonsensical to return?