# HG changeset patch # User Jordan Miner # Date 1279403463 18000 # Node ID f1e176a76c009e658fbe6bd925f10d1fe6486f6a # Parent e7595d58f8a3db2cd75cbfbe87f2229faf5d9f30 Rearrange List constructors and add a constant for the default capacity. diff -r e7595d58f8a3 -r f1e176a76c00 dynamin/core/list.d --- 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)();