Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
0281fd5c1d Remove unnecessary exports
If given type is not used across library interface it's methods can stay private.
As of now this is only test as I am not sure if it doesn't cause problems in wasm build.
2022-10-27 23:35:24 +02:00
2 changed files with 59 additions and 59 deletions

View file

@ -72,31 +72,31 @@ nothrow:
size_t length; // Used to compute loadFactor
size_t markerdDeleted;
export void clear()
void clear()
{
elements.clear();
length = 0;
markerdDeleted = 0;
}
export void reset()
void reset()
{
elements.reset();
length = 0;
markerdDeleted = 0;
}
export bool isIn(ref Key el)
bool isIn(ref Key el)
{
return getIndex(el) != getIndexEmptyValue;
}
export bool isIn(Key el)
bool isIn(Key el)
{
return getIndex(el) != getIndexEmptyValue;
}
export Value* getPtr()(auto ref Key k)
Value* getPtr()(auto ref Key k)
{
size_t index = getIndex(k);
if (index == getIndexEmptyValue)
@ -109,20 +109,20 @@ nothrow:
}
}
export ref Value get()(auto ref Key k)
ref Value get()(auto ref Key k)
{
size_t index = getIndex(k);
assert(index != getIndexEmptyValue);
return elements[index].keyValue.value;
}
deprecated("Use get with second parameter.") export auto ref Value getDefault()(
deprecated("Use get with second parameter.") auto ref Value getDefault()(
auto ref Key k, auto ref Value defaultValue)
{
return get(k, defaultValue);
}
export auto ref Value get()(auto ref Key k, auto ref Value defaultValue)
auto ref Value get()(auto ref Key k, auto ref Value defaultValue)
{
size_t index = getIndex(k);
if (index == getIndexEmptyValue)
@ -135,7 +135,7 @@ nothrow:
}
}
export ref Value getInsertDefault()(auto ref Key k, auto ref Value defaultValue)
ref Value getInsertDefault()(auto ref Key k, auto ref Value defaultValue)
{
size_t index = getIndex(k);
if (index == getIndexEmptyValue)
@ -148,7 +148,7 @@ nothrow:
}
export bool tryRemove(Key el)
bool tryRemove(Key el)
{
size_t index = getIndex(el);
if (index == getIndexEmptyValue)
@ -161,23 +161,23 @@ nothrow:
return true;
}
export void remove(Key el)
void remove(Key el)
{
bool ok = tryRemove(el);
assert(ok);
}
export ref Value opIndex()(auto ref Key key)
ref Value opIndex()(auto ref Key key)
{
return get(key);
}
export void opIndexAssign()(auto ref Value value, auto ref Key key)
void opIndexAssign()(auto ref Value value, auto ref Key key)
{
add(key, value);
}
export void add()(auto ref Key key, auto ref Value value)
void add()(auto ref Key key, auto ref Value value)
{
size_t index = getIndex(key);
if (index != getIndexEmptyValue)
@ -221,12 +221,12 @@ nothrow:
//int numA;
//int numB;
export size_t getIndex(Key el)
size_t getIndex(Key el)
{
return getIndex(el);
}
export size_t getIndex(ref Key el)
size_t getIndex(ref Key el)
{
mixin(doNotInline);
@ -260,7 +260,7 @@ nothrow:
}
export float getLoadFactor(size_t forElementsNum)
float getLoadFactor(size_t forElementsNum)
{
if (elements.length == 0)
{
@ -269,7 +269,7 @@ nothrow:
return cast(float) forElementsNum / (elements.length);
}
export void rehash()()
void rehash()()
{
mixin(doNotInline);
// Get all elements
@ -303,7 +303,7 @@ nothrow:
}
// foreach support
export int opApply(DG)(scope DG dg)
int opApply(DG)(scope DG dg)
{
int result;
foreach (ref Bucket gr; elements)
@ -336,7 +336,7 @@ nothrow:
return result;
}
export int byKey(scope int delegate(ref Key k) dg)
int byKey(scope int delegate(ref Key k) dg)
{
int result;
foreach (ref Key k; this)
@ -348,7 +348,7 @@ nothrow:
return result;
}
export int byValue(scope int delegate(ref Value v) dg)
int byValue(scope int delegate(ref Value v) dg)
{
int result;
foreach (ref Value v; this)
@ -360,7 +360,7 @@ nothrow:
return result;
}
export int byKeyValue(scope int delegate(ref Key k, ref Value v) dg)
int byKeyValue(scope int delegate(ref Key k, ref Value v) dg)
{
int result;
foreach (ref Key k, ref Value v; this)

View file

@ -14,13 +14,13 @@ import bubel.ecs.std;
import std.conv : emplace;
import std.traits : hasMember, isCopyable, TemplateOf, Unqual;
export @nogc @safe nothrow pure size_t nextPow2(size_t num)
@nogc @safe nothrow pure size_t nextPow2(size_t num)
{
return 1 << bsr(num) + 1;
}
export __gshared size_t gVectorsCreated = 0;
export __gshared size_t gVectorsDestroyed = 0;
__gshared size_t gVectorsCreated = 0;
__gshared size_t gVectorsDestroyed = 0;
struct Vector(T)
{
@ -28,19 +28,19 @@ struct Vector(T)
size_t used;
public:
export this()(T t)
this()(T t)
{
add(t);
}
export this(X)(X[] t) if (is(Unqual!X == Unqual!T))
this(X)(X[] t) if (is(Unqual!X == Unqual!T))
{
add(t);
}
/*static if (isCopyable!T) {
export this(this) {
this(this) {
T[] tmp = array[0 .. used];
array = null;
used = 0;
@ -52,17 +52,17 @@ public:
@disable this(this);
export ~this()
~this()
{
clear();
}
export void clear()
void clear()
{
removeAll();
}
export void removeAll()
void removeAll()
{
if (array !is null)
{
@ -77,17 +77,17 @@ public:
used = 0;
}
export bool empty() const
bool empty() const
{
return (used == 0);
}
export size_t length() const
size_t length() const
{
return used;
}
export void length(size_t newLength)
void length(size_t newLength)
{
if (newLength > used)
{
@ -111,12 +111,12 @@ public:
used = newLength;
}
export void reset()
void reset()
{
used = 0;
}
export void reserve(size_t numElements)
void reserve(size_t numElements)
{
if (numElements > array.length)
{
@ -124,12 +124,12 @@ public:
}
}
export size_t capacity()
size_t capacity()
{
return array.length - used;
}
export void extend(size_t newNumOfElements)
void extend(size_t newNumOfElements)
{
auto oldArray = manualExtend(array, newNumOfElements);
if (oldArray !is null)
@ -138,14 +138,14 @@ public:
}
}
export @nogc void freeData(void[] data)
@nogc void freeData(void[] data)
{
// 0x0F probably invalid value for pointers and other types
memset(data.ptr, 0x0F, data.length); // Makes bugs show up xD
free(data.ptr);
}
export static void[] manualExtend(ref T[] array, size_t newNumOfElements = 0)
static void[] manualExtend(ref T[] array, size_t newNumOfElements = 0)
{
if (newNumOfElements == 0)
newNumOfElements = 2;
@ -161,7 +161,7 @@ public:
return (cast(void*) oldArray.ptr)[0 .. oldArray.length * T.sizeof];
}
export Vector!T copy()()
Vector!T copy()()
{
Vector!T duplicate;
duplicate.reserve(used);
@ -169,12 +169,12 @@ public:
return duplicate;
}
/*export bool canAddWithoutRealloc(uint elemNum = 1)
/*bool canAddWithoutRealloc(uint elemNum = 1)
{
return used + elemNum <= array.length;
}*/
export void add()(T t)
void add()(T t)
{
if (used >= array.length)
{
@ -185,7 +185,7 @@ public:
}
/// Add element at given position moving others
export void add()(T t, size_t pos)
void add()(T t, size_t pos)
{
assert(pos <= used);
if (used >= array.length)
@ -201,7 +201,7 @@ public:
used++;
}
export void add(X)(X[] t) if (is(Unqual!X == Unqual!T))
void add(X)(X[] t) if (is(Unqual!X == Unqual!T))
{
if (used + t.length > array.length)
{
@ -214,7 +214,7 @@ public:
used += t.length;
}
export void remove(size_t elemNum)
void remove(size_t elemNum)
{
//destroy(array[elemNum]);
static if (__traits(hasMember, T, "__xdtor"))
@ -226,7 +226,7 @@ public:
used--;
}
export void removeStable()(size_t elemNum)
void removeStable()(size_t elemNum)
{
used--;
foreach (i; 0 .. used)
@ -235,7 +235,7 @@ public:
}
}
export bool tryRemoveElement()(T elem)
bool tryRemoveElement()(T elem)
{
foreach (i, ref el; array[0 .. used])
{
@ -248,65 +248,65 @@ public:
return false;
}
export void removeElement()(T elem)
void removeElement()(T elem)
{
bool ok = tryRemoveElement(elem);
assert(ok, "There is no such an element in vector");
}
export ref T opIndex(size_t elemNum) const
ref T opIndex(size_t elemNum) const
{
//debug assert(elemNum < used, "Range violation [index]");
return *cast(T*)&array.ptr[elemNum];
}
export auto opSlice()
auto opSlice()
{
return array.ptr[0 .. used];
}
export T[] opSlice(size_t x, size_t y)
T[] opSlice(size_t x, size_t y)
{
assert(y <= used);
return array.ptr[x .. y];
}
export size_t opDollar()
size_t opDollar()
{
return used;
}
export void opAssign(X)(X[] slice)
void opAssign(X)(X[] slice)
{
reset();
this ~= slice;
}
export void opOpAssign(string op)(T obj)
void opOpAssign(string op)(T obj)
{
//static assert(op == "~");
add(obj);
}
export void opOpAssign(string op, X)(X[] obj)
void opOpAssign(string op, X)(X[] obj)
{
//static assert(op == "~");
add(obj);
}
export void opIndexAssign()(T obj, size_t elemNum)
void opIndexAssign()(T obj, size_t elemNum)
{
assert(elemNum < used, "Range viloation");
array[elemNum] = obj;
}
export void opSliceAssign()(T[] obj, size_t a, size_t b)
void opSliceAssign()(T[] obj, size_t a, size_t b)
{
assert(b <= used && a <= b, "Range viloation");
array.ptr[a .. b] = obj;
}
export bool opEquals()(auto ref const Vector!(T) r) const
bool opEquals()(auto ref const Vector!(T) r) const
{
return used == r.used && array.ptr[0 .. used] == r.array.ptr[0 .. r.used];
}