当前位置: 首页>>代码示例>>Java>>正文


Java StringFunctions类代码示例

本文整理汇总了Java中com.jwetherell.algorithms.strings.StringFunctions的典型用法代码示例。如果您正苦于以下问题:Java StringFunctions类的具体用法?Java StringFunctions怎么用?Java StringFunctions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StringFunctions类属于com.jwetherell.algorithms.strings包,在下文中一共展示了StringFunctions类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testReverseCharsInString

import com.jwetherell.algorithms.strings.StringFunctions; //导入依赖的package包/类
@Test
public void testReverseCharsInString() {
    // REVERSE CHARS IN A STRING
    String string = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    String check = "zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA";
    String result = StringFunctions.reverseWithStringConcat(string);
    assertTrue("Reverse With String Concat error. expect="+check+" got="+result, check.equals(result));

    result = StringFunctions.reverseWithStringBuilder(string);
    assertTrue("Reverse With String String Builder error. expect="+check+" got="+result, check.equals(result));

    result = StringFunctions.reverseWithStringBuilderBuiltinMethod(string);
    assertTrue("Reverse With Built-in error. expect="+check+" got="+result, check.equals(result));

    result = StringFunctions.reverseWithSwaps(string);
    assertTrue("Reverse With Swaps error. expect="+check+" got="+result, check.equals(result));

    result = StringFunctions.reverseWithXOR(string);
    assertTrue("Reverse With XOR error. expect="+check+" got="+result, check.equals(result));
}
 
开发者ID:MENG2010,项目名称:java-algorithms-implementation,代码行数:21,代码来源:Strings.java

示例2: testReverseWordsInString

import com.jwetherell.algorithms.strings.StringFunctions; //导入依赖的package包/类
@Test
public void testReverseWordsInString() {
    // REVERSE WORDS IN A STRING
    String string = "Could you pretty please reverse this sentence";
    String check = "sentence this reverse please pretty you Could";
    String result = StringFunctions.reverseWordsByCharWithAdditionalStorage(string);
    assertTrue("Reverse Words By Char w/ Additional Storage error. expect="+check+" got="+result, check.equals(result));

    result = StringFunctions.reverseWordsUsingStringTokenizerWithAdditionalStorage(string);
    assertTrue("Reverse Words Using String Tokenizer w/ Additional Storage error. expect="+check+" got="+result, check.equals(result));

    result = StringFunctions.reverseWordsUsingSplitWithAdditionalStorage(string);
    assertTrue("Reverse Words Using Split w/ Additional Storage error. expect="+check+" got="+result, check.equals(result));

    result = StringFunctions.reverseWordsInPlace(string);
    assertTrue("Reverse Words In-Place error. expect="+check+" got="+result, check.equals(result));
}
 
开发者ID:MENG2010,项目名称:java-algorithms-implementation,代码行数:18,代码来源:Strings.java

示例3: testIsPalinDrone

import com.jwetherell.algorithms.strings.StringFunctions; //导入依赖的package包/类
@Test
public void testIsPalinDrone() {
    // PALINDROME
    String string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    boolean result = StringFunctions.isPalindromeWithAdditionalStorage(string);
    assertFalse("Is Palindrome With Additional Storage error. expected=false got="+result, result);

    result = StringFunctions.isPalindromeInPlace(string);
    assertFalse("Is Palindrome In Place error. expected=false got="+result, result);

    string = "ABCDEFGHIJKKJIHGFEDCBA";
    result = StringFunctions.isPalindromeWithAdditionalStorage(string);
    assertTrue("Is Palindrome With Additional Storage error. expected=true got="+result, result);

    result = StringFunctions.isPalindromeInPlace(string);
    assertTrue("Is Palindrome In Place error. expected=true got="+result, result);
}
 
开发者ID:MENG2010,项目名称:java-algorithms-implementation,代码行数:18,代码来源:Strings.java

示例4: testGenerateSubSets

import com.jwetherell.algorithms.strings.StringFunctions; //导入依赖的package包/类
@Test
public void testGenerateSubSets() {
    // COMBINATIONS
    String string = "abc";
    String[] check = new String[] {"", "c", "b", "cb", "a", "ca", "ba", "cba"};
    String[] result = StringFunctions.generateSubsets(string);
    assertTrue("Generate Subsets error. expected="+print(check)+" got="+print(result), Arrays.equals(check, result));
}
 
开发者ID:MENG2010,项目名称:java-algorithms-implementation,代码行数:9,代码来源:Strings.java

示例5: testEditDistance

import com.jwetherell.algorithms.strings.StringFunctions; //导入依赖的package包/类
@Test
public void testEditDistance() {
    // Edit Distance
    String string1 = "kitten";
    String string2 = "sitting";
    int check = 3;
    int result = StringFunctions.levenshteinDistance(string1, string2);
    assertTrue("Edit Distance error. expected="+check+" got="+result, (check==result));
}
 
开发者ID:MENG2010,项目名称:java-algorithms-implementation,代码行数:10,代码来源:Strings.java


注:本文中的com.jwetherell.algorithms.strings.StringFunctions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。