mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-10 23:09:18 +00:00
Updated kernel (tl;dr: improved filesystem, tasking, loading files, etc..)
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#define HASHMAP_ERROR -0x8A50
|
||||
|
||||
template <typename K, typename V>
|
||||
class HashNode
|
||||
{
|
||||
@ -33,6 +35,15 @@ public:
|
||||
DummyNode = new HashNode<K, V>(-1, -1);
|
||||
}
|
||||
|
||||
~HashMap()
|
||||
{
|
||||
for (int i = 0; i < HashMapCapacity; i++)
|
||||
if (Nodes[i] != nullptr)
|
||||
delete Nodes[i];
|
||||
delete[] Nodes;
|
||||
delete DummyNode;
|
||||
}
|
||||
|
||||
int HashCode(K Key) { return Key % HashMapCapacity; }
|
||||
|
||||
void AddNode(K Key, V Value)
|
||||
@ -67,7 +78,7 @@ public:
|
||||
Index++;
|
||||
Index %= HashMapCapacity;
|
||||
}
|
||||
return 0xdeadbeef;
|
||||
return HASHMAP_ERROR;
|
||||
}
|
||||
|
||||
V Get(int Key)
|
||||
@ -78,14 +89,14 @@ public:
|
||||
while (Nodes[Index] != nullptr)
|
||||
{
|
||||
if (Iterate++ > HashMapCapacity)
|
||||
return 0xdeadbeef;
|
||||
return HASHMAP_ERROR;
|
||||
|
||||
if (Nodes[Index]->Key == (K)Key)
|
||||
return Nodes[Index]->Value;
|
||||
Index++;
|
||||
Index %= HashMapCapacity;
|
||||
}
|
||||
return 0xdeadbeef;
|
||||
return HASHMAP_ERROR;
|
||||
}
|
||||
|
||||
int Size() { return HashMapSize; }
|
||||
|
Reference in New Issue
Block a user