/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1997
* Moscow Center for SPARC Technology
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#ifndef _STLP_ALGO_C
#define _STLP_ALGO_C
#if !defined (_STLP_INTERNAL_ALGO_H)
# include <stl/_algo.h>
#endif
#ifndef _STLP_INTERNAL_TEMPBUF_H
# include <stl/_tempbuf.h>
#endif
_STLP_BEGIN_NAMESPACE
_STLP_MOVE_TO_PRIV_NAMESPACE
template <class _BidirectionalIter, class _Distance, class _Compare>
void __merge_without_buffer(_BidirectionalIter __first,
_BidirectionalIter __middle,
_BidirectionalIter __last,
_Distance __len1, _Distance __len2,
_Compare __comp);
template <class _BidirectionalIter1, class _BidirectionalIter2,
class _BidirectionalIter3, class _Compare>
_BidirectionalIter3 __merge_backward(_BidirectionalIter1 __first1,
_BidirectionalIter1 __last1,
_BidirectionalIter2 __first2,
_BidirectionalIter2 __last2,
_BidirectionalIter3 __result,
_Compare __comp);
template <class _Tp>
#if !(defined (__SUNPRO_CC) && (__SUNPRO_CC < 0x420 ))
inline
#endif
const _Tp& __median(const _Tp& __a, const _Tp& __b, const _Tp& __c) {
if (__a < __b)
if (__b < __c)
return __b;
else if (__a < __c)
return __c;
else
return __a;
else if (__a < __c)
return __a;
else if (__b < __c)
return __c;
else
return __b;
}
template <class _Tp, class _Compare>
#if !(defined (__SUNPRO_CC) && (__SUNPRO_CC < 0x420 ))
inline
#endif
const _Tp&
__median(const _Tp& __a, const _Tp& __b, const _Tp& __c, _Compare __comp) {
if (__comp(__a, __b)) {
_STLP_VERBOSE_ASSERT(!__comp(__b, __a), _StlMsg_INVALID_STRICT_WEAK_PREDICATE)
if (__comp(__b, __c)) {
_STLP_VERBOSE_ASSERT(!__comp(__c, __b), _StlMsg_INVALID_STRICT_WEAK_PREDICATE)
return __b;
}
else if (__comp(__a, __c)) {
_STLP_VERBOSE_ASSERT(!__comp(__c, __a), _StlMsg_INVALID_STRICT_WEAK_PREDICATE)
return __c;
}
else
return __a;
}
else if (__comp(__a, __c)) {
_STLP_VERBOSE_ASSERT(!__comp(__c, __a), _StlMsg_INVALID_STRICT_WEAK_PREDICATE)
return __a;
}
else if (__comp(__b, __c)) {
_STLP_VERBOSE_ASSERT(!__comp(__c, __b), _StlMsg_INVALID_STRICT_WEAK_PREDICATE)
return __c;
}
else
return __b;
}
_STLP_MOVE_TO_STD_NAMESPACE
template <class _ForwardIter1, class _ForwardIter2>
_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1,
_ForwardIter2 __first2, _ForwardIter2 __last2) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2))
// Test for empty ranges
if (__first1 == __last1 || __first2 == __last2)
return __first1;
// Test for a pattern of length 1.
_ForwardIter2 __p1(__first2);
if ( ++__p1 == __last2 )
return find(__first1, __last1, *__first2);
// General case.
for ( ; ; ) { // __first1 != __last1 will be checked in find below
__first1 = find(__first1, __last1, *__first2);
if (__first1 == __last1)
return __last1;
_ForwardIter2 __p = __p1;
_ForwardIter1 __current = __first1;
if (++__current == __last1)
return __last1;
while (*__current == *__p) {
if (++__p == __last2)
return __first1;
if (++__current == __last1)
return __last1;
}
++__first1;
}
return __first1;
}
_STLP_MOVE_TO_PRIV_NAMESPACE
template <class _RandomAccessIter, class _Integer, class _Tp,
class _BinaryPred, class _Distance>
_RandomAccessIter __search_n(_RandomAccessIter __first, _RandomAccessIter __last,
_Integer __count, const _Tp& __val, _BinaryPred __pred,
_Distance*, const random_access_iterator_tag &)
{
_Distance __tailSize = __last - __first;
const _Distance __pattSize = __count;
const _Distance __skipOffset = __pattSize - 1;
_RandomAccessIter __backTrack;
_Distance __remainder, __prevRemainder;
for ( _RandomAccessIter __lookAhead = __first + __skipOffset; __tailSize >= __pattSize; __lookAhead += __pattSize ) { // the main loop...
//__lookAhead here is always pointing to the last element of next possible match.
__tailSize -= __pattSize;
while ( !__pred(*__lookAhead, __val) ) { // the skip loop...
if (__tailSize < __pattSize)
return __last;
__lookAhead += __pattSize;
__tailSize -= __pattSize;
}
if ( __skipOffset == 0 ) {
return (__lookAhead - __skipOffset); //Success
}
__remainder = __skipOffset;
for (__backTrack = __lookAhead; __pred(*--__backTrack, __val); ) {
if (--__remainder == 0)
return (__lookAhead - __skipOffset); //Success
}
if (__remainder > __tailSize)
return __last; //failure
__lookAhead += __remainder;
__tailSize -= __remainder;
while ( __pred(*__lookAhead, __val) ) {
__prevRemainder = __remainder;
__backTrack = __lookAhead;
do {
if (--__remainder == 0)
return (__lookAhead - __skipOffset); //Success
} while (__pred(*--__backTrack, __val));
//adjust remainder for next comparison
__remainder += __pattSize - __prevRemainder;
if (__remainder > __tailSize)
return __last; //failure
__lookAhead += __remainder;
__tailSize -= __remainder;
}
//__lookAhead here is always pointing to the element of the last mismatch.
}
return __last; //failure
}
template <class _ForwardIter, class _Integer, class _Tp,
class _Distance, class _BinaryPred>
_ForwardIter __search_n(_ForwardIter __first, _ForwardIter __last,
_Integer __count, const _Tp& __val, _BinaryPred __pred,
_Distance*, const forward_iterator_tag &) {
for (; (__first != __last) && !__pred(*__first, __val); ++__first) {}
while (__first != __last) {
_Integer __n = __count - 1;
_ForwardIter __i = __first;
++__i;
while (__i != __last && __n != 0 && __pred(*__i, __val)) {
++__i;
--__n;
}
if (__n == 0)
return __first;
else if (__i != __last)
for (__first = ++__i; (__first != __last) && !__pred(*__first, __val); ++__first) {}
else
break;
}
return __last;
}
_STLP_MOVE_TO_STD_NAMESPACE
// search_n. Search for __count consecutive copies of __val.
template <class _ForwardIter, class _Integer, class _Tp>
_ForwardIter search_n(_ForwardIter __first, _ForwardIter __last,
_Integer __count, const _Tp& __val) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
if (__count <= 0)
return __first;
if (__count == 1)
//We use find when __count == 1 to use potential find overload.
return find(__first, __last, __val);
return _STLP_PRIV __search_n(__first, __last, __count, __val, equal_to<_Tp>(),
_STLP_DISTANCE_TYPE(__first, _ForwardIter),
没有合适的资源?快使用搜索试试~ 我知道了~
STLport
共878个文件
h:264个
cpp:213个
mak:207个
4星 · 超过85%的资源 需积分: 0 91 下载量 148 浏览量
2008-05-08
14:08:57
上传
评论 1
收藏 1.26MB ZIP 举报
温馨提示
STLport-5.1.5 库文件。
资源详情
资源评论
资源推荐
收起资源包目录
STLport (878个子文件)
ChangeLog-4.0 28KB
ChangeLog-5.1 325KB
algorithm 1KB
configure.bat 16KB
bitset 2KB
README.borland 5KB
_algo.c 74KB
c_locale_win32.c 65KB
_rope.c 51KB
_istream.c 48KB
_deque.c 32KB
_fstream.c 27KB
_tree.c 27KB
_string.c 25KB
c_locale_glibc.c 25KB
_debug.c 23KB
_num_get.c 22KB
c_locale_glibc2.c 22KB
_monetary.c 20KB
_num_put.c 20KB
_sstream.c 17KB
_time_facets.c 17KB
_hashtable.c 17KB
_ostream.c 14KB
_algobase.c 13KB
_limits.c 12KB
c_locale_dummy.c 11KB
_vector.c 8KB
_heap.c 8KB
_list.c 7KB
_slist.c 7KB
_bitset.c 7KB
_streambuf.c 6KB
_string_io.c 5KB
_valarray.c 5KB
_threads.c 5KB
cxa.c 5KB
mwerks_console_OS_X.c 4KB
_complex.c 4KB
_ios.c 4KB
_alloc.c 3KB
_slist_base.c 3KB
_numeric.c 3KB
c_locale.c 3KB
_tempbuf.c 1KB
stdarg_header_test.c 361B
string_header_test.c 361B
iso646_header_test.c 361B
assert_header_test.c 361B
setjmp_header_test.c 361B
c_limits_header_test.c 361B
wctype_header_test.c 361B
stddef_header_test.c 361B
c_locale_header_test.c 361B
signal_header_test.c 361B
stdlib_header_test.c 361B
float_header_test.c 360B
ctype_header_test.c 360B
errno_header_test.c 360B
wchar_header_test.c 360B
stdio_header_test.c 360B
math_header_test.c 359B
time_header_test.c 359B
cassert 1KB
stterm-test.cc 2KB
eh.cc 1KB
cctype 1KB
cerrno 1KB
cfloat 1KB
ciso646 1KB
climits 1KB
clocale 1KB
cmath 1KB
complex 1KB
configure 4KB
mvctor_test.cpp 54KB
locale_test.cpp 42KB
facets_byname.cpp 40KB
allocators.cpp 37KB
fstream.cpp 35KB
string_test.cpp 33KB
num_put_float.cpp 31KB
num_get_float.cpp 31KB
locale_impl.cpp 30KB
type_traits_test.cpp 23KB
ctype.cpp 21KB
fstream_test.cpp 17KB
unordered_test.cpp 16KB
slist_test.cpp 14KB
time_facets.cpp 14KB
num_put_get_test.cpp 14KB
main.cpp 13KB
vector_test.cpp 13KB
set_test.cpp 13KB
iostream.cpp 13KB
map_test.cpp 12KB
locale.cpp 12KB
complex.cpp 11KB
dll_main.cpp 11KB
locale_catalog.cpp 10KB
共 878 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
leomsk
- 粉丝: 1
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 80632180.jpg
- 李旭国体注入追踪[5.0](1).zip
- semantic.c
- C语言基础-C语言编程基础之Leetcode编程题解之第39题组合总和.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第38题外观数列.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第37题解数独.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第36题有效的数独.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第35题搜索插入位置.zip
- index.wxml
- C语言基础-C语言编程基础之Leetcode编程题解之第33题搜索旋转排序数组.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1