473,407 Members | 2,314 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,407 software developers and data experts.

Which STL templates to use?

Hi all,

I am analysing a test file which documents auctions in World of
Warcraft. Its about 30MB and 500,000 lines of text.

Right now, I open the file and read it into a vector>string>. I chose
this becasue I thought it would be easier to navigate. Is there any
benefit to using ifstream instead?

When I analyse the data, I end up with quite a few tables which only
comprise of a key and a data item. For example "6661:0:0|Recipe:
Savory Deviate Delight" where "6661:0:0" is the key and "Recipe: Savory
Deviate Delight" is the value. The vector>stringis not likely to go
over 5000 in size, its entries are never changed though it can be added
to. Again I am storing these in vector>string>. Is that the best
option?

In choosing options, I am assuming that a user who palys World of
Warcraft has plenty of RAM and processing power. But if there are
benefts in terms of not using too much RAM or CPU power to an
alternative approach, I'd like to know as the main objective is to
learn C++ and the STL.

Thanks.

Patrick

Oct 26 '06 #1
1 1040
pkirk25 wrote:
Hi all,

I am analysing a test file which documents auctions in World of
Warcraft. Its about 30MB and 500,000 lines of text.

Right now, I open the file and read it into a vector>string>. I chose
this becasue I thought it would be easier to navigate. Is there any
benefit to using ifstream instead?

There are very efficient methods of processing files like this, however,
if you don't need to, worry about performance there is little need to
bother.

You need to know what your memory and cpu budget is and there has to be
a basis in fact behind it.

30MB is a little steep if you're talking about a background process that
runs all the time but if you're a gamer, it's a drop in the ocean ... so
it's not really a C++ question.

However, vector<stringis a fine way to do it, do not expect it to
break any performance expectations tho.

In the very few times I have had to have a really high performance
solution with file i/o, I has a special string type that would be set to
components of a memory mapped file. The 30MB of file does not get
copied to memory and only the components of the file that were changed
became in memory objects. Even faster is to use a binary file so that
the file in on disk has memory allocated in its own pool.

None of this stuff is C++ so we're way off topic for this NG.

The whole point is, before you worry about performance you need to make
sure you have a real problem to solve.

G
Oct 26 '06 #2

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

Similar topics

1
by: Vince C. | last post by:
Hi all, I've created XML documents that are described with a schema. I'm using those documents to create web pages. All my web pages contain a fixed header and a variable document part. The...
12
by: Fabio De Francesco | last post by:
Hello. I can't understand why I can't compile the following simple code, where I think I have applied all the needed rules for templates that are declared and defined in different files (*.h and...
2
by: jimbo_vr5 | last post by:
Hey I think i've figured out the idea behind apply-templates. But going through the tutorial on <http://www.w3schools.com/xsl/xsl_apply_templates.asp> theres simply just something that i dont...
25
by: Ted | last post by:
I'm putting the posts that follow here (hopefully they will follow here!) because they were rejected in comp.lang.c++.moderated. It behooves anyone reading them to first read the the thread of the...
34
by: Guch Wu | last post by:
Boost has many terrific libraries. But I want to know whether they are ready for using in real projects. Which of them are mature enough, or just only in progress?
7
by: Marek Zawadzki | last post by:
Hi all, In your opinion: what is current status of frameworks for PHP and which one would you choose? I am looking for an all-purpose, MVC-based framework I could learn and use for all the...
5
by: desktop | last post by:
I have this example: template<class T(1) void f( T ); template<class T(2) void f( T* ); template< (3)
104
by: JohnQ | last post by:
Well apparently not since one can step thru template code with a debugger. But if I was willing to make the concession on debugging, templates would be strictly a precompiler thing? I have a...
1
by: WebCM | last post by:
I'm looking for a good idea or ready library for templates. HTML with PHP isn't the best solution (it's more difficult for end-users of CMS to edit them). Perhaps, everything I need is: -...
7
by: Chris | last post by:
Hi All, This is a weird one but I am hoping someone can help or has some pointers, a recipe how to do the following: I have to move some code from c++ to objective-c and to do this I must...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.