Changeset 631


Ignore:
Timestamp:
2008/09/22 05:31:01 (4 years ago)
Author:
NoWest
Message:

List<T>、Stack<T>、Queue<T>を相互にIEnumerator<T>を使って変換できるようにしました。

List<T>クラスからReadOnlyCollectionの呼び出しがコンパイルできません。
どうしても問題を再現できなかったので、皆さんの所でも問題が発生するか確認のためにupしておきます。
やっぱり問題がおきたら、RevertするかListのAsReadOnlyメソッドをコメントアウトしてください。

Location:
trunk/ab5.0/ablib/src/Classes/System/Collections
Files:
4 edited

Legend:

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

    r592 r631  
    8080    @author NoWest 
    8181    @date   2008/07/13 
    82     @param  インデックス 
     82    @param  基になる配列へのポインタ 
     83    @param  配列の長さ 
    8384    */ 
    8485    Sub List( array As *T, length As Long ) 
     
    8788        memmove( This.items, array, length * SizeOf(T) ) 
    8889        This.count = length 
     90    End Sub 
     91 
     92    /*! 
     93    @brief  既存のIEnumerator<T>使用してListを初期化 
     94    @author NoWest 
     95    @date   2008/09/22 
     96    @param  基になるIEnumerator<T> 
     97    */ 
     98    Sub List ( enumerator As IEnumerator<T> ) 
     99        _Initialize( 1 ) 
     100        While enumerator.MoveNext() 
     101            'This.Add(enumerator.Current()) 
     102        Wend 
    89103    End Sub 
    90104 
     
    185199    End Sub 
    186200 
    187 '   Function AsReadOnly() As ReadOnlyCollection 
     201    /*! 
     202    @brief  読み取り専用のListのラッパーを取得 
     203    @author NoWest 
     204    @date   2008/09/22 
     205    */ 
     206    Function AsReadOnly() As System.Collections.ObjectModel.ReadOnlyCollection<T> 
     207        Return New System.Collections.ObjectModel.ReadOnlyCollection<T>(This) 
     208    End Function 
    188209 
    189210    /*! 
  • trunk/ab5.0/ablib/src/Classes/System/Collections/Generic/Queue.ab

    r607 r631  
    1515    End Sub 
    1616 
     17    Sub initialize() 
     18        This.items = GC_malloc(1) 
     19    End Sub 
     20 
    1721Public 
    1822    Sub Queue () 
    19         This.items = GC_malloc( 1 ) 
     23        This.initialize() 
    2024    End Sub 
    2125 
    2226    Sub Queue ( capacity As Long ) 
    23         This.items = GC_malloc( 1 ) 
     27        This.initialize() 
    2428        If capacity > 0 Then 
    2529            This.size = capacity 
    2630            Realloc(capacity) 
    2731        End If 
     32    End Sub 
     33 
     34    Sub Queue ( enumerator As IEnumerator<T> ) 
     35        This.initialize() 
     36        While enumerator.MoveNext() 
     37            This.Enqueue(enumerator.Current()) 
     38        Wend 
    2839    End Sub 
    2940 
  • trunk/ab5.0/ablib/src/Classes/System/Collections/Generic/Stack.ab

    r607 r631  
    1515    End Sub 
    1616 
     17    Sub initialize() 
     18        This.items = GC_malloc(1) 
     19    End Sub 
    1720Public 
    1821    Sub Stack () 
    19         This.items = GC_malloc( 1 ) 
     22        This.initialize() 
    2023    End Sub 
    2124 
    2225    Sub Stack ( capacity As Long ) 
    23         This.items = GC_malloc( 1 ) 
     26        This.initialize() 
    2427        If capacity > 0 Then 
    2528            This.size = capacity 
    2629            Realloc(capacity) 
    2730        End If 
     31    End Sub 
     32 
     33    Sub Stack ( enumerator As IEnumerator<T> ) 
     34        This.initialize() 
     35        While enumerator.MoveNext() 
     36            This.Push(enumerator.Current()) 
     37        Wend 
    2838    End Sub 
    2939 
  • trunk/ab5.0/ablib/src/Classes/System/Collections/ObjectModel/ReadOnlyCollection.ab

    r619 r631  
    66 
    77Class ReadOnlyCollection<T> 
    8     Implements Generic.IList<T> 
    9     list As Generic.IList<T> 
     8    Implements System.Collections.Generic.IList<T> 
     9    list As System.Collections.Generic.IList<T> 
    1010 
    1111Public 
    1212    'Collection クラスの新しいインスタンスを初期化します。  
    1313    Sub ReadOnlyCollection () 
    14         This.list = New Generic.List<T> 
     14        Dim l = New System.Collections.Generic.List<T> 
     15        This.list = l 
    1516    End Sub 
    16     Sub ReadOnlyCollection ( list As Generic.IList<T> ) 
     17    Sub ReadOnlyCollection ( list As System.Collections.Generic.IList<T> ) 
    1718        This.list = list 
    1819    End Sub 
     
    3536    'Collection をラップする IList ラッパーを取得します。  
    3637    Function Items () As Generic.IList<T> 
    37         Return list 
     38        Return This 
    3839    End Function 
    3940 
     
    5758 
    5859    'Collection を反復処理する列挙子を返します。  
    59     Override Function GetEnumerator () As Generic.IEnumerator<T> 
     60    Override Function GetEnumerator () As System.Collections.Generic.IEnumerator<T> 
    6061        Return This.list.GetEnumerator() 
    6162    End Function 
Note: See TracChangeset for help on using the changeset viewer.