 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Sue Guest
|
Posted: Wed Feb 15, 2006 2:49 am Post subject: STL VECTOR |
|
|
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
|
Posted: Sat Feb 18, 2006 10:06 am Post subject: Re: STL VECTOR |
|
|
"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.
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
|
Posted: Sat Feb 18, 2006 11:06 am Post subject: Re: STL VECTOR |
|
|
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?
std::vector< std::vector< foo > > bar;
HTH,
- J. |
|
| Back to top |
|
 |
Ivan Vecerina Guest
|
Posted: Tue Aug 22, 2006 9:11 am Post subject: Re: STL vector |
|
|
"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 |
|
 |
|
|
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
|
|