Index: trunk/ab5.0/ablib/src/Classes/System/Collections/Generic/List.ab
===================================================================
--- trunk/ab5.0/ablib/src/Classes/System/Collections/Generic/List.ab	(revision 557)
+++ trunk/ab5.0/ablib/src/Classes/System/Collections/Generic/List.ab	(revision 558)
@@ -9,4 +9,5 @@
 	items As *T
 	size As Long
+	count As Long
 
 	currentIndexForEnumerator As Long
@@ -32,5 +33,8 @@
 	Sub List( capacity As Long )
 		This.List()
-		This.Realloc( capacity )
+		If capacity > 0 Then
+			This.size = capacity
+			Realloc(capacity)
+		End If
 	End Sub
 
@@ -41,9 +45,10 @@
 	@param	インデックス
 	*/
-	Sub List( array As *T, count As Long )
-		This.List( count )
-		memmove( This.items, array, count * SizeOf(T) )
-		This.size = count
-	End Sub
+	Sub List( array As *T, length As Long )
+		This.List( length )
+		memmove( This.items, array, length * SizeOf(T) )
+		This.count = length
+	End Sub
+
 	Sub ~List()
 	End Sub
@@ -83,5 +88,5 @@
 	*/
 	Override Function Count() As Long
-		Return size
+		Return This.count
 	End Function
 
@@ -106,8 +111,10 @@
 	*/
 	Override Sub Add( item As T )
-		Realloc( size + 1 )
-
-		items[size] = item
-		size++
+		If This.size < (This.count + 1) Then
+			This.size++
+			Realloc( This.size )
+		End If
+		This.items[ This.count ] = item
+		This.count++
 	End Sub
 
@@ -120,5 +127,5 @@
 	*/
 	Override Sub Clear()
-		size = 0
+		This.count = 0
 	End Sub
 
@@ -135,5 +142,5 @@
 	Override Function IndexOf( item As T ) As Long
 		Dim i As Long
-		For i = 0 To ELM(size)
+		For i = 0 To ELM( This.count )
 			If items[i].Equals(item) Then
 				Return i
@@ -149,8 +156,11 @@
 	*/
 	Override Sub Insert( index As Long, item As T )
-		Realloc( size + 1 )
-		memmove( items + (index+1)*SizeOf(T), items + index*SizeOf(T), (size-index)*SizeOf(T) )
+		If This.size < (This.count + 1) Then
+			This.size++
+			Realloc( This.size )
+		End If
+		memmove( items + (index+1)*SizeOf(T), items + index*SizeOf(T), (This.count - index)*SizeOf(T) )
 		items[index] = item
-		size++
+		This.count++
 	End Sub
 
@@ -175,10 +185,8 @@
 	@author	Daisuke Yamamoto
 	@date	2007/10/03
-	@return	値が削除されたときはTrue、されなかったときはFlaseが返る
 	*/
 	Override Sub RemoveAt( index As Long )
-		memmove( items + index*SizeOf(T), items + (index+1)*SizeOf(T), (size-(index+1))*SizeOf(T) )
-		Realloc( size - 1 )
-		size--
+		memmove( items + index*SizeOf(T), items + (index+1)*SizeOf(T), (This.count - (index+1))*SizeOf(T) )
+		This.count--
 	End Sub
 
@@ -192,9 +200,22 @@
 		Dim string As String
 		Dim i As Long
-		For i = 0 To This.Count-2
+		For i = 0 To ELM( This.count )
 			string += This[i].ToString() + Ex"\r\n"
 		Next
 		Return string + This[i].ToString()
 	End Function
