Namespace System Namespace Collections Namespace Generic Class LinkedListNode Protected pList As LinkedList pNext As LinkedListNode pPrevious As LinkedListNode tValue As T Public '指定した値を含んだ LinkedListNode クラスの新しいインスタンスを初期化します。 Sub LinkedListNode ( value As T ) This.tValue = value End Sub Public 'LinkedListNode が属する LinkedList を取得します。 Function List () As LinkedList Return This.pList End Function 'LinkedList 内の次のノードを取得します。 Function NextNode () As LinkedListNode Return This.pNext End Function 'LinkedList 内の前のノードを取得します。 Function PreviousNode () As LinkedListNode Return This.pPrevious End Function 'ノードに格納された値を取得、設定します。 Sub Value ( value As T ) This.tValue = value End Sub Function Value () As T Return This.tValue End Function Public '現在の Object を表す String を返します。 (Object から継承されます。) Override Function ToString () As String Return This.Value().ToString() End Function End Class Namespace Detail Class _System_LinkedListNode Inherits LinkedListNode Public Sub l ( list As LinkedList ) This.pList = list End Sub Sub NextNode ( ByRef nxt As LinkedListNode ) This.pNext = nxt End Sub Sub PreviousNode ( ByRef prv As LinkedListNode ) This.pPrevious = prv End Sub End Class End Namespace Class LinkedList Inherits ICollection first As LinkedListNode last As LinkedListNode count As Long Public Sub LinkedList () This.count = 0 End Sub /*! @brief LinkedListに実際に格納されているノードの数を取得 @author NoWest @date 2008/08/08 */ Override Function Count () As Long Return This.count End Function /*! @brief LinkedListの最初のノードを取得 @author NoWest @date 2008/08/08 */ Function First () As LinkedListNode Return This.first End Function /*! @brief LinkedListの最後のノードを取得 @author NoWest @date 2008/08/08 */ Function Last () As LinkedListNode Return This.last End Function /*! @brief LinkedListが読み込み専用かどうかを取得する @author NoWest @date 2008/08/08 */ Override Function IsReadOnly() As Boolean Return False End Function Public /*! @brief LinkedListの末端にノードを追加する @author NoWest @date 2008/08/08 @param 追加するオブジェクト */ Override Sub Add( value As T ) This.AddLast(value) End Sub /*! @brief LinkedList内の既存のノードの後に新しいノードまたは値を追加 @author NoWest @date 2008/08/08 */ Sub AddAfter ( node As LinkedListNode, newNode As LinkedListNode ) End Sub Sub AddAfter ( node As LinkedListNode, value As T ) End Sub /*! @brief LinkedList内の既存のノードの前に新しいノードまたは値を追加 @author NoWest @date 2008/08/08 */ Sub AddBefore ( node As LinkedListNode, newNode As LinkedListNode ) End Sub Sub AddBefore ( node As LinkedListNode, value As T ) End Sub /*! @brief LinkedListの先頭に新しいノードまたは値を追加 @author NoWest @date 2008/08/08 */ Sub AddFirst ( newNode As LinkedListNode ) End Sub Sub AddFirst ( value As T ) Dim newnode = New Detail._System_LinkedListNode() newnode.List(This) newnode.NextNode(This.first) newnode.PreviousNode(Nothing) Dim node = This.first As Detail._System_LinkedListNode If ActiveBasic.IsNothing(node) Then This.first = newnode This.last = newnode Else node.PreviousNode(newnode) This.first = newnode End If This.count++ End Sub /*! @brief LinkedListの末尾に新しいノードまたは値を追加 @author NoWest @date 2008/08/08 */ 'Sub AddLast ( newNode As LinkedListNode ) ' This.AddLast(newNode.Value() As T) 'End Sub Sub AddLast ( value As T ) Dim newnode = New Detail._System_LinkedListNode() newnode.List(This) newnode.NextNode(Nothing) newnode.PreviousNode(This.last) Dim node = This.last As Detail._System_LinkedListNode If ActiveBasic.IsNothing(node) Then This.first = newnode This.last = newnode Else node.NextNode(newnode) This.last = newnode End If This.count++ End Sub /*! @brief LinkedListからすべてのノードを削除 @author NoWest @date 2008/08/08 */ Override Sub Clear () This.count = 0 End Sub 'ある要素がLinkedList内に存在するかどうかを判断 /* Override Function Contains ( item As T ) As Boolean TODO End Function*/ '既存の1次元のArrayにLinkedListをコピーします。 /* CopyTo*/ /*! @brief 指定した値を含む最初のノードを検索 @author NoWest @date 2008/08/08 */ Function Find( value As T ) As LinkedListNode If ActiveBasic.IsNothing(This.first) Then Return Nothing End Function /*! @brief 指定した値を含む最後のノードを検索 @author NoWest @date 2008/08/08 */ Function FindLast( value As T ) As LinkedListNode End Function /*! @brief IEnumeratorインターフェイスを取得する @author NoWest @date 2008/08/08 @return IEnumeratorインターフェイス */ Override Function GetEnumerator () As IEnumerator Return Nothing End Function /*! @brief LinkedList内で最初に出現する値/ノードを削除する @author NoWest @date 2008/08/08 @return 値が削除されたときはTrue、されなかったときはFlaseが返る */ Function Remove ( node As LinkedListNode ) As Boolean End Function Override Function Remove( value As T ) As Boolean This.Remove(This.Find(value)) End Function /*! @brief LinkedListの先頭にあるノードを削除 @author NoWest @date 2008/08/08 */ Sub RemoveFirst () End Sub /*! @brief LinkedListの末尾にあるノードを削除 @author NoWest @date 2008/08/08 */ Sub RemoveLast () End Sub 'LinkedListを新しい配列にコピーします。 /* ToArray*/ End Class End Namespace End Namespace End Namespace