求两个字符串的最大公共子序列的长度

@param arg0 字符串1
@param arg1 字符串2
@param i    字符串1的当前位置指针
@param j    字符串2的当前位置指针
@return 两个字符串的最大公共子序列的长度
359931
private static long lcs(String arg0, String arg1, int i, int j) {
        if (arg0.length() == i || arg1.length() == j) {
            return 0;
        }

        if (arg0.charAt(i) == arg1.charAt(j)) {
            return 1 + lcs(arg0, arg1, ++i, ++j);
        } else {
            return Math.max(lcs(arg0, arg1, ++i, j), lcs(arg0, arg1, i, ++j));
        }
    }
822644
private static int js_imul(Object[] args)
    {
        if (args == null) {
            return 0;
        }

        int x = ScriptRuntime.toInt32(args, 0);
        int y = ScriptRuntime.toInt32(args, 1);
        return x * y;
    }
1197493
public double get(int i, int j) {

		if (i < 0 || i >= N) throw new IllegalArgumentException("Illegal index " + i + " should be > 0 and < " + N);
		if (j < 0 || j >= N) throw new IllegalArgumentException("Illegal index " + j + " should be > 0 and < " + N);

		return rows[i].get(j);
	}
72806
public boolean isLambdaArgument(String arg) {
        if (lambdaArgs == null) {
            return false;
        }

        for (int i = lambdaArgs.size() - 1; i >= 0; i--) {
            Map<String, Object> lmap = lambdaArgs.elementAt(i);
            if (lmap.containsKey(arg)) {
                return true;
            }
        }
        return false;
    }
944200
public int get(int i, int j) {
        if (i < 0 || i >= size()) {
            throw new IllegalArgumentException("Invalid index: i = " + i);
        }

        int[] x = get(i).x;
        if (x.length == 0) {
            return 0;
        }
        
        int low = 0;
        int high = x.length - 1;
        int mid = (low + high) / 2;
        
        while (j != x[mid] && low <= high) {
            mid = (low + high) / 2;
            if (j < x[mid]) 
                high = mid - 1;
            else
                low = mid + 1;
        }
        
        if (j == x[mid]) {
            return 1;
        } else {
            return 0;
        }
    }
1243965
private static boolean getArgBoolean(String[] args, int position, boolean defaultValue) {
        if (args.length > position) {
            String lowerArg = args[position].toLowerCase();
            if (lowerArg.equals("true") || lowerArg.equals("yes")) {
                return true;
            } else if (lowerArg.equals("false") || lowerArg.equals("no")) {
                return false;
            } else {
                throw new IllegalArgumentException(args[position] + " not a valid value.  Specify true or false");
            }
        } else {
            return defaultValue;
        }
    }
62525
public void println(int i) throws IOException
  {
    String value = Integer.toString(i);
    this.output.write(value.getBytes(), 0, value.length());
    this.output.write(CRLF, 0, 2);
  }
700375
public Object invoke( Object[] args )
  {
    Object value = getValue();
    if( value instanceof ISymbol )
    {
      return ((Symbol)value).invoke( args );
    }
    if( value instanceof IBlock )
    {
      return ((IBlock) value).invokeWithArgs( args );
    }

    Method method = (Method)value;
    Object ret;
    try
    {
      ret = method.invoke( null, args );
    }
    catch( Exception e )
    {
      throw GosuExceptionUtil.forceThrow( e );
    }
    return ret;
  }
