STL vectorにおけるbegin方法(3)


原文の住所:http://www.cplusplus.com/reference/vector/vector/begin/
public member function
std::vector::begin
C+98 C+11
      iterator begin();
const_iterator begin() const;
Return iterator to begining
Returns an iterator pointing to the first element in the vector
この方法は、vectorの最初の要素を指すiteratorを返します.
Notice that,unlike member vector:front,which returns a reference to the first element,this function returns a ラドm access iterator pointing to it.
なお、front()方法とは異なり、frontは最初の要素の参照を返し、beginは最初の要素を指すランダムなアクセスを返します.
If the container is empty,the returned iterator value share not be dereferenced.
vectorが空の場合は、beginを使って戻ってきたローズマリーは参照を解除されるべきではない.
たとえば:
嗳include嗳include using namespace std;int main(){vector vi;vector::iterator vb=vi.begin();cout<>
コンパイル実行結果:
STL vector中的begin方法(3)_第1张图片
参照を解除するとエラーが発生することが見られます.
パラメータ
none
パラメータ:なし
//これからはこのような超簡単な言葉は翻訳しません.
Return Value
戻り値:
An iterator to the begining of the sequence container.
この順序のコンテナの最初の要素を指すディエゼル.
If the vector object is const-qualifed,the function returns a constiterator.Otherwise,it returns an iterator.
もしこのvectorがconst属性の場合、戻り値もconst属性のものになります.そうでなければ、普通のiteratorに戻ります.
メンバーtypes iterator and constiterator エリア ラドm access iterator types(pointing to an element and to a const element、respively)
値を返します.
Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// vector::begin/end
#include 
#include 

int main ()
{
  std::vector myvector;
  for (int i=1; i<=5; i++) myvector.push_back(i);

  std::cout << "myvector contains:";
  for (std::vector::iterator it = myvector.begin() ; it != myvector.end(); ++it)
    std::cout << ' ' << *it;
  std::cout << '
'; return 0; }
Edit&Run
Output:
myvector contains: 1 2 3 4 5
Coplexity
コンサート
Iterator validity
No changes.
ローズマリーの有効性:
この方法を起動すると、他のローズマリーの有効性に影響しません.
Data races
データの競争性?(ここは正確ではないかもしれません)
The container is accessed(neither the const nor the non-const versions modify the container)
//容器は訪問をサポートする必要がありますか?(戻り値がどのジューサーであっても、容器は変更されません)
No contained elemens are accessed by the call,but the iterator returned can be used to access or modify elemens.Concerent ly accessing or modifying different elemens is safe.
//この呼び出しは、コンテナの要素(???)にアクセスしませんが、戻ってきたこのiteratorは、要素にアクセスするか、または修正するために使用されます.
Exception safety
異常安全性:
No-throw garantee: this member function never throws exceptions.
この方法は異常を投げません.
The copy construction or assignment of the returned iterator is also garanted to never throw.
この文はどう訳したらいいか分かりません.
コンストラクタをコピーするか、または(assignment of the returned iterator)のように例外を投げません.
-----------------------------------------------------------
//この文は修正されました.///2014-8-9
コピーコンストラクタや赋価演算子を利用して得られたこのiteratorも異常を投げません.
--------------------------------------------------
//翻訳の悪いところは指摘してください.または修正してください.ありがとうございます.
//2014-8-9はGDUTにあります