code stringlengths 114 1.05M | path stringlengths 3 312 | quality_prob float64 0.5 0.99 | learning_prob float64 0.2 1 | filename stringlengths 3 168 | kind stringclasses 1
value |
|---|---|---|---|---|---|
package snackBarApp;
import java.text.DecimalFormat;
public class Main {
private static DecimalFormat df2 = new DecimalFormat("#.00");
public static void main(String[] args) {
// Customer(String name, double cash)
Customer customer1 = new Customer("Jane", 45.25);
Customer customer2 = new Customer("B... | src/snackBarApp/Main.java | 0.522689 | 0.467271 | Main.java | starcoder |
package com.wrmsr.tokamak.util.graph;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.SetMulti... | tokamak-util/src/main/java/com/wrmsr/tokamak/util/graph/DominatorTree.java | 0.829492 | 0.405272 | DominatorTree.java | starcoder |
package ru.yammi.utils.path;
import net.minecraft.block.*;
import net.minecraft.client.Minecraft;
import net.minecraft.util.BlockPos;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
public class AStarCustomPathFinder {
private Vec3 startVec3;
private Vec3 endVec3;
p... | ru/yammi/utils/path/AStarCustomPathFinder.java | 0.69451 | 0.464112 | AStarCustomPathFinder.java | starcoder |
package io.github.shiruka.api.common.vectors;
import io.github.shiruka.api.common.Floors;
import org.jetbrains.annotations.NotNull;
/**
* a class that represents two dimensional vectors.
*
* @param x the x.
* @param y the y.
*/
public record Vector2d(
double x,
double y
) {
/**
* the zero vector.
*/... | src/main/java/io/github/shiruka/api/common/vectors/Vector2d.java | 0.954647 | 0.785925 | Vector2d.java | starcoder |
package org.apache.beam.sdk.extensions.sql;
import org.apache.beam.sdk.annotations.Experimental;
import org.apache.beam.sdk.coders.BeamRecordCoder;
import org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv;
import org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode;
import org.apache.beam.sdk.extensions.sql.impl.s... | sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/BeamSql.java | 0.810366 | 0.428413 | BeamSql.java | starcoder |
package RaytracedObjects;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;
import Materials.Material;
import Utils.BoundingObject;
/**
* A complex object is made of several polygons. So many polygons that it's
* worth using a bounding box.
*
* @author <NAME>
*/
public abstract class ComplexObject e... | RaytracerCore/src/RaytracedObjects/ComplexObject.java | 0.887058 | 0.44083 | ComplexObject.java | starcoder |
package ch.fhnw.util.math;
import java.util.Collection;
import ch.fhnw.util.HashUtilities;
/**
* 4D vector for basic vector algebra. Instances are immutable.
*
* @author radar
*/
public final class Vec4 implements IVec4 {
public static final Vec4 ZERO = new Vec4(0, 0, 0, 0);
public static final Vec4 ONE = new ... | ether-core/src/main/java/ch/fhnw/util/math/Vec4.java | 0.909002 | 0.667886 | Vec4.java | starcoder |
package org.streaminer.stream.frequency;
import java.util.Random;
import org.streaminer.util.ArrayUtils;
import org.streaminer.util.hash.HashUtils;
/**
* Count sketches from Charikar, Chen, Farach-Colton '02. They support: finding
* frequent items, returning point estimates.
*
* @author <NAME> <<EMAIL>>
*/
pub... | src/main/java/org/streaminer/stream/frequency/CCFCSketch.java | 0.798029 | 0.44083 | CCFCSketch.java | starcoder |
package DataStructures.Graphs;
import java.util.*;
/*
Considering 2D matrix tspMatrix[][] as an input, where each consists of array of distances from that indexed city to all the other cities
and -1 represents of non-existant path between those two indexed cities.
The goal is to print at the lowest possible cost duri... | DataStructures/Graphs/TravelSalesmanProblem.java | 0.622689 | 0.578984 | TravelSalesmanProblem.java | starcoder |
package org.ccctc.colleaguedmiclient.util;
import org.ccctc.colleaguedmiclient.model.ByteSplitRemainder;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Utilities for byte and string conversion. All operations use Windows-1252 encoding.
... | src/main/java/org/ccctc/colleaguedmiclient/util/ByteUtils.java | 0.874399 | 0.400398 | ByteUtils.java | starcoder |
package com.epam.jdi.light.asserts.core;
import com.epam.jdi.light.asserts.generic.ITextAssert;
import com.epam.jdi.light.asserts.generic.SelectedAssert;
import com.epam.jdi.light.asserts.generic.UIAssert;
import com.epam.jdi.light.common.JDIAction;
import com.epam.jdi.light.elements.common.UIElement;
import org.hamcr... | jdi-light/src/main/java/com/epam/jdi/light/asserts/core/IsAssert.java | 0.794823 | 0.453443 | IsAssert.java | starcoder |
package io.binac.leetcode;
/**
* <p>Implement the <code>myAtoi(string s)</code> function, which converts a string to a 32-bit signed integer (similar to C/C++'s <code>atoi</code> function).</p>
*
* <p>The algorithm for <code>myAtoi(string s)</code> is as follows:</p>
*
* <ol>
* <li>Read in and ignore any leadin... | java/src/main/java/io/binac/leetcode/StringToIntegerAtoi.java | 0.818483 | 0.467818 | StringToIntegerAtoi.java | starcoder |
@FunctionalInterface
public interface MathematicalFunction
{
public double limitZero = 0.0000001d;
public double epsilon = 0.0001d;
double function ( double x );
public default double f ( double x )
{
return function(x)*60;
}
public default double derivation ( double x )
{
return ( func... | MathematicalFunction.java | 0.569374 | 0.490785 | MathematicalFunction.java | starcoder |
package com.lhkbob.imaje.color.space.rgb;
import com.lhkbob.imaje.color.ColorSpace;
import com.lhkbob.imaje.color.RGB;
import com.lhkbob.imaje.color.XYZ;
import com.lhkbob.imaje.color.space.xyz.CIE31;
import com.lhkbob.imaje.color.transform.CurveTransform;
import com.lhkbob.imaje.color.transform.MatrixTransform;
impor... | src/main/java/com/lhkbob/imaje/color/space/rgb/Linear.java | 0.923493 | 0.417806 | Linear.java | starcoder |
package org.kynosarges.tektosyne.geometry;
import java.io.Serializable;
import java.util.*;
/**
* Provides methods that compare two {@link PointD} instances,
* given a specified epsilon for lexicographic coordinate comparisons.
* Defines a {@link Comparator} that lexicographically compares {@link PointD} i... | tektosyne/src/main/java/org/kynosarges/tektosyne/geometry/PointDComparator.java | 0.967116 | 0.698548 | PointDComparator.java | starcoder |
package uk.ac.cam.ahk44.matrices;
import java.util.Arrays;
/** An immutable matrix of arbitrary dimensions. */
class Matrix {
private final double[][] elements;
private final int width;
private final int height;
private Matrix(int height, int width) {
this(new double[height][width]);
}
/** Create a... | src/main/java/uk/ac/cam/ahk44/matrices/Matrix.java | 0.928165 | 0.509703 | Matrix.java | starcoder |
package org.apache.oozie.example;
import java.util.Date;
import java.util.TimeZone;
import java.util.Calendar;
public class Repeatable {
private String name;
private Date baseline;
private TimeZone timeZone;
private int frequency;
private TimeUnit timeUnit;
public static final TimeZone UTC = TimeZone.getTimeZon... | examples/src/main/java/org/apache/oozie/example/Repeatable.java | 0.919444 | 0.425068 | Repeatable.java | starcoder |
package mote4.util.shader;
import java.nio.FloatBuffer;
import mote4.util.ErrorUtils;
import mote4.util.texture.TextureMap;
import org.lwjgl.BufferUtils;
import static org.lwjgl.opengl.GL11.glGetInteger;
import static org.lwjgl.opengl.GL13.*;
import static org.lwjgl.opengl.GL20.*;
/**
* Utility for setting shader ... | src/mote4/util/shader/Uniform.java | 0.863406 | 0.574604 | Uniform.java | starcoder |
package com.spartronics4915.lib.math.threedim.math3;
import org.apache.commons.math3.linear.RealMatrix;
import org.apache.commons.math3.linear.Array2DRowRealMatrix;
import org.apache.commons.math3.linear.MatrixUtils;
public class Matrix3 extends Array2DRowRealMatrix
{
// quell serializable warning (currently unim... | src/main/java/com/spartronics4915/lib/math/threedim/math3/Matrix3.java | 0.806281 | 0.421909 | Matrix3.java | starcoder |
package org.ddogleg.sorting;
import org.junit.jupiter.api.Test;
import java.util.Random;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author <NAME>
*/
public class TestApproximateSort_F64 {
Random rand = new Random(234);
@Test
... | test/org/ddogleg/sorting/TestApproximateSort_F64.java | 0.777553 | 0.512266 | TestApproximateSort_F64.java | starcoder |
package immortal.persistentScope.transientScope;
/**
* The <code>Vector2d</code> class implements a 2-dimensional vector that can represent the
* position or velocity of an object within a 2D space. This implementation uses public, non-final
* fields to avoid as much object creation as possible. Java does not have ... | projects/pjcd/src/main/java/immortal/persistentScope/transientScope/Vector2d.java | 0.912062 | 0.777553 | Vector2d.java | starcoder |
package us.ihmc.robotics.robotDescription;
import java.util.List;
import us.ihmc.euclid.tuple3D.Vector3D;
import us.ihmc.euclid.tuple3D.interfaces.Tuple3DReadOnly;
import us.ihmc.euclid.tuple3D.interfaces.Vector3DBasics;
import us.ihmc.euclid.tuple3D.interfaces.Vector3DReadOnly;
public class OneDoFJointDescription e... | src/main/java/us/ihmc/robotics/robotDescription/OneDoFJointDescription.java | 0.925626 | 0.509337 | OneDoFJointDescription.java | starcoder |
package com.github.errantlinguist.reflect;
import java.lang.reflect.Array;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import jav... | src/main/java/com/github/errantlinguist/reflect/ReflectingGenerics.java | 0.890592 | 0.403126 | ReflectingGenerics.java | starcoder |
package com.strategicgains.syntaxe;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import com.strategicgains.syntaxe.annotation.ChildValidation;
import com.strategicgains.syntaxe.annotation.Required;
... | test/java/com/strategicgains/syntaxe/ObjectGraphValidationTest.java | 0.90089 | 0.49347 | ObjectGraphValidationTest.java | starcoder |
package org.javarosa.core.reference;
/**
* PrefixedRootFactory provides a clean way to implement
* the vast majority of behavior for a reference factory.
*
* A PrefixedRootFactory defines a set of roots which it can
* provide references for. Roots can either be a full URI root
* like "http://", or "file://", or ... | src/main/java/org/javarosa/core/reference/PrefixedRootFactory.java | 0.88765 | 0.41401 | PrefixedRootFactory.java | starcoder |
package vlfsoft.patterns.enterprise.peaa;
import vlfsoft.paradigms.ProgrammingParadigm.Declarative;
import vlfsoft.patterns.GOF;
import vlfsoft.patterns.GOF.Interpreter;
import vlfsoft.patterns.GOF.Memento;
import vlfsoft.patterns.Pattern;
import vlfsoft.patterns.design.DesignPattern;
import vlfsoft.patterns.design.De... | src/main/java/vlfsoft/patterns/enterprise/peaa/PEAA.java | 0.818338 | 0.472562 | PEAA.java | starcoder |
package graphs.linkedlistgraph;
import java.util.ArrayList;
import java.util.List;
/**
* A vertex of a LinkedListGraph.
*/
public class LinkedListVertex {
private double x, y; // The coordinates of this vertex
private LinkedListVertexEntry head; // Pointer to the first element in the double-linked adjacenc... | src/graphs/linkedlistgraph/LinkedListVertex.java | 0.943764 | 0.530054 | LinkedListVertex.java | starcoder |
package boofcv.alg.transform.pyramid;
import boofcv.abst.filter.convolve.ConvolveInterface;
import boofcv.abst.filter.derivative.AnyImageDerivative;
import boofcv.alg.filter.derivative.GImageDerivativeOps;
import boofcv.core.image.GeneralizedImageOps;
import boofcv.core.image.border.BorderType;
import boofcv.factory.f... | main/boofcv-ip/src/boofcv/alg/transform/pyramid/NoCacheScaleSpace.java | 0.861582 | 0.572783 | NoCacheScaleSpace.java | starcoder |
package edu.snu.mist.core.task.merging;
import edu.snu.mist.common.graph.DAG;
import edu.snu.mist.common.graph.MISTEdge;
import edu.snu.mist.core.task.*;
import edu.snu.mist.core.task.QueryRemover;
import javax.inject.Inject;
import java.util.Collection;
/**
* This removes the query from MIST.
* It considers the q... | mist-core/src/main/java/edu/snu/mist/core/task/merging/MergeAwareQueryRemover.java | 0.783409 | 0.444746 | MergeAwareQueryRemover.java | starcoder |
package org.actorsguildframework.immutable;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.... | testSrc/org/actorsguildframework/immutable/ImmutableSetTest.java | 0.701713 | 0.584834 | ImmutableSetTest.java | starcoder |
package jskills.trueskill.factors;
import jskills.factorgraphs.Message;
import jskills.factorgraphs.Variable;
import jskills.numerics.GaussianDistribution;
import static jskills.numerics.GaussianDistribution.*;
import static jskills.trueskill.TruncatedGaussianCorrectionFunctions.vWithinMargin;
import static jskills.t... | src/main/java/jskills/trueskill/factors/GaussianWithinFactor.java | 0.908808 | 0.416085 | GaussianWithinFactor.java | starcoder |
package com.omtlab.algorithmrecipe.slidingwindow;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
/**
* 904. Fruit Into Baskets
* <p>
* In a row of trees, the i-th tree produces fruit with type tree[i].
* <p>
* You start at any tree of your choice, then repeatedl... | src/main/java/com/omtlab/algorithmrecipe/slidingwindow/LC904.java | 0.872822 | 0.572065 | LC904.java | starcoder |
package com.martenscedric;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.*;
import com.badlogic.gdx.math.EarClippingTriangulator;
import com.badlogic.gdx.utils.ShortArray;
import org.codetome.hexameter.core.api.Hexag... | LD38/core/src/com/martenscedric/TileData.java | 0.75401 | 0.408749 | TileData.java | starcoder |
package org.sfvl.doctesting.utils;
import java.nio.file.Path;
import java.nio.file.Paths;
public class OnePath extends DocPath {
/// extension of the file.
protected final String suffix;
/// Root path of the type of file.
protected final Path rootPath;
public OnePath(Path rootPath, Path folder, S... | documentationtesting/src/main/java/org/sfvl/doctesting/utils/OnePath.java | 0.82386 | 0.401981 | OnePath.java | starcoder |
package io.github.richardstartin.multimatcher.core.masks;
import io.github.richardstartin.multimatcher.core.Mask;
import org.roaringbitmap.IntIterator;
import org.roaringbitmap.buffer.ImmutableRoaringBitmap;
import org.roaringbitmap.buffer.MutableRoaringBitmap;
import java.nio.ByteBuffer;
import java.util.Arrays;
imp... | multi-matcher-core/src/main/java/io/github/richardstartin/multimatcher/core/masks/RoaringMask.java | 0.873134 | 0.593609 | RoaringMask.java | starcoder |
package octavian.algorithms.elgamal;
import java.math.BigInteger;
import java.util.Random;
import octavian.algorithms.Algorithm;
import octavian.algorithms.elgamal.key.ElGamalKeySet;
import octavian.algorithms.elgamal.key.ElGamalPrivateKey;
import octavian.algorithms.elgamal.key.ElGamalPublicKey;
import octavian.filem... | src/octavian/algorithms/elgamal/ElGamal.java | 0.77768 | 0.4436 | ElGamal.java | starcoder |
package us.ihmc.robotics.linearAlgebra.careSolvers;
import org.ejml.data.DMatrixRMaj;
import org.ejml.dense.row.CommonOps_DDRM;
import org.ejml.dense.row.factory.LinearSolverFactory_DDRM;
import org.ejml.interfaces.linsol.LinearSolverDense;
import us.ihmc.matrixlib.MatrixTools;
import us.ihmc.matrixlib.NativeCommonOp... | ihmc-robotics-toolkit/src/main/java/us/ihmc/robotics/linearAlgebra/careSolvers/SignFunctionCARESolver.java | 0.901298 | 0.47725 | SignFunctionCARESolver.java | starcoder |
package vanadis.lang.piji;
import java.util.Arrays;
import java.util.List;
/**
* A class describing a tree node with children in a Scheme tree
*
* @author <NAME>
*/
public final class ListNode extends AbstractNode {
private static final long serialVersionUID = -7895911217883595746L;
private static final... | lang/piji/src/main/java/vanadis/lang/piji/ListNode.java | 0.918421 | 0.480113 | ListNode.java | starcoder |
package org.lcsim.recon.tracking.trfxyp;
import org.lcsim.recon.tracking.trfutil.Assert;
import org.lcsim.recon.tracking.trfutil.TRFMath;
import org.lcsim.recon.tracking.spacegeom.SpacePoint;
import org.lcsim.recon.tracking.spacegeom.SpacePath;
import org.lcsim.recon.tracking.spacegeom.CartesianPoint;
import org.lcsi... | trf/src/main/java/org/lcsim/recon/tracking/trfxyp/SurfXYPlane.java | 0.861509 | 0.530297 | SurfXYPlane.java | starcoder |
package android.graphics;
import android.compat.annotation.UnsupportedAppUsage;
/**
* The NinePatch class permits drawing a bitmap in nine or more sections.
* Essentially, it allows the creation of custom graphics that will scale the
* way that you define, when content added within the image exceeds the normal
* ... | android-31/src/android/graphics/NinePatch.java | 0.969928 | 0.444746 | NinePatch.java | starcoder |
package com.opengamma.analytics.financial.instrument.payment;
import java.util.Arrays;
import org.apache.commons.lang.NotImplementedException;
import org.threeten.bp.LocalDate;
import org.threeten.bp.ZonedDateTime;
import com.opengamma.OpenGammaRuntimeException;
import com.opengamma.analytics.financial.instrument.In... | projects/analytics/src/main/java/com/opengamma/analytics/financial/instrument/payment/CouponIborAverageFixingDatesCompoundingDefinition.java | 0.928214 | 0.622689 | CouponIborAverageFixingDatesCompoundingDefinition.java | starcoder |
package com.baz.app.lc.medium;
import com.baz.app.Interface.Facebook.Facebook;
public class SearchInRotatedSortedArray implements Facebook {
/**
* Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
*
* (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2])... | src/main/java/com/baz/app/lc/medium/SearchInRotatedSortedArray.java | 0.772144 | 0.442817 | SearchInRotatedSortedArray.java | starcoder |
package org.assertj.guava.api;
import static org.assertj.core.error.ShouldBeEmpty.shouldBeEmpty;
import static org.assertj.core.error.ShouldBeEqual.shouldBeEqual;
import static org.assertj.guava.error.ShouldHaveSize.shouldHaveSize;
import java.io.IOException;
import org.assertj.core.api.AbstractAssert;
import org.as... | src/main/java/org/assertj/guava/api/ByteSourceAssert.java | 0.926275 | 0.616647 | ByteSourceAssert.java | starcoder |
package seedu.address.ui.statisticcard;
import static seedu.address.logic.constants.CalendarConstants.EXAM_WEEK_1;
import static seedu.address.logic.constants.CalendarConstants.EXAM_WEEK_2;
import static seedu.address.logic.constants.CalendarConstants.READING_WEEK;
import static seedu.address.logic.constants.CalendarC... | src/main/java/seedu/address/ui/statisticcard/WeekNumberCard.java | 0.851953 | 0.498047 | WeekNumberCard.java | starcoder |
package org.jhotdraw.color;
import java.awt.color.ColorSpace;
/**
* The 1976 CIE L*CHa*b* color space (CIELCH).
* <p>
* The L* coordinate of an object is the lightness intensity as measured on a
* scale from 0 to 100, where 0 represents black and 100 represents white.
* <p>
* The C and H coordinates are project... | Umplificator/UmplifiedProjects/jhotdraw7/src/main/java/org/jhotdraw/color/CIELCHabColorSpace.java | 0.923229 | 0.537588 | CIELCHabColorSpace.java | starcoder |
package frc.robot;
public final class Constants {
public static final class DriveConstants {
public static final double kDriveAlpha = 0.11765;
public static final double kDriveOneMinusAlpha = 0.88235;
public static final int kRightMasterTalonID = 16;
public static final int kRight... | src/main/java/frc/robot/Constants.java | 0.703346 | 0.526404 | Constants.java | starcoder |
package org.apache.skywalking.oap.server.analyzer.provider.meter.process;
import lombok.Data;
import org.apache.skywalking.apm.network.language.agent.v3.Label;
import org.apache.skywalking.apm.network.language.agent.v3.MeterSingleValue;
import java.math.BigDecimal;
import java.util.stream.Collectors;
/**
* Support ... | oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/meter/process/EvalSingleData.java | 0.926628 | 0.426023 | EvalSingleData.java | starcoder |
package me.earth.phobos.util;
import me.earth.phobos.features.modules.client.ClickGui;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.Packet;
import net.minecraft.network.play.client.CPacketPlayer;
import net.minecraft.util.EnumFacing;
import net.minec... | Catware/me/earth/phobos/util/RotationUtil.java | 0.61855 | 0.470372 | RotationUtil.java | starcoder |
package seedu.sugarmummy.model.records;
import static java.util.Objects.requireNonNull;
import static seedu.sugarmummy.commons.util.AppUtil.checkArgument;
/**
* Represents a Bmi Record's weight in the record book. Guarantees: immutable; is valid as declared in {@link
* #isValidWeight(String)}
*/
public class Weigh... | src/main/java/seedu/sugarmummy/model/records/Weight.java | 0.90463 | 0.451629 | Weight.java | starcoder |
package com.opengamma.strata.data.scenario;
import java.io.Serializable;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Stream;
import com.opengamma.strata.collect.function.ObjIntFunction;
/**
* A market data box that contains no data.
*/
class EmptyMarketDataBox
... | modules/data/src/main/java/com/opengamma/strata/data/scenario/EmptyMarketDataBox.java | 0.894973 | 0.475666 | EmptyMarketDataBox.java | starcoder |
M
1516438554
别无他法, 只能写一遍例子, 找规律,然后greedy.
需要写一遍发现的规律比如: 从h大的开始排列, 先放入k小的. 写comparator的时候要注意正确性.
如果要sort, 并且灵活insert:用arrayList. 自己做一个object.
最后做那个'matchCount'的地方要思路清晰, 找到最正确的spot, 然后greedy insert.
O(n) space, O(nLog(n)) time, because of sorting.
可能有简化的余地, 代码有点太长.
比如试一试不用额外空间?
```
/*
Suppose you have a random list ... | LintCode-master/Java/Queue Reconstruction by Height.java | 0.639849 | 0.953751 | Queue Reconstruction by Height.java | starcoder |
package org.ddogleg.struct;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
/**
* @author <NAME>
*/
public class TestFastQueueList {
@Test
public void size() {
FastQueue<Double> queue = new Fast... | test/org/ddogleg/struct/TestFastQueueList.java | 0.80077 | 0.593197 | TestFastQueueList.java | starcoder |
package io.jeffrey.vector;
/** a register bank that contains 3 vectors along with all possible operations */
public class VectorRegister3 extends VectorRegister2 {
public double x_2;
public double y_2;
public VectorRegister3() {
x_2 = 0.0;
y_2 = 0.0;
}
/** add the 2 and 0 together... | src/main/java/io/jeffrey/vector/VectorRegister3.java | 0.899962 | 0.851274 | VectorRegister3.java | starcoder |
package com.datastax.driver.core;
/**
* The result of a query.
* <p/>
* The retrieval of the rows of a ResultSet is generally paged (a first page
* of result is fetched and the next one is only fetched once all the results
* of the first one has been consumed). The size of the pages can be configured
* either g... | driver-core/src/main/java/com/datastax/driver/core/ResultSet.java | 0.908879 | 0.430147 | ResultSet.java | starcoder |
package org.simpliccity.styleguide.annotation;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.SOURCE;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* <p>Identifies a code ... | modules/styleguide-core/src/main/java/org/simpliccity/styleguide/annotation/CodeStyle.java | 0.763484 | 0.577287 | CodeStyle.java | starcoder |
package com.tcg.mlgpong.gamestates;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.... | core/src/com/tcg/mlgpong/gamestates/PlayState.java | 0.519765 | 0.457197 | PlayState.java | starcoder |
package com.opengamma.financial.analytics.model.equity.option;
import java.util.Collections;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.opengamma.OpenGammaRuntimeException;
import com.opengamma.analytics.financial.equity.EqyOptBjerksundStenslandPresentValueCalculator;
i... | projects/OG-Financial/src/main/java/com/opengamma/financial/analytics/model/equity/option/EquityOptionBjerksundStenslandImpliedVolFunction.java | 0.838713 | 0.446495 | EquityOptionBjerksundStenslandImpliedVolFunction.java | starcoder |
package org.iobserve.analysis.behavior.karlsruhe.data;
import java.util.ArrayList;
import java.util.List;
/**
* Represents a loop element. It contains the iterated sequence and the number of iterations as loop
* count. The start and end index states at which index the iterated segment that is represented by
* the ... | analysis/src/main/java/org/iobserve/analysis/behavior/karlsruhe/data/LoopElement.java | 0.824956 | 0.499146 | LoopElement.java | starcoder |
package se.liu.ida.nlp.sdp.toolkit.graph;
/**
* Inspect graph-theoretic properties.
*
* @author <NAME>
*/
public class InspectedGraph {
/**
* The analyzed graph.
*/
private final Graph graph;
/**
* The number of non-wall node of this graph.
*/
private final int nNonWallNodes;
/**
* DFS of the gra... | src/main/java/se/liu/ida/nlp/sdp/toolkit/graph/InspectedGraph.java | 0.946088 | 0.553867 | InspectedGraph.java | starcoder |
public class Date
{
private int monthPart;
private int dayPart;
private int yearPart;
private String dateResult;
// constructor initializes Date with month, day and year supplied as argument
public Date( int month, int day, int year )
{
monthPart = month;
dayPart = day;
yearP... | DateTest/Date.java | 0.578686 | 0.421492 | Date.java | starcoder |
package hu.sed.parser.antlr4.grammar.solidity;
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
/**
* This class provides an empty implementation of {@link SolidityVisitor},
* which can be extended to create a visitor which only needs to handle a subset
* of the available methods.
*
* @param <T> The ret... | src/main/java/hu/sed/parser/antlr4/grammar/solidity/SolidityBaseVisitor.java | 0.903496 | 0.491273 | SolidityBaseVisitor.java | starcoder |
package FuncionesCH;
import Personas.Profesor;
/**
* Esta clase permite guardar los datos del curso
*/
public class Curso {
private Materia materia;
private Profesor profesor;
private int capacidad;
private Dia dia;
private String horario;
private int registrados;
/**
* Este mé... | Hogwarts/src/FuncionesCH/Curso.java | 0.675978 | 0.425009 | Curso.java | starcoder |
package fulltheta.algos;
import fulltheta.data.graph.GraphVertex;
public class Cone implements Comparable<Cone> {
private double aperture;
private double bisector;
public Cone(double aperture, double bisector) {
this.aperture = aperture;
this.bisector = bisector;
}
/**
* Ge... | src/fulltheta/algos/Cone.java | 0.942863 | 0.59611 | Cone.java | starcoder |
package com.amcharts.json;
import java.util.List;
import com.amcharts.api.IsAxisBase;
import com.amcharts.api.IsGuide;
public class AxisBase implements IsAxisBase
{
private Boolean autoGridCount;
private double axisAlpha;
private String axisColor;
private double axisThickness;
private double axisX;
privat... | gwt-amcharts/src/main/java/com/amcharts/json/AxisBase.java | 0.886929 | 0.408336 | AxisBase.java | starcoder |
package com.freetymekiyan.algorithms.level.hard;
import com.freetymekiyan.algorithms.utils.Utils.ListNode;
/**
* Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
* <p>
* If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it... | src/com/freetymekiyan/algorithms/level/Hard/ReverseNodesInKGroup.java | 0.813313 | 0.422683 | ReverseNodesInKGroup.java | starcoder |
package bijnum;
import java.util.*;
import ij.*;
/**
* Principal component analysis (PCA) on 2-D sequences (ie. image sequences).
* Image sequences are organized as matrix with each image as a column vector.
* This is how you do it (Snapshot method by Sirovich et al.):
* <pre>
* ' is transpose
* cov = a * a'
* e... | src-plugins/FlowJ_/src/main/java/bijnum/BIJpca.java | 0.847999 | 0.590543 | BIJpca.java | starcoder |
package boofcv.alg.feature.disparity.blockmatch;
import boofcv.alg.descriptor.DescriptorDistance;
import boofcv.struct.image.*;
/**
* Contains common functions for computing disparity scores.
*
* @author <NAME>
*/
public class UtilDisparityScore { // TODO rename?
/**
* Computes the SAD disparity for an entire... | main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/blockmatch/UtilDisparityScore.java | 0.639173 | 0.741955 | UtilDisparityScore.java | starcoder |
package org.apache.hyracks.storage.am.rtree.impls;
import org.apache.hyracks.dataflow.common.data.accessors.ITupleReference;
import org.apache.hyracks.storage.am.common.api.IPrimitiveValueProvider;
public class Rectangle {
private int dim;
private double[] low;
private double[] high;
public Rectangle... | hyracks-fullstack/hyracks/hyracks-storage-am-rtree/src/main/java/org/apache/hyracks/storage/am/rtree/impls/Rectangle.java | 0.774455 | 0.457924 | Rectangle.java | starcoder |
package org.chromium.mojo.bindings;
import org.chromium.mojo.bindings.Struct.DataHeader;
import java.nio.ByteBuffer;
/**
* Header information for a message.
*/
public class MessageHeader {
private static final int SIMPLE_MESSAGE_SIZE = 16;
private static final int SIMPLE_MESSAGE_NUM_FIELDS = 2;
priva... | mojo/public/java/bindings/src/org/chromium/mojo/bindings/MessageHeader.java | 0.895583 | 0.40869 | MessageHeader.java | starcoder |
package ca.eandb.jmist.framework.scatter;
import java.util.Arrays;
import ca.eandb.jmist.framework.Random;
import ca.eandb.jmist.framework.SurfacePointGeometry;
import ca.eandb.jmist.math.Basis3;
import ca.eandb.jmist.math.MathUtil;
import ca.eandb.jmist.math.SphericalCoordinates;
import ca.eandb.jmist.math.Vector3;
... | jmist-core/src/main/java/ca/eandb/jmist/framework/scatter/TabularPerturbingSurfaceScatterer.java | 0.759225 | 0.479686 | TabularPerturbingSurfaceScatterer.java | starcoder |
package com.scottkillen.mod.dendrology.world.gen.feature.ewcaly;
import com.google.common.base.Objects;
import com.scottkillen.mod.dendrology.world.gen.feature.AbstractTree;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import java.util.Random;
public class Norm... | src/main/java/com/scottkillen/mod/dendrology/world/gen/feature/ewcaly/NormalEwcalyTree.java | 0.558929 | 0.504516 | NormalEwcalyTree.java | starcoder |
package com.jrdp.core.util;
public class BitManip
{
/**
* merges the bytes to an int. the first argument is set at the least
* significant position, second is next, and so on
*/
public final static int mergeToIntLeastSigFirst(byte a)
{
return a & 0xFF;
}
/**
* merges the bytes to an int. the first arg... | jrdp/core/src/main/java/com/jrdp/core/util/BitManip.java | 0.799481 | 0.674869 | BitManip.java | starcoder |
package org.spiderplan.causal.forwardPlanning;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import org.spiderplan.representation.l... | src/main/java/org/spiderplan/causal/forwardPlanning/CommonDataStructures.java | 0.724481 | 0.413477 | CommonDataStructures.java | starcoder |
package psymbolic.valuesummary;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* Represents a primitive value summary (Boolean, Integer, Float, String)
* @param <T> Type of value stored in the primitive value summary
*/
public c... | Src/PRuntimes/PSymbolicRuntime/src/main/java/psymbolic/valuesummary/PrimitiveVS.java | 0.938822 | 0.570271 | PrimitiveVS.java | starcoder |
package com.linkedin.dagli.util.invariant;
import com.linkedin.dagli.util.closeable.Closeables;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Supplier;
/**
* This class is heavily inspired by Guava's Preconditions class. We... | util-core/src/main/java/com/linkedin/dagli/util/invariant/Arguments.java | 0.96721 | 0.587618 | Arguments.java | starcoder |
package org.prolog4j;
import java.io.IOException;
import java.io.InputStream;
/**
* A Prover object represents a Prolog knowledge base, on which you can create
* and solve queries. The implementations of this interface should not provide
* public constructors. The Prover instances should be created through
* {@li... | bundles/org.prolog4j.api/src/org/prolog4j/Prover.java | 0.88263 | 0.427217 | Prover.java | starcoder |
package io.grpc.examples.p4p.p4p.util;
import java.util.ArrayList;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileInputStream;
/**
* A sparse matrix class. It basically stores <row, col, val> touples. By
* default the elements ar... | examples/src/main/java/io/grpc/examples/p4p/p4p/util/SparseMatrix.java | 0.814643 | 0.406273 | SparseMatrix.java | starcoder |
package com.zygon.rl.core.model;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* Location
*
*/
public class Location {
// singleton cache :/
private static final Map<Integer, Location> KNOWN_LOCATIONS = new HashMap<>();
pr... | src/main/java/com/zygon/rl/core/model/Location.java | 0.901111 | 0.470919 | Location.java | starcoder |
package de.hpi.bpt.chimera.util;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import org.json.JSONArray;
import java.util.*;
/**
* This class provides the helper methods/classes
* used for the JSON representation for the REST connections.
*/
public final class JsonUtil {
// hide default publi... | src/main/java/de/hpi/bpt/chimera/util/JsonUtil.java | 0.872755 | 0.430147 | JsonUtil.java | starcoder |
package org.apache.cassandra.db.tries;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.google.common.collect.Iterables;
/**
* A merged view of multiple tries.
*
* This is accomplished by walking the cursors in parallel; the merged cursor takes the position and features o... | src/java/org/apache/cassandra/db/tries/CollectionMergeTrie.java | 0.914034 | 0.557183 | CollectionMergeTrie.java | starcoder |
package cgeo.geocaching.maps.google.v2;
import cgeo.geocaching.maps.interfaces.GeoPointImpl;
import cgeo.geocaching.maps.interfaces.MapControllerImpl;
import cgeo.geocaching.utils.Log;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.m... | main/src/cgeo/geocaching/maps/google/v2/GoogleMapController.java | 0.852184 | 0.418816 | GoogleMapController.java | starcoder |
package com.dreamstone.util;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import com.dreamstone.core.DisplayCarrier;
/**
* The TransformImage class is a static class that comes with a variety of methods designed to help with manip... | src/com/dreamstone/util/TransformImage.java | 0.96362 | 0.584093 | TransformImage.java | starcoder |
package zgame.core.utils;
/**
* A class containing utility methods for manipulating strings
*/
public final class ZStringUtils{
/**
* Print, to the main System.out, the string representation of a list of objects on one line using efficient string concatenation
*
* @param objs The list of objects to print t... | src/zgame/core/utils/ZStringUtils.java | 0.754373 | 0.491517 | ZStringUtils.java | starcoder |
package vehicles.cars.test;
import org.junit.Test;
import vehicles.cars.*;
import vehicles.cars.engines.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import static org.junit.Assert.*;
public class CarsTest {
// Motorgyártók felsorolása
/*
@... | 20-21-1/20210118-car/CarsTest.java | 0.744842 | 0.531331 | CarsTest.java | starcoder |
package com.jswiff.swfrecords;
import com.jswiff.io.InputBitStream;
import com.jswiff.io.OutputBitStream;
import java.io.IOException;
/**
* <p>
* This class is used within <code>DefineBitsLossless2</code> tags (with 8-bit
* colormapped images). It contains a color table and an array of pixel data.
*... | projects/jswiff/src/com/jswiff/swfrecords/AlphaColorMapData.java | 0.909107 | 0.521959 | AlphaColorMapData.java | starcoder |
package com.badlogic.gdx.physics.bullet.dynamics;
import com.badlogic.gdx.math.Matrix3;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Quaternion;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.physics.bullet.BulletBase;
import com.badlogic.gdx.physics.bullet.collision.btCollisionObj... | extensions/gdx-bullet-old/gdx-bullet-dragome/src/com/badlogic/gdx/physics/bullet/dynamics/btRigidBody.java | 0.834441 | 0.459804 | btRigidBody.java | starcoder |
package org.jgrapht.alg.connectivity;
import org.jgrapht.*;
import java.util.*;
/**
* Computes the strongly connected components of a directed graph. The implemented algorithm follows
* Cheriyan-Mehlhorn/Gabow's algorithm presented in Path-based depth-first search for strong and
* biconnected components by Gabow ... | jgrapht-1.3.0/source/jgrapht-core/src/main/java/org/jgrapht/alg/connectivity/GabowStrongConnectivityInspector.java | 0.946424 | 0.523238 | GabowStrongConnectivityInspector.java | starcoder |
package cck.text;
/**
* @author <NAME>
*/
public class TermUtil {
/**
* The <code>reportQuantity()</code> method is a simply utility to print out a quantity's name
* (such as "Number of instructions executed", the value (such as 2002), and the units (such as
* cycles) in a colorized and standardiz... | src/cck/text/TermUtil.java | 0.834373 | 0.458955 | TermUtil.java | starcoder |
package com.dataframe;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import java.util.HashMap;
import java.util.Map;
import java.util.Date;
import java.awt.BorderLayout;
import org.apache.commons.math3.fitting.leastsquares.LevenbergMarquardtOptimizer;
import org.apache.commons.math3.fitting.least... | src/com/dataframe/DataFrame.java | 0.810666 | 0.461259 | DataFrame.java | starcoder |
package com.vc.hard;
import java.util.*;
class BestTimeToBuyAndSellStockIii {
public int maxProfit(int[] prices) {
/**
Input:
[3 3 5 0 0 3 1 4]
1 2 3 4 5 6 7 8
k = 2
Number of transactions allowed is 2, which means 2 Buys and 2 Sells are al... | src/main/java/com/vc/hard/BestTimeToBuyAndSellStockIii.java | 0.611846 | 0.536616 | BestTimeToBuyAndSellStockIii.java | starcoder |
package org.opencb.biodata.formats.alignment.samtools;
public class SamtoolsStats {
private String file;
private int rawTotalSequences;
private int filteredSequences;
private int sequences;
private int isSorted;
private int firstFragments;
private int lastFragments;
private int rea... | biodata-formats/src/main/java/org/opencb/biodata/formats/alignment/samtools/SamtoolsStats.java | 0.774413 | 0.480235 | SamtoolsStats.java | starcoder |
package com.github.loyada.jdollarx;
import java.util.function.BiFunction;
import java.util.function.Function;
/**
* Functions to create custom {@link ElementProperty}, if the property is unsupported out-of-the-box.
*/
public final class CustomElementProperties {
private CustomElementProperties() {}
/**
... | jdollarx/src/main/java/com/github/loyada/jdollarx/CustomElementProperties.java | 0.943478 | 0.473049 | CustomElementProperties.java | starcoder |
package com.cosium.vet.thirdparty.apache_commons_lang3;
/**
* Supports operations on bit-mapped fields. Instances of this class can be used to store a flag or
* data within an {@code int}, {@code short} or {@code byte}.
*
* <p>Each {@code BitField} is constructed with a mask value, which indicates the bits that wi... | src/main/java/com/cosium/vet/thirdparty/apache_commons_lang3/BitField.java | 0.964119 | 0.580441 | BitField.java | starcoder |
package com.spaceproject.ui;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g... | core/src/com/spaceproject/ui/Sprite3D.java | 0.856332 | 0.416144 | Sprite3D.java | starcoder |
package io.opensphere.core.common.shapefile.shapes;
import java.nio.ByteBuffer;
public class PointZRecord extends PointMRecord implements ZMinMax
{
/* Byte Position Field Value Type Order Byte 0 Shape Type 11 Integer Little
* Byte 4 X X Double Little Byte 12 Y Y Double Little Byte 20 Z Z Double
* Little... | open-sphere-base/core/src/main/java/io/opensphere/core/common/shapefile/shapes/PointZRecord.java | 0.849238 | 0.413832 | PointZRecord.java | starcoder |
package org.sbml.libsbml;
/**
* Abstract Syntax Tree (AST) representation of a
* mathematical expression.
<p>
* <p style='color: #777; font-style: italic'>
This class of objects is defined by libSBML only and has no direct
equivalent in terms of SBML components. This class is not prescribed by
the SBML specific... | third_party/libSBML-5.9.0-Source/src/bindings/java/java-files/org/sbml/libsbml/ASTNode.java | 0.87183 | 0.706899 | ASTNode.java | starcoder |
package com.bestialMania.gui.text;
import com.bestialMania.MemoryManager;
import com.bestialMania.Settings;
import com.bestialMania.rendering.*;
import com.bestialMania.rendering.model.Model;
import com.bestialMania.rendering.shader.UniformMatrix4;
import com.bestialMania.rendering.shader.UniformVector3f;
import com.b... | src/com/bestialMania/gui/text/Text.java | 0.898672 | 0.476214 | Text.java | starcoder |
package com.google.cloud.tools.eclipse.projectselector.model;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTh... | plugins/com.google.cloud.tools.eclipse.projectselector.test/src/com/google/cloud/tools/eclipse/projectselector/model/GcpProjectTest.java | 0.797675 | 0.495056 | GcpProjectTest.java | starcoder |
package Binary_Tree_Postorder_Traversal;
import java.util.ArrayList;
import java.util.Stack;
public class Solution {
public class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode(int x) {
val = x;
}
}
/**
* 递归的方式实现
* 算法的时间复杂度是O(n)... | src/Binary_Tree_Postorder_Traversal/Solution.java | 0.729905 | 0.50116 | Solution.java | starcoder |
package net.cpdomina.splaytree;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.Iterator;
import org.junit.Test;
public class SplayTreeTest {
private static final int NU... | test/src/net/cpdomina/splaytree/SplayTreeTest.java | 0.801237 | 0.754169 | SplayTreeTest.java | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.