1087248
public static void main(String[] args) {

    Object[] a1 = new Object[]{"a", "b"};
    Object[] a2 = new Object[]{"a", "b"};

    System.out.println(a1.equals(a2));


    GeneralizedCounter<String> gc = new GeneralizedCounter<String>(3);
    gc.incrementCount(Arrays.asList(new String[]{"a", "j", "x"}), 3.0);
    gc.incrementCount(Arrays.asList(new String[]{"a", "l", "x"}), 3.0);
    gc.incrementCount(Arrays.asList(new String[]{"b", "k", "y"}), 3.0);
    gc.incrementCount(Arrays.asList(new String[]{"b", "k", "z"}), 3.0);

    System.out.println("incremented counts.");

    System.out.println(gc.dumpKeys());

    System.out.println("string representation of generalized counter:");
    System.out.println(gc.toString());


    gc.printKeySet();

    System.out.println("entry set:\n" + gc.entrySet());


    arrayPrintDouble(gc.getCounts(Arrays.asList(new String[]{"a", "j", "x"})));
    arrayPrintDouble(gc.getCounts(Arrays.asList(new String[]{"a", "j", "z"})));
    arrayPrintDouble(gc.getCounts(Arrays.asList(new String[]{"b", "k", "w"})));
    arrayPrintDouble(gc.getCounts(Arrays.asList(new String[]{"b", "k", "z"})));

    GeneralizedCounter<String> gc1 = gc.conditionalize(Arrays.asList(new String[]{"a"}));
    gc1.incrementCount(Arrays.asList(new String[]{"j", "x"}));
    gc1.incrementCount2D("j", "z");
    GeneralizedCounter<String> gc2 = gc1.conditionalize(Arrays.asList(new String[]{"j"}));
    gc2.incrementCount1D("x");
    System.out.println("Pretty-printing gc after incrementing gc1:");
    gc.prettyPrint();
    System.out.println("Total: " + gc.totalCount());

    gc1.printKeySet();
    System.out.println("another entry set:\n" + gc1.entrySet());


    ClassicCounter<List<String>> c = gc.counterView();

    System.out.println("string representation of counter view:");
    System.out.println(c.toString());

    double d1 = c.getCount(Arrays.asList(new String[]{"a", "j", "x"}));
    double d2 = c.getCount(Arrays.asList(new String[]{"a", "j", "w"}));

    System.out.println(d1 + " " + d2);


    ClassicCounter<List<String>> c1 = gc1.counterView();

    System.out.println("Count of {j,x} -- should be 3.0\t" + c1.getCount(Arrays.asList(new String[]{"j", "x"})));


    System.out.println(c.keySet() + " size " + c.keySet().size());
    System.out.println(c1.keySet() + " size " + c1.keySet().size());

    System.out.println(c1.equals(c));
    System.out.println(c.equals(c1));
    System.out.println(c.equals(c));

    System.out.println("### testing equality of regular Counter...");

    ClassicCounter<String> z1 = new ClassicCounter<String>();
    ClassicCounter<String> z2 = new ClassicCounter<String>();

    z1.incrementCount("a1");
    z1.incrementCount("a2");

    z2.incrementCount("b");

    System.out.println(z1.equals(z2));

    System.out.println(z1.toString());
    System.out.println(z1.keySet().toString());


  }
743682
public int push(int i)
  {

    if ((m_firstFree + 1) >= m_mapSize)
    {
      m_mapSize += m_blocksize;

      int newMap[] = new int[m_mapSize];

      System.arraycopy(m_map, 0, newMap, 0, m_firstFree + 1);

      m_map = newMap;
    }

    m_map[m_firstFree] = i;

    m_firstFree++;

    return i;
  }
1071420
private void swap(final int i, final int j)
    {
        final double[] temp = m_data[i];

        m_data[i] = m_data[j];

        m_data[j] = temp;
    }
444862
@Override
    public final char charAt(int i) {
        if (i < -len || len <= i) {
            throw new IllegalArgumentException(
                    String.format("position %d of slice length %d is not valid.", i, len));
        }
        if (i < 0) {
            i = len + i;
        }
        return fb[off + i];
    }
403122
public void i(String format, Object... args) {
    println(LogLevel.INFO, format, args);
  }
436931
private static <T> List<T> lcs(List<T> arg0, List<T> arg1, Comparator<T> comparator, int i,
                                   int j) {
        if (arg0.size() == i || arg1.size() == j) {
            return new ArrayList<>(Math.min(arg0.size(), arg1.size()));
        }

        if (comparator.compare(arg0.get(i), arg1.get(j)) == 0) {
            T t = arg0.get(i);
            List<T> list = lcs(arg0, arg1, comparator, i + 1, j + 1);
            list.add(t);
            return list;
        } else {
            List<T> l1 = lcs(arg0, arg1, comparator, i + 1, j);
            List<T> l2 = lcs(arg0, arg1, comparator, i, j + 1);
            return l1.size() > l2.size() ? l1 : l2;
        }
    }
