|
привет Igor,
I agree it's more elegant and therefore more appealing. The problem about efficiency is that one has to determine how the code will be used. If the list reversal would be done infrequently, a recursive and interative solution would work equally. However, if the reversal was being done in a loop, we'd be better off with a an interative approach.
In my experience, a decision to suggest a code change during a code review hinges on these factors (I'm sure there are more), in descending order of importance:
- Is the code clear and easy to maintain?
- Can it be made to run faster?
- Can it be used to take less space?
Cheers,
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi Ravi (surfed all the net to find out how it should be in Hindi and doesn't found any wroking online English->Hindi translator =).
I'm 100% agree with you that that code is only looks great - in real practice I'd better use something more easy to understand and therefore to maintain.
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor@soukhov.com | ICQ:57404554 | http://soukhov.com
|
|
|
|
|
...and of course,
- Is the code correct?
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
|
Thank you Igor for your response.
In my original post, I was saying that I didn't use any data structure like the stack because it's supposed to save memory and be efficient (for efficient code, my personal view is that it solves the problem in less cycles of the processor in question, and saves as many resources as it can).
Your code is very elegant and effcient (from my own perspective), but I'm affraid that it would be rejected anyway based on the fact that it is using the system's stack for the recursion (Alas, a data structure), and dereferencing the double pointer takes some more time than dereferencing a single pointer.
I could imagine that this will be the response from the person who asked me to do such a function.
Just to be fair, I had requested to code another function related to binary trees, and guess what? I used recursion but had the same feedback
|
|
|
|
|
Don't waste your time with the person who rejects these "classic" solutions.
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor@soukhov.com | ICQ:57404554 | http://soukhov.com
|
|
|
|
|
Hello,
I'm writing the specs for my next project (well not really, I'm going through them in my head ), and I'm curious. Does anyone here know how to compile a dialog (or window) at runtime to an exe?
The project I'm considering writing is an autoplay type thingie (like demoshield(TM)). However, I'm lost as to how I would be able to compile an exe from a project file and have it work at runtime without an INI file or something.
Just looking for guidance, not necessarily code.
As always, thanks.
Frank
|
|
|
|
|
The MSDN has a code snippet on how to create a dialog template - I used it the other day because we're writing a GUI library exposed through a Python console. Is that what you mean ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
|
The MSDN sample is called DLGTEMPL, you can get it from msdn.microsoft.com if you don't have msdn on your PC. I'd post some code for you, but it's Saturday morning and it's all at work
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Howdy all,
I've been stumped on something for a while now. I've got a CEdit subclass that I'm writing to change all sorts of nifty colors, but I can't seem to change the color (usually blue) that gets drawn as the background for text that gets highlighted. I've tried setting a breakpoint in the OnChildNotify function (which as I understand gets ALL messages) but it doesn't even trigger when I highlight text. Is changing the behavior something that I'm unable to do (maybe it's internal to windows)? Any ideas - if nothing else I'd just like to get to the bottom of it and satisfy my curious mind...
Thanks,
Dave
|
|
|
|
|
I think you want COLOR_HIGHLIGHT. This is a global setting so would have to be careful to reset it when finished. GetSysColor/SetSysColor
|
|
|
|
|
Hi Every one...
In debug Mode my application compiles properly and give
perfect out put.
But when i try to compile it in Relese Mode , It gives
Linking error.
Specified as below.
/////
error LNK2001: unresolved external symbol "char const *
const _afxPchNil" (?_afxPchNil@@3PBDB)
fatal error LNK1120: 1 unresolved externals
///
Can neone guide me for the same ..
Thanks in advance
Stago
|
|
|
|
|
Check your project settings, make sure your not missing a library or header in the release settings.
|
|
|
|
|
Hi,
i developped a class derived from static to represent real time data chart. To do this i used BitBlt.
I want to port this to an activeX control bun when I create an activeX with the wizard, i cannot accomplish Bit blitting.
Does someone have a solution ?
|
|
|
|
|
In classwizard generated code I find the following comment:
// Do not call CDialog::OnPaint() for painting messages
I don't really get it. What is the OnPaint function used for if not for painting? Is this the correct place to put my code for redrawing the window?
Do I update controls from here?
Could someone enlighten me on this?
Thanks
Josh
josh@that-guy.net
|
|
|
|
|
yes, you can use it for painting. just don't call it yourself (do an Invalidate, if you want to force a redraw)
if you update controls there, your controls will be VERY busy (it gets called a lot)
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
I'm assuming I should delegate control updates into other message handlers. Is that a better way to do it?
Josh
josh@that-guy.net
|
|
|
|
|
That line just means that you can't call the base class implementation for a WM_PAINT message, because it won't work. If you really need it, you can call it, but change CPaintDC to CClientDC in the derived class (you will lose updated region info).
I can't remember if the base implementation of OnPaint actually does something. In case it doesn't, use Default().
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Where to download e-books about "COM"?
Thanks.
Maer
|
|
|
|
|
Now I want to handle the message of WM_MOUSEWHEEL. But while I add this handler in the message processing function, the VC++ compiler tell me that
error C2065: 'WM_MOUSEWHEEL' : undeclared identifier
but the WM_MOUSEWHEEL is identified while I check in the MSDN, and no other header file is requested in the help of MSDN.
|
|
|
|
|
WM_MOUSEWHEEL is declared in winuser.h; are you #including windows.h?
|
|
|
|
|
Use this line:
#define _WIN32_WINNT 0x0500
Should work,
Jerzy
|
|
|
|
|
Use this line:
#define _WIN32_WINNT 0x0500
Why?
The Platform SDK Doc. say that it should also work under Win9x...
With that define, the application might only wotk under Win2k.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
You might need to install the Platform SDK.
It updates your headerfiles to newer versions...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|