I agree, but from the standpoint of someone who needs to implement a solution(especially if it depends on your employment, for example.) ,
it will work. Giving space to think of a solution more charm.
That is, "Doing work first!"
I agree, but from the standpoint of someone who needs to implement a solution(especially if it depends on your employment, for example.) ,
it will work. Giving space to think of a solution more charm.
That is, "Doing work first!"
I hope you accept my question related to your disscussion with a time distance. The solution suggested by vcp is very important for the case, when you want to use combobox for update of the item in a database record. Very often case, when you need to limit the choice of data values by combobox and want to have a single field for the update of the item. It is one of the most frequent and needed cases in db applications. I think vcp found relatively good solution. When you are so sceptic to it, please can you advice more efficient and simpler solution? Thanks in advance for you reply, Hynek.
If there are only a few fixed items then that approach, or the OP's if-else cascade is quite fine.
If the combobox contains 10000 items then a linear search is probably not the quickest option. The more times you have to do this search the more noticeable/significant the slowdown may become. A list like that would likely have to be sorted in order to be usable by a human, and there are faster ways to search in a sorted list (binary search for example). For an unsorted list it may be an option to keep a separate hash map of text to index. As always there is a set of tradeoffs that are partly application specific.
Bookmarks