Rename Vector.data to Vector.get

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

View File

@ -2,6 +2,7 @@ sudo: false
os: os:
- linux - linux
- osx
language: d language: d

View File

@ -35,11 +35,11 @@ helper functions).
The library is currently under development, but some parts of it can already be The library is currently under development, but some parts of it can already be
used. 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. other components.
Containers were newly reworked and the API won't change significantly, but will `container`s were newly reworked and the API won't change significantly, but
be only extended. The same is true for the `memory` package. will be only extended. The same is true for the `memory` package.
`math` package contains an arbitrary precision integer implementation that has `math` package contains an arbitrary precision integer implementation that has
a stable API (that mostly consists of operator overloads), but still needs a stable API (that mostly consists of operator overloads), but still needs

View File

@ -110,7 +110,7 @@ class EpollLoop : SelectorLoop
{ {
// Don't block // Don't block
immutable timeout = cast(immutable int) blockTime.total!"msecs"; 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) if (eventCount < 0)
{ {

View File

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * 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/, * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0). * Mozilla Public License, v. 2.0).
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
@ -217,9 +217,9 @@ class KqueueLoop : SelectorLoop
} }
auto eventCount = kevent(fd, auto eventCount = kevent(fd,
changes.data.ptr, changes.get().ptr,
cast(int) changeCount, cast(int) changeCount,
events.data.ptr, events.get().ptr,
maxEvents, maxEvents,
&ts); &ts);
changeCount = 0; changeCount = 0;

View File

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * 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/, * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0). * Mozilla Public License, v. 2.0).
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) * 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 * Returns how many elements are in the queue. It iterates through the queue
* to count the elements. * to count the elements.
@ -55,7 +43,7 @@ struct Queue(T)
size_t length() const size_t length() const
{ {
size_t len; 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; ++len;
} }
@ -83,86 +71,6 @@ struct Queue(T)
assert(q.length == 0); 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. * Inserts a new element.
* *
@ -176,7 +84,7 @@ struct Queue(T)
auto temp = allocator.make!(Entry!T)(x); auto temp = allocator.make!(Entry!T)(x);
if (empty) if (empty)
{ {
first.next = rear = temp; first = rear = temp;
} }
else else
{ {
@ -192,12 +100,6 @@ struct Queue(T)
return enqueue(x); return enqueue(x);
} }
deprecated("Use enqueue instead.")
alias insert = enqueue;
deprecated("Use enqueue instead.")
alias insertBack = enqueue;
/// ///
unittest unittest
{ {
@ -214,7 +116,7 @@ struct Queue(T)
*/ */
@property bool empty() const @property bool empty() const
{ {
return first.next is null; return first is null;
} }
/// ///
@ -237,21 +139,17 @@ struct Queue(T)
in in
{ {
assert(!empty); assert(!empty);
assert(allocator !is null);
} }
body body
{ {
auto n = first.next.next; auto n = first.next;
T ret = move(first.next.content); T ret = move(first.content);
dispose(allocator, first.next); allocator.dispose(first);
first.next = n; first = n;
return ret; return ret;
} }
deprecated("Use dequeue instead.")
alias popFront = dequeue;
/// ///
unittest unittest
{ {
@ -330,10 +228,7 @@ struct Queue(T)
assert(q.empty); assert(q.empty);
} }
/// The first element of the list. private Entry!T* first;
private Entry!T first;
/// The last element of the list.
private Entry!T* rear; private Entry!T* rear;
mixin DefaultAllocator; mixin DefaultAllocator;

View File

@ -180,14 +180,14 @@ private struct Range(E)
return true; return true;
} }
@property inout(E[]) data() inout inout(E[]) get() inout
{ {
return begin[0 .. length]; return begin[0 .. length];
} }
static if (isMutable!E) static if (isMutable!E)
{ {
bool opEquals(Range that) bool opEquals(Range that) @trusted
{ {
if (length != that.length) if (length != that.length)
{ {
@ -1408,7 +1408,7 @@ struct Vector(T)
* *
* Returns: The array with elements of this vector. * Returns: The array with elements of this vector.
*/ */
@property inout(T[]) data() inout inout(T[]) get() inout
{ {
return vector[0 .. length]; return vector[0 .. length];
} }
@ -1417,13 +1417,14 @@ struct Vector(T)
unittest unittest
{ {
auto v = Vector!int(IL(1, 2, 4)); auto v = Vector!int(IL(1, 2, 4));
auto data = v.get();
assert(v.data[0] == 1); assert(data[0] == 1);
assert(v.data[1] == 2); assert(data[1] == 2);
assert(v.data[2] == 4); assert(data[2] == 4);
assert(v.data.length == 3); assert(data.length == 3);
auto data = v[1 .. 2].data; data = v[1 .. 2].get();
assert(data[0] == 2); assert(data[0] == 2);
assert(data.length == 1); assert(data.length == 1);
} }