CodeGuru: Allocators (STL)

来源:百度文库 编辑:神马文学网 时间:2024/04/28 07:00:44
FREE Security Webcast: Staying on Top of IT Threats. May 3, 2pm EDT. Protect your personnel & networks.

',1)">
IT MANAGEMENTCIO Update
DatamationeCRMGuide
DRM WatcheSecurity Planet
ITSMWatchIntranet Journal
Inside IDGrid Computing Planet
bITa PlanetIT Career Planet Planet
NETWORKINGEnterpriseNetworkingPlanet
InstantMessagingPlanetEnterpriseStorageForum
OpenNetworksTodayOpticallyNetworked
PracticallyNetworked
WEB DEVELOPMENTHTML Goodies
Javascripts.com
HARDWARE & SYSTEMSEarthWeb Hardware
SysOptVirtual Dr.
WorkstationPlanet
SOFTWARE DEVELOPMENTCodeGuru
DeveloperjGuru.com
JARSGamelan
EARTHWEBNEWS.COMBusiness
DeveloperEcommerce
EnterpriseNetworking
SecuritySpecial Reports
StorageCommentary
WirelessxSP
Stats
IT MANAGEMENT
NETWORKING
WEB DEVELOPMENT
HARDWARE & SYSTEMS
SOFTWARE DEVELOPMENT
IT NEWS

CodeGuru.com ---Articles ---Comments ---Forums Earthweb


Visual C++ / C++Visual C++ / C++ C++ » C++ » Algorithms & Formulas C++ & MFC Date & Time Managed C++ String Programming COM-based Technologies » COM-based Technologies » ATL & WTL Programming ActiveX Programming COM+ Shell Programming Controls » Controls » Button Control ComboBox Edit Control ImageList Control ListBox Control ListView Control Menu Other Controls Property Sheet Rich Edit Control Static Control Status Bar Toolbar Treeview Control Data » Data » Database Miscellaneous Frameworks » Frameworks » UI & Printing Frameworks Graphics & Multimedia » Graphics & Multimedia » Bitmaps & Palettes DirectX GDI Multimedia OpenGL Internet & Networking » Internet & Networking » IE Programming ISAPI Internet Protocols Network Protocols Miscellaneous » Miscellaneous » Miscellaneous Samples Security Security Standard Template Library Standard Template Library Visual Studio » Visual Studio » Add-ins & Macros Debugging Editor Tips Windows & Dialogs » Windows & Dialogs » Console Dialog Doc/View Docking Window Splitter Windows Programming » Windows Programming » CE Clipboard DLL File & Folder Help Systems Printing System Vista Win32 Sample Chapter Sample Chapter
.NET / C#.NET / C# .NET » .NET » Data & Databases Debugging Framework General General ASP.NET JScript .NET Managed C++ Net Security VS Add-Ins C# » C# » Basic Syntax Collections Controls Data & I/O Date & Time Delegates Graphics & Multimedia Internet Miscellaneous .NET 3.0 Network & Systems Web Services Sample Chapter Sample Chapter
Visual BasicVisual Basic General » General » Database Forms & Controls IDE & Language Misc System VB Graphics VB Multimedia Internet » Internet » ASP .NET Database HTML Indexing SMTP / eMail Web Services Mobile/Wireless » Mobile/Wireless » Mobile InternetToolkit Pocket PC .NET 3.0 .NET 3.0 VB Controls » VB Controls » .NET Controls VB ActiveX VB ComboBox VB Files VB ListBox VB ListView VB Other Controls VB Shell Sample Chapter Sample Chapter
Videos
Submit an Article
Discussion Forums
Resource Directory
Announcements
Book List
Book Reviews
List of Gurus
Guest Book
Technology Jobs
About Us
FAQs
Site Map

User ID:
Password:
Remember Me:

Forgot Password?
Not a member?Click here for more information and to register.




internet.commerce
Partners & Affiliates
Web Hosting
Condos For Sale
Promotional Products
Online Education
Imprinted Promotions
2007 New Cars
Business Lists
2nd Mortgage
Promote Your Website
Online Degrees
Server Racks
GPS
Home Mortgage Loans
Marketing Products
RSS Feeds
All

VC++/C++

.NET/C#

VB
See more EarthWeb Network feeds
Home >>Visual C++ / C++ >>C++ >>C++ & MFC >>Standard Template Library (STL)
Need help taming your data? Simplify storage and set I.T. free with the simple, reliable and affordable HP StorageWorks All-in-One Storage Systems.

