Skip to content

Commit 0ac392a

Browse files
committed
!!! BREAKING !!! [list]: Pop() pops from the front of the list, not the back
1 parent d30cacd commit 0ac392a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (ll *LockingList) Pop() any {
217217
return nil
218218
}
219219
_ = ll.Lock()
220-
e := ll.l.Back()
220+
e := ll.l.Front()
221221
ll.l.Remove(e)
222222
ll.Unlock()
223223
return e.Value

list/list_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,9 @@ func TestThePlanet(t *testing.T) {
430430
t.Errorf("Push(%d) = %v, want nil", i, err)
431431
}
432432
}
433-
for i := 4; i > 0; i-- {
434-
if pl.Pop() != i {
435-
t.Errorf("Pop() = %d, want %d", pl.Pop(), i)
433+
for i := 1; i < 5; i++ {
434+
if got := pl.Pop(); got != i {
435+
t.Errorf("Pop() = %d, want %d", got, i)
436436
}
437437
}
438438
for i := 1; i < 5; i++ {
@@ -450,7 +450,7 @@ func TestThePlanet(t *testing.T) {
450450
wg.Add(1)
451451
go func(n int) {
452452
if cerr := cl.Push(n); cerr != nil {
453-
t.Errorf("Push(%d) err = %v, want nil", i, cerr)
453+
t.Errorf("Push(%d) err = %v, want nil", n, cerr)
454454
}
455455
wg.Done()
456456
}(i)

0 commit comments

Comments
 (0)