Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
268,300
void () { Map<Object, Object> map = CollectionFactory.createWeakIdentityMap(10, 0.5f); checkHashCodeDoesntCalledFor(map); }
testWeakNativeHashCodeDoesNotGetCalledWhenCustomStrategyIsSpecified
268,301
void () { Map<Object, Object> map = CollectionFactory.createSoftMap(HashingStrategy.identity()); checkHashCodeDoesntCalledFor(map); }
testSoftNativeHashCodeDoesNotGetCalledWhenCustomStrategyIsSpecified
268,302
void (Map<Object, Object> map) { Object key = new Object(){ @Override public int hashCode() { fail("must not be called"); return super.hashCode(); } }; map.put(key, "ab"); assertSame("ab", map.get(key)); map.remove(key); assertTrue(map.isEmpty()); }
checkHashCodeDoesntCalledFor
268,303
int () { fail("must not be called"); return super.hashCode(); }
hashCode
268,304
void () { ConcurrentMap<String, String> map = CollectionFactory.createConcurrentSoftMap(10, 0.7f, 16, IGNORE_CASE_WITH_CRAZY_HASH_STRATEGY); map.put("ab", "ab"); assertEquals(1, map.size()); assertSame("ab",map.get("AB")); String removed = map.remove("aB"); assertEquals("ab", removed); assertTrue(map.isEmpty()); }
testConcurrentSoftCustomStrategy
268,305
void () { Map<String, String> map = CollectionFactory.createConcurrentSoftMap(); assertNullKeysMustThrow(map); assertNullValuesMustThrow(map); }
testConcurrentSoftMapMustNotAcceptNullKeyOrValue
268,306
void () { Map<String, String> map = ContainerUtil.createConcurrentWeakMap(); assertNullKeysMustThrow(map); assertNullValuesMustThrow(map); }
testConcurrentWeakMapMustNotAcceptNullKeyOrValue
268,307
void () { Map<String, String> map = CollectionFactory.createConcurrentWeakKeySoftValueMap(1, 1, 1, IGNORE_CASE_WITH_CRAZY_HASH_STRATEGY); assertNullKeysMustThrow(map); assertNullValuesMustThrow(map); }
testConcurrentWeakKeySoftValueMapMustNotAcceptNullKeyOrValue
268,308
void () { Map<String, String> map = ContainerUtil.createConcurrentWeakKeyWeakValueMap(IGNORE_CASE_WITH_CRAZY_HASH_STRATEGY); assertNullKeysMustThrow(map); assertNullValuesMustThrow(map); }
testConcurrentWeakKeyWeakValueMustNotAcceptNullKeyOrValue
268,309
void () { assertNullKeysMustThrow(CollectionFactory.createWeakMap(11,0.5f,HashingStrategy.canonical())); }
testWeakMapMustNotAcceptNullKey
268,310
void () { assertNullKeysMustThrow(CollectionFactory.createSoftMap()); }
testSoftMapMustNotAcceptNullKey
268,311
void () { assertNullKeysMustThrow(ContainerUtil.createWeakKeySoftValueMap()); }
testWeakKeySoftValueMapMustNotAcceptNullKey
268,312
void () { assertNullKeysMustThrow(ContainerUtil.createWeakKeyWeakValueMap()); }
testWeakKeyWeakValueMapMustNotAcceptNullKey
268,313
void () { assertNullKeysMustThrow(CollectionFactory.createSoftKeySoftValueMap()); }
testSoftKeySoftValueMapMustNotAcceptNullKey
268,314
void () { assertNullKeysMustThrow(ContainerUtil.createSoftValueMap()); }
testSoftValueMapMustNotAcceptNullKey
268,315
void () { assertNullKeysMustThrow(ContainerUtil.createWeakValueMap()); }
testWeakValueMapMustNotAcceptNullKey
268,316
void (Map<String, ? super String> map) { UsefulTestCase.assertThrows(IllegalArgumentException.class, () -> map.put(null, "ab")); assertEquals(0, map.size()); UsefulTestCase.assertThrows(IllegalArgumentException.class, () -> map.get(null)); UsefulTestCase.assertThrows(IllegalArgumentException.class, () -> map.remove(nul...
assertNullKeysMustThrow
268,317
void (Map<? super String, String> map) { UsefulTestCase.assertThrows(IllegalArgumentException.class, () -> map.put("ab", null)); assertEquals(0, map.size()); }
assertNullValuesMustThrow
268,318
void () { ConcurrentMap<String, String> map = CollectionFactory.createConcurrentWeakKeySoftValueMap(1, 1, 1, IGNORE_CASE_WITH_CRAZY_HASH_STRATEGY); map.put("ab", "ab"); assertEquals(1, map.size()); assertSame("ab", map.get("AB")); String removed = map.remove("aB"); assertEquals("ab", removed); assertTrue(map.isEmpty())...
testConcurrentWeakSoftCustomStrategy
268,319
void () { ConcurrentLongObjectMap<Object> map = ConcurrentCollectionFactory.createConcurrentLongObjectMap(); check(map); }
testConcurrentLongObjectHashMap
268,320
void (ConcurrentLongObjectMap<Object> map) { for (long i = Long.MAX_VALUE-1000; i != Long.MIN_VALUE+1000; i++) { Object prev = map.put(i, i); assertNull(prev); Object ret = map.get(i); assertTrue(ret instanceof Long); assertEquals(i, ret); if (map.size() > 1) { Object remove = map.remove(i - 1); assertTrue(remove insta...
check
268,321
void () { ConcurrentLongObjectMap<Object> map = Java11Shim.Companion.getINSTANCE().createConcurrentLongObjectMap(); check(map); }
testOldConcurrentLongObjectHashMap
268,322
void () { IntObjectMap<Object> map = ConcurrentCollectionFactory.createConcurrentIntObjectMap(); for (int i = 0; i < 1000; i++) { Object prev = map.put(i, i); assertNull(prev); Object ret = map.get(i); assertTrue(ret instanceof Integer); assertEquals(i, ret); if (i != 0) { Object remove = map.remove(i - 1); assertTrue(...
testConcurrentIntObjectHashMap
268,323
void () { IntObjectMap<Object> map = ContainerUtil.createConcurrentIntObjectMap(); for (int i = 0; i < 1000; i++) { Object prev = map.put(i, i); assertNull(prev); Object ret = map.get(i); assertTrue(ret instanceof Integer); assertEquals(i, ret); if (i != 0) { Object remove = map.remove(i - 1); assertTrue(remove instanc...
testOldConcurrentIntObjectHashMap
268,324
void () { ConcurrentMap<Object, Object> map = CollectionFactory.createConcurrentWeakKeyWeakValueMap(); checkKeyTossedEventually(map); checkValueTossedEventually(map); }
testConcurrentWeakKeyWeakValueMapTossed
268,325
void () { Map<Object, Object> map = CollectionFactory.createSoftKeySoftValueMap(); checkKeyTossedEventually(map); checkValueTossedEventually(map); }
testSoftKeySoftValueMapTossed
268,326
void () { Map<Object, Object> map = ContainerUtil.createWeakKeySoftValueMap(); checkKeyTossedEventually(map); checkValueTossedEventually(map); }
testWeakKeySoftValueMapTossed
268,327
void () { Map<String, Object> map = CollectionFactory.createConcurrentWeakValueMap(); Ref<Object> ref1 = Ref.create(new Object()); Ref<Object> ref2 = Ref.create(new Object()); map.put("a", ref1.get()); map.put("b", ref2.get()); GCWatcher.fromClearedRef(ref2).ensureCollected(); assertEquals(1, map.size()); GCWatcher.fro...
testConcurrentWeakValueSize
268,328
void () { Map<String, Object> map = CollectionFactory.createConcurrentWeakValueMap(); checkPutIfAbsent(map); }
testConcurrentWeakValuePutIfAbsentMustActuallyPutNewValueIfTheOldWasGced
268,329
void () { Map<String, Object> map = ContainerUtil.createConcurrentSoftValueMap(); checkPutIfAbsent(map); }
testConcurrentSoftValuePutIfAbsentMustActuallyPutNewValueIfTheOldWasGced
268,330
void () { ConcurrentIntObjectMap<Object> map = ConcurrentCollectionFactory.createConcurrentIntObjectSoftValueMap(); checkPutIfAbsent(map); }
testConcurrentIntKeySoftValuePutIfAbsentMustActuallyPutNewValueIfTheOldWasGced
268,331
void () { ConcurrentIntObjectMap<Object> map = ConcurrentCollectionFactory.createConcurrentIntObjectWeakValueMap(); checkPutIfAbsent(map); }
testConcurrentIntKeyWeakValuePutIfAbsentMustActuallyPutNewValueIfTheOldWasGced
268,332
void (Map<? super String, Object> map) { String key = "a"; map.put(key, new Object()); String newVal = "xxx"; int i; int N = 1_000_000; for (i = 0; i < N; i++) { Object prev = map.putIfAbsent(key, newVal); if (prev == null) { assertSame(newVal, map.get(key)); break; } assertEquals(Object.class, prev.getClass()); Object...
checkPutIfAbsent
268,333
void (ConcurrentIntObjectMap<Object> map) { int key = 4; map.put(key, new Object()); String newVal = "xxx"; int i; int N = 1_000_000; for (i = 0; i < N; i++) { Object prev = map.putIfAbsent(key, newVal); if (prev == null) { assertSame(newVal, map.get(key)); break; } assertEquals(Object.class, prev.getClass()); Object a...
checkPutIfAbsent
268,334
void () { class AwfulHashCode { @Override public int hashCode() { return 0; } } ConcurrentMap<Object, Object> map = ConcurrentCollectionFactory.createConcurrentMap(new HashingStrategy<>() { @Override public int hashCode(Object object) { return 0; } @Override public boolean equals(Object o1, Object o2) { return o1 == o2...
testConcurrentHashMapTreeBinifiesItself
268,335
int () { return 0; }
hashCode
268,336
int (Object object) { return 0; }
hashCode
268,337
boolean (Object o1, Object o2) { return o1 == o2; }
equals
268,338
void () { Set<Object> set = ContainerUtil.createWeakSet(); checkClearsEventuallyAfterGCPressure(set); }
weakSetTossed
268,339
void () { Set<Object> set = ContainerUtil.createWeakSet(); set.add(""); set.add(""); assertEquals(1, set.size()); assertTrue(set.remove("")); assertEquals(0, set.size()); assertTrue(set.isEmpty()); }
testWeakSet
268,340
void (Set<Object> set) { assertTrue(set.isEmpty()); Ref<Object> ref = Ref.create(new Object()); set.add(ref.get()); GCWatcher.fromClearedRef(ref).ensureCollected(); assertFalse(set.remove(this)); // to run processQueue assertTrue(set.isEmpty()); assertTrue(set.add(this)); // to run processQueues(); //noinspection Const...
checkClearsEventuallyAfterGCPressure
268,341
void () { UsefulTestCase.assertThrows(IllegalArgumentException.class, () -> CollectionFactory.createWeakMap(11,1,HashingStrategy.canonical())); checkKeySetIterable(CollectionFactory.createWeakMap(11,0.5f,HashingStrategy.canonical())); checkKeySetIterable(ContainerUtil.createWeakKeySoftValueMap()); checkKeySetIterable(C...
testWeakKeyMapsKeySetIsIterable
268,342
void (@NotNull Map<Object, Object> map) { for (int i=0; i<10; i++) { for (int k=0;k<i;k++) { map.put(new Object(), new Object()); } checkKeySetIterable(map.keySet()); } }
checkKeySetIterable
268,343
void (@NotNull Set<Object> set) { boolean found; do { found = false; for (Object o : set) { found = true; assertNotNull(o); } GCUtil.tryGcSoftlyReachableObjects(()->set.isEmpty()); } while (found); }
checkKeySetIterable
268,344
void () { ObjectIntMap<Object> map = ContainerUtil.createWeakKeyIntValueMap(); checkKeyTossedEventually(map); }
testWeakKeyIntValueMapTossed
268,345
void () { IntObjectMap<Object> map = ContainerUtil.createIntKeyWeakValueMap(); checkValueTossedEventually(map); }
testIntKeyWeakValueMapTossed
268,346
void () { checkEntrySetIterator(ConcurrentCollectionFactory.createConcurrentIntObjectMap()); checkEntrySetIterator(ContainerUtil.createConcurrentIntObjectMap()); checkEntrySetIterator(ConcurrentCollectionFactory.createConcurrentIntObjectSoftValueMap()); checkEntrySetIterator(ConcurrentCollectionFactory.createConcurrent...
testEntrySet
268,347
void () { checkEntrySetIteratorTossesValue(ConcurrentCollectionFactory.createConcurrentIntObjectSoftValueMap()); checkEntrySetIteratorTossesValue(ConcurrentCollectionFactory.createConcurrentIntObjectWeakValueMap()); checkEntrySetIteratorTossesValue(ContainerUtil.createIntKeyWeakValueMap()); }
testEntrySetTossesValue
268,348
void (@NotNull IntObjectMap<Object> map) { map.put(1, this); map.put(2, this); map.put(3, strong = new Object()); map.put(4, this); Iterator<IntObjectMap.Entry<Object>> iterator = map.entrySet().iterator(); assertTrue(iterator.hasNext()); strong = null; for (int i=0; i<10; i++) { if (map.get(3)==null) break; GCUtil.try...
checkEntrySetIteratorTossesValue
268,349
void (IntObjectMap<Object> map) { map.clear(); int K1 = 1; map.put(K1, this); int K2 = 2; map.put(K2, map); assertEquals(2, ContainerUtil.collect(map.entrySet().iterator()).size()); assertEquals(2, ContainerUtil.collect(map.entrySet().iterator()).size()); Iterator<IntObjectMap.Entry<Object>> iterator = map.entrySet().i...
checkEntrySetIterator
268,350
void (ConcurrentLongObjectMap<Object> map) { map.clear(); int K1 = 1; map.put(K1, this); int K2 = 2; map.put(K2, map); assertEquals(2, ContainerUtil.collect(map.entries().iterator()).size()); assertEquals(2, ContainerUtil.collect(map.entries().iterator()).size()); Iterator<ConcurrentLongObjectMap.LongEntry<Object>> ite...
checkEntrySetIterator
268,351
Condition<Integer> (int s, int e) { return integer -> s <= integer && integer <= e; }
inRange
268,352
Integer (Integer k) { int t = k0; k0 = k; return t + k; }
fun
268,353
Condition<Integer> (final int max) { return integer -> integer < max; }
LESS_THAN
268,354
Condition<Integer> (final int max) { return integer -> integer % max < max / 2; }
LESS_THAN_MOD
268,355
boolean (E e) { if (b) return false; b = Comparing.equal(e, o); return true; }
value
268,356
void () { Processor<Runnable> tryCatch = (r) -> { try { r.run(); return true; } catch (NoSuchElementException e) { return false; } }; JBIterator<Integer> it = JBIterator.from(Arrays.asList(1, 2, 3, 4).iterator()); assertFalse(tryCatch.process(it::current)); assertTrue(it.hasNext()); assertFalse(tryCatch.process(it::cur...
testIteratorContracts
268,357
void () { JBIterator<Integer> it = JBIterator.from(JBIterable.of(1).iterator()); assertTrue(it.advance()); assertEquals(Integer.valueOf(1), it.current()); assertFalse(it.hasNext()); assertEquals(Integer.valueOf(1), it.current()); }
testIteratorContractsCurrent
268,358
void () { List<Integer> list = new ArrayList<>(); JBIterable<Integer> orig = JBIterable.generate(1, INCREMENT).take(5); for (JBIterator<Integer> it : JBIterator.cursor(JBIterator.from(orig.iterator()))) { it.current(); it.hasNext(); list.add(it.current()); } assertEquals(orig.toList(), list); }
testCursorIterableContract
268,359
void () { JBIterable<Integer> orig = JBIterable.generate(1, INCREMENT).take(5); JBIterator<JBIterator<Integer>> it = JBIterator.from(JBIterator.cursor( JBIterator.from(orig.iterator())).iterator()); List<Integer> list = new ArrayList<>(); while (it.advance()) { it.hasNext(); list.add(it.current().current()); } assertEq...
testCursorIteratorContract
268,360
void () { JBIterable<Integer> orig = JBIterable.generate(1, INCREMENT).take(5); List<Integer> expected = List.of(1, 2, 3, 4, 5); List<Integer> expectedOdd = List.of(1, 3, 5); assertEquals(expected, JBIterator.cursor(JBIterator.from(orig.iterator())).transform(o -> o.current()).toList()); assertEquals(expected.size(), J...
testCursorTransform
268,361
void () { final AtomicInteger count = new AtomicInteger(0); JBIterator<Integer> it = new JBIterator<>() { @Override protected Integer nextImpl() { return count.get() < 0 ? stop() : count.incrementAndGet() < 10 ? skip() : (Integer)count.addAndGet(-count.get() - 1); } }; assertEquals(JBIterable.of(-1).toList(), JBIterabl...
testIteratorContractsSkipAndStop
268,362
Integer () { return count.get() < 0 ? stop() : count.incrementAndGet() < 10 ? skip() : (Integer)count.addAndGet(-count.get() - 1); }
nextImpl
268,363
void () { Object nil = null; assertEquals("[]", JBIterable.of(nil).toList().toString()); assertEquals("[null, null, null]", JBIterable.of(nil, nil, nil).toList().toString()); assertEquals("[null, null, null]", JBIterable.of(ContainerUtil.ar(nil, nil, nil)).toList().toString()); assertEquals("[null, null, null]", JBIter...
testIterableOfNulls
268,364
void () { JBIterable<String> it = JBIterable.of("42"); assertEquals(1, it.size()); assertEquals("42", it.first()); assertEquals("42", it.last()); assertEquals("42", it.single()); assertEquals("[42, 42]", it.append(it).toList().toString()); assertEquals("[42, 42]", it.repeat(2).toList().toString()); assertEquals("[42, 4...
testSingleElement
268,365
void () { Object element = Arrays.asList(1, 2); JBIterable<Object> iterable = JBIterable.of(element); assertEquals(1, iterable.size()); assertFalse(iterable.isEmpty()); assertEquals(element, iterable.first()); assertEquals(element, iterable.last()); assertEquals(element, iterable.get(0)); assertNull(iterable.get(1)); a...
testSingleElementWithList
268,366
void () { Object element = Collections.emptyList(); JBIterable<Object> iterable = JBIterable.of(element); assertFalse(iterable.isEmpty()); assertEquals(1, iterable.size()); assertEquals(element, iterable.first()); assertEquals(element, iterable.last()); assertEquals(element, iterable.get(0)); assertNull(iterable.get(1)...
testSingleElementWithEmptyList
268,367
void () { assertNull(JBIterable.empty().first()); assertNull(JBIterable.empty().last()); assertNull(JBIterable.empty().single()); assertEquals("a", JBIterable.generate("a", o -> o + "a").first()); assertEquals("aaa", JBIterable.generate("a", o -> o + "a").take(3).last()); assertEquals("a", JBIterable.generate("a", o ->...
testFirstLastSingle
268,368
void () { Integer o = null; JBIterable<Integer> it = JBIterable.of(o).append(o).append(JBIterable.empty()); assertTrue(it.isEmpty()); assertSame(it, JBIterable.empty()); }
testOfAppendNulls
268,369
void () { JBIterable<Integer> it = JBIterable.of(1, 2, 3).append(JBIterable.of(4, 5, 6)).append(JBIterable.empty()).append(7); assertEquals(7, it.size()); assertEquals(Arrays.asList(1, 2, 3, 4, 5, 6, 7), it.toList()); assertTrue(it.contains(5)); }
testAppend
268,370
void () { JBIterable<Integer> it = JBIterable.generate(1, INCREMENT).take(3).repeat(3); assertEquals(9, it.size()); assertEquals(Arrays.asList(1, 2, 3, 1, 2, 3, 1, 2, 3), it.toList()); }
testGenerateRepeat
268,371
void () { JBIterable<Integer> it = JBIterable.generate(1, INCREMENT).skip(10).take(10); assertEquals(10, it.size()); assertEquals(Integer.valueOf(11), it.first()); }
testSkipTakeSize
268,372
void () { assertEquals(1, JBIterable.of(1).flatMap(o -> JBIterable.of(o)).take(1).take(1).take(1).size()); assertEquals((Integer)1, JBIterable.of(1).flatMap(o -> JBIterable.of(o, o + 1)).take(2).take(1).get(0)); assertEquals((Integer)2, JBIterable.of(1).flatMap(o -> JBIterable.of(o, o + 1)).skip(1).take(1).get(0)); }
testFlattenSkipTake
268,373
void () { Condition<Integer> cond = i -> Math.abs(i - 10) <= 5; JBIterable<Integer> it = JBIterable.generate(1, INCREMENT).skipWhile(not(cond)).takeWhile(cond); assertEquals(11, it.size()); assertEquals(Integer.valueOf(5), it.first()); assertEquals(Integer.valueOf(15), it.last()); }
testRangeWithSkipAndTake
268,374
void () { JBIterable<Integer> it = JBIterable.generate(1, INCREMENT).skipWhile(LESS_THAN_MOD(10)).take(10); assertEquals(Arrays.asList(5, 6, 7, 8, 9, 10, 11, 12, 13, 14), it.toList()); }
testSkipWhile
268,375
void () { JBIterable<Integer> it = JBIterable.generate(1, INCREMENT).takeWhile(LESS_THAN_MOD(10)).take(10); assertEquals(Arrays.asList(1, 2, 3, 4), it.toList()); }
testTakeWhile
268,376
void () { JBIterable<Integer> it = JBIterable.of(1, 2, 3, 4); assertEquals((Integer)4, it.get(3)); assertNull(it.get(4)); assertNull(it.get(5)); JBIterable<Integer> it2 = JBIterable.generate(1, INCREMENT).take(4); assertEquals((Integer)4, it2.get(3)); assertNull(it2.get(4)); assertNull(it2.get(5)); }
testGetAt
268,377
void () { JBIterable<Integer> it = JBIterable.generate(1, INCREMENT).filter(IS_ODD).transform(SQUARE).takeWhile(LESS_THAN(100)); assertEquals(Arrays.asList(1, 9, 25, 49, 81), it.toList()); assertEquals(Integer.valueOf(1), it.first()); assertEquals(Integer.valueOf(81), it.last()); }
testFilterTransformTakeWhile
268,378
void () { JBIterable<Integer> it = JBIterable.generate(1, INCREMENT).filter(IS_ODD).transform(SQUARE).skipWhile(LESS_THAN(100)).take(3); assertEquals(Arrays.asList(121, 169, 225), it.toList()); assertEquals(Integer.valueOf(121), it.first()); assertEquals(Integer.valueOf(225), it.last()); }
testFilterTransformSkipWhile
268,379
void () { JBIterable<Integer> it = JBIterable.once(JBIterable.generate(1, INCREMENT).take(3).iterator()); assertEquals(Arrays.asList(1, 2, 3), it.toList()); try { assertEquals(Arrays.asList(1, 2, 3), it.toList()); fail(); } catch (UnsupportedOperationException ignored) { } }
testOnce
268,380
void () { JBIterable<Integer> it = JBIterable.generate(1, INCREMENT).take(3).flatten(i -> i % 2 == 0 ? null : JBIterable.of(i - 1, i)); assertEquals(Arrays.asList(0, 1, 2, 3), it.toList()); }
testFlatten
268,381
void () { JBIterable<Integer> it = JBIterable.generate(1, INCREMENT).take(5).filter(new JBIterable.SCond<>() { int prev; @Override public boolean value(Integer integer) { boolean b = integer > prev; if (b) prev = integer; return b; } }); assertEquals(Arrays.asList(1, 2, 3, 4, 5), it.toList()); assertEquals(Arrays.asLis...
testStatefulFilter
268,382
boolean (Integer integer) { boolean b = integer > prev; if (b) prev = integer; return b; }
value
268,383
void () { Integer base = 5; JBIterable<Integer> it = JBIterable.generate(1, INCREMENT).take(10).filter(new JBIterable.SCond<>() { IntSet visited; // MUST NOT be initialized here @Override public boolean value(Integer integer) { if (visited == null) { visited = new IntOpenHashSet(); } return visited.add(integer % base);...
testStatefulFilterWithSet
268,384
boolean (Integer integer) { if (visited == null) { visited = new IntOpenHashSet(); } return visited.add(integer % base); }
value
268,385
void () { JBIterable<Integer> it = JBIterable.generate(1, FIBONACCI2).take(8); assertEquals(Arrays.asList(1, 1, 2, 3, 5, 8, 13, 21), it.toList()); assertEquals(Arrays.asList(1, 1, 2, 3, 5, 8, 13, 21), it.toList()); }
testStatefulGenerator
268,386
void () { JBIterable<Integer> it = JBIterable.of(1, 2, 3, 4, 5); assertEquals(15, (int)it.reduce(0, (Integer v, Integer o) -> v + o)); assertEquals(3, (int)it.find((o)-> o.intValue() == 3)); assertEquals(2, it.indexOf((o)-> o.intValue() == 3)); assertEquals(-1, it.indexOf((o)-> o.intValue() == 33)); assertEquals(Arrays...
testFindIndexReduceMap
268,387
void () { assertNull(JBIterable.<String>of().join(", ").reduce((a, b) -> a + b)); assertEquals("", JBIterable.of().join(", ").reduce("", (a, b) -> a + b)); assertEquals("a", JBIterable.of("a").join(", ").reduce((a, b) -> a + b)); assertEquals("a, b, c", JBIterable.of("a", "b", "c").join(", ").reduce((a, b) -> a + b)); ...
testJoin
268,388
void () { JBIterable<Integer> it = JBIterable.of(1, 2, 3, 4, 5); assertEquals(Arrays.asList(Arrays.asList(1, 2), Arrays.asList(3, 4)), it.split(2, true).toList()); assertEquals(Arrays.asList(Arrays.asList(1, 2), Arrays.asList(3, 4), Arrays.asList(5)), it.split(2, false).toList()); assertEquals("[[1, 2], [4, 5]]", it.sp...
testSplits1
268,389
boolean (Integer integer) { return (i = (i + 2) % 12) - 5 > 0; // 3 positive, 3 negative (+1 +3 +5 : -5 -3 -1) }
value
268,390
void () { JBIterable<Integer> it = JBIterable.empty(); assertEquals("[]", it.split(OFF, o -> o % 3 == 0).map(o -> o.toList()).toList().toString()); assertEquals("[]", it.split(AROUND, o -> o % 3 == 0).map(o -> o.toList()).toList().toString()); assertEquals("[]", it.split(AFTER, o -> o % 3 == 0).map(o -> o.toList()).toL...
testSplits2
268,391
void () { JBIterable<Integer> it = JBIterable.generate(1, INCREMENT).take(30); assertEquals(it.toList(), it.unique().toList()); JBIterable<Integer> uniqueMod5 = it.unique((o) -> o % 5); assertEquals(Arrays.asList(1, 2, 3, 4, 5), uniqueMod5.toList()); assertEquals(Arrays.asList(1, 2, 3, 4, 5), uniqueMod5.toList()); // s...
testIterateUnique
268,392
void () { JBIterable<Integer> it1 = JBIterable.generate(1, INCREMENT).take(30); JBIterable<Integer> it2 = JBIterable.generate(30, o -> o - 1).take(30).sort(Integer::compareTo); assertEquals(it1.toList(), it2.unique().toList()); }
testSort
268,393
JBTreeTraverser<Integer> () { return new JBTreeTraverser<>(Functions.compose(ASSERT_NUMBER, Functions.fromMap(numbers()))).withRoot(1); }
numTraverser
268,394
JBTreeTraverser<Integer> () { return new JBTreeTraverser<>(Functions.compose(ASSERT_NUMBER, Functions.fromMap(numbers2()))).withRoot(1); }
num2Traverser
268,395
JBIterable<TreeTraversal> () { JBIterable<TreeTraversal> result = JBIterable.of(TreeTraversal.class.getDeclaredFields()) .filter(o -> Modifier.isStatic(o.getModifiers()) && Modifier.isPublic(o.getModifiers())) .map(o -> { try { return o.get(null); } catch (IllegalAccessException e) { throw new AssertionError(e); } }) ....
allTraversals
268,396
void () { JBIterable<TreeTraversal> traversals = allTraversals(); Object nil = null; JBTreeTraverser<Object> t1 = JBTreeTraverser.from(o -> JBIterable.of(nil, nil)).withRoots(Arrays.asList(nil)); assertEquals(""" BI_ORDER_DFS [null, null] INTERLEAVED_DFS [null] LEAVES_BFS [null] LEAVES_DFS [null] PLAIN_BFS [null] POST_...
testTraverserOfNulls
268,397
void () { assertEquals(Arrays.asList(1, 2, 5, 6, 7, 3, 8, 9, 10, 4, 11, 12, 13), numTraverser().toList()); }
testSimplePreOrderDfs
268,398
void () { assertEquals(Arrays.asList(1, 2, 5, 5, 6, 6, 7, 7, 2, 3, 8, 8, 9, 9, 10, 10, 3, 4, 11, 11, 12, 12, 13, 13, 4, 1), numTraverser().withTraversal(TreeTraversal.BI_ORDER_DFS).toList()); }
testSimpleBiOrderDfs
268,399
void () { assertEquals(Arrays.asList(2, 5, 5, 6, 6, 7, 7, 2, 3, 8, 8, 9, 9, 10, 10, 3, 4, 11, 11, 12, 12, 13, 13, 4), TreeTraversal.BI_ORDER_DFS.traversal(numbers().get(1), Functions.fromMap(numbers())).toList()); }
testSimpleBiOrderDfs2Roots