MCPcopy Create free account
hub / github.com/Soft/iter / Nth

Function Nth

iterator.go:452–462  ·  view source on GitHub ↗

Nth returns nth element of the Iterator.

(it Iterator[T], n uint)

Source from the content-addressed store, hash-verified

450
451// Nth returns nth element of the Iterator.
452func Nth[T any](it Iterator[T], n uint) Option[T] {
453 v := it.Next()
454 for n > 0 {
455 if v.IsNone() {
456 break
457 }
458 v = it.Next()
459 n--
460 }
461 return v
462}
463
464// Determines if the elements of two Iterators are equal.
465func Equal[T comparable](first Iterator[T], second Iterator[T]) bool {

Callers 1

TestNthFunction · 0.85

Calls 2

IsNoneMethod · 0.80
NextMethod · 0.65

Tested by 1

TestNthFunction · 0.68