Click here to Skip to main content
15,848,555 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRun time validation in .RC file in VC++ Mfc application Pin
rajmohanpatel22-Nov-16 0:50
rajmohanpatel22-Nov-16 0:50 
AnswerRe: Run time validation in .RC file in VC++ Mfc application Pin
Jochen Arndt22-Nov-16 1:11
professionalJochen Arndt22-Nov-16 1:11 
QuestionTCP server handle Clients, std::map or array? Pin
bestbear20-Nov-16 6:03
bestbear20-Nov-16 6:03 
AnswerRe: TCP server handle Clients, std::map or array? Pin
Afzaal Ahmad Zeeshan20-Nov-16 22:36
professionalAfzaal Ahmad Zeeshan20-Nov-16 22:36 
GeneralRe: TCP server handle Clients, std::map or array? Pin
bestbear20-Nov-16 23:23
bestbear20-Nov-16 23:23 
AnswerRe: TCP server handle Clients, std::map or array? Pin
Jochen Arndt21-Nov-16 1:22
professionalJochen Arndt21-Nov-16 1:22 
GeneralRe: TCP server handle Clients, std::map or array? Pin
bestbear21-Nov-16 2:11
bestbear21-Nov-16 2:11 
GeneralRe: TCP server handle Clients, std::map or array? Pin
Jochen Arndt21-Nov-16 3:35
professionalJochen Arndt21-Nov-16 3:35 
So you have these conditions:

connect and disconnect
Seldom, single add / remove. Locking is no problem.

update
Periodically, all items must be accessed. Locking is a problem when updating requires a significant time.

query
Single? access in peridocally? short/long? intervals.
If locking is a problem depends on query frequency and number of items.

So it seems that only updating is critical. But as I understood you will update all items at once and know the max. number of items. Regardless of the choosen storage type, the first optimisation is reserving the required memory to avoid re-allocations and avoid members that use dynamic memory allocation like std::string.

So your requirements are:

  • Inserting and deleting performance is not critical
  • Iterating over all items is critical
  • Accessing single items is not critical?


When using a map, use an unordered_map because it satifies the above (fast iterating over all elements but slow iterating over a subset of the elements).

When using an array, list, or vector, you have to perform a find to access single elements (which is also there but hidden when using a map).

When using a pre-allocated C array you have to implement also functions to add and remove elements where adding is simple (append) but removing requires moving memory. But this will be probably the fastest option when iterating over all items.

But I don't think that the performance of a plain C array is much better than using a container iterator (note that you must use the iterator rather then using the at or [] operator because that result in a lookup with maps and include out of range checks with other container types).

You may implement different versions and benchmark them to see the differences. But a max. number of 10240 should be not critical.
GeneralRe: TCP server handle Clients, std::map or array? Pin
bestbear21-Nov-16 3:48
bestbear21-Nov-16 3:48 
QuestionSimple WaitForSingleObject question Pin
ForNow19-Nov-16 17:14
ForNow19-Nov-16 17:14 
AnswerRe: Simple WaitForSingleObject question Pin
Midi_Mick19-Nov-16 18:09
professionalMidi_Mick19-Nov-16 18:09 
GeneralRe: Simple WaitForSingleObject question Pin
ForNow20-Nov-16 11:48
ForNow20-Nov-16 11:48 
AnswerRe: Simple WaitForSingleObject question Pin
Midi_Mick20-Nov-16 15:17
professionalMidi_Mick20-Nov-16 15:17 
QuestionComponent "Assimp" and Export 3D Scene into Graphical File Pin
Onic77719-Nov-16 12:47
Onic77719-Nov-16 12:47 
AnswerRe: Component "Assimp" and Export 3D Scene into Graphical File Pin
leon de boer19-Nov-16 20:17
leon de boer19-Nov-16 20:17 
Questionpkg_config ?? Pin
Vaclav_18-Nov-16 15:27
Vaclav_18-Nov-16 15:27 
AnswerRe: pkg_config ?? Pin
Richard MacCutchan18-Nov-16 22:55
mveRichard MacCutchan18-Nov-16 22:55 
GeneralRe: pkg_config ?? Pin
Jochen Arndt18-Nov-16 23:54
professionalJochen Arndt18-Nov-16 23:54 
GeneralRe: pkg_config ?? Pin
Richard MacCutchan19-Nov-16 2:21
mveRichard MacCutchan19-Nov-16 2:21 
GeneralRe: pkg_config ?? Pin
Vaclav_19-Nov-16 10:29
Vaclav_19-Nov-16 10:29 
GeneralRe: pkg_config ?? Pin
Richard MacCutchan19-Nov-16 13:03
mveRichard MacCutchan19-Nov-16 13:03 
AnswerRe: pkg_config ?? Pin
markkuk21-Nov-16 0:39
markkuk21-Nov-16 0:39 
GeneralRe: pkg_config ?? Pin
Vaclav_21-Nov-16 5:45
Vaclav_21-Nov-16 5:45 
GeneralRe: pkg_config ?? Pin
Vaclav_29-Nov-16 9:35
Vaclav_29-Nov-16 9:35 
Question#ifdef...#endif is not working in Resource(.rc) file Pin
Member 1233569517-Nov-16 18:20
Member 1233569517-Nov-16 18:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.