|
Well, it would work but not really what I'm looking for I considered doing this but I have to call the memset to clear the array every 4.6 secs which is one for loop (internally in machine code anyways). Then, I have to load the array, another for loop. Plus, if I only have 100 codes to enter in that time interval, I'm wasting time looping and putting empty slots. Probably, the max codes I'll have in a time interval is 500.
Actually, my data is values 0-3777 octal which is exactly 2048 bytes (2K). So, memory isn't a problem but speed checking whether one already exists in the array is. I think I will look into Christian's suggestion above, since I think a hash may be the fastest though I still will have to add elements and delete them every 4.6 seconds. However, the lookup will be tremendously faster.
|
|
|
|
|
JohnnyG wrote:
I don't really need 1204 added again, I just want some counter for 1204 to increment to 2.
Easiest way would be using map and its insert method which returns pair (details in any STL docs). First element of the pair is the iterator, second is true only if insertion took place. So if second is false, you have iterator ready for use, just increase the counter.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Tomasz Sowinski wrote:
First element of the pair is the iterator, second is true only if insertion took place.
You're saying that the it.second element is a bool with a value of false if the item has not been inserted ? I did not know that.
You've got a point though - using the reference count as the second element of the map is actually brilliant and obvious at the same time. Duh on me.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
Christian Graus wrote:
You're saying that the it.second element is a bool with a value of false if the item has not been inserted ?
Yeah. Both set and map have this insert overload. Discovering this was one of better moments in my STL-related activities
Now, if they provided us with simple case-insensitive comparisons on string
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Tomasz Sowinski wrote:
Discovering this was one of better moments in my STL-related activities
really? the examples i looked at when i was using std::map all used the pair to test success, so i've known it as long as i've known map. i guess i just assumed everyone else learned from the same examples
-c
WWJD? JWRTFM. found on /.
|
|
|
|
|
Have you read Effective C++? It has several case-insensitive comparisons for stl.
Todd Smith
|
|
|
|
|
Todd Smith wrote:
Have you read Effective C++?
You probably mean 'Effective STL'
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
std::map<int, int> mymap;
mymap[1204] += 1;
mymap[1033] += 1;
mymap[1422] += 1;
etc.
Todd Smith
|
|
|
|
|
At what point does .second get initialised to 0 ?
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
mymap[1024] calls insert(value_type(_Kv, _Ty()) where _kv and _Ty are int types. When you call int() it constucts an int initialized to 0. That's different than creating an int on the stack that doesn't get initialized. At least that's what happens on VC6 with MS-STL
Todd Smith
|
|
|
|
|
Can anyone tell me why when you add a new class or file it does not get added to VSS (like it was with VC6)? Were the developers too busy with the Excel Flight Simulator or what?
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
VSS = Visual Source Safe? Ewwww. Horrid. We switched to CVS because VSS used to be crap for multi-user projects (code shared by a team for example).
It's not like the movies. They fed us on little white lies.
|
|
|
|
|
I prefer not to automatically add a new class or file to source-safe. Only code that compiles should be added. Otherwise you end up breaking a build when somebody gets the latest code.
I'm suprised there isn't an option though.
Michael
Time flies like an arrow. Fruit flies like a banana
|
|
|
|
|
|
|
See Lounge.
Sleepy Jack the fire drill. Round and round and round and round.
|
|
|
|
|
I'm trying to use mmioOpen so a new file will be created (or truncated)
m_hFile = ::mmioOpen((LPSTR)(LPCTSTR)m_FileName,&mmioInfo, MMIO_CREATE|MMIO_WRITE|MMIO_EXCLUSIVE | MMIO_ALLOCBUF);
Sometimes mmioOpen fails. When I look in mmioInfo.wErrorRet, it's set to 257 (File not found). I can't understand why I get this error. Want to create the file, of course it doesn't exist.
But like I said sometimes this works, I haven't been able to figure out how to reproduce this.
Has anybody else run into this problem before?
|
|
|
|
|
Here's a little more info on the problem
I can create the file, record, and play from my app, but once I play the file from the explorer, then mmioOpen fails. I tried selecting a different file, but it still fails. I even tried deleting it, but it still fails. But once I hit F5, then my app will work again.
Any ideas why?
|
|
|
|
|
Ok here is a question I can't seem to find an answer to.
How can I use a command button to open up another Dialog window.
Currently want to use a Comand Button in Window A to close Window A and Open Window B...........
Anyone got any ideas? I am totally stuck
P.s. I wouldn't mind even shifting the focus (as long as the old window isn't seen) i.e. have all the windows ready but all hidden, except the one thats active.
Cheers.
P.S. If you're not living life on the edge you're taking up too much room.
From Crazy Skydiver.
|
|
|
|
|
let the window that owns dialog A handle all of it. set a flag in dlg A when the button is pushed; let the owner window check that flag; if the flag is set, have it launch dialog B.
that's how i'd do it.
-c
WWJD? JWRTFM. found on /.
|
|
|
|
|
Any chance of posting some code to do that ?
Pretty please with sugar on top (this is good magic sugar and it's not bad for your teeth)
Cheers.
P.S. If you're not living life on the edge you're taking up too much room.
From Crazy Skydiver.
|
|
|
|
|
void CMainWindow::Whatever()
{
CDialogA a;
a.DoModal();
if (a.m_flag==1)
{
CDialogB b;
b.DoModal();
}
}
....
void CDialogA::OnMagicButton()
{
m_flag = 1;
OnOK();
}
WWJD? JWRTFM. found on /.
|
|
|
|
|
I am wondering if I have gone about this project the wrong way round.
I firstly designed the displays. One intro window with some buttons, each button would take you to a different window depending on what you pressed and those windows would all have different functions and applications.
Only problem is that I can't seem to link the command button on the intro screen to open the next level.
First menu is IDD_SKYDIVE. It has several command buttons. One of which is labled Carear.
The code for it is:-
void CSkydiveDlg::OnCarear()
{
//so when the button is clicked it does whats in here..... am I right so far, and if I am right what code goes in here ?
}
I want it to open another Dialog called IDD_CAREARMODE and shut down it's own window. I think this is where I am getting mixed up.... yet I'm not exactly sure how.
Cheers.
P.S. If you're not living life on the edge you're taking up too much room.
From Crazy Skydiver.
|
|
|
|
|
Well, why don't you create a new object of the class of the dialog box that you want to open?
e.g.
put this code in the command handler of the button:
CMyDialog mydlg;
mydlg.DoModal();
Why do your need a flag after all?!
Cheers
|
|
|
|
|
because he said he wants the first dialog to go away before the second one comes up.
WWJD? JWRTFM. found on /.
|
|
|
|