Deprecate SList.length and DList.length
As they have O(n) complexity. The lists length is unknown without iterating.
This commit is contained in:
parent
af45de842e
commit
9b1f72472f
@ -560,28 +560,12 @@ struct SList(T)
|
||||
assert(l1 == l2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns: How many elements are in the list.
|
||||
*/
|
||||
deprecated
|
||||
@property size_t length() const
|
||||
{
|
||||
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.
|
||||
*
|
||||
@ -1815,28 +1799,12 @@ struct DList(T)
|
||||
return insertAfter!(T[])(r, el[]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns: How many elements are in the list.
|
||||
*/
|
||||
deprecated
|
||||
@property size_t length() const
|
||||
{
|
||||
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.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user