protected internal virtual int find_among(Among[] v, int v_size)
 {
     int i = 0;
     int j = v_size;
     
     int c = cursor;
     int l = limit;
     
     int common_i = 0;
     int common_j = 0;
     
     bool first_key_inspected = false;
     
     while (true)
     {
         int k = i + ((j - i) >> 1);
         int diff = 0;
         int common = common_i < common_j?common_i:common_j; // smaller
         Among w = v[k];
         int i2;
         for (i2 = common; i2 < w.s_size; i2++)
         {
             if (c + common == l)
             {
                 diff = - 1;
                 break;
             }
             diff = current[c + common] - w.s[i2];
             if (diff != 0)
                 break;
             common++;
         }
         if (diff < 0)
         {
             j = k;
             common_j = common;
         }
         else
         {
             i = k;
             common_i = common;
         }
         if (j - i <= 1)
         {
             if (i > 0)
                 break; // v->s has been inspected
             if (j == i)
                 break; // only one item in v
             
             // - but now we need to go round once more to get
             // v->s inspected. This looks messy, but is actually
             // the optimal approach.
             
             if (first_key_inspected)
                 break;
             first_key_inspected = true;
         }
     }
     while (true)
     {
         Among w = v[i];
         if (common_i >= w.s_size)
         {
             cursor = c + w.s_size;
             if (w.method == null)
                 return w.result;
             bool res;
             res = w.method();
             cursor = c + w.s_size;
             if (res)
                 return w.result;
         }
         i = w.substring_i;
         if (i < 0)
             return 0;
     }
 }
        // find_among_b is for backwards processing. Same comments apply
        protected internal virtual int find_among_b(Among[] v, int v_size)
        {
            int i = 0;
            int j = v_size;
            
            int c = cursor;
            int lb = limit_backward;
            
            int common_i = 0;
            int common_j = 0;
            
            bool first_key_inspected = false;
            
            while (true)
            {
                int k = i + ((j - i) >> 1);
                int diff = 0;
                int common = common_i < common_j?common_i:common_j;
                Among w = v[k];
                int i2;
                for (i2 = w.s_size - 1 - common; i2 >= 0; i2--)
                {
                    if (c - common == lb)
                    {
                        diff = - 1;
                        break;
                    }
                    diff = current[c - 1 - common] - w.s[i2];
                    if (diff != 0)
                        break;
                    common++;
                }
                if (diff < 0)
                {
                    j = k;
                    common_j = common;
                }
                else
                {
                    i = k;
                    common_i = common;
                }
                if (j - i <= 1)
                {
                    if (i > 0)
                        break;
                    if (j == i)
                        break;
                    if (first_key_inspected)
                        break;
                    first_key_inspected = true;
                }
            }
            while (true)
            {
                Among w = v[i];
                if (common_i >= w.s_size)
                {
                    cursor = c - w.s_size;
                    if (w.method == null)
                        return w.result;

                    var res = w.method();
                    cursor = c - w.s_size;
                    if (res)
                        return w.result;
                }
                i = w.substring_i;
                if (i < 0)
                    return 0;
            }
        }
示例#3
0
        protected internal virtual int find_among(Among[] v, int v_size)
        {
            int i = 0;
            int j = v_size;

            int c = cursor;
            int l = limit;

            int common_i = 0;
            int common_j = 0;

            bool first_key_inspected = false;

            while (true)
            {
                int k = i + ((j - i) >> 1);
                int diff = 0;
                int common = common_i < common_j?common_i:common_j; // smaller
                Among w = v[k];
                int i2;
                for (i2 = common; i2 < w.s_size; i2++)
                {
                    if (c + common == l)
                    {
                        diff = - 1;
                        break;
                    }
                    diff = current[c + common] - w.s[i2];
                    if (diff != 0)
                        break;
                    common++;
                }
                if (diff < 0)
                {
                    j = k;
                    common_j = common;
                }
                else
                {
                    i = k;
                    common_i = common;
                }
                if (j - i <= 1)
                {
                    if (i > 0)
                        break; // v->s has been inspected
                    if (j == i)
                        break; // only one item in v

                    // - but now we need to go round once more to get
                    // v->s inspected. This looks messy, but is actually
                    // the optimal approach.

                    if (first_key_inspected)
                        break;
                    first_key_inspected = true;
                }
            }
            while (true)
            {
                Among w = v[i];
                if (common_i >= w.s_size)
                {
                    cursor = c + w.s_size;
                    if (w.method == null)
                        return w.result;
                    bool res;
                    try
                    {
                        System.Object resobj = w.method.Invoke(w.methodobject, (System.Object[]) new System.Object[0]);
                        // {{Aroush}} UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043_3"'
                        res = resobj.ToString().Equals("true", StringComparison.InvariantCultureIgnoreCase);
                    }
                    catch (System.Reflection.TargetInvocationException)
                    {
                        res = false;
                        // FIXME - debug message
                    }
                    catch (System.UnauthorizedAccessException)
                    {
                        res = false;
                        // FIXME - debug message
                    }
                    cursor = c + w.s_size;
                    if (res)
                        return w.result;
                }
                i = w.substring_i;
                if (i < 0)
                    return 0;
            }
        }