370874
public static void main(String... args) throws Exception {

        String string = "SELECT :expr1, #($expr2.class),"
                + " WHERE #if(:expr3) {e = $expr3} #else {e IS NULL}"
                + "#for(variant in $expr4.bytes) { AND c = :variant}" // NL
                + " {AND d = :expr-5}? {AND f = $expr6}?" // NL
                + " BY #!(:expr7) ASC";

        // 在输入中查找  PREFIX 字符
        Matcher matcher = PATTERN_KEYWORD.matcher(string);

        int position = 0;

        while (matcher.find(position)) {

            System.out.println("===============================");
            System.out.println("group 0: " + matcher.group(0));
            System.out.println("group 1: " + matcher.group(1));
            System.out.println("group 2: " + matcher.group(2));
            System.out.println("group 3: " + matcher.group(3));

            position = matcher.end();
        }

        // 在循环表达式中查找
        matcher = PATTERN_IN.matcher("variant in :expr5");

        if (matcher.matches()) {

            System.out.println("===============================");
            System.out.println("group 0: " + matcher.group(0));
            System.out.println("group 1: " + matcher.group(1));
            System.out.println("group 2: " + matcher.group(2));
        }

        // 编译下列语句
        ExqlPattern pattern = new ExqlCompiler(string).compile();

        ExqlContext context = new ExqlContextImpl();

        HashMap<String, Object> map = new HashMap<String, Object>();

        map.put("expr1", "expr1");
        map.put("expr2", "expr2");
        map.put("expr3", "expr3");
        map.put("expr4", "expr4");
        map.put("expr5", "expr5");
        // map.put("expr6", "expr6");
        map.put("expr7", "expr7");

        pattern.execute(context, map, map);
        System.out.println(context.flushOut());
        System.out.println(Arrays.toString(context.getArgs()));
    }
432064
@Override
    public <T> ParameterExpression<T> parameter(Class<T> arg0, String arg1)
    {
        // TODO Auto-generated method stub
        return null;
    }
