How to find all sequences of three in an array of values
<p>first question ever here...
I am coding a simple 3-card poker hand evaluator and am having problems finding/extracting multiple "straights" (sequential series of values) from an array of values.</p>

<p>I need to extract and return EVERY straight the array possibly has. Here's an example:</p>

<p><em>(assume array is first sorted numerically incrementing)</em></p>

<pre><code>myArray = [1h,2h,3c,3h,4c]
</code></pre>

<p>Possible three-value sequences are:
    [1h,2h,3c]
    [1h,2h,3h]
    [2h,3c,4c]
    [2h,3h,4c]</p>

<p>Here is my original code to find sequences of 3, where the array contains card objects with .value and .suit. For simplicity in this question I just put "2h" etc here:</p>

<pre><code>private var _pokerHand = [1h,2h,3c,3h,4c];
private function getAllStraights(): Array 
{
    var foundStraights:Array = new Array();
    for (var i: int = 0; i &lt; (_handLength - 2); i++) 
    {
        if ((_pokerHand[i].value - _pokerHand[i + 1].value) == 1 &amp;&amp; (_pokerHand[i + 1].value - _pokerHand[i + 2].value) == 1) 
        {
            trace("found a straight!");
            foundStraights.push(new Array(_pokerHand[i], _pokerHand[i + 1], _pokerHand[i + 2]));
        }
    }
    return foundStraights;
}
</code></pre>

<p>but it of course fails when there are value duplicates (like the 3's above). I cannot discard duplicates because they could be of different suits. I need every possible straight as in the example above. This allows me to run the straights through a "Flush" function to find "straight flush".</p>

<p>What array iteration technique am I missing?</p>