From fe884541fc8bef9d6e0efb45ce4a92e73c5666bb Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 13 Jan 2017 15:23:42 +0100 Subject: [PATCH] Rename Vector.data to Vector.get --- .travis.yml | 1 + README.md | 6 +- source/tanya/async/event/epoll.d | 2 +- source/tanya/async/event/kqueue.d | 6 +- source/tanya/container/queue.d | 123 +++--------------------------- source/tanya/container/vector.d | 17 +++-- 6 files changed, 26 insertions(+), 129 deletions(-) diff --git a/.travis.yml b/.travis.yml index 24018bb..b2f6428 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ sudo: false os: - linux + - osx language: d diff --git a/README.md b/README.md index 77703f7..46772c9 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,11 @@ helper functions). The library is currently under development, but some parts of it can already be used. -`network` and `async` exist for quite some time and could be better tested than +`network` and `async` exist for quite some time and are better tested than other components. -Containers were newly reworked and the API won't change significantly, but will -be only extended. The same is true for the `memory` package. +`container`s were newly reworked and the API won't change significantly, but +will be only extended. The same is true for the `memory` package. `math` package contains an arbitrary precision integer implementation that has a stable API (that mostly consists of operator overloads), but still needs diff --git a/source/tanya/async/event/epoll.d b/source/tanya/async/event/epoll.d index 408a601..48eac8d 100644 --- a/source/tanya/async/event/epoll.d +++ b/source/tanya/async/event/epoll.d @@ -110,7 +110,7 @@ class EpollLoop : SelectorLoop { // Don't block immutable timeout = cast(immutable int) blockTime.total!"msecs"; - auto eventCount = epoll_wait(fd, events.data.ptr, maxEvents, timeout); + auto eventCount = epoll_wait(fd, events.get().ptr, maxEvents, timeout); if (eventCount < 0) { diff --git a/source/tanya/async/event/kqueue.d b/source/tanya/async/event/kqueue.d index eb585a8..79eac1d 100644 --- a/source/tanya/async/event/kqueue.d +++ b/source/tanya/async/event/kqueue.d @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /** - * Copyright: Eugene Wissner 2016. + * Copyright: Eugene Wissner 2016-2017. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) @@ -217,9 +217,9 @@ class KqueueLoop : SelectorLoop } auto eventCount = kevent(fd, - changes.data.ptr, + changes.get().ptr, cast(int) changeCount, - events.data.ptr, + events.get().ptr, maxEvents, &ts); changeCount = 0; diff --git a/source/tanya/container/queue.d b/source/tanya/container/queue.d index 31733e8..8c21fbc 100644 --- a/source/tanya/container/queue.d +++ b/source/tanya/container/queue.d @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /** - * Copyright: Eugene Wissner 2016. + * Copyright: Eugene Wissner 2016-2017. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) @@ -34,18 +34,6 @@ struct Queue(T) } } - /** - * Removes all elements from the queue. - */ - deprecated - void clear() - { - while (!empty) - { - dequeue(); - } - } - /** * Returns how many elements are in the queue. It iterates through the queue * to count the elements. @@ -55,7 +43,7 @@ struct Queue(T) size_t length() const { size_t len; - for (const(Entry!T)* i = first.next; i !is null; i = i.next) + for (const(Entry!T)* i = first; i !is null; i = i.next) { ++len; } @@ -83,86 +71,6 @@ struct Queue(T) assert(q.length == 0); } - version (D_Ddoc) - { - /** - * Compares two queues. Checks if all elements of the both queues are equal. - * - * Returns: Whether $(D_KEYWORD this) and $(D_PARAM that) are equal. - */ - deprecated - int opEquals(ref typeof(this) that); - - /// Ditto. - deprecated - int opEquals(typeof(this) that); - } - else static if (!hasMember!(T, "opEquals") - || (functionAttributes!(T.opEquals) & FunctionAttribute.const_)) - { - deprecated - bool opEquals(in ref typeof(this) that) const - { - const(Entry!T)* i = first.next; - const(Entry!T)* j = that.first.next; - while (i !is null && j !is null) - { - if (i.content != j.content) - { - return false; - } - i = i.next; - j = j.next; - } - return i is null && j is null; - } - - deprecated - bool opEquals(in typeof(this) that) const - { - return opEquals(that); - } - } - else - { - deprecated - bool opEquals(ref typeof(this) that) - { - Entry!T* i = first.next; - Entry!T* j = that.first.next; - while (i !is null && j !is null) - { - if (i.content != j.content) - { - return false; - } - i = i.next; - j = j.next; - } - return i is null && j is null; - } - - deprecated - bool opEquals(typeof(this) that) - { - return opEquals(that); - } - } - - /** - * Returns: First element. - */ - deprecated("Use dequeue instead.") - @property ref inout(T) front() inout - in - { - assert(!empty); - } - body - { - return first.next.content; - } - /** * Inserts a new element. * @@ -176,7 +84,7 @@ struct Queue(T) auto temp = allocator.make!(Entry!T)(x); if (empty) { - first.next = rear = temp; + first = rear = temp; } else { @@ -192,12 +100,6 @@ struct Queue(T) return enqueue(x); } - deprecated("Use enqueue instead.") - alias insert = enqueue; - - deprecated("Use enqueue instead.") - alias insertBack = enqueue; - /// unittest { @@ -214,7 +116,7 @@ struct Queue(T) */ @property bool empty() const { - return first.next is null; + return first is null; } /// @@ -237,21 +139,17 @@ struct Queue(T) in { assert(!empty); - assert(allocator !is null); } body { - auto n = first.next.next; - T ret = move(first.next.content); + auto n = first.next; + T ret = move(first.content); - dispose(allocator, first.next); - first.next = n; + allocator.dispose(first); + first = n; return ret; } - deprecated("Use dequeue instead.") - alias popFront = dequeue; - /// unittest { @@ -330,10 +228,7 @@ struct Queue(T) assert(q.empty); } - /// The first element of the list. - private Entry!T first; - - /// The last element of the list. + private Entry!T* first; private Entry!T* rear; mixin DefaultAllocator; diff --git a/source/tanya/container/vector.d b/source/tanya/container/vector.d index e71d203..2467325 100644 --- a/source/tanya/container/vector.d +++ b/source/tanya/container/vector.d @@ -180,14 +180,14 @@ private struct Range(E) return true; } - @property inout(E[]) data() inout + inout(E[]) get() inout { return begin[0 .. length]; } static if (isMutable!E) { - bool opEquals(Range that) + bool opEquals(Range that) @trusted { if (length != that.length) { @@ -1408,7 +1408,7 @@ struct Vector(T) * * Returns: The array with elements of this vector. */ - @property inout(T[]) data() inout + inout(T[]) get() inout { return vector[0 .. length]; } @@ -1417,13 +1417,14 @@ struct Vector(T) unittest { auto v = Vector!int(IL(1, 2, 4)); + auto data = v.get(); - assert(v.data[0] == 1); - assert(v.data[1] == 2); - assert(v.data[2] == 4); - assert(v.data.length == 3); + assert(data[0] == 1); + assert(data[1] == 2); + assert(data[2] == 4); + assert(data.length == 3); - auto data = v[1 .. 2].data; + data = v[1 .. 2].get(); assert(data[0] == 2); assert(data.length == 1); }