- Timestamp:
- Dec 8, 2007, 11:16:57 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/Classes/System/Collections/Generic/Dictionary.ab
r366 r393 40 40 41 41 Virtual Function Item(key As Key) As T 42 Imports System.Collections.Generic.Detail43 44 42 If Object.ReferenceEquals(key, Nothing) Then 45 43 'Throw ArgumentNullError … … 48 46 End If 49 47 50 Dim hash = key.GetHashCode Mod al.Count48 Dim hash = getHash(key) 51 49 Dim a = al[hash] As ArrayList 52 50 … … 54 52 Dim i As Long 55 53 For i = 0 To ELM(a.Count) 56 Dim pair = a[i] As Pair54 Dim pair = a[i] As Detail.Pair 57 55 If pair.Key.Equals(key) Then 58 56 Return pair.Value … … 63 61 'KeyNotFoundException 64 62 Return Nothing 65 66 63 End Function 67 64 68 65 Virtual Sub Item(key As Key, value As T) 69 Imports System.Collections.Generic.Detail70 71 66 If Object.ReferenceEquals(key, Nothing) Then 72 67 'Throw ArgumentNullError … … 74 69 End If 75 70 76 Dim hash = key.GetHashCode Mod al.Count71 Dim hash = getHash(key) 77 72 Dim a = al[hash] As ArrayList 78 73 … … 83 78 Dim i As Long 84 79 For i = 0 To ELM(a.Count) 85 Dim pair = a[i] As Pair80 Dim pair = a[i] As Detail.Pair 86 81 If pair.Key.Equals(key) Then 87 82 pair.Value = value … … 90 85 End If 91 86 92 a.Add(New Pair(key, value))87 a.Add(New Detail.Pair(key, value)) 93 88 End Sub 94 89 … … 108 103 'Methods 109 104 Sub Add(key As Key, value As T) 110 Imports System.Collections.Generic.Detail111 112 105 If Object.ReferenceEquals(key, Nothing) Then 113 106 'Throw ArgumentNullError … … 115 108 End If 116 109 117 Dim hash = key.GetHashCode Mod al.Count110 Dim hash = getHash(key) 118 111 Dim a = al[hash] As ArrayList 119 112 … … 124 117 Dim i As Long 125 118 For i = 0 To ELM(a.Count) 126 Dim pair = a[i] As Pair119 Dim pair = a[i] As Detail.Pair 127 120 If pair.Key.Equals(key) Then 128 121 'Throw ArgumentError … … 131 124 End If 132 125 133 a.Add(New Pair(key, value))126 a.Add(New Detail.Pair(key, value)) 134 127 135 count 128 count++ 136 129 End Sub 137 130 … … 168 161 Sub initialize(c As Long) 169 162 al = ArrayList.Repeat(Nothing, c) 170 Dim e = al[0]171 Dim p = ObjPtr(e) As ULONG_PTR172 173 163 count = 0 174 164 End Sub 165 166 Function getHash(key As Object) As Long 167 Return (key.GetHashCode As DWord) Mod al.Count 168 End Function 175 169 176 170 al As ArrayList
Note:
See TracChangeset
for help on using the changeset viewer.