summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2019-04-14 07:41:26 +0200
committerEugen Wissner <belka@caraus.de>2019-04-14 09:07:22 +0200
commit9814e5ad8ef246273cad80f86c95c3bce047509a (patch)
tree709bf7fe69ba29e343a7d52bbfd3a264cfd16437 /source
parente6c6a2d21a6869bcfdf872479db566864a22f5fc (diff)
downloadtanya-9814e5ad8ef246273cad80f86c95c3bce047509a.tar.gz
Pass allocator in all HashTable/Set constructors
Diffstat (limited to 'source')
-rw-r--r--source/tanya/container/hashtable.d9
-rw-r--r--source/tanya/container/list.d36
-rw-r--r--source/tanya/container/set.d14
3 files changed, 32 insertions, 27 deletions
diff --git a/source/tanya/container/hashtable.d b/source/tanya/container/hashtable.d
index f458ca5..2ae18db 100644
--- a/source/tanya/container/hashtable.d
+++ b/source/tanya/container/hashtable.d
@@ -416,8 +416,8 @@ if (isHashFunction!(hasher, Key))
*
* Precondition: $(D_INLINECODE allocator !is null).
*/
- this(R)(R range, shared Allocator allocator = defaultAllocator)
- if (isForwardRange!R && is(ElementType!R == KeyValue))
+ this(R)(scope R range, shared Allocator allocator = defaultAllocator)
+ if (isForwardRange!R && is(ElementType!R == KeyValue) && !isInfinite!R)
in (allocator !is null)
{
this(allocator);
@@ -450,6 +450,7 @@ if (isHashFunction!(hasher, Key))
shared Allocator allocator = defaultAllocator)
in (allocator !is null)
{
+ this(allocator);
insert(array[]);
}
@@ -714,8 +715,8 @@ if (isHashFunction!(hasher, Key))
*
* Returns: The number of the inserted elements with a unique key.
*/
- size_t insert(R)(R range)
- if (isForwardRange!R && is(ElementType!R == KeyValue))
+ size_t insert(R)(scope R range)
+ if (isForwardRange!R && is(ElementType!R == KeyValue) && !isInfinite!R)
{
size_t count;
foreach (e; range)
diff --git a/source/tanya/container/list.d b/source/tanya/container/list.d
index 279ebc4..caa7bd0 100644
--- a/source/tanya/container/list.d
+++ b/source/tanya/container/list.d
@@ -39,7 +39,7 @@ struct SRange(L)
invariant (this.head !is null);
- private this(ref EntryPointer head) @trusted
+ private this(return ref EntryPointer head) @trusted
{
this.head = &head;
}
@@ -127,7 +127,7 @@ struct SList(T)
* init = Values to initialize the list with.
* allocator = Allocator.
*/
- this(R)(R init, shared Allocator allocator = defaultAllocator)
+ this(R)(scope R init, shared Allocator allocator = defaultAllocator)
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@@ -372,7 +372,7 @@ struct SList(T)
}
/// ditto
- size_t insertFront(R)(R el) @trusted
+ size_t insertFront(R)(scope R el) @trusted
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@@ -473,7 +473,7 @@ struct SList(T)
}
/// ditto
- size_t insertBefore(R)(Range r, R el)
+ size_t insertBefore(R)(Range r, scope R el)
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@@ -798,7 +798,7 @@ struct SList(T)
*
* Returns: $(D_KEYWORD this).
*/
- ref typeof(this) opAssign(R)(R that) @trusted
+ ref typeof(this) opAssign(R)(scope R that) @trusted
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@@ -893,7 +893,8 @@ struct DRange(L)
invariant (this.head !is null);
invariant (this.tail !is null);
- private this(ref EntryPointer head, ref EntryPointer tail) @trusted
+ private this(return ref EntryPointer head, return ref EntryPointer tail)
+ @trusted
{
this.head = &head;
this.tail = &tail;
@@ -1010,7 +1011,7 @@ struct DList(T)
* init = Values to initialize the list with.
* allocator = Allocator.
*/
- this(R)(R init, shared Allocator allocator = defaultAllocator)
+ this(R)(scope R init, shared Allocator allocator = defaultAllocator)
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@@ -1261,13 +1262,10 @@ struct DList(T)
// Creates a lsit of linked entries from a range.
// Returns count of the elements in the list.
- private size_t makeList(R)(ref R el, out Entry* head, out Entry* tail) @trusted
- out (retLength)
- {
- assert((retLength == 0 && head is null && tail is null)
- || (retLength > 0 && head !is null && tail !is null));
- }
- do
+ private size_t makeList(R)(scope ref R el, out Entry* head, out Entry* tail)
+ @trusted
+ out (retLength; (retLength == 0 && head is null && tail is null)
+ || (retLength > 0 && head !is null && tail !is null))
{
size_t retLength;
@@ -1335,7 +1333,7 @@ struct DList(T)
}
/// ditto
- size_t insertFront(R)(R el)
+ size_t insertFront(R)(scope R el)
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@@ -1454,7 +1452,7 @@ struct DList(T)
}
/// ditto
- size_t insertBack(R)(R el) @trusted
+ size_t insertBack(R)(scope R el) @trusted
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@@ -1581,7 +1579,7 @@ struct DList(T)
}
/// ditto
- size_t insertBefore(R)(Range r, R el)
+ size_t insertBefore(R)(Range r, scope R el)
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@@ -1686,7 +1684,7 @@ struct DList(T)
}
/// ditto
- size_t insertAfter(R)(Range r, R el)
+ size_t insertAfter(R)(Range r, scope R el)
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@@ -2067,7 +2065,7 @@ struct DList(T)
*
* Returns: $(D_KEYWORD this).
*/
- ref typeof(this) opAssign(R)(R that) @trusted
+ ref typeof(this) opAssign(R)(scope R that) @trusted
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
diff --git a/source/tanya/container/set.d b/source/tanya/container/set.d
index 7bfa6aa..ae0a0fd 100644
--- a/source/tanya/container/set.d
+++ b/source/tanya/container/set.d
@@ -218,10 +218,13 @@ if (isHashFunction!(hasher, T))
*
* Precondition: $(D_INLINECODE allocator !is null).
*/
- this(R)(R range, shared Allocator allocator = defaultAllocator)
- if (isForwardRange!R && isImplicitlyConvertible!(ElementType!R, T))
+ this(R)(scope R range, shared Allocator allocator = defaultAllocator)
+ if (isForwardRange!R
+ && isImplicitlyConvertible!(ElementType!R, T)
+ && !isInfinite!R)
in (allocator !is null)
{
+ this(allocator);
insert(range);
}
@@ -248,6 +251,7 @@ if (isHashFunction!(hasher, T))
this(size_t n)(T[n] array, shared Allocator allocator = defaultAllocator)
in (allocator !is null)
{
+ this(allocator);
insert(array[]);
}
@@ -456,8 +460,10 @@ if (isHashFunction!(hasher, T))
*
* Returns: The number of new elements inserted.
*/
- size_t insert(R)(R range)
- if (isForwardRange!R && isImplicitlyConvertible!(ElementType!R, T))
+ size_t insert(R)(scope R range)
+ if (isForwardRange!R
+ && isImplicitlyConvertible!(ElementType!R, T)
+ && !isInfinite!R)
{
size_t count;
foreach (e; range)