⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 algorithm

📁 俄罗斯高人Mamaich的Pocket gcc编译器(运行在PocketPC上)的全部源代码。
💻
📖 第 1 页 / 共 2 页
字号:
	      *__out = *__first;	      ++__out;	      --__m;	}	--__remaining;	++__first;      }      return __out;    }  /**   *  This is an SGI extension.   *  @ingroup SGIextensions   *  @doctodo  */  template<typename _ForwardIter, typename _OutputIter, typename _Distance,	   typename _RandomNumberGenerator>    _OutputIter    random_sample_n(_ForwardIter __first, _ForwardIter __last,                   _OutputIter __out, const _Distance __n, 		   _RandomNumberGenerator& __rand)    {      // concept requirements      __glibcpp_function_requires(_ForwardIteratorConcept<_ForwardIter>)      __glibcpp_function_requires(_OutputIteratorConcept<_OutputIter,		typename iterator_traits<_ForwardIter>::value_type>)      __glibcpp_function_requires(_UnaryFunctionConcept<		_RandomNumberGenerator, _Distance, _Distance>)      _Distance __remaining = std::distance(__first, __last);      _Distance __m = min(__n, __remaining);      while (__m > 0) {	if (__rand(__remaining) < __m) {	      *__out = *__first;	      ++__out;	      --__m;	}	--__remaining;	++__first;      }      return __out;    }  template<typename _InputIter, typename _RandomAccessIter, typename _Distance>    _RandomAccessIter    __random_sample(_InputIter __first, _InputIter __last,		    _RandomAccessIter __out,		    const _Distance __n)    {      _Distance __m = 0;      _Distance __t = __n;      for ( ; __first != __last && __m < __n; ++__m, ++__first) 	__out[__m] = *__first;      while (__first != __last) {	++__t;	_Distance __M = std::__random_number(__t);	if (__M < __n)	  __out[__M] = *__first;	++__first;      }      return __out + __m;    }  template<typename _InputIter, typename _RandomAccessIter,	   typename _RandomNumberGenerator, typename _Distance>    _RandomAccessIter    __random_sample(_InputIter __first, _InputIter __last,		    _RandomAccessIter __out,		    _RandomNumberGenerator& __rand,		    const _Distance __n)    {      // concept requirements      __glibcpp_function_requires(_UnaryFunctionConcept<	    _RandomNumberGenerator, _Distance, _Distance>)      _Distance __m = 0;      _Distance __t = __n;      for ( ; __first != __last && __m < __n; ++__m, ++__first)	__out[__m] = *__first;      while (__first != __last) {	++__t;	_Distance __M = __rand(__t);	if (__M < __n)	  __out[__M] = *__first;	++__first;      }      return __out + __m;    }  /**   *  This is an SGI extension.   *  @ingroup SGIextensions   *  @doctodo  */  template<typename _InputIter, typename _RandomAccessIter>    inline _RandomAccessIter    random_sample(_InputIter __first, _InputIter __last,		  _RandomAccessIter __out_first, _RandomAccessIter __out_last)     {      // concept requirements      __glibcpp_function_requires(_InputIteratorConcept<_InputIter>)      __glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<	    _RandomAccessIter>)      return __random_sample(__first, __last,			     __out_first, __out_last - __out_first);    }  /**   *  This is an SGI extension.   *  @ingroup SGIextensions   *  @doctodo  */  template<typename _InputIter, typename _RandomAccessIter, 	   typename _RandomNumberGenerator>    inline _RandomAccessIter    random_sample(_InputIter __first, _InputIter __last,		  _RandomAccessIter __out_first, _RandomAccessIter __out_last,		  _RandomNumberGenerator& __rand)     {      // concept requirements      __glibcpp_function_requires(_InputIteratorConcept<_InputIter>)      __glibcpp_function_requires(_Mutable_RandomAccessIteratorConcept<	    _RandomAccessIter>)      return __random_sample(__first, __last,			     __out_first, __rand,			     __out_last - __out_first);    }    // is_heap, a predicate testing whether or not a range is  // a heap.  This function is an extension, not part of the C++  // standard.  template<typename _RandomAccessIter, typename _Distance>    bool    __is_heap(_RandomAccessIter __first, _Distance __n)    {      _Distance __parent = 0;      for (_Distance __child = 1; __child < __n; ++__child) {	if (__first[__parent] < __first[__child]) 	  return false;	if ((__child & 1) == 0)	  ++__parent;      }      return true;    }  template<typename _RandomAccessIter, typename _Distance,           typename _StrictWeakOrdering>    bool    __is_heap(_RandomAccessIter __first, _StrictWeakOrdering __comp,	      _Distance __n)    {      _Distance __parent = 0;      for (_Distance __child = 1; __child < __n; ++__child) {	if (__comp(__first[__parent], __first[__child]))	  return false;	if ((__child & 1) == 0)	  ++__parent;      }      return true;    }  /**   *  This is an SGI extension.   *  @ingroup SGIextensions   *  @doctodo  */  template<typename _RandomAccessIter>    inline bool    is_heap(_RandomAccessIter __first, _RandomAccessIter __last)    {      // concept requirements      __glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIter>)      __glibcpp_function_requires(_LessThanComparableConcept<	    typename iterator_traits<_RandomAccessIter>::value_type>)      return __is_heap(__first, __last - __first);    }  /**   *  This is an SGI extension.   *  @ingroup SGIextensions   *  @doctodo  */  template<typename _RandomAccessIter, typename _StrictWeakOrdering>    inline bool    is_heap(_RandomAccessIter __first, _RandomAccessIter __last,	    _StrictWeakOrdering __comp)    {      // concept requirements      __glibcpp_function_requires(_RandomAccessIteratorConcept<_RandomAccessIter>)      __glibcpp_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering,	    typename iterator_traits<_RandomAccessIter>::value_type, 	    typename iterator_traits<_RandomAccessIter>::value_type>)      return __is_heap(__first, __comp, __last - __first);    }  // is_sorted, a predicated testing whether a range is sorted in  // nondescending order.  This is an extension, not part of the C++  // standard.  /**   *  This is an SGI extension.   *  @ingroup SGIextensions   *  @doctodo  */  template<typename _ForwardIter>    bool    is_sorted(_ForwardIter __first, _ForwardIter __last)    {      // concept requirements      __glibcpp_function_requires(_ForwardIteratorConcept<_ForwardIter>)      __glibcpp_function_requires(_LessThanComparableConcept<	    typename iterator_traits<_ForwardIter>::value_type>)      if (__first == __last)	return true;      _ForwardIter __next = __first;      for (++__next; __next != __last; __first = __next, ++__next) {	if (*__next < *__first)	  return false;      }      return true;    }  /**   *  This is an SGI extension.   *  @ingroup SGIextensions   *  @doctodo  */  template<typename _ForwardIter, typename _StrictWeakOrdering>    bool    is_sorted(_ForwardIter __first, _ForwardIter __last, _StrictWeakOrdering __comp)    {      // concept requirements      __glibcpp_function_requires(_ForwardIteratorConcept<_ForwardIter>)      __glibcpp_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering,	    typename iterator_traits<_ForwardIter>::value_type, 	    typename iterator_traits<_ForwardIter>::value_type>)      if (__first == __last)	return true;      _ForwardIter __next = __first;      for (++__next; __next != __last; __first = __next, ++__next) {	if (__comp(*__next, *__first))	  return false;      }      return true;    }} // namespace __gnu_cxx#endif /* _EXT_ALGORITHM */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -