Click here to Skip to main content
15,912,493 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Number of characters of a string Pin
Maxwell Chen17-Dec-07 22:36
Maxwell Chen17-Dec-07 22:36 
GeneralRe: Number of characters of a string Pin
CodingLover17-Dec-07 23:01
CodingLover17-Dec-07 23:01 
JokeRe: Number of characters of a string Pin
CPallini17-Dec-07 23:12
mveCPallini17-Dec-07 23:12 
GeneralRe: Number of characters of a string Pin
CodingLover17-Dec-07 23:31
CodingLover17-Dec-07 23:31 
GeneralRe: Number of characters of a string Pin
cp987617-Dec-07 23:37
cp987617-Dec-07 23:37 
GeneralRe: Number of characters of a string Pin
CPallini18-Dec-07 0:04
mveCPallini18-Dec-07 0:04 
GeneralRe: Number of characters of a string Pin
cp987618-Dec-07 0:15
cp987618-Dec-07 0:15 
GeneralRe: Number of characters of a string Pin
CPallini18-Dec-07 0:43
mveCPallini18-Dec-07 0:43 
cp9876 wrote:
You are right, for a few cases the difference may be negligible.


In fact there is no difference at all, in the code snippet shown.


cp9876 wrote:
My understanding is that the switch statement can be optimized to O(log(N)) operations (using a tree type of search), whereas the simple cascaded if's will be O(N) operations. Obviously these could be the same but the compiler knows it can optimize a switch statement as the cases are all integer constants. I'd be interested to know the results if anyone can be bothered to do some test cases and analyse the code. It may be that the way the case statements are tested using less than operations is indicative that it would use a tree search for more cases (instead of the simple comparisons in the if construct).

OK, got the point.

Smile | :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.


GeneralRe: Number of characters of a string Pin
cp987618-Dec-07 10:07
cp987618-Dec-07 10:07 
GeneralYou're right Pin
CPallini18-Dec-07 12:33
mveCPallini18-Dec-07 12:33 
GeneralRe: Number of characters of a string Pin
CodingLover18-Dec-07 0:18
CodingLover18-Dec-07 0:18 
GeneralRe: Number of characters of a string Pin
Maxwell Chen18-Dec-07 1:16
Maxwell Chen18-Dec-07 1:16 
QuestionRe: Number of characters of a string Pin
David Crow18-Dec-07 3:20
David Crow18-Dec-07 3:20 
GeneralRe: Number of characters of a string Pin
David Crow18-Dec-07 3:30
David Crow18-Dec-07 3:30 
GeneralRe: Number of characters of a string Pin
jhwurmbach18-Dec-07 4:05
jhwurmbach18-Dec-07 4:05 
GeneralRe: Number of characters of a string Pin
David Crow18-Dec-07 4:14
David Crow18-Dec-07 4:14 
GeneralRe: Number of characters of a string Pin
jhwurmbach18-Dec-07 4:29
jhwurmbach18-Dec-07 4:29 
QuestionHow to read only the integer value of a txt file in C++ Pin
Cabomba17-Dec-07 20:20
Cabomba17-Dec-07 20:20 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Peter Weyzen17-Dec-07 20:48
Peter Weyzen17-Dec-07 20:48 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Cabomba17-Dec-07 21:36
Cabomba17-Dec-07 21:36 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Iain Clarke, Warrior Programmer17-Dec-07 23:48
Iain Clarke, Warrior Programmer17-Dec-07 23:48 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Cabomba18-Dec-07 19:50
Cabomba18-Dec-07 19:50 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Iain Clarke, Warrior Programmer18-Dec-07 23:56
Iain Clarke, Warrior Programmer18-Dec-07 23:56 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Cabomba20-Dec-07 3:51
Cabomba20-Dec-07 3:51 
GeneralRe: How to read only the integer value of a txt file in C++ Pin
Iain Clarke, Warrior Programmer20-Dec-07 23:56
Iain Clarke, Warrior Programmer20-Dec-07 23:56 

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.