示例#4
0
        // find_among_b is for backwards processing. Same comments apply
        protected internal virtual int find_among_b(Among[] v, int v_size)
        {
            int i = 0;
            int j = v_size;

            int c = cursor;
            int lb = limit_backward;

            int common_i = 0;
            int common_j = 0;

            bool first_key_inspected = false;

            while (true)
            {
                int k = i + ((j - i) >> 1);
                int diff = 0;
                int common = common_i < common_j?common_i:common_j;
                Among w = v[k];
                int i2;
                for (i2 = w.s_size - 1 - common; i2 >= 0; i2--)
                {
                    if (c - common == lb)
                    {
                        diff = - 1;
                        break;
                    }
                    diff = current[c - 1 - common] - w.s[i2];
                    if (diff != 0)
                        break;
                    common++;
                }
                if (diff < 0)
                {
                    j = k;
                    common_j = common;
                }
                else
                {
                    i = k;
                    common_i = common;
                }
                if (j - i <= 1)
                {
                    if (i > 0)
                        break;
                    if (j == i)
                        break;
                    if (first_key_inspected)
                        break;
                    first_key_inspected = true;
                }
            }
            while (true)
            {
                Among w = v[i];
                if (common_i >= w.s_size)
                {
                    cursor = c - w.s_size;
                    if (w.method == null)
                        return w.result;

                    bool res;
                    try
                    {
                        System.Object resobj = w.method.Invoke(w.methodobject, (System.Object[]) new System.Object[0]);
                        // {{Aroush}} UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043_3"'
                        res = resobj.ToString().Equals("true", StringComparison.InvariantCultureIgnoreCase);
                    }
                    catch (System.Reflection.TargetInvocationException)
                    {
                        res = false;
                        // FIXME - debug message
                    }
                    catch (System.UnauthorizedAccessException)
                    {
                        res = false;
                        // FIXME - debug message
                    }
                    cursor = c - w.s_size;
                    if (res)
                        return w.result;
                }
                i = w.substring_i;
                if (i < 0)
                    return 0;
            }
        }
示例#5
0
        // findAmongB is for backwards processing. Same comments apply
        protected internal virtual int findAmongB(Among[] v, int vSize)
        {
            int i = 0;
            int j = vSize;

            int c  = cursor;
            int lb = limitBackward;

            int commonI = 0;
            int commonJ = 0;

            bool firstKeyInspected = false;

            while (true)
            {
                int   k      = i + ((j - i) >> 1);
                int   diff   = 0;
                int   common = commonI < commonJ?commonI:commonJ;
                Among w      = v[k];
                int   i2;
                for (i2 = w.sSize - 1 - common; i2 >= 0; i2--)
                {
                    if (c - common == lb)
                    {
                        diff = -1;
                        break;
                    }
                    diff = current[c - 1 - common] - w.s[i2];
                    if (diff != 0)
                    {
                        break;
                    }
                    common++;
                }
                if (diff < 0)
                {
                    j       = k;
                    commonJ = common;
                }
                else
                {
                    i       = k;
                    commonI = common;
                }
                if (j - i <= 1)
                {
                    if (i > 0)
                    {
                        break;
                    }
                    if (j == i)
                    {
                        break;
                    }
                    if (firstKeyInspected)
                    {
                        break;
                    }
                    firstKeyInspected = true;
                }
            }
            while (true)
            {
                Among w = v[i];
                if (commonI >= w.sSize)
                {
                    cursor = c - w.sSize;
                    if (w.methodname == "")
                    {
                        return(w.result);
                    }

                    bool res;
                    try
                    {
                        System.Object resobj = GetMethod(w.methodname).Invoke(this, (System.Object[]) new System.Object[0]);
                        // {{Aroush}} UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca10433"'
                        res = resobj.ToString().Equals("true");
                    }
                    catch (System.Reflection.TargetInvocationException e)
                    {
                        res = false;
                        // FIXME - debug message
                    }
                    catch (System.UnauthorizedAccessException e)
                    {
                        res = false;
                        // FIXME - debug message
                    }
                    cursor = c - w.sSize;
                    if (res)
                    {
                        return(w.result);
                    }
                }
                i = w.substringI;
                if (i < 0)
                {
                    return(0);
                }
            }
        }
