• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ std::unordered_set类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中std::unordered_set的典型用法代码示例。如果您正苦于以下问题:C++ unordered_set类的具体用法?C++ unordered_set怎么用?C++ unordered_set使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了unordered_set类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: solve

box naive_icp::solve(box b, contractor & ctc, SMTConfig & config) {
    thread_local static std::unordered_set<std::shared_ptr<constraint>> used_constraints;
    used_constraints.clear();
    thread_local static vector<box> solns;
    thread_local static vector<box> box_stack;
    solns.clear();
    box_stack.clear();
    box_stack.push_back(b);
    do {
        DREAL_LOG_INFO << "naive_icp::solve - loop"
                       << "\t" << "box stack Size = " << box_stack.size();
        b = box_stack.back();
        box_stack.pop_back();
        try {
            ctc.prune(b, config);
            auto this_used_constraints = ctc.used_constraints();
            used_constraints.insert(this_used_constraints.begin(), this_used_constraints.end());
            if (config.nra_use_stat) { config.nra_stat.increase_prune(); }
        } catch (contractor_exception & e) {
            // Do nothing
        }
        if (!b.is_empty()) {
            tuple<int, box, box> splits = b.bisect(config.nra_precision);
            if (config.nra_use_stat) { config.nra_stat.increase_branch(); }
            int const i = get<0>(splits);
            if (i >= 0) {
                box const & first  = get<1>(splits);
                box const & second = get<2>(splits);
                assert(first.get_idx_last_branched() == i);
                assert(second.get_idx_last_branched() == i);
                if (second.is_bisectable()) {
                    box_stack.push_back(second);
                    box_stack.push_back(first);
                } else {
                    box_stack.push_back(first);
                    box_stack.push_back(second);
                }
                if (config.nra_proof) {
                    config.nra_proof_out << "[branched on "
                                         << b.get_name(i)
                                         << "]" << endl;
                }
            } else {
                config.nra_found_soln++;
                if (config.nra_multiple_soln > 1) {
                    // If --multiple_soln is used
                    output_solution(b, config, config.nra_found_soln);
                }
                if (config.nra_found_soln >= config.nra_multiple_soln) {
                    break;
                }
                solns.push_back(b);
            }
        }
    } while (box_stack.size() > 0);
    ctc.set_used_constraints(used_constraints);
    if (config.nra_multiple_soln > 1 && solns.size() > 0) {
        return solns.back();
    } else {
        assert(!b.is_empty() || box_stack.size() == 0);
        return b;
    }
}
开发者ID:sunqxj,项目名称:dreal3,代码行数:63,代码来源:icp.cpp


示例2:

void ndt::typevar_type::get_vars(std::unordered_set<std::string> &vars) const
{
  vars.insert(m_name.str());
}
开发者ID:Laeeth,项目名称:libdynd,代码行数:4,代码来源:typevar_type.cpp


示例3: index_object

void concept_indexer::index_object(object& o, model& m,
    std::unordered_set<qname>& processed_qnames) {
    BOOST_LOG_SEV(lg, debug) << "Indexing object: "
                             << string_converter::convert(o.name());

    if (processed_qnames.find(o.name()) != processed_qnames.end()) {
        BOOST_LOG_SEV(lg, debug) << "Object already processed.";
        return;
    }

    const auto i(o.relationships().find(relationship_types::modeled_concepts));
    if (i == o.relationships().end() || i->second.empty()) {
        processed_qnames.insert(o.name());
        BOOST_LOG_SEV(lg, debug) << "Object models no concepts.";
        return;
    }

    std::list<qname> expanded_refines;
    for (auto& qn : i->second) {
        auto& c(find_concept(qn, m));
        expanded_refines.push_back(qn);
        expanded_refines.insert(expanded_refines.end(),
            c.refines().begin(), c.refines().end());
    }
    remove_duplicates(expanded_refines);

    if (!o.is_child()) {
        i->second = expanded_refines;
        BOOST_LOG_SEV(lg, debug) << "Object has no parents, using reduced set.";
        return;
    }

    std::set<qname> our_concepts;
    our_concepts.insert(expanded_refines.begin(), expanded_refines.end());

    std::set<qname> their_concepts;
    for (const auto& qn : find_relationships(relationship_types::parents, o)) {
        auto& parent(find_object(qn, m));
        index_object(parent, m, processed_qnames);

        auto& pr(parent.relationships());
        const auto j(pr.find(relationship_types::modeled_concepts));
        if (j == pr.end() || j->second.empty())
            continue;

        their_concepts.insert(j->second.begin(), j->second.end());
    }

    /* we want to only model concepts which have not yet been modeled
     * by any of our parents.
     */
    std::set<qname> result;
    std::set_difference(our_concepts.begin(), our_concepts.end(),
        their_concepts.begin(), their_concepts.end(),
        std::inserter(result, result.end()));

    /* reinsert all of the modeled concepts which are part of the set
     * difference. we do this instead of just using the set difference
     * directly to preserve order.
     */
    BOOST_LOG_SEV(lg, debug) << "Object has parents, computing set difference.";
    i->second.clear();
    for (const auto& qn : expanded_refines) {
        if (result.find(qn) != result.end())
            i->second.push_back(qn);
    }

    BOOST_LOG_SEV(lg, debug) << "Finished indexing object.";
}
开发者ID:pgannon,项目名称:dogen,代码行数:69,代码来源:concept_indexer.cpp


