classAuthenticationManager { int timeToLive; unordered_map<string, int> expiredTime; public: AuthenticationManager(int _timeToLive) : timeToLive(_timeToLive) { } voidgenerate(string tokenId, int currentTime){ expiredTime[tokenId] = currentTime + timeToLive; } voidrenew(string tokenId, int currentTime){ auto it = expiredTime.find(tokenId); if (it != expiredTime.end() && it->second > currentTime) { generate(tokenId, currentTime); } } intcountUnexpiredTokens(int currentTime){ int ans = 0; for (constauto& p : expiredTime) { if (p.second > currentTime) { ++ans; } } return ans; } };
/** * Your AuthenticationManager object will be instantiated and called as such: * AuthenticationManager* obj = new AuthenticationManager(timeToLive); * obj->generate(tokenId,currentTime); * obj->renew(tokenId,currentTime); * int param_3 = obj->countUnexpiredTokens(currentTime); */
checking for boostlib >= 1.65 (106500)... configure: We could not detect the boost libraries (version 1.65 or higher). If you have a staged boost library (still not installed) please specify $BOOST_ROOTin your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation. configure: error: Could not find Boost