Ignore:
Timestamp:
Aug 8, 2008, 12:15:30 AM (16 years ago)
Author:
dai
Message:
  • ForeachがIDisposableを実装したIEnumerator<T>を取り扱うように変更
  • #120(列挙体のUnicode対応)の修正
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/ablib/src/Classes/System/Collections/Generic/Stack.ab

    r577 r579  
    1818    Sub Stack ()
    1919        This.items = GC_malloc( 1 )
    20         Reset()
    2120    End Sub
    2221
    2322    Sub Stack ( capacity As Long )
    2423        This.items = GC_malloc( 1 )
    25         Reset()
    2624        If capacity > 0 Then
    2725            This.size = capacity
     
    6462    */
    6563    Override Function GetEnumerator () As IEnumerator<T>
    66         Return This
     64        Return New Detail.PointerEnumerator(items, count)
    6765    End Function
    6866
     
    117115        End If
    118116    End Sub
    119 
    120 
    121     '------------------------
    122     '   IEnumeratorの実装
    123     '------------------------
    124     currentIndexForEnumerator As Long
    125 
    126     Override Function Current () As T
    127         If This.currentIndexForEnumerator = -1 Then
    128             ' MoveNextメソッドがReset後、一度も呼び出されなかった
    129             Return Nothing
    130         End If
    131         Return This.items[ This.currentIndexForEnumerator ]
    132     End Function
    133 
    134     Override Function MoveNext() As Boolean
    135         If This.currentIndexForEnumerator + 1 >= This.count Then
    136             ' 上限に達した
    137             Return False
    138         End If
    139 
    140         This.currentIndexForEnumerator ++
    141         Return True
    142     End Function
    143 
    144     Override Sub Reset ()
    145         This.currentIndexForEnumerator = -1
    146     End Sub
    147117End Class
    148118
Note: See TracChangeset for help on using the changeset viewer.