Depends on what something
and do this
are. In particular, do we have to assume global (or object) state?
Consider this:
int switch(int param) {
if ( !set.contains(param) )
set.add(param);
else
set.remove(param);
}
Now the runtime clearly depends on the implementation of set
and the number of entries it has when switch
is called. Calling switch
$n$ times starting with an empty set and using pairwise distinct parameters, you might get $\omega(n)$ runtime in total, hence not all calls run in time $O(1)$.
On the other hand, if somefunction
does not access state outside of its scope -- assuming that the function itself does not have persistent state -- the runtime can only depend on param
. That does not mean runtime is in $O(1)$ -- something
and do this
may still do non-constant things. Call methods, recurse, etc.
Note that depending on the cost model you use, even adding two numbers has non-constant cost.