Exemple #1
0
  inline int operator () (EArgs&&... args) // O(n)
  {
    if(slots.empty())
      return default_return_value;
    auto it = slots.cbegin(), end = slots.cend();
    auto prev = slots.cbefore_begin();
    while(it != end)
    {
      try
      {
        (it->second)(std::forward<EArgs>(args)...);
        prev = it;
        ++it;
      }
      catch(slot_remove)
      {
        it = slots.erase_after(prev);
      }
      catch(signal_return e)
      {
        return e.get();
      }
    }

    return default_return_value;
  }
Exemple #2
0
void removeDupsNoBuffer(std::forward_list<int>& l) {
    if (l.empty())
        return;
    auto backtrack = l.before_begin();
    while (std::next(backtrack) != l.end()) {
        // Iterate and print values of the list
        for (int n : l)
            std::cout << n << '\t';
        std::cout << std::endl;

        auto prev = std::next(backtrack);
        auto iter = std::next(prev);
        //std::cout << " prev =" << *prev << ", iter=" << *iter << std::endl;
        while (iter != l.end()) {
            if (*iter == *std::next(backtrack))
                iter = l.erase_after(prev);
            else {
                ++prev;
                ++iter;
            }
                
        }
        ++backtrack;
    }
}
Exemple #3
0
U foldr_dest(std::function< U (U, T)>& op, const U& val, std::forward_list<T>& L)
{
  if (L.empty()) return U(val);
  T h = L.front();
  L.pop_front();
  return op (foldr(op, val, L),  h);
}
		bool runDeferred() {
			__EVENTEMITTER_LOCK_GUARD(mutex);
			if(deferredQueue.empty()) {
				return false;
			}
			(deferredQueue.front())();
			deferredQueue.pop_front();
			return true;
		}
Exemple #5
0
static ptid_t
fbsd_next_vfork_done (void)
{
  if (!fbsd_pending_vfork_done.empty ())
    {
      ptid_t ptid = fbsd_pending_vfork_done.front ();
      fbsd_pending_vfork_done.pop_front ();
      return ptid;
    }
  return null_ptid;
}
Exemple #6
0
  /* virtual methods from class Notify */
  void OnNotification() override {
    const bool was_empty = items.empty();

    {
      const ScopeLock protect(mutex);

      if (new_items.empty())
        return;

      do {
        items.emplace_back(std::move(new_items.front()));
        new_items.pop_front();
      } while (!new_items.empty());
    }

    GetList().SetLength(items.size());

    if (was_empty)
      /* the list has just become non-empty, so allow pressing the
         "select" button */
      select_button->SetEnabled(true);
  }
void middle_end_to_backend_workflow::write_files_activity(
    const std::forward_list<
        std::shared_ptr<dogen::formatters::file_writer_interface>
        >& writers,
    const std::forward_list<formatters::file>& files) const {

    if (files.empty()) {
        BOOST_LOG_SEV(lg, warn) << "No files were generated, so no output.";
        return;
    }

    for (const auto writer : writers)
        writer->write(files);
}
Exemple #8
0
 void operator()(clmdep_msgpack::object::with_zone& o, const std::forward_list<T, Alloc>& v) const {
     o.type = clmdep_msgpack::type::ARRAY;
     if(v.empty()) {
         o.via.array.ptr = nullptr;
         o.via.array.size = 0;
     } else {
         uint32_t size = checked_get_container_size(std::distance(v.begin(), v.end()));
         o.via.array.size = size;
         clmdep_msgpack::object* p = static_cast<clmdep_msgpack::object*>(
             o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size));
         o.via.array.ptr = p;
         for(auto const& e : v) *p++ = clmdep_msgpack::object(e, o.zone);
     }
 }
Exemple #9
0
void rReverse(std::forward_list<int> &l){
	
	if(!l.empty()){
		 a = l.front();

		l.pop_front();  //Remove all elements until empty

		rReverse(l); 
	}else{

		l.push_front(a); //Insert elements from the function stack
		
	}
	
}
Exemple #10
0
void IEventsEx::addEventHandlers(std::forward_list<IEventSinkBase*> eventHandlers)
{
	if(eventHandlers.empty()) return;
	_eventHandlerMutex.lock();
	for(std::forward_list<IEventSinkBase*>::iterator i = eventHandlers.begin(); i != eventHandlers.end(); ++i)
	{
		bool exists = false;
		for(std::forward_list<IEventSinkBase*>::iterator j = _eventHandlers.begin(); j != _eventHandlers.end(); ++j)
		{
			if(*j == *i)
			{
				exists = true;
				break;
			}
		}
		if(exists) continue;
		_eventHandlers.push_front(*i);
	}
    _eventHandlerMutex.unlock();
}
Exemple #11
0
 inline void operator () (Args... args)
 {
   if(slots.empty())
     return;
   auto it = slots.begin(), end = slots.end();
   auto prev = slots.before_begin();
   while(it != end)
   {
     try
     {
       (*it)(args...);
     }
     catch(slot_remove)
     {
       slots.erase_after(prev);
       it = prev;
     }
     prev = it;
     ++it;
   }
 }
Exemple #12
0
//Using recursion
int rReturn(std::forward_list<int> l, int n){

    static int i = 0;

	if(i == n)
 	return l.front();

	if(!l.empty())
		
	{
	int a = l.front();
	
	l.pop_front();

	rReturn(l, n);
	
	l.push_front(a);

	i++;
	
     }
	
}
Exemple #13
0
 inline bool empty() const
 {
   return slots.empty();
 }
Exemple #14
0
 inline bool empty()
 {
 	return slots.empty();
 }