method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
edb1dd43-311b-42d8-8256-5a61f52dc3b7
5
@Ignore @Test public void testCreate() throws Exception { Thread t = monitorThread(); // final long length = 128 * 1000 * 1000 * 1000L; final long length = 10 * 1000 * 1000 * 1000L; HugeArrayList<MutableBoolean> hugeList = new HugeArrayBuilder<MutableBoolean>() {{ capacity = length; }}...
96ac1422-1970-4312-8abb-c9381bdb03c2
9
public int search(int[] A, int target) { int l = A == null ? 0 : A.length; if (l == 0) return -1; int low = 0, high = l - 1; while (low <= high) { int mid = low + (high - low) / 2; if (target == A[mid]) { return mid; } else if (A[mid] >...
d6fd7a92-6c87-485f-ac23-144bfa6ca7d4
0
@Override public String toString() { return "[name=" + name + ", helloWorld=" + helloWorld + "]"; }
99a445d8-800d-4ff6-902a-54d1df7a1e9c
8
public Graph<Integer> execute(int size) { Graph<Integer> maze = new Graph<Integer>(); //Add all the nodes to the graph for(int i = 0; i < size*size; i++) { maze.addNode(i); } ArrayList<Integer> visited = new ArrayList<Integer>(); ArrayList<Integer> adjacentCells = new ArrayList<Integer>(); ArrayList<In...
4eeaa7b5-35b8-42ed-ba26-e18afad70754
5
public String remove(Properties serviceProperties) {String GETCommand="", ret=""; if(serviceProperties!=null && !serviceProperties.equals("")) { GETCommand=""; Enumeration e = serviceProperties.propertyNames(); while (e.hasMoreElements()) { String key = (String) e.nextElem...
8daabb5c-ba3f-4e2d-be7c-72fedf7435f0
1
public void visitCode() { if (mv != null) { mv.visitCode(); } }
1686dcd2-01ea-42be-990b-15d19e376a77
6
public static void main(String[] args) { final String menu[] = {"Quitter", "Visualiser", "Supprimer", "Modifier", "Ajouter"}; JOptionPane.showMessageDialog(null, "BIENVENUE DANS MON PROGRAMME"); int choix; // contient le choix de l'utilisateur dans le menu //boucler tant et aussi long...
1628f3f3-ff94-4b4d-896d-546d39bca1bc
6
private UndirectedGraph<Vertex> multiStep(){ initHistoricalControl(); UndirectedGraph<Vertex> forReturn = graph.clone(); UndirectedGraph<Vertex> forModification = null; rand = new Random(); int x = 0, curColor; while(x < numChange){ Vertex toChange; HashSet<Vertex> dis = new HashSet<Vertex>(disallowe...
7a913ce9-b41e-4ab5-aaa2-a250a5361578
7
private MouseMotionListener getScrollerMouseMotionListener() { return new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { if (!needDragging || getColorSchemeByUsage()) return; DNAScrollerModel dnamodel = getModel(); if (dnamodel == null) return; if (!dnamodel.isStrandsAvai...
4d41b684-b32c-4290-8a0e-efc2a12b2758
8
public static SingleTestResult create(Command command) { if(Command.SUCCESS_POSITIVE == command) { return SUCCESS_POSITIVE; } if(Command.SUCCESS_NEGATIVE == command) { return SUCCESS_NEGATIVE; } if(Command.FAIL_NEGATIVE == command) { ...
90489939-9b9a-434e-a755-a05b263214cb
4
private boolean checkEdgeCases(CurrentBall previousBall) { if (currentLevel == 3) { if (previousBall.getNameImage() == imageMap.get("orc") || previousBall.getNameImage() == imageMap.get("replicationproteins")) { if (firedBall.getNameImage() == imageMap.get("dnareplication")) { firedBall.setStrand(previous...
f4a62d48-ab64-4bab-89d3-65b15274868c
5
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton4ActionPerformed {//GEN-HEADEREND:event_jButton4ActionPerformed if (!gameover) { if (rule.turn()) { if (rule.check(0, 1)) { rule.pressed(0, 1); if ...
e8e3b4d8-c86f-4df3-b832-d00fb3c13a08
7
public boolean onItemUse(ItemStack var1, EntityPlayer var2, World var3, int var4, int var5, int var6, int var7) { if(var7 == 0) { return false; } else if(var7 == 1) { return false; } else { byte var8 = 0; if(var7 == 4) { var8 = 1; } if...
e537121c-6b77-4b63-915f-d127044e43d4
9
public boolean isOver() { boolean test = false; if (test || m_test) System.out.println("ConnectFour::isOver() - BEGIN"); checkWinner(); Iterator<Coordinate> iterator = m_win.iterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); } if (getWinner() == Game.PlayerTurn.PLAYER1 ...
c91e2088-8898-44f2-8117-bf51925eb43a
2
@Override public String toString() { String transactionItems = ""; int num = this.transaction.getItemSet().size(); for (int i = 0; i < num; i++) { String item = this.transaction.getItemSet().get(i).toString(); transactionItems = transactionItems + item; if (i < num - 1) { transactionItems = transact...
1ddc51bb-4613-4c17-bfed-71e346c623e3
3
public LocomotiveChoice(Frame owner, DepartingTrain theTrain) { super(owner, true); this.theTrain = theTrain; setTitle("Locomotive"); setBounds(100, 100, 332, 180); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, Borde...
7409a1fc-4a97-424e-af19-4365f850f936
2
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setCharacterEncoding("UTF-8"); response.setContentType("text/html;charset=utf-8"); HttpSession session = request.getSession(); User user = (User)session.getAttr...
b66c1a33-981f-4646-b3e6-c6a84463d5b4
2
@Override protected DPLotSizingDecision getDecision( DPBackwardRecursionPeriod[] periods, int setupPeriod, int nextSetupPeriod, double alpha) throws ConvolutionNotDefinedException { //Get the vector of aggregated demand (there is no ADI in this approach) RealDistribution[] demand = new RealDistribution...
ca20a3cf-988f-4688-9bfc-adec58090310
2
public static void main(String[] args) { if(args.length == 3) { if(args[0].equals("f")) { fullscreen = true; } else { fullscreen = false; } width = Integer.parseInt(args[1]); height = Integer.parseInt(args[2]);...
f6bcbf47-eeb7-42d7-8401-248e4e28fec7
7
private void initConnection() throws IOException { ObjectOutputStream objectOutputStream = new ObjectOutputStream(getClientSocket().getOutputStream()); getServer().getClientConnections().add(new ClientConnection(objectOutputStream, getClientSocket())); ObjectInputStream objectInputStream = new ObjectInputStream(g...
54842433-ae3b-429a-902d-5d76ac110d82
0
public CreativeMaterialListResponse( final Boolean success, final String errorMessage, final List<CreativeMaterial> creativeMaterialList ) { super(success, errorMessage); this.creativeMaterialList = creativeMaterialList; }
bc462979-bf52-492f-9357-c9a70ab7de97
5
@Override public void actionPerformed(ActionEvent e) { // Validate the file // if validation fails, ask the user if they would like to save anyway // if they would like to save anyway, // ask them where to save // save boolean save = false; if (documentManager.validate(tabManager.getText())) { save = ...
cd9dafe1-fbb1-40a4-aba5-61999f5a7c9f
4
public void renderBackground() { if(game.menu == null || game.menu.transparentMenu()){ int px = player.x >> 4; int py = player.y >> 4; //System.out.println(px+"/"+py); //System.out.println(getTile(px,py).getClass().getName()); for(int x = px - 7; x < px+8; x++){ for(int y = py-6; y < py+7; y++){ ga...
84b32b65-0667-427f-be54-a8ec7cf21179
6
public void set(int x, int y, Color color) { if (x < 0 || x >= width()) throw new IndexOutOfBoundsException("x must be between 0 and " + (width()-1)); if (y < 0 || y >= height()) throw new IndexOutOfBoundsException("y must be between 0 and " + (height()-1)); if (color == null) throw new NullPoi...
ec1055cd-133e-4b03-b641-9c2a17fe2770
6
public static String escape(String string) { StringBuffer sb = new StringBuffer(); for (int i = 0, length = string.length(); i < length; i++) { char c = string.charAt(i); switch (c) { case '&': sb.append("&amp;"); break; cas...
9ddd4a6a-b35f-4ed0-876f-47f61eb0be59
7
public void removeSubTag(Tag tag) { if (type != Type.TAG_List && type != Type.TAG_Compound) throw new RuntimeException(); if (tag == null) return; Tag[] subtags = (Tag[]) value; for (int i = 0; i < subtags.length; i++) { if (subtags[i] == tag) { ...
8ef3e5f3-f810-485f-b31b-f8fbf417daf8
5
private int intToBytes( int i ) { int q, r; int charPos = 12; byte sign = 0; if (i < 0) { sign = '-'; i = -i; } // Generate two digits per iteration while (i >= 65536) { q = i / 100; // really: r = i - ...
a41f59db-eaa4-4d81-88c3-61559b9c248c
4
public synchronized String setParameters(String KeyValuePairs) { if (game == null) { game = BriscaGameFactory.instantiante( BriscaGameFactory.VANILLA_BRISCA_GAME, null); } if (!game.initialParametersSet()) isWaitingForUsers = true; if (KeyValuePairs.contains(BriscaGameFactory.TOURNAMENT_GAME + "=tr...
9e17b599-01a6-452f-94ca-7b8844772a1f
8
private static int whoWon(char user1, char user2) throws Exception { if (user1 == user2) { return 0; } else if ((user1 == 'r' && user2 == 's') || (user1 == 's' && user2 == 'p') || (user1 == 'p' && user2 == 'r')) { return 1; } else if (whoWon(user2, user1) == 1) { // just ...
1f40261e-d840-47fa-968f-e1d2dc7637a7
3
public RuleSet(String rule) throws IllegalArgumentException { if (!rule.matches("[0-8]{0,9}/[0-8]{0,9}")) { throw new IllegalArgumentException("Bad RuleSet string format."); } this.rule = rule; String survive = rule.substring(0, rule.indexOf("/")); String born = rule...
306e5cf1-2bcf-480c-8ff7-d28765b57ab2
4
public static double jauEect00(double date1, double date2) { /* Time since J2000.0, in Julian centuries */ double t; /* Miscellaneous */ int i, j; double a, s0, s1; /* Fundamental arguments */ double fa[] = new double[14]; /* Returned value. */ double eect; ...
b34b9089-f1ad-4f7e-9147-24501be82e22
1
private static String getFileContents(String filename) throws IOException, FileNotFoundException { File file = new File(filename); StringBuilder contents = new StringBuilder(); BufferedReader input = new BufferedReader(new FileReader(file)); try { String line = ...
771b190e-91fa-49ad-9f5a-30590223a2d2
5
public void draw(Graphics g) { if (paused) { pauseState.draw(g); } else if (gameStates[currentState] != null) { gameStates[currentState].draw(g); } if (doAnimate) { if (changing) { animate(g); } if (changingPause) { animate(g); } } }
584dd1fa-f799-44da-a8bf-b7944fea950c
1
public void visit_if_icmpgt(final Instruction inst) { if (longBranch) { final Label tmp = method.newLabel(); addOpcode(Opcode.opc_if_icmple); addBranch(tmp); addOpcode(Opcode.opc_goto_w); addLongBranch((Label) inst.operand()); addLabel(tmp); } else { addOpcode(Opcode.opc_if_icmpgt); addBranc...
43fdf829-8940-403a-8160-5e7f2cc9bdef
8
public static double svm_predict_probability(svm_model model, svm_node[] x, double[] prob_estimates) { if ((model.param.svm_type == svm_parameter.C_SVC || model.param.svm_type == svm_parameter.NU_SVC) && model.probA != null && model.probB != null) { int i; int nr_class = ...
a8cdc6a1-2993-4c21-8b38-b6bfb6a1df6f
6
public static void printWhynotJustification(Justification justification, OutputStream stream, int maxdepth, Keyword style, boolean summaryP) { { Object old$ExplanationStyle$000 = Logic.$EXPLANATION_STYLE$.get(); try { Native.setSpecial(Logic.$EXPLANATION_STYLE$, ((style != null) ? style : Logic.KWD_B...
f3c223bf-e553-4508-8bf7-a7f9ec22091e
5
public void render(SpriteBatch batch) { // render itself batch.end(); mapRenderer.render(); batch.begin(); for (Rock rock : this.rocks) { rock.render(batch); } for (Light light : this.lights) { light.render(batch); } for ...
79176f05-b01c-405c-9d10-6db14eb1c99d
3
@Test public void testUnzipZipWithRootFolder(){ try { File testFile = new File(this.getClass().getResource("/ziptest_folder/folder.zip").toURI()); String testUnzipFolderPath = testFile.getParent()+ "/zip_content"; File testUnzipFolder = new File(testUnzipFolderPath); //Unzip the file assertTrue(Zi...
165057b8-ac8a-48c0-8ca1-b916a0dbf71d
2
public SwitchServerWindow() { //Window's components. GradientPanel gp = new GradientPanel(new Color(173, 173, 173), new Color(78, 78, 78)); gp.setPreferredSize(new Dimension(width, height)); gp.setLayout(null); ipLabel.setBounds(width / 2 - (83 + 145) / 2, height / 2 - (25 + 5 + 25) / 2, 83, 25); iptf.setB...
4461c4a5-e338-4359-941c-f84326ed8619
9
public static void main(String[] args) throws Exception { List<URL> urls = new ArrayList<URL>(); File tiled = null; for (String s : tiledJars) { tiled = new File(s); if (tiled.exists()) break; } if (tiled == null || !tiled.exists()) { System.e...
d16799ae-21d5-4a95-b2f1-de74967e8649
7
public void setOptions(String[] options) throws Exception { //Debug Option debug = Utils.getFlag('D', options); // Set Tolerance. String Tol = Utils.getOption("Tl", options); if (Tol.length() != 0) { Tolerance = Double.parseDouble(Tol); } //Set Threshold String Thres = Utils.get...
8d13ae9e-c868-40ad-9765-ba32e410405d
8
public final String uriFilter( String line ) { for ( int i = 0; i < VALID_URI_SCHEMES.length; ++i ) { String scheme = VALID_URI_SCHEMES[i]; int index = line.indexOf( scheme ); if ( index != -1 ) { int start = index; in...
0d0c2c24-e7dd-4a08-a199-cbf82f67df47
5
@SuppressWarnings("resource") public int getEmployeeNo(DataSource ds) { while (true) { System.out.print("Back = 0. Enter employee no or doctor name: "); Scanner s = new Scanner(System.in); String doctor_info = s.nextLine(); try { int option = Integer.parseInt(doctor_info); if (option == 0) { ...
02ad7376-91d5-4d92-a2dd-966e14f902d4
2
public static String trimRight(String s) { int i = s.length(); while (i > 0 && s.charAt(i - 1) == ' ') { i--; } return s.substring(0, i); }
9b3a505e-c52c-43f2-94de-1d3a45731fe7
9
public void startElement(String uri, String name, String qName, Attributes atts) { if ("".equals(uri)) { if(is_in_step) { if(qName.equals("lat")) { characters.setLength(0); } if(qName.equals("lng")) ...
62010991-1164-4d96-a1c0-c79dc5d0c7ce
9
public Card[] pickCards(SelectCardOptions sco, Card[] allcards) { GameQuery p = new GameQuery(QueryType.GETCARD, QueryType.CARD) .setInteger(sco.count) .setBoolean(sco.exactly) .setString(sco.header) .setObject(sco); p = query(p); if (p == null) ...
8a57a3c6-c2aa-4fa5-bbf0-faffbbdc30aa
4
public void setFieldValue(_Fields field, Object value) { switch (field) { case WHAT: if (value == null) { unsetWhat(); } else { setWhat((Integer)value); } break; case WHY: if (value == null) { unsetWhy(); } else { setWhy((String)value); ...
d6e39951-5c1c-42db-a3c4-d480a304366a
7
private static final TheoryNormalizer createTheoryNormalizer(TheoryType theoryType, int reasonerVersion) throws ReasoningEngineFactoryException { TheoryNormalizer theoryNormalizer = null; switch (theoryType) { case SDL: switch (reasonerVersion) { case 1: theoryNormalizer = new spindle.engine.sdl.SdlT...
0bbf0dce-36f9-4df1-bd8b-e46750f98959
7
public static void makeCompactGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad) { SpringLayout layout; try { layout = (SpringLayout) parent.getLayout(); } catch (ClassCastException exc) { Syst...
f9c63d6c-3726-4624-9a87-75061070b2cc
3
public Set<Being> getSurroundingBeings(Being base, double radius){ Set<Being> surroundingBeings = new HashSet<Being> (); synchronized (beings) { for (Being being : beings){ if (base.getPosition().isInRadius(being.getPosition(), radius) && base != being) { ...
97c81b93-4cb7-48e6-bf6f-75413e3e737c
9
public static void main(String args[]) { if (args == null) { argumentos = null; } else { System.out.println(args.toString()); for (int i = 0; i < args.length; i++) { System.out.println(args[i].toString()); if (i == 0) { ...
46f03ea5-1e62-4ae9-8c56-663c5b5a0ed1
1
public boolean serializeTable(){ try{ File f = new File(TABLE_FILE); f.createNewFile(); OutputStream file = new FileOutputStream(TABLE_FILE); OutputStream buffer = new BufferedOutputStream(file); ObjectOutput output = new ObjectOutputStream(buffer); try{ output.writeObject(table); } ...
a4e560ec-ddf1-4934-9999-9f54b8bbf3ec
0
protected void setName(String newName) { name = newName; }
ecef5ef6-c5d5-4507-b8c9-e78c4c30bc32
6
private HashMap<String, String> loadHashMap() { HashMap result = new HashMap(); try { BufferedReader br = new BufferedReader(new FileReader(this.out)); String line; while ((line = br.readLine()) != null) { if ((!line.isEmpty()) && (!line.startsWith("#")) && (line.contains(": ...
fa9f1752-2633-4751-bec1-6c7f00c16909
4
private boolean linkPresentForFrame(){ //checking if rectangle is already present for the selected hyperlink on the current frame String linkSelected = jList2.getSelectedValue().toString(); for(int i=0; i<hyperLinks; i++){ if(metaRecords.get(i).rectName.equals(linkSelected))...
cd6445f5-b508-46ab-a5c7-a9cd84e05c10
9
private void onKeyPress() { if (txtFirstName.getText().isEmpty() || txtLastName.getText().isEmpty() || txtAddress.getText().isEmpty() || txtPhone.getText().isEmpty() || txtPaymentNo.getText().isEmpty()) { btnSave.setEnabled(false); } else { btnSave.setEnabled(true...
91a1e615-bdfa-42b7-9144-1e2a4aa53dde
2
public void visitLookupSwitchInsn(final Label dflt, final int[] keys, final Label[] labels) { buf.setLength(0); buf.append(tab2).append("LOOKUPSWITCH\n"); for (int i = 0; i < labels.length; ++i) { buf.append(tab3).append(keys[i]).append(": "); appendLabel(labels[i]); buf.append('\n'); } buf.append...
dec22b3b-93ab-4ee5-b35c-07bc603efdef
3
public BufferedImage readImage() { if (imageStore != null) return imageStore; // if caching, write the image to file; if (isCached) {//isCachingEnabled) { BufferedImage image = null; try { image = ImageIO.read(tempFile); // ge...
4ce045ff-d7bc-42e3-b0d4-a10884ba8960
2
@Override public void run() { this.queue.start(); PartialMessage str = null; while (null != (str = this.socketAdapter.read(str))) { if (str.isComplete()) { this.handleMessage(this.parseMessage(str.getMessage())); str = null; } } }
6e58e876-d868-4c04-babf-12c08cb8c5bc
9
static Collection<String> print(short value, String name, String indent) { String str; switch (value) { case 16: str = "BT_NEW_RATE"; break; case 17: str = "BT_FLAT_RATE"; break; case 18: str = "BT_PREMIUM_CHARGE"; break; case 19: str = "BT_PREMIUM_CREDIT"; break; case 24: str =...
62232a97-1f95-4c49-9261-dd1d80c66ba4
0
public int getS2() { return this.state2; }
cfa38c51-9475-4ee0-812e-fedb07011ec1
8
public Impact hitWall(int width, int height) { if (X <= 0) { if(Y <= 0 || Y +(SizeY*2) >= height - (SizeY*4)) return Impact.BOTH; //ball about to hit corner return Impact.LEFT; } else if (X >= 700 - SizeX) { if(Y <= 0 || Y +(SizeY*2) >= height - (SizeY*4)) return Impact.BOTH; //ball a...
7bea8980-4216-41e2-8595-db19b45bb0da
2
public void addNewPlayer(Player plr, stream str, stream updateBlock) { int id = plr.playerId; playerInListBitmap[id >> 3] |= 1 << (id&7); // set the flag playerList[playerListSize++] = plr; str.writeBits(11, id); // client doesn't seem to like id=0 // TODO: properly implement the character appearance handli...
d9d49811-61da-47e6-97ef-37e85bcd3412
9
@SuppressWarnings("deprecation") public void editBook(Player player, ItemStack item) { // PUT THIS INTO EVERY METHOD PluginDescriptionFile pdfFile = plugin.getDescription(); String cmdFormat = "[" + pdfFile.getName() + "] "; // -------------------------- // This function will check if the player // holds ...
97b32881-9dff-4ed8-8688-a3f5aca02657
5
private void sendReservation(ArrayList resARList, ArrayList resNameList) { // total reservation made. 1 reservation reserves 1 PE. int totalPE = 1; int totalReservation = list_.size(); // total number of Gridlets // gets the init simulation time Calendar cal = Gri...
107e26af-5b8d-4066-aba6-4b8a9c5484b8
1
@Test public void pieniEsteOikealla() { laitetaasPariPientaEstetta(); pe.liikuOikealle(); for (int i = 0; i < 100; i++) { pe.eksistoi(); } assertTrue("Hahmo pääsi matalasta seinästä läpi oikealle paahtaessaan. x = " + pe.getX(), pe.getX() < 400); ...
94c38e08-86ec-4f5f-8f2b-303c7243f0ce
1
@Override public List<Ellipse2D> getBalls() { List<Ellipse2D> myBalls = new LinkedList<Ellipse2D>(); for (Ball b : ballList) { myBalls.add(new Ellipse2D.Double(b.x - b.r, b.y - b.r, 2 * b.r, 2 * b.r)); } return myBalls; // List<Ellipse2D> myBalls = new LinkedList<Ellipse2D>(); // myBalls.add(new E...
4779e4a4-bf01-4018-8561-d0650f968981
4
final public FuncBody FuncBody() throws ParseException { ParList pl = null; Block b; FuncBody f; long i = LineInfo(); jj_consume_token(75); switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { case NAME: case 79: pl = ParList(); break; default: jj_la1[24] = jj_gen; ; } jj_consume_token(76); ...
7ab7b7b9-2adb-4527-aa85-9f187c688393
0
public Event(String n, String sT, String eT, String l, String d) { name = n; startTime = sT; endTime = eT; location = l; description = d; }
207fe285-02ad-46f2-ad18-950b389117e6
7
public void actualiza() { //Determina el tiempo que ha transcurrido desde que el Applet inicio su ejecución long tiempoTranscurrido = System.currentTimeMillis() - tiempoActual; //Guarda el tiempo actual tiempoActual += tiempoTranscurrido; //Como el gordo no tie...
82b2d7e2-3e19-4b1d-bc99-f5a25626ef0d
1
public Tetromino getGhost(Board board) { Tetromino ghost = getCopy(); while (ghost.tryMove(board, Direction.DOWN)); return ghost; }
6098cafa-31f2-4296-b3b9-e36b5e5fafe7
2
@Override public void setCourseNumber(String courseNumber) { if(courseNumber == null || courseNumber.length() == 0) { JOptionPane.showMessageDialog(null, "Error: courseNumber cannot be null of empty string"); System.exit(0); } this.courseNumber = c...
cf443c72-1d2a-4d1e-97ca-e8690699789e
9
protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out) { int remaining = in.remaining(); while (remaining-- > 0) { // make sure we have output space (the max we might need) if (out.remaining() < 4) return CoderResult.OVERFLOW; ...
a85b5f60-8fb6-4c7d-990b-c7ed18aa4a50
7
public int firstMissingPositive(int[] A) { // Start typing your Java solution below // DO NOT write main() function if (A.length == 0) {// if A is empty, that means '1' is the missing // positive return 1; } for (int i = 0; i < A.length; i++) { if (A[i] > 0 && (A[i] - 1 < A.length) && A[A[i] - 1...
7d85837e-ecd0-4917-93f9-aab0a82499ce
1
@Override public void mouseMoved(MouseEvent event) { Point where = event.getPoint(); DirectScrollPanelArea area = checkAndConvertToArea(where); if (area != DirectScrollPanelArea.NONE) { setColumnDividerHighlight(where.x); } }
3c1136f7-1377-4e17-b782-111dc4290f07
0
@Override public <T extends PersistentObject> long count(Class<T> entityClass) { long count; CriteriaBuilder qb = em.getCriteriaBuilder(); CriteriaQuery<Long> cq = qb.createQuery(Long.class); Root root = cq.from(entityClass); cq.select(qb.count(root)); count = em.crea...
f945cb82-e956-4b83-abdd-fc41bf27936f
0
@Override public YamlPermissionConsole getConsole() throws DataLoadFailedException { checkCache(PermissionType.CONSOLE, "console"); return (YamlPermissionConsole) cache.get(PermissionType.CONSOLE).get("console"); }
61d1dbb1-83a7-4b64-9b28-17545dd5f987
7
public static void generateXmlFile() throws DocumentException { Document document = generateDocument(); XMLWriter out = null; BufferedWriter bw = null; OutputStreamWriter osw = null; FileOutputStream fos = null; try { File xmlFile = ...
ad3e80f2-4a6e-4596-bb9f-e8467b44a9ae
8
@Override public void run() { this.stopped = false; Log.info("OutThread running..."); Object obj; while (!isStop()) { try { //busy wait for incomming request from client while ((obj = getMessage()) == null) { Thread.sle...
e7ab83bf-4f55-4757-9cd1-ed39f4bb89f2
8
public String[] lex(String t) throws LexingException { this.target = t.replaceAll("\\s+", ""); ArrayList<String> result = new ArrayList<String>(); int l = 0; int r = 0; boolean f; while (r < target.length()) { ++r; f = true; String temp...
895815f3-a8c4-49ed-b410-1299487786d0
1
public ChatServer(int port) { try { datagramSocket = new DatagramSocket(port); System.out.println("Server started, port [" + port + "]"); receive(); } catch (Exception e) { System.out.println(e.getClass().getName()); } }
982d2739-babe-4484-97ac-44c478d388fc
9
protected void calcNeValue() { // 牛顿插值公式运算 double t = 0; int i, j, k; double result = 0.0; double[] x = new double[Def.N]; double[] y = new double[Def.N]; try { t = Double.parseDouble(neTTextField.getText()); } catch (NumberFormatException e) { // t值输入格式错误 JOptionPane.showMessageDialog(null, E...
e835b524-6713-40d3-a991-51a3ae70f19e
5
public double winRatio(int tableSize, Card holeCard1, Card holeCard2){ if(tableSize > 10 || tableSize < 2 || holeCard1 == null || holeCard2 == null) return -1; double[][][] applicable = (holeCard1.getSuit() == holeCard2.getSuit() ? suited : unSuited); return applicable[tableSize-2][holeCard1.getValue()-2][holeCar...
1ac6e8bf-1266-4763-9175-f05973e88107
8
public static double userBasedCustomPrediction (long targetItemId, LinkedList<IdSimilarityPair> topNeighborsList, HashMap<Long, HashMap<Long, RatingDatePair>> userItemRatingMap, HashMap<Long, Double> usersAvgRating, double amplification, double presenceBoost) throws ParseException{ double prediction = 0.d; doubl...
39b10f74-e5ce-41c4-9464-543ceff0ccb2
5
@Override public Node<TypeOfState, TypeOfValue> next() { if (!this.hasNext()) throw new NoSuchElementException("No more nodes to iterate."); Node<TypeOfState, TypeOfValue> node = this._queue.pollFirst(); if (0 < node.getChildren()) { // If the node has children: for (...
eca54491-ffd5-4780-a242-c822a66f646e
9
private String getMaxLoad(int[] v, int[] w, int wMax) { // 1. Dynamical stuff // a[i][j] represents the value reached with objects chosen from {1..i} and maximum weight j int iMax = v.length + 1; int jMax = wMax + 1; int[][] a = new int[iMax][jMax]; // not required to initialize // a[i][0] = 0; // a[0...
ac30c06d-fbd0-4487-90d9-afb0ced4cbde
5
public void handle(ActionEvent event) { if(event.getSource() == create) { try { AssetType type = this.type.getSelectionModel().getSelectedItem(); Path af = mp.mod.getAssetFolder(); Path p = af.resolve(name.getText() + "." + type.getFileExtension()); p = af.relativize(p); ModToolkit.log.in...
651f2e42-4da2-4e60-94f5-860c7806463c
4
public void attackUnit(Unit attacker, Unit toBeAttacked, boolean aiMove) { if (aiMove || Teams.comparePlayers(this.getOwner(),game.getCurrentPlayer())) { HashSet<Player> tmp = Teams.getTeamFriends(Teams .getTeamOfPlayer(owner)); if (attacker.getAttacked() == true) { ...
9fb160c8-303d-4fad-9bbb-ca4e9a974ee5
7
public static String htmlEntityEncode(String s) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) { ...
ab3ee382-8818-469a-9b29-2b64f40e31d1
0
public FooObject getFriend() { return friend; }
020c8f46-692b-4f3f-be8d-f66acaafeb38
7
private void sendFileData(String file) throws IOException, FileNotFoundException { /* Why aren't resources being found when this runs on Win95? */ InputStream fis = getClass().getResourceAsStream(file); if(fis == null) throw new FileNotFoundException(file); byte[] data = new byte[fis.available()]; ...
8dbc94dd-44b8-4fcc-bf71-974ab3d63da4
9
private int updateCellCount(int current, int count) { if(count == 0) { if(current == 1) { return -1; } if(current == 2) { return 1; } } else { if(count < 0) { if(current == 1) { return count-1; } if(current == 2) { ...
52ef4c84-f0a2-4331-93ad-325fe519710e
9
private static boolean comparerTabProfils (String[] tab, String[] tabTest) { boolean pareil = true; int i = 0; try { if (tab == null && tabTest == null) { pareil = true; } else if (tab != null && tabTest != null && tabTest.length == tab.length){ while (...
946791a2-2e18-4983-93df-f03bf72d4ce5
0
private MailChimpException logException(String method, Exception e) throws MailChimpException { logger.error("Unable to {} MailChimp request", method, e); return new MailChimpException("Unable to " + method + " MailChimp request", e); }
c5c84f5f-1ab2-4647-bd65-7fb046ffa275
5
public String sendFile(File file) throws IOException { try { fis = new DataInputStream(new BufferedInputStream( new FileInputStream(file))); out = new DataOutputStream(socket.getOutputStream()); out.writeUTF(file.getName()); out.flush(); out.writeLong(file.length()); out.flush(); int buffer...
ee57d1a8-b336-43ed-a353-5566bb72fd08
7
@Test public void testColorPointSerialization() { MyColorPoint cp1 = new MyColorPoint(new MyPoint(1,2), new MyColor(1.1f, 1.2)); // Serialize System.out.println("Serializing MyColorPoint..."); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream out =...
dc938f08-4162-412e-b512-f975406fe857
1
final public void Digits() throws ParseException { /*@bgen(jjtree) Digits */ SimpleNode jjtn000 = new SimpleNode(JJTDIGITS); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); try { jj_consume_token(INTEGER_LITERAL); } finally { if (jjt...
2a7353a5-ca9b-4b52-9581-17a2a590c741
5
public static boolean save() { if (DoorList.size() == 0) { //If queue is empty OR economy is disabled. DoorFile.delete(); return true; } ColorKeys.Log(Level.INFO, "Saving doors..."); try { if (!DoorFile.exists()) { if (!DoorFile.createNewFile()) { ColorKeys.Log(Level.SEVERE, "Error creating...
5a9d0132-98a3-4e62-b9a5-801ad0e62dc5
7
private void dealWithOperator(char c) throws ExpressionException { ArithmeticParameter arithmeticSymbol = ArithmeticParameter.getArithmeticBySymbol(c); if (arithmeticSymbol == OPEN_BRACKET) operatorStack.push(OPEN_BRACKET); else { if (operatorStack.empty() || arithmeticSy...
ee24a500-2217-4060-988a-3b9a4ffee233
3
@Override public void afterPhase(PhaseEvent fase) { System.out.println("Depois da Fase"+getPhaseId()); if(fase.getPhaseId().equals(PhaseId.RENDER_RESPONSE)){ Session session = FacesContextUtil.getRequestSession(); try { session.getTransaction().commit(); } ca...