Private xn, Dict
Public Property Let init(n)
Set Dict = CreateObject("Scripting.Dictionary")
xn = n
End Property
Public Property Let ajout(cle, item)
If Not Dict.Exists(cle) Then
Dict(cle) = item
xn = xn + 1
End If
End Property
Public Property Get Count()
Count = xn
End Property
Public Property Get listeItems()
listeItems = Application.Transpose(Dict.Items)
End Property
Public Property Get listeCles()
listeCles = Application.Transpose(Dict.keys)
End Property
Public Property Get item(cle)
item = Dict(cle)
End Property
Public Property Get Existe(cle)
Existe = Dict.Exists(cle)
End Property
Public Property Let Sup(cle)
Dict.Remove (cle)
End Property
Public Property Get TriDict()
Dim temp()
ReDim temp(1 To Dict.Count, 1 To 2)
i = 1
For Each c In Dict.keys
temp(i, 1) = c
temp(i, 2) = Dict(c)
i = i + 1
Next c
Call Tri(temp, LBound(temp), UBound(temp))
TriDict = temp
End Property
Sub Tri(a, gauc, droi) ' Quick sort
ref = a((gauc + droi) \ 2, 1)
g = gauc: d = droi
Do
Do While a(g, 1) < ref: g = g + 1: Loop
Do While ref < a(d, 1): d = d - 1: Loop
If g <= d Then
temp = a(g, 1): a(g, 1) = a(d, 1): a(d, 1) = temp
temp = a(g, 2): a(g, 2) = a(d, 2): a(d, 2) = temp
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call Tri(a, g, droi)
If gauc < d Then Call Tri(a, gauc, d)
End Sub