/** * Computes the edit distance between two strings. * * <p> * The complexity is O(nm) where n=a.length() and m=b.length(). */ public static int editDistance( String a, String b ) { // let's check cache AbstractMap.SimpleEntry<String,String> entry = new AbstractMap.SimpleEntry<String, String>(a, b); // using this class to avoid creation of my own which will handle PAIR of values Integer result = null; if (CACHE.containsKey(entry)) result = CACHE.get(entry); // looks like we have it if (result == null) { result = new EditDistance(a, b).calc(); CACHE.put(entry, result); // cache the result } return result; }
/** * Computes the edit distance between two strings. * * <p> * The complexity is O(nm) where n=a.length() and m=b.length(). */ public static int editDistance( String a, String b ) { // let's check cache AbstractMap.SimpleEntry<String,String> entry = new AbstractMap.SimpleEntry<String, String>(a, b); // using this class to avoid creation of my own which will handle PAIR of values Integer result = null; if (CACHE.containsKey(entry)) result = CACHE.get(entry); // looks like we have it if (result == null) { result = new EditDistance(a, b).calc(); CACHE.put(entry, result); // cache the result } return result; }
/** * Computes the edit distance between two strings. * * <p> * The complexity is O(nm) where n=a.length() and m=b.length(). */ public static int editDistance( String a, String b ) { // let's check cache AbstractMap.SimpleEntry<String,String> entry = new AbstractMap.SimpleEntry<String, String>(a, b); // using this class to avoid creation of my own which will handle PAIR of values Integer result = null; if (CACHE.containsKey(entry)) result = CACHE.get(entry); // looks like we have it if (result == null) { result = new EditDistance(a, b).calc(); CACHE.put(entry, result); // cache the result } return result; }
/** * Computes the edit distance between two strings. * * <p> * The complexity is O(nm) where n=a.length() and m=b.length(). */ public static int editDistance( String a, String b ) { // let's check cache AbstractMap.SimpleEntry<String,String> entry = new AbstractMap.SimpleEntry<String, String>(a, b); // using this class to avoid creation of my own which will handle PAIR of values Integer result = null; if (CACHE.containsKey(entry)) result = CACHE.get(entry); // looks like we have it if (result == null) { result = new EditDistance(a, b).calc(); CACHE.put(entry, result); // cache the result } return result; }
/** * Computes the edit distance between two strings. * * <p> * The complexity is O(nm) where n=a.length() and m=b.length(). */ public static int editDistance( String a, String b ) { // let's check cache AbstractMap.SimpleEntry<String,String> entry = new AbstractMap.SimpleEntry<String, String>(a, b); // using this class to avoid creation of my own which will handle PAIR of values Integer result = null; if (CACHE.containsKey(entry)) result = CACHE.get(entry); // looks like we have it if (result == null) { result = new EditDistance(a, b).calc(); CACHE.put(entry, result); // cache the result } return result; }
/** * Computes the edit distance between two strings. * * <p> * The complexity is O(nm) where n=a.length() and m=b.length(). */ public static int editDistance( String a, String b ) { // let's check cache AbstractMap.SimpleEntry<String,String> entry = new AbstractMap.SimpleEntry<String, String>(a, b); // using this class to avoid creation of my own which will handle PAIR of values Integer result = null; if (CACHE.containsKey(entry)) result = CACHE.get(entry); // looks like we have it if (result == null) { result = new EditDistance(a, b).calc(); CACHE.put(entry, result); // cache the result } return result; }