Changeset 312 for trunk/Include/Classes


Ignore:
Timestamp:
Aug 27, 2007, 12:38:43 AM (17 years ago)
Author:
イグトランス (egtra)
Message:

getter側のItemの戻り値の型をTにした版(Pairをジェネリクス化)。注意:現在のコンパイラではコンパイルできない。

File:
1 edited

Legend:

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

    r311 r312  
    88
    99Namespace Detail
    10     Class Pair
     10    Class Pair<TKey, T>
    1111    Public
    12         Sub Pair(key As Object, value As Object)
     12        Sub Pair(key As TKey, value As T)
    1313            Key = key
    1414            Value = value
    1515        End Sub
    1616
    17         Key As Object
    18         Value As Object
     17        Key As TKey
     18        Value As T
    1919    End Class
    2020End Namespace 'Detail
     
    3939'   End Function
    4040
    41 '   Virtual Function Item(key As Key) As T
    42     Virtual Function Item(key As Key) As Object
     41    Virtual Function Item(key As Key) As T
    4342        Imports System.Collections.Generic.Detail
    4443
     
    5453            Dim i As Long
    5554            For i = 0 To ELM(a.Count)
    56                 Dim pair = a[i] As Pair
     55                Dim pair = a[i] As Pair<T, Key>
    5756                If pair.Key.Equals(key) Then
    5857                    Return pair.Value
     
    8281            Dim i As Long
    8382            For i = 0 To ELM(a.Count)
    84                 Dim pair = a[i] As Pair
     83                Dim pair = a[i] As Pair<T, Key>
    8584                If pair.Key.Equals(key) Then
    8685                    pair.Value = value
     
    8988        End If
    9089
    91         a.Add(New Pair(key, value))
     90        a.Add(New Pair<T, Key>(key, value))
    9291    End Sub
    9392
     
    9695/*
    9796    'Operators
    98 '   Function Operator [](key As Key) As T
    99     Function Operator [](key As Key) As Object
     97    Function Operator [](key As Key) As T
    10098        Return Item[key]
    10199    End Function
     
    123121            Dim i As Long
    124122            For i = 0 To ELM(a.Count)
    125                 Dim pair = a[i] As Pair
     123                Dim pair = a[i] As Pair<T, Key>
    126124                If pair.Key.Equals(key) Then
    127125                    'Throw ArgumentError
     
    130128        End If
    131129
    132         a.Add(New Pair(key, value))
     130        a.Add(New Pair<T, Key>(key, value))
    133131    End Sub
    134132
Note: See TracChangeset for help on using the changeset viewer.