浏览代码

Added Stack.Compact.

Mark Sibly 8 年之前
父节点
当前提交
b75ce3884d
共有 1 个文件被更改,包括 6 次插入0 次删除
  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
 		Return _data.Length
 	End
 	End
 	
 	
+	#rem monkeydoc Compacts the stack
+	#end
+	Method Compact()
+		If _length<>_data.Length _data=_data.Slice( 0,_length )
+	End
+	
 	#rem monkeydoc Resizes the stack.
 	#rem monkeydoc Resizes the stack.
 	
 	
 	If `length` is greater than the current stack length, any extra elements are initialized to null.
 	If `length` is greater than the current stack length, any extra elements are initialized to null.