|
Chris Hafey wrote:
and add a hash() method to std::string
Here we go again. You don't think this issue has been beaten to death by C++ experts?
Exactly WHAT would your hash aglorithm be for a string? Not everyone wants the same, and you better watch your back before introducing suggestions about introducing virtual member functions into std::basic_string to be able to overload on your personal notion of what a hash value should be. :->
Microsoft clearly could have put more effort into this, especially since >90% of hash tables use strings as keys.
Microsoft has basically NOTHING to do with this. The standard C++ (with emphasis on C++) library provided by MSVC is the Dinkumware library. Microsoft couldn't create such a work of art even if they wanted to.
But since you now have made a statement that more than 90% of the hash_table uses use a string as the key, I urge you (nay, I challange you) to prove this. I'd say you're speaking out of the south end of a north going 'ru.
In fact, I have personally never used a non string key in a hash.
And you think you should in some way be in authority when speaking about using C++ here, especially with statements like "Well I have surely never seen anything else"? Get real! You are in a forum where many use MFC and actually think it's good!!!
I urge you to read up on compl.lang.c++.moderated, and please read it a while before posting your ideas to not make a fool out of yourself.
|
|
|
|
|
I am sure this issue has been discussed in depth, in fact I bet this issue is exactly why hash_map didn't make it into the original standard. I am very well aware that different hash algorithms have different characteristics. I am also very aware that there are some which are considered very good for general purpose use. Just because there is no one algorithm that meets everyones needs doesn't mean there shouldn't be one selected as the default for strings. Besides, if someone has a need to use a different algorithm, it is just a matter of specifying it at as the third parameter.
Challenging me to proove that 90% of hash tables use strings makes you look like a fool. Can you honestly say that this is not a reasonable estimation? I never claimed to be an authority in C++, but I am a user with a very strong background in C++. This whole thread is about usability, something you seem to feel takes a backseat to design purity. Don't take me wrong, I am all for design purity, but sometimes a bit more usability for the majority is worth the expense of some purity.
Finally I urge you to think about how you responded to this thread. Your attitude was uncalled for and did nothing to help the discussion. If you think acting like an ass hole earns you respect, you have a lot to learn.
|
|
|
|
|
Chris Hafey wrote:
Just because there is no one algorithm that meets everyones needs doesn't mean there shouldn't be one selected as the default for strings.
True. But it also doesn't mean any algorithm should be selected. It would in a sense be like providing some "black box" less<T> for any type imaginable. Not a pretty sight, especially since less<t> for a hash-value for a string is with almost certainty not the same as its case-sensitive string comparison strcmp() .
Besides, if someone has a need to use a different algorithm, it is just a matter of specifying it at as the third parameter.
A third parameter to ... what?
I'm sure you are aware that predicates are by convention types, and they are given as template arguments at compile time to the class template using them. I've got a "prototype" hash_map implementation from Dinkumware here (the revision before VC7 release I believe). It has got four template parameters. There is also the problem that many implementations (of whatever standard template it might be) are given (or have taken) the freedom to append (default) template parameters to the template parameter list.
I understand the point that for usability there should possibly be a default string-hashing std function, but I also see that this is such a controversial subject that the standard perhaps is better off by not providing a "demo" implementation (remember that many of the std:: techniques are really "demonstrations" of how to do stuff).
Challenging me to proove that 90% of hash tables use strings makes you look like a fool.
It does?
You who stated "especially since >90% of hash tables use strings as keys". Are you really surprised that someone challanged that statement and asked you to back it up? Either you have proof and your statement holds, or you don't have proof.
It might be that I'm a fool sometimes, but I leave it up to you to figure out who can and who can't back their statements up in this case...
Can you honestly say that this is not a reasonable estimation?
Yes. I could also say No and it would possibly be equally true. I just don't know, and neither do you - that's my point.
From my experience it's not true. From your experience it apparently is true, but without some figures to back it up I'd still say "south end of north going 'ru".
Finally I urge you to think about how you responded to this thread.
You're right. I was having a bad day and unfortunately that showed up in my post. It was uncalled for and I apologize.
(Thanks for having a cooler head and not creating a flame-fest of it.)
|
|
|
|
|
I need the code on how to turn my computer off in C++ base programming which the can run on any DOS base system.
|
|
|
|
|
You cannot turn it off, but you can reboot.
From a 16 bit DOS program you can do this :-
void (far* reboot)() = (void (far*)())0xFFFF0000;
(*reboot)();
Hope that helped
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
You're obviously using new "PC"'s. You'll have to look deeper into ACPI AFAIK.
Best of luck. I don't envy your quest. Should you however find out something useful I hope you'll post a small CP article about it (even that it's not Win32 per se).
|
|
|
|
|
Will WinExec only execute executable files ?
Is there any other function that would call the C++ program when a button is pressed and also will allow me to pass data to the function ?
I am designing a screen in Visual C++. Any help would be appreciated.
Thank you in advance
|
|
|
|
|
All arguments have to be passed in the command line.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Hey Tim , off topic and besides the normal CSTringT discussion that we and others are having at WTL discussion group, I thank you about the tip that interlockedincrement translates to a nop instruction in ST , and I want to ask you where you learned that, you checked the assembly or you did took knowledge by other means ?
Cheers,
Joao Vaz
The Most Unhappy and Frustrated TCL programmer,besides that a Happy guy
|
|
|
|
|
Hey, that was you over there.
I looked at the machine code. Used the debugger to step into the routine.
But it isn't that it is NOPed in a ST program, it is that it is NOPed on a single processor system.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim Smith wrote:
But it isn't that it is NOPed in a ST program, it is that it is NOPed on a single processor system.
, I wanted to write that, but my head on this monday isn't at 100% after the weekend
Tim Smith wrote:
Hey, that was you over there
, didn't you discovered ??? The 2nd and further posts have my name and I exchanged some posts with you about this same issue on CP ! Are you joking or are you serious ?
Cheers,
Joao Vaz
The Most Unhappy and Frustrated TCL programmer,besides that a Happy guy
|
|
|
|
|
Heh, I will claim the same weekend clouded brain.
No, actually, I am very very bad with names. I could have sworn your name was spelled differently. But I thought it was you.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim Smith wrote:
I will claim the same weekend clouded brain
Tim Smith wrote:
I am very very bad with names
You are not alone on this
Tim Smith wrote:
But I thought it was you
Nice thought .
Cheers,
Joao Vaz
Frustrated TCL programmer,good c++ programmer wannabe
|
|
|
|
|
Along wih the name of the program itself, WinExec can pass an arbitrary number of commandline parameters --these parameters the program has be to be designed to accept. Check CCommandLineInfo for further info on commandline parms, or have a look at standard argc and argv parameters for main -based console apps.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
To pass data to an already running (Windows) program, post the target program a WM_COPYDATA message. See the online docs for more info.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
If you want a window to pop up when you click a button, you need not create a separate program for that. You can add a new dialog to your program and pop that up instead.
But if you insist on having a separate program pop up you can use ShellExecute to pop it up. Or ShellExecuteEx if you want to keep track of your spawned app.
See:- http://www.codeproject.com/useritems/newbiespawn.asp
Passing arguments to the new program is quite easy with ShellExecute/Ex
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
You must pass data in the command line. you can use 'system' insted of 'winexec'
E.g:-
system ("myapp.exe data1 data2")
Gaurika Wijeratne. // www.gaurika.com
|
|
|
|
|
Hi,
I'm using IVideoWindow to play a video, but I want the video to stop playing as soon as any key is pressed on the keyboard. I read somewhere that you need to use put_MessageDrain() to do this, but I can't get it to recognise my other window to take messages (the other window has been registered but not shown yet)...
Any ideas on how I can get the ActiveMovie Window to close on any key press?
Many thanks for any suggestions,
Keith
|
|
|
|
|
Anybody? This has me totally stumped. Incidentally, I have based my code on the "playit" sample that comes with the Dshow SDK for Directx 6.1.
Thanks,
Keith
|
|
|
|
|
Ambit wrote:
I want the video to stop playing as soon as any key is pressed on the keyboard
If you want it to stop for any key pressed, then I see but two possibilities:
- Implement it as an application that takes care of all keyboard input.
- Hook the global keyboard input handling.
I'm sure you'd be hated for doing the latter.
|
|
|
|
|
Can anyone, give set of instructions to setup a button on a visual screen to execute a (.exe) program. I already have built a .exe.
Couple of questions
1) how to let the button execute this program
2) also how will the button know where the .exe program is. In other words, how do u let the button know the path for this program.
Thank you
M
|
|
|
|
|
Read the FAQ. ShellExecute is what you're after.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
See http://www.codeproject.com/useritems/newbiespawn.asp
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
Learning wrote:
a button on Visual C++ to execute a pgm
If you just want some entry on the "IDE" of Visual C++ to execute other executables, here's the instruction:
1) Click the menu of VC++ [Tools]->[Customize...], you would see a dialog "Customize".
2) Choose the third tab "Tools", here it manages what you see in the sub-menu of Tools, like : "Register control", "Visual Component Manager", "Error lookup", etc.
3) There's a "New" button beside the "Delete" button, click it to add a new entry. Just give a name for what you want to execute, ex. "My application 003". Remember the sequence you add.
4) Then you see "Command", that's for specify the target path and filename.
5) Then you switch back to the first tab "Command", choose category "Tools", drag the icon hammer-N out. Thus you get your button!
Maxwell Chen
|
|
|
|
|
try this
void CTestdlgDlg::OnButton1()
{
// Two commands here , Both are working.
// TSys.exe is in applicatin path
WinExec("TSys.exe",SW_SHOWNORMAL);
//In a defferent path
WinExec("F:\\GauShare\\TSys.exe",SW_SHOWNORMAL);
//C++ Command
system("F:\\GauShare\\tsys.exe");
}
Gaurika Wijeratne. // www.gaurika.com
|
|
|
|