Explorar o código

Added Stack.Compact.

Mark Sibly %!s(int64=8) %!d(string=hai) anos
pai
achega
b75ce3884d
Modificáronse 1 ficheiros con 6 adicións e 0 borrados
  1. 6 0
      modules/std/collections/stack.monkey2

+ 6 - 0
modules/std/collections/stack.monkey2

@@ -290,6 +290,12 @@ Class Stack<T> Implements IContainer<T>
 		Return _data.Length
 	End
 	
+	#rem monkeydoc Compacts the stack
+	#end
+	Method Compact()
+		If _length<>_data.Length _data=_data.Slice( 0,_length )
+	End
+	
 	#rem monkeydoc Resizes the stack.
 	
 	If `length` is greater than the current stack length, any extra elements are initialized to null.