zoukankan      html  css  js  c++  java
  • Dereference and Increment on vector Iterators

    Dereference and Increment on vector Iterators

    • The operations on iterator types let us retrieve element to which an iterator refers and let us move an iterator from one element to another.

    • Iterator types use the dereference operator (the * operator) to access the element to which the iterator refers:

    *iter=0;	//The effect of this statement is to assign 0 to that element
    
    • The dereference operator returns the element that the iterator currently denotes.Assuming iter refers to the first element of the vector,then *iter is the same element as ivec[0].The effect of this statement is to assign 0 to that element.

    A Program that Uses Iterators

    • Assume we had a vector named ivec and we wanted to reset each of its elements to zero.We might do so by using a subscript:
    for(vector<int>::size_type ix=0;ix!=ivec.size();++ix)
    	ivec[ix]=0;		//reset all the elements in ivec to 0
    
    • A more typical way to write this loop would use iterators:
    for(vector<int>::iterator iter=ivec.begin();iter!=ivec.end();++iter
    
    The First The Second
    subscript ['sab skript]下标
    norm 范数
  • 相关阅读:
    笔试题 1.3 百度 2012 10.09 简答题 + 程设 --A
    windows中搜索dll的顺序
    笔试题 1.2 关于大文件处理:
    笔试题 1.1 最少比赛数目
    小优化
    LightOJ
    LightOJ
    LightOJ
    LightOJ
    LightOJ
  • 原文地址:https://www.cnblogs.com/hugeng007/p/9351729.html
Copyright © 2011-2022 走看看