1,array(仅c++11支持)

固定大小的容器,不能进行扩展和缩小(vector 可以),预分配的大小只是一个参数,在编译时确定真正的大小。

Iterator 有下面几种:

begin: [ )

end:   [ )

rbegin: ( ] return reverse iterator to reverse beginning

rend:  ( ]  return reverse iterator to reverse end

cbegin:

cend: return const_iterator to end  (const_iterator 只能读取指向的元素,不能进行修改)

crbegin:

crend:

Capacity 有下面几种:

size: 容器内包含几个元素,在定义时确定的,如 arrar<int,10> 则此时 size 大小为 10 ,因为其中元素已经全被赋值了。

max_size:容器内能包含的最多元素个数,总是和 size 相同。

empty:

Element access:

operator [ ]:下标获取

at:

front:    access first  element

back:    access last element

data:     return a pointer to the firsr element in the array object.指针类型取决于容器中元素的类型,如果是 const 类型,则指针也是 const 类型。

 // array::data
#include <iostream>
#include <cstring>
#include <array> int main ()
{
const char* cstr = "Test string";
std::array<char,> charray;
std::memcpy (charray.data(),cstr,);
std::cout << charray.data() << '\n'; // Test string
return ;
}

Modifiers:

fill: 把容器内的值全部设置为 val;

 array<int,> array1;
array1.fill(); // {5,5,5,5,5}

swap: 交换两个数组的元素;

 array<int,> array1,array2;
array1.swap(array2); // 两个数组必须类型相同,大小相同,否则抛出异常

STL::array的更多相关文章

  1. Huffman树及其编码(STL array实现)

    这篇随笔主要是Huffman编码,构建哈夫曼树有各种各样的实现方法,如优先队列,数组构成的树等,但本质都是堆. 这里我用数组来存储数据,以堆的思想来构建一个哈弗曼树,并存入vector中,进而实现哈夫 ...

  2. C++ STL@ list 应用 (leetcode: Rotate Array)

    STL中的list就是一双向链表,可高效地进行插入删除元素. List 是 C++标准程式库 中的一个 类 ,可以简单视之为双向 连结串行 ,以线性列的方式管理物件集合.list 的特色是在集合的任何 ...

  3. c/c++ 模板与STL小例子系列<一 >自建Array数组

    c/c++ 模板与STL小例子系列 自建Array数组 自建的Array数组,提供如下对外接口 方法 功能描述 Array() 无参数构造方法,构造元素个数为模板参数个的数组 Array(int le ...

  4. STL - 容器 - Array

    Array是C++ 11给STL新增加的容器 ArrayTest.cpp #include <array> #include <algorithm> #include < ...

  5. 侯捷STL学习(七)--深度探索vector&&array

    layout: post title: 侯捷STL学习(七) date: 2017-06-13 tag: 侯捷STL --- 第十六节 深度探索vector vector源码剖析 vector内存2倍 ...

  6. Array的简单使用(Boost和STL通用)

    目录 目录 介绍 使用 Boost和STL的区别 介绍 本来这一次是想简单介绍一下Boost里面的协程库的使用的,但是Boost.Coroutine已经被废弃了,而Boost.Coroutine2目前 ...

  7. Leetcode 26 Remove Duplicates from Sorted Array STL

    题目本身是去重 由于我很懒,所以用了STL库里的unique函数来去重,小伙伴们可以考虑自己实现去重的函数,其实并不复杂. class Solution { public: int removeDup ...

  8. [翻译] C++ STL容器参考手册(第一章 <array>)

    返回总册 本章节原文:http://www.cplusplus.com/reference/array/array/ 1. std::array (C++11支持) template < cla ...

  9. STL容器之Array[转]

    转自https://blog.csdn.net/sin_geek/article/details/51067874 作者 Sin_Geek 简介 array在头文件<array> 中定义 ...

随机推荐

  1. mybatis三(关联查询)

    一.类属性 @Alias("depart")public class Department { private Integer id; private String departN ...

  2. JsonConvert

    ///"{'jsonParam' : " + jsonText + "}" /* Dictionary<string, object> tmp = ...

  3. 【JEECG技术文档】online自定义模板的使用

    一. 业务背景 客户需要快速开发一个信息采集的功能模块,并使用已规划好的页面,实现个性化页面展示,使用标准左右布局的Table或DIV风格的页面表现力不强,不能满足客户的个性化页面需要 二. 需求 1 ...

  4. Java工具类DateFormatUtils详解

    日期和时间格式化实用程序和常量public static String format(Calendar calendar, String pattern) 说明:将日历格式化为特定的模式:参数:cal ...

  5. 关于vector变量的size,是一个无符号数引发的bug。LeetCode 3 sum

    class Solution { public: vector<vector<int>> threeSum(vector<int>& a) { vector ...

  6. CAS无锁技术

    前言:关于同步,很多人都知道synchronized,Reentrantlock等加锁技术,这种方式也很好理解,是在线程访问的临界区资源上建立一个阻塞机制,需要线程等待 其它线程释放了锁,它才能运行. ...

  7. Visual SVN Server备份脚本

    set tt=%date:~0,4%%date:~5,2%%date:~8,2% mkdir D:\SVN_BACKUP_%tt%\Repositories xcopy C:\Repositories ...

  8. linux 排查page的状态问题

    最近遇到一个page的释放异常的问题,堆栈如下: [ 1000.691858] BUG: Bad page state in process server.o pfn:309d22 [ mapcoun ...

  9. Python正则表达式与re模块介绍

    Python中通过re模块实现了正则表达式的功能.re模块提供了一些根据正则表达式进行查找.替换.分隔字符串的函数.本文主要介绍正则表达式先关内容以及re模块中常用的函数和函数常用场景. 正则表达式基 ...

  10. LeetCode OJ 94. Binary Tree Inorder Traversal

    Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tre ...