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


Java DiscreteDomain类代码示例

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


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

示例1: create

import com.google.common.collect.DiscreteDomain; //导入依赖的package包/类
@Override
protected SortedSet<Integer> create(Integer[] elements) {
  SortedSet<Integer> set = nullCheckedTreeSet(elements);
  if (set.isEmpty()) {
    /*
     * The (tooLow + 1, tooHigh) arguments below would be invalid because tooLow would be
     * greater than tooHigh.
     */
    return ContiguousSet.create(Range.openClosed(0, 1), DiscreteDomain.integers()).subSet(0, 1);
  }
  int tooHigh = set.last() + 1;
  int tooLow = set.first() - 1;
  set.add(tooHigh);
  set.add(tooLow);
  return checkedCreate(set).subSet(tooLow + 1, tooHigh);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:17,代码来源:SetGenerators.java

示例2: multipleGroupByTest

import com.google.common.collect.DiscreteDomain; //导入依赖的package包/类
@Test
public void multipleGroupByTest() throws Exception {
	Set expectedAges = new HashSet<Integer>(ContiguousSet.create(Range.closed(20, 40), DiscreteDomain.integers()));

	Map<String, Set<Integer>> buckets = new HashMap<>();

	Aggregations result = query(String.format("SELECT COUNT(*) FROM %s/account GROUP BY gender,  terms('field'='age','size'=200,'alias'='age')", TEST_INDEX));
	Terms gender = result.get("gender");
	for(Terms.Bucket genderBucket : gender.getBuckets()) {
		String genderKey = genderBucket.getKey().toString();
		buckets.put(genderKey, new HashSet<Integer>());
		Terms ageBuckets = (Terms) genderBucket.getAggregations().get("age");
		for(Terms.Bucket ageBucket : ageBuckets.getBuckets()) {
			buckets.get(genderKey).add(Integer.parseInt(ageBucket.getKey().toString()));
		}
	}

	Assert.assertEquals(2, buckets.keySet().size());
	Assert.assertEquals(expectedAges, buckets.get("m"));
	Assert.assertEquals(expectedAges, buckets.get("f"));
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:22,代码来源:AggregationTest.java

示例3: multipleGroupBysWithSize

import com.google.common.collect.DiscreteDomain; //导入依赖的package包/类
@Test
public void multipleGroupBysWithSize() throws Exception {
    Set expectedAges = new HashSet<Integer>(ContiguousSet.create(Range.closed(20, 40), DiscreteDomain.integers()));

    Map<String, Set<Integer>> buckets = new HashMap<>();

    Aggregations result = query(String.format("SELECT COUNT(*) FROM %s/account GROUP BY gender, terms('alias'='ageAgg','field'='age','size'=3)", TEST_INDEX));
    Terms gender = result.get("gender");
    Assert.assertEquals(2,gender.getBuckets().size());
    for(Terms.Bucket genderBucket : gender.getBuckets()) {

        String genderKey = genderBucket.getKey().toString();
        buckets.put(genderKey, new HashSet<Integer>());
        Terms ageBuckets = genderBucket.getAggregations().get("ageAgg");
        Assert.assertEquals(3,ageBuckets.getBuckets().size());

    }


}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:21,代码来源:AggregationTest.java

示例4: load

import com.google.common.collect.DiscreteDomain; //导入依赖的package包/类
public WorldGenSpikes.EndSpike[] load(Long p_load_1_) throws Exception
{
    List<Integer> list = Lists.newArrayList(ContiguousSet.create(Range.closedOpen(Integer.valueOf(0), Integer.valueOf(10)), DiscreteDomain.integers()));
    Collections.shuffle(list, new Random(p_load_1_.longValue()));
    WorldGenSpikes.EndSpike[] aworldgenspikes$endspike = new WorldGenSpikes.EndSpike[10];

    for (int i = 0; i < 10; ++i)
    {
        int j = (int)(42.0D * Math.cos(2.0D * (-Math.PI + (Math.PI / 10D) * (double)i)));
        int k = (int)(42.0D * Math.sin(2.0D * (-Math.PI + (Math.PI / 10D) * (double)i)));
        int l = ((Integer)list.get(i)).intValue();
        int i1 = 2 + l / 3;
        int j1 = 76 + l * 3;
        boolean flag = l == 1 || l == 2;
        aworldgenspikes$endspike[i] = new WorldGenSpikes.EndSpike(j, k, i1, j1, flag);
    }

    return aworldgenspikes$endspike;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:20,代码来源:BiomeEndDecorator.java

示例5: getValidPixelSetAsIntArr

import com.google.common.collect.DiscreteDomain; //导入依赖的package包/类
/**
 * Return an int array with the ids of the pixelSet belonging to the given Key,
 * return all camera pixel Ids if the set is not existing
 */
public static int[] getValidPixelSetAsIntArr(Data item, int npix, String pixelSetKey) {
    int[] pixels;

    //Load a given pixelset, otherwise use the the whole camera

    if (pixelSetKey == null) {
        ContiguousSet<Integer> numbers = ContiguousSet.create(Range.closed(0, npix - 1), DiscreteDomain.integers());
        pixels = Ints.toArray(numbers);
    } else {
        Utils.isKeyValid(item, pixelSetKey, PixelSet.class);
        PixelSet pixelSet = (PixelSet) item.get(pixelSetKey);
        pixels = pixelSet.toIntArray();
    }

    return pixels;
}
 
开发者ID:fact-project,项目名称:fact-tools,代码行数:21,代码来源:Utils.java

示例6: modify

import com.google.common.collect.DiscreteDomain; //导入依赖的package包/类
private String modify(String data, Set<Integer> indexesToRemove) {
  List<String> lines = Arrays.asList(StringUtils.split(data, NEWLINE));
  Set<Integer> dataIndexes = ContiguousSet.create(Range.closed(1, lines.size()),
      DiscreteDomain.integers());
  if (!dataIndexes.containsAll(indexesToRemove)) {
    LOGGER.warn("Some of defined ranges exceed source lenght. Source length is: " + lines.size());
  }
  Set<Integer> filtereedIndexesToRemove = Sets.intersection(dataIndexes, indexesToRemove);
  List<String> modifiedLines = new ArrayList<String>(
      lines.size() - filtereedIndexesToRemove.size());
  for (int i = 0; i < lines.size(); i++) {
    if (!filtereedIndexesToRemove.contains(i + 1)) {
      modifiedLines.add(lines.get(i));
    }
  }
  return StringUtils.join(modifiedLines, NEWLINE);
}
 
开发者ID:Cognifide,项目名称:aet,代码行数:18,代码来源:RemoveLinesDataModifier.java

示例7: addHeadersToSheet

import com.google.common.collect.DiscreteDomain; //导入依赖的package包/类
/**
 * Ajoute les en-têtes dans la feuille de calcul et cache les colonnes qui doivent l'être.
 * 
 * @param sheet feuille de calcul
 * @param rowIndex numéro de la ligne
 * @param columnInfos RangeMap contenant les informations de colonnes (valeurs) et les index sur auxquelles s'appliquent ces colonnes (clés).
 *                    Les "colonnes" s'étendant sur plus d'un index seront automatiquement fusionnées.
 */
protected void addHeadersToSheet(Sheet sheet, int rowIndex, RangeMap<Integer, ColumnInformation> columnInfos) {
	Row rowHeader = sheet.createRow(rowIndex);
	for (Map.Entry<Range<Integer>, ColumnInformation> entry : columnInfos.asMapOfRanges().entrySet()) {
		Range<Integer> range = entry.getKey();
		ColumnInformation columnInformation = entry.getValue();
		
		addHeaderCell(rowHeader, range.lowerEndpoint(), getColumnLabel(columnInformation.getHeaderKey()));
		
		for (Integer columnIndex : ContiguousSet.create(range, DiscreteDomain.integers())) {
			sheet.setColumnHidden(columnIndex, columnInformation.isHidden());
		}
		
		int beginIndex = range.lowerEndpoint();
		int endIndex = range.upperEndpoint();
		if (beginIndex != endIndex) {
			sheet.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, beginIndex, endIndex));
		}
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:28,代码来源:AbstractExcelTableExport.java

示例8: checkOnNext

import com.google.common.collect.DiscreteDomain; //导入依赖的package包/类
private static void checkOnNext(MemoizingObserver<Object> observer) {
    assertTrue(observer.responses().isEmpty());

    final Object firstResponse = new Object();
    observer.onNext(firstResponse);
    assertEquals(firstResponse, observer.firstResponse());

    final ContiguousSet<Integer> sorted = ContiguousSet.create(Range.closed(1, 20),
                                                               DiscreteDomain.integers());
    final List<Integer> moreResponses = newArrayList(newHashSet(sorted));

    for (Integer element : moreResponses) {
        observer.onNext(element);
    }
    final List<Object> actualResponses = observer.responses();

    assertEquals(firstResponse, actualResponses.get(0));
    assertEquals(moreResponses.size() + 1, // as there was the first response
                 actualResponses.size());
    assertEquals(moreResponses, actualResponses.subList(1, actualResponses.size()));
}
 
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:22,代码来源:StreamObserversShould.java

示例9: UniformCrossover

import com.google.common.collect.DiscreteDomain; //导入依赖的package包/类
@VisibleForTesting
UniformCrossover(final RandomGenerator rng, final double p) {
    this(new Function<Integer, Iterable<Integer>>() {
        @Override
        public Iterable<Integer> apply(final Integer bitStringLength) {
            if (bitStringLength * p < 0.01) {
                return Samplings.random(rng).withoutReplacement().sample(
                        ContiguousSet.create(Range.closedOpen(0, bitStringLength), DiscreteDomain.integers()),
                        new BinomialDistribution(rng, bitStringLength, p).sample()
                );
            } else {
                return Iterables.filter(
                        ContiguousSet.create(Range.closedOpen(0, bitStringLength), DiscreteDomain.integers()),
                        new Predicate<Integer>() {
                            @Override
                            public boolean apply(@Nullable final Integer input) {
                                return p > rng.nextFloat();
                            }
                        });
            }
        }
    });
}
 
开发者ID:asoem,项目名称:greyfish,代码行数:24,代码来源:Recombinations.java

示例10: multipleGroupByTest

import com.google.common.collect.DiscreteDomain; //导入依赖的package包/类
@Test
public void multipleGroupByTest() throws Exception {
	Set expectedAges = new HashSet<Integer>(ContiguousSet.create(Range.closed(20, 40), DiscreteDomain.integers()));

	Map<String, Set<Integer>> buckets = new HashMap<>();

	Aggregations result = query(String.format("SELECT COUNT(*) FROM %s/account GROUP BY gender, age", TestsConstants.TEST_INDEX));
	Terms gender = result.get("gender");
	for(Terms.Bucket genderBucket : gender.getBuckets()) {
		String genderKey = genderBucket.getKey().toString();
		buckets.put(genderKey, new HashSet<Integer>());
		Terms ageBuckets = (Terms) genderBucket.getAggregations().get("age");
		for(Terms.Bucket ageBucket : ageBuckets.getBuckets()) {
			buckets.get(genderKey).add(Integer.parseInt(ageBucket.getKey().toString()));
		}
	}

	Assert.assertEquals(2, buckets.keySet().size());
	Assert.assertEquals(expectedAges, buckets.get("m"));
	Assert.assertEquals(expectedAges, buckets.get("f"));
}
 
开发者ID:selvakumarEsra,项目名称:es4sql,代码行数:22,代码来源:AggregationTest.java

示例11: multipleGroupByTest

import com.google.common.collect.DiscreteDomain; //导入依赖的package包/类
@Test
public void multipleGroupByTest() throws Exception {
	Set expectedAges = new HashSet<Integer>(ContiguousSet.create(Range.closed(20, 40), DiscreteDomain.integers()));

	Map<String, Set<Integer>> buckets = new HashMap<>();

	Aggregations result = query(String.format("SELECT COUNT(*) FROM %s/account GROUP BY gender,  terms('field'='age','size'=200,'alias'='age')", TEST_INDEX_ACCOUNT));
	Terms gender = result.get("gender");
	for(Terms.Bucket genderBucket : gender.getBuckets()) {
		String genderKey = genderBucket.getKey().toString();
		buckets.put(genderKey, new HashSet<Integer>());
		Terms ageBuckets = (Terms) genderBucket.getAggregations().get("age");
		for(Terms.Bucket ageBucket : ageBuckets.getBuckets()) {
			buckets.get(genderKey).add(Integer.parseInt(ageBucket.getKey().toString()));
		}
	}

	Assert.assertEquals(2, buckets.keySet().size());
	Assert.assertEquals(expectedAges, buckets.get("m"));
	Assert.assertEquals(expectedAges, buckets.get("f"));
}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:22,代码来源:AggregationTest.java

示例12: multipleGroupBysWithSize

import com.google.common.collect.DiscreteDomain; //导入依赖的package包/类
@Test
public void multipleGroupBysWithSize() throws Exception {
    Set expectedAges = new HashSet<Integer>(ContiguousSet.create(Range.closed(20, 40), DiscreteDomain.integers()));

    Map<String, Set<Integer>> buckets = new HashMap<>();

    Aggregations result = query(String.format("SELECT COUNT(*) FROM %s/account GROUP BY gender, terms('alias'='ageAgg','field'='age','size'=3)", TEST_INDEX_ACCOUNT));
    Terms gender = result.get("gender");
    Assert.assertEquals(2,gender.getBuckets().size());
    for(Terms.Bucket genderBucket : gender.getBuckets()) {

        String genderKey = genderBucket.getKey().toString();
        buckets.put(genderKey, new HashSet<Integer>());
        Terms ageBuckets = genderBucket.getAggregations().get("ageAgg");
        Assert.assertEquals(3,ageBuckets.getBuckets().size());

    }


}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:21,代码来源:AggregationTest.java

示例13: generate_odd_numbers_in_range_guava

import com.google.common.collect.DiscreteDomain; //导入依赖的package包/类
@Test
public void generate_odd_numbers_in_range_guava() {

	Set<Integer> set = ContiguousSet.create(Range.closed(1, 10),
			DiscreteDomain.integers());

	Iterable<Integer> oddNumbers = Iterables.filter(set,
			new Predicate<Integer>() {
				@Override
				public boolean apply(Integer input) {
					return input % 2 != 0;
				}
			});

	logger.info(oddNumbers);

	assertThat(
			oddNumbers,
			contains(new Integer(1), new Integer(3), new Integer(5),
					new Integer(7), new Integer(9)));
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:22,代码来源:GenerateOddNumbers.java

示例14: generate_even_numbers_in_range_guava

import com.google.common.collect.DiscreteDomain; //导入依赖的package包/类
@Test
public void generate_even_numbers_in_range_guava() {

	Set<Integer> set = ContiguousSet.create(Range.closed(1, 10),
			DiscreteDomain.integers());

	Iterable<Integer> evenNumbers = Iterables.filter(set,
			new Predicate<Integer>() {
				@Override
				public boolean apply(Integer input) {
					return input % 2 == 0;
				}
			});


	assertThat(
			evenNumbers,
			contains(new Integer(2), new Integer(4), new Integer(6),
					new Integer(8), new Integer(10)));
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:21,代码来源:GenerateEvenNumbers.java

示例15: normalizeRange

import com.google.common.collect.DiscreteDomain; //导入依赖的package包/类
private static Range<Integer> normalizeRange(final Range<Integer> range)
{
    Range<Integer> newRange = AT_LEAST_ZERO.intersection(range);

    if (newRange.isEmpty())
        throw new IllegalArgumentException("illegal range " + range
            + ": intersection with " + AT_LEAST_ZERO + " is empty");

    newRange = newRange.canonical(DiscreteDomain.integers());

    final int lowerBound = newRange.lowerEndpoint();

    return newRange.hasUpperBound()
        ? Range.closed(lowerBound, newRange.upperEndpoint() - 1)
        : Range.atLeast(lowerBound);
}
 
开发者ID:fge,项目名称:grappa,代码行数:17,代码来源:RangeMatcherBuilder.java


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