Преглед на файлове

Merge pull request #241 from thareh/master

Removed duplicate method
Brucey преди 3 години
родител
ревизия
6778a4d58b
променени са 1 файла, в които са добавени 40 реда и са изтрити 11 реда
  1. 40 11
      collections.mod/linkedlist.bmx

+ 40 - 11
collections.mod/linkedlist.bmx

@@ -33,17 +33,6 @@ Public
 		End If
 	End Method
 
-	Rem
-	bbdoc: Creates a new #TLinkedList initialised by @array.
-	End Rem
-	Method New(array:T[])
-		If array Then
-			For Local element:T = EachIn array
-				AddLast(element)
-			Next
-		End If
-	End Method
-
 	Rem
 	bbdoc: Returns an iterator that iterates through the #TLinkedList.
 	End Rem
@@ -87,6 +76,46 @@ Public
 		End If
 	End Method
 	
+	Rem
+	bbdoc: Gets the first value of the #TLinkedList.
+	End Rem
+	Method FirstValue:T()
+		If head Then
+			Return head.value
+		Else
+			Return Null
+		EndIf
+	EndMethod
+	
+	Rem
+	bbdoc: Gets the last value of the #TLinkedList.
+	End Rem
+	Method LastValue:T()
+		If head Then
+			Return head.PreviousNode.value
+		Else
+			Return Null
+		EndIf
+	EndMethod
+	
+	Rem
+	bbdoc: Removes the first value of the #TLinkedList and returns it.
+	EndRem
+	Method Shift:T()
+		Local val:T = FirstValue()
+		RemoveFirst()
+		Return val
+	EndMethod
+	
+	Rem
+	bbdoc: Removes the last value of the #TLinkedList and returns it.
+	EndRem
+	Method Pop:T()
+		Local val:T = LastValue()
+		RemoveLast()
+		Return val
+	EndMethod
+	
 	Rem
 	bbdoc: Adds a new node containing the specified @value after the specified existing @node in the #TLinkedList.
 	returns: The new node.