/*
* Copyright 2008-2010 NVIDIA Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*! \file binary_search.h
* \brief Search for values in sorted ranges.
*/
#pragma once
#include <thrust/detail/config.h>
#include <thrust/pair.h>
namespace thrust
{
/*! \addtogroup algorithms
*/
/*! \addtogroup searching
* \ingroup algorithms
* \{
*/
/*! \addtogroup binary_search Binary Search
* \ingroup searching
* \{
*/
//////////////////////
// Scalar Functions //
//////////////////////
/*! \p lower_bound is a version of binary search: it attempts to find
* the element value in an ordered range <tt>[first, last)</tt>.
* Specifically, it returns the first position where value could be
* inserted without violating the ordering. This version of
* \p lower_bound uses <tt>operator<</tt> for comparison and returns
* the furthermost iterator \c i in <tt>[first, last)</tt> such that,
* for every iterator \c j in <tt>[first, i)</tt>, <tt>*j < value</tt>.
*
* \param first The beginning of the ordered sequence.
* \param last The end of the ordered sequence.
* \param value The value to be searched.
* \return The furthermost iterator \c i, such that <tt>*i < value</tt>.
*
* \tparam ForwardIterator is a model of <a href="http://www.sgi.com/tech/stl/ForwardIterator">Forward Iterator</a>.
* \tparam LessThanComparable is a model of <a href="http://www.sgi.com/tech/stl/LessThanComparable.html">LessThanComparable</a>.
*
* The following code snippet demonstrates how to use \p lower_bound
* to search for values in a ordered range.
*
* \code
* #include <thrust/binary_search.h>
* #include <thrust/device_vector.h>
* ...
* thrust::device_vector<int> input(5);
*
* input[0] = 0;
* input[1] = 2;
* input[2] = 5;
* input[3] = 7;
* input[4] = 8;
*
* thrust::lower_bound(input.begin(), input.end(), 0); // returns input.begin()
* thrust::lower_bound(input.begin(), input.end(), 1); // returns input.begin() + 1
* thrust::lower_bound(input.begin(), input.end(), 2); // returns input.begin() + 1
* thrust::lower_bound(input.begin(), input.end(), 3); // returns input.begin() + 2
* thrust::lower_bound(input.begin(), input.end(), 8); // returns input.begin() + 4
* thrust::lower_bound(input.begin(), input.end(), 9); // returns input.end()
* \endcode
*
* \see http://www.sgi.com/tech/stl/lower_bound.html
* \see \p upper_bound
* \see \p equal_range
* \see \p binary_search
*/
template <class ForwardIterator, class LessThanComparable>
ForwardIterator lower_bound(ForwardIterator first,
ForwardIterator last,
const LessThanComparable& value);
/*! \p lower_bound is a version of binary search: it attempts to find
* the element value in an ordered range <tt>[first, last)</tt>.
* Specifically, it returns the first position where value could be
* inserted without violating the ordering. This version of
* \p lower_bound uses function object \c comp for comparison
* and returns the furthermost iterator \c i in <tt>[first, last)</tt>
* such that, for every iterator \c j in <tt>[first, i)</tt>,
* <tt>comp(*j, value)</tt> is \c true.
*
* \param first The beginning of the ordered sequence.
* \param last The end of the ordered sequence.
* \param value The value to be searched.
* \param comp The comparison operator.
* \return The furthermost iterator \c i, such that <tt>comp(*i, value)</tt> is \c true.
*
* \tparam ForwardIterator is a model of <a href="http://www.sgi.com/tech/stl/ForwardIterator">Forward Iterator</a>.
* \tparam T is comparable to \p ForwardIterator's \c value_type.
* \tparam StrictWeakOrdering is a model of <a href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">Strict Weak Ordering</a>.
*
* The following code snippet demonstrates how to use \p lower_bound
* to search for values in a ordered range.
*
* \code
* #include <thrust/binary_search.h>
* #include <thrust/device_vector.h>
* #include <thrust/functional.h>
* ...
* thrust::device_vector<int> input(5);
*
* input[0] = 0;
* input[1] = 2;
* input[2] = 5;
* input[3] = 7;
* input[4] = 8;
*
* thrust::lower_bound(input.begin(), input.end(), 0, thrust::less<int>()); // returns input.begin()
* thrust::lower_bound(input.begin(), input.end(), 1, thrust::less<int>()); // returns input.begin() + 1
* thrust::lower_bound(input.begin(), input.end(), 2, thrust::less<int>()); // returns input.begin() + 1
* thrust::lower_bound(input.begin(), input.end(), 3, thrust::less<int>()); // returns input.begin() + 2
* thrust::lower_bound(input.begin(), input.end(), 8, thrust::less<int>()); // returns input.begin() + 4
* thrust::lower_bound(input.begin(), input.end(), 9, thrust::less<int>()); // returns input.end()
* \endcode
*
* \see http://www.sgi.com/tech/stl/lower_bound.html
* \see \p upper_bound
* \see \p equal_range
* \see \p binary_search
*/
template <class ForwardIterator, class T, class StrictWeakOrdering>
ForwardIterator lower_bound(ForwardIterator first,
ForwardIterator last,
const T& value,
StrictWeakOrdering comp);
/*! \p upper_bound is a version of binary search: it attempts to find
* the element value in an ordered range <tt>[first, last)</tt>.
* Specifically, it returns the last position where value could be
* inserted without violating the ordering. This version of
* \p upper_bound uses <tt>operator<</tt> for comparison and returns
* the furthermost iterator \c i in <tt>[first, last)</tt> such that,
* for every iterator \c j in <tt>[first, i)</tt>, <tt>value < *j</tt>
* is \c false.
*
* \param first The beginning of the ordered sequence.
* \param last The end of the ordered sequence.
* \param value The value to be searched.
* \return The furthermost iterator \c i, such that <tt>value < *i</tt> is \c false.
*
* \tparam ForwardIterator is a model of <a href="http://www.sgi.com/tech/stl/ForwardIterator">Forward Iterator</a>.
* \tparam LessThanComparable is a model of <a href="http://www.sgi.com/tech/stl/LessThanComparable.html">LessThanComparable</a>.
*
* The following code snippet demonstrates how to use \p upper_bound
* to search for values in a ordered range.
*
* \code
* #include <thrust/binary_search.h>
* #include <thrust/device_vector.h>
* ...
* thrust::device_vector<int> input(5);
*
* input[0] = 0;
* input[1] = 2;
* input[2] = 5;
* input[3] = 7;
* input[4] = 8;
*
* thrust::upper_bound(input.begin(), input.end(), 0); // returns input.begin() + 1
* thrust::upper_bound(input.begin(), input.end(), 1); // returns input.begin() + 1
* thrust::upper_bound(input.begin(), input.end(), 2); // returns input.begin() + 2
* thrust::upper_bound(input.begin(), input.end(), 3); // returns input.begin() + 2
* thrust::upper_bound(input.begin(), input.end(), 8); // returns input.end()
* thrust::upper_bound(input.begin(), input.end(), 9); // returns input.end()
* \endcode
*
* \see http://www.sgi.com/tech/stl/upper_bound.html
* \see \p lower_bound
* \see \p equal_range
* \see \p binary_search
*/
template <class ForwardIterator, class LessThanComparable>
ForwardIterator upper_bound(ForwardIterator first,
ForwardIterator last,
const LessThanComparable& value);
/*! \p upper_bound is a version of b
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Thrust v1.2是个CUDA并行算法库,含有一个类似于C++标准模板库(STL)的界面。Thrust提供了一个灵活的高级GPU编程接口,可以极大地增强开放者的生产力,可以利用Thrust迅速开发高性能的应用程序。这是一个非常重要的第三方CUDA开发库。 Thrust is a CUDA library of parallel algorithms with an interface resembling the C++ Standard Template Library (STL). Thrust provides a flexible high-level interface for GPU programming that greatly enhances developer productivity. Develop high-performance applications rapidly with Thrust!
资源推荐
资源详情
资源评论



























收起资源包目录





































































































共 348 条
- 1
- 2
- 3
- 4
资源评论


beyondht2003
- 粉丝: 2
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 软件工程师求职简历样本.docx
- 2023年计算机二级考试复习软件工程基础.doc
- 校园网综合布线设计方案模板.doc
- 试谈网络对中学生心理健康的影响(精).doc
- 基于Arduino单片机的智能家居设计.docx
- 现代物流电子商务平台建设项目可行性研究报告.doc
- 无人船UUV与无人车编队控制的避障与队形变换:虚拟结构一致性人工势场法的MATLAB编程实现
- 基于物联网技术的消防安全系统的设计.doc
- 基于51单片机的数字语音存储与回放系统设计.doc
- 软件开发专业实习报告.docx
- 工程项目管理流程图.docx
- 各种网络安全设备巡检报告.doc
- 钱月如项目管理讲座.ppt
- 灾难医学应对(网络授课).pdf
- 中级通信工程师考试题综合能力.docx
- 项目管理实务操作标准教材.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
