Browse Source

Added Stack.Compact.

Mark Sibly 8 years ago
parent
commit
b75ce3884d
1 changed files with 6 additions and 0 deletions
  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.