+
+	/*!
+	@brief	実際の要素数が現在の容量の 90% 未満の場合は、容量をその数に設定します
+	@author	NoWest
+	@date	2008/07/20
+	*/
+	Sub TrimExcess ()
+		Dim pmemobj = _System_pGC->GetMemoryObjectPtr( items )
+		If ( This.size ) * 0.9 > This.count Then
+			This.size = This.count
+			Realloc( This.size )
+		End If
+	End Sub
 
 	/*!
Index: trunk/ab5.0/ablib/src/Classes/System/Collections/Generic/Queue.ab
===================================================================
--- trunk/ab5.0/ablib/src/Classes/System/Collections/Generic/Queue.ab	(revision 558)
+++ trunk/ab5.0/ablib/src/Classes/System/Collections/Generic/Queue.ab	(revision 558)
@@ -0,0 +1,149 @@
+
+Namespace System
+Namespace Collections
+Namespace Generic
+
+Class Queue<T>
+	Inherits ICollection
+
+	items As *T
+	size As Long
+	count As Long
+
+	Sub Realloc ( allocateSize As Long )
+		This.items = realloc( This.items, allocateSize * SizeOf(T) )
+	End Sub
+
+Public
+	Sub Queue ()
+		This.items = GC_malloc( 1 )
+		Reset()
+	End Sub
+
+	Sub Queue ( capacity As Long )
+		This.Queue()
+		If capacity > 0 Then
+			This.size = capacity
+			Realloc(capacity)
+		End If
+	End Sub
+
+	/*!
+	@brief	Queueに格納されている要素の数を取得
+	@author	NoWest
+	@date	2008/07/20
+	*/
+	Override Function Count () As Long
+		Return This.count
+	End Function
+
+Public
+	/*!
+	@brief	Queueからすべての要素を削除する
+	@author	NoWest
+	@date	2008/07/20
+	*/
+	Override Sub Clear ()
+		This.count = 0
+	End Sub
+
+	'ある要素が Queue内に存在するかどうかを判断
+/*	Override Function Contains ( item As T ) As Boolean
+		TODO
+	End Function*/
+
+	'既存の 1 次元の Array に Stack をコピーします。コピー操作は、配列の指定したインデックスから始まります。 
+/*	CopyTo*/
+
+	/*!
+	@brief	IEnumeratorインターフェイスを取得する
+	@author	NoWest
+	@date	2008/07/20
+	@return	IEnumeratorインターフェイス
+	*/
+	Override Function GetEnumerator () As IEnumerator<T>
+		Return This
+	End Function
+
+ 	/*!
+	@brief	Queueの先頭にあるオブジェクトを削除し、返します
+	@author	NoWest
+	@date	2008/07/20
+	*/
+	Function Dequeue () As T
+		Dequeue = This.items[ 0 ]
+		memmove( items, items + SizeOf(T), (This.count - 1)*SizeOf(T) )
+		This.count--
+	End Function
+
+	/*!
+	@brief	Queueの末尾にオブジェクトを追加します
+	@author	NoWest
+	@date	2008/07/20
+	*/
+	Sub Enqueue ( item As T )
+		If This.size < (This.count + 1) Then
+			This.size++
+			Realloc( This.size )
+		End If
+		This.items[ This.count ] = item
+		This.count++
+	End Sub
+
+	/*!
+	@brief	Queueの先頭にあるオブジェクトを削除せずに返します
+	@author	NoWest
+	@date	2008/07/20
+	*/
+	Function Peek () As T
+		Peek = This.items[ 0 ]
+	End Function
+
+	'Queueを新しい配列にコピーします。 
+/*	ToArray*/
+
+	/*!
+	@brief	実際の要素数が現在の容量の 90% 未満の場合は、容量をその数に設定します
+	@author	NoWest
+	@date	2008/07/20
+	*/
+	Sub TrimExcess ()
+		Dim pmemobj = _System_pGC->GetMemoryObjectPtr( items )
+		If ( This.size ) * 0.9 > This.count Then
+			This.size = This.count
+			Realloc( This.size )
+		End If
+	End Sub
+
+
+	'------------------------
+	'	IEnumeratorの実装
+	'------------------------
+	currentIndexForEnumerator As Long
+
+	Override Function Current () As T
+		If This.currentIndexForEnumerator = -1 Then
+			' MoveNextメソッドがReset後、一度も呼び出されなかった
+			Return Nothing
+		End If
+		Return This.items[ This.currentIndexForEnumerator ]
+	End Function
+
+	Override Function MoveNext() As Boolean
+		If This.currentIndexForEnumerator + 1 >= This.size Then
+			' 上限に達した
+			Return False
+		End If
+
+		This.currentIndexForEnumerator ++
+		Return True
+	End Function
+
+	Override Sub Reset ()
+		This.currentIndexForEnumerator = -1
+	End Sub
+End Class
+
+End Namespace
+End Namespace
+End Namespace
Index: trunk/ab5.0/ablib/src/Classes/System/Collections/Generic/Stack.ab
===================================================================
--- trunk/ab5.0/ablib/src/Classes/System/Collections/Generic/Stack.ab	(revision 557)
+++ trunk/ab5.0/ablib/src/Classes/System/Collections/Generic/Stack.ab	(revision 558)
@@ -72,5 +72,5 @@
 	*/
 	Function Peek () As T
-		Peek = This.items[ This.count -1 ]
+		Peek = This.items[ 0 ]
 	End Function
 
@@ -81,5 +81,6 @@
 	*/
 	Function Pop () As T
-		Pop = This.items[ This.count -1 ]
+		Pop = This.items[ 0 ]
+		memmove( items, items + SizeOf(T), (This.count - 1)*SizeOf(T) )
 		This.count--
 	End Function
@@ -91,10 +92,11 @@
 	*/
 	Sub Push ( item As T )
-		This.count++
-		If This.size < This.count Then
+		If This.size < (This.count + 1) Then
 			This.size++
 			Realloc( This.size )
 		End If
-		This.items[ This.count -1 ] = item
+		memmove( items + SizeOf(T), items, This.count * SizeOf(T) )
+		items[ 0 ] = item
+		This.count++
 	End Sub
 
