Imports System.Runtime.CompilerServices
Imports System.Collections.Generic

Module IListExtensions
    <Extension>
    Public Function IterateForward(Of T)(src As IList(Of T)) As IEnumerable(Of T)
        Return IterateForward(src, 0)
    End Function

    <Extension>
    Public Function IterateForward(Of T)(src As IList(Of T), startIndex As Integer) As IEnumerable(Of T)
        Return New CircularIterator(Of T)(src).IterateForward(startIndex)
    End Function

    <Extension>
    Public Function IterateBackwards(Of T)(src As IList(Of T)) As IEnumerable(Of T)
        Return IterateBackwards(src, src.Count - 1)
    End Function

    <Extension>
    Public Function IterateBackwards(Of T)(src As IList(Of T), startIndex As Integer) As IEnumerable(Of T)
        Return New CircularIterator(Of T)(src).IterateBackwards(startIndex)
    End Function
End Module
