mirror of
https://github.com/Mr-X-GTA/GTAV-Classes-1.git
synced 2026-10-10 03:43:17 +08:00
add pgBaseMetaDataType and pgBaseMetaDataDebugNameType and pgDictionary and pgDictionaryBase (#138)
This commit is contained in:
@@ -14,4 +14,23 @@ namespace rage
|
||||
}; //Size: 0x0008
|
||||
static_assert(sizeof(pgBase) == 0x10);
|
||||
|
||||
class pgBaseMetaDataType
|
||||
{
|
||||
public:
|
||||
virtual ~pgBaseMetaDataType() = default;
|
||||
virtual void Lookup(uint32_t hash) = 0;
|
||||
}; //Size: 0x0008
|
||||
|
||||
class pgBaseMetaDataDebugNameType : public pgBaseMetaDataType
|
||||
{
|
||||
public:
|
||||
virtual ~pgBaseMetaDataDebugNameType() = default;
|
||||
char pad_0000[64];
|
||||
}; //Size: 0x0072
|
||||
|
||||
class pgBaseRefCounted : public pgBase
|
||||
{
|
||||
public:
|
||||
virtual ~pgBaseRefCounted() = default;
|
||||
}; //Size: 0x0008
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
#pragma once
|
||||
|
||||
namespace rage
|
||||
{
|
||||
class pgDictionaryBase
|
||||
{
|
||||
public:
|
||||
virtual ~pgDictionaryBase() = default;
|
||||
}; //Size: 0x0008
|
||||
|
||||
template<typename T>
|
||||
class pgDictionary : public pgDictionaryBase
|
||||
{
|
||||
private:
|
||||
struct Node {
|
||||
T key;
|
||||
Node* next;
|
||||
|
||||
Node(const T& k, Node* n = nullptr)
|
||||
: key(k), next(n) {}
|
||||
};
|
||||
Node* head;
|
||||
public:
|
||||
pgDictionary() : head(nullptr) {}
|
||||
~pgDictionary() {
|
||||
clearDict();
|
||||
}
|
||||
|
||||
void addDict(const T& key) {
|
||||
Node* newNode = new Node(key, head);
|
||||
head = newNode;
|
||||
}
|
||||
|
||||
bool containsDict(const T& key) const {
|
||||
Node* current = head;
|
||||
while (current != nullptr) {
|
||||
if (current->key == key) {
|
||||
return true;
|
||||
}
|
||||
current = current->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void removeDict(const T& key) {
|
||||
if (head == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (head->key == key) {
|
||||
Node* temp = head;
|
||||
head = head->next;
|
||||
delete temp;
|
||||
return;
|
||||
}
|
||||
|
||||
Node* current = head;
|
||||
while (current->next != nullptr) {
|
||||
if (current->next->key == key) {
|
||||
Node* temp = current->next;
|
||||
current->next = current->next->next;
|
||||
delete temp;
|
||||
return;
|
||||
}
|
||||
current = current->next;
|
||||
}
|
||||
}
|
||||
|
||||
size_t sizeDict() const {
|
||||
size_t count = 0;
|
||||
Node* current = head;
|
||||
while (current != nullptr) {
|
||||
count++;
|
||||
current = current->next;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void clearDict() {
|
||||
while (head != nullptr) {
|
||||
Node* temp = head;
|
||||
head = head->next;
|
||||
delete temp;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user