Which practice of iteration through containers is preferred


Posted on 16th Feb 2014 07:03 pm by admin

In the "real world" what kind of loop do most people use to iterate through a container like a vector.

A loop like this...
Code: for (int i = 0; i < v.size(); ++i) { // do whatever}Or like this...
Code: for (vector::iterator i = v.begin(); i != v.end(); ++i) { // do whatever}In addition to this question, I'm also wondering what's preferred in terms of output of a container. Iterating through its elements (like shown above) or using the copy algorithm with a stream iterator like this.

Code: ostream_iterator os(cout);copy(v.begin(), v.end(), os);Just some general coding practice questions for those in the industry. Any information is appreciated. Thanks.

No comments posted yet

Your Answer:

Login to answer
83 Like 47 Dislike
Previous forums Next forums
Other forums

What is SAP Avatar ?
Hi All,

This G.Satish , my boss asked me to explore on SAP Avatar. I searced in internet

IP Logger for Voting Script
Can anybody help me place an IP logger into my voting script?
I know that maybe it is not as secu

PHP & Java
Hello,

can PHP code be used inside java code?

Code: <SCRIPT LANGUAGE="Java

Convert .fdf to .pdf
I currently have a web form that uploads the form data to an .fdf file and emails it.

However

retrieving policy name inside the function called by this particular policy
Hi there,

I've playing around with dbms_rls package, trying to set up some security repo

How a counter of users ? such as ---> (231 Viewing)
I want to count how many users are actually viewing the page, How is that possible?
Thank you guy

session variable problem
Session variable is not working in Fire fox i am getting null value but it is working fine in IE.

Regarding accessing SQL query issued by any user in Oracle 10g
Hi all,
i want to know the queries issued by various users accessing a database...

MySQL issue
I am taking sentences through a form on page. Then checking some condition and trying to insert them

losing variables between php brackets
Hi

have got this code:
Code: $id=mysql_result($result,0,"itemid");
$title=mys

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash