Property Name() As String
Get
Return m_name
End Get
End Property
End Class
'' "Aggregate"
Public Interface IAbstractCollection
Function CreateIterator() As Iterator
End Interface
'' "ConcreteAggregate"
Public Class Collection
Implements IAbstractCollection
Private items As New ArrayList()
Public Function CreateIterator() As Iterator Implements IAbstractCollection.CreateIterator
Return New Iterator(Me)
End Function
'' Property
Public ReadOnly Property Count() As Integer
Get
Return items.Count
End Get
End Property
'' Indexer
Default Public Property Item(ByVal index As Integer) As Object
Get
Return items(index)
End Get
Set(ByVal value As Object)
items.Add(value)
End Set
End Property
End Class
'' "Iterator"
Public Interface IAbstractIterator
Function First() As Item
Function [Next]() As Item
ReadOnly Property IsDone() As Boolean
ReadOnly Property CurrentItem() As Item
End Interface
'' "ConcreteIterator"
Public Class Iterator
Implements IAbstractIterator
Private collection As Collection
Private current As Integer = 0
Private m_step As Integer = 1
'' Constructor
Public Sub New(ByVal collection As Collection)
Me.collection = collection
End Sub
Public Function First() As