Rename Vector.data to Vector.get

This commit is contained in:
2017-01-13 15:23:42 +01:00
parent 8973bdb2af
commit fe884541fc
6 changed files with 26 additions and 129 deletions

View File

@ -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)
{

View File

@ -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;

View File

@ -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;

View File

@ -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);
}