Ignore:
Timestamp:
Dec 18, 2007, 2:55:40 AM (16 years ago)
Author:
dai
Message:

Foreachを試験的に実装。
ジェネリクスインターフェイスをサポートした。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Include/Classes/System/Collections/Generic/List.ab

    r387 r396  
    44Namespace Generic
    55
     6Interface IEnumerable<T>
     7    ' Method
     8    Function GetEnumerator() As IEnumerator<T>
     9End Interface
     10
     11Interface IEnumerator<T>
     12    ' Methods
     13    Function MoveNext() As Boolean
     14    Sub Reset()
     15    ' Property
     16    Function Current() As T
     17End Interface
     18
    619Class List<T>
    7     Implements IEnumerable, IEnumerator
     20    Implements IEnumerable<T>, IEnumerator<T>
    821    items As *T
    922    size As Long
     
    138151    @return IEnumeratorインターフェイスが返る
    139152    */
    140     Function GetEnumerator() As IEnumerator
     153    Function GetEnumerator() As IEnumerator<T>
    141154        Return This
    142155    End Function
     
    173186    @return カレントオブジェクトが返る
    174187    */
    175     Function Current() As Object
     188    Function Current() As T
    176189        If currentIndexForEnumerator = -1 Then
    177190            ' MoveNextメソッドがReset後、一度も呼び出されなかった
    178191            Return Nothing
    179192        End If
    180         Return items[currentIndexForEnumerator] As Object
     193        Return items[currentIndexForEnumerator]
    181194    End Function
    182195End Class
Note: See TracChangeset for help on using the changeset viewer.