|
|
Anonymous wrote:
If I have an array of n records. Which of them will be fast according to operations for traversing all records.
I believe MAP are much Faster!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
It is interesting that he suggested 'traverse' without specifying a constraint.
Because if he merely requires ITERATION in inserted order, how can anything be faster than 'traversing' an array? No additional pointer access or lookup required, as long as records are all of same size. Just set a pointer to beginning of array and increement it by sizeof record to get next element. Not even a list is faster than that, right? Unless pointer assignment is faster than addition ...
You have
pCurrent = pCurrent + sizeof(record)
or else
pCurrent = pCurrent->Next
A map involves much more effort, but can give you potentaily sorted items, grouped items, or a lookup by keyed items.
|
|
|
|
|
Blake Miller wrote:
Because if he merely requires ITERATION in inserted order, how can anything be faster than 'traversing' an array?
My Wrong, I want to say searching is much faster in MAP if you have a Key!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I'm looking for ways to validate a file name - as independent as possible form the file system (i.e. find out if the path is well-formed).
Is this even possible independent of knowing the file system?
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
I may be wrong, but I recall that the Boost library had such a function, although it may be a lot more basic than you want.
|
|
|
|
|
I just want to see what can be done with simple measures.
what boost does looks good
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
I want to modify a text file programmatically. Suppose it is huge in size and my desired operation on it is to modify it by adding some text in middle of File. Is there any other except the traditional one, I always use i.e. to insert the string and shift all the rest that follow the string. Can some1 please tell me a fast method other than it.
|
|
|
|
|
It depends what you mean by 'modify'. If you are inserting new text then no, there is no other way than rewriting everything after the new string.
If you are just modifying existing text then you can overwrite the part of the file you are interested in.
|
|
|
|
|
u could always read the file, split it in half where u want to write
then rewrite that to the file in the order u want
i am also curious as to how to change where the file is being written/overwritten to
|
|
|
|
|
is it after i set the button in the dialog based application manually, i still have to do programming to locate the button in a certain location in the dialog apllication?
Thx a lot 4 help.
|
|
|
|
|
could i plot a real time signal n Spectrum in the dialog based application?
Could anyone give me fast fourier transform implementation coding?
i already have coding of how to detect the sound frm mic by using sound card in pc.by hw am i gng to transform the signal in analog into digital value(is it in ascii code) to do signal processing afterward?
thx a lot for your help.
|
|
|
|
|
1. How can one find out, from which drive the actual program has been loaded from?
2. How can one find out, what kind of drive that is (floppy disk, RAMdisk, fixed volume, CDROM, etc.)? I found something re Stylebit of Removable Volume, but I did not find how to get it in C++.
Thanks
|
|
|
|
|
1. Use GetModuleFileName to get the full path to the program, then use something like splitpath to grab the drive letter.
2. Use GetDriveType
In Italy for thirty years under the Borgias they had warfare, terror, murder, bloodshed - but they produced Michelangelo, Leonardo da Vinci and the Renaissance. In Switzerland they had brotherly love, five hundred years of democracy and what did that produce - the cuckoo clock!
-- Harry Lime
|
|
|
|
|
Thankx; I was looking for just these functionalities (without knowing their names
|
|
|
|
|
I'm having trouble placing the cursor in the correct spot in an edit box after writing content to it. It would seem that after CEdit::SetWindowText() the cursor is placed at the beginning (or left side) of the edit box. I want it to be placed on the right (i.e. at the end of the text that was just written). The following code does NOT do the trick:
// m_editOffset is a CEdit and boxtext is a std::string
// which I have parsed to ensure only numeric values
<br />
m_editOffset.SetWindowText(boxtext.c_str()); <br />
// At this point the caret is placed at the leftmost
// position in the edit box. So I'll calculate
// where its new position is supposed to be:
// The correct caret 'x' position follows the pattern
// 1,7,13,19 etc.. I've already verified this.
<br />
int caretOffset = boxtext.size() * 6 + 1; <br />
m_editOffset.SetCaretPos(CPoint(caretOffset,1));<br />
Now here is the strange part. The following code DOES work the way I want:
<br />
m_editOffset.SetWindowText(boxtext.c_str());<br />
AfxMessageBox(boxtext.c_str());<br />
int caretOffset = boxtext.size() * 6 + 1; <br />
m_editOffset.SetCaretPos(CPoint(caretOffset,1));<br />
Yup, the only difference is the call to AfxMessagBox() before setting the caret position . After I get done closing the message boxes the caret magically appears in the correct position.
Does anyone know what is going on? Clearly, I cant have my users closing message boxes for no good reaso at all.
|
|
|
|
|
Use CEdit::SetSel() instead, like:
m_editOffset.SetWindowText(boxtext.c_str());
m_editOffset.SetSel(boxtext.length(), boxtext.length());
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
David,
You rule!
Minor technicality, the code needed to be:
<br />
m_editOffset.SetSel(boxtext.length(), boxtext.length(),TRUE);<br />
... as the compiler had problems resolving ambiguity in SetSel().
Now out of curiosity, does anyone know why the message box code in my originial post makes things work?
|
|
|
|
|
gremlinimp wrote:
Now out of curiosity, does anyone know why the message box code in my originial post makes things work?
Well it probably wasn't working the way you intended. What was happening was after the Message box was dismissed the edit box was receiving the focus; the windows default is to add the cursor end of an edit box.
-------------------------------
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
Interesting, so I wonder if a call to SetFocus() after setting the caret position would have worked in my original code? The code David suggested seems 'more right' than my position calculations but my curiousity is piqued nonetheless. I'm on to breaking other parts of my code at this point, but I'll be sure to play around with the SetFocus possibility in the future.
Thanks!
Oh, and I would liken debugging more to removing needles from a needlestack.
|
|
|
|
|
SetFocus is not as reliable as David’s suggestion.
gremlinimp wrote:
Oh, and I would liken debugging more to removing needles from a needlestack.
-------------------------------
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
ok, not striclty c++, but i dunno where else to put this
i have made a program in python, which gets an edit control from another program, and get's its content. Becuase its content is constly changing, what is the best method of getting the changing content.
My first thoughts were a continuous loop of some sort, but i think this will be wasteful
is there anyway of setting up something which listens and notifies my main code when changes occur?
cheers
|
|
|
|
|
Anonymous wrote:
have made a program in python, which gets an edit control from another program, and get's its content. Becuase its content is constly changing, what is the best method of getting the changing content.
if you can use Window Message in python, you can use WM_GETTEXT message to retrieve content of an edit box!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I have a Oracle 9i installed on server and Want to connect and process QUERIES, PROCEDURES AND FUNCTIONS ON IT THROUGH 3 DIFF MACHINES.
HOW TO EATABLISH A CONNECTION?
HOW TO PROCESS QUERIES?
I WANT THE ODBC DIALOG BOX TO BE CLOSED WHILE ESTABLISHING CONNECTION IE WHEN MY SYSTEM LOADS IE SYSTEM IS OPEN IT SHOULD CONNECT AUTOMATICALLY TO THE ORACLE.
i NEED TO CONNECT THROUGH SYSTEMDSN PLS PLS HELP ME IN THE CODE FOR DSN THAT SYSTEMDSN NEED TO BE CREATED ONLY ON SERVER OR EACH AND EVERY MACHINE
PLS MAIL ME URGENT
** A Fighter Never Loses !!!!
|
|
|
|
|
Hi
I'm very fresh with MFC programming.
My program works on the background, when the user clicks on a predefined hot key, the app performes the action and what I'm trying to do is to notify the user with an ok image on top of the screen for less than a second and disappear.
I tried to create a dialog without window borders with a picture control within, the problems i encountered are:
a. The picture control takes only bmp files which are can not be transparent.
b. Whenever i set the dialog as transparent it is not become on top and start to act weird.
The folowing code works fine except that the picture is not transparent.
1. When the action performed:
<br />
AfxBeginThread(notify,NULL);<br />
2. Opennig the dialog:
<br />
UINT notify(LPVOID pParam){<br />
NotifyDialog saved;<br />
saved.DoModal();<br />
return TRUE;<br />
}<br />
3. The initialization of the dialog:
<br />
BOOL NotifyDialog::OnInitDialog()<br />
{<br />
CDialog::OnInitDialog();<br />
hDlg = this->m_hWnd;
AfxBeginThread(WaitingToHideIcon,(LPVOID)NULL);<br />
return TRUE;<br />
}<br />
4. Closing the dialog:
<br />
UINT WaitingToHideIcon(LPVOID pParam){<br />
Sleep(600);<br />
EndDialog(hDlg,1);<br />
return 0;<br />
}<br />
5. The resource of the dialog and the picture control:
<br />
IDD_NOTIFYDIALOG DIALOGEX 0, 0, 58, 71<br />
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_SYSMENU<br />
EXSTYLE WS_EX_TOPMOST<br />
FONT 8, "MS Shell Dlg", 400, 0, 0x1<br />
BEGIN<br />
CONTROL 143,IDC_STATIC,"Static",SS_BITMAP | SS_CENTERIMAGE,0,0,<br />
58,71<br />
END<br />
<br />
IDB_BITMAP1 BITMAP "res\\OkHandSign.bmp"<br />
I would love to get suggestions and improvements on how to do this
Thanks a lot
Mamtz
|
|
|
|