stringvectoriterator

    技术2022-05-11  74

         // an iterator that cannot write elements     vector<int>::const_iterator     // an iterator whose value cannot change     const vector<int>::iterator

    Table 3.2. string Operations

    s.empty()

    Returns true if s is empty; otherwise returns false

    s.size()

    Returns number of characters in s

    s[n]

    Returns the character at position n in s; positions start at 0.

    s1 + s2

    Returns a string equal to the concatenation of s1 and s2

    s1 = s2

    Replaces characters in s1 by a copy of s2

    v1 == v2

    Returns true if v1 and v2 are equal; false otherwise

    !=, <, <=, >, and >=

    Have their normal meanings

    Table 3.5. vector Operations

    v.empty()

    Returns true if v is empty; otherwise returns false

    v.size()

    Returns number of elements in v

    v.push_back(t)

    Adds element with value t to end of v

    v[n]

    Returns element at position n in v

    v1 = v2

    Replaces elements in v1 by a copy of elements in v2

    v1 == v2

    Returns TRue if v1 and v2 are equal

    !=, <, <=, >, and >=

    Have their normal meanings

    //The iterator returned by begin refers to the first element, if any, in the container: vector<int>::iterator iter = ivec.begin();//The iterator returned by the end operation is an iterator positioned "one past the end" of the vector. vector<int>::iterator iter = ivec.end();

     If the vector is empty, the iterator returned by begin is the same as the iterator returned by end.


    最新回复(0)