Are there techniques for this, or does it come down to the individual language and compiler?
+2
A:
Dictionaries, HasSets, HashTables, Associative Arrays, or similar are the thing to look for. The usually provide O(1) access to the named parameters.
Obalix
2010-03-04 12:32:59
And are positional parameters faster than O(1)?
Zubair
2010-03-04 12:44:54
No, they are also O(1) operations.
Obalix
2010-03-04 13:20:13
O(1) means constant, there is nothing really faster then O(1).
Vlad
2010-03-04 13:30:28
Ok, briliant, I see no reason to use positional parameters then
Zubair
2010-03-04 16:02:23
Goof reasons to use positional parameters is to save on typing and improve clarity of the code. This usually applies to methods that have gazillions of parameters and you are happy with most of the defaults.
Vlad
2010-03-04 17:22:04
@Zubair: Whether to use positional or named parameters depends upon teh the problem you are looking at. If you have a list that has an order and needs to be iterated over, then positional access is the way to go. If you have a dictionary (key value pairs) and the order of the items does not matter than named access is preferred. There are also constructs (e.g. SortedList in c#) that provide for both access methods at the same time (with O1 access).
Obalix
2010-03-04 18:42:40