Mercurial > projects > dynamin
changeset 87:7cf356729515
Set removed items in a List to T.init. T could be a struct containing a pointer
or even be a pointer itself.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Mon, 26 Jul 2010 00:29:13 -0500 |
parents | 366e1323bcb9 |
children | f149c868a34f |
files | dynamin/core/list.d |
diffstat | 1 files changed, 3 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/dynamin/core/list.d Mon Jul 19 21:42:06 2010 -0500 +++ b/dynamin/core/list.d Mon Jul 26 00:29:13 2010 -0500 @@ -159,8 +159,7 @@ throw new Exception("List.pop() - List is empty"); T item = _data[_count-1]; // must null out to allow to be collected - static if(is(T == class) || is(T == interface)) - _data[_count-1] = cast(T)null; + _data[_count-1] = T.init; --_count; static if(changeNotification) whenChanged(ListChangeType.Removed, item, T.init, _count); @@ -181,8 +180,7 @@ for(uint i = index + 1; i < _count; ++i) _data[i-1] = _data[i]; // must null out to allow to be collected - static if(is(T == class) || is(T == interface)) - _data[_count-1] = cast(T)null; + _data[_count-1] = T.init; --_count; static if(changeNotification) @@ -201,8 +199,7 @@ static if(changeNotification) whenChanged(ListChangeType.Removed, _data[_count-1], T.init, _count-1); // must null out to allow to be collected - static if(is(T == class) || is(T == interface)) - data[_count-1] = cast(T)null; + data[_count-1] = T.init; } } uint find(T item) {