// Algorithm implementation -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/** @file stl_algo.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
#ifndef _STL_ALGO_H
#define _STL_ALGO_H 1
#include <cstdlib> // for rand
#include <bits/algorithmfwd.h>
#include <bits/stl_heap.h>
#include <bits/stl_tempbuf.h> // for _Temporary_buffer
#include <debug/debug.h>
// See concept_check.h for the __glibcxx_*_requires macros.
_GLIBCXX_BEGIN_NAMESPACE(std)
/**
* @brief Find the median of three values.
* @param a A value.
* @param b A value.
* @param c A value.
* @return One of @p a, @p b or @p c.
*
* If @c {l,m,n} is some convolution of @p {a,b,c} such that @c l<=m<=n
* then the value returned will be @c m.
* This is an SGI extension.
* @ingroup SGIextensions
*/
template<typename _Tp>
inline const _Tp&
__median(const _Tp& __a, const _Tp& __b, const _Tp& __c)
{
// concept requirements
__glibcxx_function_requires(_LessThanComparableConcept<_Tp>)
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;
}
/**
* @brief Find the median of three values using a predicate for comparison.
* @param a A value.
* @param b A value.
* @param c A value.
* @param comp A binary predicate.
* @return One of @p a, @p b or @p c.
*
* If @c {l,m,n} is some convolution of @p {a,b,c} such that @p comp(l,m)
* and @p comp(m,n) are both true then the value returned will be @c m.
* This is an SGI extension.
* @ingroup SGIextensions
*/
template<typename _Tp, typename _Compare>
inline const _Tp&
__median(const _Tp& __a, const _Tp& __b, const _Tp& __c, _Compare __comp)
{
// concept requirements
__glibcxx_function_requires(_BinaryFunctionConcept<_Compare, bool,
_Tp, _Tp>)
if (__comp(__a, __b))
if (__comp(__b, __c))
return __b;
else if (__comp(__a, __c))
return __c;
else
return __a;
else if (__comp(__a, __c))
return __a;
else if (__comp(__b, __c))
return __c;
else
return __b;
}
// for_each
/// This is an overload used by find() for the Input Iterator case.
template<typename _InputIterator, typename _Tp>
inline _InputIterator
__find(_InputIterator __first, _InputIterator __last,
const _Tp& __val, input_iterator_tag)
{
while (__first != __last && !(*__first == __val))
++__first;
return __first;
}
/// This is an overload used by find_if() for the Input Iterator case.
template<typename _InputIterator, typename _Predicate>
inline _InputIterator
__find_if(_InputIterator __first, _InputIterator __last,
_Predicate __pred, input_iterator_tag)
{
while (__first != __last && !bool(__pred(*__first)))
++__first;
return __first;
}
/// This is an overload used by find() for the RAI case.
template<typename _RandomAccessIterator, typename _Tp>
_RandomAccessIterator
__find(_RandomAccessIterator __first, _RandomAccessIterator __last,
const _Tp& __val, random_access_iterator_tag)
{
typename iterator_traits<_RandomAccessIterator>::difference_type
__trip_count = (__last - __first) >> 2;
for (; __trip_count > 0; --__trip_count)
{
if (*__first == __val)
return __first;
++__first;
if (*__first == __val)
return __first;
++__first;
if (*__first == __val)
return __first;
++__first;
if (*__first == __val)
return __first;
++__first;
}
switch (__last - __first)
{
case 3:
if (*__first == __val)
return __first;
++__first;
case 2:
if (*__first == __val)
return __first;
++__first;
case 1:
if (*__first == __val)
return __first;
++__first;
case 0:
default:
return __last;
}
}
/// This is an overload used by find_if() for the RAI case.
template<typename _RandomAccessIterator, typename _Predicate>
_RandomAccessIterator
__find_if(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Predicate __pred, random_access_iterator_tag)
{
typename iterator_traits<_RandomAccessIterator>::difference_type
__trip_count = (__last - __first) >> 2;
for (; __trip_count > 0; --__trip_count)
{
if (__pred(*__first))
return __first;
++__first;
if (__pred(*__first))
return __first;
++__first;
if (__pred(*__first))
return __first;
++__first;
if (__pred(*__first))
return __first;
++__first;
}
switch (__last - __first)
{
case 3:
if (__pred(*__first))
return __first;
++__first;
case 2:
if (__pred(*__first))
return __first;
++__first;
case 1:
if (__pred(*__first))
return __first;
++__first;
case 0:
default:
return __last;
}
}
// set_difference
// set_intersection
// set_symmetric_difference
// set_union
// for_each
// find
// find_if
// find_first_of
// adjacent_find
// count
// count_if
// search
/**
* This is an uglified
* search_n(_ForwardIterator, _ForwardIterator, _Integer, const _Tp&)
* overloaded for forward iterators.
*/
template<typename _ForwardIterator, typename _Integer, typename _Tp>
_ForwardIterator
__search_n(_Forwa
没有合适的资源?快使用搜索试试~ 我知道了~
mips-gcc交叉编译工具压缩包gcc-4.3-ls232.tar.gz
需积分: 0 17 下载量 82 浏览量
2023-09-17
11:27:06
上传
评论 1
收藏 106.97MB GZ 举报
温馨提示
共2000个文件
h:1241个
so:289个
hpp:265个
mips-gcc交叉编译工具压缩包gcc-4.3-ls232.tar.gz 适用于CPU设计实战4.3节的内容
资源推荐
资源详情
资源评论
收起资源包目录
mips-gcc交叉编译工具压缩包gcc-4.3-ls232.tar.gz (2000个子文件)
libpthread.so.0 936KB
ld.so.1 690KB
libnsl.so.1 446KB
libcidn.so.1 244KB
librt.so.1 225KB
libthread_db.so.1 177KB
libcrypt.so.1 105KB
libanl.so.1 73KB
libutil.so.1 23KB
libBrokenLocale.so.1 18KB
libresolv.so.2 272KB
libnss_nisplus.so.2 244KB
libnss_nis.so.2 191KB
libnss_files.so.2 186KB
libnss_compat.so.2 110KB
libdl.so.2 101KB
libnss_hesiod.so.2 71KB
libnss_dns.so.2 68KB
libc.so.6 8.49MB
libm.so.6 1.1MB
libc.a 15.99MB
libm.a 1.86MB
libpthread.a 1.68MB
libnsl.a 787KB
libresolv.a 390KB
librt.a 369KB
libcrypt.a 146KB
libanl.a 109KB
libc_nonshared.a 54KB
libdl.a 34KB
libutil.a 30KB
libBrokenLocale.a 15KB
libmcheck.a 8KB
libpthread_nonshared.a 3KB
libg.a 2KB
libbsd-compat.a 2KB
libieee.a 2KB
am_ET 45KB
ar_DZ 6KB
ar_IQ 6KB
ar_KW 6KB
ar_TN 6KB
be_BY@latin 4KB
br_FR 5KB
ca_AD 2KB
ca_FR 1KB
catchsegv 3KB
..install.cmd 4KB
..install.cmd 1KB
..install.cmd 864B
..install.cmd 843B
..install.cmd 803B
..install.cmd 775B
..install.cmd 745B
..install.cmd 677B
..install.cmd 633B
..install.cmd 633B
..install.cmd 622B
..install.cmd 617B
..install.cmd 600B
..install.cmd 599B
..install.cmd 599B
..install.cmd 576B
..install.cmd 558B
..install.cmd 557B
..install.cmd 551B
..install.cmd 551B
..install.cmd 549B
..install.cmd 543B
..install.cmd 539B
..install.cmd 535B
..install.cmd 533B
..install.cmd 531B
..install.cmd 525B
..install.cmd 524B
..install.cmd 519B
..install.cmd 518B
..install.cmd 505B
..install.cmd 481B
cs_CZ 89KB
stab.def 9KB
dz_BT 58KB
el_GR 6KB
en_BW 3KB
en_DK 5KB
es_BO 5KB
es_CO 5KB
es_CR 5KB
es_GT 5KB
es_MX 5KB
es_PE 5KB
es_SV 5KB
fr_FR@euro 1KB
fr_LU 5KB
ga_IE@euro 1KB
gconv-modules 55KB
gencat 66KB
getconf 41KB
getent 58KB
gu_IN 6KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
weixin_46191137
- 粉丝: 1348
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功