title: "Programming pearls": Column 13 Searching
body: <p>From Programming Pearls: <a href="http://books.google.com/books?id=kse_7qbWbjsC&amp;pg=PA144&amp;lpg=PA144&amp;dq=programming%20pearls%20column%2013&amp;source=bl&amp;ots=DgvTDRAMcv&amp;sig=gWPqGmJ_AIs1TZPzGJ7FtXMCjNk&amp;hl=en&amp;sa=X&amp;ei=IkQbUPnpOKP20gGouYCoAg&amp;ved=0CGQQ6AEwAw#v=onepage&amp;q&amp;f=false" rel="nofollow">Column 12: Searching:</a><br>
  There are two code segments:</p>
  
  <pre><code>    IntSetList(int maxelements, int maxval)
      {   sentinel = head = new node(maxval, 0);
          n = 0;
      }
      void report(int *v)
      {   int j = 0;
          for (node *p = head; p != sentinel; p = p-&gt;next)
              v[j++] = p-&gt;val;
      }
  </code></pre>
  
  <p>I'm curious how does the <em>sentinel</em> work in the <em>report</em> function?</p>
  
  <p>If necessary, please see <a href="http://www.cs.bell-labs.com/cm/cs/pearls/sets.cpp" rel="nofollow">the complete source code</a>.</p>
  
  <p>Thanks, </p>