Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » U ++ Vector vs STL vector
U ++ Vector vs STL vector [message #27334] Mon, 12 July 2010 22:02 Go to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Hi,

I am interested in knowing the differences, advantages and disadvantages of the Vector and vector. From the reading of the manual I am able to infer that Vector is “lighter” than vector, although I do not (full) understand the topic “deep copy constructor” and “moveable” features.

I will be grateful if someone explains me theses topics.

Thanks and best wishes.

Javier
Re: U ++ Vector vs STL vector [message #27336 is a reply to message #27334] Tue, 13 July 2010 00:13 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
“moveable” basically means that you can just "move" memory when you want to shift data in memory. You do not need to call a constructor and a destructor in a row. Such a situation happens very often when you want to resize a vector, which stores data in a continuous piece of memory. You just need to move old data into a newly allocated memory. If your data is "moveable" you can just call the memcpy() function instead of calling a copy constructor in a loop.

Hope this helps.


Regards,
Novo
Re: U ++ Vector vs STL vector [message #27341 is a reply to message #27334] Tue, 13 July 2010 08:49 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
deep copy means the Vector data are really copied into another Vector. When you do a = b; with Vectors, b is just picked up and moved to a, leaving b "empty" in picked state. If you want true copy without picking b, you have to use deep copy. (a <<= b; is the short form I think?)
Re: U ++ Vector vs STL vector [message #27342 is a reply to message #27334] Tue, 13 July 2010 10:16 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

The main difference between Vector and vector IMHO is the speed Smile Since for Vector a=b just moves (pickes) the content, instead of copying it into the new container, it is way faster. In real life, most of the operations with containers doesn't care about the content of b after the operation. Sometimes it requires the programmer to think bit more about what he's doing, but the performance gain really pays off (See comparisons). I think I could count on my fingers how many times I had to use the deep copy operator <<=.

Honza
Re: U ++ Vector vs STL vector [message #27347 is a reply to message #27342] Tue, 13 July 2010 13:08 Go to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Another great feature is that picking be default allows you to use Vector/Array/other containers as a return type from functions. This greatly reduces the reliance on passing parameters by reference for complicated output.
Previous Topic: What is the difference between Splitter and SplitterFrame?
Next Topic: Help needed.
Goto Forum:
  


Current Time: Tue Apr 16 15:23:35 CEST 2024

Total time taken to generate the page: 0.02193 seconds