title: What is meaning of locality of data structure?
body: <p>I was reading following article,</p>
  
  <p><a href="https://msdn.microsoft.com/en-us/magazine/dn904673.aspx">What Every Programmer Should Know About Compiler Optimizations</a></p>
  
  <blockquote>
    <p>There are other important optimizations that are currently beyond the
    capabilities of any compiler—for example, replacing an inefficient
    algorithm with an efficient one, or changing the layout of a data
    structure to improve its locality.</p>
  </blockquote>
  
  <p>Does that mean if I change sequence (<em>layout</em>) of data members in class, it can affect performance?</p>
  
  <p>So,</p>
  
  <pre><code>class One
  {
  int data0;
  abstract-data-type data1;
  };
  </code></pre>
  
  <p>Differes in performance from,</p>
  
  <pre><code>class One
  {
  abstract-data-type data0;
  int data1;
  };
  </code></pre>
  
  <p>If this is true, what is rule of thumb while defining classes or data structure?</p>