changeset 80:f1e176a76c00

Rearrange List constructors and add a constant for the default capacity.
author Jordan Miner <jminer7@gmail.com>
date Sat, 17 Jul 2010 16:51:03 -0500
parents e7595d58f8a3
children de94552446ab
files dynamin/core/list.d
diffstat 1 files changed, 14 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/dynamin/core/list.d	Sat Feb 06 15:45:53 2010 -0600
+++ b/dynamin/core/list.d	Sat Jul 17 16:51:03 2010 -0500
@@ -45,26 +45,29 @@
 		void delegate(T, int) whenAdded;
 		void delegate(T, int) whenRemoved;
 	}
+	const int DefaultCapacity = 16;
 public:
-	this() {
-		this(16);
-	}
-	this(uint capacity) {
-		_data = new T[capacity];
-	}
 	static if(hasDelegates) {
 		/// whenAdded or whenRemoved is called right after an item is added
 		/// or removed
 		this(void delegate(T, int) whenAdded,
-				void delegate(T, int) whenRemoved) {
-			this(16, whenAdded, whenRemoved);
+		     void delegate(T, int) whenRemoved) {
+			this(DefaultCapacity, whenAdded, whenRemoved);
 		}
-		this(uint capacity, void delegate(T, int) whenAdded,
-				void delegate(T, int) whenRemoved) {
-			this(capacity);
+		this(uint capacity,
+		     void delegate(T, int) whenAdded,
+		     void delegate(T, int) whenRemoved) {
+			_data = new T[capacity];
 			this.whenAdded = whenAdded;
 			this.whenRemoved = whenRemoved;
 		}
+	} else {
+		this() {
+			this(DefaultCapacity);
+		}
+		this(uint capacity) {
+			_data = new T[capacity];
+		}
 	}
 	static List!(T) fromArray(T[] arr...) {
 		auto list = new List!(T)();