method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
5ceb1006-f543-4166-8e7f-5e453fdabcaa
2
public void testForFields_time_Mm() { DateTimeFieldType[] fields = new DateTimeFieldType[] { DateTimeFieldType.minuteOfHour(), DateTimeFieldType.millisOfSecond(), }; int[] values = new int[] {20, 40}; List types = new ArrayList(Arrays.asList(fields)); ...
7447946f-0a7b-4d4d-8271-7ee65acf968d
2
public boolean isAllLinkVisited() { for (Link<T> link : links) { if (! link.visited) return false; } return true; }
c8ab036a-cff0-4e58-974a-3ed766ce4573
4
@Override public boolean containsFloat(String name) { JOSObject<? , ?> raw = this.getObject(name); if(raw == null) return false; if(raw.getName().equalsIgnoreCase(FLOAT_NAME)) return true; return false; }
38b66ef9-7def-4449-b01f-ea95b21ee7cf
1
public double getTotalCostOfBasket() { double cost = 0; ProductInBasket[] products = getAllProductsInBasket(); for (ProductInBasket product : products) { cost += product.getQuantity() * product.getProduct().getPrice(); } return cost; }
14769470-bff6-4bc1-95de-e1c173746b3f
7
private void txtcedulaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtcedulaKeyTyped char caracter = evt.getKeyChar();//Validacion del campo cedula if (caracter >= '0' && caracter <= '9' || caracter == 8 || caracter == KeyEvent.VK_BACK_SPACE || caracter == KeyEvent.VK_CAPS_LOCK || caracter ...
0495d9ea-3b2d-4f85-a874-8a60ccffbbc7
7
public void recurDivIndex(int sX, int sY, int width) { int orig = width; DiamondSquare dS = new DiamondSquare(terrain); while (width > 4) { //Invert axis? for (int r = sX; r < sX + orig; r += width) { for (int c = sY; c < sY + orig; c += width) { double divIndex = divIndex(r, c, width); ...
d12ac3cc-ff16-4d84-b31a-b07ece24b12a
3
@Override public int hashCode() { int hash = 0; hash += (iTitemitserie != null ? iTitemitserie.hashCode() : 0); hash += (iTitemitmarca != null ? iTitemitmarca.hashCode() : 0); hash += (empleadoempNoEmpleado != null ? empleadoempNoEmpleado.hashCode() : 0); return hash; }
8ab142b5-1cb1-4664-bdb2-9b7c6fff343d
5
@Override public List<Edital> Buscar(Edital obj) { String sql = "select a from Edital a"; String filtros = ""; if(obj != null){ if(obj.getId() != null){ filtros += "a.id = " + obj.getId(); } // if(obj.getNumero() != null){ ...
1e746cdd-b0e5-4409-ad4c-ba67407d865e
2
public static boolean testRand(int a, int b){ // Return a<b with randomness if a==b if (a==b){ if(Math.random()<0.5) // randomly choose another difference ++ a; else -- a; } return a<b; }
c417bf35-f4ea-4f4d-abb1-c8ead073e777
3
private List<Vertex> getNeighbors(Vertex node) { List<Vertex> neighbors = new ArrayList<Vertex>(); for (Edge edge : edges) { if (edge.getSource().equals(node) && !isSettled(edge.getDestination())) { neighbors.add(edge.getDestination()); } } return neighbors; }
6a4ecad4-bdf1-4e42-ae21-ef40e1ad0d6a
7
private boolean check(Graph G) { // graph is bipartite if (isBipartite) { for (int v = 0; v < G.V(); v++) { for (int w : G.adj(v)) { if (color[v] == color[w]) { System.err.printf("edge %d-%d with %d and %d in same side of bipartitio...
df8d9d1f-af14-4cab-b1c9-b67dcdba429c
5
public void run(Args args) throws IOException { if (args == null) { throw new InvalidParameterException("args is null!"); } if (StringUtils.isBlank(args.getConfigFileName())) { throw new InvalidParameterException("config file was not found!"); } if("create...
b6bc62ba-7333-4cfc-84a8-2f0375cbf102
8
public void testingPartialSeqScenario3(){ System.out.println("======================="); System.out.println("ONE SEQUENCE LEARNT"); System.out.println("======================="); System.out.println("Seq_ptr="+this.seq_ptr); int numTrials = seqStartIndexes.size()-1; int sumSuccess = 0;...
d42fb0ff-546c-472f-9d7b-3c0089916f8c
2
public void loadDataFromBackup() throws IOException { log(loggers, "starting loading data from backup: "); DataContainer allData = BackupExecutor.readTableDescriptions(); for (TableDescription tableDescription : allData.getTableDescriptions()) { try { createTable(ta...
c29db8a2-f042-40ed-bd5e-4e20e7885369
6
private static void assertFiles(final File expected, final File actual) { String actualLine, expectedLine; BufferedReader expectedR = null, actualR = null; try { expectedR = new BufferedReader(new FileReader(expected)); actualR = new BufferedReader(new FileRea...
038e6805-2fb7-4522-bee1-2e93d42b2ebd
2
private boolean hasCashOfficeWithSameNumber(CashOffice searchedCashOffice) { for (CashOffice cashOffice : cashOffices) { if (searchedCashOffice.getNumber() == cashOffice.getNumber()) return true; } return false; }
42605536-3c01-4ab3-b3de-51190ed40f61
1
private static String urlEncodeUTF8(String value) { try { return URLEncoder.encode(value, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new UnsupportedOperationException(e); } }
4116241b-6ef6-4b2f-932b-75fd495e7fca
3
public boolean placeInRange(int x, int y) { return x >= 0 && x < 8 && y >= 0 && y < 8; }
43751872-38b6-4dac-b4f1-378aa4afc8ff
4
private int[] merge(int[] one, int[] two) { int[] result = new int[one.length + two.length]; int i = 0; int j = 0; for (int k = 0; k < result.length; k++) { if (i == one.length) { result[k] = two[j++]; } else if (j == two.length) { result[k] = one[i++]; } else if (one[i] < two[j]) { result[...
665482ed-e94c-43ad-a1b7-4df45d1f3946
9
static private boolean jj_3R_25() { Token xsp; xsp = jj_scanpos; if (jj_3R_26()) { jj_scanpos = xsp; if (jj_3R_27()) { jj_scanpos = xsp; if (jj_3R_28()) { jj_scanpos = xsp; if (jj_3R_29()) { jj_scanpos = xsp; if (jj_3R_30()) { jj_scanpos = xsp; if (jj_3R_31()) { j...
92ca64db-5434-4888-9da1-1304f66e85a2
1
private final static byte[] getBytes(String string, String charsetName) { try { return string.getBytes(charsetName); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return null; } }
a2a21bcb-e3ca-4e36-8372-d7fc7685e5b4
5
public void draw(GOut g) { if (!Config.showMyAvatar) this.c.x = newx; else this.c.x = oldx; int x = 0; for (int i = 0; i < 4; i++) { Tex t; if (i == pspd) { g.chcolor(pspdc); } else { g.chcolor();...
0e25c617-ba0a-4a19-b770-f3026db0e0e2
3
public void drawAt(Screen screen, int x, int y) { if (currentSpell == null) { return; } Bitmap theButton = clicked ? Art.guiCastBtndn : Art.guiCastBtnup; int adjust = clicked ? 1 : 0; screen.blit(theButton, x, y, this); TextRenderer.drawString(currentSpell.name, screen, x+2+adjust, y+2+adjust, this); ...
e971e2f1-b59e-4c2b-9ddf-f62d0d06a5ce
8
@Override public Object getValueAt(int row, int col) { FullExec full = m_trades.get( row); switch( col) { case 0: return full.m_trade.m_time; case 1: return full.m_trade.m_acctNumber; case 2: return full.m_trade.m_side; case 3: return full.m_trade.m_shares; case 4: return full.m_contract.d...
0e7a87c5-4bdc-4c04-8738-b9bd256fa622
0
public void startTest() { this.testRead(); Aux.show(this.graf); Aux.printToExcel(this.graf, "Read_Test_Results.txt"); }
a4fe916c-89d4-4715-891c-850ce884da35
2
public String endTask(String taskNumber, String alfrescoTicket) { String line = "", response = ""; //send cURL request try { String url = "http://phaedrus.scss.tcd.ie/CS3BC2/group6/tomcat/alfresco/service/api/workflow/task/end/" + taskNumber + "?alf_ticket=" + alfrescoTicket; ...
0d0d538b-e066-434d-b59f-9289d397a0e6
0
public String getUserName() { return userName; }
092e29f0-3f8c-4593-b1fa-acb661ae4e39
8
private String assembleURL( String host, int port, String userInfo, String authority, String protocol, List path_list, List query_list, String fragment ) { StringBuffer buf = new StringBuffer(); if (this.is_absolute_path) { // Protocol if (protocol != null && protocol.length() > 0) { b...
19ec9e1e-ae99-4d06-af1f-3aa59a5bab01
5
@Override public synchronized void handlePieceAvailability(SharingPeer peer, Piece piece) { // If we don't have this piece, tell the peer we're interested in // getting it from him. if (!this.completedPieces.get(piece.getIndex()) && !this.requestedPieces.get(piece.getIndex())) { peer.interesting(); } ...
4715b77a-924f-479f-9320-e4b50bb802cb
7
public Telegram buildTelegram(){ if(type.equals(SocketTest.Tele_Stat)||type.equals(SocketTest.Tele_Sysr)){ Telegram_STAT t = new Telegram_STAT(send, empf, cp, hndshk, numb, error, type, source, dest, mfs_error, cs, csgr, rsrc); return t; } else if(type.equals(SocketTest.Tele_Wt)||type.equals(SocketTest.Tele...
be912c06-099c-4d03-b970-86e8f21c47f7
7
@SuppressWarnings("unchecked") void readSlaterBasis() throws Exception { /* * slater format: [STO] 1 0 0 0 1 1.565085 0.998181645138011 1 1 0 0 0 1.842345 2.59926303779824 1 0 1 0 0 * 1.842345 2.59926303779824 1 0 0 1 0 1.842345 2.59926303779824 */ Vector intinfo = new Vector(); Vector floatinfo = new V...
9a144fce-6618-4acf-b8e8-452256a26143
6
public ListNode mergeKLists(List<ListNode> lists) { if(lists == null || lists.size()==0) return null; PQsort sort = new PQsort(); PriorityQueue<ListNode> pq = new PriorityQueue<ListNode>(lists.size(), sort); for(ListNode oneList : lists){ if(oneList != null) pq.offer(oneList); } ListNo...
6312b71c-b758-444f-b0a5-a2d856e92cf0
0
@AfterClass public static void tearDownClass() { }
057c13c0-5510-44b4-b020-dace93736948
6
public AudioDevice createAudioDevice() throws JavaLayerException { AudioDevice device = null; AudioDeviceFactory[] factories = getFactoriesPriority(); if (factories==null) throw new JavaLayerException(this+": no factories registered"); JavaLayerException lastEx = null; for (int i=0; (device==null) &...
9bb4f389-fb0c-41b8-9e38-657138a18e13
5
@Override public void happens() { Character character = Game.getInstance().getCurrentCharacter(); int rollResult = Game.getInstance().rollDice(2); if(rollResult == 4){ character.incrementSanity(); } else if (rollResult == 3){ character.incrementKnowledge(); } else if (rollResult >= 1 && rollResult <=2)...
0668eaf3-2191-4cdb-bcfb-dc6714c3be3c
3
public static boolean isTree(mxAnalysisGraph aGraph) { if (isConnected(aGraph) && !isCyclicUndirected(aGraph) && isSimple(aGraph)) { return true; } return false; };
a8ae0c68-6cb1-4486-b92a-dd9a18bf2bd1
2
private void TimeAllotted_chkboxActionPerformed(java.awt.event.ActionEvent evt) { if(TimeAllottedField_text.isEditable()){ TimeAllottedField_text.setEditable(false); status.setText("Field is No Longer Editable"); } else if(!TimeAllottedField_text.isEditable()){ TimeAllottedField_text.setEdi...
59bf6d0a-fa70-4c84-9cae-fc563f0961f0
5
public void decorateChunk(WorldChunk chunk, World w, Random rand) { for(int x = 0 ; x < 16 ; x++) { int height = 150; do { height--; if(!w.getBlockAt(x + chunk.chunkID * 16, height).equals("air") || height <= 0) { break; } } while(true); w.setBlock(x + chunk.chu...
c51d1be0-81f1-4767-befb-c4866656b9e6
2
public boolean checkNoPlayerBoundsCollisionPositive(int playerID) { Point2D point = players.get(playerID).getBatPos(); if(point.getX() > maxX-maxX/20 || point.getY() < minY+minY/20)return false; return true; }
360639d2-80f0-4ad1-bf49-15d835a0e056
4
public static void leerNumerosEnteros(BufferedReader br) { // variables Scanner s = null; try { s = new Scanner(br); // para scannear solo un tipo de datos while (s.hasNext()) { if (s.hasNextInt()) { System.out.println(s.nextInt()); } else { s.next(); } } } catch (Exception e) {...
6c86924f-a742-4907-b7f1-6696646efc69
0
public int GetAvailableBusCount() { return availableBuses.size(); }
1efbb450-87ce-4fcd-91ca-0836f8332569
6
private IMessage adapter(IMessage m) { char[] c=new char[m.taille()]; int r=0; for(int i=0;i<m.taille();i++) { if(m.getChar(i)>=65 && m.getChar(i)<=90) { c[r]=m.getChar(i); r++; } if(m.getChar(i)>=97 && m.getChar(i)<=122) { c[r]=(char)(m.getChar(i)-32); r++; } } char[] aRetourner=n...
c4729aa0-53d2-4ec4-bf38-96896e525796
6
public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) { int var4 = 3; int var5 = 5; if (this.coordBaseMode == 1 || this.coordBaseMode == 2) { var4 = 8 - var4; var5 = 8 - var5; } this.getNextCo...
d21ff40e-2123-4258-bfd4-1d3da102cc2f
4
private RegisterResult registerSlave(InetAddress ip, int port, StringBuilder name) { String slaveName = null; SlaveInfo info = new SlaveInfo(port, ip); Set<String> nodeNameSet = this.slaveTable.keySet(); for (String nodeName : nodeNameSet) { if (this.slaveTable.get(nodeName).getIP().equals(info.getIP()) && ...
bb79ae8f-791f-45c8-8028-a6fd41ccf455
4
private void onDrain() { for (int i = 0; i < this.prevBufferLen; i++) { Runnable callback = this.callbackBuffer.get(i); if (callback != null) { callback.run(); } } for (int i = 0; i < this.prevBufferLen; i++) { this.writeBuffer.pol...
c51e7910-8430-4443-9d9f-8b1508f84083
5
@Override public void execute(CommandSender sender, String gateName, List<String> args) { this.sender = sender; String gateTarget = (args.size() > 0 ? args.get(0) : null); if (gateName == null || gateTarget == null) { error("No gate(s) given."); reply("Usage: /gate link <gatename> <target_gatename>"); ...
e598f9e7-d699-40e8-bcda-94fce0b01566
6
private void writeEstimates() { int numInterested = NUM_INTERESTED; if (histogram.length >= NUM_INTERESTED) { numInterested = NUM_INTERESTED; } else if (histogram.length > 0) { numInterested = 1; } else { System.out.println("Nothing found!"); return; } System.out.println("Increasing probabili...
5f96d0f0-6287-4b4f-8e87-899f1265e2a0
7
private String constructNonDoubleQuery(String regExp, String[] columns, String[][] values) { String type; String columnName; String query = ""; int numColumns = columns.length; for (int i = 0; i < numColumns; i++) { type = typeMap.get(columns[i]); if (type.equalsIgnoreCase("character varying")) c...
8571aad4-d80a-40b5-a251-d51bb958e8ff
8
public void connect() { try { System.out.println("----------HEADERS"); for(String k : conn.getRequestProperties().keySet()) { List<String> l = conn.getRequestProperties().get(k); for(String v : l) { System.out.println(k + " : " + v); } } System.out.println(""); Syste...
099de8a6-e133-4c1e-8c66-fc4165cc556a
3
public int maxFlow(int src, int dest) { int flow = 0; int[] dist = new int[V]; while (dinicBfs(src, dest, dist)) { int[] ptr = new int[V]; while (true) { int df = dinicDfs(ptr, dist, dest, src, Integer.MAX_VALUE); if (df == 0) break; flow += df; } } return flow; }
b9d1d513-ec3f-4ef3-ad35-403b5c54db64
8
private boolean r_tidy_up() { int among_var; // (, line 183 // [, line 184 ket = cursor; // substring, line 184 among_var = find_among_b(a_7, 4); if (among_var == 0) { ...
3e4ae7cc-cb7b-479c-92e3-f86135c23d6d
5
public static ArrayList<Integer> inorderTraversal3(TreeNode root) { ArrayList<Integer> list =new ArrayList<Integer>(); if(root == null) return list; Stack<TreeNode> stack = new Stack<TreeNode>(); TreeNode node = root; while(node != null){ stack.push(node); node = n...
9c2e2b04-34d2-48bf-9745-a0d6eef28476
1
public Builder id(int receivedId) { if (receivedId < 0) { log.warn("Wrong ID. receivedId ={}", id); throw new IllegalArgumentException("Id must be integer value more than 0. Received value =" + receivedId); } this.id = receivedId; return th...
6f76d1b3-2c33-4ce6-b49f-7a2d16030227
5
public void render(GameContainer gc, Graphics g) throws SlickException { BackGround = new Image("res/horrorBG.png"); BackGround.draw(); g.drawString("HP : " + (int) KuZombies.KUhealth, 20, 150); g.drawString("Kill : " + (int) KuZombies.KUKill, 20, 170); g.drawString("Zombies Pass : " + (int) (KuZombies.Zombie...
7b72eb07-fac8-47c0-baed-36a496480660
8
public static void checkGetMethodNames(Object model, YIComponent view) throws YInvalidMVCNameException { ArrayList comps = YUIToolkit.getViewComponents(view); Iterator it = comps.iterator(); String falseNames = ""; while (it.hasNext()) { Object comp = (Object) it.next(); // checking only components which ...
a002d6f6-3af1-490b-91af-b5351050b2cf
5
public void discoverRelationships(File folder) { List<String> classNames = new ArrayList<String>(); Iterator<String> classNameLoader = typeAndFieldListPerClass.keySet() .iterator(); while (classNameLoader.hasNext()) { classNames.add((String) classNameLoader.next()); } Set<String> fieldTypes; for ...
8c486862-0e8b-47c2-a2c6-e4f444fc4077
2
private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed try { this.guardar(); } catch (FileNotFoundException ex) { Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException...
13c20de7-01bf-4e04-9f14-70500b07d61c
8
public void autoScroll(Rachel r){ if(r.getYScreen() < 30 && r.isFacingUp()){ setPosition(x, y + 750); r.setPosition(r.getX(), r.getY() - 50); } if(r.getYScreen() > GamePanel.HEIGHT - 30 && r.isFacingDown()){ setPosition(x, y - 750); r.setPosition(r.getX(), r.getY() + 50); } if(r.getXScreen() > ...
561c8ace-8d26-4c00-9f7e-5faec2bc9bc1
5
public MetroMap(PApplet p) throws DAOException { app = p; factory = DAOFactory.getInstance(); daoStation = factory.getDaoStation(); daoLine = factory.getDaoLine(); daoMetroGraph = factory.getDaoMetroGraph(); stations = new ArrayList<Station>(); // 1. Récupérér depuis la base de données les...
4875b2f8-9d1f-4510-9628-6b3d2851ef5c
1
public static QcTestCase getTestcase(HierarchicalConfiguration testcaseData) { QcTestCase qcTestcase = null; if (testcaseData != null) { qcTestcase = new QcTestCase(); qcTestcase.setId(testcaseData.getString(ID_TAG)); qcTestcase.setName(testcaseData.getString(NAME_TAG...
238970bf-4821-4f6b-aff0-e223f245f84c
2
private ArrayList<Argument> getArguments(String Declaration) { ArrayList<Argument> result = new ArrayList(); if(Declaration.trim().equals("")){ return result; }else { StringTokenizer st = new StringTokenizer(Declaration, ","); while(st.hasMoreElements()){ String token = st.nextToken(); StringToke...
56c95c48-4a31-4809-9852-d11dfdb566ac
8
@Override public Position locate(MacRssiPair[] data) { double x = 0.0; double y = 0.0; int total = 0; for (MacRssiPair pair1:data) { for (MacRssiPair pair2:data) { if (pair2 == pair1 || !pair1.isOnMap() || !pair2.isOnMap()) { continue;...
bec16621-7f37-4a38-ad33-f709ffc1b572
1
@Override public boolean isDataFlavorSupported(DataFlavor flavor) { return DATA_FLAVOR.equals(flavor) || DataFlavor.stringFlavor.equals(flavor); }
ab273603-fb4f-49da-8545-7e6b4a63db99
3
public void fromByteArray(byte[] array) throws Exception { int i = -1; while (array[++i] != -1 ) namensfeld = new String(new byte[] { array[i] }, "UTF-8") + namensfeld; String sZahl = ""; while (array[++i] != -1 ) sZahl = new String(new byte[] { array[i] }, "UTF-8") + sZahl; zahl = Integer.p...
6d06c274-fbd9-48b2-862d-8298d210e658
6
public void usarKinect(){ if (JOptionPane.showConfirmDialog(null, "\nUsar midia virtual?\n","Iniciando Kinect",JOptionPane.YES_NO_OPTION) == 0 ){ JOptionPane pane = new JOptionPane("\nAtivando Kinect...\n", JOptionPane.DEFAULT_OPTION); final JDialog dialog = pa...
bc44f893-8d53-48e2-9788-692073901ada
6
public synchronized BackgroundSound playBackground(InputStream is) { if (bs != null) { bs.stopBackgroundSound(false); } AudioInputStream ais = null; try { ais = AudioSystem.getAudioInputStream(is); } catch (UnsupportedAudioFileException e) { e...
73354c0d-393a-40a3-8b77-f9b2cffb0dc5
9
public void update() { time++; if(time % 30 == 0){ xa = 0; ya = 0; if(random.nextInt(12) == 6){ xa = random.nextInt(3) - 1; ya = random.nextInt(3) - 1; } } if(walking) animSprite.update(); else animSprite.setFrame(0); if (ya < 0){ animSprite = up; dir = Direction.UP; } else if...
2ece18d0-6365-448c-8c9f-121512fc0be5
7
public static void main(String[] a) throws IOException { Scanner s = new Scanner(new File(a[0])); while (s.hasNextLine()) { String[] arr1 = s.nextLine().split("\\|"); int size = arr1[0].split(" ").length; // init int[] max = new int[size]; for (int i = 0; i < max.length; i++) { max[i] = Integ...
dd5753ad-5af2-42c8-b22c-82b253327fbf
6
public static boolean setupTables() throws SQLException { boolean retVal = false; if(!(dbm.isTable("titles") || dbm.isTable("players"))) { try { dbm.query("CREATE TABLE IF NOT EXISTS titles (titleid VARCHAR(20) PRIMARY KEY, titlename VARCHAR(20));"); dbm.query("CREATE TABLE IF NOT EXISTS players (play...
14f243dd-1620-4a0c-9e15-2ab6ce8bde66
3
public static WeaponType getWeaponType(WL plugin, Material material) { if (isWeapon(plugin, material)) { return WeaponType.WEAPON; } else if (isArmor(plugin, material)) { return WeaponType.ARMOR; } else if (isTool(plugin, material)) { return WeaponType.TOOL; } else { return WeaponType...
3676f54c-295a-4b20-811a-43f7713ef82a
8
private void openAndCopyFile() { JFileChooser fileChooser = null; if (lastOpenPath != null && !lastOpenPath.equals("")) { fileChooser = new JFileChooser(lastOpenPath); } else { fileChooser = new JFileChooser(); } FileFilter wavFilter = new FileFilter() {...
5f9cfc4f-a59a-4500-bf41-688aabd704d8
5
@Override public double getYRotation() { double lowest = 9001; double highest = 0; int y = 0; if (getRotationAngle() == 90) y = 20; if (getRotationAngle() == 270) y = -20; for (Block block : blockArray) { if (block.getYValue() > highest) highest = block.getYValue(); if (block.getYValue()...
9d1e33e9-2672-4763-80a7-efac29ea3133
8
public static int getGoodMove(Board board) { int color; int goodMove; int threePointBlock = -1; for (int x = 0; x < board.getBoardWidth(); x++) { for (int y = 0; y < board.getBoardWidth(); y++) { color = board.getPoint(x, y); if (color != Board.VACANT) { goodMove = checkColor(board, x, y); ...
1fc27612-fad3-4f81-9a32-26948e184e48
3
private void parse(VDKInnerDirectory parentDir) { VDKInnerDirectory dir; long nextOffset; if(parentDir instanceof VDK1FileInfo) nextOffset = parentDir.getDotDirectory().getNextAddrOffset(); // IF the parent directory is a directory instance. else nextOffset = parentDir.getParentAccessorDirectory().g...
83cc8d40-55f3-4911-9a23-d85275d9e3d6
3
@Override public void messageReceived(IoSession session, Object message) throws Exception { String text = UTFCoder.decode(message); synchronized(message){ String[] instructions = text.split(Constant.END_MSG); int start=0, end=instructions.length; if(!text.endsWith(Constant.END_MSG)){ end = instructio...
375483b5-ddc5-4c31-bb78-5eee975730a4
7
public static double[] toRGB(double h, double s, double l) { double c = (1 - Math.abs(2 * l - 1)) * s; double x = c * (1 - Math.abs((h / 60) % 2 - 1)); double m = l - c / 2; double[] arr = new double[0]; if (h < 60) { arr = new double[]{c, x, 0}; } else if (h ...
aa97e89a-3c23-4667-8c98-221f1dcfe6c4
9
public static void main(String args[]) throws Throwable { try { // Removing verbosity Logger.getLogger("net.jxta").setLevel(Level.SEVERE); // Retrieving the JXTA loader JxtaLoader TheLoader = GenericPeerGroup.getJxtaLoader(); ...
d992f2e6-a766-456b-83ab-48ac8b977bd6
8
public void doRun() { /* Check if any messages are waiting * in the queue. */ boolean doLoop; synchronized( this ) { doLoop = waitQueue.size() > 0; } if( doLoop ) { while( true ) { Message m; synchronized( this ) { m = getMostRecentMessage(); // See if m exists and should be del...
03f5385b-cb3b-4f5a-aeac-5f8a82ca566f
8
Room(int dX, int dY, String shape){ if (shape == "square"){ dimX = dX; dimY = dY; grid = new Tile[dimX][dimY]; for (int i = 1; i < dimX-1; i++){ grid[i][0] = new Tile(i, 0, EWWALL); grid[i][dimY-1] = new Tile(i, dimY-1, EWWALL); } for (int j = 1; j < dimY-1; j++){ grid[0][j] = new Tile(0...
45351e2d-d5f5-421a-8d09-61a18fbac9fe
5
public void encode() /*throws IOException, FileNotFoundException*/{ //Scanner in = new Scanner(System.in); //System.out.println("Enter 0 for String input or 1 for Filename input"); //int k=in.nextInt(); //System.out.println("Enter the input string: "); //input_string = i...
439ddbbf-ac1a-44d0-b3d7-e2a2acfa60cf
4
private void performHysteresis(int low, int high) { Arrays.fill(data, 0); int offset = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (data[offset] == 0 && magnitude[offset] >= high) { follow(x, y, offset, low); } offset++; } } }
80ebb974-ba71-4d46-8e9f-54ec95ccf489
8
public final HashMap<String,String> InstalledLang(){ HashMap<String, String> InstalledLang = new HashMap<>(); try { if(Status.RunMode.equals(RunType.JAR)){ String ThisJarPath=this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath(); if(ThisJarPath.contains("!")){ ThisJarPath=Thi...
db6f372a-4367-49cd-b710-3c2d0dccc6f1
6
private void validateAndNormalizeData(Map<String, String[]> parameterMap) { try { String data = parameterMap.get("dane")[0]; int columnsNumber = resultSetMetaData.getColumnCount(); //tyczy się aktualnie rozważanej tabeli if ((data == null) || (data.is...
1a9f76ec-183f-4395-a36d-dc3d1eb38baa
2
public double stateScore() { double maxScore = -1 * Double.MAX_VALUE; for (Action a : actions) if (a.getReward() > maxScore) maxScore = a.getReward(); return maxScore; }
a856493a-dadb-4373-b048-ad2661ee68db
4
public void pushParams(ArrayList<ArithmeticResult> argumentList) { // ReversePush instructions.add(new SSAInstruction(OP.SAVE_STATUS)); for (int i = argumentList.size() - 1; i >= 0; --i) { ArithmeticResult result = argumentList.get(i); if (result.getKind() == Kind.CONST) { instructions.add(new SSAInstru...
a5bb5f97-be2c-42ed-a7d4-907f93bd29e8
3
private void removeItemFromIndex(int sel, int amount) { if (sel >= items.size()) return; ItemStack stack = getItemStack(sel); int amt = (amount <= stack.getAmount() ? amount : stack.getAmount()); stack.removeItem(amt); if (stack.getAmount() <= 0) removeItemStack(stack); }
d18baa90-7773-4f77-bfc6-aec87b0919d7
4
public boolean isStalemate(Player player) { for (Field field : this.window.board.fields) { if (field.hasPiece() && field.getPiece().isWhite == player.isWhite && this.hasLegalField(player)) { return false; } } return true; }
42355f27-bada-4fc8-8ce9-ebff672b0765
2
public String getNicknameWhereClicked(MouseEvent e) { // Nejblizsi prvek u mista, kde bylo kliknuto int cell = userList.locationToIndex( e.getPoint() ); if (cell == -1) return null; // Opravdu bylo kliknuto na prvek, nebo jen "nekam blizko" nej? Rectangle r = userLis...
8d9cab00-672b-4748-8c58-07f623a1664c
2
private void read(SelectionKey key) throws IOException { SocketChannel socketChannel = (SocketChannel) key.channel(); // Clear out our read buffer so it's ready for new data this.readBuffer.clear(); // Attempt to read off the channel int numRead; try { numRead = socketChannel.read(this.readBuffer); }...
41611f0d-67eb-4acb-b65f-382be019e3a5
2
private void resizeArray( int minNewSize) { int newSize = array.length; while(newSize < minNewSize) { newSize *= 2; } // Could be Arrays.copyOf(array,newSize); Object[] newArray = new Object[newSize]; for(int i = 0; i < array.length; i ++) { newArray[i] = array[i]; } array = newArray; }
0f2365f4-ed81-4f38-9591-9a9ac0bcbf56
1
public GameList getGamesList(String name) { try { return apiRequest("GetGamesList.php?name=" + URLEncoder.encode(name, "UTF-8"), new GameList()); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; }
91e97ffc-8e1e-40cb-9d5e-e69255485d70
3
void setCellFont () { if (!instance.startup) { table1.getItem (0).setFont (1, cellFont); } /* Set the font item's image to match the font of the item. */ Font ft = cellFont; if (ft == null) ft = table1.getItem (0).getFont (1); TableItem item = colorAndFontTable.getItem(CELL_FONT); Image oldImage = item...
05203eab-8564-4e2e-8aa1-553c05c5ff0b
4
public void serverCutText(String str, int len) { setContents(str); SecurityManager sm = System.getSecurityManager(); try { if (sm != null) sm.checkSystemClipboardAccess(); Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); if (cb != null) { StringSelection ss = new St...
b66e8e1a-e0b7-4447-938e-0b5ae4074a67
9
private void doOnce() throws InterruptedException { if(iteration > 15 || (iteration > 2 && game.board.whiteMoves == "")){ throw new InterruptedException(); } Piece.Type otherPlayer = player; MiniMaxTree mmt = new MiniMaxTree(game.copyGame()); try{ mmt.processToDepth(iteration...
f4b04279-ad37-4eee-ae66-3d5843adbf00
0
public String getName() { return name; }
d3b0e120-1cfc-4a90-863a-a4dce107c1dd
4
public int Init() { // Delete the contents of the log file. if (logFilename != null) { try { FileOutputStream fos = new FileOutputStream(logFilename); fos.close(); WriteLogMessage("initializing"); } catch (Exception e) { // do nothing. } } switch (initMode) { case 0: return LoadMa...
dbc5df8e-d866-46fb-bf85-917ffb2baedf
9
public static String solve( ){ String nName = ""; nName+=Character.toLowerCase(tmpName[0].charAt(0)); String lastName = tmpName[tmpName.length-1]; for (int i = 0; i < lastName.length( ); i++) { char act = lastName.charAt(i); if(Character.isLetter(act)) nName+=Character.toLowerCase(act); } if( nNa...
00e58710-387d-4902-ad64-3ce8d43de6ca
7
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if(!(affected instanceof MOB)) return true; final MOB mob=(MOB)affected; // when this spell is on a MOBs Affected list, // it should consistantly prevent the mob // from trying to do ANYTHING except sleep if(msg.amISour...
8958ad05-e675-4005-8ff5-90ae0a6dd0ab
4
public String atacar(Personagem atacado,Personagem atacante){ int inicial, total; inicial = atacado.getQuantidadeVida(); Scanner operacao = new Scanner(System.in); int op; if (atacante.getTipo().equals("Protagonista")){ System.out.println("1) Atacar"); ...
223e3efa-74cd-4941-b79c-17d893796ad8
7
protected void doLockKeys() { if (!Options.useLockingKeyState) return; if (Constants.OS == Constants.LINUX) return; // broken for linux if (Constants.OS == Constants.MAC) return; // unsupported operation for mac logger.debug("doLockKeys"); try { Toolkit tk = Toolkit.getDefaultToolkit(); if (t...