method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
a45d57f6-b22c-4292-891a-a261774c4f4b
8
void solve() { for (int i = 0; i < numberOfPoints; i++) { // zeros wavefunction phi[i] = 0; } for (int i = 0; i < numberOfPoints; i++) { phi[i] = state[0]; // stores wavefunction x[i] = state[2]; solver.step(); // steps Schroedinger equation if (Math.abs(state[0]) > stepThresh...
b98f2031-e3ad-48f1-a0a5-afe1a3ca5273
2
private String packListIntoString () { StringBuilder list = new StringBuilder(); int index = 0; for (String name : myPPClientList.keySet()) { list.append(myPPClientList.get(name) + ":" + name); if (index != myPPClientList.size() - 1) { list.append(';'); ...
16e57336-47f7-4679-aa56-49834f66be74
7
public void reorderList(ListNode head) { if (head == null || head.next == null) { return; } ListNode tail = head.next; ListNode mid = head; while (tail != null && tail.next != null) { mid = mid.next; tail = tail.next.next; } tail = mid.next; mid.next = null; // split list to two parts tail = ...
b06b4633-b296-40e2-aa53-e0a158c25cba
3
public void tellOps(String string) { Collection<? extends Player> tmp = getServer().getOnlinePlayers(); Player[] players = tmp.toArray(new Player[tmp.size()]); for(int a = 0; a < players.length; a++) { if(players[a].isOp()) players[a].sendMessage(string); } }
787c76fb-7d89-4367-8105-d7bd4bc8434b
9
@SuppressWarnings("unchecked") public float read(float[] leftBuf, float[] rightBuf, int readRate) { if (buf.length != leftBuf.length) buf = new float[leftBuf.length]; if (sounds.size() > maxChannels) { Collections.sort(sounds); } Arrays.fill(leftBuf, 0); ...
9126e49c-140c-4e35-bcfb-efcdc1ddcb35
3
public String Prom () { double acumA=0, acumB=0; double promA=0, promB=0; for (int i = 0; i < CursoA.length; i++) { acumA+=CursoA[i]; } for (int i = 0; i < CursoB.length; i++) { acumB+=CursoB[i]; } promA=acumA/5; promB=acumB/5; ...
76129342-62ce-41f4-bc8c-71c9dd379b39
3
private boolean doSaveBeforeOpenOrNew(){ LogoDocument program = getProgram(); if (program.isDirty()){ int option = JOptionPane.showConfirmDialog(this, "Hay cosas sin guardar, desea guardar ahora?", "Atencion", JOptionPane.YES_NO_CANCEL_OPTION); if (option == JOptionPane.CANCEL_OPTION){ return false; }...
9d4da9e0-7550-40c2-b45d-092f5753a1e8
0
public void register(IncomingConnectionListener listener) { this.listeners.add(listener); }
2025f99b-c7d1-4d0d-aaf9-eae12b52f23c
6
public void run() { count = 0; ok = true; int d = new Random().nextInt(10000); while (proxy.isRunning()) { try { if (proxy.isConnected()) sleep(20000 + d); else sleep(2000); count++; ok = false; sentTime = System.currentTimeMillis(); if (proxy.isConnected()) { prox...
7cd318c0-ec40-43d0-b424-5741889fb37c
6
public static List loadNeuralNetworkFile(String file) { { List nets = List.newList(); InputFileStream stream = InputFileStream.newInputFileStream(file); int numHidden = 0; Cons prop = Stella.NIL; Stella_Object temp = null; int numIn = 0; PropositionNeuralNetwork net = null; ...
d7b66b02-17c7-4de0-9b8e-b9898ee538cf
6
public static int substringsCount(String string, String pattern) { if(string == null || pattern == null) return -1; char[] str = string.toCharArray(); char[] pat = pattern.toCharArray(); int startIndex = 0; int lastIndex = 0; int count = 0; while(lastIndex < str.length) { if(lastIndex - startI...
26e95619-84e4-44b1-8522-fa8f364e3137
7
public final FEMDatetime moveZone(final int hours, final int minutes) throws IllegalStateException, IllegalArgumentException { if (!this.hasZone()) throw new IllegalStateException(); if ((hours == 0) && (minutes == 0)) return this; if ((hours < -28) || (hours > 28)) throw new IllegalArgumentException(); if ((mi...
8c24dd10-bf04-4462-8f03-399cde5aa19e
4
public void showStatus(int step, Field field) { if (!isVisible()) { setVisible(true); } stepLabel.setText(STEP_PREFIX + step); stats.reset(); fieldView.preparePaint(); for (int row = 0; row < field.getDepth(); row++) { for (int col = 0; col < fi...
27ba58f0-93d0-4bb0-998e-dc33ec136cf2
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...
6b57fbc1-1dbd-4890-afc3-6ed60af24b4c
7
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { setBackground(isSelected ? SystemColor.textHighlight : Color.white); setForeground(isSelected ? SystemColor.textHighlightText : Color.black); if (value instanceof PageMolecularViewer...
d743dbdf-f26b-4a3a-ab10-7db61ddf8917
9
public int ladderLength(String start, String end, HashSet<String> dict) { // Start typing your Java solution below // DO NOT write main() function\ //mlgb, zhen bu rong yi.... LinkedList<String> queue = new LinkedList<String>(); queue.add(start); String lastFirst = start; int ret = 1; if(dict.contains(s...
54400d12-6887-4134-8d99-1b25fdf587b8
9
@SuppressWarnings("static-access") public void handle(CommandLine parser) { //Handle listing files if (parser.hasOption("ls")) { final File jenHome = new File(options.jenHome); if (jenHome.listFiles().length == 0) { log.info("No jen environments found."); return; } for (File f : jenHome.listFi...
8d3faa1d-737e-481f-a33e-96f8a59c7eca
6
public void goCompare() { try { HashMap<String, ArrayList> tableInfoOne = appState.getDbOperationManagerOne().getTableInfo(tComparatorOne.getSelectedTable()); HashMap<String, ArrayList> tableInfoTwo = appState.getDbOperationManagerTwo().getTableInfo(tComparatorTwo.getSelectedTable()); if(compare...
be0dbb14-9fa5-4e69-afa1-15fdec67b635
1
@Override public void run() { try { MulticastSocket socket = new MulticastSocket(4446); InetAddress address = InetAddress.getByName("230.0.0.1"); socket.joinGroup(address); DatagramPacket packet; byte[] buf = new byte[256]; packet = n...
9a05f37e-8dbc-492b-a538-057a9c8eae21
1
public static void main(String[] args) { PerformChecker.check(new Logic() { @Override public void doIt() { // 計測対象の処理 for (int i = 0; i < 100; i++) { System.out.println("hello"); } } }); // checkTime(); }
da898846-96b1-4748-a0ec-d1b0b4664fd4
9
private void jButtonNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNextActionPerformed // TODO add your handling code here: if(jPanelRadio.isVisible()){ jPanelRadio.setVisible(false); jPanelList.setVisible(true); if(jRadioButtonImport.is...
c5d83d24-0022-4125-91f3-2e89d1a380b7
5
public void delete(int arvo) { AvlSolmu solmu = etsiArvo(juuri, arvo); if (solmu != null) { AvlSolmu vanhempi = solmu.getParent(); if ((solmu.getLeft() == null) && (solmu.getRight() == null)) { poistaSolmuJollaEiLapsia(vanhempi, solmu); } else if ...
03e535cf-4c35-434c-aef8-c79513139556
9
protected void addHeader() { String theHeader = ""; if (HumboldtJS.preInitFile != "") { File inFile = getFile(HumboldtJS.preInitFile); if (inFile == null) { HumboldtJS.showError("Cannot find file: " + HumboldtJS.preInitFile); } byte[] buffer = loadFile(inFile, HumboldtJS.preInitFile); theHe...
ecd271eb-69b8-4d5a-9466-c84d90feb540
2
public void add(int id, String title, String author, float price, int quantityOrdered) { // Check if the id is already in the shopping cart Iterator<CartItem> iter = cart.iterator(); while (iter.hasNext()) { CartItem item = iter.next(); if (item.getId() == id) { // id fou...
1d281e8b-13e2-4ede-905d-9c9a4a17246e
9
static private boolean jj_scan_token(int kind) { if (jj_scanpos == jj_lastpos) { jj_la--; if (jj_scanpos.next == null) { jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); } else { jj_lastpos = jj_scanpos = jj_scanpos.next; } } else { jj_scanpo...
050632db-0ca3-402d-8f45-d5ad40b8939b
2
private Token isReservedWord(Token token) { Token tok = token; for (ReservedWord rw : ReservedWord.values()) { //Si encontramos que en el enum ReservedWord existe el lexema que estoy comparando, entonces devuelvo el TokenType que tiene asociado en ese enum. //de lo contrario devu...
3f9187a8-49f0-447b-ae27-6261fecf7409
5
public void paint(Graphics g, int offsetX, int offsetY) { if (hit) { if (hitFrameCounter % HIT_FLICKER > HIT_FLICKER / 2) { super.paint(g, offsetX, offsetY); } hitFrameCounter++; if (hitFrameCounter == HIT_FRAMES) { hit = false; } } else { super.paint(g, offsetX, offsetY); } // Pi...
edbb1c71-f6e9-4b01-a3f0-033b5c2e2b6d
1
private static Employee EmployeeObject(ResultSet rs) { Employee newEmployee = null; try { newEmployee = new Employee(rs.getInt(rs.getMetaData().getColumnName(1)), rs.getString(rs.getMetaData().getColumnName(2)), r...
498e322e-0980-403a-8516-23b8bf772042
2
public static SIIS deSerializeFile(File filename) { try { FileInputStream file = new FileInputStream(filename); ObjectInputStream o = new ObjectInputStream(file); SIIS tmp = (SIIS) o.readObject(); o.close(); return tmp; } catch (IOException e) { System.err.println(e); } catch (ClassNotFoundExcep...
6308ba61-1690-4128-92f9-f600fef1a788
2
public Status getIntake() throws MenuException { String command; Scanner input = new Scanner(System.in); this.display(); command = input.nextLine(); command = command.trim().toUpperCase(); switch (command) { case "E": System.out.println("Th...
82eade89-9e01-4d22-a3a5-62245d26d0d1
2
public void setCartregesReamaining(int cartregesReamaining) { this.cartregesReamaining = cartregesReamaining; if (isOutOfAmo() && cartregesReamaining > 0) { setOutOfAmo(false); reload(); } }
204a6c25-c5d9-4b3b-88ed-c9774f3796da
4
private static void insertionSort(int[] arr) { if(arr.length < 2) return; int firstUnsortedNum; //索引i之前的全部是已排好序的数组元素 for(int i=1; i<arr.length; i++){ firstUnsortedNum = arr[i]; //截取字数组 int[] sortedArr = new int[i]; for(int m=0; m<i; m++){ sortedArr[m] = arr[m]; } //用二分搜索找到arr[i]...
32f71fc2-34fa-4afe-b27d-9722eb9fdf63
5
private void AplicarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AplicarjButtonActionPerformed int option = 0; if (comparacion(piloto1, piloto1Num, pilot1)) { option = 1; } if (metodo == 2) { if (comparacion(piloto2, piloto2Num, pilot2...
8d65c7ce-4313-47fd-876b-e418771d013d
0
public Firewall[] getFirewalls() { return firewalls; }
aa442fb9-5a44-4562-b00d-19b00a01a7ce
4
public static List<Image> getGalleryContents(String galleryName) { List<Image> images = new ArrayList<Image>(); NodeList nList = getNodeList(); for (int i = 0; i < nList.getLength(); i++) { Node nNode = nList.item(i); if (nNode.getNodeType() == Node.ELEMENT_NODE) { ...
cc824ebb-69e4-43b7-8f8c-79f0083cb9c8
4
private void percolateDown(int hole){ int child; AnyType tmp = this.array[hole]; for( ; hole*2 <= this.currentSize; hole = child){ child = hole*2; if(child != this.currentSize && compare(this.array[child+1], this.array[child])< 0) child++; if(compare(this.array[child],tmp)<0) this.array[hole] = ...
1db44f5c-fb89-4d88-a3f3-e7cf31d79685
4
public List<Gaest> getGaester() { Gaest gl = null; String SQLString = " select * from GAEST_TBL"; PreparedStatement statement = null; List<Gaest> gaesteListe = new ArrayList<>(); try { statement = con.prepareStatement(SQLString); ...
ed167f92-8b77-45f4-99f8-382b06cec8ad
5
@Override public void keyPressed(int k) { switch(k){ case KeyEvent.VK_ENTER: select(); break; case KeyEvent.VK_UP: currentChoice--; if (currentChoice == -1){ currentChoice = options.length - 1; } break; case KeyEvent.VK_DOWN: currentChoice++; if (currentChoice == options.length){ ...
707c2792-85f6-4d0d-9edc-4dbf138a48a0
7
private Color blockTypeColor(BlockType blockType) { switch (blockType) { case I: return Color.CYAN; case J: return Color.BLUE; case L: return Color.ORANGE; case O: return Color.YELLOW; case S: return Color.GREEN; case T: return PURPLE_COLOR...
474c656b-7dd0-402b-ae08-f7202782e91b
4
protected void setupPowersButtons() { final Quickbar bar = this ; final UIGroup powerGroup = new UIGroup(UI) ; final List <Button> powerSlots = new List <Button> () ; for (final Power power : Power.BASIC_POWERS) { final Button button = new Button( UI, power.buttonTex, Button.IC...
ef41a141-3d71-4889-a2be-807bbfcd8495
1
private void setText(String text) { try { // remove all text and insert the completed string super.remove(0, getLength()); super.insertString(0, text, null); } catch (BadLocationException e) { throw new RuntimeException(e.toString()); } }
3faa1fab-b8ec-4a15-b675-62259122fa8a
1
public ArrayList<DamagePackage> getDamagePacks() { ArrayList<DamagePackage> packages = new ArrayList<DamagePackage>(); DamagePackage base = new DamagePackage(base_damage, AttackType.typeConversion(attackType)); packages.add(base); for (int c = 0; c < passiveEnchants.size(); c++) { ...
e066c440-6c38-4607-8858-ce112f5f8e8f
5
public synchronized void executeNextTask() { // System.out.println("HIT"); if (this.m_TaskQueue.size() > 0) { for (int i = 0; i < this.m_Threads.size(); i++) { DCThread thread = this.m_Threads.get(i); // System.out.println("Got thread: " + thread.getThreadId()); if (thread.getThreadState() == THREAD...
8101214c-bc73-425a-80ec-b6379e708c97
8
protected boolean checkMessage(HttpServletRequest req, HttpServletResponse resp, boolean response) throws IOException { final String signature = req.getParameter("signature"); final String timestamp = req.getParameter("timestamp"); final String nonce = req.getParameter("nonce"); final String echostr = req.ge...
ad125a2b-efdd-4cd4-86ba-3ec2e6f2070c
6
public ModelExploiter(){ boolean accept = false; while (!accept){ ModelExplorer PE = new ModelExplorer(); PE.train(); rl = PE.getRL(); Player[] players = new Player[]{ new PlayerComputer(this), new PlayerComputer(new ModelRandom()) }; Game g = Game.create(players, 5, 1, false); int pla...
f999f3ad-56fd-4ca0-8d4a-b4aea55e9fbc
2
private static boolean isPowerOf(double power_value, double user_value, int range) { double[] powersList = new double[range]; for(int i = 0; i < range; i++) { // generate powers of list powersList[i] = Math.pow(power_value, new Double(i)); // if the users value is...
88f4f210-bb3d-4fd2-8284-02e35b62e24d
6
public String makeURL(boolean weather, String ownloaction) { String URL="https://www.google.co.in/search?q="; //only for weather for perticular location if(weather==true && ownloaction!=null){ URL+="current+temp+"+ownloaction; } //only for current location if(weather==false && ownloaction==null){ URL+="cu...
db6fc30b-8a57-48b2-a99e-b831858cb6da
4
private void sendMsg(String msg) { if(socket != null && socket.isConnected()) { try { DataOutputStream out = new DataOutputStream(socket.getOutputStream()); if (!msg.endsWith("\n")) msg += "\n"; out.writeBytes(msg); ...
2699b136-1a1f-4455-9dd2-c95caf91f429
0
protected void onTime(String sourceNick, String sourceLogin, String sourceHostname, String target) { this.sendRawLine("NOTICE " + sourceNick + " :\u0001TIME " + new Date().toString() + "\u0001"); }
9c527e33-b592-45cc-bb9b-d06acdd28445
4
public String addPlayer(Player p ){ String Team = null; if(blau.size()!= 4){ blau.add(p); Team = "Blau"; } if(rot.size()!= 4){ rot.add(p); Team = "Rot"; } if(grün.size()!= 4){ grün.add(p); Team = "Grün"; } if(gelb.size()!= 4){ gelb.add(p); Team = "Gelb"; } return Team; }
a291e751-4148-4ab4-aeca-26b1d005e192
8
@Test(timeout = 1000) public void testConcurrentReaderPiping() throws Exception { final int charCount = 30; final char[] vals = "123456789".toCharArray(); final int n = vals.length; Reader[] readers = new Reader[n]; // Generate n readers with charCount equal elements in them....
b21ddefa-863f-4289-86ef-7312f47cf039
2
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); response.setContentType("text/html; charset=UTF-8"); PrintWriter out = response.getWriter(); name = request.getParame...
f67c37ac-656d-4836-aab6-df6a7f6c435e
4
private void initPanel(){ int scale = 10; JPanel p = new JPanel(); p.setLayout(null); //Outstanding Borrowing JLabel label0 = new JLabel("Outstanding Borrowing: "); label0.setBounds(scale, 0, WIDTH/3, HEIGHT/scale); label0.setHorizontalAlignment(SwingConstants.LEFT); label0.setVerticalAlignment(Swin...
bdf836fe-4de0-4c0a-9fd9-d55b518c90e9
4
public boolean accept(File f) { if(f != null) { if(f.isDirectory()) { return true; } String extension = getExtension(f); if(extension != null && filters.get(getExtension(f)) != null) { return true; }; } return false; }
ec77efd7-2288-42fb-9420-e1f8469d4bf9
8
public static boolean wrapperP(Stella_Object x) { if (Stella.$CLASS_HIERARCHY_BOOTEDp$) { return ((x != null) && Stella_Object.isaP(x, Stella.SGT_STELLA_WRAPPER)); } return (Stella_Object.booleanP(x) || (Stella_Object.integerP(x) || (Stella_Object.longIntegerP(x) || ...
456bd2ed-bd25-475e-8a6f-a82f70b02835
8
@Override public void callback(DiscreteEventSimulator DES) throws SimulatorException { boolean isNative = context.getContextID() == target.getCoreID(); if (isNative){ Context oldContext = target.switchNativeContext(context); context.endStall(); // give predictor feedback switch (type){ case C...
a9d74c1c-afec-47af-9fb9-31a662cc05dd
0
public String getFossil() { return this.fossil; }
090959e4-197a-4007-a8e7-46173335889f
1
void labelClicked(final int xCoordinate, final int yCoordinate) { //открываем эту новую область boolean[][] currentBricks = state.getBricks(); currentBricks[xCoordinate][yCoordinate] = false; state.setBricks(currentBricks); state.setResultFromButton(false); //уменьшаем сч...
62dbc180-6f54-43e8-b3fd-4533c730520f
0
public void setZAxisDeadZone(float zone) { setDeadZone(zaxis,zone); }
b367c545-4000-4668-99db-c0519f46f078
6
public boolean mySolveSudoku(char[][] board,int row, int column) { if(!isValidBox(board,row,column)) return false; for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { if (board[i][j] == '.'){ for (int k = 1; k < 10; k++){ ...
e123ef3f-3eec-4e99-9260-49e224df22bb
9
public static boolean isValidLocalLink(String value) { // Allow links to files stored in the jar. if (value.startsWith("static_files/")) { value = value.substring("static_files/".length()); } for (int index = 0; index < value.length(); index++) { char c = value....
6a5369ff-71bd-4436-bfd9-f35b7f4e7620
7
static final public Engine program() throws ParseException { Engine engine = new Engine(); ActorType at; CreateActorStatement createStmt; SendMessageStatement sendStmt; label_1: while (true) { at = actor_type(); engine.addActorType(at); if (jj_2_1(4)) { ...
ccfeacf3-460d-40c7-859a-4802f4ea347e
0
@Test public void addingVerticesWorks() { g.addVertex(v); DynamicArray a = g.getVertices(); assertTrue(a.contains(v)); }
9e37ba6d-bc17-49a0-a802-15da53927755
1
public SignatureVisitor visitParameterType() { endFormals(); if (!hasParameters) { hasParameters = true; buf.append('('); } return this; }
ceae6ca1-49c8-46a6-a16b-e0b20034b369
2
public String getValue(String name) throws Exception { if (this.prop == null) { InputStream propIs = null; try { propIs = Thread.currentThread().getContextClassLoader().getResourceAsStream(propPath); this.prop = new Properties(); this.prop.load(propIs); } catch (Exception e) { ...
457d49e0-6574-4f1e-b7b4-766aea041c09
6
public static String[] splitAndMaskWordsAroundNotLeavePunctuation(String text) { String[] words = text.split("\\s+"); //ignore words around "not" (next to, or one word away) - //G.H. (this can be much more efficient with a regex) for (int i=0; i<words.length; i++) { if (words[i...
39f49e36-b139-448a-ac2c-c08254ec4475
2
private static void displayTables() // tester function { for (int i = 0; i < DiningRoom.size(); i++) { Table thisTable = new Table((Table) DiningRoom.get(i)); Vector thisTab = thisTable.getIDList(); System.out.println("Table has " + thisTab.size() + " people."); for (int j = 0; j < thisTab.size(); j++) {...
1464e6d7-6068-4716-8521-b3e0356ea06b
5
public GedcomObjectFactory findFactoryForTag(String tag) { if (tag.equalsIgnoreCase("SOUR")) return sourceFactory; else if (tag.equalsIgnoreCase("NOTE")) return noteFactory; else if (tag.equalsIgnoreCase("NAME")) return nameFactory; GedcomObjectFactory factory = eventHash.get(tag); if (factory != ...
7b47f819-a7c1-4a11-9c6b-caef0d9d90de
6
public void printTranslation(String foundWords, String englishOrBliss) { //if notFoundQueue is empty if(notFoundQueue.checkQueueEmpty()==true) { System.out.print(foundWords +" translated to "+ englishOrBliss +" is: "); while(myQueue.checkQueueEmpty() != true) ...
99ae79ff-8005-4480-9165-93d1648f1c55
4
public static void main(String[] args) throws Exception { System.setSecurityManager(null); // Script file String scriptFile = (args.length < 1) ? "trips" : args[0]; // Registry host String host = (args.length < 1) ? null : args[1]; Registry registry = LocateRegistry.getRegistry(host); // Lookup agency ...
af5c80b4-1d7c-42ae-9561-0829fd680171
5
public void FillCircle(int X, int Y, int R) { // long time = System.nanoTime(); for (int i1 = Math.max(X-(R+1),0); i1 < Math.min(X+(R+1),w); i1 ++) { for (int i2 = Math.max(Y-(R+1),0); i2 < Math.min(Y+(R+1),h); i2 ++) { if (M...
940067dc-5b30-42a3-8a8b-8c109d949e32
0
public static UserAgent parseUserAgentString(String userAgentString) { return new UserAgent(userAgentString); }
0729111d-9623-4853-974a-b139de026c74
7
private static int partition(int left, int right) { int pivot = array[right]; int i = left; int j = right - 1; do{ while(array[i] <= pivot && i < right) i++; while(array[j] >= pivot && j > left) j--; ...
c3e72084-c6e5-430b-9c11-2080f32bcb56
7
private int extractIntFromStart (int pos) { int v=0; if (startBuffer[pos]==true) v=64; if (startBuffer[pos+1]==true) v=v+32; if (startBuffer[pos+2]==true) v=v+16; if (startBuffer[pos+3]==true) v=v+8; if (startBuffer[pos+4]==true) v=v+4; if (startBuffer[pos+5]==true) v=v+2; if (startBuffer[pos+6]==true) ...
78971f90-8f70-4c36-8ff8-9e6c2e83d9e6
3
public static Image createCircleImage(int height, int width) { Image binaryImage = new RgbImage(width, height); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { double aTerm = Math.pow(x - width / 2, 2); double bTerm = Math.pow(y - height / 2, 2); double rTerm = Math.pow(height / ...
41d3a14a-237b-494f-a927-88367608bebb
7
public static ArrayList<String> FetchjobsFromJobPortal(String urlForJob) { WebDriver driver1 = new FirefoxDriver(); // Code for pagination driver1.get(urlForJob); ArrayList<String> listOfJobs = new ArrayList<String>(); //WebElement ulOfPagination = divForJobs.findElement(By...
322edacc-3c54-4233-bdd6-9b0a7c82da1b
1
public boolean isMainHeroDead() { if (mainHero == null) return false; return getPlayer(playerColor()).getDeadHeroes().contains(mainHero); }
6141ae1f-68c2-4082-bc50-c141f397cd61
2
public void rotate180(Board board) { Point[] newRel = new Point[3]; for (int i = 0; i < rel.length; i++) { newRel[i] = new Point(-rel[i].getX(), -rel[i].getY()); } if (rotateAlgorithm(board, base, newRel, getKicks()[(rotation+1)%4])) { addRotation(2); } }
93d7aecd-a9e6-40cf-b2cb-ac14d1d7a34e
6
private void kingBottomPossibleMove(Piece piece, Position position) { int x1 = position.getPositionX(); int y1 = position.getPositionY(); if((x1 >= 0 && y1 >= 1) && (x1 < maxWidth && y1 < maxHeight)) { if(board.getChessBoardSquare(x1, y1-1).getPiece().getPieceType() != board.getBlankPiece().getPieceType(...
69fce206-1eb0-4441-a001-177d5eee26bb
0
public int hashCode() { return super.hashCode() ^ getLabel().hashCode() ^ getOutput().hashCode(); }
7470796c-aafe-406f-8ab7-e9d44d23ccac
5
public static <A, O extends A> A[] addObjectToArray(A[] array, O obj) { Class<?> compType = Object.class; if (array != null) { compType = array.getClass().getComponentType(); } else if (obj != null) { compType = obj.getClass(); } int newArrLength = (array != null ? array.length + 1 : 1); @SuppressWarn...
571d6615-fac9-4407-aa00-ab8a737e911d
3
public static SpriteID getSpriteID1(EntityType type) { switch (type) { case OBJ_TREE: return EnviroSprite.tree_green_1; case OBJ_DOOR_WOOD: return EnviroSprite.door_wooden_closed; case ENTR_DUNGEON: return EnviroSprite.stone_ha...
c6bf3e57-22da-438e-86b9-a9219571cab8
8
public void startGame(Player p, String team1, String team2){ try{ greenTeam = Team.valueOf(team1.toUpperCase()); }catch(Exception e){ p.sendMessage(ChatColor.RED + team1 + " is not a valid team name!"); return; } try{ blueTeam = Team.valueOf(team2.toUpperCase()); }catch(Exception e){ p.sendMess...
ec7c6ac3-c5a8-4ea7-bc1a-5865f6d175a0
9
public synchronized void zoomIn(float zoomPercent) { if (zoomScale >= zoomScaleMax) return; float xmin = xAxis.getMin(); float xmax = xAxis.getMax(); float ymin = yAxis.getMin(); float ymax = yAxis.getMax(); float dx = xmax - xmin; float num = dx / (xAxis.getMajorTic()); if (dx / num * zoomPercent...
d68474d2-d105-4f8e-b73e-cf75afba1fe5
4
public static double calculateCentralitySum(double average, ArrayList<Double> averageRatings, ArrayList<Double> ratings, ArrayList<Double> similarities, ArrayList<Double> centralityScores) { double denominator = 0, numerator = 0; for (int i = 0; i < ratings.size(); i++) { if (similarities.get(i) > 0 && c...
c24e850f-0aba-4795-af05-dcef49abb96d
6
public double getCollisionForceDirection(Point collisionpoint) { // Circles simply push the object away if (this.collisiontype == CollisionType.CIRCLE) return HelpMath.pointDirection(getX(), getY(), collisionpoint.x, collisionpoint.y); // Walls simply push the object to the right (relative) else if (t...
81f2f424-beea-4951-8a0d-56b4011df908
3
void readCdsFileFasta() { // Load file FastaFileIterator ffi = new FastaFileIterator(cdsFile); for (String seq : ffi) { String trId = ffi.getName(); // Repeated transcript Id? => Check that CDS is the same if ((cdsByTrId.get(trId) != null) && (!cdsByTrId.get(trId).equals(seq))) System.err.println("ERRO...
43552214-a6e5-4f39-9f81-15c4880be644
6
public final void setOwner(ChunkyObject object, Boolean keepChildren, boolean clearPermissions) { if (owner != null) { if (keepChildren) owner.removeOwnable(this); else owner.removeOwnableAndTakeChildren(this); } else if(!keepChildren) { ...
b2f4fb10-33ac-4ca9-a44b-0d84fa27808e
9
public String[] preprocess(String sourceCode) throws BadLabelFormatError { String[] lines = sourceCode.split("\\n"); //ArrayList<String> newLines = new ArrayList(lines.length); Console.log("Preprocessing...", "info"); labelTable = new Hashtable<String, Short>(20); short memoryPoi...
c80e1c88-60aa-4464-ab42-b9b1d0a9b8b9
0
public Chance( double p ) { this.probability = p; }
b400baba-7192-425f-b56e-210b6316787e
3
private void ProcurarEscola_ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ProcurarEscola_ButtonActionPerformed // TODO add your handling code here: Escola escola = a.getEscola(Escola_ComboBox2.getSelectedItem().toString()); if (escola != null) { EscolaSelec...
79931531-64fc-4ae3-afe2-40e550b337b7
7
public static void addTaskToAgenda(String task,int startTime,int duration){ JTextArea agendaContent = new JTextArea(task); agendaContent.setWrapStyleWord(true); agendaContent.setLineWrap(true); agendaContent.setEditable(false); Border border = BorderFactory.createEmptyBorder(); agendaContent.setBorder(Borde...
75e50ba6-01ca-423f-a029-4a42736d3e4e
2
public static boolean isDependentOn(String v1, String v2, Grammar grammar) { GrammarChecker gc = new GrammarChecker(); ProductionChecker pc = new ProductionChecker(); Production[] productions = GrammarChecker.getProductionsOnVariable(v1, grammar); for (int k = 0; k < productions.length; k++) { if (Produc...
796eb115-0fc5-441d-99a1-7063dc53f572
2
public synchronized Object lockExclusive() throws IOException { while (myLock != null) { try { wait(); } catch (InterruptedException ex) { throw new IOException(ex); } } myLock = getLockingObject(); return myLock; }
afa47f72-01f8-43d9-bb88-21dee2b5e832
4
private boolean isHovering(MouseEvent e) { Rectangle quad = new Rectangle(quadHndl.x + (int)quadXPos - 1, quadHndl.y + (int)quadYPos - 1, quadHndl.width+2, quadHndl.height+2); Rectangle quadEnd = new Rectangle(quadEndHndl.x + (int)quadXPos - 1, quadEndHndl.y + (int)quadYPos - 1, quadEndHndl.width+2, quadEndHndl.heigh...
a71fe606-f37b-4a4d-9984-c660ba6063eb
7
private void filter() { if(model != null) { if(jCheckBoxCrossPrice.isSelected() && jCheckBoxNFPrice.isSelected()) { sorter.setRowFilter(null); } else if(jCheckBoxCrossPrice.isSelected() && !jCheckBoxNFPrice.isSelected()) { sorter.setRowFilter(R...
8c84658a-cd81-47ef-b5a9-badcf36c40ce
2
public void worldBroadcast(String message, String world) { for (Player p : server.players) { if(p.world == world) p.sendMessage(message); } }
1f6858ad-e7f0-4ead-8b42-df808217cf03
9
@Test public void selectATargetLocation() { // Will go In room ComputerPlayer player = new ComputerPlayer(); player.setLastVisited('Z'); Board board = game.getBoard(); board.calcTargets(4, 5, 2); int loc_4_3 = 0; int total = 120; for(int i = 0; i < total; i++) { BoardCell selected = player.pic...
86639a40-d045-438c-bc18-f929b6408522
2
public static void useRod(Item item) { if (!hasItem(item)) { errorWindow.addMessage(" You don't have this item in your inventory to use! "); errorWindow.toFront(); return; } if(JokemonDriver.canFish()) { inventoryWindow.closeInventory(); JokemonDriver.fishing=true; JokemonDriver.performing...
d4e218f4-5619-418d-bbbe-0ba37876ed98
9
public void ComputeBigWindowStatisticByToeflDataSet() throws IOException{ int correctAnswers = 0; File testFile = new File("toefl.tst"); BufferedReader testReader = new BufferedReader(new FileReader(testFile)); String rdline; int LineNo = 0; String[] question = new String[6]; while ((rdline = te...