com.sun.enterprise.admin.cli
Class StringEditDistance

java.lang.Object
  extended by com.sun.enterprise.admin.cli.StringEditDistance

public class StringEditDistance
extends Object


Field Summary
private  String a
          Two strings to be compared.
private  String b
          Two strings to be compared.
private  int[] back
          back buffer.
private  int[] cost
          cost vector.
 
Constructor Summary
private StringEditDistance(String a, String b)
           
 
Method Summary
private  int calc()
           
static int editDistance(String a, String b)
          Computes the edit distance between two strings.
static String findNearest(String key, String[] group)
          Finds the string in the group closest to key and returns it.
private  void flip()
          Swaps two buffers.
private  int min(int a, int b, int c)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cost

private int[] cost
cost vector.


back

private int[] back
back buffer.


a

private final String a
Two strings to be compared.


b

private final String b
Two strings to be compared.

Constructor Detail

StringEditDistance

private StringEditDistance(String a,
                           String b)
Method Detail

editDistance

public static int editDistance(String a,
                               String b)
Computes the edit distance between two strings.

The complexity is O(nm) where n=a.length() and m=b.length().


findNearest

public static String findNearest(String key,
                                 String[] group)
Finds the string in the group closest to key and returns it.

Returns:
null if group.length==0.

flip

private void flip()
Swaps two buffers.


min

private int min(int a,
                int b,
                int c)

calc

private int calc()


Copyright © 2012 GlassFish Community. All Rights Reserved.