Deprecate SList.length and DList.length

As they have O(n) complexity. The lists length is unknown without
iterating.
This commit is contained in:
Eugen Wissner 2018-03-31 08:21:15 +02:00
parent af45de842e
commit 9b1f72472f
1 changed files with 2 additions and 34 deletions

View File

@ -560,28 +560,12 @@ struct SList(T)
assert(l1 == l2); assert(l1 == l2);
} }
/** deprecated
* Returns: How many elements are in the list.
*/
@property size_t length() const @property size_t length() const
{ {
return count(this[]); return count(this[]);
} }
///
@nogc nothrow pure @safe unittest
{
SList!int l;
l.insertFront(8);
l.insertFront(9);
assert(l.length == 2);
l.removeFront();
assert(l.length == 1);
l.removeFront();
assert(l.length == 0);
}
/** /**
* Comparison for equality. * Comparison for equality.
* *
@ -1815,28 +1799,12 @@ struct DList(T)
return insertAfter!(T[])(r, el[]); return insertAfter!(T[])(r, el[]);
} }
/** deprecated
* Returns: How many elements are in the list.
*/
@property size_t length() const @property size_t length() const
{ {
return count(this[]); return count(this[]);
} }
///
@nogc nothrow pure @safe unittest
{
DList!int l;
l.insertFront(8);
l.insertFront(9);
assert(l.length == 2);
l.removeFront();
assert(l.length == 1);
l.removeFront();
assert(l.length == 0);
}
/** /**
* Comparison for equality. * Comparison for equality.
* *