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


Java BoundType.OPEN属性代码示例

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


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

示例1: testIncludes

@Test
public void testIncludes() throws Exception {
    DestinationName dn = DestinationName.get("persistent://pulsar/use/ns1/topic-1");
    Long hashKey = factory.getLongHashCode(dn.toString());
    Long upper = Math.max(hashKey + 1, NamespaceBundles.FULL_UPPER_BOUND);
    BoundType upperType = upper.equals(NamespaceBundles.FULL_UPPER_BOUND) ? BoundType.CLOSED : BoundType.OPEN;
    NamespaceBundle bundle = factory.getBundle(dn.getNamespaceObject(),
            Range.range(hashKey / 2, BoundType.CLOSED, upper, upperType));
    assertTrue(bundle.includes(dn));
    bundle = factory.getBundle(NamespaceName.get("pulsar/use/ns1"),
            Range.range(upper, BoundType.CLOSED, NamespaceBundles.FULL_UPPER_BOUND, BoundType.CLOSED));
    assertTrue(!bundle.includes(dn));

    NamespaceBundle otherBundle = factory.getBundle(NamespaceName.get("pulsar/use/ns2"),
            Range.range(0l, BoundType.CLOSED, 0x40000000L, BoundType.OPEN));
    assertTrue(!otherBundle.includes(dn));
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:17,代码来源:NamespaceBundleTest.java

示例2: canonical

static Range<IPAddress> canonical(final Range<IPAddress> range,
    final LongDiscreteDomain<IPAddress> domain) {
  if (range.isEmpty()) {
    return null;
  }
  final boolean l = range.lowerBoundType() == BoundType.OPEN;
  final boolean u = range.upperBoundType() == BoundType.OPEN;
  final IPAddress s = range.lowerEndpoint();
  final IPAddress e = range.upperEndpoint();
  if (l && u) {
    Range.closed(domain.next(s), domain.previous(e));
  } else if (l) {
    return Range.closed(domain.next(s), e);
  } else if (u) {
    return Range.closed(s, domain.previous(e));
  }
  return range;
}
 
开发者ID:canbican,项目名称:jiplib,代码行数:18,代码来源:IPAddresses.java

示例3: computeBmp

private void computeBmp(RangeMap<Integer, Short> fullMap) {
    for (Map.Entry<Range<Integer>, Short> me : fullMap.asMapOfRanges().entrySet()) {
        Range<Integer> range = me.getKey();
        int min = range.lowerEndpoint();
        if (range.lowerBoundType() == BoundType.OPEN) {
            min++;
        }
        if (min < Character.MAX_VALUE) {
            int rmax = range.upperEndpoint();
            if (range.upperBoundType() == BoundType.OPEN) {
                rmax--;
            }
            int max = Math.min(Character.MAX_VALUE, rmax);
            for (int x = min; x <= max; x++) {
                this.bmpMap[x] = me.getValue();
            }
        }
    }
}
 
开发者ID:basis-technology-corp,项目名称:tcl-regex-java,代码行数:19,代码来源:RuntimeColorMap.java

示例4: isLessThan

/**
 * Return true if the specified range is strictly less than the specified value.
 *
 * @param <C> range endpoint type
 * @param range range, must not be null
 * @param value value, must not be null
 * @return true if the specified range is strictly less than the specified value
 */
public static <C extends Comparable> boolean isLessThan(final Range<C> range, final C value)
{
    checkNotNull(range);
    checkNotNull(value);

    if (!range.hasUpperBound())
    {
        return false;
    }
    if (range.upperBoundType() == BoundType.OPEN && range.upperEndpoint().equals(value))
    {
        return true;
    }
    return range.upperEndpoint().compareTo(value) < 0;
}
 
开发者ID:heuermh,项目名称:variation-cytoscape3-app,代码行数:23,代码来源:Ranges.java

示例5: getHashRange

private static Range<Long> getHashRange(String rangePathPart) {
    String[] endPoints = rangePathPart.split("_");
    checkArgument(endPoints.length == 2, "Malformed bundle hash range path part:" + rangePathPart);
    Long startLong = Long.decode(endPoints[0]);
    Long endLong = Long.decode(endPoints[1]);
    BoundType endType = (endPoints[1].equals(LAST_BOUNDARY)) ? BoundType.CLOSED : BoundType.OPEN;
    return Range.range(startLong, BoundType.CLOSED, endLong, endType);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:8,代码来源:ServiceUnitZkUtils.java

示例6: Range

public Range(final com.google.common.collect.Range<T> range) {
	_range = range;
	_upperBound = range.hasUpperBound() ? range.upperEndpoint() : null;
	_lowerBound = range.hasLowerBound() ? range.lowerEndpoint() : null;
	
	_upperBoundType = range.hasUpperBound() ? range.upperBoundType() : BoundType.OPEN;
	_lowerBoundType = range.hasLowerBound() ? range.lowerBoundType() : BoundType.OPEN;
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:8,代码来源:Range.java

示例7: lookupBucketTable

public ShardState lookupBucketTable(Range<Integer> range) {
    Map<Range<Integer>, ShardState> rangeMaps = bucketMap.subRangeMap(range).asMapOfRanges();
    if (rangeMaps.size() > 1) {
        boolean same = true;
        ShardState prev = null;
        for (Map.Entry<Range<Integer>, ShardState> e : rangeMaps.entrySet()) {
            Range<Integer> r = e.getKey();
            if (r.upperEndpoint() - r.lowerEndpoint() <= 1 && r.lowerBoundType() == BoundType.OPEN
                && r.upperBoundType() == BoundType.OPEN) {
                continue;
            }
            if (prev != null && !prev.equals(e.getValue())) {
                same = false;
                break;

            }
            prev = e.getValue();
        }
        if (!same) {
            throw new IllegalStateException(
                "Overlapped range found - inputRange=" + range + " ranges=" + rangeMaps.toString());
        }
        return prev;
    } else if (rangeMaps.size() == 0) {
        return null;
    }
    return rangeMaps.values().stream().findFirst().get();
}
 
开发者ID:yahoo,项目名称:gondola,代码行数:28,代码来源:BucketManager.java

示例8: bounds

public <O extends Comparable<? super O>>Range<O> bounds() {
  O mini = minInclusive();
  O mine = minExclusive();
  O maxi = maxInclusive();
  O maxe = maxExclusive();
  Ordering<O> ordering = Ordering.<O>natural();
  O min = ordering.nullsLast().min(mini,mine);
  O max = ordering.nullsFirst().max(maxi,maxe);
  BoundType lower = 
    min == null ? null :
    min == mini ? BoundType.CLOSED :
      BoundType.OPEN;
  BoundType upper = 
    max == null ? null : 
    max == maxi ? BoundType.CLOSED :
      BoundType.OPEN;
  if (lower == null && upper == null)
    return Range.<O>all();
  else if (lower != null && upper == null) 
    return lower == BoundType.CLOSED ? 
      Range.atLeast(min) : 
      Range.greaterThan(min);
  else if (lower == null && upper != null)
    return upper == BoundType.CLOSED ?
      Range.atMost(max) :
      Range.lessThan(max);
  else {
    return Range.range(min, lower, max, upper);
  }
}
 
开发者ID:OpenSocial,项目名称:activitystreams,代码行数:30,代码来源:Parameter.java

示例9: AddressIterable

/**
 * @param range
 *          the address range
 * @param domain
 *          addressing domain
 */
public AddressIterable(final Range<IPAddress> range) {
  this();
  this.range = range;
  this.domain = (LongDiscreteDomain<IPAddress>) range.lowerEndpoint()
      .getDomain();
  this.current = range.lowerEndpoint();
  if (range.lowerBoundType() == BoundType.OPEN) {
    this.current = this.domain.next(this.current);
  }
}
 
开发者ID:canbican,项目名称:jiplib,代码行数:16,代码来源:AddressIterable.java

示例10: size

/**
 * @return size of the address range
 */
public BigInteger size() {
  BigInteger result = this.domain.distance(this.range.lowerEndpoint(),
      this.range.upperEndpoint());
  result = result.add(BigInteger.ONE);
  if (this.range.upperBoundType() == BoundType.OPEN) {
    result = result.subtract(BigInteger.ONE);
  }
  if (this.range.lowerBoundType() == BoundType.OPEN) {
    result = result.subtract(BigInteger.ONE);
  }
  return result;
}
 
开发者ID:canbican,项目名称:jiplib,代码行数:15,代码来源:AddressIterable.java

示例11: simplifyUsingPredicates

private <C extends Comparable<C>> RexNode simplifyUsingPredicates(RexNode e,
    Class<C> clazz) {
  final Comparison comparison = Comparison.of(e);
  // Check for comparison with null values
  if (comparison == null
      || comparison.kind == SqlKind.NOT_EQUALS
      || comparison.literal.getValue() == null) {
    return e;
  }
  final C v0 = comparison.literal.getValueAs(clazz);
  final Range<C> range = range(comparison.kind, v0);
  final Range<C> range2 =
      residue(comparison.ref, range, predicates.pulledUpPredicates,
          clazz);
  if (range2 == null) {
    // Term is impossible to satisfy given these predicates
    return rexBuilder.makeLiteral(false);
  } else if (range2.equals(range)) {
    // no change
    return e;
  } else if (range2.equals(Range.all())) {
    // Term is always satisfied given these predicates
    return rexBuilder.makeLiteral(true);
  } else if (range2.lowerEndpoint().equals(range2.upperEndpoint())) {
    if (range2.lowerBoundType() == BoundType.OPEN
        || range2.upperBoundType() == BoundType.OPEN) {
      // range is a point, but does not include its endpoint, therefore is
      // effectively empty
      return rexBuilder.makeLiteral(false);
    }
    // range is now a point; it's worth simplifying
    return rexBuilder.makeCall(SqlStdOperatorTable.EQUALS, comparison.ref,
        rexBuilder.makeLiteral(range2.lowerEndpoint(),
            comparison.literal.getType(), comparison.literal.getTypeName()));
  } else {
    // range has been reduced but it's not worth simplifying
    return e;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:39,代码来源:RexSimplify.java

示例12: subrange

/**
 * subrange - allocate new subcolors to this range of chars, fill in arcs.
 * The range will overlap existing ranges; even in the simplest case,
 * it will overlap the initial WHITE range. For each existing range that
 * it overlaps, allocate a new color, mark the range as mapping to that color,
 * and add an arc between the states for that color.
 */
void subrange(int from, int to, State lp, State rp) throws RegexException {
    /* Avoid one call to map.get() for each character in the range.
     * This map will usually contain one item, but in complex cases more.
     * For example, if we had [a-f][g-h] and then someone asked for [f-g], there
     * would be two. Each of these new ranges will get a new color via subcolor.
     */
    Map<Range<Integer>, Short> curColors = map.subRangeMap(Range.closed(from, to)).asMapOfRanges();
    /*
     * To avoid concurrent mod problems, we need to copy the ranges we are working from.
     */
    List<Range<Integer>> ranges = Lists.newArrayList(curColors.keySet());
    for (Range<Integer> rangeToProcess : ranges) {
        // bound management here irritating.
        int start = rangeToProcess.lowerEndpoint();
        if (rangeToProcess.lowerBoundType() == BoundType.OPEN) {
            start++;
        }
        int end = rangeToProcess.upperEndpoint();
        if (rangeToProcess.upperBoundType() == BoundType.CLOSED) {
            end++;
        }
        // allocate a new subcolor and account it owning the entire range.
        short color = subcolor(start, end - start);
        compiler.getNfa().newarc(Compiler.PLAIN, color, lp, rp);
    }
}
 
开发者ID:basis-technology-corp,项目名称:tcl-regex-java,代码行数:33,代码来源:ColorMap.java

示例13: isLessThan

/**
 * Return true if the specified range is strictly less than the specified value.
 *
 * @param <C> range endpoint type
 * @param range range, must not be null
 * @param value value, must not be null
 * @return true if the specified range is strictly less than the specified value
 */
public static <C extends Comparable> boolean isLessThan(final Range<C> range, final C value) {
    checkNotNull(range);
    checkNotNull(value);

    if (!range.hasUpperBound()) {
        return false;
    }
    if (range.upperBoundType() == BoundType.OPEN && range.upperEndpoint().equals(value)) {
        return true;
    }
    return range.upperEndpoint().compareTo(value) < 0;
}
 
开发者ID:nmdp-bioinformatics,项目名称:ngs,代码行数:20,代码来源:Ranges.java

示例14: isGreaterThan

/**
 * Return true if the specified range is strictly greater than the specified value.
 *
 * @param <C> range endpoint type
 * @param range range, must not be null
 * @param value value, must not be null
 * @return true if the specified range is strictly greater than the specified value
 */
public static <C extends Comparable> boolean isGreaterThan(final Range<C> range, final C value) {
    checkNotNull(range);
    checkNotNull(value);

    if (!range.hasLowerBound()) {
        return false;
    }
    if (range.lowerBoundType() == BoundType.OPEN && range.lowerEndpoint().equals(value)) {
        return true;
    }
    return range.lowerEndpoint().compareTo(value) > 0;
}
 
开发者ID:nmdp-bioinformatics,项目名称:ngs,代码行数:20,代码来源:Ranges.java

示例15: any

/**
 * Generate a {@code long} within the intersection formed by the specified {@code range} and this instance own range.
 *
 * @param range the specfied range
 * @return a generated {@code long}
 */
public long any(final Range<Long> range) {

  Range<Long> r = range.intersection(constraint);

  if (r.isEmpty()) {
    throw new IllegalStateException(String.format(
        "The intersection of the passed in range %s and this class constrained range %s result in a empty range", range, constraint));
  }

  long upperBound = r.hasUpperBound() ? r.upperEndpoint() : Long.MAX_VALUE;
  long lowerBound = r.hasLowerBound() ? r.lowerEndpoint() : Long.MIN_VALUE;

  if (r.hasUpperBound() && BoundType.CLOSED == r.upperBoundType()) {
    upperBound++;
  }

  if (r.hasLowerBound() && BoundType.OPEN == r.lowerBoundType()) {
    lowerBound++;
  }

  long delta = Math.abs(upperBound - lowerBound);

  long randomLong = ((( Math.abs(this.random.nextLong()) % (delta / resolution))) * resolution) + lowerBound ;

  return randomLong;
}
 
开发者ID:letrait,项目名称:magenta,代码行数:32,代码来源:RandomLong.java


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