Public Class StringSet
Private m_elements List As Integer
Private m_count As Long
Public Sub New
m_count = 0
End Sub
Public Function Add(element As String) As Variant
If Contains(element) Then
Add = False
Else
m_elements(element) = 0
m_count = m_count + 1
Add = True
End If
End Function
Public Function Contains(element As String) As Variant
If Iselement(m_elements(element)) Then
Contains = True
Else
Contains = False
End If
End Function
Public Function Remove(element As String) As Variant
If Contains(element) Then
m_count = m_count - 1
Erase m_elements(element)
Me.Remove = True
Else
Me.Remove = False
End If
End Function
Public Property Get Size As Long
Size = m_count
End Property
Public Function IsEmpty As Variant
Me.IsEmpty = (m_count = 0)
End Function
Public Function Elements As Variant
If m_count = 0 Then
Elements = Null
Exit Function
End If
Dim elems() As String
Redim elems(m_count - 1) As String
Dim i As Long
i = 0
Forall e In m_elements
elems(i) = Listtag(e)
i = i + 1
End Forall
Elements = elems
End Function
End Class