title: Allowing iteration without generating any garbage
body: <p>I have the following code in an object pool that implements the IEnumerable interface.</p>
  
  <pre><code>public IEnumerable&lt;T&gt; ActiveNodes
  {
      get
      {
          for (int i = 0; i &lt; _pool.Count; i++)
          {
              if (_pool[i].AvailableInPool)
              {
                  yield return _pool[i];
              }
          }
      }
  }
  </code></pre>
  
  <p>As far as I know (according to <a href="https://stackoverflow.com/questions/5486363/ienumerable-garbage-creation">this</a> question), this will generate garbage as the IEnumerable object will need to be collected.
  None of the elements in _pool will ever be collected, as the purpose of the pool is to keep references to all of them to prevent garbage creation.</p>
  
  <p>Can anyone suggest a way to allow iteration over _pool so that no garbage is generated?</p>
  
  <p>When iterating over pool, all of the items in pool that have <code>AvailableInPool == true</code> should be iterated over. Order doesn't matter.</p>