Format engine codebase with ReSharper

This commit is contained in:
Wojtek Figat
2022-06-14 19:05:04 +02:00
parent 3294624849
commit d4d27b88f0
82 changed files with 276 additions and 775 deletions

View File

@@ -17,18 +17,15 @@ API_CLASS(InBuild) class Array
{
friend Array;
public:
typedef T ItemType;
typedef typename AllocationType::template Data<T> AllocationData;
private:
int32 _count;
int32 _capacity;
AllocationData _allocation;
public:
/// <summary>
/// Initializes a new instance of the <see cref="Array"/> class.
/// </summary>
@@ -208,7 +205,6 @@ public:
}
public:
/// <summary>
/// Gets the amount of the items in the collection.
/// </summary>
@@ -334,7 +330,6 @@ public:
}
public:
FORCE_INLINE T* begin()
{
return &_allocation.Get()[0];
@@ -356,7 +351,6 @@ public:
}
public:
/// <summary>
/// Clear the collection without changing its capacity.
/// </summary>
@@ -738,7 +732,6 @@ public:
}
public:
/// <summary>
/// Performs push on stack operation (stack grows at the end of the collection).
/// </summary>
@@ -777,7 +770,6 @@ public:
}
public:
/// <summary>
/// Performs enqueue to queue operation (queue head is in the beginning of queue).
/// </summary>
@@ -800,7 +792,6 @@ public:
}
public:
/// <summary>
/// Searches for the given item within the entire collection.
/// </summary>
@@ -869,7 +860,6 @@ public:
}
public:
bool operator==(const Array& other) const
{
if (_count == other._count)
@@ -891,7 +881,6 @@ public:
}
public:
/// <summary>
/// The collection iterator.
/// </summary>
@@ -915,7 +904,6 @@ public:
}
public:
Iterator()
: _array(nullptr)
, _index(-1)
@@ -935,7 +923,6 @@ public:
}
public:
FORCE_INLINE Array* GetArray() const
{
return _array;
@@ -1008,7 +995,6 @@ public:
};
public:
/// <summary>
/// Gets iterator for beginning of the collection.
/// </summary>

View File

@@ -17,11 +17,9 @@ class IGrouping : public Array<TSource>
friend ArrayExtensions;
protected:
TKey _key;
public:
/// <summary>
/// Gets the common key.
/// </summary>
@@ -47,7 +45,6 @@ public:
class ArrayExtensions
{
public:
/// <summary>
/// Searches for the specified object using a custom query and returns the zero-based index of the first occurrence within the entire collection.
/// </summary>

View File

@@ -15,18 +15,15 @@ API_CLASS(InBuild) class BitArray
friend BitArray;
public:
typedef uint64 ItemType;
typedef typename AllocationType::template Data<ItemType> AllocationData;
private:
int32 _count;
int32 _capacity;
AllocationData _allocation;
public:
/// <summary>
/// Initializes a new instance of the <see cref="BitArray"/> class.
/// </summary>
@@ -119,7 +116,6 @@ public:
}
public:
/// <summary>
/// Gets the pointer to the bits storage data (linear allocation).
/// </summary>
@@ -216,7 +212,6 @@ public:
}
public:
/// <summary>
/// Clear the collection without changing its capacity.
/// </summary>

View File

