10225501448 李度 10225101546 陈胤遒 10215501422 高宇菲
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

34 líneas
667 B

#include "fielddb/field_db.h"
using namespace fielddb;
class ThreadSafeSet
{
private:
std::set<std::string> keys;
std::mutex setMutex;
public:
ThreadSafeSet(){}
void insert(std::string key){
std::lock_guard<std::mutex> lock(setMutex);
keys.insert(key);
}
void erase(std::string key){
std::lock_guard<std::mutex> lock(setMutex);
keys.erase(key);
}
void clear(){
std::lock_guard<std::mutex> lock(setMutex);
keys.clear();
}
size_t size(){
std::lock_guard<std::mutex> lock(setMutex);
return keys.size();
}
bool haveKey(std::string key){
return std::find(keys.begin(), keys.end(), key) != keys.end();
}
};