diff options
| author | Eugen Wissner <belka@caraus.de> | 2018-03-31 08:21:15 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2018-03-31 08:21:15 +0200 |
| commit | 9b1f72472f528846c5e09c5fb4d87e415457dce4 (patch) | |
| tree | 629827b2d890c469e9369e38125433a20de86929 | |
| parent | af45de842e3d69a4d07788b5153902d21601d91c (diff) | |
| download | tanya-9b1f72472f528846c5e09c5fb4d87e415457dce4.tar.gz | |
Deprecate SList.length and DList.length
As they have O(n) complexity. The lists length is unknown without
iterating.
| -rw-r--r-- | source/tanya/container/list.d | 36 |
1 files changed, 2 insertions, 34 deletions
diff --git a/source/tanya/container/list.d b/source/tanya/container/list.d index 4c99906..fe62b5f 100644 --- a/source/tanya/container/list.d +++ b/source/tanya/container/list.d @@ -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. * |
