Replace defaultAllocator with theAllocator

This commit is contained in:
2016-11-30 21:54:31 +01:00
parent ed0eb4ac74
commit 9fdcef86e7
8 changed files with 106 additions and 117 deletions

View File

@ -27,7 +27,7 @@ class SList(T)
* allocator = The allocator should be used for the element
* allocations.
*/
this(IAllocator allocator = defaultAllocator)
this(IAllocator allocator = theAllocator)
{
this.allocator = allocator;
reset();
@ -79,7 +79,7 @@ class SList(T)
///
unittest
{
auto l = make!(SList!int)(defaultAllocator);
auto l = make!(SList!int)(theAllocator);
int[2] values = [8, 9];
l.front = values[0];
@ -87,7 +87,7 @@ class SList(T)
l.front = values[1];
assert(l.front == values[1]);
dispose(defaultAllocator, l);
dispose(theAllocator, l);
}
/**
@ -108,7 +108,7 @@ class SList(T)
///
unittest
{
auto l = make!(SList!int)(defaultAllocator);
auto l = make!(SList!int)(theAllocator);
int value = 5;
assert(l.empty);
@ -118,7 +118,7 @@ class SList(T)
assert(l.front == value);
assert(!l.empty);
dispose(defaultAllocator, l);
dispose(theAllocator, l);
}
/**
@ -153,7 +153,7 @@ class SList(T)
///
unittest
{
auto l = make!(SList!int)(defaultAllocator);
auto l = make!(SList!int)(theAllocator);
int[2] values = [8, 9];
l.front = values[0];
@ -162,7 +162,7 @@ class SList(T)
l.popFront();
assert(l.front == values[0]);
dispose(defaultAllocator, l);
dispose(theAllocator, l);
}
/**
@ -192,7 +192,7 @@ class SList(T)
///
unittest
{
auto l = make!(SList!int)(defaultAllocator);
auto l = make!(SList!int)(theAllocator);
int[3] values = [8, 5, 4];
l.front = values[0];
@ -203,7 +203,7 @@ class SList(T)
assert(l.remove() == 8);
assert(l.empty);
dispose(defaultAllocator, l);
dispose(theAllocator, l);
}
/**
@ -220,7 +220,7 @@ class SList(T)
///
unittest
{
auto l = make!(SList!int)(defaultAllocator);
auto l = make!(SList!int)(theAllocator);
int[2] values = [8, 5];
l.current = values[0];
@ -231,7 +231,7 @@ class SList(T)
l.reset();
assert(l.current == 5);
dispose(defaultAllocator, l);
dispose(theAllocator, l);
}
/**
@ -262,7 +262,7 @@ class SList(T)
///
unittest
{
auto l = make!(SList!int)(defaultAllocator);
auto l = make!(SList!int)(theAllocator);
int[3] values = [5, 4, 9];
l.front = values[0];
@ -275,7 +275,7 @@ class SList(T)
assert(i != 2 || e == values[0]);
}
dispose(defaultAllocator, l);
dispose(theAllocator, l);
}
/// Ditto.
@ -300,7 +300,7 @@ class SList(T)
///
unittest
{
auto l = make!(SList!int)(defaultAllocator);
auto l = make!(SList!int)(theAllocator);
int[3] values = [5, 4, 9];
size_t i;
@ -315,7 +315,7 @@ class SList(T)
++i;
}
dispose(defaultAllocator, l);
dispose(theAllocator, l);
}
/**
@ -398,7 +398,7 @@ interface Stuff
///
unittest
{
auto l = make!(SList!Stuff)(defaultAllocator);
auto l = make!(SList!Stuff)(theAllocator);
dispose(defaultAllocator, l);
dispose(theAllocator, l);
}

View File

@ -27,7 +27,7 @@ class Queue(T)
* allocator = The allocator should be used for the element
* allocations.
*/
this(IAllocator allocator = defaultAllocator)
this(IAllocator allocator = theAllocator)
{
this.allocator = allocator;
}
@ -91,7 +91,7 @@ class Queue(T)
///
unittest
{
auto q = make!(Queue!int)(defaultAllocator);
auto q = make!(Queue!int)(theAllocator);
int[2] values = [8, 9];
q.insertBack(values[0]);
@ -99,7 +99,7 @@ class Queue(T)
q.insertBack(values[1]);
assert(q.front is values[0]);
dispose(defaultAllocator, q);
dispose(theAllocator, q);
}
/**
@ -119,7 +119,7 @@ class Queue(T)
///
unittest
{
auto q = make!(Queue!int)(defaultAllocator);
auto q = make!(Queue!int)(theAllocator);
int value = 5;
assert(q.empty);
@ -129,7 +129,7 @@ class Queue(T)
assert(q.front == value);
assert(!q.empty);
dispose(defaultAllocator, q);
dispose(theAllocator, q);
}
/**
@ -143,14 +143,14 @@ class Queue(T)
///
unittest
{
auto q = make!(Queue!int)(defaultAllocator);
auto q = make!(Queue!int)(theAllocator);
int value = 7;
assert(q.empty);
q.insertBack(value);
assert(!q.empty);
dispose(defaultAllocator, q);
dispose(theAllocator, q);
}
/**
@ -176,7 +176,7 @@ class Queue(T)
///
unittest
{
auto q = make!(Queue!int)(defaultAllocator);
auto q = make!(Queue!int)(theAllocator);
int[2] values = [8, 9];
q.insertBack(values[0]);
@ -185,7 +185,7 @@ class Queue(T)
q.popFront();
assert(q.front is values[1]);
dispose(defaultAllocator, q);
dispose(theAllocator, q);
}
/**
@ -212,7 +212,7 @@ class Queue(T)
///
unittest
{
auto q = make!(Queue!int)(defaultAllocator);
auto q = make!(Queue!int)(theAllocator);
dispose(defaultAllocator, q);
dispose(theAllocator, q);
}

View File

@ -17,12 +17,12 @@ import tanya.memory;
*
* If you assign a value:
* ---
* auto v = make!(Vector!int)(defaultAllocator);
* auto v = make!(Vector!int)(theAllocator);
* int value = 5;
*
* v[1000] = value;
*
* dispose(defaultAllocator, v);
* dispose(theAllocator, v);
* ---
* it will allocate not only for one, but for 1000 elements. So this
* implementation is more suitable for sequential data with random access.
@ -40,14 +40,14 @@ class Vector(T)
* allocator = The allocator should be used for the element
* allocations.
*/
this(size_t length, IAllocator allocator = defaultAllocator)
this(size_t length, IAllocator allocator = theAllocator)
{
this.allocator = allocator;
vector = makeArray!T(allocator, length);
}
/// Ditto.
this(IAllocator allocator = defaultAllocator)
this(IAllocator allocator = theAllocator)
{
this(0, allocator);
}
@ -82,19 +82,18 @@ class Vector(T)
///
unittest
{
auto v = make!(Vector!int)(defaultAllocator);
auto v = make!(Vector!int)(theAllocator);
v.length = 5;
assert(v.length == 5);
// TODO
v.length = 7;
assert(v.length == 7);
v.length = 0;
assert(v.length == 0);
dispose(defaultAllocator, v);
dispose(theAllocator, v);
}
/**
@ -140,7 +139,7 @@ class Vector(T)
///
unittest
{
auto v = make!(Vector!int)(defaultAllocator);
auto v = make!(Vector!int)(theAllocator);
int[2] values = [5, 15];
assert(v.length == 0);
@ -151,7 +150,7 @@ class Vector(T)
v[4] = values[1];
assert(v.length == 5);
dispose(defaultAllocator, v);
dispose(theAllocator, v);
}
/**
@ -170,7 +169,7 @@ class Vector(T)
///
unittest
{
auto v = make!(Vector!int)(defaultAllocator);
auto v = make!(Vector!int)(theAllocator);
int[2] values = [5, 15];
v[1] = values[0];
@ -182,7 +181,7 @@ class Vector(T)
v[0] = values[1];
assert(v[0] is values[1]);
dispose(defaultAllocator, v);
dispose(theAllocator, v);
}
/**
@ -227,7 +226,7 @@ class Vector(T)
///
unittest
{
auto v = make!(Vector!int)(defaultAllocator, 1);
auto v = make!(Vector!int)(theAllocator, 1);
int[3] values = [5, 15, 8];
v[0] = values[0];
@ -250,7 +249,7 @@ class Vector(T)
assert(j != 2 || e is values[2]);
}
dispose(defaultAllocator, v);
dispose(theAllocator, v);
}
/**
@ -280,7 +279,7 @@ class Vector(T)
///
unittest
{
auto v = make!(Vector!int)(defaultAllocator, 1);
auto v = make!(Vector!int)(theAllocator, 1);
int[2] values = [5, 15];
v.front = values[0];
@ -289,7 +288,7 @@ class Vector(T)
v.front = values[1];
assert(v.front == 15);
dispose(defaultAllocator, v);
dispose(theAllocator, v);
}
/**
@ -312,7 +311,7 @@ class Vector(T)
///
unittest
{
auto v = make!(Vector!int)(defaultAllocator, 1);
auto v = make!(Vector!int)(theAllocator, 1);
int[2] values = [5, 15];
v[0] = values[0];
@ -325,7 +324,7 @@ class Vector(T)
v.popFront();
assert(v.empty);
dispose(defaultAllocator, v);
dispose(theAllocator, v);
}
/**
@ -355,7 +354,7 @@ class Vector(T)
///
unittest
{
auto v = make!(Vector!int)(defaultAllocator, 1);
auto v = make!(Vector!int)(theAllocator, 1);
int[2] values = [5, 15];
v.back = values[0];
@ -364,7 +363,7 @@ class Vector(T)
v.back = values[1];
assert(v.back == 15);
dispose(defaultAllocator, v);
dispose(theAllocator, v);
}
/**
@ -386,7 +385,7 @@ class Vector(T)
///
unittest
{
auto v = make!(Vector!int)(defaultAllocator, 1);
auto v = make!(Vector!int)(theAllocator, 1);
int[2] values = [5, 15];
v[0] = values[0];
@ -399,7 +398,7 @@ class Vector(T)
v.popBack();
assert(v.empty);
dispose(defaultAllocator, v);
dispose(theAllocator, v);
}
/// Container.
@ -411,7 +410,7 @@ class Vector(T)
///
unittest
{
auto v = make!(Vector!int)(defaultAllocator);
auto v = make!(Vector!int)(theAllocator);
dispose(defaultAllocator, v);
dispose(theAllocator, v);
}