@@ -17,7 +17,6 @@ class ChunkedArray
friend ChunkedArray;
private:
// TODO: don't use Array but small struct and don't InlinedArray or Chunk* but Chunk (less dynamic allocations)
typedef Array<T> Chunk;
@@ -25,7 +24,6 @@ private:
Array<Chunk*, InlinedAllocation<32>> _chunks;
public:
ChunkedArray()
{
}
@@ -36,7 +34,6 @@ public:
}
public:
/// <summary>
/// Gets the amount of the elements in the collection.
/// </summary>
@@ -70,7 +67,6 @@ public:
}
public:
// Gets element by index
FORCE_INLINE T& At(int32 index) const
{
@@ -93,7 +89,6 @@ public:
}
public:
/// <summary>
/// Chunked array iterator.
/// </summary>
@@ -102,7 +97,6 @@ public:
friend ChunkedArray;
private:
ChunkedArray* _collection;
int32 _chunkIndex;
int32 _index;
@@ -115,7 +109,6 @@ public:
}
public:
Iterator()
: _collection(nullptr)
, _chunkIndex(INVALID_INDEX)
@@ -131,7 +124,6 @@ public:
}
public:
FORCE_INLINE ChunkedArray* GetChunkedArray() const
{
return _collection;
@@ -143,7 +135,6 @@ public:
}
public:
bool IsEnd() const
{
ASSERT(_collection);
@@ -157,7 +148,6 @@ public:
}
public:
FORCE_INLINE T& operator*() const
{
return _collection->_chunks[_chunkIndex]->At(_index);
@@ -169,7 +159,6 @@ public:
}
public:
FORCE_INLINE bool operator==(const Iterator& v) const
{
return _collection == v._collection && _chunkIndex == v._chunkIndex && _index == v._index;
@@ -181,7 +170,6 @@ public:
}
public:
Iterator& operator++()
{
ASSERT(_collection);
@@ -280,7 +268,6 @@ public:
};
public:
/// <summary>
/// Adds the specified item to the collection.
/// </summary>
@@ -482,7 +469,6 @@ public:
}
public:
Iterator Begin() const
{
return Iterator(this, 0);

View File

@@ -39,7 +39,6 @@ template<typename T, CollectionPoolCacheUtils::ClearCallback<T> ClearCallback =
class CollectionPoolCache
{
public:
/// <summary>
/// Helper object used to access the pooled collection and return it to the pool after usage (on code scope execution end).
/// </summary>
@@ -48,7 +47,6 @@ public:
friend CollectionPoolCache;
private:
CollectionPoolCache* _pool;
ScopeCache(CollectionPoolCache* pool, T* value)
@@ -58,7 +56,6 @@ public:
}
public:
T* Value;
ScopeCache() = delete;
@@ -99,7 +96,6 @@ public:
};
private:
CriticalSection _locker;
Array<T*, InlinedAllocation<64>> _pool;
@@ -111,7 +107,6 @@ private:
}
public:
/// <summary>
/// Finalizes an instance of the <see cref="CollectionPoolCache"/> class.
/// </summary>
@@ -121,7 +116,6 @@ public:
}
public:
/// <summary>
/// Gets the collection instance from the pool. Can reuse the object from the pool or create a new one. Returns collection is always cleared and ready to use.
/// </summary>

View File

