次のユーザー構造体があるとします。
struct User {
string userId;
UserType userType; // UserType is just an enumeration
string hostName;
string ipAddress;
//and more other attributes will be added here
};
そして、ユーザーレコードのコレクションを保存する必要があります(約10 ^ 5ユーザー、さらに大きく拡張できます)。unordered_setまたはunordered_mapとして保存すると、パフォーマンスが向上しますか?Unordered_setは技術的にはHashSetと同じであり、unordered_mapはHashMapと同じですよね?要素の数が増えると挿入と削除が非常に遅くなるため、通常のセット(順序付き)を使用することはできません。
unordered_set <User> userRecords;
また
unordered_map <string, User> userRecords; // string is the user ID.
挿入、削除、およびuserIdによる特定のユーザーオブジェクトへのアクセスに関して、非常に高速である必要があります。