瀏覽代碼

added clear()

Nicolas Cannasse 19 年之前
父節點
當前提交
e70b6cc4b7
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      std/List.hx

+ 8 - 0
std/List.hx

@@ -117,6 +117,14 @@ class List<T> {
 		return (h == null);
 	}
 
+	/**
+		Makes the list empty.
+	**/
+	public function clear() : Void {
+		h = null;
+		length = 0;
+	}
+
 	/**
 		Remove the first element that is [== v] from the list.
 		Returns [true] if an element was removed, [false] otherwise.