@@ -18,7 +18,6 @@ API_CLASS(InBuild) class Dictionary
{
friend Dictionary;
public:
/// <summary>
/// Describes single portion of space for the key and value pair in a hash map.
/// </summary>
@@ -106,14 +105,12 @@ public:
typedef typename AllocationType::template Data<Bucket> AllocationData;
private:
int32 _elementsCount = 0;
int32 _deletedCount = 0;
int32 _size = 0;
AllocationData _allocation;
public:
/// <summary>
/// Initializes a new instance of the <see cref="Dictionary"/> class.
/// </summary>
@@ -200,7 +197,6 @@ public:
}
public:
/// <summary>
/// Gets the amount of the elements in the collection.
/// </summary>
@@ -234,7 +230,6 @@ public:
}
public:
/// <summary>
/// The Dictionary collection iterator.
/// </summary>
@@ -359,7 +354,6 @@ public:
};
public:
/// <summary>
/// Gets element by the key (will add default ValueType element if key not found).
/// </summary>
@@ -460,7 +454,6 @@ public:
}
public:
/// <summary>
/// Clears the collection but without changing its capacity (all inserted elements: keys and values will be removed).
/// </summary>
@@ -571,7 +564,6 @@ public:
}
public:
/// <summary>
/// Add pair element to the collection.
/// </summary>
@@ -700,7 +692,6 @@ public:
}
public:
/// <summary>
/// Finds the element with given key in the collection.
/// </summary>
@@ -775,7 +766,6 @@ public:
}
public:
/// <summary>
/// Clones other collection into this.
/// </summary>
@@ -813,7 +803,6 @@ public:
}
public:
Iterator Begin() const
{
Iterator i(*this, -1);
@@ -851,7 +840,6 @@ public:
}
protected:
/// <summary>
/// The result container of the dictionary item lookup searching.
/// </summary>
@@ -898,7 +886,7 @@ protected:
if (insertPos == -1)
insertPos = bucketIndex;
}
// Occupied bucket by target key
// Occupied bucket by target key
else if (bucket.Key == key)
{
// Found key

View File

@@ -17,7 +17,6 @@ API_CLASS(InBuild) class HashSet
{
friend HashSet;
public:
/// <summary>
/// Describes single portion of space for the item in a hash map.
/// </summary>
@@ -31,7 +30,7 @@ public:
Deleted,
Occupied,
};
/// <summary>The item.</summary>
T Item;
@@ -78,18 +77,16 @@ public:
return _state != Occupied;
}
};
typedef typename AllocationType::template Data<Bucket> AllocationData;
private:
int32 _elementsCount = 0;
int32 _deletedCount = 0;
int32 _size = 0;
AllocationData _allocation;
public:
/// <summary>
/// Initializes a new instance of the <see cref="HashSet"/> class.
/// </summary>
@@ -176,7 +173,6 @@ public:
}
public:
/// <summary>
/// Gets the amount of the elements in the collection.
/// </summary>
@@ -210,7 +206,6 @@ public:
}
public:
/// <summary>
/// The hash set collection iterator.
/// </summary>
@@ -234,7 +229,6 @@ public:
}
public:
Iterator(const Iterator& i)
: _collection(i._collection)
, _index(i._index)
@@ -248,7 +242,6 @@ public:
}
public:
FORCE_INLINE bool IsEnd() const
{
return _index == _collection.Capacity();
@@ -332,7 +325,6 @@ public:
};
public:
/// <summary>
/// Removes all elements from the collection.
/// </summary>
@@ -431,7 +423,6 @@ public:
}
public:
/// <summary>
/// Add element to the collection.
/// </summary>
@@ -513,7 +504,6 @@ public:
}
public:
/// <summary>
/// Find element with given item in the collection
/// </summary>
@@ -545,7 +535,6 @@ public:
}
public:
/// <summary>
/// Clones other collection into this
/// </summary>
@@ -561,7 +550,6 @@ public:
}
public:
Iterator Begin() const
{
Iterator i(*this, -1);
@@ -599,7 +587,6 @@ public:
}
protected:
/// <summary>
/// The result container of the set item lookup searching.
/// </summary>
@@ -646,7 +633,7 @@ protected:
if (insertPos == -1)
insertPos = bucketIndex;
}
// Occupied bucket by target item
// Occupied bucket by target item
else if (bucket.Item == item)
{
// Found item

View File

@@ -13,92 +13,89 @@ template<typename T, typename AllocationType = HeapAllocation>
class RingBuffer
{
public:
typedef T ItemType;
typedef typename AllocationType::template Data<T> AllocationData;
typedef T ItemType;
typedef typename AllocationType::template Data<T> AllocationData;
private:
int32 _front = 0, _back = 0, _count = 0, _capacity = 0;
AllocationData _allocation;
int32 _front = 0, _back = 0, _count = 0, _capacity = 0;
AllocationData _allocation;
public:
~RingBuffer()
{
Memory::DestructItems(Get() + Math::Min(_front, _back), _count);
}
~RingBuffer()
{
Memory::DestructItems(Get() + Math::Min(_front, _back), _count);
}
FORCE_INLINE T* Get()
{
return _allocation.Get();
}
FORCE_INLINE T* Get()
{
return _allocation.Get();
}
FORCE_INLINE int32 Count() const
{
return _count;
}
FORCE_INLINE int32 Count() const
{
return _count;
}
FORCE_INLINE int32 Capacity() const
{
return _capacity;
}
FORCE_INLINE int32 Capacity() const
{
return _capacity;
}
void PushBack(const T& data)
{
if (_capacity == 0 || _capacity == _count)
{
const int32 capacity = _allocation.CalculateCapacityGrow(_capacity, _count + 1);
AllocationData alloc;
alloc.Allocate(capacity);
const int32 frontCount = Math::Min(_capacity - _front, _count);
Memory::MoveItems(alloc.Get(), _allocation.Get() + _front, frontCount);
Memory::DestructItems(_allocation.Get() + _front, frontCount);
const int32 backCount = _count - frontCount;
Memory::MoveItems(alloc.Get() + frontCount, _allocation.Get(), backCount);
Memory::DestructItems(_allocation.Get(), backCount);
_allocation.Swap(alloc);
_front = 0;
_back = _count;
_capacity = capacity;
}
Memory::ConstructItems(_allocation.Get() + _back, &data, 1);
_back = (_back + 1) % _capacity;
_count++;
}
void PushBack(const T& data)
{
if (_capacity == 0 || _capacity == _count)
{
const int32 capacity = _allocation.CalculateCapacityGrow(_capacity, _count + 1);
AllocationData alloc;
alloc.Allocate(capacity);
const int32 frontCount = Math::Min(_capacity - _front, _count);
Memory::MoveItems(alloc.Get(), _allocation.Get() + _front, frontCount);
Memory::DestructItems(_allocation.Get() + _front, frontCount);
const int32 backCount = _count - frontCount;
Memory::MoveItems(alloc.Get() + frontCount, _allocation.Get(), backCount);
Memory::DestructItems(_allocation.Get(), backCount);
_allocation.Swap(alloc);
_front = 0;
_back = _count;
_capacity = capacity;
}
Memory::ConstructItems(_allocation.Get() + _back, &data, 1);
_back = (_back + 1) % _capacity;
_count++;
}
FORCE_INLINE T& PeekFront()
{
return _allocation.Get()[_front];
}
FORCE_INLINE T& PeekFront()
{
return _allocation.Get()[_front];
}
FORCE_INLINE const T& PeekFront() const
{
return _allocation.Get()[_front];
}
FORCE_INLINE const T& PeekFront() const
{
return _allocation.Get()[_front];
}
FORCE_INLINE T& operator[](int32 index)
{
ASSERT(index >= 0 && index < _count);
return _allocation.Get()[(_front + index) % _capacity];
return _allocation.Get()[(_front + index) % _capacity];
}
FORCE_INLINE const T& operator[](int32 index) const
{
ASSERT(index >= 0 && index < _count);
return _allocation.Get()[(_front + index) % _capacity];
return _allocation.Get()[(_front + index) % _capacity];
}
void PopFront()
{
Memory::DestructItems(_allocation.Get() + _front, 1);
_front = (_front + 1) % _capacity;
_count--;
}
void PopFront()
{
Memory::DestructItems(_allocation.Get() + _front, 1);
_front = (_front + 1) % _capacity;
_count--;
}
void Clear()
{
Memory::DestructItems(Get() + Math::Min(_front, _back), _count);
_front = _back = _count = 0;
}
void Clear()
{
Memory::DestructItems(Get() + Math::Min(_front, _back), _count);
_front = _back = _count = 0;
}
};

View File

@@ -12,12 +12,10 @@ template<typename T, int32 Size>
class SamplesBuffer
{
protected:
int32 _count = 0;
T _data[Size];
public:
/// <summary>
/// Gets amount of elements in the collection.
/// </summary>
@@ -110,7 +108,6 @@ public:
}
public:
/// <summary>
/// Adds the specified value to the buffer.
/// </summary>
@@ -146,7 +143,6 @@ public:
}
public:
/// <summary>
/// Gets the minimum value in the buffer.
/// </summary>

View File

@@ -11,14 +11,12 @@
class FLAXENGINE_API Sorting
{
public:
/// <summary>
/// Helper collection used by the sorting algorithms. Implements stack using single linear allocation with variable capacity.
/// </summary>
class FLAXENGINE_API SortingStack
{
public:
static SortingStack& Get();
int32 Count = 0;
@@ -47,7 +45,6 @@ public:
};
public:
/// <summary>
/// Sorts the linear data array using Quick Sort algorithm (non recursive version, uses temporary stack collection).
/// </summary>