當前位置: 首頁>>代碼示例>>Java>>正文


Java Chars.toArray方法代碼示例

本文整理匯總了Java中com.google.common.primitives.Chars.toArray方法的典型用法代碼示例。如果您正苦於以下問題:Java Chars.toArray方法的具體用法?Java Chars.toArray怎麽用?Java Chars.toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.primitives.Chars的用法示例。


在下文中一共展示了Chars.toArray方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setUp

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
@BeforeExperiment void setUp() {
  random = new Random(0xdeadbeef);  // fix the seed so results are comparable across runs

  int nonAlpha = size / nonAlphaRatio;
  int alpha = size - nonAlpha;

  List<Character> chars = Lists.newArrayListWithCapacity(size);
  for (int i = 0; i < alpha; i++) {
    chars.add(randomAlpha());
  }
  for (int i = 0; i < nonAlpha; i++) {
    chars.add(randomNonAlpha());
  }
  Collections.shuffle(chars, random);
  char[] array = Chars.toArray(chars);
  this.testString = new String(array);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:18,代碼來源:AsciiBenchmark.java

示例2: toArray

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
@SuppressWarnings({"unchecked", "rawtypes"}) // NOTE: We assume the component type matches the list
private Object toArray(Class<?> componentType, List<Object> values) {
    if (componentType == boolean.class) {
        return Booleans.toArray((Collection) values);
    } else if (componentType == byte.class) {
        return Bytes.toArray((Collection) values);
    } else if (componentType == short.class) {
        return Shorts.toArray((Collection) values);
    } else if (componentType == int.class) {
        return Ints.toArray((Collection) values);
    } else if (componentType == long.class) {
        return Longs.toArray((Collection) values);
    } else if (componentType == float.class) {
        return Floats.toArray((Collection) values);
    } else if (componentType == double.class) {
        return Doubles.toArray((Collection) values);
    } else if (componentType == char.class) {
        return Chars.toArray((Collection) values);
    }
    return values.toArray((Object[]) Array.newInstance(componentType, values.size()));
}
 
開發者ID:TNG,項目名稱:ArchUnit,代碼行數:22,代碼來源:JavaClassProcessor.java

示例3: setUp

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
@BeforeExperiment void setUp() {
  random = new Random();

  int nonAlpha = size / nonAlphaRatio;
  int alpha = size - nonAlpha;

  List<Character> chars = Lists.newArrayListWithCapacity(size);
  for (int i = 0; i < alpha; i++) {
    chars.add(randomAlpha());
  }
  for (int i = 0; i < nonAlpha; i++) {
    chars.add(randomNonAlpha());
  }
  Collections.shuffle(chars, random);
  char[] array = Chars.toArray(chars);
  this.testString = new String(array);
}
 
開發者ID:sander120786,項目名稱:guava-libraries,代碼行數:18,代碼來源:AsciiBenchmark.java

示例4: setUp

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
@BeforeExperiment
void setUp() {
  random = new Random(0xdeadbeef); // fix the seed so results are comparable across runs

  int nonAlpha = size / nonAlphaRatio;
  int alpha = size - nonAlpha;

  List<Character> chars = Lists.newArrayListWithCapacity(size);
  for (int i = 0; i < alpha; i++) {
    chars.add(randomAlpha());
  }
  for (int i = 0; i < nonAlpha; i++) {
    chars.add(randomNonAlpha());
  }
  Collections.shuffle(chars, random);
  char[] array = Chars.toArray(chars);
  this.testString = new String(array);
}
 
開發者ID:google,項目名稱:guava,代碼行數:19,代碼來源:AsciiBenchmark.java

示例5: create

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
@Override
public List<Character> create(Character[] elements) {
  char[] chars = Chars.toArray(Arrays.asList(elements));
  StringBuilder str = new StringBuilder();
  str.append(chars);
  return Lists.charactersOf(str);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:8,代碼來源:ListGenerators.java

示例6: reserveCharacters

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
/**
 * Provides the array of available characters based on the specified arrays.
 * @param chars The list of characters that are legal
 * @param reservedCharacters The characters that should not be used
 * @return An array of characters to use. Will return the chars array if
 *    reservedCharacters is null or empty, otherwise creates a new array.
 */
static char[] reserveCharacters(char[] chars, char[] reservedCharacters) {
  if (reservedCharacters == null || reservedCharacters.length == 0) {
    return chars;
  }    
  Set<Character> charSet = Sets.newLinkedHashSet(Chars.asList(chars));
  for (char reservedCharacter : reservedCharacters) {
    charSet.remove(reservedCharacter);
  }
  return Chars.toArray(charSet);
}
 
開發者ID:andyjko,項目名稱:feedlack,代碼行數:18,代碼來源:NameGenerator.java

示例7: reserveCharacters

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
/**
 * Provides the array of available characters based on the specified arrays.
 * @param chars The list of characters that are legal
 * @param reservedCharacters The characters that should not be used
 * @return An array of characters to use. Will return the chars array if
 *    reservedCharacters is null or empty, otherwise creates a new array.
 */
static char[] reserveCharacters(char[] chars, char[] reservedCharacters) {
  if (reservedCharacters == null || reservedCharacters.length == 0) {
    return chars;
  }
  Set<Character> charSet = Sets.newLinkedHashSet(Chars.asList(chars));
  for (char reservedCharacter : reservedCharacters) {
    charSet.remove(reservedCharacter);
  }
  return Chars.toArray(charSet);
}
 
開發者ID:ehsan,項目名稱:js-symbolic-executor,代碼行數:18,代碼來源:NameGenerator.java

示例8: NumberSystem

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
public NumberSystem(String digits) {
	checkArgument(
			checkNotNull(digits, "digits must not be null").length() > 1,
			"digits must contain at least two characters");
	List<Character> characters = Lists.charactersOf(digits);
	checkState(Sets.newHashSet(characters).size() == digits.length(),
			"Duplicates found in %s", digits);
	this.digits = Chars.toArray(characters);
	this.numDigits = digits.length();
}
 
開發者ID:pfichtner,項目名稱:jcrunch,代碼行數:11,代碼來源:NumberSystem.java

示例9: create

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
@Override public List<Character> create(Character[] elements) {
  char[] chars = Chars.toArray(Arrays.asList(elements));
  return Lists.charactersOf(String.copyValueOf(chars));
}
 
開發者ID:sander120786,項目名稱:guava-libraries,代碼行數:5,代碼來源:ListGenerators.java

示例10: shuffleAndCopyAlphabet

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
private static String shuffleAndCopyAlphabet(Set<Character> input, Random random) {
  List<Character> shuffled = new ArrayList<>(input);
  Collections.shuffle(shuffled, random);
  return new String(Chars.toArray(shuffled));
}
 
開發者ID:google,項目名稱:closure-compiler,代碼行數:6,代碼來源:RandomNameGenerator.java


注:本文中的com.google.common.primitives.Chars.toArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。