mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-07 21:39:19 +00:00
Updated types
This commit is contained in:
@ -6,8 +6,8 @@ template <class T>
|
||||
class Vector
|
||||
{
|
||||
private:
|
||||
uint64_t VectorSize = 0;
|
||||
uint64_t VectorCapacity = 0;
|
||||
size_t VectorSize = 0;
|
||||
size_t VectorCapacity = 0;
|
||||
T *VectorBuffer = nullptr;
|
||||
|
||||
public:
|
||||
@ -23,7 +23,7 @@ public:
|
||||
VectorBuffer = 0;
|
||||
}
|
||||
|
||||
__no_instrument_function Vector(uint64_t Size)
|
||||
__no_instrument_function Vector(size_t Size)
|
||||
{
|
||||
VectorCapacity = Size;
|
||||
VectorSize = Size;
|
||||
@ -33,7 +33,7 @@ public:
|
||||
VectorBuffer = new T[Size];
|
||||
}
|
||||
|
||||
__no_instrument_function Vector(uint64_t Size, const T &Initial)
|
||||
__no_instrument_function Vector(size_t Size, const T &Initial)
|
||||
{
|
||||
VectorSize = Size;
|
||||
VectorCapacity = Size;
|
||||
@ -41,7 +41,7 @@ public:
|
||||
debug("VECTOR INIT: Vector( %lld %llx )", Size, Initial);
|
||||
#endif
|
||||
VectorBuffer = new T[Size];
|
||||
for (uint64_t i = 0; i < Size; i++)
|
||||
for (size_t i = 0; i < Size; i++)
|
||||
VectorBuffer[i] = Initial;
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ public:
|
||||
debug("VECTOR INIT: Vector( <vector> )->Size: %lld", VectorSize);
|
||||
#endif
|
||||
VectorBuffer = new T[VectorSize];
|
||||
for (uint64_t i = 0; i < VectorSize; i++)
|
||||
for (size_t i = 0; i < VectorSize; i++)
|
||||
VectorBuffer[i] = Vector.VectorBuffer[i];
|
||||
}
|
||||
|
||||
@ -65,21 +65,21 @@ public:
|
||||
delete[] VectorBuffer;
|
||||
}
|
||||
|
||||
__no_instrument_function void remove(uint64_t Position)
|
||||
__no_instrument_function void remove(size_t Position)
|
||||
{
|
||||
if (Position >= VectorSize)
|
||||
return;
|
||||
memset(&*(VectorBuffer + Position), 0, sizeof(T));
|
||||
for (uint64_t i = 0; i < VectorSize - 1; i++)
|
||||
for (size_t i = 0; i < VectorSize - 1; i++)
|
||||
{
|
||||
*(VectorBuffer + Position + i) = *(VectorBuffer + Position + i + 1);
|
||||
}
|
||||
VectorSize--;
|
||||
}
|
||||
|
||||
__no_instrument_function uint64_t capacity() const { return VectorCapacity; }
|
||||
__no_instrument_function size_t capacity() const { return VectorCapacity; }
|
||||
|
||||
__no_instrument_function uint64_t size() const { return VectorSize; }
|
||||
__no_instrument_function size_t size() const { return VectorSize; }
|
||||
|
||||
__no_instrument_function bool empty() const;
|
||||
|
||||
@ -104,7 +104,7 @@ public:
|
||||
{
|
||||
if (VectorSize <= 1)
|
||||
return;
|
||||
for (uint64_t i = 0, j = VectorSize - 1; i < j; i++, j--)
|
||||
for (size_t i = 0, j = VectorSize - 1; i < j; i++, j--)
|
||||
{
|
||||
T c = *(VectorBuffer + i);
|
||||
*(VectorBuffer + i) = *(VectorBuffer + j);
|
||||
@ -112,7 +112,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
__no_instrument_function void reserve(uint64_t Capacity)
|
||||
__no_instrument_function void reserve(size_t Capacity)
|
||||
{
|
||||
if (VectorBuffer == 0)
|
||||
{
|
||||
@ -122,25 +122,25 @@ public:
|
||||
#ifdef DEBUG_MEM_ALLOCATION
|
||||
debug("VECTOR ALLOCATION: reverse( %lld )", Capacity);
|
||||
#endif
|
||||
T *Newbuffer = new T[Capacity];
|
||||
uint64_t _Size = Capacity < VectorSize ? Capacity : VectorSize;
|
||||
for (uint64_t i = 0; i < _Size; i++)
|
||||
Newbuffer[i] = VectorBuffer[i];
|
||||
T *NewBuffer = new T[Capacity];
|
||||
size_t _Size = Capacity < VectorSize ? Capacity : VectorSize;
|
||||
for (size_t i = 0; i < _Size; i++)
|
||||
NewBuffer[i] = VectorBuffer[i];
|
||||
VectorCapacity = Capacity;
|
||||
#ifdef DEBUG_MEM_ALLOCATION
|
||||
debug("VECTOR ALLOCATION: reverse( <Capacity> )->Buffer:~%lld", VectorBuffer);
|
||||
#endif
|
||||
delete[] VectorBuffer;
|
||||
VectorBuffer = Newbuffer;
|
||||
VectorBuffer = NewBuffer;
|
||||
}
|
||||
|
||||
__no_instrument_function void resize(uint64_t Size)
|
||||
__no_instrument_function void resize(size_t Size)
|
||||
{
|
||||
reserve(Size);
|
||||
VectorSize = Size;
|
||||
}
|
||||
|
||||
__no_instrument_function T &operator[](uint64_t Index) { return VectorBuffer[Index]; }
|
||||
__no_instrument_function T &operator[](size_t Index) { return VectorBuffer[Index]; }
|
||||
|
||||
__no_instrument_function Vector<T> &operator=(const Vector<T> &Vector)
|
||||
{
|
||||
@ -151,7 +151,7 @@ public:
|
||||
debug("VECTOR ALLOCATION: operator=( <vector> )->Size:%lld", VectorSize);
|
||||
#endif
|
||||
VectorBuffer = new T[VectorSize];
|
||||
for (uint64_t i = 0; i < VectorSize; i++)
|
||||
for (size_t i = 0; i < VectorSize; i++)
|
||||
VectorBuffer[i] = Vector.VectorBuffer[i];
|
||||
return *this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user