Skip to content

Commit

Permalink
Merge pull request #128 from NULLx76/enqueue-return
Browse files Browse the repository at this point in the history
implement returning of old elements on enqueue
  • Loading branch information
jdonszelmann authored May 16, 2024
2 parents 137f388 + 088f780 commit 75fe4f1
Show file tree
Hide file tree
Showing 8 changed files with 272 additions and 264 deletions.
12 changes: 6 additions & 6 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ fn benchmark_push_dequeue<T: RingBuffer<i32>, F: Fn() -> T>(b: &mut Bencher, new
let mut rb = new();

for _i in 0..100_000 {
rb.enqueue(1);
let _ = rb.enqueue(1);
black_box(());
rb.enqueue(2);
let _ = rb.enqueue(2);
black_box(());

assert_eq!(black_box(rb.dequeue()), Some(1));
assert_eq!(black_box(rb.dequeue()), Some(2));

rb.enqueue(1);
let _ = rb.enqueue(1);
black_box(());
rb.enqueue(2);
let _ = rb.enqueue(2);
black_box(());

assert_eq!(black_box(rb.dequeue()), Some(1));
assert_eq!(black_box(rb.dequeue()), Some(2));

rb.enqueue(1);
let _ = rb.enqueue(1);
black_box(());
rb.enqueue(2);
let _ = rb.enqueue(2);
black_box(());

assert_eq!(black_box(rb.get_signed(-1)), Some(&2));
Expand Down
Loading

1 comment on commit 75fe4f1

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.