C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

STL VECTOR

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Sue
Guest





PostPosted: Wed Feb 15, 2006 2:49 am    Post subject: STL VECTOR Reply with quote



I need to use STL vectors. Especially, I need limited number of vectors(more
than 10)

Is it possible to use array of STL vectors?

How to make it?
Back to top
Marco Wahl
Guest





PostPosted: Sat Feb 18, 2006 10:06 am    Post subject: Re: STL VECTOR Reply with quote



"Sue" <suejlee (AT) stanford (DOT) edu> writes:

Quote:
I need to use STL vectors. Especially, I need limited number of vectors(more
than 10)

Is it possible to use array of STL vectors?

It is possible to use an array of STL vectors.

Quote:
How to make it?

Let's say your limit is 42.

The following program is an example for 42 vectors stored in an array.

[[[
#include <vector>
using std::vector;
int main() {
vector<short> v[42];
return 0;
}
]]]
Back to top
Jacek Dziedzic
Guest





PostPosted: Sat Feb 18, 2006 11:06 am    Post subject: Re: STL VECTOR Reply with quote



Sue wrote:
Quote:
I need to use STL vectors. Especially, I need limited number of vectors(more
than 10)

Is it possible to use array of STL vectors?

Why not a STL vector of STL vectors?

Quote:
How to make it?

std::vector< std::vector< foo > > bar;

HTH,
- J.
Back to top
Ivan Vecerina
Guest





PostPosted: Tue Aug 22, 2006 9:11 am    Post subject: Re: STL vector Reply with quote

"Christian Christmann" <plfriko (AT) yahoo (DOT) de> wrote in message
news:pan.2006.08.17.10.49.02.445669 (AT) yahoo (DOT) de...
: On Thu, 17 Aug 2006 12:37:26 +0200, Christian Christmann wrote:
[...]
: Sorry, that's just half the truth. What I actually need is:
: A new element has to be inserted into an STL vector before an
: element that is specified by its position in the form of an
: integer value.
[...]
: So, IMHO, the insertion should look like this:
:
: myVector.insert( find( myVector.begin(), myVector.end(),
: myVector.at(n) ), newElement );

What is the desired behavior if another element equal to myVector[n]
is present earlier in the vector?

: Looks somehow cumbersome. ;-)

It seems easier to write:
myVector.insert( myVector.begin()+n, newElement );


hth -Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <> http://www.brainbench.com
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.