<?xml version="1.0" encoding="windows-1252"?>
<node id="301455" title="Re: Re: Re: Perl Idioms Explained: &amp;&amp; and || &quot;Short Circuit&quot; operators" created="2003-10-22 22:34:02" updated="2005-07-07 15:24:55">
<type id="11">
note</type>
<author id="211692">
pg</author>
<data>
<field name="doctext">
&lt;p&gt;It is correct to say C's switch is O(1).&lt;/p&gt;
&lt;p&gt;Theoritically speaking, [BrowserUK] is also wrong when he said O(1) means test once. However he had something in () said "in this case", which made himself "politically" right ;-)&lt;/p&gt;
&lt;p&gt;Strictly speaking, O(1) means that the cost is a constant, not a function of any variable, thus it is considered ideal, as the cost is 100% predictable. The complexity (worst scenario cost) of the switch statement is determined at the coding time, not base on the input data at execution time.&lt;/p&gt;
&lt;p&gt;C's switch statement falls into this category. I personally believe that there is a benefit to have it in Perl. &lt;p&gt;</field>
<field name="root_node">
301355</field>
<field name="parent_node">
301410</field>
</data>
</node>
