public static void FindBounds( IArrayExtra pa, out int nMin, out int nMax) // on start - nMin == any correct index in array { if (pa.Length <= 0) { throw new ArgumentException(); } int n = Int32.MaxValue; int d = pa.Length - 2; while (pa.IndexInRange(n) == false) { n -= d; } nMin = n; try { while (true) { n = pa[nMin - 1]; nMin--; } } catch (Exception e) { if ((e is IndexOutOfRangeException) == false) // ( e as IndexOutOfRangeException )== null { throw e; } } nMax = nMin + pa.Length - 1; }
public static void TestIndex( IArrayExtra pa, int nMin, int nMax) { int i; // test set for (i = nMin; i <= nMax; i++) { pa[i] = i; } // test get for (i = nMin; i <= nMax; i++) { Console.Write(" {0}", pa[i]); } Console.WriteLine(); }