예제 #1
0
void
throw_exception_sjlj (const struct gdb_exception &exception)
{
  /* Jump to the nearest CATCH_SJLJ block, communicating REASON to
     that call via setjmp's return value.  Note that REASON can't be
     zero, by definition in common-exceptions.h.  */
  exceptions_state_mc (CATCH_THROWING);
  enum return_reason reason = exception.reason;
  catchers.front ().exception = exception;
  longjmp (catchers.front ().buf, reason);
}
예제 #2
0
void get(int k){
	termStack.sort(std::greater<node>());
	for(int i=0; i<k; i++){
		cout<<termStack.front().t<<endl;
		termStack.pop_front();
	}
}
예제 #3
0
파일: fold.cpp 프로젝트: fons/presentations
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);
}
예제 #4
0
		bool runDeferred() {
			__EVENTEMITTER_LOCK_GUARD(mutex);
			if(deferredQueue.empty()) {
				return false;
			}
			(deferredQueue.front())();
			deferredQueue.pop_front();
			return true;
		}
예제 #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;
}
예제 #6
0
void add(string term){
	if(terms.find(term) == terms.end()){
		node *n = new node;
		n->t=term;
		n->i=1;
		termStack.push_front(*n);
		terms[term]=&termStack.front();			
	}
	else{
		terms[term]->i++;
	}
}
예제 #7
0
파일: Nnode.cpp 프로젝트: rand0wn/ask-dsa
//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++;
	
     }
	
}
예제 #8
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
		
	}
	
}
예제 #9
0
TEST(std_forward_list, emplace_front) {
  std::forward_list<std::pair<int, int>> l1{
    std::pair<int, int>{1, 2},
    std::pair<int, int>{2, 3},
    std::pair<int, int>{3, 4},
  };

  l1.emplace_front(0, 1);

  const std::forward_list<std::pair<int, int>> l2{
    std::pair<int, int>{0, 1},
    std::pair<int, int>{1, 2},
    std::pair<int, int>{2, 3},
    std::pair<int, int>{3, 4},
  };

  ASSERT_TRUE(l1 == l2);
  const std::pair<int, int> v1{0, 1};
  ASSERT_EQ(v1, l2.front());
}
예제 #10
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);
  }
예제 #11
0
int
exceptions_state_mc_catch (struct gdb_exception *exception,
			   int mask)
{
  *exception = std::move (catchers.front ().exception);
  catchers.pop_front ();

  if (exception->reason < 0)
    {
      if (mask & RETURN_MASK (exception->reason))
	{
	  /* Exit normally and let the caller handle the
	     exception.  */
	  return 1;
	}

      /* The caller didn't request that the event be caught, relay the
	 event to the next exception_catch/CATCH_SJLJ.  */
      throw_exception_sjlj (*exception);
    }

  /* No exception was thrown.  */
  return 0;
}
예제 #12
0
 int top() {
     return data_.front();
 }
    list.PushBack(18);

    return list.CopyToArray();
}

}//namespace


const std::vector<int> EXPECTED_SORTED_INSERT_ARRAY = { -8, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 15, 18};


SIMPLE_BENCHMARK(testSortedInsert, SAMPLE_ARRAY);

SIMPLE_TEST(testSortedInsert, TestSample, EXPECTED_SORTED_INSERT_ARRAY, SAMPLE_ARRAY);


const std::forward_list<int> EMPTY_LIST = {};
const std::forward_list<int> SINGLE_ITEM_LIST = {5};
const std::forward_list<int> EXPECTED2 = {2, 5};
const std::forward_list<int> EXPECTED3 = {5, 8};
const std::forward_list<int> SAMPLE_LIST = {EXPECTED_SORTED_INSERT_ARRAY.cbegin(), EXPECTED_SORTED_INSERT_ARRAY.cend()};
const std::forward_list<int> EXPECTED4 = { -8, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 15, 18};


SIMPLE_BENCHMARK(SortedInsert_STL, SAMPLE_LIST, 10);

SIMPLE_TEST(SortedInsert_STL, TestSample1, SINGLE_ITEM_LIST, EMPTY_LIST, SINGLE_ITEM_LIST.front());
SIMPLE_TEST(SortedInsert_STL, TestSample2, EXPECTED2, SINGLE_ITEM_LIST, EXPECTED2.front());
SIMPLE_TEST(SortedInsert_STL, TestSample3, EXPECTED3, SINGLE_ITEM_LIST, 8);
SIMPLE_TEST(SortedInsert_STL, TestSample4, EXPECTED4, SAMPLE_LIST, 10);
예제 #14
0
jmp_buf *
exceptions_state_mc_init ()
{
  catchers.emplace_front ();
  return &catchers.front ().buf;
}
예제 #15
0
static int
exceptions_state_mc (enum catcher_action action)
{
  switch (catchers.front ().state)
    {
    case CATCHER_CREATED:
      switch (action)
	{
	case CATCH_ITER:
	  /* Allow the code to run the catcher.  */
	  catchers.front ().state = CATCHER_RUNNING;
	  return 1;
	default:
	  internal_error (__FILE__, __LINE__, _("bad state"));
	}
    case CATCHER_RUNNING:
      switch (action)
	{
	case CATCH_ITER:
	  /* No error/quit has occured.  */
	  return 0;
	case CATCH_ITER_1:
	  catchers.front ().state = CATCHER_RUNNING_1;
	  return 1;
	case CATCH_THROWING:
	  catchers.front ().state = CATCHER_ABORTING;
	  /* See also throw_exception.  */
	  return 1;
	default:
	  internal_error (__FILE__, __LINE__, _("bad switch"));
	}
    case CATCHER_RUNNING_1:
      switch (action)
	{
	case CATCH_ITER:
	  /* The did a "break" from the inner while loop.  */
	  return 0;
	case CATCH_ITER_1:
	  catchers.front ().state = CATCHER_RUNNING;
	  return 0;
	case CATCH_THROWING:
	  catchers.front ().state = CATCHER_ABORTING;
	  /* See also throw_exception.  */
	  return 1;
	default:
	  internal_error (__FILE__, __LINE__, _("bad switch"));
	}
    case CATCHER_ABORTING:
      switch (action)
	{
	case CATCH_ITER:
	  {
	    /* Exit normally if this catcher can handle this
	       exception.  The caller analyses the func return
	       values.  */
	    return 0;
	  }
	default:
	  internal_error (__FILE__, __LINE__, _("bad state"));
	}
    default:
      internal_error (__FILE__, __LINE__, _("bad switch"));
    }
}
예제 #16
0
파일: pulley.cpp 프로젝트: arpa2/steamworks
	int add_follower(const std::string& base, const std::string& filter, Object& response)
	{
		m_following.emplace_front(new PulleySyncRepl(base, filter, m_parser));
		m_following.front()->execute(*m_connection, &response);
		return 0;
	}
예제 #17
0
 int getMin() {
     return mins_.front();
 }
예제 #18
0
 void push(int x) {
     data_.push_front(x);
     mins_.push_front(mins_._empty() ? x : std::min(x, mins_.front()));
 }