Esempio n. 1
1
 @Override
 protected PriorityQueue<Float> ofAll(float[] array) {
   return PriorityQueue.ofAll(List.ofAll(array));
 }
Esempio n. 2
1
 @Override
 protected PriorityQueue<Long> ofAll(long[] array) {
   return PriorityQueue.ofAll(List.ofAll(array));
 }
Esempio n. 3
1
 @Override
 protected PriorityQueue<Character> ofAll(char[] array) {
   return PriorityQueue.ofAll(List.ofAll(array));
 }
Esempio n. 4
1
 @Override
 protected PriorityQueue<Double> ofAll(double[] array) {
   return PriorityQueue.ofAll(List.ofAll(array));
 }
Esempio n. 5
1
 @Override
 protected PriorityQueue<Boolean> ofAll(boolean[] array) {
   return PriorityQueue.ofAll(List.ofAll(array));
 }
Esempio n. 6
1
 @Override
 protected PriorityQueue<Byte> ofAll(byte[] array) {
   return PriorityQueue.ofAll(List.ofAll(array));
 }
Esempio n. 7
1
 @Override
 protected PriorityQueue<Integer> ofAll(int[] array) {
   return PriorityQueue.ofAll(List.ofAll(array));
 }
Esempio n. 8
1
 @Override
 protected PriorityQueue<Short> ofAll(short[] array) {
   return PriorityQueue.ofAll(List.ofAll(array));
 }
Esempio n. 9
0
 @Test
 public void shouldNarrowQueue() {
   final PriorityQueue<Double> doubles = of(1.0d);
   final PriorityQueue<Number> numbers = PriorityQueue.narrow(doubles);
   final int actual = numbers.enqueue(new BigDecimal("2.0")).sum().intValue();
   assertThat(actual).isEqualTo(3);
 }
Esempio n. 10
0
 private void assertMinimumsAreEqual(
     java.util.PriorityQueue<Integer> oldQueue, PriorityQueue<Integer> newQueue) {
   assertThat(oldQueue.isEmpty()).isEqualTo(newQueue.isEmpty());
   if (!newQueue.isEmpty()) {
     assertThat(oldQueue.peek()).isEqualTo(newQueue.head());
   }
 }
Esempio n. 11
0
  @Test
  public void shouldMergeTwoPriorityQueues() {
    final PriorityQueue<Integer> source = of(3, 1, 4, 1, 5);
    final PriorityQueue<Integer> target = of(9, 2, 6, 5, 3);
    assertThat(source.merge(target)).isEqualTo(of(3, 1, 4, 1, 5, 9, 2, 6, 5, 3));

    assertThat(PriorityQueue.of(3).merge(PriorityQueue.of(toStringComparator(), 1)))
        .isEqualTo(of(3, 1));
  }
Esempio n. 12
0
 @Test
 public void shouldComputeDistinctOfNonEmptyTraversableUsingKeyExtractor() {
   final Comparator<String> comparator = (o1, o2) -> Integer.compare(o1.charAt(1), o2.charAt(1));
   assertThat(
           PriorityQueue.of(comparator, "5c", "1a", "3a", "1a", "2a", "4b", "3b")
               .distinct()
               .map(s -> s.substring(1)))
       .isEqualTo(of("a", "b", "c"));
 }
Esempio n. 13
0
 @Override
 protected <T> PriorityQueue<T> of(T element) {
   return PriorityQueue.ofAll(toStringComparator(), List.of(element));
 }
Esempio n. 14
0
 @Override
 protected <T> Traversable<T> ofJavaStream(Stream<? extends T> javaStream) {
   return PriorityQueue.ofAll(toStringComparator(), javaStream);
 }
Esempio n. 15
0
 @Override
 protected <T> PriorityQueue<T> empty() {
   return PriorityQueue.empty(toStringComparator());
 }
Esempio n. 16
0
 @Override
 protected <T> Collector<T, ArrayList<T>, PriorityQueue<T>> collector() {
   return PriorityQueue.collector();
 }
Esempio n. 17
0
 @Test
 public void shouldKeepInstanceOfPriorityQueue() {
   final PriorityQueue<Integer> queue = PriorityQueue.of(1, 3, 2);
   assertThat(queue.toPriorityQueue()).isSameAs(queue);
 }
Esempio n. 18
0
 @Test
 public void toListIsSortedAccordingToComparator() {
   final Comparator<Integer> comparator = composedComparator();
   final PriorityQueue<Integer> queue = PriorityQueue.ofAll(comparator, values);
   assertThat(queue.toList()).isEqualTo(values.sorted(comparator));
 }
Esempio n. 19
0
 @Override
 @SuppressWarnings("unchecked")
 protected final <T> PriorityQueue<T> of(T... elements) {
   return PriorityQueue.ofAll(toStringComparator(), List.of(elements));
 }
Esempio n. 20
0
 @Override
 protected <T> PriorityQueue<T> ofAll(Iterable<? extends T> elements) {
   return PriorityQueue.ofAll(toStringComparator(), elements);
 }
Esempio n. 21
0
 @Override
 protected <T> PriorityQueue<T> tabulate(int n, Function<? super Integer, ? extends T> f) {
   return PriorityQueue.tabulate(n, f);
 }
Esempio n. 22
0
 @Override
 protected <T> PriorityQueue<T> fill(int n, Supplier<? extends T> s) {
   return PriorityQueue.fill(n, s);
 }