Thread: Handling a two character operator in a switch statement

  1. #16
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    That's a lot of wasted space in that lookup table. Perhaps a std::map would be more appropriate?

    Or you could find a perfect hash for the available operators. That would be fastest.


    But we're no longer really helping the OP.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  2. #17
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by CornedBee View Post
    That's a lot of wasted space in that lookup table. Perhaps a std::map would be more appropriate?
    Maybe, but I haven't done it with any other methods than a pure lookup table based by value.

    Quote Originally Posted by CornedBee View Post
    Or you could find a perfect hash for the available operators. That would be fastest.
    That is, if I can find a good hashing method, because I don't know one.

    Quote Originally Posted by CornedBee View Post
    But we're no longer really helping the OP.
    Ah... does it matter? We could hijack the thread for interesting discussions on doing this

  3. #18
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Quote Originally Posted by Elysia View Post
    Ah... does it matter? We could hijack the thread for interesting discussions on doing this
    Not unless I know that the OP doesn't need the thread anymore. And given the last discussion, I think this isn't the case.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using a character array in a switch question.
    By bajanElf in forum C Programming
    Replies: 10
    Last Post: 11-08-2008, 08:06 AM
  2. Getting the switch statement to work.
    By mtymightymike in forum C Programming
    Replies: 7
    Last Post: 10-15-2008, 06:32 PM
  3. switch case statement
    By stanlvw in forum C++ Programming
    Replies: 3
    Last Post: 02-26-2008, 05:06 AM
  4. switch statement that uses loop
    By mike in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2002, 05:47 PM
  5. Uh-oh! I am having a major switch problem!
    By goodn in forum C Programming
    Replies: 4
    Last Post: 11-01-2001, 04:49 PM