MCPcopy Create free account
hub / github.com/benbjohnson/immutable / validateBackwardIterator

Method validateBackwardIterator

immutable_test.go:380–396  ·  view source on GitHub ↗
(typ string, itr *ListIterator[int])

Source from the content-addressed store, hash-verified

378}
379
380func (l *TList) validateBackwardIterator(typ string, itr *ListIterator[int]) error {
381 itr.Last()
382 for i := len(l.std) - 1; i >= 0; i-- {
383 if j, v := itr.Prev(); i != j || l.std[i] != v {
384 return fmt.Errorf("ListIterator.Prev()=<%v,%v>, expected <%v,%v> [%s]", j, v, i, l.std[i], typ)
385 }
386
387 done := i == 0
388 if v := itr.Done(); v != done {
389 return fmt.Errorf("ListIterator.Done()=%v, expected %v [%s]", v, done, typ)
390 }
391 }
392 if i, v := itr.Prev(); i != -1 || v != 0 {
393 return fmt.Errorf("ListIterator.Prev()=<%v,%v>, expected DONE [%s]", i, v, typ)
394 }
395 return nil
396}
397
398func BenchmarkList_Append(b *testing.B) {
399 b.ReportAllocs()

Callers 1

ValidateMethod · 0.95

Calls 3

LastMethod · 0.45
PrevMethod · 0.45
DoneMethod · 0.45

Tested by

no test coverage detected