まずは愚かな質問があれば申し訳ありませんが、私はC++の初心者です。マルチマップの要素が値がC++の場合のみ
私はライブラリを表すシステムを書いており、私たちが本を取り除くことができるようになっている私のライブラリクラスのメンバ関数があります。今、本がユーザーによって貸与されている場合は、私の_usersLoaningMultimap
(multimap<UserId,LoanInfo>
)に要素があることを意味します。キー(UserId)を知らなくても、私が望むLoanInfoを見つける方法はありますか?
bool Library::removeBook(const BookId& bookId){
//how to find my book in my library without knowing who loaned it.
}
ちょうどそれをより明確にするために、私のクラスライブラリは、そのようなものです:
class Library {
public:
Library();
void addUser(const UserId&, const string&);
Optional<string>& getUserInfo(const UserId& userId);
void addBook(const BookId& bookId, const string& description);
Optional<string>& getBookInfo(const BookId& bookId);
bool returnBook(const UserId& userId, const BookId& bookId);
void loanBook(const UserId& userId,LoanInfo& loan);
bool removeUser(const UserId& userId);
void getLoansSortedByDate(const UserId,std::vector<LoanInfo>& loanVector);
~Library() {}
private:
map<BookId, string> _bookMap;
map<UserId, string> _userMap;
multimap<UserId, LoanInfo> _usersLoaningMultimap;
};
ありがとうございます! – adlsc