boost中的range与slice函数简介
来源:互联网 发布:培育发展新动力优化 编辑:程序博客网 时间:2024/06/04 19:47
1 Range<SizeType,DistanceType>
1.1 Description
The class range
specifies a range of indicies. The range is a sequence of indices from a start value to stop value. The indices increase by one and exlude the stop value.range
can therefore be used to specify ranges of elements from vectors and matrices.
1.2 Example
#include <boost/numeric/ublas/storage.hpp> //range可以确定一组下标的范围,其步长为1,没有办法人为改变。int main () { using namespace boost::numeric::ublas; range r (0, 3); for (unsigned i = 0; i < r.size (); ++ i) { std::cout << r (i) << std::endl; }}
1.3 Definition
Defined in the header storage.hpp.
1.4 Model of
Reversible Container.
1.5 Type requirements
None, except for those imposed by the requirements of ReversibleContainer.
1.6 Public base classes
None.
1.7 Members
range (size_type start, size_type stop)
Constructs a range of indicies from start
to stop (excluded)
.size_type start () const
Returns the beginning of the range
.size_type size () const
Returns the size of the range
.const_reference operator [] (size_type i)const
Returns the value start + i
of the i
-th element.range compose (const range &r) const
Returns the composite range from start + r.start()
to start + r.start () + r.size ()
.bool operator == (const range &r) const
Tests two ranges for equality.bool operator != (const range &r) const
Tests two ranges for inequality.const_iterator begin () const
Returns a const_iterator
pointing to the beginningof the range
.const_iterator end () const
Returns a const_iterator
pointing to the end ofthe range
.const_reverse_iterator rbegin () const
Returns a const_reverse_iterator
pointing to thebeginning of the reversedrange
.const_reverse_iterator rend () const
Returns a const_reverse_iterator
pointing to theend of the reversedrange
.1.8 Preconditions
start () <= stop ()
2 Slice<SizeType,DistanceType>
2.1 Description
The class slice
specifies a 'slice' of indicies. Slices are more generalthen ranges, the stride allows the sequence of indicies to increase and decrease by the specified amount between element.slice
can therefore be used to specify slices of element from vectors and matrices.
2.2 Example
#include <boost/numeric/ublas/storage.hpp> //slice的用途和range几乎相同,但是比range更加的通用,其可以指定步长,以及包含的元素个数。int main () { using namespace boost::numeric::ublas; slice s (0, 1, 3); for (unsigned i = 0; i < s.size (); ++ i) { std::cout << s (i) << std::endl; }}
2.3 Definition
Defined in the header storage.hpp.
2.4 Model of
Reversible Container.
2.5 Type requirements
None, except for those imposed by the requirements of ReversibleContainer.
2.6 Public base classes
None.
2.7 Members
slice (size_type start, size_type stride, size_typesize)
Constructs a slice start,start+stride,start+2*stride...
withsize
elements.size_type start () const
Returns the beginning of the slice
.size_type stride () const
Returns the stride of the slice
.size_type size () const
Returns the size of the slice
.const_reference operator [] (size_type i)const
Returns the value start + i * stride
of thei
-th element.slice compose (const range &r) const
Returns the composite slice from start + stride * r.start()
to start + stride * (r.start () + r.size ())
with stride stride
.slice compose (const slice &s) const
Returns the composite slice from start + stride * s.start()
to start + stride * s.stride () * (s.start () +s.size ())
with stride stride * s.stride ()
.bool operator == (const slice &s) const
Tests two slices for equality.bool operator != (const slice &s) const
Tests two slices for inequality.const_iterator begin () const
Returns a const_iterator
pointing to the beginningof the slice
.const_iterator end () const
Returns a const_iterator
pointing to the end ofthe slice
.const_reverse_iterator rbegin () const
Returns a const_reverse_iterator
pointing to thebeginning of the reversedslice
.const_reverse_iterator rend () const
Returns a const_reverse_iterator
pointing to theend of the reversedslice
.- boost中的range与slice函数简介
- Python 中的range()函数与array()函数
- Python 中的range()函数与array()函数
- Python 中的range()函数与array()函数
- Python 中的range()函数与array()函数
- javaScript 中的 slice 函数
- go slice与函数
- Python中的range()与array()函数
- python中的range与list函数
- Python中的range函数与xrange函数及生成器介绍
- Python中的range()函数
- Python中的range函数
- python中的range函数
- Python中的range函数
- Array#slice![inclusive range]
- HEVC中的条带(slice)与条带片段(slice segment)
- 简介-Boost 中的智能指针
- Python 中的range(),arange()函数
- 求助 求助 一个坦克大战重画的问题
- jsp页面传参的几种方式
- 云计算应用之Dropcam HD
- (个人笔记) java.util.logging.Logger 写日志
- mysql授权+IP登录
- boost中的range与slice函数简介
- MapReduce 程序模板 (采用 新/旧API)
- 除法表达式(数论初步) By ACReaper
- Debian 5.0.5的介绍与详细安装图解
- MSSQL如何删除字段的所有约束和索引
- windows下查看linux文件的工具--Explore2fs
- vs2010下cppunit 配置和实例
- poj2362 - Square
- VMware中安装CentOS6.4 Minimal并启用共享文件夹