示例#6
0
        protected internal virtual int findAmong(Among[] v, int vSize)
        {
            int i = 0;
            int j = vSize;

            int c = cursor;
            int l = limit;

            int commonI = 0;
            int commonJ = 0;

            bool firstKeyInspected = false;

            while (true)
            {
                int   k      = i + ((j - i) >> 1);
                int   diff   = 0;
                int   common = commonI < commonJ?commonI:commonJ;               // smaller
                Among w      = v[k];
                int   i2;
                for (i2 = common; i2 < w.sSize; i2++)
                {
                    if (c + common == l)
                    {
                        diff = -1;
                        break;
                    }
                    diff = current[c + common] - w.s[i2];
                    if (diff != 0)
                    {
                        break;
                    }
                    common++;
                }
                if (diff < 0)
                {
                    j       = k;
                    commonJ = common;
                }
                else
                {
                    i       = k;
                    commonI = common;
                }
                if (j - i <= 1)
                {
                    if (i > 0)
                    {
                        break;                         // v->s has been inspected
                    }
                    if (j == i)
                    {
                        break;                         // only one item in v
                    }
                    // - but now we need to go round once more to get
                    // v->s inspected. This looks messy, but is actually
                    // the optimal approach.

                    if (firstKeyInspected)
                    {
                        break;
                    }
                    firstKeyInspected = true;
                }
            }
            while (true)
            {
                Among w = v[i];
                if (commonI >= w.sSize)
                {
                    cursor = c + w.sSize;
                    if (w.methodname == "")
                    {
                        return(w.result);
                    }
                    bool res;
                    try
                    {
                        System.Object resobj = GetMethod(w.methodname).Invoke(this, (System.Object[]) new System.Object[0]);
                        // {{Aroush}} UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca10433"'
                        res = resobj.ToString().Equals("true");
                    }
                    catch (System.Reflection.TargetInvocationException e)
                    {
                        res = false;
                        // FIXME - debug message
                    }
                    catch (System.UnauthorizedAccessException e)
                    {
                        res = false;
                        // FIXME - debug message
                    }
                    cursor = c + w.sSize;
                    if (res)
                    {
                        return(w.result);
                    }
                }
                i = w.substringI;
                if (i < 0)
                {
                    return(0);
                }
            }
        }
示例#7
0
        // find_among_b is for backwards processing. Same comments apply
        protected internal virtual int find_among_b(Among[] v, int v_size)
        {
            int i = 0;
            int j = v_size;

            int c  = cursor;
            int lb = limit_backward;

            int common_i = 0;
            int common_j = 0;

            bool first_key_inspected = false;

            while (true)
            {
                int   k      = i + ((j - i) >> 1);
                int   diff   = 0;
                int   common = common_i < common_j?common_i:common_j;
                Among w      = v[k];
                int   i2;
                for (i2 = w.s_size - 1 - common; i2 >= 0; i2--)
                {
                    if (c - common == lb)
                    {
                        diff = -1;
                        break;
                    }
                    diff = current[c - 1 - common] - w.s[i2];
                    if (diff != 0)
                    {
                        break;
                    }
                    common++;
                }
                if (diff < 0)
                {
                    j        = k;
                    common_j = common;
                }
                else
                {
                    i        = k;
                    common_i = common;
                }
                if (j - i <= 1)
                {
                    if (i > 0)
                    {
                        break;
                    }
                    if (j == i)
                    {
                        break;
                    }
                    if (first_key_inspected)
                    {
                        break;
                    }
                    first_key_inspected = true;
                }
            }
            while (true)
            {
                Among w = v[i];
                if (common_i >= w.s_size)
                {
                    cursor = c - w.s_size;
                    if (w.method == null)
                    {
                        return(w.result);
                    }

                    var res = w.method();
                    cursor = c - w.s_size;
                    if (res)
                    {
                        return(w.result);
                    }
                }
                i = w.substring_i;
                if (i < 0)
                {
                    return(0);
                }
            }
        }
