|
Member functions of container are almost always either optimized or does not exists at all.
For that reason, a vector, for example, only have push_back and not push_front as it would not be efficient (would have to copy every items, every time with typical implementation).
A function that may not be optimized in some implementation is size for a list. This is the reason why empty member function should be used when we only want to knows if a STL container is empty (as this will be optimal for any container on any implementation).
Philippe Mori
|
|
|
|
|
moredip wrote:
Is it worth keeping an iterator to the end of the list and using insert( end_it, foo ),
Probably not. Perhaps you could shave off a few CPU cycles, but that's it.
or would it be just as fast, or faster, to simply use push_back( foo )?
Since any list insertion is O(1) and end() is also O(1) for a list, I think you know the answer.
|
|
|
|
|
Ok, that's what I thought.
Thanks chaps!
|
|
|
|
|
I'd say that keeping the iterator is slightly faster (one level of indirection less.) A quick look at the source code for std::list should let you know.
If you allow me to do a little advertising, my block allocator can prove useful in improving the performance of your code.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
what functions are used for:
1. create short cut file from original one?
2. update a dll file which is being used by system or other apps?
includeh10
|
|
|
|
|
1. Several of them. PJ Naughter has already done the work of bundling all the stuff into his CShellLink & CUrlShellLink v1.1.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
thank u.
i downloaded the code and had a simple look.
actually i created a similar class myself last year from com interface.
i really don't understand why microsoft doesn't offer native c function to user, instead offer COM!
i use COM for several years, i really hate it!
C++ is not VB, we don't want to be silly.
includeh10
|
|
|
|
|
|
2. If possible, rename the existing dll and place the new one in it's place. Any Win95/98 machines completely lock out dlls tho. This will only work for NT/XP machines.
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
Hi
I have a dialog box that will have two buttons, Start and Stop. I need to make sure the user has the ability to click Stop while the application is processing. I am using MFC. Could someone post some sample code.
thanks
ashish
|
|
|
|
|
i see two options:
1. use a modeless dialog with a Stop button. when start is pressed, the modeless dialog is launched and processing starts. if Stop is pressed, it sets a flag (or sends a message, or uses one of the synchronization objects, like an Event) which the processing code is watching. the processing code stops, then removes the modeless dialog. there's code on this site that explains modeless dialogs.
2. when start is pressed, start a worker thread to do the processing. when stop is pressed, your code sets a flag (sends and event, whatever) that the processing code is watching. there are some multi-threading articles here, too.
i'd probably go with 2, since it's a little cleaner. but 1 is a perfectly acceptable way to go, to (IMO)
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
Thanks. Trouble is, I have never used threads (this would be a good time to start). So where do I begin?
thanks
ashish
|
|
|
|
|
take a look here : http://www.codeproject.com/threads/. there are a few "threads for beginners" articles.
the hardest part (which isn't really hard, you just need to be careful) about multi-threading is communication between the controlling thread (your normal app) and the worker thread. the articles i glanced at all dealt with this.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
This should be easy. I am trying to add the Microsoft Communication Control to the control toolbar in Visual C.
Thanks
|
|
|
|
|
Suddenly i have discovered that menu option "New ATL Object..." is lost in my Visual Studio. What's happend? how it can be repaired? help, plz!
|
|
|
|
|
Please help me with painting the region which I've shown on the image! I've got my own CTabCtrl class and I've tried overiding the OnPaint, OnNcPaint and OnEraseBkgnd, but none of them seem to do what I want. Do I have to implement a complete ownerdraw CTabCtrl class or can I just paint that background in some other way? Please HELP!!!
click here to see the image
Dennis
MCP, MCSD
|
|
|
|
|
How do I get the contents of CString m_strData into BYTE* m_pData?
I have a edit box that has a member variable of m_strData, and I need to get the string into the m_pData variable.
Thanks
|
|
|
|
|
try this one:
CString strTemp = "Hello World";
BYTE* pByte = (BYTE*) (LPCTSTR) strTemp;
MS
|
|
|
|
|
NO!!! This is dangerous!
You need to do this:
CString strTemp = "Hello World";
BYTE* pByte = (BYTE*) strTemp.LockBuffer();
and when pByte is not needed anymore:
strTemp.UnlockBuffer();
Never cast away the const-ness of a pointer...
Concussus surgo.
When struck I rise.
|
|
|
|
|
What Martin suggested sets m_pData to point to m_strData. I interpret your question as...You want to copy the contents of m_strData to m_pData(which is already allocated).
If so you could use memcpy
or
strcpy and cast m_pData to a char*
Gary Kirkham
A working Program is one that has only unobserved bugs
|
|
|
|
|
Yes I wanted to copy the string thats held in m_strData into m_pData.. I used his suggestion and it worked fine.. I just saw the second post and will adjust my code...
Thanks everyone!
|
|
|
|
|
I am not an experienced sockets programmer, so I think I am missing something very basic. All of this is for UDP messages only.
I have a program that has two sockets set up. 1 for sending, and one for listening.
The sender is created by using the INADDR_ANY IP, and a specific port number (1594).
The listener is created by using the INADDR_ANY IP, and 0 as the port number.
This has been working for years with no problems.
I recently had to add the ability to send a broadcast UDP packet, but with a specific source address (the default would have picked the primary NIC source address, and this was causing problems).
Sending broadcasts is not the problem. This has been working for years also. It was the part where the source IP needs to be specified where problems came in.
I created another socket that uses a specific IP (10.3.2.1) as the IP, and 0 for the port number (letting a port get picked automatically). I send the message, then close the socket.
The message gets sent correctly, and a response does come back (using a sniffer to see this).
The problem is that my listener socket does not see the reply.
Since the only addition to the otherwise working application was the new (temporary) socket to send the broadcast, I'm wondering why this reply is not seen by the listener socket?
I'm hoping someone will be able to see a basic flaw in my thinking.
Thanks.
|
|
|
|
|
Anonymous wrote:
The problem is that my listener socket does not see the reply.
Do you really try to recieve from the right interface? Have you called bind to bind the listening socket to the interface the data is really coming in on, or are you just listening on the "default" interface?
|
|
|
|
|
The bind for the listening socket is passed the ANY_ADDR, and 0 for the port number. When I do a recvfrom on this type of bind, does this rcv everything, or only messages that haven't been directed to other more specific binds?
Thanks again.
|
|
|
|
|
I'm a little confused following your story and I am no expert either but I have written some small apps in VB to send and receive UDP datagrams. You must be using some sort of user defined 2-way UDP communication cause I don't know what you meant about a reply.
Anonymous wrote:
The listener is created by using the INADDR_ANY IP, and 0 as the port number.
Doesn't the listening port number have to be the same as the transmit port?
In my apps, one box sends UDP broadcast using port XYZ, my other app listens using port XYZ. Of course they both have to be on the same subnet. I tried before using different subnets and it wouldn't work.
|
|
|
|