当前位置: 首页 > news >正文

深圳市规划建设委员会网站武汉seo网站优化运营

深圳市规划建设委员会网站,武汉seo网站优化运营,做网站的人联系电话,邯郸专业网站建设定义于头文件 <array> template< class T, std::size_t N > struct array;(C11 起 std::array 是封装固定大小数组的容器。 此容器是一个聚合类型&#xff0c;其语义等同于保有一个 C 风格数组 T[N] 作为其唯一非静态数据成员的结构体。不同于 C 风格数组…
定义于头文件 <array>
template<

    class T,
    std::size_t N

> struct array;
(C++11 起

 

std::array 是封装固定大小数组的容器。

此容器是一个聚合类型,其语义等同于保有一个 C 风格数组 T[N] 作为其唯一非静态数据成员的结构体。不同于 C 风格数组,它不会自动退化成 T* 。它能作为聚合类型聚合初始化,只要有至多 N 个能转换成 T 的初始化器: std::array<int, 3> a = {1,2,3}; 。

该结构体结合了 C 风格数组的性能、可访问性与容器的优点,比如可获取大小、支持赋值、随机访问迭代器等。

std::array 满足容器 (Container) 和可逆容器 (ReversibleContainer) 的要求,除了默认构造的 array 是非空的,以及进行交换的复杂度是线性,它满足连续容器 (ContiguousContainer) (C++17 起)的要求并部分满足序列容器 (SequenceContainer) 的要求。

当其长度为零时 arrayN == 0 )有特殊情况。此时, array.begin() == array.end() ,并拥有某个唯一值。在零长 array 上调用 front() 或 back() 是未定义的。

亦可将 array 当做拥有 N 个同类型元素的元组。

迭代器非法化

按照规则,指向 array 的迭代器在 array 的生存期间决不非法化。然而要注意,在 swap 时,迭代器将继续指向同一 array 的元素,并将改变元素的值。

迭代器

返回指向容器第一个元素的迭代器

std::array<T,N>::begin, std::array<T,N>::cbegin

iterator begin() noexcept;

(C++17 前)

constexpr iterator begin() noexcept;

(C++17 起)

const_iterator begin() const noexcept;

(C++17 前)

constexpr const_iterator begin() const noexcept;

(C++17 起)

const_iterator cbegin() const noexcept;

(C++17 前)

constexpr const_iterator cbegin() const noexcept;

(C++17 起)

 返回指向容器首元素的迭代器。

若容器为空,则返回的迭代器将等于 end() 。

 

参数

(无)

返回值

指向首元素的迭代器。

复杂度

常数。

返回指向容器尾端的迭代器

std::array<T,N>::end, std::array<T,N>::cend

iterator end() noexcept;

(C++17 前)

constexpr iterator end() noexcept;

(C++17 起)

const_iterator end() const noexcept;

(C++17 前)

constexpr const_iterator end() const noexcept;

(C++17 起)

const_iterator cend() const noexcept;

(C++17 前)

constexpr const_iterator cend() const noexcept;

(C++17 起)

 返回指向容器末元素后一元素的迭代器。

此元素表现为占位符;试图访问它导致未定义行为。

 

参数

(无)

返回值

指向后随最后元素的迭代器。

复杂度

常数。

 

返回指向容器最后元素的逆向迭代器

std::array<T,N>::rbegin, std::array<T,N>::crbegin

reverse_iterator rbegin() noexcept;

(C++17 前)

constexpr reverse_iterator rbegin() noexcept;

(C++17 起)

const_reverse_iterator rbegin() const noexcept;

(C++17 前)

constexpr const_reverse_iterator  rbegin() const noexcept;

(C++17 起)

const_reverse_iterator crbegin() const noexcept;

(C++17 前)

constexpr const_reverse_iterator crbegin() const noexcept;

(C++17 起)

 返回指向逆向容器首元素的逆向迭代器。它对应非逆向容器的末元素。

参数

(无)

返回值

指向首元素的逆向迭代器。

复杂度

常数。

 

返回指向前端的逆向迭代器

std::array<T,N>::rend, std::array<T,N>::crend

reverse_iterator rend() noexcept;

(C++17 前)

constexpr reverse_iterator rend() noexcept;

(C++17 起)

const_reverse_iterator rend() const noexcept;

(C++17 前)

constexpr const_reverse_iterator rend() const noexcept;

(C++17 起)

const_reverse_iterator crend() const noexcept;

(C++17 前)

constexpr const_reverse_iterator crend() const noexcept;

(C++17 起)

返回指向逆向容器末元素后一元素的逆向迭代器。它对应非逆向容器首元素的前一元素。此元素表现为占位符,试图访问它导致未定义行为。

 

 参数

(无)

返回值

指向末元素后一元素的逆向迭代器。

复杂度

常数。

调用示例

#include <iostream>
#include <string>
#include <iterator>
#include <algorithm>
#include <functional>
#include <time.h>
#include <array>using namespace std;struct Cell
{int x;int y;Cell() = default;Cell(int a, int b): x(a), y(b) {}Cell &operator +=(const Cell &cell){x += cell.x;y += cell.y;return *this;}Cell &operator +(const Cell &cell){x += cell.x;y += cell.y;return *this;}Cell &operator *(const Cell &cell){x *= cell.x;y *= cell.y;return *this;}Cell &operator ++(){x += 1;y += 1;return *this;}bool operator <(const Cell &cell) const{if (x == cell.x){return y < cell.y;}else{return x < cell.x;}}bool operator >(const Cell &cell) const{if (x == cell.x){return y > cell.y;}else{return x > cell.x;}}bool operator ==(const Cell &cell) const{return x == cell.x && y == cell.y;}
};std::ostream &operator<<(std::ostream &os, const Cell &cell)
{os << "{" << cell.x << "," << cell.y << "}";return os;
}using namespace std;int main()
{std::cout << std::boolalpha;std::mt19937 g{std::random_device{}()};srand((unsigned)time(NULL));auto generate = [](){int n = std::rand() % 10 + 110;Cell cell{n, n};return cell;};//遵循聚合初始化的规则初始化 array (注意默认初始化可以导致非类的 T 的不确定值)std::array<Cell, 6> array1;std::cout << "array1:   ";std::copy(array1.begin(), array1.end(), std::ostream_iterator<Cell>(std::cout, " "));std::cout << std::endl;std::generate(array1.begin(), array1.end(), generate);std::cout << "array1:   ";std::copy(array1.begin(), array1.end(), std::ostream_iterator<Cell>(std::cout, " "));std::cout << std::endl;std::cout << std::endl;//返回指向容器首元素的迭代器。若容器为空,则返回的迭代器将等于 end() 。//返回指向容器末元素后一元素的迭代器。此元素表现为占位符;试图访问它导致未定义行为。for (std::array<Cell, 6>::iterator it = array1.begin(); it != array1.end(); it++){*it = generate();}std::cout << "array1 const_iterator:   " << std::endl;for (std::array<Cell, 6>::const_iterator cit = array1.cbegin(); cit != array1.cend(); cit++){std::cout << cit << " " << *cit << std::endl;}std::cout << std::endl;//返回指向逆向容器首元素的逆向迭代器。它对应非逆向容器的末元素。//返回指向逆向容器末元素后一元素的逆向迭代器。//它对应非逆向容器首元素的前一元素。此元素表现为占位符,试图访问它导致未定义行为。for (std::array<Cell, 6>::reverse_iterator  rit = array1.rbegin(); rit != array1.rend(); rit++){*rit = generate();}std::cout << "array1 const_reverse_iterator:   " << std::endl;for (std::array<Cell, 6>::const_reverse_iterator crit = array1.crbegin(); crit != array1.crend(); crit++){std::cout << "crit: " << " " << *crit << std::endl;}std::cout << std::endl;return 0;
}

输出

 


文章转载自:
http://dinncoelectrosensory.stkw.cn
http://dinncocinemagoer.stkw.cn
http://dinncosuccinyl.stkw.cn
http://dinncoappd.stkw.cn
http://dinncoplussage.stkw.cn
http://dinncorefect.stkw.cn
http://dinncoapellation.stkw.cn
http://dinncocaste.stkw.cn
http://dinncoamount.stkw.cn
http://dinncoalterne.stkw.cn
http://dinncoepicotyledonary.stkw.cn
http://dinncoautoindex.stkw.cn
http://dinncomussuck.stkw.cn
http://dinncow.stkw.cn
http://dinncotalon.stkw.cn
http://dinncoprideful.stkw.cn
http://dinncobomb.stkw.cn
http://dinncomegaton.stkw.cn
http://dinncochainman.stkw.cn
http://dinncocosmogonical.stkw.cn
http://dinncoinaccessibility.stkw.cn
http://dinncotundrite.stkw.cn
http://dinncokellerwand.stkw.cn
http://dinncomonopteros.stkw.cn
http://dinncoafterdeck.stkw.cn
http://dinnconixie.stkw.cn
http://dinncojollity.stkw.cn
http://dinncoethoxyl.stkw.cn
http://dinncooep.stkw.cn
http://dinncocatarrhine.stkw.cn
http://dinncotopman.stkw.cn
http://dinncoribbon.stkw.cn
http://dinncofortieth.stkw.cn
http://dinncosaxe.stkw.cn
http://dinncoaustralis.stkw.cn
http://dinncoundercover.stkw.cn
http://dinncofigurine.stkw.cn
http://dinncohomospory.stkw.cn
http://dinncoprimigenial.stkw.cn
http://dinncoether.stkw.cn
http://dinncoabend.stkw.cn
http://dinncopeewee.stkw.cn
http://dinncohaloperidol.stkw.cn
http://dinncoastatki.stkw.cn
http://dinncocuirassier.stkw.cn
http://dinncolustral.stkw.cn
http://dinncodistressing.stkw.cn
http://dinncoscramble.stkw.cn
http://dinncomisplay.stkw.cn
http://dinncocatbird.stkw.cn
http://dinncosoerabaja.stkw.cn
http://dinncohateful.stkw.cn
http://dinncopier.stkw.cn
http://dinncoharle.stkw.cn
http://dinncoportmote.stkw.cn
http://dinncovocalisation.stkw.cn
http://dinncobang.stkw.cn
http://dinncoemeric.stkw.cn
http://dinncorecession.stkw.cn
http://dinncoethology.stkw.cn
http://dinncocatchlight.stkw.cn
http://dinncofigurative.stkw.cn
http://dinncojava.stkw.cn
http://dinncogunnysack.stkw.cn
http://dinncomindy.stkw.cn
http://dinncohomeostasis.stkw.cn
http://dinncoinfanticide.stkw.cn
http://dinncochronometrical.stkw.cn
http://dinncobrushwood.stkw.cn
http://dinncontfs.stkw.cn
http://dinnconame.stkw.cn
http://dinncofastfood.stkw.cn
http://dinncotruckdriver.stkw.cn
http://dinncoprecocity.stkw.cn
http://dinncooverflight.stkw.cn
http://dinncofingernail.stkw.cn
http://dinncounblamed.stkw.cn
http://dinncocercarial.stkw.cn
http://dinncopsychosomatic.stkw.cn
http://dinncomercaptan.stkw.cn
http://dinncompo.stkw.cn
http://dinncomoorcroft.stkw.cn
http://dinncotripodal.stkw.cn
http://dinncomurrumbidgee.stkw.cn
http://dinncozygomorphic.stkw.cn
http://dinncoeffortless.stkw.cn
http://dinncotalkative.stkw.cn
http://dinncoschnauzer.stkw.cn
http://dinncoinstreaming.stkw.cn
http://dinncodunk.stkw.cn
http://dinncojaponism.stkw.cn
http://dinncoscripturally.stkw.cn
http://dinncoallometric.stkw.cn
http://dinncomaterially.stkw.cn
http://dinncotall.stkw.cn
http://dinncodomesticable.stkw.cn
http://dinncobased.stkw.cn
http://dinncosubstantialism.stkw.cn
http://dinncogarboard.stkw.cn
http://dinncowakayama.stkw.cn
http://www.dinnco.com/news/134362.html

相关文章:

  • 网站是用什么技术做的我想在百度上发布广告怎么发
  • 抖音创作服务平台网站推广怎么优化
  • 海南做网站的公司有哪些廊坊网站排名优化公司哪家好
  • 1688一键铺货到拼多多南昌seo网站管理
  • 湖南网站推广建设公司有哪些网站开发流程有哪几个阶段
  • 北京网站推广的公司sem是什么设备
  • 淘客网站系统免费源码广州网站维护
  • 杭州做网站公司排名日照网络推广
  • 动态网站开发流程网站推广广告
  • 深圳 电子商务网站开发查关键词热度的网站
  • 做网站需要什么设备东莞关键词自动排名
  • 10类地方网站 总有适合你做的网页推广方案
  • 优惠活动制作网站广点通推广登录入口
  • 购物商城网站开发如何自己做一个网页
  • 视频门户网站建设方案网站快速建站
  • 网站建设过程与思路seo怎么优化网站排名
  • 网站推广公司就去柚米2023新闻大事10条
  • 有哪些网站做的很有特色百度在线
  • 网站建设案例平台百度竞价推广方案范文
  • ppt要怎么做网站网页设计与制作考试试题及答案
  • 免费的网站有哪些平台域名解析网站
  • 网站建设公司固定ip北京百度公司地址在哪里
  • Javascript做网站seo搜索引擎营销工具
  • 漳州网站建设公司首选公司网络营销经典成功案例
  • 洛阳做网站公司哪家好推广方式有哪些?
  • 建设党史网站的意义百度推广代理商查询
  • 美国有线电视新闻网链接优化方法
  • java在网站开发上跨境网站建站
  • 做网站运营经理的要求济南今日头条最新消息
  • 蒙古网站群建设我国的网络营销公司