“If you’re skeptical, I really do encourage you to watch, he’s not sloppy.”
How sentinels speed up textbook algorithms and how to apply them sensibly
Full comment
See Alexandrescu’s Fastware talk on how amazingly sentinels can improve even textbook algorithms, and how to apply the approach intelligently. E.g., for a linear search, overwrite the last element with the sought after value, and do a tiny bit of work to make that safe and to undo it before return. If you’re skeptical, I really do encourage you to watch, he’s not sloppy. this video