Allocators (STL)
Rating:
Gabriel Fleseriu and Andreas Masur (view profile)
February 10, 2004
Environment:
Compilers/IDE: VC++ 6.0 SP5, Dev-C++ 5 using gcc version 3.2 (mingw special 20020817-1), KDevelop 2.0 using gcc 2.96 20000731
STL Implementations: Dinkumware for VC++ 6.0, STLport 4-5-3, GNU ISO C++ Library
Operating systems: Windows 2000 SP2, Red Hat Linux 7.2 (kernel 2.4.7-10)
Introduction
In the previous article,A Beginner‘s Tutorial For std::vector, Part 1, it was promised that the next part of the tutorial will comment on the second template parameter of the ‘std::vector‘, that is, the allocator. However, as we started digging into this topic, we realized that it is worth a stand-alone article. One of the reasons is that, after putting together a neat custom allocator and successfully testing it with ‘std::vector‘, we thought we give it a shot with ‘std::list‘, too. Boom! It did not work. So, besides talking about allocators as a concept, we will also take a look at some pitfalls you may encounter if you decide to implement one.
(continued)
',2)">

Join the Innovate on Windows Vista Program
The release of the new Windows Vista operating system offers a unique opportunity to create innovative applications that help you respond to your customer‘s needs and increase your revenue. Millions of customers will soon be looking for compatible software and solutions that fully showcase the powerful new features of Windows Vista.
Click here
Take a Break at the Windows Vista Innovation Cafi
This interactive cafi lets you play around with a bunch of Windows Vista applications--right from your browser. Try out everything from online shopping in 3D to interactive experiences that you can drop right into your Office docs. See for yourself!
Click here
Learn More About Windows Vista Partners
Discover what Windows Vista partners have to offer.
Click here
MSDN Windows Vista Developer Center
Windows Vista offers substantial new capabilities in security, performance, reliability, and manageability. It was built from the ground up with a focus on secure development, an enhanced user experience, and optimization around hardware advancements. Learn why Windows Vista is the ideal platform for your applications.
Click here
Windows Vista Forums
Ask questions, share information, or exchange ideas with others, including experts from around the globe, with these forums.
Click here
Windows Vista Security
Understand the impact that the security changes in Windows Vista may have on existing solutions and the opportunities that exist to build a new generation of secure solutions for Windows
Click here


Conclusion
This article is not only meant to teach you what a standard allocator is and how it works. It is also aimed at showing a modus operandi, when implementing extensions to the STL and when having to deal with broken compilers. Understanding how to write portable code is much more important than having some out-of-the-box allocator that won‘t outperform the standard one in the general case, anyway.
Final note: If you are wondering why ‘pool_allocator‘ performs so poorly with ‘std::list‘ under Linux: our Linux computer is much slower than the Windows 2000 one. Final-final note: If you are wondering why we do not provide complete out-of-the-box demo applications...we have decided to simply provide the necessary source code files only rather than specific Visual Studio or KDevelop projects for various reasons. Nevertheless, creating a project should be obvious...
Downloads
allocator_src.zip - Download source code.

Developing Intelligent Communications? Visit the Avaya Developer Connection Center on DevX.
Developing Intelligent Communications? Visit the Avaya Developer Connection Center on DevX.
Whitepaper: An ISV?s Guide to Achieving Business Advantage through Faster Application Problem Resolution
Generate Complete .NET Web Apps in Minutes . Download Iron Speed Designer today.
IDC Executive Brief: Beyond Toll Bypass--Assessing IP Telephony‘s Total Cost of Ownership

RATE THIS ARTICLE:   Excellent  Very Good  Average  Below Average  Poor  
(You must be signed in to rank an article. Not a member?Click here to register)

Latest Comments:
•profiling allocators under vc2003 - rboerdijk (02/07/2006)
•about 2nd time ‘push_back‘ - Honjo (09/05/2005)
•Bugs found in code... - Derek Chandler (06/23/2004)
•rebinding nicely explained - Zaccheus (04/24/2004)
•Image Links Invalid - JasonD (04/17/2004)
View All Comments
Add a Comment:
Title:
Comment:
Pre-Formatted: Check this if you want the text to display with the formatting as typed (good for source code)

(You must be signed in to comment on an article. Not a member?Click here to register)

',3)">
JupiterWeb networks:
Search JupiterWeb:
Jupitermedia Corporation has two divisions:Jupiterimages andJupiterWeb
Jupitermedia Corporate Info
Copyright 2007 Jupitermedia Corporation All Rights Reserved.
Legal Notices,Licensing,Reprints, &Permissions,Privacy Policy.
Web Hosting |Newsletters |Tech Jobs |Shopping |E-mail Offers

C++
COM-based Technologies
Controls
Data
Frameworks
Graphics & Multimedia
Internet & Networking
Miscellaneous
Standard Template Library
Visual Studio
Windows Programming
Windows & Dialogs
Sample Chapter
C#
.NET
Controls
General
Internet
Mobile/Wireless
Sample Chapter