'Classes/System/Collections/Generic/Dictionary.ab '#require Namespace System Namespace Collections Namespace Generic Namespace Detail Class Pair Public Sub Pair(key As Key, value As T) Key = key Value = value End Sub Key As Key Value As T End Class End Namespace 'Detail Class Dictionary Public 'Constructor Sub Dictionary() initialize(23) End Sub ' Sub Dictionary(d As IDictionary) ' Sub Dictionary(comparer As IEqualityComparer) Sub Dictionary(capacity As Long) initialize(capacity) End Sub ' Sub Dictionary(d As IDictionary, comparer As IEqualityComparer) ' Sub Dictionary(capacity As Long, comparer As IEqualityComparer) 'Properties ' Function Comparer() As IEqualityComparer ' Virtual Function Count() As Long ' End Function ' Virtual Function Item(key As Key) As T Virtual Function Item(key As Key) As Object Imports System.Collections.Generic.Detail Imports System.Diagnostics If Object.ReferenceEquals(key, Nothing) Then 'Throw ArgumentNullError Exit Sub End If Dim hash = key.GetHashCode Mod al.Count Dim a = al[hash] As ArrayList If Not Object.ReferenceEquals(a, Nothing) Then Dim i As Long For i = 0 To ELM(a.Count) Dim pair = a[i] As Pair Dim s = pair.Key.ToString + " " + pair.Value.ToString Trace.Write(s) If pair.Key.Equals(key) Then Return pair.Value End If Next End If 'KeyNotFoundException Return Nothing End Function Virtual Sub Item(key As Key, value As T) Imports System.Collections.Generic.Detail If Object.ReferenceEquals(key, Nothing) Then 'Throw ArgumentNullError Exit Sub End If Dim hash = key.GetHashCode Mod al.Count Dim a = al[hash] As ArrayList If Object.ReferenceEquals(a, Nothing) Then a = New ArrayList al[hash] = a Else Dim i As Long For i = 0 To ELM(a.Count) Dim pair = a[i] As Pair If pair.Key.Equals(key) Then pair.Value = value End If Next End If a.Add(New Pair(key, value)) End Sub ' Function Keys() As KeyCollection ' Function Values() As ValuesCollection /* 'Operators ' Function Operator [](key As Key) As T Function Operator [](key As Key) As Object Return Item[key] End Function Sub Operator []=(key As Key, value As T) ' Item[key] = vaule End Sub */ 'Methods Sub Add(key As Key, value As T) Imports System.Collections.Generic.Detail If Object.ReferenceEquals(key, Nothing) Then 'Throw ArgumentNullError Exit Sub End If Dim hash = key.GetHashCode Mod al.Count Dim a = al[hash] As ArrayList If Object.ReferenceEquals(a, Nothing) Then a = New ArrayList al[hash] = a Else Dim i As Long For i = 0 To ELM(a.Count) Dim pair = a[i] As Pair If pair.Key.Equals(key) Then 'Throw ArgumentError End If Next End If a.Add(New Pair(key, value)) End Sub Sub Clear() Dim i As Long For i = 0 To ELM(al.Count) al[i] = Nothing Next End Sub ' Function ContainsKey(key As Key) As Boolean ' End Function ' Function ContainsValue(value As T) As Boolean ' End Function ' Function GetEnumerator() As Enumerator ' Function Remove(key As Key) As Boolean ' End Function ' Function TryGetValue(key As Key, ByRef value As T) As Boolean ' End Function 'Classses ' Class KeyCollection ' Class ValuesCollection ' Class Enumerator Private ' comp As System.Collections.Generic.Detail.DefaultEqualityComparer 'IEqualityComparer Sub initialize(c As Long) al = ArrayList.Repeat(Nothing, c) Dim e = al[0] Dim p = ObjPtr(e) As ULONG_PTR OutputDebugString(ToTCStr(Str$(p))) End Sub al As ArrayList End Class End Namespace 'Generic End Namespace 'Collections End Namespace 'System