コード例 #1
0
const char *git_win32__crtdbg_stacktrace(int skip, const char *file)
{
	git_win32__stack__raw_data new_data;
	git_win32__crtdbg_stacktrace__row *row;
	const char * result = file;

	if (git_win32__stack_capture(&new_data, skip+1) < 0)
		return result;

	EnterCriticalSection(&g_crtdbg_stacktrace_cs);

	if (g_cs_ins < g_cs_end) {
		row = insert_unique(&new_data);
		result = row->uid.uid;
	} else {
		g_limit_reached = true;
	}

	g_count_total_allocs++;

	LeaveCriticalSection(&g_crtdbg_stacktrace_cs);

	return result;
}
コード例 #2
0
ファイル: _tree.c プロジェクト: Frankie-666/tomita-parser
__iterator__
_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> ::insert_unique(iterator __position,
                                                                          const _Value& __val) {
  if (__position._M_node == this->_M_header._M_data._M_left) { // begin()

    // if the container is empty, fall back on insert_unique.
    if (empty())
      return insert_unique(__val).first;

    if (_M_key_compare(_KeyOfValue()(__val), _S_key(__position._M_node))) {
      return _M_insert(__position._M_node, __val, __position._M_node);
    }
    // first argument just needs to be non-null
    else {
      bool __comp_pos_v = _M_key_compare( _S_key(__position._M_node), _KeyOfValue()(__val) );

      if (__comp_pos_v == false)  // compare > and compare < both false so compare equal
        return __position;
      //Below __comp_pos_v == true

      // Standard-conformance - does the insertion point fall immediately AFTER
      // the hint?
      iterator __after = __position;
      ++__after;

      // Check for only one member -- in that case, __position points to itself,
      // and attempting to increment will cause an infinite loop.
      if (__after._M_node == &this->_M_header._M_data)
        // Check guarantees exactly one member, so comparison was already
        // performed and we know the result; skip repeating it in _M_insert
        // by specifying a non-zero fourth argument.
        return _M_insert(__position._M_node, __val, 0, __position._M_node);

      // All other cases:

      // Optimization to catch insert-equivalent -- save comparison results,
      // and we get this for free.
      if (_M_key_compare( _KeyOfValue()(__val), _S_key(__after._M_node) )) {
        if (_S_right(__position._M_node) == 0)
          return _M_insert(__position._M_node, __val, 0, __position._M_node);
        else
          return _M_insert(__after._M_node, __val, __after._M_node);
      }
      else {
        return insert_unique(__val).first;
      }
    }
  }
  else if (__position._M_node == &this->_M_header._M_data) { // end()
    if (_M_key_compare(_S_key(_M_rightmost()), _KeyOfValue()(__val))) {
        // pass along to _M_insert that it can skip comparing
        // v, Key ; since compare Key, v was true, compare v, Key must be false.
        return _M_insert(_M_rightmost(), __val, 0, __position._M_node); // Last argument only needs to be non-null
    }
    else
      return insert_unique(__val).first;
  }
  else {
    iterator __before = __position;
    --__before;

    bool __comp_v_pos = _M_key_compare(_KeyOfValue()(__val), _S_key(__position._M_node));

    if (__comp_v_pos
        && _M_key_compare( _S_key(__before._M_node), _KeyOfValue()(__val) )) {

      if (_S_right(__before._M_node) == 0)
        return _M_insert(__before._M_node, __val, 0, __before._M_node); // Last argument only needs to be non-null
      else
        return _M_insert(__position._M_node, __val, __position._M_node);
      // first argument just needs to be non-null
    }
    else {
      // Does the insertion point fall immediately AFTER the hint?
      iterator __after = __position;
      ++__after;
      // Optimization to catch equivalent cases and avoid unnecessary comparisons
      bool __comp_pos_v = !__comp_v_pos;  // Stored this result earlier
      // If the earlier comparison was true, this comparison doesn't need to be
      // performed because it must be false.  However, if the earlier comparison
      // was false, we need to perform this one because in the equal case, both will
      // be false.
      if (!__comp_v_pos) {
        __comp_pos_v = _M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__val));
      }

      if ( (!__comp_v_pos) // comp_v_pos true implies comp_v_pos false
          && __comp_pos_v
          && (__after._M_node == &this->_M_header._M_data ||
              _M_key_compare( _KeyOfValue()(__val), _S_key(__after._M_node) ))) {
        if (_S_right(__position._M_node) == 0)
          return _M_insert(__position._M_node, __val, 0, __position._M_node);
        else
          return _M_insert(__after._M_node, __val, __after._M_node);
      } else {
        // Test for equivalent case
        if (__comp_v_pos == __comp_pos_v)
          return __position;
        else
          return insert_unique(__val).first;
      }
    }
  }
}
コード例 #3
0
ファイル: skiplist_map.hpp プロジェクト: dodikk/iWesnoth
Value& operator[](const Key& k) {
	return insert_unique(std::make_pair(k, Value())).first->second;
}