示例#8
0
        protected internal virtual int find_among(Among[] v, int v_size)
        {
            int i = 0;
            int j = v_size;

            int c = cursor;
            int l = limit;

            int common_i = 0;
            int common_j = 0;

            bool first_key_inspected = false;

            while (true)
            {
                int   k      = i + ((j - i) >> 1);
                int   diff   = 0;
                int   common = common_i < common_j?common_i:common_j; // smaller
                Among w      = v[k];
                int   i2;
                for (i2 = common; i2 < w.s_size; i2++)
                {
                    if (c + common == l)
                    {
                        diff = -1;
                        break;
                    }
                    diff = current[c + common] - w.s[i2];
                    if (diff != 0)
                    {
                        break;
                    }
                    common++;
                }
                if (diff < 0)
                {
                    j        = k;
                    common_j = common;
                }
                else
                {
                    i        = k;
                    common_i = common;
                }
                if (j - i <= 1)
                {
                    if (i > 0)
                    {
                        break; // v->s has been inspected
                    }
                    if (j == i)
                    {
                        break; // only one item in v
                    }
                    // - but now we need to go round once more to get
                    // v->s inspected. This looks messy, but is actually
                    // the optimal approach.

                    if (first_key_inspected)
                    {
                        break;
                    }
                    first_key_inspected = true;
                }
            }
            while (true)
            {
                Among w = v[i];
                if (common_i >= w.s_size)
                {
                    cursor = c + w.s_size;
                    if (w.method == null)
                    {
                        return(w.result);
                    }
                    bool res;
                    res    = w.method();
                    cursor = c + w.s_size;
                    if (res)
                    {
                        return(w.result);
                    }
                }
                i = w.substring_i;
                if (i < 0)
                {
                    return(0);
                }
            }
        }
示例#9
0
        // find_among_b is for backwards processing. Same comments apply
        protected internal virtual int find_among_b(Among[] v, int v_size)
        {
            int i = 0;
            int j = v_size;

            int c  = cursor;
            int lb = limit_backward;

            int common_i = 0;
            int common_j = 0;

            bool first_key_inspected = false;

            while (true)
            {
                int   k      = i + ((j - i) >> 1);
                int   diff   = 0;
                int   common = common_i < common_j?common_i:common_j;
                Among w      = v[k];
                int   i2;
                for (i2 = w.s_size - 1 - common; i2 >= 0; i2--)
                {
                    if (c - common == lb)
                    {
                        diff = -1;
                        break;
                    }
                    diff = current[c - 1 - common] - w.s[i2];
                    if (diff != 0)
                    {
                        break;
                    }
                    common++;
                }
                if (diff < 0)
                {
                    j        = k;
                    common_j = common;
                }
                else
                {
                    i        = k;
                    common_i = common;
                }
                if (j - i <= 1)
                {
                    if (i > 0)
                    {
                        break;
                    }
                    if (j == i)
                    {
                        break;
                    }
                    if (first_key_inspected)
                    {
                        break;
                    }
                    first_key_inspected = true;
                }
            }
            while (true)
            {
                Among w = v[i];
                if (common_i >= w.s_size)
                {
                    cursor = c - w.s_size;
                    if (w.method == null)
                    {
                        return(w.result);
                    }

                    bool res;
                    try
                    {
                        System.Object resobj = w.method.Invoke(w.methodobject, (System.Object[]) new System.Object[0]);
                        // {{Aroush}} UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043_3"'
                        res = resobj.ToString().Equals("true", StringComparison.InvariantCultureIgnoreCase);
                    }
                    catch (System.Reflection.TargetInvocationException)
                    {
                        res = false;
                        // FIXME - debug message
                    }
                    catch (System.UnauthorizedAccessException)
                    {
                        res = false;
                        // FIXME - debug message
                    }
                    cursor = c - w.s_size;
                    if (res)
                    {
                        return(w.result);
                    }
                }
                i = w.substring_i;
                if (i < 0)
                {
                    return(0);
                }
            }
        }