473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Access a list of vectors

Dear cpp-ians,

I have created a list of vectors and its iterator:

list < vector <long double> > listValues;
list < vector <long double> >::iterator itListValues;

but I don't know how to access the elements of that list.
I have a list of vectors with 4 elements. The size of my list is 500,
the size of every vector is 4.

How do I move around in that list of vectors?
E.g:
When I want to access the elements in my list that are the fourth
element in my vector?
for (itListValues = listValues.begin()[4];
itListValues < listValues.end()[4]; itListValues++)
{ *itListValues; }

This is not correct, but I don't know how to write it differently to
access the individual values of my list of vectors. Any advice?

Thank you in advance,
Stef

Jul 23 '05 #1
2 1996
steflhermitte wrote:
I have created a list of vectors and its iterator:

list < vector <long double> > listValues;
list < vector <long double> >::iterator itListValues;

but I don't know how to access the elements of that list.
I have a list of vectors with 4 elements. The size of my list is 500,
the size of every vector is 4.

How do I move around in that list of vectors?
E.g:
When I want to access the elements in my list that are the fourth
element in my vector?
for (itListValues = listValues.begin()[4];
itListValues < listValues.end()[4]; itListValues++)
{ *itListValues; }

This is not correct, but I don't know how to write it differently to
access the individual values of my list of vectors. Any advice?

for (itListValues = listValues.begin();
itListValues != listValues.end(); ++itListValues)
{
vector<long double>& v = *itListValues;
long double sum = v[0] + v[1] + v[2] + v[3];
}

V
Jul 23 '05 #2
Thank you. It works perfectly!

Stef

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Pratyush | last post by:
Hi, Suppose there is a vector of objects of class A, i.e., std::vector<A> vec_A(N); The class A satisifies all the STL vector requirements. Now I wish to add some attributes for each of the...
5
by: Computer Whizz | last post by:
I was reading through Accelerated C++ at work when I read through the first mention of Vectors, giving us certain functions etc. Is there any benefit of Arrays over Vectors? Since all Vectors...
3
by: Amit | last post by:
Hello. I am having some problem organizing a set of vectors. The vectors itself, could contain a pointer( say integer pointer) or could contain another object MyClass. 1>So, first of all, is...
4
by: Dr. J.K. Becker | last post by:
Hi all, I have vectors that holds pointers to other vectors, like so: vector<whatever> x; vector<whatever*> z; z=&x; Now I add something to x
25
by: Nudge | last post by:
Hello, Someone posted the following code to a different group: void function2(int a, int b, int c) { int exchange; char buffer; char *bufPt; buffer = 'A'; buffer = 'B';
5
by: madhu | last post by:
http://msdn2.microsoft.com/en-us/library/fs5a18ce(VS.80).aspx vector <intv1; v1.push_back( 10 ); //adds 10 to the tail v1.push_back( 20 ); //adds 20 to the tail cout << "The size of v1 is " <<...
5
by: andrewmorrey | last post by:
Hello, I've got a VC++ project containing multiple classes and a main function. In one of the class functions, it reads from a text file and places the data into a vector; //...
1
by: Rob | last post by:
How would I do this? I want to be able to handle vectors of many different types of data and vectors that can contain any number of other vectors of data. Currently, I have a templated...
36
by: pereges | last post by:
Hi, I am wondering which of the two data structures (link list or array) would be better in my situation. I have to create a list of rays for my ray tracing program. the data structure of ray...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.