method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
c210e92f-d201-4133-a88d-29311cc4db9f
2
public ControlUnitImpl(boolean pipeliningMode, MemoryBufferRegister mbr, BusController systemBus) { this.pipeliningMode = pipeliningMode; this.systemBus = systemBus; this.mbr = mbr; mar = new MAR(); genRegisters = new RegisterFile16(); pc = new PC(); rCC = new ConditionCodeRegister(); if (!pipe...
21f125f0-737b-4f4c-80f6-e5c7da33f5ea
3
public void paintComponent(Graphics g) { if (gameStatus.get() == 0) { super.paintComponent( g ); Graphics2D g2= (Graphics2D) g; setBackground(Color.black); g2.setStroke(new BasicStroke(2)); // We need to draw our walls. g2.setPaint( Color.blue); g2.fill(new Rectangle2D.Double(90,90,10,420...
de181a9f-f430-4d14-9ea0-234eb4184c57
0
@Override public List<Employee> getAll() { return new ArrayList<Employee>(map.values()); }
30622ddf-51de-47c5-87f6-94f3bd486c23
3
public boolean inRange(Position position){ return position.getX() >= 0 && position.getY() >= 0 && position.getX() < 8 && position.getY() < 8; }
0af9f377-cbe7-48bd-b9fb-a514f5dcb6f1
0
public double getPrecio() { return precio; }
f7eb135d-732d-42e5-9544-ed27aa47bfaf
8
@Override public BMPImage apply(BMPImage image) { BMPImage filteredImage = new BMPImage(image); // double[][] core = {{1, 9, 3, 11}, // {13, 5, 15, 7}, // {4, 12, 2, 10}, // {16, 8, 14, 6}}; double[][] core = { ...
e8254a9b-b53b-48ad-9366-7ba848af3379
5
private LinkedList<Direction> getPath(){ LinkedList<Direction> result = new LinkedList<Direction>(); ArrayList<Node> openlist = new ArrayList<Node>(); ArrayList<Node> closedlist = new ArrayList<Node>(); Node firstNode = new Node(null, start.x, start.y); openlist.add(firstNode); while(!openlist.isEm...
703e0d44-b98d-4c67-a189-d9bff4b51d9c
5
private Boolean checkState() { int t=0; String msg=""; Boolean stateOk=false; try { com.serialPort.writeByte((byte)SPACE_KEY); while( t < 100 ) { t++; Thread.sleep(5); if( com.serialPort.getInputBufferBytesCount() > 0 ) { msg += com.serialPort.readString(); if( msg.endsWith...
8252f001-d563-415f-8587-2051794a070a
2
protected boolean printThisLevel(int[] levels) { for (int currentLevel : levels) { if (level == currentLevel) { return true; } } return false; }
5c5ac138-5aac-43bb-9dfb-01b0328bc874
1
public LinkedList<Order> getOwnOrders() throws SQLException { LinkedList<String> select = new LinkedList<String>(); select.add("OrderID"); select.add("Date"); select.add("Amount"); select.add("Username"); select.add("ISBN"); LinkedList<String> from = new LinkedLis...
26e23568-67fe-458c-a9fa-11288db26903
0
public byte getTypeByte() { return (byte)this.id; }
53ef88e6-47fc-4b98-b47f-10ad0cb13d27
7
public void run() { // connect to server try { connect(this.getUsername(), this.getPassword(), this.host, Integer.parseInt(this.port)); logger.info(fetchResponse()); if (isConnected()) { for (String cmd : getCommandList()) { if (cmd.trim().equalsIgnoreCase("")) { continue; } logge...
3ea5af5e-2b5b-4de9-ab96-5bb5d4108589
9
private double computeOverlap() { for (int c = 0; c < numFClusters; c++) { if (!(clustering.get(c) instanceof SphereCluster)) { System.out.println("Compactness only supports Sphere Cluster. Found: " + clustering.get(c).getClass()); return Double.NaN; } ...
91d9cc6d-53d0-41c6-bd07-4d385719d20d
4
@Override public String getSheetTypeString() { switch( grbit ) { case SHEET_DIALOG: return "Sheet or Dialog"; case XL4_MACRO: return "XL4 Macro"; case CHART: return "Chart"; case VBMODULE: return "VB Module"; default: return null; } }
9231e363-454d-4e94-bc1d-5dbf3fd4c504
1
private void setDoubleValue(final Cursor cursor, final int index, final Field field, final Object object) { final Double value = (!cursor.isNull(index) ? cursor.getDouble(index) : null); Reflection.setFieldValue(field.getName(), object, value); }
7507a66d-b1e2-4083-ad2a-84cc5f6c10d7
1
private boolean jj_2_39(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_39(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(38, xla); } }
05fb349c-925d-4a9f-9a83-846262b6d791
2
public Transition transitionCollapse(State from, State to) { if (currentStep != CONVERT_TRANSITIONS) { outOfOrder(); return null; } Transition[] ts = automaton.getTransitionsFromStateToState(from, to); if (ts.length <= 1) { JOptionPane.showMessageDialog(frame, "Collapse requires 2 or more transiti...
f57f8ddf-127d-4cef-a9bc-862371f040af
8
public TrackingDialog(final Panel panel) { this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.panel = panel; setTitle("Video Tracking"); setBounds(1, 1, 300, 250); Dimension size = getToolkit().getScreenSize(); setLocation(size.width / 3 - getWidth() / 3 + panel.getWidth(), size.height / 3 - getHeigh...
58928ad3-ef9c-41a7-80b8-92649930b0a7
5
@Override public double nextDouble() throws IOException { JsonToken token = peek(); if (token != JsonToken.NUMBER && token != JsonToken.STRING) { throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + token); } double result = ((JsonPrimitive) peekStack()).getAsDouble(); ...
f66986ea-82c0-4bab-af99-860a37ebbccc
4
public void syncPlayerInfo(ArrayList<Player> players) { int i; for (i = 0; i < players.size() && i < Game.MAX_PLAYERS; i++) { checkCircles[i].check(); nameFields[i].setText(players.get(i).getName()); typeFields[i].setText(players.get(i).getType().name()); ...
6aaa047f-ca4f-4057-9b50-d6907759a9de
5
public Symbol lookup(String name) throws SymbolNotFoundError { //Check local table for(Symbol s : symTable){ if(s.name().equals(name)){ return s; } } SymbolTable symTablePtr = this.parent; while(symTablePtr != null){ for(Symbol s : symTablePtr.symTable){ ...
1110e97e-81f6-408d-a193-d802543eb53c
5
public void validaCamposTelefone(String grupo, String telefone, String contato) { if (grupo.isEmpty()) { JOptionPane.showMessageDialog(null, "Grupo Inválido!"); cbx_grupo.requestFocus(); } else { if (telefone.equals("( ) - ") == true) { JOption...
7a62e914-89d6-457d-9a6e-87330fbe655f
5
private ArrayList<Position> findPlayerEndPos() { Search.Result result; ArrayList<Position> positions = new ArrayList<Position>(); for(Position box : this.boxes){ result = Search.bfs(this, new IsAtPosition(box.x+1,box.y), this.player.x, this.player.y); if(result != nul...
0cc412b9-0b20-4ca3-9317-c287a53ae2cf
3
private void getLogcat(final Device device) { new Thread() { @Override public void run() { try { final File ADB = adbController.getADB(); ProcessBuilder process = new ProcessBuilder(); List<String> args = new Arr...
c75b849c-c9a2-465a-aba2-27e276a047e3
7
public int minDistance(String word1, String word2) { if(word1.length() ==0) return word2.length(); if(word2.length() ==0) return word1.length(); int[][] res = new int[word1.length()+1][word2.length()+1]; res[0][0] = 0; for(int i=1; i<=word1.length(); i++) res[i][0] = i; ...
196d184a-3109-45c8-9505-e5c41a28dc0d
6
public static boolean isInsidePolygon(Vector2D[] verts, double x0, double y0){ boolean oddNodes = false; for (int i = 0, j = verts.length - 1; i < verts.length; j = i, i++) { Vector2D vi = verts[i]; Vector2D vj = verts[j]; if ((vi.y < y0 && vj.y >= y0 || vj.y < y0 && vi.y >= y0) && (vi.x + (y0 -...
76bfe507-888b-41b4-aabd-4bab5fa3fb97
8
public void saveConsumable() { BufferedReader reader; try { reader = new BufferedReader(new FileReader(System.getProperty("resources") + "/database/consumables")); String line; int pos = 0; StringBuilder fileContent = new StringBuilder(); String newLine = null; while((line = reader.readLine()) !=...
e5750350-8e0c-4b4a-9195-2824365329db
1
public int hashCode() { return (name != null ? name.hashCode() : 0); }
8025bba3-f84c-485c-855d-3edf8a0bd587
5
public void run() { MyMouseListener mouseListener = new MyMouseListener(getInstance()); addMouseListener(mouseListener); addMouseMotionListener(mouseListener); addMouseWheelListener(mouseListener); addKeyListener(new MyKeyListener()); displayProgress("Loading...", 0); startUp(); try { do { long s...
8d42b46a-760b-4511-bb88-0390430657a0
3
private void printGrammar(List list, Grammar gram, String title){ list.clear(); list.add(title); list.add("Axiom:"); list.add(gram.GetBeginNonTerminal()); list.add("Terminals:"); for(String s : gram.GetTerminals()){ list.add(s); } list.add("Non...
b0c89e4f-c9ef-4442-ad26-f387934d3c2c
8
@Override public void keyReleased(KeyEvent e) { int keyCode = e.getKeyCode(); switch (keyCode) { case KeyEvent.VK_UP: U = false; break; case KeyEvent.VK_W: U = false; break; case KeyEvent.VK_DOWN: D = false; break; case KeyEvent.VK_S: D = false; break; case KeyEvent.VK_LEFT: L ...
5e748f9b-5844-4d7b-b42a-9884598ca481
2
public static void main(String[] args) { String[] filenames = args.length > 0 ? args : DE406_FILES; String strStep = System.getProperty("step", "10.0"); double dt = Double.parseDouble(strStep); for (int i = 0; i < filenames.length; i++) processFile(filenames[i], dt); System.exit(0); }
a437ae87-d002-4687-bfac-37bad82e04f8
1
boolean tryWhitespace() throws java.lang.Exception { char c; c = readCh(); if (isWhitespace(c)) { skipWhitespace(); return true; } else { unread(c); return false; } }
45d0494b-b12c-42eb-b081-05a601254b38
8
final private boolean jj_3R_28() { Token xsp; xsp = jj_scanpos; if (jj_3R_48()) { jj_scanpos = xsp; if (jj_3R_49()) { jj_scanpos = xsp; if (jj_3R_50()) { jj_scanpos = xsp; if (jj_3R_51()) { jj_scanpos = xsp; if (jj_3_28()) { jj_scanpos = xsp; if (jj_3R_52()) { jj_...
6ef430d4-26d6-4bb0-b3c0-8cba565ed66d
0
public TargetPIDTurn(Target target, double timeout, boolean continuous){ super(target,Target.Axis.X,timeout,continuous, 0.5, 0.1, 1, // P, I, D 4,0.7, // tolerance, maxOutput (higher because of carpet) 1.0/20); // period requires(Robot.driveTrain); ...
3b84942a-b8d4-496b-b2ea-b56537cbbc10
0
private void createLeftSidePanelForUserSettings() { btnNewUser = new JButton("Dodaj użytkownika"); btnNewUser.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { userDataRegister.setVisible(true); } }); btnNewUser.setBounds(6, 112, 207, 28); leftSidePanel.add(btnN...
f5dffa93-a567-4fb9-a9d5-bb7e8244ddc5
4
public void center(int centerVs) { Dimension otherSize = null; Dimension dialogSize = null; Point otherLocation = null; if ((centerVs != VS_PARENT) && (centerVs != VS_SCREEN)) { return; } // Center the dialog as directed. switch (centerVs) { ...
a38bdd4f-77dd-43f9-82f8-7f8d54a8862b
8
public ArrayList<Move> whiteSafeMoves(ArrayList<Move> allWhiteMoves) { ArrayList<Move> rez = new ArrayList<Move>(); for (Move currMove : allWhiteMoves) { int movedPiece = Utils.getMovedPieceFromMoveNumber(currMove.moveNumber); int to = Utils.getTargetPositionFromMoveNumber(currM...
be6c42f0-a123-439b-90d4-9bf8bd74999c
5
public byte[] encode() { int seqLength = 0; EncodeStream stream = new EncodeStream(256); // // The transaction splits are encoded as an optional context-specific // field with identifier 2 // if (splits != null && !splits.isEmpty()) { int splitsLeng...
12e9705f-ca32-4f19-aa28-0eedae17f7e0
5
public static void main(String[] args) throws IOException { // TODO Auto-generated method stub //需要处理的文件路径 //String originalDocsPath = PathConfig.ldaDocsPath; String originalDocsPath = PathConfig.dblpPath; //结果保存路径 String resultPath = PathConfig.LdaResultsPath; //LDA参数文件路径 String parameterFile= Constant...
dea4bd69-b07a-4968-ae27-927d56e8bd42
8
public void setInformation(Tile[][] t, int length){ arrLength = length; float rSize = (float) (SIZE / arrLength); // This block of code will create a new Line and Color pair to correspond with each tile on the map // This pair will then be rendered to represent the minimap. for (int i = 0; i < arrLength; i...
6c8b7cdc-4d0e-4800-a14c-e40e41f13691
0
public void disable() { disabled = true; }
4c6e2612-fa7b-4282-8ef6-20d00f99176d
9
public void getAlternateLabel(StringBuffer s) throws Exception { //StringBuffer s = new StringBuffer(); FastVector tmp = (FastVector)m_ranges.elementAt(0); if (m_classObject != null && m_training.classAttribute().isNominal()) { s.append("Classified by " + m_classObject.getClass()...
5c0b3913-660a-4a89-98c6-32d2345b2357
7
private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: if (accion.equals("Insertar")) { if (lblNombre.getText().equals("") || lblNombre.getText().equals("Código Incorrecto")) { J...
9d3d4190-7a48-45e9-aa75-94d5cb589728
7
public String validar(String usr, String cont){ try{ ConexionBD con = new ConexionBD(); Connection conex = con.conectar(); Statement stmt = conex.createStatement(); ResultSet rs = stmt.executeQuery("select * from profesor where nUsuario='"+usr+"';"); i...
303b511e-59a3-41e6-ab2a-50ab76a40c8a
3
public void actionPerformed(ActionEvent e) { if (e.getSource() == evalButton) { evaluateRegex(); } else if (e.getSource() == nextMatchButton) { jumpToNextMatch(); } else if (e.getSource() == prevMatchButton) { jumpToPrevMatch(); } }
18bb14d8-3d9c-438b-812d-4dd9aad4c4eb
1
public static HttpServletRequest listAPatientBills(HttpServletRequest request) { Models.DatabaseModel.Patient patient = new Models.DatabaseModel.Patient(); int patientID = Integer.parseInt(request.getParameter("patientID")); patient = patient.findPatient(patientID); ArrayList<Models.D...
a18d6a50-a205-4a80-aea6-06b8d11429f2
5
@Override public int hashCode() { int result = item != null ? item.hashCode() : 0; result = 31 * result + (item2 != null ? item2.hashCode() : 0); result = 31 * result + (item3 != null ? item3.hashCode() : 0); result = 31 * result + (item4 != null ? item4.hashCode() : 0); resu...
1ad0e427-645a-46be-84a8-0a758089080b
7
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; HeuristicNode other = (HeuristicNode) obj; if (fscore != other.fscore) return false; if (node == null) { if (other.node != null) retu...
f8bb0f68-b90d-4e6d-9e40-512da8765e60
7
public final String getArtistBiography(String url) throws ArtistBiographyException { if(url.contains("en.wikipedia") == false) throw new ArtistBiographyException("The expected url is not the english version of wikipedia web site"); //gets all info from wikipedia website String bio= "[From en.wikipedi...
f2d2fecb-19a0-41fa-ac7d-45f1c75f6086
9
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PrivateMessage that = (PrivateMessage) o; if (recieverAccountId != that.recieverAccountId) return false; if (senderAccountId != that.senderAcco...
6c300d40-2e0a-42d7-8f7c-be9bff8013ba
8
public MOB getAccountMob(String s) { MOB M=CMLib.players().getPlayer(s); if(M!=null) return M; if(CMLib.players().playerExists(s)) return CMLib.players().getLoadPlayer(s); if(CMLib.players().accountExists(s)) { final PlayerAccount A=CMLib.players().getLoadAccount(s); if(A.numPlayers()==0) M=A...
89b0fd3f-c102-4dda-ac45-72f15ceeafd5
2
private List<Produto> carregaDadosDoBanco(){ this.dao = new ProdutoDAO(); List<Produto> listaDeProdutos = null; try { listaDeProdutos = dao.listarTodos(); } catch (ErroValidacaoException ex) { //Logger.getLogger(frmListarProduto.class.getName()).log(Level.SEVERE, ...
a7eb4042-865b-44ae-b5f2-fcaa2e295300
1
private void setProgress( int proVal, String proStr ) { final int tmpVal = proVal; final String tmpStr = proStr; try { SwingUtilities.invokeAndWait( new Runnable() { public void run( ) { mainFrame.setProgress(tmpVal, tmpStr); } }); } catch( Exception exc ) { FastICAApp.exceptionDi...
69f6f688-49c4-490a-8b4d-f32dd4b4afdf
8
@Override public void decodeTerm(long[] longs, DataInput in, FieldInfo fieldInfo, BlockTermState _termState, boolean absolute) throws IOException { final IntBlockTermState termState = (IntBlockTermState) _termState; final boolean fieldHasPositions = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_...
3223cf6f-39cf-439e-8842-d56c6cd4bf6c
0
public static void setNumOS(String numOS) { OS.numOS = numOS; }
fc50e22b-0b5c-40f1-a3e0-733547ff5442
4
public static void main(String[] args) { if ((args.length > 1) || (args.length > 0 && args[0].equals("-h"))) { System.out.println(USAGE); System.exit(1); } String bankName; if (args.length > 0) { bankName = args[0]; new Client(bankName).ru...
d47ad236-98c1-4c63-b0af-75df854d71f1
2
private static void thirdStrategy() { Semaphore MReading = new Semaphore(1); Semaphore MWriting = new Semaphore(1); Semaphore MPrio = new Semaphore(1); Random r = new Random(); while(true) { if(r.nextDouble() > 0.5) new Lecteur2(MReading,MWriting,MPrio).run(); else new Redacteur2(MWriting...
847ad991-4087-478a-9346-8f78f1213033
8
public static boolean isLongitude(String name, String dataType) { if ((dataType == null || dataType.equalsIgnoreCase("lat-lng") || dataType.startsWith("float") || dataType.startsWith("double")) && (name.toLowerCase().equals("lng") || name.toLowerCase().equals("longitude") || name.toLowerCase().equals("lon") || na...
9466981c-7699-4717-8527-93982eb60dbd
8
public List<Long> getPathListAsEdges(List<Long> pathV) { List<Long> pathE = new ArrayList<>(pathV.size()); for (int i = 0; i < pathV.size() - 1; i++) { for (Long eid : graph.getEdges()) { long currVertice = pathV.get(i); long nextVertice = pathV.get(i + 1); // case forward // in this if/elseif ...
b27178f5-4951-48c0-afba-693a9d650bb4
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
bc62c165-1dbe-4180-9368-64965ec10c3e
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
02b35603-f39f-48c3-8659-7d45dfa25919
1
public void render(Renderer renderer) { renderer.setColor(1, 0, 0); if (this.isQuad()) { renderer.drawQuad(a, b, c, d); } else { renderer.drawTriangle(a, b, c); } }
0eb1b921-05af-47fb-9f13-cce97d91cbef
2
public Node insert(Node node, int value) { if(node==null) return new Node(value); else { if(node.left==null) // Check is req to avoid duplicate insertion { System.out.println("Lnull-"+node.value); node.left = insert(node.left,value); } else { System.out.p...
9a63f73c-4ebe-4d37-8d37-4b2dbe76d266
4
public synchronized PacketReceipt getSentPacketWithSequenceNumber(int sequenceNumber) { //ignore N/A sequence numbers if(sequenceNumber == Packet.SEQUENCE_NUMBER_NOT_APPLICABLE) return null; //if the sequence number is for a packet in the future then we haven't sent it yet int delta = Packet.deltaBetweenSeq...
cb3d07b6-9204-4f43-a7ef-aabd57f23c6f
9
public void start(String[] spielerName){ for (int i = 0; i < 4; i++) { if(spielerName[i] != null){ anzSpieler = anzSpieler + 1; } } brauerei = new Brauerei[anzSpieler]; spieler = new Spieler[anzSpieler]; int[] posX = {5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 10, 15 }; int[] posY = {5, ...
cacd3793-2dfe-4961-9fa7-acbb8b4249cd
5
private int checkNumber(int i) { int sum = 0; for (Integer prim : primBrojevi) { if (i == prim) { return 1; } else { if (i % prim == 0) { sum++; } } } if (sum == 1) { return 4; } else if (sum % 2 == 0) { return 2; } return 3; }
e9be11f1-f011-4296-89a6-9b239b857b62
9
protected void performChoice(int choice) { if (choice == 1) { decoding = new ViterbiDecoding(hmm); } else if (choice == 2) { decoding = new PosteriorDecoding(hmm); } else if (choice == 3) { if (decoding != null){ DecodingReporter reporter = null; try { reporter = new DecodingReporter("")...
7f5d7a10-c7ff-4faf-88c6-5d396245444c
6
@Override public void run() { if(this.isValid()){ while(blnRepeat){ try { Object readObject = inStream.readObject(); if(readObject instanceof IMessage){ IMessage msg = (IMessage)readObject; sw...
f30d8725-d52a-4066-9b57-042b40cb1406
8
public void clean(String jobID) { /* // cheating, just remove the domain, TODO: change to per jobID in the future DeleteDomainRequest request = new DeleteDomainRequest(); request.setDomainName(dbManagerDomain); try { DeleteDomainResponse response = service.deleteDomain(request); ...
edfc7c77-d51b-4fbf-a16f-89447e38acd3
2
@Override public double escapeTime(Complex point, Complex seed) { // Keep iterating until either n is reached or divergence is found int i = 0; while (point.modulusSquared() < escapeSquared && i < iterations) { // Z(i+1) = complement(Z(i) * Z(i)) + c point = point.com...
23953abb-d06a-426b-8cff-780232cbaed3
1
private RandomListNode copyNext (RandomListNode head) { RandomListNode headNew = new RandomListNode(head.label); RandomListNode node1 = head.next; RandomListNode node2 = headNew; map.put(head, headNew); RandomListNode node = null; while(node1 != null){ node ...
c464bd36-295d-46fb-b764-3cb7ae9c5d6e
6
private void setcamera(String camtype) { curcam = camtype; Utils.setpref("defcam", curcam); String[] args = camargs.get(curcam); if (args == null) args = new String[0]; MapView mv = ui.mapview; if (mv != null) { if (curcam.equals("clicktgt")) mv.cam = new Map...
7b33c1f7-d6ff-42ee-bb1a-9582cb14101b
5
private int jjMoveStringLiteralDfa30_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 29); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return jjMoveNfa_0(0, 29); } switch(curChar) { case 54: return jjMoveStringLiter...
c84c0fc3-b13f-43ed-a1e9-035336a32bc7
6
@EventHandler public void EndermanNausea(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getEndermanConfig().getDouble("Enderman.Na...
6d92ec3a-2531-41bc-9215-8cade51b147c
4
private void initiateCandidateSolutions() { int columns = objectiveFunction.getVariables(); position = new double[numberOfParticles][columns]; double random = upperLimit - lowerLimit; for(int i = 0; i < numberOfParticles; i++){ for(int k = 0; k < objectiveFunction.getVariables(); k++){ double d = lowerLi...
91740aa2-22a5-4bf1-aa93-5a688a3f5766
2
public double calc() { if (calcMethod == null ) { throw new RuntimeException("CalcMethod not yet maintained"); } if (position == null ) { throw new RuntimeException(" Position not yet maintained"); } return calcMethod.calc(position); }
d9338c23-2bba-4f50-a8aa-ea81e69b97fe
8
public boolean resultCheck(final ResultDataBean databean) { boolean checkflag; // どれか一つでもnullがあったらエラー if (databean.getOrderId() == null || databean.getOrderId().equals("null")) { checkflag = false; } else if (databean.getmStatus() == null || databean.getmStatus().equals("nul...
85678e37-18c6-4a17-81d8-9aac90e0ca23
2
@SuppressWarnings("unchecked") public static TreeMap<String, float[][]> restoreTM2D(String findFromFile) { TreeMap<String, float[][]> dataSet = null; try { FileInputStream filein = new FileInputStream(findFromFile); ObjectInputStream objin = new ObjectInputStream(filein); try { dataSet = (TreeMap<Stri...
a2772622-6e53-4cc2-8880-804bea66b369
1
public void scale(int x, int y, int z) { for (int i = 0; i < vertexCount; i++) { xVertex[i] = xVertex[i] * x / 128; yVertex[i] = yVertex[i] * z / 128; zVertex[i] = zVertex[i] * y / 128; } }
2c1fd654-6d77-4553-b912-c9782691264a
4
public static void findContinuesNumber(int sum){ if(sum < 3){ return ; } int begin = 1; int end = 2; int middle = (1 + sum)/2; int curSum = begin + end; while(begin < middle){ if(curSum == sum){ printContinuesNumber(begin,end); break; } else if(curSum > sum){ curSum -= begin; ...
9ae6900c-980e-4728-8260-789b216cf4da
7
@Override public String list(){ String toRet = ""; List<String> mods = new ArrayList<>(this.getModifiers()); Collections.sort(mods); for(String mod : mods){ toRet += mod + " "; } toRet += this.getPackage() + "." + this.getName() + "\n" + "Fields: "; if(fields.size() == 0){ toRet += "(none)"; } ...
7a27ad45-6a97-4597-b5dc-b63fc6cf9415
0
public String goToUserProductDetails() { this.product = this.userFacade.getProductById(this.id); return "userProductDetails"; }
35083704-1802-45a2-8cf3-f81d5cbda06e
3
private int insert(Funcionario f) { Connection con = null; PreparedStatement pstm = null; int retorno = -1; try { con = ConnectionFactory.getConnection(); pstm = con.prepareStatement(INSERT, Statement.RETURN_GENERATED_KEYS); pstm.setString(1, f.getNo...
09c42bac-184c-481c-beac-91d1cdbb1ba4
9
public Document transformSee() throws XPathExpressionException { transformDocument = realDocument; NodeList nodes = Parser.nodesByXPath(transformDocument, "//@*[starts-with(., '@')]"); for(int i =0; i < nodes.getLength(); i++) { Node nodeValue = nodes.item(i); String newStringNodeValue = ""; for(Stri...
9a0b37a5-7f45-465c-b80c-004d7ee0351e
9
public static void main(String[] args) { StdDraw.text(.5, .5, "Click this window and type m, k, o, comma, l or p"); // big font for displaying the currently pressed key StdDraw.setFont(new Font("SansSerif", Font.BOLD, 120)); Guitar guitar = new Guitar(); // keys to pluck a string char[] pluckKeys = { 'm', '...
87c52ee6-70ed-4e19-b8f3-10f4e68efd42
1
public String getInternalName(){ //just for trying to preserve old way of saving. //ASSUME that ID's are Independent return myInternalName == null? myInternalName = "Machine"+ getID() : myInternalName; //create an internal name if one has not been assigned explicitly }
fca7750d-0d6b-4ba5-906c-b8d7d334deef
4
public boolean intersects(Rectangle other) { if ((x > (other.x + other.width)) || ((x + width) < other.x)) { return false; } if ((y > (other.y + other.height)) || ((y + height) < other.y)) { return false; } return true; }
f1cc41f3-c32d-447a-a386-610d5be48088
2
public void merge(CountingBloomFilter cbf) { assert cbf != null; assert filter_.length == cbf.filter_.length; assert hashCount == cbf.hashCount; for ( int i = 0; i < buckets(); ++i ) { Bucket b = new Bucket(i); Bucket b2 = cbf.getBucket(i); ...
5a36d3cb-4db9-40f3-bcd0-9da43ebbc585
7
public void write(byte[] input) throws IOException { synchronized (chunks) { if (currentChunk == null) { currentChunk = new Chunk(); chunks.add(currentChunk); lastChunk = currentChunk; } int toWrite = input.length; int posArray = 0; while (true) { if (positionWithinChunk + toWri...
9e81ab0f-b9e9-4f1e-9161-5a1849b4dfbc
3
public void setTickTime(int ups) { if (this.tickTimer != null && this.tickTimer.isRunning()) this.tickTimer.stop(); this.tickTimer = new Timer(1000 / ups, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (isRunning) onTick(1); } }); this.tickTimer.start(); }
b6204d28-ebac-4d5a-83e7-2dfde041fed2
7
public final void assignment() throws RecognitionException { ParserRuleReturnScope labelfield2 =null; ParserRuleReturnScope value3 =null; try { // C:\\Users\\Shreeprabha\\Documents\\GitHub\\CecilRPi\\src\\org\\raspberrypi\\cecil\\model\\grammar\\Cecil.g:164:3: ( ( '.' labelfield )? 'insert' value ) // C:\\...
ca6bb792-ddf0-455a-be84-8a3a44cd28d5
3
public void actionPerformed (ActionEvent ae) { if (ae.getActionCommand().equals("Envoyer")) { // On envoi un message s'il n'est pas vide if (bcast_chat.getText().length() > 0) { String my_contact = Cast.getAddress() + ";" + program.getNickname(); Message message = new Message(my_contact, null, 10,...
f1c41ce0-e294-4918-b3b7-30487011b2e4
2
public ResultSet select(String column[]){ try { stmt = conn.createStatement(); String query = "select "; for(int i=0;i<column.length;i++){ query += column[i] + ", "; } query = query.substring(0, query.length()-3); ...
0e07a44f-81ef-483e-a7a9-98ef34d8cba8
5
int getMaxNumberOfSameWords(){ int result = 0; int currNumber; Sentence sentence = new Sentence(this); //copy of current sentence while(sentence.numberOfSentenceElements() > 0){ currNumber = 1; SentenceElement firstElement = sentence.getSentenceElement(0); ...
feb86d25-4a49-4610-a74e-b2378ab780f2
5
@Override public boolean equals(Object obj) { if (obj instanceof String) { return this.str.equals(obj); } else if (obj instanceof Token) { Token tkn = (Token)obj; if (!this.str.equals(tkn.str)) { return false; } if (this.line != tkn.line) { return false; } if (...
29f6dafa-a645-40f8-b3f1-858e48233ce8
4
private void Clean_List() { for (int i = 0; i < positions.size(); i++) { for (int j = 1; j < positions.size(); j++) { if (i != j && positions.get(i).getPos().Equals(positions.get(j).getPos())) positions.remove(j--); } } }
b98e8b7b-a2d5-40c2-876c-669c3928f316
6
public static void splitUpMetaInfo(LinkInfo li) { li.getMetaData().put("power",li.getPower()); li.getMetaData().put("time", li.getTimestamp()); li.getMetaData().put("source", li.getSourceNode()); li.getMetaData().put("destination", li.getDestinationNode()); if(li.getMetaDat...
7fbed19f-8bbf-4865-bafa-811e5695e140
8
@Override public String howMuch(String item, String client, String market) { logger.info("Calculating how much is the delivery. " + "item " + item + ", client " + client + ", market " + market); // business rule: delivery date depends of the market last letter // business rule: delivery date depends of t...
9c7dde37-340f-45ef-bc52-cfbeec37ba32
8
private List<NodeTuple> mergeNode(MappingNode node, boolean isPreffered, Map<Object, Integer> key2index, List<NodeTuple> values) { List<NodeTuple> nodeValue = node.getValue(); for (Iterator<NodeTuple> iter = nodeValue.iterator(); iter.hasNext();) { final NodeTuple nodeTuple = ite...