473,796 Members | 2,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

implementing remove in std::allocator

I've made a container class over std::allocator. Also implement create,
clear, push_back
but i need some assistance on removing item from container.

do i need to create empty container and than use push_back on all items
except item i want to delete or is there
any smoother way to do that ?

would this do the job ?
template <typename T> void TVecArray<T>::r emove (iterator i)
{
alloc.destroy (i);
alloc.deallocat e (i, 1);
}

implemented code (from accelerated c++):
std::allocator< T> alloc;
void push_back(const T& t){
if (avail == limit)
grow ();
unchecked_appen d (t);
}
template <typename T> void TVecArray<T>::g row ()
{
size_type new_size = max (2 * (limit - data), ptrdiff_t(1));
iterator new_data = alloc.allocate (new_size);
iterator new_avail = std::uninitiali zed_copy (data, avail, new_data);
uncreate ();
data = new_data;
avail = new_avail;
limit = data + new_size;
}
template <typename T> void TVecArray<T>::u nchecked_append (const T& val)
{
alloc.construct (avail++, val);
}


Jul 22 '05 #1
0 1100

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

Similar topics

5
1867
by: Vinu | last post by:
Hi I am facing a problem in compilation the error is like this In constructor xServices::CServices<TImp>::StHoldClientList::StHoldClientList(std::set<TImp*, std::less<TImp*>, std::allocator<TImp*> >&)': : error: expected `;' before "pos" : error: `pos' undeclared (first use this function) : error: (Each undeclared identifier is reported only once for each function it appears in.)
1
5288
by: hokus | last post by:
How to code (generally) std::allocator class to use HeapAlloc function? Thanks
7
3081
by: Grahamo | last post by:
Hi, can anybody tell me where I can get the boiler plate code for std::allocator. I need to have my version of new and delete called and want to get reference code. My compilers headers are all over the place with #ifdefs and what not, I'd like a clean copy. thanks much
13
9679
by: kamaraj80 | last post by:
Hi I am using the std:: map as following. typedef struct _SeatRowCols { long nSeatRow; unsigned char ucSeatLetter; }SeatRowCols; typedef struct _NetData
27
2178
by: Pete | last post by:
I'm doing exercise 8-2 from "Accelerated C++" where we're supposed to implement library algorithms, trying to minimize the number of iterator operations. I have two questions so far. First, it took me a while to figure out how to get accumulate() to compile correctly: // begin and begin2 must both be input iterators.
1
1670
by: silverburgh.meryl | last post by:
Hi, I have this piece of code which calls STL remove(): _aList.erase(remove(_aList.begin(), _aList.end(), bd), _aList.end()); where _aList is a 'vector<A*>' and bd is 'A*' But i get this compile error:
1
7298
by: sharmadeep1980 | last post by:
Hi All, I am facing a very unique problem while compling my project in "Release" build. The project is building in DEBUG mode but giving linking error on Release build. Here is the error: Creating library Release/fnimqcmd.lib and object Release/fnimqcmd.exp CoIMQCmd.obj : error LNK2001: unresolved external symbol
8
1895
by: Anamika | last post by:
Can I have maps with following properties? Key= A character strings... Value=A structure... Members of structure will be two character strings.... If yes how to do that?Can anyone tell me the detail syntax of that... How to compare a character string with one of the value in that structure????????
2
2731
by: pssraju | last post by:
Hi, At present application was built on solaris 9 using sun studio 9 (Sun C++ 5.6) & rouguewave sorce pro 5. We are planning to port the same application onto SuSE Linux 9.5.0 using GCC 3.3.3 & RW source pro 9. My application heavily uses RW tools through wrapper classes on the top existing RW classes. RW libraries were built using gcc on linux platform and standalong RW examples are working fine. Since the application compilation is moving...
0
9685
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, 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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10242
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10021
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9061
agi2029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7558
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4127
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
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.