RED4ext.SDK icon indicating copy to clipboard operation
RED4ext.SDK copied to clipboard

Adds iterator to HashMap

Open jackhumbert opened this issue 1 year ago • 3 comments

jackhumbert avatar Jul 30 '22 20:07 jackhumbert

Looking at HashMap::ForEach I don't really understand how it works, don't we need a custom iterator?

WopsS avatar Jul 30 '22 20:07 WopsS

I'm not sure, but it complained about this for loop until I added these, which mirror DynArray's.

jackhumbert avatar Jul 30 '22 20:07 jackhumbert

DynArray is a contiguously memory, but this one has buckets / nodes. So I am a bit confused.

If I am right the following:

auto rttiSystem = RED4ext::CRTTISystem::Get();
for (auto node : rttiSystem ->types)
{
    // ...
}

will be translated to after compilation:

auto rttiSystem = RED4ext::CRTTISystem::Get();
auto begin = rttiSystem->begin();
auto end= rttiSystem->end();

while (begin != end)
{
    // ...
    being += sizeof(HashMap::Node);
}

Which is wrong.

I think we are running in an undefined behavior in a long run.

WopsS avatar Jul 30 '22 21:07 WopsS