本文整理匯總了Java中com.google.common.primitives.Ints.toArray方法的典型用法代碼示例。如果您正苦於以下問題:Java Ints.toArray方法的具體用法?Java Ints.toArray怎麽用?Java Ints.toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.primitives.Ints
的用法示例。
在下文中一共展示了Ints.toArray方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: provideExtractorForValue
import com.google.common.primitives.Ints; //導入方法依賴的package包/類
private <T> ValueExtractor provideExtractorForValue(Class<T> clazz, int target, List<String> chainOfProperties) {
Class<?> propertyClass = clazz;
List<Integer> indices = Lists.newArrayList();
for (String property : chainOfProperties) {
Field field;
try {
field = clazz.getDeclaredField(property);
} catch (NoSuchFieldException e) {
throw new InvalidQueryException(e);
}
PortableProperty portablePropertyAnnotation = field.getAnnotation(PortableProperty.class);
if (portablePropertyAnnotation == null) {
throw new InvalidQueryException("");
}
// TODO add support for customs codecs some day ;)
int index = portablePropertyAnnotation.value();
indices.add(index);
propertyClass = field.getDeclaringClass();
}
return new PofExtractor<>(propertyClass, new SimplePofPath(Ints.toArray(indices)), target);
}
示例2: toArray
import com.google.common.primitives.Ints; //導入方法依賴的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()));
}
示例3: getZoomLevels
import com.google.common.primitives.Ints; //導入方法依賴的package包/類
private int[] getZoomLevels() {
final List<Integer> zoomLevels = new ArrayList<>();
final File[] files = directory.listFiles();
if (files == null) {
return new int[]{};
}
final Pattern pattern = Pattern.compile("^([0-9]|1[0-9]|2[0-2])$");
for (final File file : files) {
final String fileName = file.getName();
final Matcher matcher = pattern.matcher(fileName);
if (matcher.matches()) {
final int value = Integer.parseInt(matcher.group());
zoomLevels.add(value);
}
}
final int[] result = Ints.toArray(zoomLevels);
Arrays.sort(result);
return result;
}
示例4: testScale_index_compute_intVarargs
import com.google.common.primitives.Ints; //導入方法依賴的package包/類
public void testScale_index_compute_intVarargs() {
int[] dataset = Ints.toArray(SIXTEEN_SQUARES_INTEGERS);
assertThat(Quantiles.scale(10).index(1).compute(dataset))
.isWithin(ALLOWED_ERROR)
.of(SIXTEEN_SQUARES_DECILE_1);
assertThat(dataset).asList().isEqualTo(SIXTEEN_SQUARES_INTEGERS);
}
示例5: testScale_indexes_varargs_compute_intVarargs
import com.google.common.primitives.Ints; //導入方法依賴的package包/類
public void testScale_indexes_varargs_compute_intVarargs() {
int[] dataset = Ints.toArray(SIXTEEN_SQUARES_INTEGERS);
assertThat(Quantiles.scale(10).indexes(0, 10, 5, 1, 8, 1).compute(dataset))
.comparingValuesUsing(QUANTILE_CORRESPONDENCE)
.containsExactly(
0, SIXTEEN_SQUARES_MIN,
10, SIXTEEN_SQUARES_MAX,
5, SIXTEEN_SQUARES_MEDIAN,
1, SIXTEEN_SQUARES_DECILE_1,
8, SIXTEEN_SQUARES_DECILE_8);
assertThat(dataset).asList().isEqualTo(SIXTEEN_SQUARES_INTEGERS);
}
示例6: finishPage
import com.google.common.primitives.Ints; //導入方法依賴的package包/類
private void finishPage() {
// Create and add the page
IGuideElement[] pageElements = elems.toArray(new IGuideElement[elems.size()]);
int[] pageStartPoints = Ints.toArray(startPoints);
int[] pageEndPoints = Ints.toArray(endPoints);
int[] translationPoints = Ints.toArray(heights);
pages.add(new GuidePage(guide, pageElements, pageStartPoints, pageEndPoints, translationPoints));
// Reset all values
elems.clear();
heights.clear();
startPoints.clear();
endPoints.clear();
y = 0;
}
示例7: testScale_indexes_varargs_compute_intVarargs
import com.google.common.primitives.Ints; //導入方法依賴的package包/類
public void testScale_indexes_varargs_compute_intVarargs() {
int[] dataset = Ints.toArray(SIXTEEN_SQUARES_INTEGERS);
ImmutableMap<Integer, Double> expected = ImmutableMap.of(
0, SIXTEEN_SQUARES_MIN,
10, SIXTEEN_SQUARES_MAX,
5, SIXTEEN_SQUARES_MEDIAN,
1, SIXTEEN_SQUARES_DECILE_1,
8, SIXTEEN_SQUARES_DECILE_8
);
assertQuantilesMap(expected, Quantiles.scale(10).indexes(0, 10, 5, 1, 8, 1).compute(dataset));
assertDatasetInOrder(SIXTEEN_SQUARES_INTEGERS, dataset);
}
示例8: Metadata
import com.google.common.primitives.Ints; //導入方法依賴的package包/類
private Metadata(int lines, List<Integer> originalLineOffsets, int lastValidOffset) {
this.lines = lines;
this.originalLineOffsets = Ints.toArray(originalLineOffsets);
this.lastValidOffset = lastValidOffset;
}
示例9: deserialize
import com.google.common.primitives.Ints; //導入方法依賴的package包/類
@Override public int[] deserialize(TypeToken<?> type, ConfigurationNode value) throws ObjectMappingException {
List<Integer> list = value.getList(ttb);
return Ints.toArray(list);
}
示例10: testScale_index_compute_intVarargs
import com.google.common.primitives.Ints; //導入方法依賴的package包/類
public void testScale_index_compute_intVarargs() {
int[] dataset = Ints.toArray(SIXTEEN_SQUARES_INTEGERS);
assertQuantile(1, SIXTEEN_SQUARES_DECILE_1, Quantiles.scale(10).index(1).compute(dataset));
assertDatasetInOrder(SIXTEEN_SQUARES_INTEGERS, dataset);
}