本文整理汇总了C++中std::unordered_set::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_set::empty方法的具体用法?C++ unordered_set::empty怎么用?C++ unordered_set::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::unordered_set
的用法示例。
在下文中一共展示了unordered_set::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doWalkFunction
void doWalkFunction(Function* func) {
Flat::verifyFlatness(func);
// Build the data-flow IR.
graph.build(func, getModule());
nodeUsers.build(graph);
// Propagate optimizations through the graph.
std::unordered_set<DataFlow::Node*> optimized; // which nodes we optimized
for (auto& node : graph.nodes) {
workLeft.insert(node.get()); // we should try to optimize each node
}
while (!workLeft.empty()) {
//std::cout << "\n\ndump before work iter\n";
//dump(graph, std::cout);
auto iter = workLeft.begin();
auto* node = *iter;
workLeft.erase(iter);
workOn(node);
}
// After updating the DataFlow IR, we can update the sets in
// the wasm.
// TODO: we also need phis, as a phi can flow directly into say
// a return or a call parameter.
for (auto* set : graph.sets) {
auto* node = graph.setNodeMap[set];
auto iter = optimized.find(node);
if (iter != optimized.end()) {
assert(node->isExpr()); // this is a set, where the node is defined
set->value = node->expr;
}
}
}
示例2: evaluate
EvaluateResult evaluate(struct w_query_ctx* ctx, FileResult* file) override {
if (!set.empty()) {
bool matched;
w_string str;
if (wholename) {
str = w_query_ctx_get_wholename(ctx);
if (caseSensitive == CaseSensitivity::CaseInSensitive) {
str = str.piece().asLowerCase();
}
} else {
str = caseSensitive == CaseSensitivity::CaseInSensitive
? file->baseName().asLowerCase()
: file->baseName().asWString();
}
matched = set.find(str) != set.end();
return matched;
}
w_string_piece str;
if (wholename) {
str = w_query_ctx_get_wholename(ctx);
} else {
str = file->baseName();
}
if (caseSensitive == CaseSensitivity::CaseInSensitive) {
return w_string_equal_caseless(str, name);
}
return str == name;
}
示例3: Settings
std::shared_ptr<Settings> Settings::create(
std::shared_ptr<SettingsStorageInterface> settingsStorage,
std::unordered_set<std::shared_ptr<GlobalSettingsObserverInterface>> globalSettingsObserver,
std::shared_ptr<registrationManager::CustomerDataManager> dataManager) {
if (!settingsStorage) {
ACSDK_ERROR(LX("createFailed").d("reason", "settingsStorageNullReference").d("return", "nullptr"));
return nullptr;
}
if (globalSettingsObserver.empty()) {
ACSDK_ERROR(LX("createFailed").d("reason", "emptysettingsGlobalObserver").d("return", "nullptr"));
return nullptr;
}
for (auto observer : globalSettingsObserver) {
if (!observer) {
ACSDK_ERROR(LX("createFailed").d("reason", "settingsGlobalObserverNullReference").d("return", "nullptr"));
return nullptr;
}
}
auto settingsObject = std::shared_ptr<Settings>(new Settings(settingsStorage, globalSettingsObserver, dataManager));
if (!settingsObject->initialize()) {
ACSDK_ERROR(LX("createFailed").d("reason", "Initialization error."));
return nullptr;
}
return settingsObject;
}
示例4: setup_api_sets
void pal::setup_api_sets(const std::unordered_set<pal::string_t>& api_sets)
{
if (api_sets.empty())
{
return;
}
pal::string_t path;
(void) getenv(_X("PATH"), &path);
// We need this ugly hack, as the PInvoked DLL's static dependencies can come from
// some other NATIVE_DLL_SEARCH_DIRECTORIES and not necessarily side by side. However,
// CoreCLR.dll loads PInvoke DLLs with LOAD_WITH_ALTERED_SEARCH_PATH. Note that this
// option cannot be combined with LOAD_LIBRARY_SEARCH_USER_DIRS, so the AddDllDirectory
// doesn't help much in telling CoreCLR where to load the PInvoke DLLs from.
// So we resort to modifying the PATH variable on our own hoping Windows loader will do the right thing.
for (const auto& as : api_sets)
{
// AddDllDirectory is still needed for Standalone App's CoreCLR load.
::AddDllDirectory(as.c_str());
// Path patch is needed for static dependencies of a PInvoked DLL load out of the nuget cache.
path.push_back(PATH_SEPARATOR);
path.append(as);
}
trace::verbose(_X("Setting PATH=%s"), path.c_str());
::SetEnvironmentVariableW(_X("PATH"), path.c_str());
}
示例5:
mod_manager::mod_manager()
{
// Insure obsolete_mod_list is initialized.
if( obsolete_mod_list.empty() && file_exist(FILENAMES["obsolete-mods"]) ) {
load_obsolete_mods(FILENAMES["obsolete-mods"]);
}
}
示例6: find_symbols
bool find_symbols(expression const e, std::function<bool(symbol)> const selector,
std::unordered_set<symbol,symbol::hash>& output)
{
if (selector(get_symbol(e)))
output.insert(get_symbol(e));
for (uint64_t i = 0ULL; i < num_parameters(e); ++i)
find_symbols(argument(e,i),selector,output);
return !output.empty();
}
示例7: perform
void editor_coordinates_gui::perform(
editor_setup& setup,
const vec2i screen_size,
const vec2i mouse_pos,
const std::unordered_set<entity_id>& all_selected
) {
using namespace augs::imgui;
auto coordinates = make_scoped_window(ImGuiWindowFlags_AlwaysAutoResize);
if (!coordinates) {
return;
}
const auto settings = setup.settings;
auto& v = setup.view();
if (const auto current_eye = setup.find_current_camera_eye()) {
const auto cone = camera_cone(*current_eye, screen_size);
const auto world_cursor_pos = cone.to_world_space(mouse_pos);
text("Grid size: %x/%x", v.grid.unit_pixels, settings.grid.render.get_maximum_unit());
text("Cursor: %x", world_cursor_pos);
text("View center: %x", vec2(current_eye->transform.pos).discard_fract());
text("Camera AABB: %x", cone.get_visible_world_rect_aabb());
{
auto zoom = current_eye->zoom * 100.f;
if (slider("Zoom: ", zoom, 1.f, 1000.f, "%.3f%%")) {
if (!v.panned_camera.has_value()) {
v.panned_camera = current_eye;
}
zoom = std::clamp(zoom, 1.f, 1000.f);
v.panned_camera->zoom = zoom / 100.f;
}
}
}
text("Rect select mode: %x", format_enum(v.rect_select_mode));
if (!all_selected.empty()) {
text("Selected %x entities", all_selected.size());
if (const auto aabb = setup.find_selection_aabb()) {
const auto size = aabb->get_size();
text("AABB: %x x %x pixels\ncenter: %x\nlt: %x\nrb: %x", size.x, size.y, aabb->get_center(), aabb->left_top(), aabb->right_bottom());
}
}
else {
text("No entity selected");
}
}
示例8: EraseFeatureFromInteraction
GMsg VectorBuffer::EraseFeatureFromInteraction(
const feature_ptr &src, const string &proj,
const std::unordered_set<long> &targets,
const std::unordered_set<long> &immunes)
{
GRect ext = MapnikUtils::Box2d2GRect(src->envelope());
unordered_map<long, feature_ptr> fs = GetFeaturesInRect(
proj, ext, _config_app().VIEW_VECTORBUFFER_SELECTION_MAX);
unordered_map<long, feature_ptr> edited_in_clipping;
unordered_set<long> removed_in_clipping;
for (unordered_map<long, feature_ptr>::const_iterator it = fs.begin();
it != fs.end(); it++)
{
feature_ptr f = it->second;
if (immunes.find(f->id()) != immunes.end()) continue;
if (!targets.empty() && targets.find(f->id()) == targets.end()) continue;
if (MapnikUtils::contains(
src, f, wkbPolygon, _book->GetGeomType(), proj, _layer->proj()))
{
removed_in_clipping.insert(it->first);
}
else if (MapnikUtils::intersects(
src, f, wkbPolygon, _book->GetGeomType(), proj, _layer->proj()))
{
feature_ptr clipped = MapnikUtils::difference(
f, src, _book->GetGeomType(), wkbPolygon, _layer->proj(), proj);
if (clipped != nullptr) {
edited_in_clipping.insert(pair<long, feature_ptr>(it->first, clipped));
}
}
}
unsigned int num = removed_in_clipping.size() + edited_in_clipping.size();
if (num == 0) return G_NOERR;
_undoStack->beginMacro(num == 1 ? "Erase feature" : "Erase features");
for (unordered_set<long>::const_iterator it = removed_in_clipping.begin();
it != removed_in_clipping.end(); it++)
{
_undoStack->push(new VBCommandDeleteFeature(this, *it));
}
for (unordered_map<long, feature_ptr>::const_iterator it = edited_in_clipping.begin();
it != edited_in_clipping.end(); it++)
{
long fid = it->first;
feature_ptr f = it->second;
Q_ASSERT(_deletedFeatures.find(fid) == _deletedFeatures.end());
f->put<value_unicode_string>(
_config_app().VIEW_VECTORBUFFER_FIELD_EDITED,
transcoder("utf-8").transcode("edited"));
_undoStack->push(new VBCommandEditFeature(this, fid, f));
}
_undoStack->endMacro();
return G_NOERR;
}
示例9:
//------------------------------------------------------------------------------
Entity * Scene::getTaggedEntity(const std::string & tag)
{
u32 tagIndex = m_tagManager.getTagIndex(tag);
if (tagIndex == TagManager::INVALID_INDEX)
return nullptr;
const std::unordered_set<Entity*> taggedEntities = m_tagManager.getObjectsByTag(tagIndex);
if (taggedEntities.empty())
return nullptr;
return *taggedEntities.begin();
}
示例10: codetester_module_cleanup
static bool codetester_module_cleanup(KviModule *)
{
while(!g_pCodeTesterWindowList.empty())
{
auto w = g_pCodeTesterWindowList.begin();
if (w == g_pCodeTesterWindowList.end())
break;
(*w)->close(); // deleted path!
}
return true;
}
示例11: global_initialize
virtual void global_initialize(m3bp::Task &task) override {
EXPECT_FALSE(m_global_initialized);
EXPECT_TRUE(m_thread_local_initialized.empty());
const auto num_iports = input_ports().size();
for(m3bp::identifier_type i = 0; i < num_iports; ++i){
const auto &iport = input_ports()[i];
if(iport.movement() == m3bp::Movement::BROADCAST){
m_broadcasted[i] = read_input(task.input(i));
}
}
m_global_initialized = true;
}
示例12: operator
void operator()(msgpack::object::with_zone& o, const std::unordered_set<T>& v) const {
o.type = msgpack::type::ARRAY;
if(v.empty()) {
o.via.array.ptr = nullptr;
o.via.array.size = 0;
} else {
uint32_t size = checked_get_container_size(v.size());
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
msgpack::object* const pend = p + size;
o.via.array.ptr = p;
o.via.array.size = size;
typename std::unordered_set<T>::const_iterator it(v.begin());
do {
*p = msgpack::object(*it, o.zone);
++p;
++it;
} while(p < pend);
}
}
示例13: wordBreak
bool wordBreak(std::string s, std::unordered_set<std::string> &dict) {
if (dict.empty())
return false;
int len = s.size(), max_len = dict.begin()->size(), min_len = max_len;
for (auto it = dict.begin(); it != dict.end(); ++it)
if (it->size() > max_len)
max_len = it->size();
else if (it->size() < min_len)
min_len = it->size();
std::vector<int> flag(len + 1);
flag[len] = 1;
for (int i = len - 1; i >= 0; --i)
for (int j = min_len; j <= std::min(max_len, len - i); ++j)
if (flag[i + j] && dict.find(s.substr(i, j)) != dict.end()) {
flag[i] = 1;
break;
}
return flag[0] == 1;
}
示例14:
virtual ~TestProcessorBase(){
EXPECT_FALSE(m_global_initialized);
EXPECT_TRUE(m_thread_local_initialized.empty());
}
示例15: links_module_can_unload
static bool links_module_can_unload(KviModule *)
{
return (g_pLinksWindowList.empty());
}