Jelajahi Sumber

Added IsEmpty() convenience method to ICollection.

woollybah 6 tahun lalu
induk
melakukan
6e933f3074

+ 1 - 0
collections.mod/collection.bmx

@@ -4,5 +4,6 @@ Interface ICollection<T> Extends IIterable<T>
 
 	Method Count:Int()
 	Method CopyTo(array:T[], index:Int = 0)
+	Method IsEmpty:Int()
 
 End Interface

+ 7 - 0
collections.mod/linkedlist.bmx

@@ -58,6 +58,13 @@ Public
 		Return size
 	End Method
 
+	Rem
+	bbdoc: Returns #True if the #TLinkedList is empty, otherwise #False.
+	End Rem
+	Method IsEmpty:Int() Override
+		Return size = 0
+	End Method
+
 	Method CopyTo(array:T[], index:Int = 0)
 		' TODO
 	End Method

+ 7 - 0
collections.mod/list.bmx

@@ -78,6 +78,13 @@ Public
 	Method Count:Int() Override
 		Return size
 	End Method
+
+	Rem
+	bbdoc: Returns #True if the #TArrayList is empty, otherwise #False.
+	End Rem
+	Method IsEmpty:Int() Override
+		Return size = 0
+	End Method
 	
 	Rem
 	bbdoc: Gets the total number of elements the internal data structure can hold without resizing.

+ 7 - 0
collections.mod/map.bmx

@@ -62,6 +62,13 @@ Type TTreeMap<K, V> Implements IMap<K,V>
 		Return size
 	End Method
 
+	Rem
+	bbdoc: Returns #True if the #TTreeMap is empty, otherwise #False.
+	End Rem
+	Method IsEmpty:Int() Override
+		Return size = 0
+	End Method
+
 	Method CopyTo(array:TMapNode<K,V>[], index:Int = 0)
 	End Method
 	

+ 8 - 1
collections.mod/queue.bmx

@@ -71,7 +71,14 @@ Public
 	Method Count:Int()
 		Return size
 	End Method
-	
+
+	Rem
+	bbdoc: Returns #True if the #TQueue is empty, otherwise #False.
+	End Rem
+	Method IsEmpty:Int() Override
+		Return size = 0
+	End Method
+
 	Method CopyTo(array:T[], index:Int = 0)
 	End Method
 

+ 7 - 0
collections.mod/set.bmx

@@ -86,6 +86,13 @@ Type TSet<T> Implements ISet<T>
 		Return size
 	End Method
 
+	Rem
+	bbdoc: Returns #True if the #TSet is empty, otherwise #False.
+	End Rem
+	Method IsEmpty:Int() Override
+		Return size = 0
+	End Method
+
 	Method CopyTo(array:T[], index:Int = 0)
 	End Method
 	

+ 8 - 1
collections.mod/stack.bmx

@@ -67,7 +67,14 @@ Public
 	Method Count:Int()
 		Return size
 	End Method
-	
+
+	Rem
+	bbdoc: Returns #True if the #TStack is empty, otherwise #False.
+	End Rem
+	Method IsEmpty:Int() Override
+		Return size = 0
+	End Method
+
 	Method CopyTo(array:T[], index:Int = 0)
 	End Method