Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
268,100 | void () { Vector vector = Vector.create(1, 2, 3); Matrix matrix = Matrix.createColumn(vector); assertEquals(1, matrix.getColumns()); assertEquals(3, matrix.getRows()); assertEquals(vector, matrix.getColumn(0)); assertEquals(Vector.create(1), matrix.getRow(0)); assertEquals(Vector.create(2), matrix.getRow(1)); assertEqu... | testCreateColumn |
268,101 | void () { Vector vector = Vector.create(1, 2, 3); Matrix matrix = Matrix.createRow(vector); assertEquals(3, matrix.getColumns()); assertEquals(1, matrix.getRows()); assertEquals(vector, matrix.getRow(0)); assertEquals(Vector.create(1), matrix.getColumn(0)); assertEquals(Vector.create(2), matrix.getColumn(1)); assertEqu... | testCreateRow |
268,102 | void () { // see http://ru.onlinemschool.com/math/library/matrix/add_subtract/ assertEquals(Matrix.create(2, // rows 7, 3, 6, 4), Matrix.create(2, // rows 4, 2, 9, 0).plus(Matrix.create(2, // rows 3, 1, -3, 4))); } | testPlus |
268,103 | void () { try { fail("Created " + Matrix.create(1, 0).plus(Matrix.create(2, 1, 1, 1, 1))); } catch (Exception ignored) { } } | testPlusWrong |
268,104 | void () { // see http://ru.onlinemschool.com/math/library/matrix/add_subtract/ assertEquals(Matrix.create(2, // rows 1, 1, 12, -4), Matrix.create(2, // rows 4, 2, 9, 0).minus(Matrix.create(2, // rows 3, 1, -3, 4))); } | testMinus |
268,105 | void () { try { fail("Created " + Matrix.create(1, 0).minus(Matrix.create(2, 1, 1, 1, 1))); } catch (Exception ignored) { } } | testMinusWrong |
268,106 | void () { // see http://ru.onlinemschool.com/math/library/matrix/multiply1/ assertEquals(Matrix.create(2, // rows 20, 10, 45, 0), Matrix.create(2, // rows 4, 2, 9, 0).multiply(5)); assertEquals(Matrix.create(3, // rows -4, 4, 2, -0.0, // fix -10, 2), Matrix.create(3, // rows 2, -2, -1, 0, 5, -1).multiply(-2)); } | testMultiplyByValue |
268,107 | void () { // see http://ru.onlinemschool.com/math/library/matrix/multiply/ assertEquals(Matrix.create(2, // rows 6, 12, 27, 9), Matrix.create(2, // rows 4, 2, 9, 0).multiply(Matrix.create(2, // rows 3, 1, -3, 4))); assertEquals(Matrix.create(3, // rows 7, -2, 19, -15, 3, -18, 23, -4, 17), Matrix.create(3, // rows 2, 1,... | testMultiplyByMatrix |
268,108 | void () { Vector vector = Vector.create(1, 2, 3); assertEquals(vector, Matrix.createIdentity(3).multiply(vector)); Matrix matrix = Matrix.create(2, /*row:*/ 11, 12, 13, /*row:*/ 21, 22, 23); Vector result = matrix.multiply(vector); assertEquals(Vector.create(74, 134), result); assertEquals(matrix.getRows(), result.getS... | testMultiplyByVector |
268,109 | void () { // see http://ru.onlinemschool.com/math/library/matrix/determinant/ assertEquals(33.0, Matrix.create(2, 5, 7, -4, 1).determinant()); assertEquals(97.0, Matrix.create(3, 5, 7, 1, -4, 1, 0, 2, 0, 3).determinant()); assertEquals(6.0, Matrix.create(3, 2, 4, 1, 0, 2, 1, 2, 1, 1).determinant()); assertEquals(0.0, M... | testDeterminant |
268,110 | void () { assertEquals(0.0, Matrix.create(3, 0, 0, 0, 1, 2, 3, 4, 5, 6).determinant()); // 1 zero row assertEquals(0.0, Matrix.create(3, 1, 1, 1, 1, 1, 1, 1, 2, 3).determinant()); // 2 equal rows assertEquals(0.0, Matrix.create(3, 1, 1, 1, 2, 2, 2, 1, 2, 3).determinant()); // 2 proportional rows } | testDeterminantZero |
268,111 | void () { assertEquals(1.0, Matrix.createIdentity(1).determinant()); assertEquals(1.0, Matrix.createIdentity(2).determinant()); assertEquals(1.0, Matrix.createIdentity(3).determinant()); assertEquals(1.0, Matrix.createIdentity(4).determinant()); assertEquals(1.0, Matrix.createIdentity(5).determinant()); } | testDeterminantIdentity |
268,112 | void () { Matrix matrix = Matrix.create(2, 5, 7, -4, 1); assertEquals(matrix.determinant(), 1 / matrix.inverse().determinant()); } | testDeterminantInverse |
268,113 | void () { Matrix matrix = Matrix.create(2, 5, 7, -4, 1); assertEquals(matrix.determinant(), matrix.transpose().determinant()); } | testDeterminantTranspose |
268,114 | void () { Matrix matrix = Matrix.create(3, /*row:*/ 11, 12, /*row:*/ 21, 22, /*row:*/ 31, 32); Matrix result = matrix.transpose(); assertEquals(matrix.getColumns(), result.getRows()); assertEquals(matrix.getColumn(0), result.getRow(0)); assertEquals(matrix.getColumn(1), result.getRow(1)); assertEquals(matrix.getRows(),... | testTranspose |
268,115 | void () { Matrix matrix = Matrix.create(3, /*row:*/ 11, 12, 13, /*row:*/ 21, 22, 23, /*row:*/ 31, 32, 33); assertEquals(matrix, Matrix.createIdentity(3).multiply(matrix)); assertEquals(matrix, matrix.multiply(Matrix.createIdentity(3))); } | testTransposeIdentity |
268,116 | void () { Matrix matrix = Matrix.create(2, 5, 7, -4, 1); assertEquals(matrix, matrix.inverse().inverse()); assertEquals(matrix.transpose().inverse(), matrix.inverse().transpose()); // see http://ru.onlinemschool.com/math/library/matrix/inverse/ assertEquals(Matrix.create(3, //rows 1 / 6.0, -1 / 2.0, 1 / 3.0, 1 / 3.0, 0... | testInverse |
268,117 | void () { LOG.append(finalI + ", "); executed.countDown(); } | run |
268,118 | String () { return String.valueOf(finalI); } | toString |
268,119 | void () { Listener listener1 = new Listener() { @Override public void foo() { myBuffer.append("[1]"); removeListener(this); } }; Listener listener2 = new Listener() { @Override public void foo() { myBuffer.append("[2]"); } }; final Listener listener3 = new Listener() { @Override public void foo() { myBuffer.append("[3]... | testRemoveListener1 |
268,120 | void () { myBuffer.append("[1]"); removeListener(this); } | foo |
268,121 | void () { myBuffer.append("[2]"); } | foo |
268,122 | void () { myBuffer.append("[3]"); } | foo |
268,123 | void () { final Listener listener3 = new Listener() { @Override public void foo() { myBuffer.append("[3]"); } }; Listener listener1 = new Listener() { @Override public void foo() { myBuffer.append("[1]"); removeListener(listener3); } }; Listener listener2 = new Listener() { @Override public void foo() { myBuffer.append... | testRemoveListener2 |
268,124 | void () { myBuffer.append("[3]"); } | foo |
268,125 | void () { myBuffer.append("[1]"); removeListener(listener3); } | foo |
268,126 | void () { myBuffer.append("[2]"); } | foo |
268,127 | void () { final Listener listener3 = new Listener() { @Override public void foo() { myBuffer.append("[3]"); } }; Listener listener1 = new Listener() { @Override public void foo() { myBuffer.append("[1.1]"); dispatchPendingEvent(listener3); myBuffer.append("[1.2]"); } }; Listener listener2 = new Listener() { @Override p... | testDispatchPending |
268,128 | void () { myBuffer.append("[3]"); } | foo |
268,129 | void () { myBuffer.append("[1.1]"); dispatchPendingEvent(listener3); myBuffer.append("[1.2]"); } | foo |
268,130 | void () { myBuffer.append("[2]"); } | foo |
268,131 | void () { final Listener listener3 = new Listener() { @Override public void foo() { myBuffer.append("[3]"); removeListener(this); } }; Listener listener1 = new Listener() { @Override public void foo() { myBuffer.append("[1.1]"); dispatchPendingEvent(listener3); myBuffer.append("[1.2]"); } }; Listener listener2 = new Li... | testRemoveInDispatchPending |
268,132 | void () { myBuffer.append("[3]"); removeListener(this); } | foo |
268,133 | void () { myBuffer.append("[1.1]"); dispatchPendingEvent(listener3); myBuffer.append("[1.2]"); } | foo |
268,134 | void () { myBuffer.append("[2]"); } | foo |
268,135 | void (Listener listener) { myDispatcher.addListener(listener); } | addListener |
268,136 | void (Listener listener) { myDispatcher.removeListener(listener); } | removeListener |
268,137 | void (final Listener listener) { myDispatcher.dispatchPendingEvent(listener); } | dispatchPendingEvent |
268,138 | void (String result) { myDispatcher.getMulticaster().foo(); assertEquals(result, myBuffer.toString()); } | checkResult |
268,139 | void () { Throwable t1 = new Throwable(); assertStackTraceIsExpanded(t1, false); Throwable i1 = ThrowableInterner.intern(t1); assertStackTraceIsExpanded(t1, false); assertSame(i1, ThrowableInterner.intern(t1)); assertStackTraceIsExpanded(t1, false); assertNotSame(i1, ThrowableInterner.intern(new Throwable())); // must ... | testItDoesWork |
268,140 | void (Throwable t, boolean expanded) { StackTraceElement[] traces = ReflectionUtil.getField(t.getClass(), t, StackTraceElement[].class, "stackTrace"); assertEquals(expanded, traces.length != 0); } | assertStackTraceIsExpanded |
268,141 | PsiFileImpl () { return (PsiFileImpl)myFixture.addFileToProject( "classes.java", """ class A { void foo() {} } class B {} """ ); } | addFile |
268,142 | PsiFileImpl () { return (PsiFileImpl)myFixture.addFileToProject( "classes2.java", """ class C { void foo() {} } class D {} """ ); } | addAnotherFile |
268,143 | void () { DefaultLogger.disableStderrDumping(getTestRootDisposable()); PsiFileImpl file = addFile(); assertFalse(file.isContentsLoaded()); assertThrows(AstLoadingException.class, () -> AstLoadingFilter.disallowTreeLoading( () -> file.getNode() ) ); } | testDisallowedLoading |
268,144 | void () { LongLinkedHashMap<String> map = new LongLinkedHashMap<>(10, 1, true); Assert.assertNull(map.get(123)); Assert.assertNull(map.put(123, "123")); Assert.assertEquals("123", map.get(123)); } | testPutAndGet |
268,145 | void () { LongLinkedHashMap<String> map = new LongLinkedHashMap<>(10, 1, true); map.put(1, "1"); map.put(2, "2"); map.put(3, "3"); map.put(4, "4"); Assert.assertEquals(4, map.size()); map.clear(); Assert.assertEquals(0, map.size()); Assert.assertTrue(map.isEmpty()); } | testClear |
268,146 | void () { LongLinkedHashMap<String> map = new LongLinkedHashMap<>(10, 1, true) { @Override protected boolean removeEldestEntry(Entry<String> eldest) { return size() > 3; } }; map.put(1, "1"); map.put(2, "2"); map.put(3, "3"); map.put(4, "4"); Assert.assertEquals(3, map.size()); Assert.assertNull(map.get(1)); Assert.ass... | testRemoveEldest |
268,147 | boolean (Entry<String> eldest) { return size() > 3; } | removeEldestEntry |
268,148 | int (final ThreadLocalRandom current) { for (int i = 0; i < 1024; i++) { final int key = current.nextInt(); if (!generatedKeyValues.containsKey(key)) { return key; } } //avoid test hangs in pathological cases: throw new IllegalStateException("Something is wrong with 1024 random ints all contained in generatedKeyValues"... | nextKeyNotContainedInTree |
268,149 | Int2IntOpenHashMap (final int keysCount) { final Int2IntOpenHashMap keyValues = new Int2IntOpenHashMap(keysCount); final ThreadLocalRandom rnd = ThreadLocalRandom.current(); for (int i = 0; i < keysCount; i++) { final int key = rnd.nextInt(); final int value = rnd.nextInt(); keyValues.put(key, value); } return keyValue... | generateKeyValues |
268,150 | long[] (final int size) { final long[] swarmOfLongs = new long[size]; final ThreadLocalRandom rnd = ThreadLocalRandom.current(); for (int i = 0; i < swarmOfLongs.length; i++) { swarmOfLongs[i] = rnd.nextBoolean() ? rnd.nextLong() : Long.MAX_VALUE; } return swarmOfLongs; } | generateLongArray |
268,151 | boolean (PersistentHashMap<String, Record> map) { Random random = new Random(); try { for (int i = 0; i < 100000; i++) { if (random.nextInt(1000) == 1) { map.force(); continue; } String key = myKeys.get(random.nextInt(myKeys.size())); myEnumerator.enumerate(key); if (random.nextBoolean()) { // for (int j = 0; j < 10; j... | doTask |
268,152 | String () { return createRandomString(random); } | createRandomString |
268,153 | String (Random random) { builder.setLength(0); int len = random.nextInt(40) + 10; for (int i = 0; i < len; ++i) { builder.append((char)(32 + random.nextInt(2 + i >> 1))); } return builder.toString(); } | createRandomString |
268,154 | InputStreamOverPagedStorage (long position, long limit) { return new InputStreamOverPagedStorage(storage, position, limit); } | streamOverStorage |
268,155 | String () { builder.setLength(0); int len = random.nextInt(40) + 10; for (int i = 0; i < len; ++i) { builder.append((char)(32 + random.nextInt(2 + i >> 1))); } return builder.toString(); } | createRandomString |
268,156 | int () { return unwrapMap().getSize(); } | getMapSize |
268,157 | int () { return unwrapMap().getGarbageSize(); } | getGarbageSize |
268,158 | String () { return StringEnumeratorTest.createRandomString(); } | createRandomString |
268,159 | void () { //i.e. it is safe to call it on any OS: PowerStatus.getPowerStatus(); } | getPowerStatusDoesntThrowException |
268,160 | void () { if (SystemInfo.isLinux) { String powerSupplySysNode = "/sys/class/power_supply"; File[] sysFsPowerSupplyFiles = notNull(new File(powerSupplySysNode).listFiles(), ArrayUtilRt.EMPTY_FILE_ARRAY); assumeTrue("Linux: can't query power source if '" + powerSupplySysNode + "' is empty or not exist", sysFsPowerSupplyF... | getPowerStatusReturnsReasonableResult |
268,161 | int (final ThreadLocalRandom current) { for (int i = 0; i < 1024; i++) { final int key = current.nextInt(); if (!generatedKeyValues.containsKey(key)) { return key; } } //avoid test hangs in pathological cases: throw new IllegalStateException("Something is wrong with 1024 random ints all contained in generatedKeyValues"... | nextKeyNotContainedInTree |
268,162 | Int2IntMap (final int keysCount) { final Int2IntMap keyValues = new Int2IntOpenHashMap(keysCount); final ThreadLocalRandom rnd = ThreadLocalRandom.current(); for (int i = 0; i < keysCount; i++) { final int key = rnd.nextInt(); final int value = rnd.nextInt(); keyValues.put(key, value); } return keyValues; } | generateKeyValues |
268,163 | List<PageContentLockingStrategy> () { return List.of( PageContentLockingStrategy.LOCK_PER_PAGE, new PageContentLockingStrategy.SharedLockLockingStrategy() ); } | strategiesToTry |
268,164 | void () { try { myMap.close(); } catch (IOException ignore) {} } | closeMapSilently |
268,165 | void () { assertThrows( IllegalArgumentException.class, () -> streamOverStorage(0, (long)Integer.MAX_VALUE + 1) ); } | failToCreateStreamLargerThanMaxInteger |
268,166 | byte[] (int size) { byte[] byteWritten = new byte[size]; ThreadLocalRandom.current().nextBytes(byteWritten); return byteWritten; } | randomBytes |
268,167 | InputStream (long position, long limit) { return new MappedFileInputStream(storage, position, limit, false); } | streamOverStorage |
268,168 | List<String> (final List<String> keys) { final List<String> keysCopy = new ArrayList<>(keys); Collections.sort(keysCopy, Comparator.naturalOrder()); return keysCopy; } | stableSortByStringCompare |
268,169 | List<Object[]> () { return Arrays.asList( new Object[]{ new Function<List<String>, List<String>>() { @Override public List<String> apply(List<String> keys) { return stableSortByStringCompare(keys); } @Override public String toString() { return "SortByStringCompare"; } } }, new Object[]{ new Function<List<String>, List<... | sorters |
268,170 | List<String> (List<String> keys) { return stableSortByStringCompare(keys); } | apply |
268,171 | String () { return "SortByStringCompare"; } | toString |
268,172 | List<String> (List<String> keys) { return stableSortBySerializedBytes(keys, EnumeratorStringDescriptor.INSTANCE); } | apply |
268,173 | String () { return "SortBySerializedBytes"; } | toString |
268,174 | List<String> (List<String> keys) { return stableSortByHashCodeAndBytes(keys, EnumeratorStringDescriptor.INSTANCE); } | apply |
268,175 | String () { return "SortByKeyHashCodesAndBytes"; } | toString |
268,176 | void () { final Map<String, String> keysValues = generateKeyValues(KEYS_COUNT, MAX_KEY_VALUE_SIZE); final List<String> keys = keysValues.keySet().stream().toList(); final List<List<? extends String>> sortedKeys = new ArrayList<>(); for (int i = 0; i < ENOUGH_SHUFFLE_TRIES; i++) { final List<String> keysCopy = new Array... | sorterProvidesStableSort |
268,177 | String (final PersistentHashMap<String, String> map) { map.force(); final PHMEntry entry = mapsEntries.get(map); assert entry != null : "No entry for " + map + ": only maps created by .createPHMap() are allowed"; final StringBuilder sb = new StringBuilder(); for (File file : entry.directory.listFiles()) { sb.append(fil... | hashOfContent |
268,178 | String (final ThreadLocalRandom rnd, final int size) { final char[] chars = new char[size]; final int base = 36; for (int i = 0; i < chars.length; i++) { chars[i] = Character.forDigit(rnd.nextInt(0, base), base); } return new String(chars); } | randomAlphanumericString |
268,179 | void () { //Just to force IDEA to show 'run tests' for this superclass } | fakeTest |
268,180 | void (final String caption, final long totalBytes, final long elapsedNs) { System.out.printf("%-60s: %3.1f GiB / %5d ms = %.2f GiB/s\n", caption, (totalBytes * 1.0) / GiB, NANOSECONDS.toMillis(elapsedNs), (totalBytes * 1.0) / GiB / (NANOSECONDS.toMillis(elapsedNs) / 1000.0) ); } | printReportForThroughput |
268,181 | ByteBuffer (final int size) { final byte[] array = PerformanceOfFileAccessBaseTest.randomArray(size); return ByteBuffer.wrap(array); } | randomContentBufferOfSize |
268,182 | byte[] (final int size) { final ThreadLocalRandom rnd = ThreadLocalRandom.current(); final byte[] array = new byte[size]; for (int i = 0; i < array.length; i++) { array[i] = (byte)rnd.nextInt(Byte.MIN_VALUE, Byte.MAX_VALUE + 1); } return array; } | randomArray |
268,183 | void (final String caption, final int bytesPerShot, final int averageDelayBetweenShotsNs, final int totalRoundsPerThread, final Histogram responseTimeUsHisto) { final double meanResponseTimeUs = responseTimeUsHisto.getMean(); final double averageDelayBetweenShotsUs = averageDelayBetweenShotsNs / 1000.0; final double to... | printReportForResponseTime |
268,184 | long (final long cacheCapacityInPages, final int numberOfDifferentPagesRequested, final int totalRequestsCount) { final long expectedPagesAllocated; if (cacheCapacityInPages >= numberOfDifferentPagesRequested) { expectedPagesAllocated = numberOfDifferentPagesRequested; } else { final double cacheEffectiveness = Math.mi... | estimatePagesToLoad |
268,185 | String () { ThreadLocalRandom rnd = ThreadLocalRandom.current(); return BlobStorageTestBase.randomString(rnd, rnd.nextInt(128)); } | generateValue |
268,186 | List<V> (int valuesCount) { final ArrayList<V> values = new ArrayList<>(); for (int i = 0; i < valuesCount; i++) { values.add(generateValue()); } return values; } | generateValues |
268,187 | void () { assumeTrue("Can't test lock-free storage if LOCK_FREE_PAGE_CACHE_ENABLED=false", PageCacheUtils.LOCK_FREE_PAGE_CACHE_ENABLED); } | checkLockFreeEnabled |
268,188 | String () { ThreadLocalRandom rnd = ThreadLocalRandom.current(); return BlobStorageTestBase.randomString(rnd, rnd.nextInt(128)); } | generateValue |
268,189 | NonDurableNonParallelIntToMultiIntMap (@NotNull Path tempDir) { return new NonDurableNonParallelIntToMultiIntMap(); } | openInDir |
268,190 | void () { assertEquals( multimap.size(), 0 ); } | emptyMultimapHasSizeZero |
268,191 | void () { final long[] packedKeysValues = generateKeyValues(ENOUGH_ENTRIES); final Int2IntMultimap multimap = new Int2IntMultimap(); for (final long packedKeyValue : packedKeysValues) { final int key = key(packedKeyValue); final int value = value(packedKeyValue); multimap.put(key, value); assertTrue( "Multimap must hav... | manyKeyValuesInserted_AreAllExistInTheMap |
268,192 | void () { final long[] packedKeysValues = generateKeyValues(ENOUGH_ENTRIES); final Int2IntMultimap multimap = new Int2IntMultimap(); for (final long packedKeyValue : packedKeysValues) { final int key = key(packedKeyValue); final int value = value(packedKeyValue); multimap.put(key, value); assertTrue( "Multimap must hav... | manyKeyValuesInserted_AndRemoved_NoneExistInTheMap |
268,193 | void () { final long[] packedKeysValues = generateKeyValues(ENOUGH_ENTRIES); final Int2IntMultimap multimap = new Int2IntMultimap(); //Use Map[int -> Set[int]] as 'etalon' multimap implementation to compare against: final Int2ObjectMap<IntSet> etalon = new Int2ObjectOpenHashMap<>(); for (final long packedKeyValue : pac... | afterManyKeyValues_InsertedAndRemovedRandomly_MultimapContentIsSameAsEtalon |
268,194 | void (final Int2IntMultimap multimap) { final IntOpenHashSet keys = new IntOpenHashSet(); multimap.forEach((key, value) -> keys.add(key)); for (final int key : keys) { final IntOpenHashSet values = new IntOpenHashSet(); multimap.lookup(key, value -> { if (!values.add(value)) { fail("get(" + key + ") values are non-uniq... | assertInvariant_ValuesForEachKeysAreUnique |
268,195 | IntOpenHashSet (final Int2IntMultimap multimap, final int key) { final IntOpenHashSet values = new IntOpenHashSet(); multimap.lookup(key, value -> { values.add(value); return true; }); return values; } | getValues |
268,196 | long (final int key, final int value) { return Integer.toUnsignedLong(key) << Integer.SIZE | Integer.toUnsignedLong(value); } | pack |
268,197 | int (final long packedKeyValue) { return (int)(packedKeyValue >> 32); } | key |
268,198 | int (final long packedKeyValue) { return (int)packedKeyValue; } | value |
268,199 | long[] (final int size) { return ThreadLocalRandom.current().longs() .filter(v -> key(v) != Int2IntMultimap.NO_VALUE && value(v) != Int2IntMultimap.NO_VALUE) .limit(size) .toArray(); } | generateKeyValues |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.