github.com/primecitizens/pcz/std@v0.2.1/core/iter/iterex.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  
     4  package iter
     5  
     6  // CoreEx is like Core but accepts an extra argument.
     7  type CoreEx[Arg, Elem any] interface {
     8  	NthEx(Arg, int) (Elem, bool)
     9  }
    10  
    11  // FiniteEx is like Finite but takes an extra argument.
    12  type FiniteEx[Arg any] interface {
    13  	LenEx(Arg) int
    14  }
    15  
    16  // DivisibleEx is Divisible with an extra argument.
    17  type DivisibleEx[Arg, Self any] interface {
    18  	SliceFromEx(arg Arg, start int) Self
    19  }
    20  
    21  type InterfaceEx[Arg, Elem, Self any] interface {
    22  	CoreEx[Arg, Elem]
    23  	FiniteEx[Arg]
    24  	DivisibleEx[Arg, Self]
    25  }
    26  
    27  // FuncEx implements CoreEx for function.
    28  type FuncEx[Arg, Elem any] func(Arg, int) (Elem, bool)
    29  
    30  func (fn FuncEx[Arg, Elem]) NthEx(arg Arg, i int) (Elem, bool) {
    31  	return fn(arg, i)
    32  }