Which STL templates to use? | Bytes (2024)

pkirk25

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|Recip e:
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

Subscribe Reply

1 Which STL templates to use? | Bytes (1) 1049 Which STL templates to use? | Bytes (2)

Gianni Mariani

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 2554

Dynamically reusing XSLT templates across XSL files

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 header is the same in each page and is described in an XML document, "Head.xml". The document part, which is variable in content, is described in...

.NET Framework

12 1949

linker errors with templates

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 *.cpp). What amazes me is that I have already some code like this in another project where I don't get errors, so I am pretty sure I am missing...

C / C++

2 1621

xsl:apply-templates dont get it

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 get! In the following i've copy pasted the example from <http://www.w3schools.com/xsl/xsl_apply_templates.asp> into this post. I divide into sections...

.NET Framework

25 3295

Overuse of Templates

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 same subject in clc++m to get the more of the context. Ted

C / C++

34 3122

Which libraries in Boost are mature enough to be used in real applications?

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?

C / C++

7 2143

What is current status of frameworks? Which to choose?

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 applications I'll be working on in the future. Something that is currently stable and documented enough to be used in a commercial world (but it...

PHP

5 1636

Which function gets specialized?

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)

C / C++

104 4461

Are C++ templates a precompiler thing?

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 feeling the answer I'm going to get back will be "no, because templates have taken on a life of their own since their original conception and now also...

C / C++

1 1824

Template systems - which method?

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: - variables - e.g. {var} - sections or conditions (some elements won't be printed out) - loops or selecting fragments* - cache (recommended for speed) The...

PHP

7 1697

Removing Templates from Code - Best Method

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 remove all defined templates. I am not really a c++ guy so I have not worked with templates all that much (not really at all) and as such I don't have...

C / C++

7464

What is ONU?

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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...

General

7656

Problem With Comparison Operator <=> in G++

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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...

C / C++

1 7413

The easy way to turn off automatic updates for Windows 10/11

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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...

Windows Server

5968

AI Job Threat for Devs

by: agi2029 |last post by:

Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...

Career Advice

4943

Couldn’t get equations in html when convert word .docx file to html file in C#.

by: conductexam |last post by:

I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...

C# / C Sharp

3449

Trying to create a lan-to-lan vpn between two differents networks

by: TSSRALBI |last post by:

Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...

Networking - Hardware / Configuration

3440

Windows Forms - .Net 8.0

by: adsilva |last post by:

A Windows Forms form does not have the event Unload, like VB6. What one acts like?

Visual Basic .NET

1 1874

transfer the data from one system to another through ip address

by: 6302768590 |last post by:

Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

C# / C Sharp

700

Comprehensive Guide to Website Development in Toronto: Expert Insights from BSMN Consultancy

by: bsmnconsultancy |last post by:

In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

General

Which STL templates to use? | Bytes (2024)

References

Top Articles
Latest Posts
Article information

Author: Delena Feil

Last Updated:

Views: 6195

Rating: 4.4 / 5 (45 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Delena Feil

Birthday: 1998-08-29

Address: 747 Lubowitz Run, Sidmouth, HI 90646-5543

Phone: +99513241752844

Job: Design Supervisor

Hobby: Digital arts, Lacemaking, Air sports, Running, Scouting, Shooting, Puzzles

Introduction: My name is Delena Feil, I am a clean, splendid, calm, fancy, jolly, bright, faithful person who loves writing and wants to share my knowledge and understanding with you.