1348062
void radbg(final int ido, final int ip, final int l1, final int idl1, final double in[], final int in_off, final double out[], final int out_off, final int offset) {
		int idij, ipph, j2, ic, jc, lc, is;
		double dc2, ai1, ai2, ar1, ar2, ds2, w1r, w1i;
		int nbd;
		double dcp, arg, dsp, ar1h, ar2h;
		int iw1 = offset;

		arg = TWO_PI / (double) ip;
		dcp = Math.cos(arg);
		dsp = Math.sin(arg);
		nbd = (ido - 1) / 2;
		ipph = (ip + 1) / 2;
		int idx0 = ip * ido;
		if (ido >= l1) {
			for (int k = 0; k < l1; k++) {
				int idx1 = k * ido;
				int idx2 = k * idx0;
				for (int i = 0; i < ido; i++) {
					out[out_off + i + idx1] = in[in_off + i + idx2];
				}
			}
		} else {
			for (int i = 0; i < ido; i++) {
				int idx1 = out_off + i;
				int idx2 = in_off + i;
				for (int k = 0; k < l1; k++) {
					out[idx1 + k * ido] = in[idx2 + k * idx0];
				}
			}
		}
		int iidx0 = in_off + ido - 1;
		for (int j = 1; j < ipph; j++) {
			jc = ip - j;
			j2 = 2 * j;
			int idx1 = j * l1 * ido;
			int idx2 = jc * l1 * ido;
			int idx3 = j2 * ido;
			for (int k = 0; k < l1; k++) {
				int idx4 = k * ido;
				int idx5 = idx4 * ip;
				int iidx1 = iidx0 + idx3 + idx5 - ido;
				int iidx2 = in_off + idx3 + idx5;
				double i1r = in[iidx1];
				double i2r = in[iidx2];

				out[out_off + idx4 + idx1] = i1r + i1r;
				out[out_off + idx4 + idx2] = i2r + i2r;
			}
		}

		if (ido != 1) {
			if (nbd >= l1) {
				for (int j = 1; j < ipph; j++) {
					jc = ip - j;
					int idx1 = j * l1 * ido;
					int idx2 = jc * l1 * ido;
					int idx3 = 2 * j * ido;
					for (int k = 0; k < l1; k++) {
						int idx4 = k * ido + idx1;
						int idx5 = k * ido + idx2;
						int idx6 = k * ip * ido + idx3;
						for (int i = 2; i < ido; i += 2) {
							ic = ido - i;
							int idx7 = out_off + i;
							int idx8 = in_off + ic;
							int idx9 = in_off + i;
							int oidx1 = idx7 + idx4;
							int oidx2 = idx7 + idx5;
							int iidx1 = idx9 + idx6;
							int iidx2 = idx8 + idx6 - ido;
							double a1i = in[iidx1 - 1];
							double a1r = in[iidx1];
							double a2i = in[iidx2 - 1];
							double a2r = in[iidx2];

							out[oidx1 - 1] = a1i + a2i;
							out[oidx2 - 1] = a1i - a2i;
							out[oidx1] = a1r - a2r;
							out[oidx2] = a1r + a2r;
						}
					}
				}
			} else {
				for (int j = 1; j < ipph; j++) {
					jc = ip - j;
					int idx1 = j * l1 * ido;
					int idx2 = jc * l1 * ido;
					int idx3 = 2 * j * ido;
					for (int i = 2; i < ido; i += 2) {
						ic = ido - i;
						int idx7 = out_off + i;
						int idx8 = in_off + ic;
						int idx9 = in_off + i;
						for (int k = 0; k < l1; k++) {
							int idx4 = k * ido + idx1;
							int idx5 = k * ido + idx2;
							int idx6 = k * ip * ido + idx3;
							int oidx1 = idx7 + idx4;
							int oidx2 = idx7 + idx5;
							int iidx1 = idx9 + idx6;
							int iidx2 = idx8 + idx6 - ido;
							double a1i = in[iidx1 - 1];
							double a1r = in[iidx1];
							double a2i = in[iidx2 - 1];
							double a2r = in[iidx2];

							out[oidx1 - 1] = a1i + a2i;
							out[oidx2 - 1] = a1i - a2i;
							out[oidx1] = a1r - a2r;
							out[oidx2] = a1r + a2r;
						}
					}
				}
			}
		}

		ar1 = 1;
		ai1 = 0;
		int idx01 = (ip - 1) * idl1;
		for (int l = 1; l < ipph; l++) {
			lc = ip - l;
			ar1h = dcp * ar1 - dsp * ai1;
			ai1 = dcp * ai1 + dsp * ar1;
			ar1 = ar1h;
			int idx1 = l * idl1;
			int idx2 = lc * idl1;
			for (int ik = 0; ik < idl1; ik++) {
				int idx3 = in_off + ik;
				int idx4 = out_off + ik;
				in[idx3 + idx1] = out[idx4] + ar1 * out[idx4 + idl1];
				in[idx3 + idx2] = ai1 * out[idx4 + idx01];
			}
			dc2 = ar1;
			ds2 = ai1;
			ar2 = ar1;
			ai2 = ai1;
			for (int j = 2; j < ipph; j++) {
				jc = ip - j;
				ar2h = dc2 * ar2 - ds2 * ai2;
				ai2 = dc2 * ai2 + ds2 * ar2;
				ar2 = ar2h;
				int idx5 = j * idl1;
				int idx6 = jc * idl1;
				for (int ik = 0; ik < idl1; ik++) {
					int idx7 = in_off + ik;
					int idx8 = out_off + ik;
					in[idx7 + idx1] += ar2 * out[idx8 + idx5];
					in[idx7 + idx2] += ai2 * out[idx8 + idx6];
				}
			}
		}
		for (int j = 1; j < ipph; j++) {
			int idx1 = j * idl1;
			for (int ik = 0; ik < idl1; ik++) {
				int idx2 = out_off + ik;
				out[idx2] += out[idx2 + idx1];
			}
		}
		for (int j = 1; j < ipph; j++) {
			jc = ip - j;
			int idx1 = j * l1 * ido;
			int idx2 = jc * l1 * ido;
			for (int k = 0; k < l1; k++) {
				int idx3 = k * ido;
				int oidx1 = out_off + idx3;
				int iidx1 = in_off + idx3 + idx1;
				int iidx2 = in_off + idx3 + idx2;
				double i1r = in[iidx1];
				double i2r = in[iidx2];

				out[oidx1 + idx1] = i1r - i2r;
				out[oidx1 + idx2] = i1r + i2r;
			}
		}

		if (ido == 1)
			return;
		if (nbd >= l1) {
			for (int j = 1; j < ipph; j++) {
				jc = ip - j;
				int idx1 = j * l1 * ido;
				int idx2 = jc * l1 * ido;
				for (int k = 0; k < l1; k++) {
					int idx3 = k * ido;
					for (int i = 2; i < ido; i += 2) {
						int idx4 = out_off + i;
						int idx5 = in_off + i;
						int oidx1 = idx4 + idx3 + idx1;
						int oidx2 = idx4 + idx3 + idx2;
						int iidx1 = idx5 + idx3 + idx1;
						int iidx2 = idx5 + idx3 + idx2;
						double i1i = in[iidx1 - 1];
						double i1r = in[iidx1];
						double i2i = in[iidx2 - 1];
						double i2r = in[iidx2];

						out[oidx1 - 1] = i1i - i2r;
						out[oidx2 - 1] = i1i + i2r;
						out[oidx1] = i1r + i2i;
						out[oidx2] = i1r - i2i;
					}
				}
			}
		} else {
			for (int j = 1; j < ipph; j++) {
				jc = ip - j;
				int idx1 = j * l1 * ido;
				int idx2 = jc * l1 * ido;
				for (int i = 2; i < ido; i += 2) {
					int idx4 = out_off + i;
					int idx5 = in_off + i;
					for (int k = 0; k < l1; k++) {
						int idx3 = k * ido;
						int oidx1 = idx4 + idx3 + idx1;
						int oidx2 = idx4 + idx3 + idx2;
						int iidx1 = idx5 + idx3 + idx1;
						int iidx2 = idx5 + idx3 + idx2;
						double i1i = in[iidx1 - 1];
						double i1r = in[iidx1];
						double i2i = in[iidx2 - 1];
						double i2r = in[iidx2];

						out[oidx1 - 1] = i1i - i2r;
						out[oidx2 - 1] = i1i + i2r;
						out[oidx1] = i1r + i2i;
						out[oidx2] = i1r - i2i;
					}
				}
			}
		}
		System.arraycopy(out, out_off, in, in_off, idl1);
		for (int j = 1; j < ip; j++) {
			int idx1 = j * l1 * ido;
			for (int k = 0; k < l1; k++) {
				int idx2 = k * ido + idx1;
				in[in_off + idx2] = out[out_off + idx2];
			}
		}
		if (nbd <= l1) {
			is = -ido;
			for (int j = 1; j < ip; j++) {
				is += ido;
				idij = is - 1;
				int idx1 = j * l1 * ido;
				for (int i = 2; i < ido; i += 2) {
					idij += 2;
					int idx2 = idij + iw1;
					w1r = wtable_r[idx2 - 1];
					w1i = wtable_r[idx2];
					int idx4 = in_off + i;
					int idx5 = out_off + i;
					for (int k = 0; k < l1; k++) {
						int idx3 = k * ido + idx1;
						int iidx1 = idx4 + idx3;
						int oidx1 = idx5 + idx3;
						double o1i = out[oidx1 - 1];
						double o1r = out[oidx1];

						in[iidx1 - 1] = w1r * o1i - w1i * o1r;
						in[iidx1] = w1r * o1r + w1i * o1i;
					}
				}
			}
		} else {
			is = -ido;
			for (int j = 1; j < ip; j++) {
				is += ido;
				int idx1 = j * l1 * ido;
				for (int k = 0; k < l1; k++) {
					idij = is - 1;
					int idx3 = k * ido + idx1;
					for (int i = 2; i < ido; i += 2) {
						idij += 2;
						int idx2 = idij + iw1;
						w1r = wtable_r[idx2 - 1];
						w1i = wtable_r[idx2];
						int idx4 = in_off + i;
						int idx5 = out_off + i;
						int iidx1 = idx4 + idx3;
						int oidx1 = idx5 + idx3;
						double o1i = out[oidx1 - 1];
						double o1r = out[oidx1];

						in[iidx1 - 1] = w1r * o1i - w1i * o1r;
						in[iidx1] = w1r * o1r + w1i * o1i;

					}
				}
			}
		}
	}