func (s *suite) TestMaxLenBack(c *gc.C) { const max = 5 d := deque.NewWithMaxLen(max) // Exceed the maximum length by 3 for i := 0; i < max+3; i++ { d.PushBack(i) } // Observe the the first 3 items on the front were dropped. v, ok := d.PopFront() c.Assert(ok, jc.IsTrue) c.Assert(v.(int), gc.Equals, 3) }
func (s *suite) TestMaxLenFront(c *gc.C) { const max = 5 d := deque.NewWithMaxLen(max) // Exceed the maximum length by 2 for i := 0; i < max+2; i++ { d.PushFront(i) } // Observe the the first 2 items on the back were dropped. v, ok := d.PopBack() c.Assert(ok, jc.IsTrue) c.Assert(v.(int), gc.Equals, 2) }
func newRecentIdTracker(maxLen int) *recentIdTracker { return &recentIdTracker{ ids: deque.NewWithMaxLen(maxLen), } }