|
I would just do binary or plaintext file, put in resource, when needed load to memory and do something like Price=MemArray[index].
Igor Green
http://www.grigsoft.com/
Compare It! + Synchronize It! - files and folders comparison never was easier!
|
|
|
|
|
I don't think it would be particularly slow, actually, but the code would be really large. The compiler is likely to build a jump table rather than a sequence of if/else tests.
As to how to implement it, it depends whether the data will change over time, and if so, whether you want to allow an administrator to make the changes (in which case some form of external file access is in order). If you think the data is fixed for all time, or if a recompile is acceptable to change the values, I'd create a lookup table. Since it's 10000 values I'd probably write a program to generate the C++ file containing the lookup table! Obviously if you do this it's harder to change values, but on the other hand you won't need to write file handling and validation code, nor have to handle situations where the file is not present or inaccessible.
If you decide to go the external data route, I'd go with a file that fits in with the existing data access and the expected skill of the administrator. If data already comes from a SQL or Jet database, I'd place it there. If it's a flat file, I'd add this as an extra flat file, and so on.
Finally, if the quantity can be computed from some equation, I'd just do the computation rather than the lookup. A few years ago I might have cached the values of computations, or used lookup tables. Now processors are so much faster than RAM that computing most quantities is often quicker than retrieving a precomputed value. Obviously you need to measure this with a profiling tool.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
I recommend using a Product_Case to Price map.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
You still have to get the valuess INTO the map, so how does that provide any gains over the switch statement? Especially if the switch compiles into a jump table and not a series of if/else if type statements. However, I would accept that a MAP might be the way to go if reading of an external data source is implemented.
|
|
|
|
|
Blake Miller wrote:
You still have to get the valuess INTO the map, so how does that provide any gains over the switch statement?
The gains are in the area of maintenance, not necessarily performance.
- For large
switch statements a map lookup is easier to understand and therefore easier to maintain.
- A map lookup is more robust (i.e. less error-prone, dure to factoring) if the switch is needed more than once.
- As you have already pointed out, a map allows run-time initialization and is therefore more flexible.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hey.
I dont know where this topic should be...
I am looking for a SIMPLE description of jabber protocol.
|
|
|
|
|
|
hi ,
I want to use command line by using GetCommandLine but:
When I run my app like this:
MyApp.exe /run then get an error.
Why?
Thanks.
|
|
|
|
|
but man how are you running your application I mean what parameter is it run by.
You shoul write a registry key for this. I have a program on code project that uses this function GetCommandLine ("Little Audio Player" by euacela)
you can easily see there how to use getcommandline function. the program uses it to load a playlist just like winamp. Just by clicking on the playlist the program starts up and loads it.
gabby
|
|
|
|
|
Hi~ I'm Korean.
I can't write English..also can't read.. sorry.. ^..^
I want simple messenger source..
It will use for study of programing..
Where is a reference room in CodeProject..?
I can't find it..
Please..help me..
e-mail : larc21c@hotmail.com
^^;
|
|
|
|
|
Been busy with common controls and implemented a trackbar
(At last..it works fine !)
As I have limited skills in programming, I looked into MSDN and wonder how I can implement the buddywindows that are by default assigned to both ends of the trackbar...?
I'd like these to show two icons..I have to work with the TBM_GETBUDDY and TBM_SETBUDDY Messages but I don't know how to proceed.
Another thing is: whenever I click in the trackbar area ,a dotted line (probably the bounding rectangle) appears around the trackbar. Does anyone know how to prevent this? Should I send WM_KILLFOCUS messages or something?
Ok, enough questions. Any help would be greatly appreciated.
|
|
|
|
|
When IE downloads an exe file, it checks its signature. Does anyone know how to verify exe signature from our application ? that is, can someone help me find the source code/api to the signature verification tool ?
thanks a lot
Hari
Hari Krishnan
|
|
|
|
|
|
thanks a lot Mike, I'll check it out.
Hari
Hari Krishnan
|
|
|
|
|
Is there any such api which enlists the devices on the computer or WMI SDK is the only option.
Please give a name of the book which explains a the WMI .
A line of code is worth thousand words .If u have got such a code which enlists the devices on the computer i will be obliged.
|
|
|
|
|
Use the setupapi to enum and configure installed device drivers. It might be easier than WMI.
Don't try it, just do it!
|
|
|
|
|
Hi,
I am developing an application in VC++ in which i need to set the date and time of the System in which my application is running.
Please provide me some ways by which System date and time can be set from VC++ Application
Thanks in Advance
R.Gopalakrishnan
|
|
|
|
|
|
hi,
I am using,winsnmputils.exe for get and getnext, now i want to set snmp can u plz help me how to write the code for set.
narasimha varma p
|
|
|
|
|
how to do socket pgming using multi threading???
|
|
|
|
|
Search cp, there are lots of articles.
Don't try it, just do it!
|
|
|
|
|
I have a project on code project just to help you.
- Network Administrator by euacela
i use mutithreading to do it and winsock ofcourse
gabby
|
|
|
|
|
Hello Every Body,
I am facing problem to allocate the global memory to string, which i am going to use with WM_GETTEXT msg during interprocess communication to get text from edit box of another application.
Thanks very much.
[Vote One Here, Complete my Survey....]
Alok Gupta visit me at http://www.thisisalok.tk
"I Think Believe this Will Help"
|
|
|
|
|
Hi,
what do u mean exactly?
SkyWalker
|
|
|
|
|
Hello Sir,
actually i amn't able to use GlobalAlloc and other heap related function, I requires a good reference for that, MSDN is no help till now.
Sir,if you know any link related to memory managment,etc please refer it to me......
I am very much Thankful to u for your reply!!!
[Vote One Here, Complete my Survey....]
Alok Gupta visit me at http://www.thisisalok.tk
"I Think Believe this Will Help"
|
|
|
|