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


Java NavigableSet.add方法代码示例

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


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

示例1: list

import java.util.NavigableSet; //导入方法依赖的package包/类
public synchronized NavigableSet<NamespaceDescriptor> list() throws IOException {
  NavigableSet<NamespaceDescriptor> ret =
      Sets.newTreeSet(NamespaceDescriptor.NAMESPACE_DESCRIPTOR_COMPARATOR);
  ResultScanner scanner = getNamespaceTable().getScanner(HTableDescriptor.NAMESPACE_FAMILY_INFO_BYTES);
  try {
    for(Result r : scanner) {
      byte[] val = CellUtil.cloneValue(r.getColumnLatestCell(
        HTableDescriptor.NAMESPACE_FAMILY_INFO_BYTES,
        HTableDescriptor.NAMESPACE_COL_DESC_BYTES));
      ret.add(ProtobufUtil.toNamespaceDescriptor(
          HBaseProtos.NamespaceDescriptor.parseFrom(val)));
    }
  } finally {
    scanner.close();
  }
  return ret;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TableNamespaceManager.java

示例2: testDescendingIteratorRemove

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * iterator.remove removes current element
 */
public void testDescendingIteratorRemove() {
    final NavigableSet q = dset0();
    q.add(new Integer(2));
    q.add(new Integer(1));
    q.add(new Integer(3));

    Iterator it = q.iterator();
    it.next();
    it.remove();

    it = q.iterator();
    assertEquals(2, it.next());
    assertEquals(3, it.next());
    assertFalse(it.hasNext());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:TreeSubSetTest.java

示例3: list

import java.util.NavigableSet; //导入方法依赖的package包/类
public NavigableSet<NamespaceDescriptor> list() throws IOException {
  NavigableSet<NamespaceDescriptor> ret =
      Sets.newTreeSet(NamespaceDescriptor.NAMESPACE_DESCRIPTOR_COMPARATOR);
  for(NamespaceDescriptor ns: cache.values()) {
    ret.add(ns);
  }
  return ret;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:9,代码来源:ZKNamespaceManager.java

示例4: testDescendingAddNonComparable

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * Add of non-Comparable throws CCE
 */
public void testDescendingAddNonComparable() {
    NavigableSet q = dset0();
    try {
        q.add(new Object());
        q.add(new Object());
        shouldThrow();
    } catch (ClassCastException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:TreeSubSetTest.java

示例5: addColumn

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * Get the column from the specific family with the specified qualifier.
 * <p>
 * Overrides previous calls to addFamily for this family.
 * @param family family name
 * @param qualifier column qualifier
 * @return the Get objec
 */
public Get addColumn(byte [] family, byte [] qualifier) {
  NavigableSet<byte []> set = familyMap.get(family);
  if(set == null) {
    set = new TreeSet<byte []>(Bytes.BYTES_COMPARATOR);
  }
  if (qualifier == null) {
    qualifier = HConstants.EMPTY_BYTE_ARRAY;
  }
  set.add(qualifier);
  familyMap.put(family, set);
  return this;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:Get.java

示例6: testDescendingContainsAll

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * containsAll(c) is true when c contains a subset of elements
 */
public void testDescendingContainsAll() {
    NavigableSet q = populatedSet(SIZE);
    NavigableSet p = dset0();
    for (int i = 0; i < SIZE; ++i) {
        assertTrue(q.containsAll(p));
        assertFalse(p.containsAll(q));
        p.add(new Integer(i));
    }
    assertTrue(p.containsAll(q));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ConcurrentSkipListSubSetTest.java

示例7: mutateSubSet

import java.util.NavigableSet; //导入方法依赖的package包/类
void mutateSubSet(NavigableSet<Integer> set, int min, int max,
                  BitSet bs) {
    int size = set.size();
    int rangeSize = max - min + 1;

    // Remove a bunch of entries directly
    for (int i = 0, n = rangeSize / 2; i < n; i++) {
        remove(set, min - 5 + rnd.nextInt(rangeSize + 10), bs);
    }

    // Remove a bunch of entries with iterator
    for (Iterator<Integer> it = set.iterator(); it.hasNext(); ) {
        if (rnd.nextBoolean()) {
            bs.clear(it.next());
            it.remove();
        }
    }

    // Add entries till we're back to original size
    while (set.size() < size) {
        int element = min - 5 + rnd.nextInt(rangeSize + 10);
        if (element >= min && element <= max) {
            put(set, element, bs);
        } else {
            try {
                set.add(element);
                shouldThrow();
            } catch (IllegalArgumentException success) {}
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:ConcurrentSkipListSetTest.java

示例8: getCols

import java.util.NavigableSet; //导入方法依赖的package包/类
NavigableSet<byte[]> getCols(String ...strCols) {
  NavigableSet<byte[]> cols = new TreeSet<byte[]>(Bytes.BYTES_COMPARATOR);
  for (String col : strCols) {
    byte[] bytes = Bytes.toBytes(col);
    cols.add(bytes);
  }
  return cols;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:9,代码来源:TestStoreScanner.java

示例9: getPrimes

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * Load the primes up to the specified bound (inclusive) into a
 * {@code NavigableSet}, appending the prime {@code Integer.MAX_VALUE}.
 *
 * @param upperBound The maximum prime to allow
 * @return a set of primes
 */
private static NavigableSet<BigInteger> getPrimes(int upperBound) {
    BitSet bs = createPrimes(upperBound);
    NavigableSet<BigInteger> primes = bs.stream()
            .mapToObj(p -> BigInteger.valueOf(p + 2))
            .collect(toCollection(TreeSet::new));
    primes.add(BigInteger.valueOf(Integer.MAX_VALUE));
    System.out.println(String.format("Created %d primes", primes.size()));
    return primes;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:PrimeTest.java

示例10: mutateSubSet

import java.util.NavigableSet; //导入方法依赖的package包/类
void mutateSubSet(NavigableSet<Integer> set, int min, int max) {
    int size = set.size();
    int rangeSize = max - min + 1;

    // Remove a bunch of entries directly
    for (int i = 0, n = rangeSize / 2; i < n; i++) {
        remove(set, min - 5 + rnd.nextInt(rangeSize + 10));
    }

    // Remove a bunch of entries with iterator
    for (Iterator<Integer> it = set.iterator(); it.hasNext(); ) {
        if (rnd.nextBoolean()) {
            bs.clear(it.next());
            it.remove();
        }
    }

    // Add entries till we're back to original size
    while (set.size() < size) {
        int element = min - 5 + rnd.nextInt(rangeSize + 10);
        if (element >= min && element <= max) {
            put(set, element);
        } else {
            try {
                set.add(element);
                shouldThrow();
            } catch (IllegalArgumentException success) {}
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:TreeSetTest.java

示例11: testDescendingSize

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * size changes when elements added and removed
 */
public void testDescendingSize() {
    NavigableSet q = populatedSet(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(SIZE - i, q.size());
        q.pollFirst();
    }
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.size());
        q.add(new Integer(i));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:ConcurrentSkipListSubSetTest.java

示例12: testAddNull

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * add(null) throws NPE
 */
public void testAddNull() {
    NavigableSet q = set0();
    try {
        q.add(null);
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:TreeSubSetTest.java

示例13: testAddNonComparable

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * Add of non-Comparable throws CCE
 */
public void testAddNonComparable() {
    NavigableSet q = set0();
    try {
        q.add(new Object());
        q.add(new Object());
        shouldThrow();
    } catch (ClassCastException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:TreeSubSetTest.java

示例14: testContainsAll

import java.util.NavigableSet; //导入方法依赖的package包/类
/**
 * containsAll(c) is true when c contains a subset of elements
 */
public void testContainsAll() {
    NavigableSet q = populatedSet(SIZE);
    NavigableSet p = set0();
    for (int i = 0; i < SIZE; ++i) {
        assertTrue(q.containsAll(p));
        assertFalse(p.containsAll(q));
        p.add(new Integer(i));
    }
    assertTrue(p.containsAll(q));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:TreeSubSetTest.java

示例15: testAsMapNavigableReadsThrough

import java.util.NavigableSet; //导入方法依赖的package包/类
@GwtIncompatible // NavigableMap
public void testAsMapNavigableReadsThrough() {
  NavigableSet<String> strings = Sets.newTreeSet();
  Collections.addAll(strings, "one", "two", "three");
  NavigableMap<String, Integer> map = Maps.asMap(strings, LENGTH_FUNCTION);
  assertNull(map.comparator());
  assertEquals(ImmutableSortedMap.of("one", 3, "two", 3, "three", 5), map);
  assertNull(map.get("four"));
  strings.add("four");
  assertEquals(
      ImmutableSortedMap.of("one", 3, "two", 3, "three", 5, "four", 4),
      map);
  assertEquals(Integer.valueOf(4), map.get("four"));
  SortedMap<String, Integer> headMap = map.headMap("two");
  assertEquals(
      ImmutableSortedMap.of("four", 4, "one", 3, "three", 5),
      headMap);
  strings.add("five");
  strings.remove("one");
  assertEquals(
      ImmutableSortedMap.of("five", 4, "four", 4, "three", 5),
      headMap);
  assertThat(map.entrySet()).containsExactly(
      mapEntry("five", 4),
      mapEntry("four", 4),
      mapEntry("three", 5),
      mapEntry("two", 3)).inOrder();

  NavigableMap<String, Integer> tailMap = map.tailMap("s", true);
  NavigableMap<String, Integer> subMap = map.subMap("a", true, "t", false);

  strings.add("six");
  strings.remove("two");
  assertThat(tailMap.entrySet()).containsExactly(
      mapEntry("six", 3),
      mapEntry("three", 5)).inOrder();
  assertThat(subMap.entrySet()).containsExactly(
      mapEntry("five", 4),
      mapEntry("four", 4),
      mapEntry("six", 3)).inOrder();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:42,代码来源:MapsTest.java


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