本文整理汇总了C++中std::deque::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ deque::empty方法的具体用法?C++ deque::empty怎么用?C++ deque::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::deque
的用法示例。
在下文中一共展示了deque::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_work
void do_work (CompletionCounter)
{
if (m_called_stop.load () == 1)
return;
// We don't have any work to do at this time
if (m_work.empty())
{
m_idle = true;
m_journal.trace << "Sleeping";
return;
}
if (m_work.front().names.empty())
m_work.pop_front();
std::string const name (m_work.front().names.back());
HandlerType handler (m_work.front().handler);
m_work.front().names.pop_back();
HostAndPort const hp (parseName(name));
if (hp.first.empty())
{
m_journal.error <<
"Unable to parse '" << name << "'";
m_io_service.post (m_strand.wrap (boost::bind (
&NameResolverImpl::do_work, this,
CompletionCounter(this))));
return;
}
boost::asio::ip::tcp::resolver::query query (
hp.first, hp.second);
m_resolver.async_resolve (query, boost::bind (
&NameResolverImpl::do_finish, this, name,
boost::asio::placeholders::error, handler,
boost::asio::placeholders::iterator,
CompletionCounter(this)));
}
示例2: operator
void operator()(clmdep_msgpack::object::with_zone& o, const std::deque<T, Alloc>& v) const {
o.type = clmdep_msgpack::type::ARRAY;
if(v.empty()) {
o.via.array.ptr = MSGPACK_NULLPTR;
o.via.array.size = 0;
} else {
uint32_t size = checked_get_container_size(v.size());
clmdep_msgpack::object* p = static_cast<clmdep_msgpack::object*>(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(clmdep_msgpack::object)));
clmdep_msgpack::object* const pend = p + size;
o.via.array.ptr = p;
o.via.array.size = size;
typename std::deque<T, Alloc>::const_iterator it(v.begin());
do {
*p = clmdep_msgpack::object(*it, o.zone);
++p;
++it;
} while(p < pend);
}
}
示例3: operator
void operator()(msgpack::object::with_zone& o, const std::deque<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::deque<T>::const_iterator it(v.begin());
do {
*p = msgpack::object(*it, o.zone);
++p;
++it;
} while(p < pend);
}
}
示例4: while
std::deque<tgt::ivec2> Flow2D::flowPosToSlicePos(std::deque<tgt::vec2>& fps,
const tgt::ivec2& sliceSize, const tgt::ivec2& offset) const
{
std::deque<tgt::ivec2> sps; // slice positions
while (fps.empty() == false) {
std::deque<tgt::vec2>::iterator it = fps.begin();
// no call to overloaded flowPosToViewportPos() for performance
//
tgt::vec2 aux(*it / static_cast<tgt::vec2>(dimensions_));
tgt::ivec2 sp(
(static_cast<int>(tgt::round(aux.x * sliceSize.x)) + offset.x) % sliceSize.x,
(static_cast<int>(tgt::round(aux.y * sliceSize.y)) + offset.y) % sliceSize.y);
sps.push_back(sp);
fps.erase(it);
}
return sps;
}
示例5: add
void InstallProviderSpecXml::add(
const SmartPtrCInstallProviderSpecDoc installProviderSpecDoc,
const SmartPtrCXmlElement thisXml) {
CAF_CM_STATIC_FUNC_VALIDATE("InstallProviderSpecXml", "add");
CAF_CM_ENTER {
CAF_CM_VALIDATE_SMARTPTR(installProviderSpecDoc);
CAF_CM_VALIDATE_SMARTPTR(thisXml);
const std::string clientIdVal =
BasePlatform::UuidToString(installProviderSpecDoc->getClientId());
CAF_CM_VALIDATE_STRING(clientIdVal);
thisXml->addAttribute("clientId", clientIdVal);
const std::string providerNamespaceVal = installProviderSpecDoc->getProviderNamespace();
CAF_CM_VALIDATE_STRING(providerNamespaceVal);
thisXml->addAttribute("providerNamespace", providerNamespaceVal);
const std::string providerNameVal = installProviderSpecDoc->getProviderName();
CAF_CM_VALIDATE_STRING(providerNameVal);
thisXml->addAttribute("providerName", providerNameVal);
const std::string providerVersionVal = installProviderSpecDoc->getProviderVersion();
CAF_CM_VALIDATE_STRING(providerVersionVal);
thisXml->addAttribute("providerVersion", providerVersionVal);
const std::deque<SmartPtrCMinPackageElemDoc> packageValVal =
installProviderSpecDoc->getPackageCollection();
CAF_CM_VALIDATE_STL(packageValVal);
if (! packageValVal.empty()) {
for (TConstIterator<std::deque<SmartPtrCMinPackageElemDoc> > packageValIter(packageValVal);
packageValIter; packageValIter++) {
const SmartPtrCXmlElement packageValXml =
thisXml->createAndAddElement("package");
MinPackageElemXml::add(*packageValIter, packageValXml);
}
}
thisXml->addAttribute("version", "1.0");
}
CAF_CM_EXIT;
}
示例6: has_focus
bool has_focus(const sdl_handler* hand, const SDL_Event* event)
{
if(event_contexts.empty()) {
return true;
}
if(hand->requires_event_focus(event) == false) {
return true;
}
const handler_list::iterator foc = event_contexts.back().focused_handler;
auto& handlers = event_contexts.back().handlers;
// If no-one has focus at the moment, this handler obviously wants
// focus, so give it to it.
if(foc == handlers.end()) {
focus_handler(hand);
return true;
}
sdl_handler* const foc_hand = *foc;
if(foc_hand == hand){
return true;
} else if(!foc_hand->requires_event_focus(event)) {
// If the currently focused handler doesn't need focus for this event
// allow the most recent interested handler to take care of it
for(auto i = handlers.rbegin(); i != handlers.rend(); ++i) {
sdl_handler* const thief_hand = *i;
if(thief_hand != foc_hand && thief_hand->requires_event_focus(event)) {
// Steal focus
focus_handler(thief_hand);
// Position the previously focused handler to allow stealing back
handlers.splice(handlers.end(), handlers, foc);
return thief_hand == hand;
}
}
}
return false;
}
示例7: priority_sort
/** sorts a priority list by filter*/
void priority_sort(std::string filter){
if(priority.size() == 1){
ready.push(priority.front());
priority.pop_front();
}
else{
//if priority is bigger than 1, then need to sort
int s = priority.size();
struct Qu t[s];
int i = 0;
while(!priority.empty()){
t[i] = priority.front();
++i;
priority.pop_front();
}
//sort in array, then add back to prioroity
int j;
for(j=0; j<s; ++j){
int k;
for(k=1; k<s; ++k){
if(filter.compare("priority") == 0){
if(t[j].priority>t[k].priority && j<k){
struct Qu u = t[j];
t[j] = t[k];
t[k] = u;
} }
else if(filter.compare("sjf") == 0){
if(t[j].cpu_burst>t[k].cpu_burst && j<k){
struct Qu u = t[j];
t[j] = t[k];
t[k] = u;
}
else if(t[j].cpu_burst==t[k].cpu_burst && j<k){
if(t[j].arrival_time > t[k].arrival_time){
struct Qu u = t[j];
t[j] = t[k];
t[k] = u;
} } }
} }
for(j=0; j<s; ++j) ready.push(t[j]);
}
}
示例8: coalesce_messages
// coalesce recent like messages
bool coalesce_messages(std::string const &msg, game_message_type const type) {
if (messages.empty()) {
return false;
}
auto &last_msg = messages.back();
if (last_msg.turn() + 3 < calendar::turn.get_turn()) {
return false;
}
if (type != last_msg.type || msg != last_msg.message) {
return false;
}
last_msg.count++;
last_msg.time = calendar::turn;
last_msg.type = type;
return true;
}
示例9: logic_error
const MutationCandidate<value_t> & getMutationCandidate() {
if(mutationCandidates.empty()) {
throw std::logic_error("No mutation candidates available.");
}
uint32_t & mutationCount = mutationCandidates.front().mutationCount;
++mutationCount;
// Find the first element with a value not less the new mutationCount
auto firstElem = std::lower_bound(mutationCandidates.begin(),
mutationCandidates.end(),
mutationCount,
mutationCountLess);
if(firstElem == mutationCandidates.begin()) {
// If the only entry is the first one itself, nothing has to be done
return mutationCandidates.front();
}
auto swapPosition = std::prev(firstElem);
std::iter_swap(swapPosition, mutationCandidates.begin());
return *swapPosition;
}
示例10: gl_draw_scene
void gl_draw_scene() {
int i;
while (!pointclouds.empty()) {
nsick_pointcloud pointcloud = pointclouds.front();
pointclouds.pop_front();
GLuint list_index = glGenLists(1);
glNewList(list_index, GL_COMPILE);
glBegin(GL_POINTS);
for (int i = 0; i < pointcloud.num_points; ++i)
glVertex3f(pointcloud.x[i], pointcloud.y[i], pointcloud.z[i]);
glEnd();
glEndList();
lists.push_back(list_index);
nsick_pointcloud_free(&pointcloud);
if (lists.size() > MAX_POINTCLOUDS) {
glDeleteLists(lists.front(), 1);
lists.pop_front();
}
}
for (std::deque<GLuint>::const_iterator it = lists.begin();
it != lists.end(); ++it) {
std::deque<GLuint>::const_iterator jt = it;
++jt;
if (jt == lists.end()) {
glPointSize(2.0);
glColor3f(1, 0, 0);
}
else {
glPointSize(1.0);
glColor3f(0, 0, 0);
}
glCallList(*it);
}
}
示例11: consumer
// Worker Thread
void consumer ()
{
packaged_task< _llu() > t;
thread::id this_id = this_thread::get_id();
while (1) {
// Critical section
{
std::unique_lock<std::mutex> locker(mu);
// Lambda function is called for spurious wakeups
// 1. Unlock mutex
// 2. Suspend
// 3. Wakeup on notify and acquire mutex
cond.wait(locker, []() {return !task_q.empty();});
cout << "TID " << this_id << endl << flush;
t = std::move(task_q.front());
task_q.pop_front();
locker.unlock();
}
t();
}
}
示例12: dim
std::deque<tgt::ivec3> Flow3D::toTexturePosition(std::deque<tgt::vec3>& fps, const tgt::ivec3& textureSize,
const tgt::ivec3& offset) const
{
const tgt::vec3 dim(static_cast<tgt::vec3>(dimensions_));
const tgt::vec3 textureScaling(static_cast<tgt::vec3>(textureSize) / dim);
std::deque<tgt::ivec3> tps;
while (fps.empty() == false) {
std::deque<tgt::vec3>::iterator it = fps.begin();
const tgt::vec3& r = *it;
tgt::ivec3 temp(
(static_cast<int>(tgt::round(r.x * textureScaling.x)) + offset.x),
(static_cast<int>(tgt::round(r.y * textureScaling.y)) + offset.y),
(static_cast<int>(tgt::round(r.z * textureScaling.z)) + offset.z));
temp = tgt::clamp(temp, tgt::ivec3::zero, textureSize);
tps.push_back(temp);
fps.erase(it);
}
return tps;
}
示例13: visitor
void
attach(upstream<OtherTag>&& u) {
static_assert(
detail::is_compatible<Tag, OtherTag>::value,
"upstream protocol is not compatible with this message queue"
);
upstream_ = std::move(u.ptr);
if(operations.empty()) {
return;
}
aux::frozen_visitor_t visitor(upstream_);
for(auto it = operations.begin(); it != operations.end(); ++it) {
boost::apply_visitor(visitor, *it);
}
operations.clear();
}
示例14: if
bool
process(const std::deque<std::string>& words)
{
if (words.empty()) return true;
if (words.size() == 1) {
if (!symbol_exist(words[0])) return false;
cout << words[0] << " = " << symbols[words[0]] << endl;
return true;
}
if (words.size() == 2) {
cout << "ERROR: expected more than 2 words in statement" << endl;
return false;
}
size_t i = 0;
std::string sym;
if (words[1] == "=") {
sym = words[0];
i += 2;
}
Int result;
if (i+1 == words.size()) {
if (!load_symbol_or_int(words[i], result)) return false;
} else if (i+3 == words.size() && words[i+1] == "+") {
Int first, second;
if (!load_symbol_or_int(words[i], first)) return false;
if (!load_symbol_or_int(words[i+2], second)) return false;
result = first + second;
} else {
// for now only do plus:
cout << "ERROR: expected plus statement" << endl;
return false;
}
cout << result << endl;
if (!sym.empty()) {
symbols[sym] = result;
}
return true;
}
示例15: do_work
void do_work (CompletionCounter)
{
if (m_stop_called == true)
return;
// We don't have any work to do at this time
if (m_work.empty ())
return;
std::string const name (m_work.front ().names.back());
HandlerType handler (m_work.front ().handler);
m_work.front ().names.pop_back ();
if (m_work.front ().names.empty ())
m_work.pop_front();
HostAndPort const hp (parseName (name));
if (hp.first.empty ())
{
JLOG(m_journal.error()) <<
"Unable to parse '" << name << "'";
m_io_service.post (m_strand.wrap (std::bind (
&ResolverAsioImpl::do_work, this,
CompletionCounter (this))));
return;
}
boost::asio::ip::tcp::resolver::query query (
hp.first, hp.second);
m_resolver.async_resolve (query, std::bind (
&ResolverAsioImpl::do_finish, this, name,
std::placeholders::_1, handler,
std::placeholders::_2,
CompletionCounter (this)));
}