本文整理汇总了C++中boost::get方法的典型用法代码示例。如果您正苦于以下问题:C++ boost::get方法的具体用法?C++ boost::get怎么用?C++ boost::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost
的用法示例。
在下文中一共展示了boost::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get
friend inline value_type
get(const global_index_map& gim, const key_type& x)
{
using boost::get;
return (*gim.starting_index)[get(gim.global, x).first]
+ get(gim.index_map, x);
}
示例2: update
void update(MoveableValueRef v)
#endif
{
using boost::get;
size_type index = get(index_in_heap, v);
assert(index <= data.size());
preserve_heap_property_up(GRAEHL_D_ARY_FORWARD_REF(v), index, get(distance, v));
verify_heap();
}
示例3: push_or_update
void push_or_update(Value const& v)
#endif
{
using boost::get;
size_type index = get(index_in_heap, v);
if (contains(v, index))
preserve_heap_property_up(GRAEHL_D_ARY_FORWARD_REF(v), index, get(distance, v));
else
push(GRAEHL_D_ARY_FORWARD_REF(v));
}
示例4: second_best
distance_type second_best(distance_type null = 0) const {
if (data.size() < 2) return null;
int m = std::min(data.size(), Arity + 1);
distance_type b = get(distance, data[1]);
for (int i = 2; i < m; ++i) {
distance_type d = get(distance, data[i]);
if (better(d, b)) b = d;
}
return b;
}
示例5: swap
inline void swap(ArrayBinaryTreeNode x, ExternalData& edata ) {
using boost::get;
value_type tmp = x.value();
/*swap external data*/
edata[ get(id, tmp) ] = i;
edata[ get(id, value()) ] = x.i;
x.value() = value();
value() = tmp;
i = x.i;
}
示例6: get
virtual boost::any get(const any& key)
{
#if defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 95)
return boost::get(property_map, any_cast<key_type>(key));
#else
using boost::get;
return get(property_map, any_cast<key_type>(key));
#endif
}
示例7: tree_edge
void tree_edge(Edge e, const Graph& g) {
using boost::get;
m_decreased = relax(e, g, m_weight, m_predecessor, m_distance,
m_combine, m_compare);
if(m_decreased) {
m_vis.edge_relaxed(e, g);
put(m_cost, target(e, g),
m_combine(get(m_distance, target(e, g)),
m_h(target(e, g))));
} else
m_vis.edge_not_relaxed(e, g);
}
示例8: get_string
virtual std::string get_string(const any& key)
{
#if defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 95)
std::ostringstream out;
out << boost::get(property_map, any_cast<key_type>(key));
return out.str();
#else
using boost::get;
std::ostringstream out;
out << get(property_map, any_cast<key_type>(key));
return out.str();
#endif
}
示例9: black_target
void black_target(Edge e, const Graph& g) {
using boost::get;
m_decreased = relax(e, g, m_weight, m_predecessor, m_distance,
m_combine, m_compare);
if(m_decreased) {
m_vis.edge_relaxed(e, g);
put(m_cost, target(e, g),
m_combine(get(m_distance, target(e, g)),
m_h(target(e, g))));
m_Q.push(target(e, g));
put(m_color, target(e, g), Color::gray());
m_vis.black_target(e, g);
} else
m_vis.edge_not_relaxed(e, g);
}
示例10: push
void push(MoveableValueRef v)
#endif
{
size_type index = data.size();
if (index) {
#if GRAEHL_CPP11
data.emplace_back();
#else
data.push_back(Value()); // (hoping default construct is cheap, construct-copy inline)
#endif
preserve_heap_property_up(GRAEHL_D_ARY_FORWARD_REF(v), index, get(distance, v));
// we don't have to recopy v, or init index_in_heap
verify_heap();
} else {
put(index_in_heap, v, 0);
#if GRAEHL_CPP11
data.emplace_back(GRAEHL_D_ARY_FORWARD_REF(v));
#else
data.push_back(v); // (hoping default construct is cheap, construct-copy inline)
#endif
}
}
示例11: test_main
int test_main(int,char**) {
// build property maps using associative_property_map
std::map<std::string, int> string2int;
std::map<double,std::string> double2string;
boost::associative_property_map< std::map<std::string, int> >
int_map(string2int);
boost::associative_property_map< std::map<double, std::string> >
dbl_map(double2string);
// add key-value information
string2int["one"] = 1;
string2int["five"] = 5;
double2string[5.3] = "five point three";
double2string[3.14] = "pi";
// build and populate dynamic interface
boost::dynamic_properties properties;
properties.property("int",int_map);
properties.property("double",dbl_map);
using boost::get;
using boost::put;
using boost::type;
// Get tests
{
BOOST_CHECK(get("int",properties,std::string("one")) == "1");
#ifndef BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS
BOOST_CHECK(boost::get<int>("int",properties,std::string("one")) == 1);
#endif
BOOST_CHECK(get("int",properties,std::string("one"), type<int>()) == 1);
BOOST_CHECK(get("double",properties,5.3) == "five point three");
}
// Put tests
{
put("int",properties,std::string("five"),6);
BOOST_CHECK(get("int",properties,std::string("five")) == "6");
put("int",properties,std::string("five"),std::string("5"));
#ifndef BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS
BOOST_CHECK(get<int>("int",properties,std::string("five")) == 5);
#endif
BOOST_CHECK(get("int",properties,std::string("five"),type<int>()) == 5);
put("double",properties,3.14,std::string("3.14159"));
BOOST_CHECK(get("double",properties,3.14) == "3.14159");
put("double",properties,3.14,std::string("pi"));
#ifndef BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS
BOOST_CHECK(get<std::string>("double",properties,3.14) == "pi");
#endif
BOOST_CHECK(get("double",properties,3.14,type<std::string>()) == "pi");
}
// Nonexistent property
{
try {
get("nope",properties,3.14);
BOOST_ERROR("No exception thrown.");
} catch (boost::dynamic_get_failure&) { }
try {
put("nada",properties,3.14,std::string("3.14159"));
BOOST_ERROR("No exception thrown.");
} catch (boost::property_not_found&) { }
}
// Nonexistent property gets generated
{
boost::dynamic_properties props(&string2string_gen);
put("nada",props,std::string("3.14"),std::string("pi"));
BOOST_CHECK(get("nada",props,std::string("3.14")) == "pi");
}
return boost::exit_success;
}
示例12: colored_edges_test
bool colored_edges_test() {
std::cout << "colored_edges_test()" << std::endl;
typedef boost::property<alps::edge_type_t,unsigned int> edge_props;
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, boost::no_property, edge_props> graph_type;
typedef boost::graph_traits<graph_type>::edge_descriptor edge_descriptor;
typedef boost::property_map<graph_type,alps::edge_type_t>::type edge_color_map_type;
graph_type g(4);
{
edge_color_map_type edge_color = get(alps::edge_type_t(),g);
edge_descriptor e;
e = add_edge(0, 1, g).first;
edge_color[e] = 0;
e = add_edge(1, 2, g).first;
edge_color[e] = 0;
e = add_edge(2, 3, g).first;
edge_color[e] = 0;
e = add_edge(0, 3, g).first;
edge_color[e] = 0;
}
graph_type h(g);
{
edge_descriptor e = edge(2,3,h).first;
get(alps::edge_type_t(),h)[e] = 1;
}
graph_type i(g);
{
edge_descriptor e = edge(2,3,i).first;
get(alps::edge_type_t(),i)[e] = 2;
}
graph_type j(h);
{
edge_descriptor e = edge(2,3,j).first;
get(alps::edge_type_t(),j)[e] = 1;
}
graph_type k(g);
{
edge_color_map_type edge_color = get(alps::edge_type_t(),k);
edge_descriptor e;
e = edge( 0, 1, k).first;
edge_color[e] = 1;
e = edge( 1, 2, k).first;
edge_color[e] = 1;
e = edge( 2, 3, k).first;
edge_color[e] = 1;
e = edge( 0, 3, k).first;
edge_color[e] = 1;
}
alps::graph::graph_label<graph_type>::type label_g(get<1>(canonical_properties(g)));
alps::graph::graph_label<graph_type>::type label_h(get<1>(canonical_properties(h)));
alps::graph::graph_label<graph_type>::type label_i(get<1>(canonical_properties(i)));
alps::graph::graph_label<graph_type>::type label_j(get<1>(canonical_properties(j)));
alps::graph::graph_label<graph_type>::type label_k(get<1>(canonical_properties(k)));
std::cout<<label_g<<std::endl;
std::cout<<label_h<<std::endl;
std::cout<<label_i<<std::endl;
std::cout<<label_j<<std::endl;
std::cout<<label_k<<std::endl;
std::cout<<std::boolalpha<<(label_g == label_h)<<std::endl;
std::cout<<std::boolalpha<<(label_h == label_i)<<std::endl;
std::cout<<std::boolalpha<<(label_h == label_j)<<std::endl;
std::cout<<std::boolalpha<<(label_g == label_k)<<std::endl;
return true;
}
示例13: examine_edge
void examine_edge(Edge e, const Graph& g) {
if (m_compare(get(m_weight, e), m_zero))
BOOST_THROW_EXCEPTION(negative_edge());
m_vis.examine_edge(e, g);
}
示例14: main
int main() {
using boost::get;
using boost::put;
using alps::graph::canonical_properties;
typedef unsigned int lc_type;
typedef boost::property<alps::edge_type_t,alps::type_type> edge_props;
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS,boost::no_property,edge_props> graph_type;
typedef alps::graph_helper<>::vertex_iterator vertex_iterator;
typedef alps::graph_helper<>::edge_iterator edge_iterator;
alps::Parameters parm;
unsigned int side_length = 40;
std::ifstream in("../../lib/xml/lattices.xml");
parm["LATTICE"] = "coupled ladders";
parm["L"] = side_length;
parm["L"] = side_length;
alps::graph_helper<> lattice(in,parm);
graph_type lattice_graph(num_vertices(lattice.graph()));
boost::graph_traits<alps::graph_helper<>::graph_type>::edge_iterator it, et;
for(boost::tie(it, et) = edges(lattice.graph()); it != et; ++it)
{
boost::graph_traits<graph_type>::edge_descriptor e = add_edge(source(*it, lattice.graph()), target(*it, lattice.graph()), lattice_graph).first;
if(get(alps::edge_type_t(),lattice.graph(),*it) == 1)
put(alps::edge_type_t(), lattice_graph, e, 1);
else
put(alps::edge_type_t(), lattice_graph, e, 0);
}
std::vector<std::pair<graph_type,lc_type> > g;
boost::graph_traits<graph_type>::edge_descriptor e;
// edge color 0 ...
// edge color 1 ___
// 0...1
g.push_back(std::make_pair(graph_type(), 3));
e = add_edge(0, 1, g.back().first).first;
put(alps::edge_type_t(), g.back().first, e, 0);
// 0___1
g.push_back(std::make_pair(graph_type(), 1));
e = add_edge(0, 1, g.back().first).first;
put(alps::edge_type_t(), g.back().first, e, 1);
// 0...1
// | |
// 2...3
//
g.push_back(std::make_pair(graph_type(), 1));
e = add_edge(0, 1, g.back().first).first;
put(alps::edge_type_t(), g.back().first, e, 0);
e = add_edge(1, 3, g.back().first).first;
put(alps::edge_type_t(), g.back().first, e, 1);
e = add_edge(3, 2, g.back().first).first;
put(alps::edge_type_t(), g.back().first, e, 0);
e = add_edge(2, 0, g.back().first).first;
put(alps::edge_type_t(), g.back().first, e, 1);
//
// 0...1
// : :
// 2...3
//
g.push_back(std::make_pair(graph_type(), 1));
e = add_edge(0, 1, g.back().first).first;
put(alps::edge_type_t(), g.back().first, e, 0);
e = add_edge(1, 3, g.back().first).first;
put(alps::edge_type_t(), g.back().first, e, 0);
e = add_edge(3, 2, g.back().first).first;
put(alps::edge_type_t(), g.back().first, e, 0);
e = add_edge(2, 0, g.back().first).first;
put(alps::edge_type_t(), g.back().first, e, 0);
//
// 0...1
// . |
// 2___3
//
g.push_back(std::make_pair(graph_type(), 0));
e = add_edge(0, 1, g.back().first).first;
put(alps::edge_type_t(), g.back().first, e, 0);
e = add_edge(1, 3, g.back().first).first;
put(alps::edge_type_t(), g.back().first, e, 1);
e = add_edge(3, 2, g.back().first).first;
put(alps::edge_type_t(), g.back().first, e, 1);
e = add_edge(2, 0, g.back().first).first;
put(alps::edge_type_t(), g.back().first, e, 0);
//
// 1...0...2
//
g.push_back(std::make_pair(graph_type(),6));
e = add_edge(0, 1,g.back().first).first;
put(alps::edge_type_t(), g.back().first, e, 0);
//.........这里部分代码省略.........
示例15: best
distance_type best(distance_type null = 0) const { return empty() ? null : get(distance, data[0]); }