示例4: parse

  static std::unique_ptr<QueryExpr>
  parse(w_query*, const json_ref& term, CaseSensitivity caseSensitive) {
    const char *pattern = nullptr, *scope = "basename";
    const char *which =
        caseSensitive == CaseSensitivity::CaseInSensitive ? "iname" : "name";
    std::unordered_set<w_string> set;

    if (!term.isArray()) {
      throw QueryParseError("Expected array for '", which, "' term");
    }

    if (json_array_size(term) > 3) {
      throw QueryParseError(
          "Invalid number of arguments for '", which, "' term");
    }

    if (json_array_size(term) == 3) {
      const auto& jscope = term.at(2);
      if (!jscope.isString()) {
        throw QueryParseError("Argument 3 to '", which, "' must be a string");
      }

      scope = json_string_value(jscope);

      if (strcmp(scope, "basename") && strcmp(scope, "wholename")) {
        throw QueryParseError(
            "Invalid scope '", scope, "' for ", which, " expression");
      }
    }

    const auto& name = term.at(1);

    if (name.isArray()) {
      uint32_t i;

      for (i = 0; i < json_array_size(name); i++) {
        if (!json_array_get(name, i).isString()) {
          throw QueryParseError(
              "Argument 2 to '",
              which,
              "' must be either a string or an array of string");
        }
      }

      set.reserve(json_array_size(name));
      for (i = 0; i < json_array_size(name); i++) {
        w_string element;
        const auto& jele = name.at(i);
        auto ele = json_to_w_string(jele);

        if (caseSensitive == CaseSensitivity::CaseInSensitive) {
          element = ele.piece().asLowerCase(ele.type()).normalizeSeparators();
        } else {
          element = ele.normalizeSeparators();
        }

        set.insert(element);
      }

    } else if (name.isString()) {
      pattern = json_string_value(name);
    } else {
      throw QueryParseError(
          "Argument 2 to '",
          which,
          "' must be either a string or an array of string");
    }

    auto data = new NameExpr(std::move(set), caseSensitive,
                             !strcmp(scope, "wholename"));

    if (pattern) {
      data->name = json_to_w_string(name).normalizeSeparators();
    }

    return std::unique_ptr<QueryExpr>(data);
  }
开发者ID:facebook,项目名称:watchman,代码行数:77,代码来源:name.cpp


示例5: main

