Monotonic replacement algorithms and their implementation