|
-
July 28th, 2005, 05:03 AM
#1
Clearing ::std::vector<float>
Hi Gurus,
A real quickie here...
In the given context below, is calling the member function clear enough to clear ::std::vector<float> such that calling size() returns zero?
Code:
bool c_ieee488_LeCroy_Waverunner_LT264::Waveform(const int ch, ::std::vector<float>& data) const
{
// Clear the result data vector.
data.clear();
// Build the command string.
// Go on to call resize() and collect the acquired data in the vector.
Thanks ::pow(10.0, 6.0);
(That means thanks a million)
You're gonna go blind staring into that box all day.
-
July 28th, 2005, 05:21 AM
#2
Re: Clearing ::std::vector<float>
Yes, it will empty the container logically but not necessarily physically, i.e. you cannot guarantee it will free any memory.
But why not call resize() to the new size right at the start then start filling it will values?
-
July 28th, 2005, 05:33 AM
#3
Re: Clearing ::std::vector<float>
Oh, that's a goog idea, thanks.
Instead of calling clear(), reserve(...) and using push_back(...) to manipulate the vector, I can use resize() and subsequently operator[](...).
That makes it easier and results in compacter code.
Sincerely, Chris.
You're gonna go blind staring into that box all day.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|