I am wondering how to implement a TArray-backed Map, or if someone has already made one, please share.
The purpose is entirely for replication purposes. I don’t mind my Map being less performant but it needs to replicate. I am tired of creating a TMap, TArray and writing the functions every time I need this functionality. I just want a class that I can reuse whenever.
I have spent a few hours trying to come up with a solution but I seem to always be limited by something.
The current implementation I have right now is a class inherited from TArray, but has a Map as a member (which is <KeyType, int32>, where int32 is the index within the array). Certain functions have been overridden to ensure the Map is always updated when the array is modified.
The issue with this is that I am unable to make it a UPROPERTY. I would have thought inheriting from TArray would have helped with that but apparently not.
I tried creating a USTRUCT that would hold a TArray and TMap - basically doing the same thing as the other implementation but with all the auto-generated functionality that USTRUCTS provide, but I can’t seem to use template/generic types on USTRUCTs.
Does anyone have any info on this? All I really want is a replicated array that can be accessed almost O(1) through a key.