本文整理汇总了C++中set_type::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ set_type::begin方法的具体用法?C++ set_type::begin怎么用?C++ set_type::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类set_type
的用法示例。
在下文中一共展示了set_type::begin方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
inline Observer& Observer::operator=(const Observer& o) {
iterator i;
for (i=observables_.begin(); i!=observables_.end(); ++i)
(*i)->unregisterObserver(this);
observables_ = o.observables_;
for (i=observables_.begin(); i!=observables_.end(); ++i)
(*i)->registerObserver(this);
return *this;
}
示例2: enableUpdates
inline void ObservableSettings::enableUpdates() {
boost::lock_guard<boost::mutex> lock(mutex_);
// if there are outstanding deferred updates, do the notification
updatesType_ = UpdatesEnabled;
if (deferredObservers_.size()) {
bool successful = true;
std::string errMsg;
for (iterator i=deferredObservers_.begin();
i!=deferredObservers_.end(); ++i) {
try {
const ext::shared_ptr<Observer::Proxy> proxy = i->lock();
if (proxy)
proxy->update();
} catch (std::exception& e) {
successful = false;
errMsg = e.what();
} catch (...) {
successful = false;
}
}
deferredObservers_.clear();
QL_ENSURE(successful,
"could not notify one or more observers: " << errMsg);
}
}
示例3: unregisterWithAll
inline void Observer::unregisterWithAll() {
boost::lock_guard<boost::recursive_mutex> lock(mutex_);
for (iterator i=observables_.begin(); i!=observables_.end(); ++i)
(*i)->unregisterObserver(proxy_);
observables_.clear();
}
示例4: lock
inline Observer::~Observer() {
boost::lock_guard<boost::recursive_mutex> lock(mutex_);
if (proxy_)
proxy_->deactivate();
for (iterator i=observables_.begin(); i!=observables_.end(); ++i)
(*i)->unregisterObserver(proxy_);
}
示例5: Observer
inline Observer::Observer(const Observer& o) {
proxy_.reset(new Proxy(this));
{
boost::lock_guard<boost::recursive_mutex> lock(o.mutex_);
observables_ = o.observables_;
}
for (iterator i=observables_.begin(); i!=observables_.end(); ++i)
(*i)->registerObserver(proxy_);
}
示例6: check_node
int check_node(int x, int y, int z, MapData * map, int destroy)
{
if (nodes == NULL) {
nodes = (Position*)malloc(sizeof(Position) * NODE_RESERVE_SIZE);
nodes_size = NODE_RESERVE_SIZE;
}
node_pos = 0;
push_back_node(x, y, z);
while (node_pos > 0) {
if (node_pos >= nodes_size - 6) {
nodes_size += NODE_RESERVE_SIZE;
nodes = (Position*)realloc((void*)nodes,
sizeof(Position) * nodes_size);
}
const Position * current_node = pop_back_node();
z = current_node->z;
if (z >= 62) {
marked.clear();
return 1;
}
x = current_node->x;
y = current_node->y;
int i = get_pos(x, y, z);
// already visited?
pair<set_type<int>::iterator, bool> ret;
ret = marked.insert(i);
if (ret.second) {
add_node(x, y, z - 1, map);
add_node(x, y - 1, z, map);
add_node(x, y + 1, z, map);
add_node(x - 1, y, z, map);
add_node(x + 1, y, z, map);
add_node(x, y, z + 1, map);
}
}
// destroy the node's path!
if (destroy) {
for (set_type<int>::const_iterator iter = marked.begin();
iter != marked.end(); ++iter)
{
map->geometry[*iter] = 0;
map->colors.erase(*iter);
}
}
marked.clear();
return 0;
}
示例7: insert
//-----------------------------------------------------------------//
handle_type insert(const T& st) {
handle_type h;
if(erase_set_.empty()) {
h = static_cast<handle_type>(array_.size());
array_.push_back(st);
} else {
set_it it = erase_set_.begin();
h = *it;
array_[h] = st;
erase_set_.erase(it);
}
return h;
}
示例8: create
//-----------------------------------------------------------------//
handle_type create() {
handle_type h;
if(erase_set_.empty()) {
if(current_ < limit_) {
h = current_;
++current_;
} else {
current_ = limit_ - 1;
h = 0;
}
} else {
set_it it = erase_set_.begin();
h = *it;
erase_set_.erase(it);
}
return h;
}
示例9: powerset
powerset_type powerset(set_type const& set)
{
typedef set_type::const_iterator set_iter;
typedef std::vector<set_iter> vec;
typedef vec::iterator vec_iter;
struct local
{
static int dereference(set_iter v) { return *v; }
};
powerset_type result;
vec elements;
do
{
set_type tmp;
std::transform(elements.begin(), elements.end(),
std::inserter(tmp, tmp.end()),
local::dereference);
result.insert(tmp);
if (!elements.empty() && ++elements.back() == set.end())
{
elements.pop_back();
}
else
{
set_iter iter;
if (elements.empty())
{
iter = set.begin();
}
else
{
iter = elements.back();
++iter;
}
for (; iter != set.end(); ++iter)
{
elements.push_back(iter);
}
}
} while (!elements.empty());
return result;
}
示例10: begin
iterator begin () const {
return m_set.begin ();
}
示例11: disjoint
bool disjoint(const set_type& a, const set_type& b) {
counting_output_iterator out;
return std::set_intersection(a.begin(), a.end(),
b.begin(), b.end(), out).count() == 0;
}
示例12: printSet
void printSet(set_type s) {
for (typename set_type::iterator p = s.begin(); p != s.end(); p++)
cout << *p << ' ';
cout << endl;
}