int main(int argc, char* argv[])
{
	if (MPI_Init(&argc, &argv) != MPI_SUCCESS) {
		cerr << "Coudln't initialize MPI." << endl;
		abort();
	}

	MPI_Comm comm = MPI_COMM_WORLD;

	int rank = 0, comm_size = 0;
	MPI_Comm_rank(comm, &rank);
	MPI_Comm_size(comm, &comm_size);

	float zoltan_version;
	if (Zoltan_Initialize(argc, argv, &zoltan_version) != ZOLTAN_OK) {
	    cout << "Zoltan_Initialize failed" << endl;
	    abort();
	}

	Dccrg<std::array<int, 2>> grid;

	const std::array<uint64_t, 3> grid_length = {{18, 18, 1}};
	grid
		.set_initial_length(grid_length)
		.set_neighborhood_length(2)
		.set_maximum_refinement_level(0)
		.set_periodic(true, true, true)
		.set_load_balancing_method("RANDOM")
		.initialize(comm);

	/*
	Use a neighborhood like this in the z plane:
	O.O.O
	.....
	O.X.O
	.....
	O.O.O
	and play 4 interlaced games simultaneously.
	*/
	typedef dccrg::Types<3>::neighborhood_item_t neigh_t;
	const std::vector<neigh_t> neighborhood{
		{-2, -2, 0},
		{-2,  0, 0},
		{-2,  2, 0},
		{ 0, -2, 0},
		{ 0,  2, 0},
		{ 2, -2, 0},
		{ 2,  0, 0},
		{ 2,  2, 0}
	};

	const int neighborhood_id = 1;
	if (!grid.add_neighborhood(neighborhood_id, neighborhood)) {
		std::cerr << __FILE__ << ":" << __LINE__
			<< " Couldn't set neighborhood"
			<< std::endl;
		abort();
	}

	// initial condition
	const std::unordered_set<uint64_t> live_cells = get_live_cells(grid_length[0], 0);
	for (const uint64_t cell: live_cells) {
		auto* const cell_data = grid[cell];
		if (cell_data != nullptr) {
			(*cell_data)[0] = 1;
		}
	}

	// every process outputs the game state into its own file
	ostringstream basename, suffix(".vtk");
	basename << "tests/user_neighborhood/general_neighborhood_" << rank << "_";
	ofstream outfile, visit_file;

	// visualize the game with visit -o game_of_life_test.visit
	if (rank == 0) {
		visit_file.open("tests/user_neighborhood/general_neighborhood.visit");
		visit_file << "!NBLOCKS " << comm_size << endl;
	}

	#define TIME_STEPS 36
	for (int step = 0; step < TIME_STEPS; step++) {

		grid.balance_load();
		grid.update_copies_of_remote_neighbors(neighborhood_id);

		// check that the result is correct
		if (step % 4 == 0) {
			const std::unordered_set<uint64_t> live_cells = get_live_cells(grid_length[0], step);
			for (const auto& cell: grid.local_cells(neighborhood_id)) {
				if ((*cell.data)[0] == 0) {
					if (live_cells.count(cell.id) > 0) {
						std::cerr << __FILE__ << ":" << __LINE__
							<< " Cell " << cell.id
							<< " shouldn't be alive on step " << step
							<< endl;
						abort();
					}
				} else {
					if (live_cells.count(cell.id) == 0) {
						std::cerr << __FILE__ << ":" << __LINE__
//.........这里部分代码省略.........
开发者ID:fmihpc,项目名称:dccrg,代码行数:101,代码来源:game_of_life.cpp


示例6: connect_face_to_chunks

void mesh::connect_face_to_chunks(
    int f, 
    std::unordered_set<int> & to_add, 
    float step_distance, 
    std::unordered_set<int> & chunk
) {
    using namespace std;

    // If this polygon is surrounded by only polygons in the same chunk skip it
    bool surrounded = true;
    for (int n : neighbouring_triangles[f])
        surrounded &= !(chunk.count(n) == 0);

    if (surrounded)
        return;

    // Dijkstras
    unordered_map<int, float> dist;
    unordered_map<int, int> prev;
    priority_queue<S> pq;

    pq.push(S(f, 0.0f));

    while(!pq.empty()) {
        S min = pq.top();
        pq.pop();

        for (int n : neighbouring_triangles[min.face]) {
            S alt(n, distance(f, n));
            
            // Cuttoffs
            // Max step distance is exceeded
            if (alt.dist > step_distance)
                continue;

            if (dist.count(alt.face) == 0) {
                dist.emplace(alt.face, alt.dist);
                prev.emplace(alt.face, min.face);

                pq.push(alt);
            }
            else if (alt.dist < dist[alt.face]) {
                dist.emplace(alt.face, alt.dist);
                prev.emplace(alt.face, min.face);

                pq.push(alt);
            }
        }
    }

    for(auto kv : prev) {
        // If the polygon is walkable AND not in the same chunk as the starting point
        // if ((walkable_faces.count(kv.first) > 0) and chunk.count(kv.first) == 0) {
        if (walkable_faces.count(kv.first) > 0) {
            int curr = kv.first;

            while (curr != f){
                to_add.insert(prev[curr]);

                if (prev.count(curr) > 0)
                    curr = prev[curr];
            }
        }
    }
}
开发者ID:lzbotha,项目名称:hons-project,代码行数:65,代码来源:mesh.cpp


示例7: checkEntry

bool checkEntry(const InputMethodEntry &entry, const std::unordered_set<std::string> &inputMethods) {
    return (entry.name().empty() || entry.uniqueName().empty() || entry.addon().empty() ||
            inputMethods.count(entry.addon()) == 0)
               ? false
               : true;
}
开发者ID:fcitx,项目名称:fcitx5,代码行数:6,代码来源:inputmethodmanager.cpp


示例8: insert_data

 static void insert_data(const T& data, std::unordered_set<T> &value)
 {
     value.insert(value.rbegin() , data);
 }
开发者ID:kylemanna,项目名称:jsonpack,代码行数:4,代码来源:sequences.hpp


示例9: setValues

void KeyMultiValueTagFilter::setValues(const std::unordered_set<std::string> & values)
{
	setValues(values.cbegin(), values.cend());
}
开发者ID:inphos42,项目名称:osmpbf,代码行数:4,代码来源:filter.cpp


示例10: clearErrors


//.........这里部分代码省略.........
int libxml_streams_IO_write(void* context, const char* buffer, int len) {
  ITRACE(1, "libxml_IO_write({}, {}, {})\n", context, (void*)buffer, len);
  Trace::Indent _i;

  auto stream = getStream(context);
  int64_t ret = stream->write(String(buffer, len, CopyString));
  return (ret < INT_MAX) ? ret : -1;
}

int libxml_streams_IO_close(void* context) {
  ITRACE(1, "libxml_IO_close({}), sweeping={}\n",
         context, MemoryManager::sweeping());
  Trace::Indent _i;

  if (MemoryManager::sweeping()) {
    // Stream wrappers close themselves on sweep, so there's nothing to do here
    return 0;
  }

  return forgetStream(context) ? 0 : -1;
}

int libxml_streams_IO_nop_close(void* context) {
  return 0;
}

static xmlExternalEntityLoader s_default_entity_loader = nullptr;

/*
 * A whitelist of protocols allowed to be use in xml external entities. Note
 * that accesses to this set are not synchronized, so it must not be modified
 * after module initialization.
 */
static std::unordered_set<
  const StringData*,
  string_data_hash,
  string_data_isame
> s_ext_entity_whitelist;

static bool allow_ext_entity_protocol(const String& protocol) {
  return s_ext_entity_whitelist.count(protocol.get());
}

static xmlParserInputPtr libxml_ext_entity_loader(const char *url,
                                                  const char *id,
                                                  xmlParserCtxtPtr context) {
  ITRACE(1, "libxml_ext_entity_loader({}, {}, {})\n",
         url, id, (void*)context);
  Trace::Indent _i;

  auto protocol = Stream::getWrapperProtocol(url);
  if (!allow_ext_entity_protocol(protocol)) {
    raise_warning("Protocol '%s' for external XML entity '%s' is disabled for"
                  " security reasons. This may be changed using the"
                  " hhvm.libxml.ext_entity_whitelist ini setting.",
                  protocol.c_str(), url);
    return nullptr;
  }

  return s_default_entity_loader(url, id, context);
}

static xmlParserInputBufferPtr
libxml_create_input_buffer(const char* URI, xmlCharEncoding enc) {
  ITRACE(1, "libxml_create_input_buffer({}, {})\n", URI, static_cast<int>(enc));
  Trace::Indent _i;
开发者ID:shantanusharma,项目名称:hhvm,代码行数:67,代码来源:ext_libxml.cpp


示例11: stealChunks

void TransactionContext::stealChunks(std::unordered_set<RevisionCacheChunk*>& target) {
  target.clear();
  _chunks.swap(target);
} 
开发者ID:triagens,项目名称:arangodb,代码行数:4,代码来源:TransactionContext.cpp


示例12: Compress

void GraphCompressor::Compress(const std::unordered_set<NodeID> &barrier_nodes,
                               const std::unordered_set<NodeID> &traffic_lights,
                               RestrictionMap &restriction_map,
                               util::NodeBasedDynamicGraph &graph,
                               CompressedEdgeContainer &geometry_compressor)
{
    const unsigned original_number_of_nodes = graph.GetNumberOfNodes();
    const unsigned original_number_of_edges = graph.GetNumberOfEdges();

    util::Percent progress(original_number_of_nodes);

    for (const NodeID node_v : util::irange(0u, original_number_of_nodes))
    {
        progress.PrintStatus(node_v);

        // only contract degree 2 vertices
        if (2 != graph.GetOutDegree(node_v))
        {
            continue;
        }

        // don't contract barrier node
        if (barrier_nodes.end() != barrier_nodes.find(node_v))
        {
            continue;
        }

        // check if v is a via node for a turn restriction, i.e. a 'directed' barrier node
        if (restriction_map.IsViaNode(node_v))
        {
            continue;
        }

        //    reverse_e2   forward_e2
        // u <---------- v -----------> w
        //    ----------> <-----------
        //    forward_e1   reverse_e1
        //
        // Will be compressed to:
        //
        //    reverse_e1
        // u <---------- w
        //    ---------->
        //    forward_e1
        //
        // If the edges are compatible.

        const bool reverse_edge_order = graph.GetEdgeData(graph.BeginEdges(node_v)).reversed;
        const EdgeID forward_e2 = graph.BeginEdges(node_v) + reverse_edge_order;
        BOOST_ASSERT(SPECIAL_EDGEID != forward_e2);
        BOOST_ASSERT(forward_e2 >= graph.BeginEdges(node_v) && forward_e2 < graph.EndEdges(node_v));
        const EdgeID reverse_e2 = graph.BeginEdges(node_v) + 1 - reverse_edge_order;
        BOOST_ASSERT(SPECIAL_EDGEID != reverse_e2);
        BOOST_ASSERT(reverse_e2 >= graph.BeginEdges(node_v) && reverse_e2 < graph.EndEdges(node_v));

        const EdgeData &fwd_edge_data2 = graph.GetEdgeData(forward_e2);
        const EdgeData &rev_edge_data2 = graph.GetEdgeData(reverse_e2);

        const NodeID node_w = graph.GetTarget(forward_e2);
        BOOST_ASSERT(SPECIAL_NODEID != node_w);
        BOOST_ASSERT(node_v != node_w);
        const NodeID node_u = graph.GetTarget(reverse_e2);
        BOOST_ASSERT(SPECIAL_NODEID != node_u);
        BOOST_ASSERT(node_u != node_v);

        const EdgeID forward_e1 = graph.FindEdge(node_u, node_v);
        BOOST_ASSERT(SPECIAL_EDGEID != forward_e1);
        BOOST_ASSERT(node_v == graph.GetTarget(forward_e1));
        const EdgeID reverse_e1 = graph.FindEdge(node_w, node_v);
        BOOST_ASSERT(SPECIAL_EDGEID != reverse_e1);
        BOOST_ASSERT(node_v == graph.GetTarget(reverse_e1));

        const EdgeData &fwd_edge_data1 = graph.GetEdgeData(forward_e1);
        const EdgeData &rev_edge_data1 = graph.GetEdgeData(reverse_e1);

        if (graph.FindEdgeInEitherDirection(node_u, node_w) != SPECIAL_EDGEID)
        {
            continue;
        }

        // this case can happen if two ways with different names overlap
        if (fwd_edge_data1.name_id != rev_edge_data1.name_id ||
            fwd_edge_data2.name_id != rev_edge_data2.name_id)
        {
            continue;
        }

        if (fwd_edge_data1.IsCompatibleTo(fwd_edge_data2) &&
            rev_edge_data1.IsCompatibleTo(rev_edge_data2))
        {
            BOOST_ASSERT(graph.GetEdgeData(forward_e1).name_id ==
                         graph.GetEdgeData(reverse_e1).name_id);
            BOOST_ASSERT(graph.GetEdgeData(forward_e2).name_id ==
                         graph.GetEdgeData(reverse_e2).name_id);

            // Do not compress edge if it crosses a traffic signal.
            // This can't be done in IsCompatibleTo, becase we only store the
            // traffic signals in the `traffic_lights` list, which EdgeData
            // doesn't have access to.
            const bool has_node_penalty = traffic_lights.find(node_v) != traffic_lights.end();
//.........这里部分代码省略.........
开发者ID:AlifArnado,项目名称:osrm-backend,代码行数:101,代码来源:graph_compressor.cpp


示例13: _assertion_is_explicit_nonnull_check

/* Calculate whether an assertion is a standard non-NULL check.
 * e.g. (x != NULL), (x), (x != NULL && …) or (x && …).
 *
 * Insert the ValueDecls of the variables being checked into the provided
 * unordered_set, and return the number of such insertions (this will be 0 if no
 * variables are non-NULL checked). The returned number may be an over-estimate
 * of the number of elements in the set, as it doesn’t account for
 * duplicates. */
static unsigned int
_assertion_is_explicit_nonnull_check (Expr& assertion_expr,
                                      const ASTContext& context,
                                      std::unordered_set<const ValueDecl*>& ret)
{
	DEBUG_EXPR (__func__ << ": ", assertion_expr);

	switch ((int) assertion_expr.getStmtClass ()) {
	case Expr::BinaryOperatorClass: {
		BinaryOperator& bin_expr =
			cast<BinaryOperator> (assertion_expr);
		BinaryOperatorKind opcode = bin_expr.getOpcode ();

		if (opcode == BinaryOperatorKind::BO_LAnd) {
			/* LHS && RHS */
			unsigned int lhs_count =
				AssertionExtracter::assertion_is_nonnull_check (*(bin_expr.getLHS ()), context, ret);
			unsigned int rhs_count =
				AssertionExtracter::assertion_is_nonnull_check (*(bin_expr.getRHS ()), context, ret);

			return lhs_count + rhs_count;
		} else if (opcode == BinaryOperatorKind::BO_LOr) {
			/* LHS || RHS */
			std::unordered_set<const ValueDecl*> lhs_vars, rhs_vars;

			unsigned int lhs_count =
				AssertionExtracter::assertion_is_nonnull_check (*(bin_expr.getLHS ()), context, lhs_vars);
			unsigned int rhs_count =
				AssertionExtracter::assertion_is_nonnull_check (*(bin_expr.getRHS ()), context, rhs_vars);

			std::set_intersection (lhs_vars.begin (),
			                       lhs_vars.end (),
			                       rhs_vars.begin (),
			                       rhs_vars.end (),
			                       std::inserter (ret, ret.end ()));

			return lhs_count + rhs_count;
		} else if (opcode == BinaryOperatorKind::BO_NE) {
			/* LHS != RHS */
			Expr* rhs = bin_expr.getRHS ();
			Expr::NullPointerConstantKind k =
				rhs->isNullPointerConstant (const_cast<ASTContext&> (context),
				                            Expr::NullPointerConstantValueDependence::NPC_ValueDependentIsNotNull);
			if (k != Expr::NullPointerConstantKind::NPCK_NotNull &&
			    bin_expr.getLHS ()->IgnoreParenCasts ()->getStmtClass () == Expr::DeclRefExprClass) {
				DEBUG ("Found non-NULL check.");
				ret.insert (cast<DeclRefExpr> (bin_expr.getLHS ()->IgnoreParenCasts ())->getDecl ());
				return 1;
			}

			/* Either not a comparison to NULL, or the expr being
			 * compared is not a DeclRefExpr. */
			return 0;
		}

		return 0;
	}
	case Expr::UnaryOperatorClass: {
		/* A unary operator. For the moment, assume this isn't a
		 * non-null check.
		 *
		 * FIXME: In the future, define a proper program transformation
		 * to check for non-null checks, since we could have expressions
		 * like:
		 *     !(my_var == NULL)
		 * or (more weirdly):
		 *     ~(my_var == NULL)
		 */
		return 0;
	}
	case Expr::ConditionalOperatorClass: {
		/* A conditional operator. For the moment, assume this isn’t a
		 * non-null check.
		 *
		 * FIXME: In the future, define a proper program transformation
		 * to check for non-null checks, since we could have expressions
		 * like:
		 *     (x == NULL) ? TRUE : FALSE
		 */
		return 0;
	}
	case Expr::CStyleCastExprClass:
	case Expr::ImplicitCastExprClass: {
		/* A (explicit or implicit) cast. This can either be:
		 *     (void*)0
		 * or
		 *     (bool)my_var */
		CastExpr& cast_expr = cast<CastExpr> (assertion_expr);
		Expr* sub_expr = cast_expr.getSubExpr ()->IgnoreParenCasts ();

		if (sub_expr->getStmtClass () == Expr::DeclRefExprClass) {
			DEBUG ("Found non-NULL check.");
//.........这里部分代码省略.........
开发者ID:pwithnall,项目名称:tartan,代码行数:101,代码来源:assertion-extracter.cpp


示例14: nextPossibles

    std::vector<std::string> nextPossibles(const std::string& s,
                                           std::unordered_set<std::string>& visited,
                                           std::unordered_set<std::string>& deadendSet)
    {
        std::vector<std::string> res;

        int a = s[0] - '0';
        int b = s[1] - '0';
        int c = s[2] - '0';
        int d = s[3] - '0';

        std::vector<int> aV = { a == 0 ? 9 : a - 1, a == 9 ? 0 : a + 1};
        std::vector<int> bV = { b == 0 ? 9 : b - 1, b == 9 ? 0 : b + 1};
        std::vector<int> cV = { c == 0 ? 9 : c - 1, c == 9 ? 0 : c + 1};
        std::vector<int> dV = { d == 0 ? 9 : d - 1, d == 9 ? 0 : d + 1};

        for(int i = 0; i < 2; ++i)
        {
            std::stringstream ss;
            ss<< aV[i] << b << c << d;
            const auto& s = ss.str();
            if(visited.find(s) == visited.end() && deadendSet.find(s) == deadendSet.end())
            {
                visited.insert(s);
                res.push_back(s);
            }
        }

        for(int i = 0; i < 2; ++i)
        {
            std::stringstream ss;
            ss<< a << bV[i] << c << d;
            const auto& s = ss.str();
            if(visited.find(s) == visited.end() && deadendSet.find(s) == deadendSet.end())
            {
                visited.insert(s);
                res.push_back(s);
            }
        }

        for(int i = 0; i < 2; ++i)
        {
            std::stringstream ss;
            ss<< a << b << cV[i] << d;
            const auto& s = ss.str();
            if(visited.find(s) == visited.end() && deadendSet.find(s) == deadendSet.end())
            {
                visited.insert(s);
                res.push_back(s);
            }
        }

        for(int i = 0; i < 2; ++i)
        {
            std::stringstream ss;
            ss<< a << b << c << dV[i];
            const auto& s = ss.str();
            if(visited.find(s) == visited.end() && deadendSet.find(s) == deadendSet.end())
            {
                visited.insert(s);
                res.push_back(s);
            }
        }

        return res;
    }
开发者ID:knightzf,项目名称:review,代码行数:66,代码来源:main.cpp


示例15: LOGW

/*!
 * \brief First pass of patching operation
 *
 * This performs the following operations:
 *
 * - Files needed by an AutoPatcher are extracted to the temporary directory.
 * - Otherwise, the file is copied directly to the output zip.
 */
bool ZipPatcher::pass1(const std::string &temporary_dir,
                       const std::unordered_set<std::string> &exclude)
{
    using namespace std::placeholders;

    void *h_in = MinizipUtils::ctx_get_zip_handle(m_z_input);
    void *h_out = MinizipUtils::ctx_get_zip_handle(m_z_output);

    int ret = mz_zip_goto_first_entry(h_in);
    if (ret != MZ_OK && ret != MZ_END_OF_LIST) {
        m_error = ErrorCode::ArchiveReadHeaderError;
        return false;
    }

    if (ret != MZ_END_OF_LIST) {
        do {
            if (m_cancelled) return false;

            mz_zip_file *file_info;

            ret = mz_zip_entry_get_info(h_in, &file_info);
            if (ret != MZ_OK) {
                m_error = ErrorCode::ArchiveReadHeaderError;
                return false;
            }

            std::string cur_file{file_info->filename, file_info->filename_size};

            update_files(++m_files, m_max_files);
            update_details(cur_file);

            // Skip files that should be patched and added in pass 2
            if (exclude.find(cur_file) != exclude.end()) {
                if (!MinizipUtils::extract_file(h_in, temporary_dir)) {
                    m_error = ErrorCode::ArchiveReadDataError;
                    return false;
                }
                continue;
            }

            // Rename the installer for mbtool
            if (cur_file == "META-INF/com/google/android/update-binary") {
                cur_file = "META-INF/com/google/android/update-binary.orig";
            }

            if (!MinizipUtils::copy_file_raw(h_in, h_out, cur_file,
                    std::bind(&ZipPatcher::la_progress_cb, this, _1))) {
                LOGW("minizip: Failed to copy raw data: %s", cur_file.c_str());
                m_error = ErrorCode::ArchiveWriteDataError;
                return false;
            }

            m_bytes += file_info->uncompressed_size;
        } while ((ret = mz_zip_goto_next_entry(h_in)) == MZ_OK);

        if (ret != MZ_END_OF_LIST) {
            m_error = ErrorCode::ArchiveReadHeaderError;
            return false;
        }
    }

    if (m_cancelled) return false;

    return true;
}
开发者ID:chenxiaolong,项目名称:DualBootPatcher,代码行数:73,代码来源:zippatcher.cpp


示例16: parse_goals

std::pair<uint, std::pair<goals, goals>> parse_goals(
    parser& p,
    std::vector<warning>& warnings_list,
    const std::unordered_set<char>& declared_pieces,
    const board& declared_board)throw(goals_parse_error,parse_error){
    uint turns_limit;
    goals uppercase_player_goals;
    goals lowercase_player_goals;
    if(!p.expect_string("<GOALS>"))
        throw parse_error(p.get_line_number(), p.get_char_in_line_number(), "Goals segment must begin with \'<GOALS>\' string");
    p.expect_whitespace();
    parser_result<int> turns_limit_result = p.expect_int();
    if(!turns_limit_result)
        throw goals_parse_error(turns_limit_result.info.line_number, turns_limit_result.info.char_number, turns_limit_result.info.human_readable_info.c_str());
    if(turns_limit_result.result < 1)
        throw goals_parse_error(p.get_line_number(), p.get_char_in_line_number(), "Turns limit must be positive");
    turns_limit = turns_limit_result.result;
    p.expect_whitespace();
    if(p.expect_plain_char()!='&')
        throw goals_parse_error(p.get_line_number(), p.get_char_in_line_number(), "Turns limit must be terminated with \'&\'");
    p.expect_whitespace();
    char next_char = p.expect_plain_char();
    bool ignore;
    while(next_char == '@' || next_char == '#'){
        ignore = false;
        if(next_char == '@'){
            next_char = p.expect_plain_char();
            bool uppercase_player;
            if(isupper(next_char))
                uppercase_player = true;
            else if(islower(next_char)){
                uppercase_player = false;
                next_char = toupper(next_char);
            }
            else
                throw goals_parse_error(p.get_line_number(), p.get_char_in_line_number(), "Expected letter after \'@\'");
            if(!declared_pieces.count(next_char)){
                ignore = true;
                warnings_list.push_back(warning(p.get_line_number(), p.get_char_in_line_number(), "Undeclared piece (piece doesn't appear in the previous board declaration)"));
            }
            char piece_symbol = next_char;
            do{
                p.expect_whitespace();
                parser_result<int> x_result = p.expect_int();
                if(!x_result)
                    throw goals_parse_error(x_result.info.line_number, x_result.info.char_number, x_result.info.human_readable_info.c_str());
                if(x_result.result < 0)
                    throw goals_parse_error(p.get_line_number(), p.get_char_in_line_number(), "x coordinate must be non-negative");
                if(!p.expect_whitespace())
                    throw goals_parse_error(p.get_line_number(), p.get_char_in_line_number(), "Expected whitespace after x coordinate");
                parser_result<int> y_result = p.expect_int();
                if(!y_result)
                    throw goals_parse_error(y_result.info.line_number, y_result.info.char_number, y_result.info.human_readable_info.c_str());
                if(y_result.result < 0)
                    throw goals_parse_error(p.get_line_number(), p.get_char_in_line_number(), "y coordinate must be non-negative");
                if(!declared_board.inside(x_result.result, y_result.result)){
                    ignore = true;
                    warnings_list.push_back(warning(p.get_line_number(), p.get_char_in_line_number(), "Given point is outside the board"));
                }
                if(!ignore){
                    if(uppercase_player)
                        uppercase_player_goals.add_piece_placement_goal(piece_symbol, x_result.result, y_result.result);
                    else
                        lowercase_player_goals.add_piece_placement_goal(piece_symbol, x_result.result, y_result.result);
                }
                p.expect_whitespace();
                next_char = p.expect_plain_char();
                if(next_char != ',' && next_char != '&')
                    throw goals_parse_error(p.get_line_number(), p.get_char_in_line_number(), "Expected \',\' or \'&\'");
            }while(next_char != '&');
        }
        else{
            next_char = p.expect_plain_char();
            bool uppercase_player;
            if(isupper(next_char))
                uppercase_player = false;
            else if(islower(next_char)){
                uppercase_player = true;
                next_char = toupper(next_char);
            }
            else
                throw goals_parse_error(p.get_line_number(), p.get_char_in_line_number(), "Expected letter after \'#\'");
            if(!declared_pieces.count(next_char)){
                ignore = true;
                warnings_list.push_back(warning(p.get_line_number(), p.get_char_in_line_number(), "Undeclared piece (piece doesn't appear in the previous board declaration)"));
            }
            p.expect_whitespace();
            parser_result<int> number_of_pieces_result = p.expect_int();
            if(!number_of_pieces_result)
                throw goals_parse_error(number_of_pieces_result.info.line_number, number_of_pieces_result.info.char_number, number_of_pieces_result.info.human_readable_info.c_str());
            if(number_of_pieces_result.result < 0)
                throw goals_parse_error(p.get_line_number(), p.get_char_in_line_number(), "Number of piece captures must be non negative");
            if(!ignore){
                if(uppercase_player)
                    uppercase_player_goals.add_piece_capture_goal(next_char, number_of_pieces_result.result);
                else
                    lowercase_player_goals.add_piece_capture_goal(next_char, number_of_pieces_result.result);
            }
            p.expect_whitespace();
            if(p.expect_plain_char()!='&')
//.........这里部分代码省略.........
开发者ID:uicus,项目名称:sbg2gdl,代码行数:101,代码来源:goals.cpp


示例17: elementParserName

namespace citygml {


    // The nodes that are valid Polygon Objects
    std::unordered_set<int> typeIDSet;
    bool typeIDSetInitialized = false;
    std::mutex polygonElementParser_initializedTypeIDMutex;

    PolygonElementParser::PolygonElementParser(CityGMLDocumentParser& documentParser, CityGMLFactory& factory, std::shared_ptr<CityGMLLogger> logger, std::function<void(std::shared_ptr<Polygon>)> callback)
        : GMLObjectElementParser(documentParser, factory, logger)
    {
        m_callback = callback;
    }

    std::string PolygonElementParser::elementParserName() const
    {
        return "PolygonElementParser";
    }

    bool PolygonElementParser::handlesElement(const NodeType::XMLNode& node) const
    {
        if (!typeIDSetInitialized) {
            std::lock_guard<std::mutex> lock(polygonElementParser_initializedTypeIDMutex);

            if(!typeIDSetInitialized) {
                typeIDSet.insert(NodeType::GML_TriangleNode.typeID());
                typeIDSet.insert(NodeType::GML_RectangleNode.typeID());
                typeIDSet.insert(NodeType::GML_PolygonNode.typeID());
                typeIDSet.insert(NodeType::GML_PolygonPatchNode.typeID());
                typeIDSetInitialized = true;
            }
        }

        return typeIDSet.count(node.typeID()) > 0;
    }

    bool PolygonElementParser::parseElementStartTag(const NodeType::XMLNode& node, Attributes& attributes)
    {

        if (!handlesElement(node)) {
            CITYGML_LOG_ERROR(m_logger, "Expected start tag of PolygonObject but got <" << node.name() << "> at " << getDocumentLocation());
            throw std::runtime_error("Unexpected start tag found.");
        }

        m_model = m_factory.createPolygon(attributes.getCityGMLIDAttribute());
        return true;

    }

    bool PolygonElementParser::parseElementEndTag(const NodeType::XMLNode&, const std::string&)
    {
        m_callback(m_model);
        return true;
    }



    bool PolygonElementParser::parseChildElementStartTag(const NodeType::XMLNode& node, Attributes& attributes)
    {
        if (m_model == nullptr) {
            throw std::runtime_error("PolygonElementParser::parseChildElementStartTag called before PolygonElementParser::parseElementStartTag");
        }

        if (node == NodeType::GML_InteriorNode) {

            parseRingElement(true);
            return true;
        } else if (node == NodeType::GML_ExteriorNode) {

            parseRingElement(false);
            return true;
        }

        return GMLObjectElementParser::parseChildElementStartTag(node, attributes);
    }

    bool PolygonElementParser::parseChildElementEndTag(const NodeType::XMLNode& node, const std::string& characters)
    {

        if (m_model == nullptr) {
            throw std::runtime_error("PolygonElementParser::parseChildElementEndTag called before PolygonElementParser::parseElementStartTag");
        }

        if (node == NodeType::GML_InteriorNode || node == NodeType::GML_ExteriorNode) {

            return true;
        }

        return GMLObjectElementParser::parseChildElementEndTag(node, characters);

    }

    Object* PolygonElementParser::getObject()
    {
        return m_model.get();
    }

    void PolygonElementParser::parseRingElement(bool interior)
    {
        setParserForNextElement(new LinearRingElementParser(m_documentParser, m_factory, m_logger, interior, [this](LinearRing* ring){
//.........这里部分代码省略.........
开发者ID:j-o,项目名称:libcitygml,代码行数:101,代码来源:polygonelementparser.cpp


示例18: insert

 void insert(const Reg& reg){
     registers.insert(reg);
 }
开发者ID:shenyanjun,项目名称:eddic,代码行数:3,代码来源:LiveRegistersProblem.hpp


示例19: erase


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ std::valarray类代码示例发布时间:2022-05-31
下一篇:
C++ std::unordered_multimap类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap