Browse Source

added clear()

Nicolas Cannasse 19 năm trước cách đây
mục cha
commit
e70b6cc4b7
1 tập tin đã thay đổi với 8 bổ sung0 xóa
  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.