Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ CheckOptions:
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.ClassPrefix
value: 'Fx'
value: 'Fox'
- key: readability-identifier-naming.StructCase
value: CamelCase
- key: readability-identifier-naming.StructPrefix
value: 'Fx'
value: 'Fox'
- key: readability-identifier-naming.FunctionCase
value: CamelCase
- key: readability-identifier-naming.MethodCase
Expand Down
41 changes: 19 additions & 22 deletions FxMPPagedArray.hpp → FoxMPPagedArray.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma once

#include "FxScriptUtil.hpp"
#include "FoxScriptUtil.hpp"

#include <cstdlib>
#include <cassert>
#include <cstdlib>

template <typename ElementType>
class FxMPPagedArray
class FoxMPPagedArray
{
public:
struct Page
Expand All @@ -28,14 +28,12 @@ class FxMPPagedArray
// {
// }

Iterator(Page* current_page, uint32 index)
: mCurrentPage(current_page), mCurrentIndex(index)
Iterator(Page* current_page, uint32 index) : mCurrentPage(current_page), mCurrentIndex(index)
{
}

Iterator& operator ++ ()
Iterator& operator++()
{

++mCurrentIndex;

if (mCurrentIndex > mCurrentPage->Size) {
Expand All @@ -46,17 +44,16 @@ class FxMPPagedArray
return *this;
}

Iterator operator ++ (int)
Iterator operator++(int)
{
Iterator iterator = *this;
++*this;

return iterator;
}

Iterator& operator -- ()
Iterator& operator--()
{

if (mCurrentIndex == 0) {
mCurrentPage = mCurrentPage->Prev;
mCurrentIndex = mCurrentPage->Size;
Expand All @@ -67,12 +64,12 @@ class FxMPPagedArray
return *this;
}

ElementType& operator * ()
ElementType& operator*()
{
return mCurrentPage->Data[mCurrentIndex];
}

bool operator != (const Iterator& other)
bool operator!=(const Iterator& other)
{
return mCurrentPage && (mCurrentPage != other.mCurrentPage || mCurrentIndex != other.mCurrentIndex);
}
Expand All @@ -81,14 +78,14 @@ class FxMPPagedArray
uint32 mCurrentIndex = 0;
};

FxMPPagedArray() = default;
FoxMPPagedArray() = default;

FxMPPagedArray(uint32 page_node_capacity)
FoxMPPagedArray(uint32 page_node_capacity)
{
Create(page_node_capacity);
}

FxMPPagedArray& operator = (const FxMPPagedArray& other)
FoxMPPagedArray& operator=(const FoxMPPagedArray& other)
{
FirstPage = other.FirstPage;
CurrentPage = other.CurrentPage;
Expand All @@ -101,7 +98,7 @@ class FxMPPagedArray
return *this;
}

FxMPPagedArray& operator = (FxMPPagedArray&& other)
FoxMPPagedArray& operator=(FoxMPPagedArray&& other)
{
FirstPage = other.FirstPage;
CurrentPage = other.CurrentPage;
Expand Down Expand Up @@ -149,7 +146,7 @@ class FxMPPagedArray

inline size_t Size() const
{
//return GetCalculatedSize();
// return GetCalculatedSize();
return TrackedSize;
}

Expand Down Expand Up @@ -318,7 +315,7 @@ class FxMPPagedArray
}


ElementType& operator [] (size_t index)
ElementType& operator[](size_t index)
{
return Get(index);
}
Expand Down Expand Up @@ -381,7 +378,7 @@ class FxMPPagedArray
CurrentPage = nullptr;
}

~FxMPPagedArray()
~FoxMPPagedArray()
{
if (FirstPage == nullptr) {
return;
Expand All @@ -396,7 +393,7 @@ class FxMPPagedArray
// Allocate and initialize the page object
void* allocated_page = std::malloc(sizeof(Page));
if (allocated_page == nullptr) {
FxPanic("FxPagedArray", "Memory error allocating page", 0);
FoxPanic("FoxPagedArray", "Memory error allocating page", 0);
return nullptr; // for msvc
}

Expand All @@ -410,7 +407,7 @@ class FxMPPagedArray
void* allocated_nodes = FX_SCRIPT_ALLOC_MEMORY(ElementType, (sizeof(ElementType) * PageNodeCapacity));

if (allocated_nodes == nullptr) {
FxPanic("FxPagedArray", "Memory error allocating page data", 0);
FoxPanic("FoxPagedArray", "Memory error allocating page data", 0);
return nullptr; // for msvc
}

Expand All @@ -424,7 +421,7 @@ class FxMPPagedArray
inline void SizeCheck(uint32 size) const
{
if (size > PageNodeCapacity) {
FxPanic("FxPagedArray", "The current size of a page is greater than the allocated page node capacity!", 0);
FoxPanic("FoxPagedArray", "The current size of a page is greater than the allocated page node capacity!", 0);
}
}

Expand Down
Loading