Forums WoW Modding Support Archives Azerothcore Discord Archives [DiscordArchive] <@224931509046345729> Can you elaborate a little bit about your problem? You are having an issue wit

[DiscordArchive] <@224931509046345729> Can you elaborate a little bit about your problem? You are having an issue wit

[DiscordArchive] <@224931509046345729> Can you elaborate a little bit about your problem? You are having an issue wit

rektbyfaith
Administrator
0
11-15-2023, 07:13 PM
#1
Archived author: walkline • Posted: 2023-11-15T19:13:32.213000+00:00
Original source

<@224931509046345729> Can you elaborate a little bit about your problem? You are having an issue with handling data with double index (string+integer) in C++?
rektbyfaith
11-15-2023, 07:13 PM #1

Archived author: walkline • Posted: 2023-11-15T19:13:32.213000+00:00
Original source

<@224931509046345729> Can you elaborate a little bit about your problem? You are having an issue with handling data with double index (string+integer) in C++?

rektbyfaith
Administrator
0
11-15-2023, 07:33 PM
#2
Archived author: Kitzunu • Posted: 2023-11-15T19:33:16.191000+00:00
Original source

handling indexing/storing it
rektbyfaith
11-15-2023, 07:33 PM #2

Archived author: Kitzunu • Posted: 2023-11-15T19:33:16.191000+00:00
Original source

handling indexing/storing it

rektbyfaith
Administrator
0
11-15-2023, 08:07 PM
#3
Archived author: Natrist • Posted: 2023-11-15T20:07:11.833000+00:00
Original source

I can probably look into it tonight
rektbyfaith
11-15-2023, 08:07 PM #3

Archived author: Natrist • Posted: 2023-11-15T20:07:11.833000+00:00
Original source

I can probably look into it tonight

rektbyfaith
Administrator
0
11-15-2023, 08:41 PM
#4
Archived author: walkline • Posted: 2023-11-15T20:41:56.969000+00:00
Original source

<@224931509046345729> There are several options that I see here.
1. Use nested maps.
Example:
```
typedef std::unordered_map<int32, ModuleString> ModuleStringByEntryContainer;
typedef std::unordered_map<std:Confusedtring, ModuleStringByEntryContainer> ModuleStringContainers;

// Fill in
ModuleStringByEntryContainer entryContainer;
entryContainer[entryId] = ModuleString();

ModuleStringContainers containers;
containers["my-module"] = entryContainer;

// Get value
ModuleString v = containers["my-module"][entryId];
```
2. Build your custom hash function and use single map.
You can transform module name and entry into single string and use it as an index.
For example:
```
typedef std::unordered_map<std:Confusedtring, ModuleString> ModuleStringContainer;

std:Confusedtring moduleStringKeyForModuleAndEntry(const std:Confusedtring& moduleName, int32 entry) {
return moduleName + ":" + std::to_string(entry);
}

// Fill in
ModuleStringContainer container;
container[moduleStringKeyForModuleAndEntry("my-module", 42)] = ModuleString();

// Get value
ModuleString v = container[moduleStringKeyForModuleAndEntry("my-module", 42)];
```
3. Use ModuleString object as a key for map.
I think it's possible to implement hash function in ModuleString class and then use it like you usually do. More details here - https://stackoverflow.com/questions/1701...as-the-key
[Embed: C++ unordered_map using a custom class type as the key]
I am trying to use a custom class as key for an unordered_map, like the following:

#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;

class ...
https://stackoverflow.com/questions/1701...as-the-key
rektbyfaith
11-15-2023, 08:41 PM #4

Archived author: walkline • Posted: 2023-11-15T20:41:56.969000+00:00
Original source

<@224931509046345729> There are several options that I see here.
1. Use nested maps.
Example:
```
typedef std::unordered_map<int32, ModuleString> ModuleStringByEntryContainer;
typedef std::unordered_map<std:Confusedtring, ModuleStringByEntryContainer> ModuleStringContainers;

// Fill in
ModuleStringByEntryContainer entryContainer;
entryContainer[entryId] = ModuleString();

ModuleStringContainers containers;
containers["my-module"] = entryContainer;

// Get value
ModuleString v = containers["my-module"][entryId];
```
2. Build your custom hash function and use single map.
You can transform module name and entry into single string and use it as an index.
For example:
```
typedef std::unordered_map<std:Confusedtring, ModuleString> ModuleStringContainer;

std:Confusedtring moduleStringKeyForModuleAndEntry(const std:Confusedtring& moduleName, int32 entry) {
return moduleName + ":" + std::to_string(entry);
}

// Fill in
ModuleStringContainer container;
container[moduleStringKeyForModuleAndEntry("my-module", 42)] = ModuleString();

// Get value
ModuleString v = container[moduleStringKeyForModuleAndEntry("my-module", 42)];
```
3. Use ModuleString object as a key for map.
I think it's possible to implement hash function in ModuleString class and then use it like you usually do. More details here - https://stackoverflow.com/questions/1701...as-the-key
[Embed: C++ unordered_map using a custom class type as the key]
I am trying to use a custom class as key for an unordered_map, like the following:

#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;

class ...
https://stackoverflow.com/questions/1701...as-the-key

rektbyfaith
Administrator
0
11-15-2023, 08:53 PM
#5
Archived author: Kitzunu • Posted: 2023-11-15T20:53:38.825000+00:00
Original source

Thanks, will look into it in the weekend probably
rektbyfaith
11-15-2023, 08:53 PM #5

Archived author: Kitzunu • Posted: 2023-11-15T20:53:38.825000+00:00
Original source

Thanks, will look into it in the weekend probably

Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)