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


Java Range.singleton方法代码示例

本文整理汇总了Java中com.google.common.collect.Range.singleton方法的典型用法代码示例。如果您正苦于以下问题:Java Range.singleton方法的具体用法?Java Range.singleton怎么用?Java Range.singleton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.Range的用法示例。


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

示例1: getRecipes

import com.google.common.collect.Range; //导入方法依赖的package包/类
protected List<Recipe> getRecipes(FeatureWrapper feature, Collection<Pickle> pickles) {
	int pickleCount = pickles.size();
	ArrayList<Recipe> recipes = Lists.newArrayListWithExpectedSize(pickleCount);
	Set<Integer> pickleLines = Sets.newHashSetWithExpectedSize(pickleCount);

	RangeMap<Integer, ScenarioDefinition> rangeMap = getRangeMap(feature);
	for (Pickle pickle : pickles) {
		List<PickleLocation> locations = pickle.getLocations();
		for (PickleLocation location : locations) {
			int line = location.getLine();
			if (!pickleLines.contains(line)) {
				pickleLines.add(line);
				Range<Integer> range = Range.singleton(line);
				RangeMap<Integer, ScenarioDefinition> subRangeMap = rangeMap.subRangeMap(range);
				Map<Range<Integer>, ScenarioDefinition> asMap = subRangeMap.asMapOfRanges();
				checkState(1 == asMap.size(), "no single range found encompassing PickleLocation %s", location);
				ScenarioDefinition definition = Iterables.getOnlyElement(asMap.values());
				Recipe recipe = new Recipe(feature, pickle, location, definition);
				recipes.add(recipe);
			}
		}
	}
	return recipes;
}
 
开发者ID:qas-guru,项目名称:martini-core,代码行数:25,代码来源:DefaultMixology.java

示例2: parseInternal

import com.google.common.collect.Range; //导入方法依赖的package包/类
@Override
protected Range<N> parseInternal(Node node, String text) throws FormatException, InvalidXMLException {
    final String[] parts = text.split("\\.\\.");
    switch(parts.length) {
        case 1: return Range.singleton(domainParser.parse(node, text));
        case 2: return Range.closed(domainParser.parse(node, parts[0]),
                                    domainParser.parse(node, parts[1]));
    }
    throw new FormatException();
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:11,代码来源:RangeParser.java

示例3: parseKillStreak

import com.google.common.collect.Range; //导入方法依赖的package包/类
@MethodParser("kill-streak")
public KillStreakFilter parseKillStreak(Element el) throws InvalidXMLException {
    boolean repeat = XMLUtils.parseBoolean(el.getAttribute("repeat"), false);
    boolean persistent = XMLUtils.parseBoolean(el.getAttribute("persistent"), false);
    Integer count = XMLUtils.parseNumber(el.getAttribute("count"), Integer.class, (Integer) null);
    Integer min = XMLUtils.parseNumber(el.getAttribute("min"), Integer.class, (Integer) null);
    Integer max = XMLUtils.parseNumber(el.getAttribute("max"), Integer.class, (Integer) null);
    Range<Integer> range;

    if(count != null) {
        range = Range.singleton(count);
    } else if(min == null) {
        if(max == null) {
            throw new InvalidXMLException("kill-streak filter must have a count, min, or max", el);
        } else {
            range = Range.atMost(max);
        }
    } else {
        if(max == null) {
            range = Range.atLeast(min);
        } else {
            range = Range.closed(min, max);
        }
    }

    if(repeat && !range.hasUpperBound()) {
        throw new InvalidXMLException("repeating kill-streak filter must have a count or max", el);
    }

    return new KillStreakFilter(range, repeat, persistent);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:32,代码来源:FilterDefinitionParser.java

示例4: generateRange

import com.google.common.collect.Range; //导入方法依赖的package包/类
@Generates private static <C extends Comparable<?>> Range<C> generateRange(C freshElement) {
  return Range.singleton(freshElement);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:4,代码来源:FreshValueGenerator.java

示例5: getPlayerLimits

import com.google.common.collect.Range; //导入方法依赖的package包/类
/**
 * Return the number of players that this module alone can allow to join a match.
 */
default Range<Integer> getPlayerLimits() {
    return Range.singleton(0);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:7,代码来源:MapModule.java

示例6: parseNumericRange

import com.google.common.collect.Range; //导入方法依赖的package包/类
/**
 * Parse a range in the standard mathematical format e.g.
 *
 *     [0, 1) for a closed-open range from 0 to 1.
 *
 * Can also parse single numbers as a closed range e.g.
 *
 *     5 for a closed-closed range from 5 to 5.
 */
public static <T extends Number & Comparable<T>> Range<T> parseNumericRange(Node node, Class<T> type) throws InvalidXMLException {
    String value = node.getValue();

    Matcher matcher = RANGE_RE.matcher(value);
    if(!matcher.matches()) {
        T number = parseNumber(node, value, type, (T) null);
        if(number != null) {
            return Range.singleton(number);
        }
        throw new InvalidXMLException("Invalid " + type.getSimpleName().toLowerCase() + " range '" + value + "'", node);
    }

    T lower = parseNumber(node, matcher.group(2), type, true);
    T upper = parseNumber(node, matcher.group(3), type, true);

    BoundType lowerType = null, upperType = null;
    if(!Double.isInfinite(lower.doubleValue())) {
        lowerType = "(".equals(matcher.group(1)) ? BoundType.OPEN : BoundType.CLOSED;
    }
    if(!Double.isInfinite(upper.doubleValue())) {
        upperType = ")".equals(matcher.group(4)) ? BoundType.OPEN : BoundType.CLOSED;
    }

    if(lower.compareTo(upper) == 1) {
        throw new InvalidXMLException("range lower bound (" + lower + ") cannot be greater than upper bound (" + upper + ")", node);
    }

    if(lowerType == null) {
        if(upperType == null) {
            return Range.all();
        } else {
            return Range.upTo(upper, upperType);
        }
    } else {
        if(upperType == null) {
            return Range.downTo(lower, lowerType);
        } else {
            return Range.range(lower, lowerType, upper, upperType);
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:51,代码来源:XMLUtils.java


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