title: Non-recursive implementation of Flood Fill algorithm?
body: <p>I'm working on a small drawing application in Java. I'm trying to create a 'bucket-fill' tool by implementing the Flood Fill algorithm.</p>
  
  <p>I tried using a recursion implementation, but it was problematic. Anyway, I searched around the web and it seems that for this purpose, a <strong>non-recursive</strong> implementation of this algorithm is recommended.</p>
  
  <p>So I ask you:</p>
  
  <p>Could you describe a <strong><em>non-recursive</em> implementation of the Flood Fill algorithm</strong>? An actual code example, some pseudo-code, or even a general explanation will all be welcome.</p>
  
  <p>I'm looking for simplest, <strong>or</strong> the most efficient implementation you can think of.</p>
  
  <p><em>(Doesn't have to be Java specific).</em></p>
  
  <p>Thank you</p>