method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
e0ac918d-aff8-4028-9a70-67f738c56f5c
5
public static void saveRegion( Region region, File dir ) { File f = new File( dir, String.format( "r%d %d %d.gven.dat", region.x, region.y, region.z ) ); if ( !createFile( f ) ) { return; } Chunk[] chunks = region.getChunks(); int[][] chunkCoords = new ...
ec1f3262-3ab6-4265-b136-9edfc23e9ae0
3
Transcript createTranscript(Gene gene, String trId) { int start = gene.getStart(), end = gene.getEnd(); Transcript tr = new Transcript(gene, gene.getStart(), gene.getEnd(), gene.getStrand(), "transcript_" + trId); tr.setProteinCoding(true); add(tr); // Add exons int numEx = Math.max(random.nextInt(maxExons...
7b3abd49-7595-472c-82d6-2ad797e6ab9f
3
private Cipher createAndInitialiseContentCipher( ByteBuffer encrypted, byte[] decryptionKeyBytes) throws PDFParseException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterExce...
370cf007-fb08-494a-8b1c-e322c0546523
4
private void getKeys() { try { generatedKeys = (List<KeyPair>)((new ObjectInputStream(new FileInputStream(SCRATCH_PATH))).readObject()); } catch( Exception e ) { System.err.println("couldn't get scratch keys: " + e.toString()); System.out.println("generating keys..."); CryptoUtils c = new CryptoUtil...
4757e924-ca8b-42e2-a471-2ac89bf24353
6
public void downloadVideo(String ytLink){ final String[] args = new String[]{"youtube-dl.exe","-c", ytLink}; final String vidString = ytLink.substring(ytLink.indexOf("watch?v=")+8); try { youtubeProc = Runtime.getRuntime().exec(args); downloadThread = new Thread(){ public void run(){ BufferedRea...
c2fd846a-e089-4d10-9953-b8bbba49848d
5
@EventHandler(priority = EventPriority.LOWEST) public void onPlayerRespawn(PlayerRespawnEvent e){ File fichier_language = new File(OneInTheChamber.instance.getDataFolder() + File.separator + "Language.yml"); final FileConfiguration Language = YamlConfiguration.loadConfiguration(fichier_language); final String ...
b8b1507c-aa75-4e3b-873c-7c21de9883fb
2
public boolean remove(Class<?> type) { T removed = provided.remove(type); if (removed != null) { provided.values().removeAll(Arrays.asList(removed)); return true; } return false; }
e0cc425a-a730-42e0-a28f-ede0e7d6f3ab
8
private Polygon rectangleShadow(int x, int y, int shapeX, int shapeY, int width, int height) { int[] xPoints = {0, 0, 0, 0, 0}; int[] yPoints = {0, 0, 0, 0, 0}; //Left side of screen if (x > shapeX + width) { //top if (y > shapeY + height) { xPoints = new int[] {shapeX, ...
d75dc2ed-c8e6-410d-85d2-f76a9ab3f1b3
9
private boolean HandleMiscCommand(String s) { if (s.equals("i") || s.equals("inventory")) { if (! inventory.isEmpty()) { String invStr = inventory.toString(); invStr = invStr.split("\\[")[1]; invStr = invStr.split("\\]")[0]; System.out.println("inventory: " + invStr); } else { System.out.pri...
d7696800-ac4c-475a-9a44-31b1609becd3
3
@Override public void execute(CommandSender arg0, String[] arg1) { if (!arg0.hasPermission("BungeeSuite.admin")) { arg0.sendMessage(plugin.NO_PERMISSION); return; } if (arg1.length == 1) { if (arg1[0].equalsIgnoreCase("reload")) { plugin.reload(); arg0.sendMessage("All configs for BungeeSuite r...
5d119956-064f-40fd-8b48-ee93496e7768
8
public void afficherPiece(Piece piece, JPanel panel) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { panel.getComponent(i + j * 4).setBackground(Color.DARK_GRAY); } } if (piece != null) { int positiony = 0; int ...
bdc59219-4478-4e11-8c37-7934619cb99b
2
public Main () { int nCounters = 3; YourMonitor mon = new YourMonitor(nCounters); DisplayHandler disp = new DisplayHandler(mon); ClerkHandler[] clerk = new ClerkHandler[nCounters]; for (int i=0; i<nCounters; i++) clerk[i] = new ClerkHandler(mon, i); CustomerHandler dispenser = new CustomerHandler(mon); ...
c79ac8b8-3bca-44fc-b53f-c63c8046a6b0
9
public static void main(String[] args) throws IOException { BufferedReader in; StringBuilder out = new StringBuilder(); File f = new File("entrada"); if (f.exists()) { in = new BufferedReader(new FileReader(f)); } else in = new BufferedReader(new InputStreamReader(System.in)); int HPy, ATKy, DEFy, HP...
aea08bb6-bd61-49a6-b580-ba8afaa9c60b
3
public void visitPhiCatchStmt(final PhiCatchStmt stmt) { if (stmt.target() != null) { stmt.target().visit(this); } print(" := Phi-Catch("); final Iterator e = stmt.operands().iterator(); while (e.hasNext()) { final Expr operand = (Expr) e.next(); operand.visit(this); if (e.hasNext()) { pri...
79c4a72e-bf84-4be7-9fe3-b5c33e4698e9
6
private String constructTagAttributesQuery(String regExp, String qualification, String[][] values) { String selectqry = ""; String columnName = ""; if (qualification.equalsIgnoreCase("Tags")) { selectqry = " SELECT TAG_ENTITY_UUID FROM TAGS" + " WHERE UPPER(TAG_NAME)"; columnName = "UPPER(TAG_NAME)"...
08e6fc68-206e-445d-8d41-75c7fd8a30fb
1
@Override public int hashCode() { int hash = 0; hash += (id != null ? id.hashCode() : 0); return hash; }
70e7d38d-e0d9-45e4-a87c-e415fad4c5dc
6
private <T> ArrayList<Method> findTestMethods(T object, String testname) { Method[] allMethods = findAllMethods(object.getClass()); ArrayList<Method> allNamed = new ArrayList<Method>(); Class<?>[] testerParam = new Class[] { this.getClass() }; // make a list of all methods with the given name for (Method me...
458e0679-3711-4e0d-88c6-eb9938a762cf
5
private void subdivide(EChannel cod_info) { int scfb_anz = 0; if ( bigvalues_region == 0) { /* no big_values region */ cod_info.region0_count = 0; cod_info.region1_count = 0; } else { if ( cod_info.window_switching_flag == 0 ) { int index0, index1; /* Calculate scfb_anz */ while (scale...
afcb36b2-0214-42a7-b351-4732d7d5ab5a
3
public ArrayList<String> parseTemplate(ArrayList<String> data,ArrayList<String> expressions){ int position; ArrayList<String> newTemplate = new ArrayList<String>(); for(String line : template){ for(int i = 0; i < data.size();i++){ String temp = expressions.get(i); // Get expression position = line.inde...
164ac95e-c1c5-45c6-804c-c03c5f35a5a9
4
public void upgrade() { if(canUpgrade) { ArrayList<Object> deedNames = new ArrayList<Object>(); for (int i = 0; i < deeds.size(); i++) { Property prop = deeds.get(i); if (prop instanceof Street) deedNames.add(prop.name); } String[] nam...
457806cd-67e5-4b9b-8808-0fe66aeca92a
3
@Override public void keyTyped(KeyEvent e) { /* * if (keys.contains(KeyEvent.VK_COMMA) && speed - 50 >= 1) { * timer.cancel(); speed -= 50; setTimers(); } if * (keys.contains(KeyEvent.VK_PERIOD)) { timer.cancel(); speed += 50; * setTimers(); } */ if (keys.contains(KeyEvent.VK_ESCAPE)) { if (state...
cbd587e7-73fd-460a-a081-a930e4f62304
0
public void decoder(int[] octets_data){ }
5fb3b7fa-d3b0-43b1-ba07-6becb6be8425
8
public Path shortestPath(int x1, int y1, int x2, int y2){ if(x1<0 || x2<0 || y1<0 || y2<0 || x1>(width-1) || x2>(width-1) || y1>(height-1) || y2>(height-1)){ return null; } PathFinder pf = new AStar(this.graph,this); return pf.shortestPath(this.grid.get(new Coordinate(x1,y1)...
e977eae0-e8d3-4589-b1f0-92d1efa073d9
0
public int getSeconds() { return (int) (this.numSamples / this.sampleRateHz); }
790aba3b-245c-41a8-b307-6d0c71e41b34
2
protected void play(InputStream in, AudioDevice dev) throws JavaLayerException { stopPlayer(); if (in!=null && dev!=null) { player = new Player(in, dev); playerThread = createPlayerThread(); playerThread.start(); } }
14af3dfd-262a-4a21-a0f8-f5d2f5c09abf
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...
cd523c58-1a83-4722-b67b-a879e3547ee8
2
public double[] subarray_as_magnitude_of_Phasor(int start, int end){ if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1)); Phasor[] pp = this.getArray_as_Phasor(); double[] magn = new double[end-start+1]; for(in...
d7b134e1-e3a2-49ee-9a5c-50e4e44380c0
5
public String toString() { Set<Product> set = deals_list.keySet(); Iterator<Product> i = set.iterator(); String list = ""; String message; while (i.hasNext()) { Product p = i.next(); Deal d = deals_list.get(p); if (p instanceof UnitProduct && d instanceof ItemPromo) { message = ("Buy " + d.getDea...
7fb173fd-dc8b-4682-88c2-8c65861f81d9
5
public static Map<Integer, Map<Integer, Pearson>> getAllPearson(UserPreferences[] UP, double minPearson) { Map<Integer, Map<Integer, Pearson>> pearsons = new TreeMap<Integer, Map<Integer, Pearson>>(); for (int i = 0; i < UP.length; i++) { for (int j = i + 1; j < UP.length; j++) { Pearson p = new Pearson(UP[i...
f05977a4-0435-49c2-a98a-fa1598704a1d
4
private void updateGegnerPanels(JPanel spielFeld) { List<JPanel> panels = new ArrayList<JPanel>(); for (int i = 9; i >= 0; i--) { for (int j = 0; j < 10; j++) { JPanel panel = new JPanel(); if (gegner.getSpielfeld().getElements()[j][i] .getZustandsIndex() == 2) { panel.setBackground(new FreiZu...
8375713e-598c-4602-81d2-54ffc675969f
7
private Method findSupertypeMethod(Object o, String methodName, Class<?>[] types) { Method matchingMethod = null; Method[] methods = o.getClass().getDeclaredMethods(); methodloop: for (Method method : methods) { if (methodName.equals(method.getName())) { Class<?>[] params = metho...
a04ac88e-c57d-4284-8d31-1861ec74919e
1
public Polygon getPolygon() { Polygon polygon = new Polygon(); for(Point P : vertices) { polygon.addPoint(P.ix, P.iy); } return polygon; }
335b32dd-36b2-4dc1-ae2e-dd72a89dbf93
9
public void start() { synchronized (this) { if (ps != null) { ps.destroy(); ps = null; } running = true; Thread t = new Thread(new Runnable() { @Override public void run() { String[] cmd; if (from.endsWith("TVCardTC4000SD")) { cmd = new String[] { "/usr/local/bin/ffmpeg...
e0c2fa38-b799-4f5b-aa2c-cddd41ba5deb
1
private DocumentBuilder getDocumentBuilder() throws ParserConfigurationException { if(documentBuilder==null) { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilder = documentBuilderFactory.newDocumentBuilder(); documentBuilder....
7261b520-29db-4113-ba10-582ff72a77e8
2
void obfuscatePasswd(String passwd, byte[] obfuscated) { for (int i = 0; i < 8; i++) { if (i < passwd.length()) obfuscated[i] = (byte)passwd.charAt(i); else obfuscated[i] = 0; } DesCipher des = new DesCipher(obfuscationKey); des.encrypt(obfuscated, 0, obfuscated, 0); }
847fa496-4fc2-47db-ba7f-2247dd563e6f
8
public void print(int mm,int yy){ if(mm<0||mm>11) throw new IllegalArgumentException("Month "+mm+" bad, must be 0-11."); System.out.print(months[mm]); System.out.print(" "); System.out.println(yy); System.out.println("Su Mo Tu We Th Fr Sa"); GregorianCalendar calendar=new GregorianCalendar(yy...
8ac92172-f573-48eb-bfae-a365f7afed84
5
public Dialog(int rows,int columns,final Matrix m){ super("matrix input"); final JTextField field[][] = new JTextField[rows][columns]; try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch(Exception e) { ...
2df2f69d-976b-480d-b66a-4dc5549134e1
0
public int getHP() { return hp; }
e6153051-f842-432c-b81c-b4cc0b43759d
9
public static void main(String [] args){ String usage = "java mobilemedia.startMobileMediaServer --hostName <String> --portNum <String> --archName <String>\n"; String hostName=null,portNum=null; String archName=null; for(int i=0; i < args.length; i++){ if(args[i].equals("--hostName")){ hostName = args...
ce63521f-418b-4808-aacc-023c9b4c6678
1
@Override public void mouseExited(MouseEvent e) { if(selection != -1) { setSelection(selection); } e.consume(); }
85373772-a516-46e0-bc4c-cb9bc67134b2
6
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; g2.translate(200,200); GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD); for(int x = 0; x >-100; x--) { for(int y = -100; y < 0; y++) { if(x == 0) { path.moveTo(0, -100); } ...
de8cf5bf-ebf1-456b-9fce-a7693adc82fb
7
void updateDisplay() { long now = System.currentTimeMillis(); // current time in ms long elapsed = now - lastUpdate; // ms elapsed since last update remaining -= elapsed; // adjust remaining time lastUpdate = now; // remember this update time // Convert remaining milliseconds to mm:ss format and display if...
1f7e503c-98c9-490f-a985-b2da0d6bc9eb
2
public boolean equals(Object o) { if (o instanceof Map.Entry) { Map.Entry e = (Map.Entry) o; return key.equals(e.getKey()) && value.equals(e.getValue()); } return false; }
97609672-68b2-4af0-928a-3f2cd272ac1c
5
@Override public void draw(Graphics2D g) { setMapPosition(); if(jiggle){ tracker ++; if(tracker < 2) xmap +=4; else if(tracker < 4) xmap-=4; else { jiggle = false; tracker = 0; } } if (facingRight) g.drawImage(getAnimation().getImage(), (int) ((xScreen + xmap) - (width ...
d183409d-a4cd-4763-bdfa-e4d976a0d072
7
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { final MOB target=this.getTarget(mob,commands,givenTarget); if(target==null) return false; if(target==mob) { mob.tell(L("You already know your own alignment!.")); return false; } if(...
24d7574a-ebad-4ad7-b0cc-1f2d72ca1ed7
0
public DrawableItem getDitem() { return ditem; }
0b73bfd0-5090-4cc5-80dc-f61b1ed76d21
5
private static void run() throws InterruptedException { while (!finished) { Display.update(); if (Display.isCloseRequested()) { finished = true; } else if (Display.isActive()) { Display.sync(FRAMERATE); render(); } e...
caa7f0fb-831f-4a2d-8ef4-3b0c103e941c
8
private static void addFiles(File file, List<String> result, File reference) { if (file == null || !file.exists() || !file.isDirectory()) { return; } for (File child : file.listFiles()) { if (child.isDirectory()) { addFiles(child, result, reference); } else { String path = null; while (child ...
39d62620-80b8-4832-bbf5-f45d5ecf7447
0
public static void main(String[] args){ int h; System.out.println(); }
d0b0979e-a455-42ad-8e80-1b004f0a378e
9
@Override public String rawReviewsData(int pageNum) { HttpPost httppost = null; String responseBody = ""; try { StringBuffer sb = new StringBuffer(postURL); sb.append("id="+ID) .append("/page="+pageNum) .append("/xml"); ResponseHandler<String> responseHandler = new ResponseHandler<String>(){ ...
08d6cc95-6093-4877-a1ba-8a244aa8fe7d
4
private static void generateMainPanel() { // main panel layout GridLayout mainPanelGrid = new GridLayout(1, 2); mainPanel.setLayout(mainPanelGrid); // generating data source data = new DataRetriever(); initMap(data); // map initialization // Flights and crews flightList = new JList(data.generateFlight...
1d4514e9-a5c6-409b-a097-90f4337f0eca
7
public boolean addObject(int x, int y, int width, int length, int height) { if ((x - width) > 0 || (x + width) < map.length || (y - length) > 0 || (y + length) < map[0].length) { for (int i = x - (width / 2); i < x + (width / 2); i++) { for (int j = y - (length / 2); j < y + (length ...
c4c7ebbf-c8c0-4bcd-bc22-ed8b1e25a8a7
9
public void setChecked(boolean checked) { Object newValue = null; // For backward compatibility, if the style is not // set yet, then convert it to a toggle button. if (value == null || value == VAL_TOGGLE_BTN_ON || value == VAL_TOGGLE_BTN_OFF) { newValue = checked ? VAL_TOGGLE_BTN_ON : VAL_TOGGLE_BTN_O...
54a30bf4-b799-407c-aa8a-1ceffedd3dd8
3
public void setRight(PExpLogica node) { if(this._right_ != null) { this._right_.parent(null); } if(node != null) { if(node.parent() != null) { node.parent().removeChild(node); } node.parent(this); ...
00429d4d-fdcc-48e3-9c19-739dcd18601e
7
public DoubledDigraph<SugiyamaNode<V>,SugiyamaArc<V,E>> createLayoutGraph(Digraph<V,E> graph, DigraphLayoutDimensionProvider<V> dimensions, Digraph<V,?> feedback, int horizontalSpacing) { DoubledDigraph<SugiyamaNode<V>,SugiyamaArc<V,E>> result = DoubledDigraphAdapter.getAdapterFactory(factory).create(); Map<V,S...
ac1b8ab8-1fdc-4921-a285-2ebdf5a0c800
9
protected void syncActivation(float[] activeNumbers) { //todo: refactor (it can become faster and easier) HashSet<Model> activeModel2 = new HashSet<>(); activeModels.clear(); if (activeNumbers[0] >= 0) { int speed = 0; int ls = 0; for (Model model : mo...
f41d6d77-998f-43e2-a710-1411a7d40680
8
public void SetParameter(String head, String unit, String digital, String analog, float xfrom, ...
53c593b6-7367-4e24-8408-06d436ac433c
2
private void reduce(){ int[] primeNumbers = getPrimeNumbers(); for (int primeNumber: primeNumbers){ while (isReducible(primeNumber)){ numerator /= primeNumber; denominator /= primeNumber; } } }
8308e0dc-b469-4ef6-a851-93d52fc52242
2
public Object opt(int index) { return (index < 0 || index >= length()) ? null : this.myArrayList.get(index); }
c275e33f-ddda-4bb8-94ae-daf103c3956e
2
private int inserir (Endereco e){ int status = -1; Connection con = null; PreparedStatement pstm = null; try{ con = ConnectionFactory.getConnection(); pstm = con.prepareStatement(INSERT, Statement.RETURN_GENERATED_KEYS); pstm.setStrin...
7f9ded5e-1f7e-403a-87f0-f36a504dc55f
2
private boolean isValidPixel(int pixel) { if (pixel >= 0 && pixel < pixels.length) return true; return false; }
04c08461-130e-4758-881e-4a0ccb90c971
1
private PublicKey byteArrayToPublicKey(byte[] tmp) { PublicKey pubK = null; ByteArrayInputStream bis = new ByteArrayInputStream(tmp); ObjectInput in; try { in = new ObjectInputStream(bis); pubK = (PublicKey) in.readObject(); bis.close(); in.close(); } catch (Exception e) { e.printStackTrace(); ...
e0beafc3-b803-4c69-b492-efdcc5711f3a
8
final public void Class_name() throws ParseException { /*@bgen(jjtree) Class_name */ SimpleNode jjtn000 = new SimpleNode(JJTCLASS_NAME); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); try { Identifier(); } catch (Throwable jjte000) ...
2abfe9d4-9c41-422c-892a-df011035e126
5
public double computeSimilarity(Map<Integer, Double> a, Map<Integer, Double> b) throws Exception { double result = 0.0; // compute inner product of a and b double sum = 0.0; for (int keya : a.keySet()){ if (b.containsKey(keya)){ sum += a.get(keya) * b.get(keya); } } if (...
f6afc6a9-d5c1-4c95-8bcd-c39f77a57356
9
private static void render(String s) { if (s.equals("{")) { buf_.append("\n"); indent(); buf_.append(s); _n_ = _n_ + 2; buf_.append("\n"); indent(); } else if (s.equals("(") || s.equals("[")) buf_.append(s); else if (s.equals(")") || s.equals("]")) ...
f91553a6-162c-453c-89eb-21e02a96d1a7
9
public static void gerenciarCarros() { int opcao; String chassi, cor, modelo, placa; float diaria; int ano; ArrayList<Carro> carros; while (true) { opcao = menu.menuCarros(); switch (opcao) { case 1: System.out.p...
611081e2-1a13-43bd-aed8-e6c446b95a9d
3
protected void skipAttributes(DataInputStream input) throws IOException { int count = input.readUnsignedShort(); for (int i = 0; i < count; i++) { input.readUnsignedShort(); // the name index long length = input.readInt(); while (length > 0) { long skipped = input.skip(length); if (skipped == 0) ...
ef1f70c1-ff9e-4398-936d-121dc4e04960
3
public void close() { try { if ((this.connect != null) && (!this.connect.isClosed())) { this.connect.close(); } } catch (SQLException ex) { System.out.println("Error: " + ex); } }
656e081e-ca1b-444a-9204-4b5b25cf0a93
2
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); response.setCharacterEncoding("UTF-8"); request.setCharacterEncoding("UTF-8"); String msj_exito =...
c47b59a4-24ab-4a8d-957e-02bdd34fb1ad
6
public Tr(HtmlMidNode parent, HtmlAttributeToken[] attrs){ super(parent, attrs); for(HtmlAttributeToken attr:attrs){ String v = attr.getAttrValue(); switch(attr.getAttrName()){ case "align": align = Align.parse(this, v); break; case "bgcolor": bgcolor = Bgcolor.parse(this, v); bre...
f542d922-d635-4884-89a5-930cde3af462
5
private final void parseDoctype() throws IOException { int nesting = 1; while (true) { switch (read()) { case -1: fail(UNEXPECTED_EOF); break; case '<': nesting++; break; case '>': if (--nesting == 0) { return; } break; default: break; } } }
608fbcc3-c616-4b4f-bcb8-b4d0b782901d
4
public JSONObject toJSONObject(JSONArray names) throws JSONException { if (names == null || names.length() == 0 || this.length() == 0) { return null; } JSONObject jo = new JSONObject(); for (int i = 0; i < names.length(); i += 1) { jo.put(names.getString(i), this....
c2a74d3d-0d27-49de-b1e2-1465afcd612e
9
protected void keyTyped(char par1, int par2) { field_73905_m = false; if (par2 == 15) { completePlayerName(); } else { field_73897_d = false; } if (par2 == 1) { mc.displayGuiScreen(null); } ...
17e750c7-46b1-4b0c-b208-7b285dec0796
5
public void faltaEnvido(boolean envido, boolean envidoEnvido, boolean realEnvido, Humano jugadorH, Contador contador, boolean mentir){ System.out.println("\n"+this.getNombre()+": Falta Envido"); //condicional para ver si el humano quiere if(jugadorH.cantoFaltaEnvido()){ System.out.println(jugadorH.getNombre()+...
a5038647-4972-431a-8f0b-4dad8940a778
5
private boolean findUnexploredCellWithDist(int rowCount, int colCount) { boolean foundMin = false; for(int rowID = 0;rowID < rowCount ; rowID++){ for(int colID = 0;colID < colCount;colID++){ for(int drcID = OREIT_MIN;drcID <= OREIT_MAX;drcID ++){ if(!explored[rowID][colID][drcID] && distance[ro...
df14836d-30e5-405b-896a-b885187f1bb7
4
public static void validateCity(City city) throws TechnicalException { if (city == null) { throw new TechnicalException(MSG_ERR_NULL_ENTITY); } if ( ! isStringValid(city.getName(), NAME_SIZE)) { throw new TechnicalException(NAME_ERROR_MSG); } if ( ! isStri...
06d36e71-97b0-4a3e-a8af-e9fa27708201
1
private int[] createBowl(int [] platter) { int[] bowl = new int[NUM_FRUITS]; int sz = 0; while (sz < bowlsize) { // pick a fruit according to current fruit distribution int fruit = pickFruit(platter); int c = 1 + random.nextInt(3); c = Math.mi...
3cbebacd-85d6-4fbb-91ff-5ddfef9c5892
5
private static int compareIp(final InetAddress adr1, final InetAddress adr2) { byte[] ba1 = adr1.getAddress(); byte[] ba2 = adr2.getAddress(); // general ordering: ipv4 before ipv6 if (ba1.length < ba2.length) { return -1; } if (ba1.length > ba2.length) { ...
697590ba-a102-48d6-9f61-71022a0a9596
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...
afe2455e-f89d-41cc-bceb-fceab69bca8f
1
@Test(expected = IllegalArgumentException.class) public void testPickUpActionTestInventoryFull() throws InvalidActionException { // Max size of inventory is 6 for (int i = 0; i < 6; i++) player.getInventory().add(new LightGrenade(grid)); player.incrementActionsWithMaxActions(); final LightGrenade item = ...
7a32ab32-2986-4094-a433-1647d8bc2948
4
public SpriteSheet(String path) { BufferedImage image = null; try { image = ImageIO.read(this.getClass().getResourceAsStream(path)); } catch (IOException e) { e.printStackTrace(); } if (image == null) { return; } this.path = path; this.width = image.getWidth(); this.height = image.getHeight(...
2bb4059e-460b-4df3-9275-6248c67a1cad
2
public void calculateDeltaFunctionValuesForOutputNeuron(double teachingInput) { myDelta = 0.0; if (this.neuronType != ENeuronType.Output) throw new UnsupportedOperationException( "This function is only for the use with Output-Neurons! This is a " + this.neuronType.toString()); myDelta = teachingInp...
4e9b4d47-db7b-4b14-9e98-fa682e07944d
7
private static void identifySeparator(File fname) { separators.put(",", new int[2]); separators.put(";", new int[2]); separators.put(":", new int[2]); separators.put("|", new int[2]); separators.put("\t", new int[2]); separators.put(" ", new int[2]); java.io.Buffe...
90ea8831-1242-4081-933d-818dee09c6bb
3
public void writeBooleanArray(boolean[] v) throws IOException { final int size = v.length; final int byteCount = NBTInputStream.ceilDiv(size, 8); final byte[] data = new byte[byteCount]; this.writeInt(size); for (int boolIndex = 0, byteIndex = 0, bitIndex = 7; boolIndex < size; boolIndex++) { if (v[bo...
c4c7dfc5-569c-4202-9aaf-75e66e141a78
3
public SingleTreeNode uct(StateObservationMulti state) { SingleTreeNode selected = null; double bestValue = -Double.MAX_VALUE; for (SingleTreeNode child : this.children) { double hvVal = child.totValue; double childValue = hvVal / (child.nVisits + this.epsilon);...
1986d586-e3a3-49d9-bfba-1dc4db11f768
9
protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) { Color backColor = tabPane.getBackgroundAt(tabIndex); if (!(backColor instanceof UIResource)) { super.paintText(g, tabPlacement, font, m...
b2ca7e8a-151e-4b9b-926a-0ec5dcf5f10c
8
public void updatePosition() { if (xPos < xDestination) xPos++; else if (xPos > xDestination) xPos--; if (yPos < yDestination) yPos++; else if (yPos > yDestination) yPos--; if(xPos == xDestination && yPos == yDestination) ...
3181e507-8f53-446e-af93-cd0845933a53
9
public void toDot(String filename) { System.out.println("Writing " + filename); BufferedWriter w = null; try { FileWriter fstream = new FileWriter(filename); w = new BufferedWriter(fstream); w.write("digraph G {\n"); // nodes for (PDAState s : states) { String id = Util.dotId(s); if ...
a85409ea-e058-458c-a1a4-6af8ff00a677
2
public double standardDeviation_as_Complex_ConjugateCalcn() { boolean hold = Stat.nFactorOptionS; if (nFactorReset) { if (nFactorOptionI) { Stat.nFactorOptionS = true; } else { Stat.nFactorOptionS = false; } } Complex[] cc = this.getArray_as_Complex(); double variance = Stat.varianceConjugat...
71678e77-e569-4b51-b6e6-76781561de7e
5
public static boolean readUserSelectedFile() { if (fileDialog == null) fileDialog = new JFileChooser(); fileDialog.setDialogTitle("Select File for Input"); int option = fileDialog.showOpenDialog(null); if (option != JFileChooser.APPROVE_OPTION) return false; File selected...
219e9310-78b0-4859-8551-3cac19ea6092
8
public static synchronized JMenu createFileMenu(){ JMenu fileMenu = new JMenu("File"); // Open File JMenuItem item = MenuBarUtils.createItem("Open", "open.png", new ActionListener() { public void actionPerformed(ActionEvent e) { FileSummary fileSummary = FileUtils.openF...
7fe38319-01c0-4c00-a89f-a68c5f71da1d
9
public ArrayList<String> wordBreak(String s, Set<String> dict) { if (s == null || s.length() == 0) { return null; } int len = s.length(); boolean[] t = new boolean[len + 1]; t[0] = true; for (int i = 0; i < len; i++) { if (!t[i]) continue; for (String a : dict) { int length = a.length(); ...
5eefa2d7-a7ba-4deb-b795-9ca590f79a25
9
protected Cursor loadCursor(String address, int x, int y) { if (address == null) return null; File f = null; if (Page.isApplet() || FileUtilities.isRemote(address)) { URL u = null; try { u = new URL(address); } catch (MalformedURLException e) { e.printStackTrace(); return null; } ...
d1c56daf-49b0-4d72-a8ae-b4b72a5f5e92
0
public void setTransform(AffineTransform af){ curTransform = af; }
275064f3-894a-4f28-a11f-7dbc06e23a26
4
public static void moveSelectedY(int y) { if (Main.selectedId != -1 && !Main.getSelected().locked) { RSInterface rsi = Main.getInterface(); if (rsi != null) { if (rsi.children != null) { rsi.childY.set(getSelectedIndex(), rsi.childY.get(getSelectedIndex()) + y); } } } }
f6623bcf-d345-4604-bf0f-cea1a0219382
2
public boolean satisfies(ArrayList<Boolean> b) { //since a clause is a disjunction, if one variable is //true, the whole clause is true. for(Variable v: variables) { boolean varBoo = b.get(v.getNumber()-1); //get boolean //for corresponding variable. ...
32297c68-5fc3-42b9-a6a3-a892ba089f93
8
@Override public String buscarDocumentoPorFechaVencimiento(String fechaven1, String fechaven2) { ArrayList<Venta> geResult= new ArrayList<Venta>(); ArrayList<Venta> dbVentas = tablaVentas(); String result=""; Date xfechaven1; Date xfechaven2; Date f1; ...
6f426ebd-77b1-44ed-837b-700d97c2e0df
3
@Test public void testPutGetMessagesInOrder() { try { int noOfMessages = 5; final CountDownLatch gate = new CountDownLatch(noOfMessages); final ArrayList<Message> list = new ArrayList<Message>(noOfMessages); for (int i = 0; i < noOfMessages; i++) { Message msg = new MockMessage("TestMessage"); li...
846c2f69-13c7-4fe8-9113-8a53177fdb24
2
public String getFieldrefName(int index) { FieldrefInfo f = (FieldrefInfo)getItem(index); if (f == null) return null; else { NameAndTypeInfo n = (NameAndTypeInfo)getItem(f.nameAndTypeIndex); if(n == null) return null; else ...
454d5894-6af0-418c-81de-88e1a9c1fd36
7
public static void main(String[] args) { Scanner s = new Scanner(System.in); String str; int temp = 0; int last = -1; Boolean consecutive = true; System.out.println("Please enter a string of positve integers."); System.out.println("Please enter '...