乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      QQ郵箱

       步芝 2014-12-29
      Array是一個順序容器,和其他標準容器相比它的特點是容器的大小固定,順序存儲。

      1array的構造函數(shù)

      array();

      arrayconst array & right);

      2array的成員變量
                                                                    
      [L]Type Definition[/L]
          
      [L]Description[/L]
          
      [L]array::const_iterator[/L]
          
      [L]The type of a constant iterator for  the controlled sequence.[/L]
          
      [L]array::const_pointer[/L]
          
      [L]The type of a constant pointer to an  element.[/L]
          
      [L]array::const_reference[/L]
          
      [L]The type of a constant reference to an  element.[/L]
          
      [L]array::const_reverse_iterator[/L]
          
      [L]The type of a constant reverse  iterator for the controlled sequence.[/L]
          
      [L]array::difference_type[/L]
          
      [L]The type of a signed distance between  two elements.[/L]
          
      [L]array::iterator[/L]
          
      [L]The type of an iterator for the  controlled sequence.[/L]
          
      [L]array::pointer[/L]
          
      [L]The type of a pointer to an element.[/L]
          
      [L]array::reference[/L]
          
      [L]The type of a reference to an element.[/L]
          
      [L]array::reverse_iterator[/L]
          
      [L]The type of a reverse iterator for the  controlled sequence.[/L]
          
      [L]array::size_type[/L]
          
      [L]The type of an unsigned distance  between two elements.[/L]
          
      [L]array::value_type[/L]
          
      [L]The type of an element.[/L]
        





      3array的關于迭代器的成員函數(shù)

      [L]Iterators[/L]


      [L]begin  Return iterator to beginning (public member function )[/L]

      [L]end          Return iterator to end (public member function )[/L]

      [L]rbegin[/B] Return reverseiterator to reverse beginning (public member function )[/L]

      [L]rend[/B]         Returnreverse iterator to reverse end (public member function )[/L]

      [L]cbegin[/B] Returnconst_iterator to beginning (public member function )[/L]

      [L]cend[/B]   Returnconst_iterator to end (public member function )[/L]

      [L]crbegin[/B]    Returnconst_reverse_iterator to reverse beginning (public memberfunction )[/L]

      [L]crend[/B]  Returnconst_reverse_iterator to reverse end (public member function )[/L]




      4array中關于容量的函數(shù)

      [L]Capacity[/L]


      [L]size[/B]          Returnsize (public member function )[/L]

      [L]max_size[/B]       Returnmaximum size (public member function )[/L]

      [L]empty[/B]      Testwhether array is empty (public member function )[/L]


      4.1 size()函數(shù)的用法,從結果中可以看出array容量的一些端倪來。
      size_type size() const;
      #include <iostream>
      #include <array>
      int main ()
      {  
      std::array<
      int,5> myints;
      std::cout <<
      "size of myints: " << myints.size() << std::endl;

      std::cout <<
      "sizeof(myints): " <<
      sizeof(myints) << std::endl;
      return 0;
      }結果
      size of myints: 5sizeof(myints): 20
      4.2 max_size()函數(shù)的用法,說明這個函數(shù)和list中的max_size()的不同
      size_type max_size() const;
      #include <iostream>
      #include <array>
      int main ()
      {  
      std::array<
      int,10> myints;
      std::cout <<
      "size of myints: " << myints.size() << '\n';

      std::cout <<
      "max_size of myints: " << myints.max_size() << '\n';
        return 0;
      }
      結果:size of myints: 10max_size of myints: 10

      4.3 empty函數(shù)

      bool empty() const;

      5array中關于元素操作的函數(shù)

      [L]Element access[/L]


      [L]operator[][/B]     Accesselement (public member function )[/L]

      [L]at[/B]             Accesselement (public member function )[/L]

      [L]front[/B]        Accessfirst element (public member function )[/L]

      [L]back[/B]               Accesslast element (public member function )[/L]

      [L]data[/B]               Getpointer to data (public member function )[/L]


      5.1 operator[]操作符

      reference operator[](size_type off);
      const_reference operator[](size_type off) const;
      示例:
      #include <iostream>
      #include <array>
      int main ()
      {  
        std::array<
      int,10> myarray;  
        
      unsigned int i;  
        
      for (i=0; i<10; i++) myarray=i; // assign some values:  
        
      std::cout <<
      "myarray contains:";
      // print content    
      for (i=0; i<10; i++)  
        
      std::cout <<
      ' '<< myarray;

        std::cout <<
      '\n';

        
      return 0;

      }

      輸出結果:

      myarray contains: 0 1 2 3 4 5 6 7 8 9

      5.2 at()函數(shù)的用法

      reference at(size_type off);
      const_reference at(size_type off) const;

      用法:

      #include <iostream>
      #include <array>
      int main ()
      {
      std::array<
      int,10> myarray;
      for (int i=0; i<10; i++)   
          
      myarray.at(i) = i+1;
      // assign some values:
        std::cout << "myarray contains:" // print content:;
        for (int i=0; i<10; i++)    
          
      std::cout <<
      ' ' << myarray.at(i);

      std::cout <<
      '\n';
        return 0;
      }
      輸出結果:
      myarray contains: 1 2 3 4 5 6 7 8 9 10
      5.3 front函數(shù)的用法
      reference front();
      const_reference front() const;
      示例:
      #include <iostream>
      #include <array>
      int main ()
      {
      std::array<
      int,3>
      myarray = {2, 16, 77};

      std::cout <<
      "front is: " << myarray.front() << std::endl;  
      // 2  
      std::cout <<
      "back is: " << myarray.back() << std::endl;    
      // 77
      myarray.front() = 100;

      std::cout <<
      "myarray now contains:";

      for ( int& x : myarray )
      std::cout <<
      ' ' << x;
        std::cout << '\n';
        return 0;
      }
      結果:front is: 2back is: 77myarray now contains: 100 16 77
      5.4 back函數(shù)的用法reference back();
      const_reference back() const;
      關于例子,在5.3中的例子已經(jīng)包含了5.5 data函數(shù)的用法Ty *data();
      const Ty *data() const;
      返回值指向第一個元素的指針,因為是順序存儲,所以知道了首元素的指針就可以知道所有元素了。
      #include <iostream>
      #include <cstring>
      #include <array>
      int main ()
      {  
      const char* cstr = "Test string";
      std::array<
      char,12> charray;  
      std::memcpy (charray.data(),cstr,12);

      std::cout << charray.data() <<
      '\n';
        return 0;
      }
      結果:Test string6 修改元素的函數(shù)

      [L]Modifiers[/L]


      [L]fill[/B]      Fill arraywith value (public member function )[/L]

      [L]swap[/B]  Swap content (public member function )[/L]


      6.1 fill函數(shù)的用法void fill(const Type& _Val);
      函數(shù)將array中所有的元素替換成_val
      #include <iostream>
      #include <array>
      int main ()
      {

      std::array<
      int,6> myarray;
        
      myarray.fill(5);

      std::cout <<
      "myarray contains:";

        
      for ( int& x : myarray)
      { std::cout <<
      ' ' << x;
      }
        
      std::cout <<
      '\n';
        
      return 0;
      }結果:myarray contains: 5 5 5 5 5 5
      6.2 swap函數(shù)的用法void swap(array& right);
      交換兩個具有相同長度的array,切記兩個array的長度必須一致例子:
      #include <iostream>
      #include <array>
      int main ()
      {
      std::array<
      int,5> first = {10, 20, 30, 40, 50};
      std::array<
      int,5> second = {11, 22, 33, 44, 55};
        
      first.swap (second);

        
      std::cout <<
      "first:";
        for (int& x : first)
      std::cout <<
      ' ' << x;
        std::cout << '\n';
      std::cout <<
      "second:";

      for (int& x : second)
      std::cout <<
      ' ' << x;

      std::cout <<
      '\n';
        return 0;
      }
      結果
      first contains: 11 22 33 44 55second contains: 10 20 30 40 50
      參考網(wǎng)站:
      http://wenku.baidu.com/link?url=fVhoz8y-kXwhcBs1aq0-zcNe8q1lQY8NXFMI7_YWEOGlheZQBYWafojiy36qvnH_7hcrU8kDoBR5VAgnO-wm15nMtvX89C8Hq_1ghp64Cim



        本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多