zoukankan      html  css  js  c++  java
  • STL array

     先声明,这个STL 容器很少有人使用,因为必须要指定大小,一般都用vector或list 了。

    template < class T, size_t N > class array;

    Container properties

    Sequence
    Elements in sequence containers are ordered in a strict linear sequence. Individual elements are accessed by their position in this sequence.
    Contiguous storage(连续的)
    The elements are stored in contiguous memory locations, allowing constant time random access to elements. Pointers to an element can be offset to access other elements.
    Fixed-size aggregate(集合,聚集)
    The container uses implicit constructors and destructors to allocate the required space statically. Its size is compile-time constant. No memory or time overhead.
    用法和vector差不多:
    // array::begin example
    #include <iostream>
    #include <array>
    
    int main ()
    {
      std::array<int,5> myarray = { 2, 16, 77, 34, 50 };
    
      std::cout << "myarray contains:";
      for ( auto it = myarray.begin(); it != myarray.end(); ++it )
        std::cout << " " << *it;
    
      std::cout << std::endl;
    
      return 0;
    }
  • 相关阅读:
    iTestin云测试工具
    android 存储操作 大小显示换算 kb mb KB MB 读取
    android 发送短信 判断号码规则 判断字符数70
    android 震动 各种
    10.13总结
    10.8每日总结
    10.9
    10.15
    10.14
    10.12每日总结
  • 原文地址:https://www.cnblogs.com/youxin/p/2592318.html
Copyright © 2011-2022 走看看