Skip to content

Commit

Permalink
ref(collections): rename BeginIt to ForwardIt (#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
plastikfan committed Dec 11, 2023
1 parent 457b6c1 commit c6bcfcd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions collections/iterators.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type Iterator[T any] interface {
Reset(entries []T)
}

// BeginIt creates a forward iterator over a non empty slice. If the provided
// ForwardIt creates a forward iterator over a non empty slice. If the provided
// slice is empty, then a nil iterator is returned.
//
// The zero value represents the value that is returned if the Next method on the
Expand All @@ -62,7 +62,7 @@ type Iterator[T any] interface {
// Next after Valid has returned false. This is preferable than generating a
// panic. If the collection contains structs, then pass in an empty struct
// as the nil value.
func BeginIt[T any](elements []T, zero T) Iterator[T] {
func ForwardIt[T any](elements []T, zero T) Iterator[T] {
// 📚 NB: it is not possible to obtain the type of a generic parameter at runtime
// using reflection. Generics in Go are a compile-time feature, and type information
// is generally not available at runtime due to the language's design principles.
Expand Down
10 changes: 5 additions & 5 deletions collections/iterators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func getSleeveIt(forward bool, sequence []sleeve) collections.Iterator[sleeve] {
return lo.TernaryF(
forward,
func() collections.Iterator[sleeve] {
return collections.BeginIt(sequence, nil)
return collections.ForwardIt(sequence, nil)
},
func() collections.Iterator[sleeve] {
return collections.ReverseIt(sequence, nil)
Expand All @@ -62,7 +62,7 @@ func getRecordPtrIt(forward bool, sequence []*record) collections.Iterator[*reco
return lo.TernaryF(
forward,
func() collections.Iterator[*record] {
return collections.BeginIt(sequence, nil)
return collections.ForwardIt(sequence, nil)
},
func() collections.Iterator[*record] {
return collections.ReverseIt(sequence, nil)
Expand All @@ -74,7 +74,7 @@ func getRecordsIt(forward bool, sequence []record) collections.Iterator[record]
return lo.TernaryF(
forward,
func() collections.Iterator[record] {
return collections.BeginIt(sequence, record{})
return collections.ForwardIt(sequence, record{})
},
func() collections.Iterator[record] {
return collections.ReverseIt(sequence, record{})
Expand All @@ -86,7 +86,7 @@ func getInt32It(forward bool, sequence []int32) collections.Iterator[int32] {
return lo.TernaryF(
forward,
func() collections.Iterator[int32] {
return collections.BeginIt(sequence, int32(0))
return collections.ForwardIt(sequence, int32(0))
},
func() collections.Iterator[int32] {
return collections.ReverseIt(sequence, int32(0))
Expand Down Expand Up @@ -282,7 +282,7 @@ var _ = Describe("Iterators", func() {
it := lo.TernaryF(
entry.forward,
func() collections.Iterator[sleeve] {
return collections.BeginIt(entry.sleeves, nil)
return collections.ForwardIt(entry.sleeves, nil)
},
func() collections.Iterator[sleeve] {
return collections.ReverseIt(entry.sleeves, nil)
Expand Down
2 changes: 1 addition & 1 deletion xfs/nav/sampling-while-iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (i *directoryEntryWhileIt) start(entries []fs.DirEntry) {
if i.isNil() {
i.iterator = lo.TernaryF(i.forward,
func() collections.Iterator[fs.DirEntry] {
return collections.BeginIt[fs.DirEntry](entries, i.zero)
return collections.ForwardIt[fs.DirEntry](entries, i.zero)
},
func() collections.Iterator[fs.DirEntry] {
return collections.ReverseIt[fs.DirEntry](entries, i.zero)
Expand Down

0 comments on commit c6bcfcd

Please sign in to comment.