method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
bb6bec7c-0376-4814-85a5-fb9b9acee40d
4
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); if (rotation % 2 == 1) { g.drawOval(75, 75, 50, 50); g.drawLine(0, 100, 75, 100); g.drawLine(125, 100, 200, 100); } if (rotation % 2 == 0) { g.drawOval(7...
f6d23a04-f5af-42a7-91a9-c7c6c72e9249
3
public DodgeballTeam autoSelectTeam() { if(teamPlayerCount[TEAM_1.ordinal()] > teamPlayerCount[TEAM_2.ordinal()]) { return TEAM_2; } if(teamPlayerCount[TEAM_1.ordinal()] < teamPlayerCount[TEAM_2.ordinal()]) { return TEAM_1; } return rand.nextBoolean() ? D...
7f48c05d-e575-4a9d-bf12-00a42b98f12a
5
private void cargar_Campos (int cta){ try{ this.vaciarCampos(); r_con.Connection(); PreparedStatement pstm = r_con.getConn().prepareStatement( "SELECT *" + "FROM Cuentas "+ "WHERE Cta_Nro = "+cta); ...
f451e3b8-7bf9-4668-9deb-d4fa2d5a4105
4
public void addExclusive(SignalArea areaToAdd) { final SignalArea current = areaToAdd; // list of already treated mutEx areas, which are mutually exclusive, and // exclusive with the 'current' area final List<SignalArea> currentMutEx = new LinkedList<>(); while (!isEmpty()) { ...
20e0193e-9929-4cb5-a737-fdb2ebc6b10c
6
private void quicksort(int low, int high) { int i = low, j = high; // Get the pivot element from the middle of the list int pivot = list.get(low + (high-low)/2); // Divide into two lists while (i <= j) { // If the current value from the left list is smaller then the pivot // element then get the next e...
4da0617b-dfe7-43e1-870f-4bbe25bc56b6
5
private float calculateExposureFromExif(ExifSubIFDDirectory exif) { float fNumber = 0.1f; try { fNumber = exif.getFloat(ExifSubIFDDirectory.TAG_FNUMBER); } catch (MetadataException e) { } float exposureTime = 0.005f; try { exposureTime = exif.getFl...
cd7bb2dc-dbd9-47dd-852d-8944f6628650
7
@Override public void actionPerformed(ActionEvent ae) { try { String op = ae.getActionCommand(); switch(op) { case "Listar Documentos": DAOCrlv daoCrlv = new DAOCrlv(); ViewGerenciarCrlvs gCrlvs = new ViewGerenciarC...
a05403a6-2d5a-4437-b8da-6d76333ce778
0
private void setProductFromProperty() { this.product.setName(this.name); this.product.setPrice(Float.parseFloat(this.price)); this.product.setQuantity(this.quantity); this.product.setCode(this.code.toUpperCase()); this.product.setDescription(this.desc); }
3bd0dc8e-1281-42a1-b005-c618eb7ac9db
1
public static Car createCar(String carType){ if (carType.equals("TruckI")){ return new TruckI("black", (int) (Math.random() * 5) ); } else return null; }
bbfa93dd-28e7-4e99-bee9-f48ae21f9cb0
1
private void allocMemory () { int row = stackedToOneColMat[0].getRowDimension(); int col = stackedToOneColMat[0].getColumnDimension(); int rowD = reshapedProductUVBaseMat[0].getColumnDimension(); tempDiff = new TempDiff(row, col, codeCbCr); lambda = new Lambda(row, col, codeCbCr...
0d5a291a-627a-4022-8999-74790dcd6b21
9
@Override public void propertyChange(PropertyChangeEvent e) { Object source = e.getSource(); int value = 0; if (source == this.textRed) { value = (int) this.textRed.getValue(); if ((value >= 0) && (value <= 255)) { this.sliderred.setValue(value); } } else if (source == this.textGreen) { value =...
83a6ba4d-90f8-4fad-9c01-89664bfee0b6
9
private void search(File folder) { if (folder == null || !folder.isDirectory()) { return; } File[] objects; if (filter != null) { objects = folder.listFiles(filter); } else { objects = folder.listFiles(); } if (objects == null...
502c8f09-bb90-4320-af6f-53889d28bc49
2
private void removeRowsInternal(int[] indexes) { Row[] rows = new Row[indexes.length]; int i; Arrays.sort(indexes); for (i = 0; i < indexes.length; i++) { rows[i] = getRowAtIndex(indexes[i]); } preserveSelection(); notifyOfRowsWillBeRemoved(rows); for (i = indexes.length - 1; i >= 0; i--) { mRow...
c49db98f-f469-4c27-9afd-f746b940ccac
8
@Override public void run() { try { // Eclipse doesn't support System.console() BufferedReader console = new BufferedReader(new InputStreamReader(System.in)); ConfigManager config = NetBase.theNetBase().config(); String targetIP = config.getProperty("net.server.ip"); if ( targetIP == null ) { Sys...
751485f7-75ea-4c49-ae99-40bd77c4c03b
7
private final void step6() { j = k; if (b[k] == 'e') { int a = m(); if (a > 1 || a == 1 && !cvc(k-1)) k--; } if (b[k] == 'l' && doublec(k) && m() > 1) k--; }
ba309f87-4a65-46fe-9a95-bfb8cc92a898
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...
60cc9cb6-de6a-4fb4-8b90-587dc1d1a874
1
public T extractMax() { if (size == 0) throw new ArrayIndexOutOfBoundsException("the array is already empty"); T head = heap.get(0); heap.set(0, heap.get(--size)); siftDown(0); return head; }
b324f66d-b576-4af0-a67c-0023d648f814
3
public Boolean validarFecha(String fecha) { Boolean est = false; if (fecha != null) { if (Pattern.matches("\\d{2}/\\d{2}/\\d{4}", fecha)) { String dato[] = fecha.split("/"); Integer dia = Integer.parseInt(dato[0]); Integer mes = Integer.parseIn...
8b8c6cf9-8e88-40d7-8e7c-b070e1439148
7
public List<SelectItem> getmenuItemsLocation() { List<SelectItem> menuItemsLocation = new ArrayList<SelectItem>() { private static final long serialVersionUID = 3109256773218160485L; { try { //Connect to database conn = DriverMan...
71398d4f-2eeb-460a-b16b-ac3493b2e0fe
7
public NoAddReason getNoAddReason(Locatable locatable) { if (locatable == this) { return NoAddReason.ALREADY_PRESENT; } else if (locatable instanceof Unit) { return (!canCarryUnits()) ? NoAddReason.WRONG_TYPE : (((Unit)locatable).getSpaceTaken() > ...
2f315187-eab3-4a1d-a33f-6656504b21c9
4
public HashMap<Direction, MazeField> getRatSurrounding(MazeRat rat) { HashMap<Direction, MazeField> surround = new HashMap<Direction, MazeField>(); try { surround.put(Direction.NORTH, maze[rat.position.y - 1][rat.position.x]); } catch (ArrayIndexOutOfBoundsException e) { } try { surround.put(Direc...
5592cf7c-dbbd-470b-a1c8-f0b3feb5f8b7
9
public void flushSentence(DataElement data) { if (data == null) { return; } if (elementsCache.isEmpty()) { return; } if (elementsCache.size() == 1 && conditions.size() == 0) { throw new IllegalStateException("Unexpected situation at " + data + ...
5e5633f8-6f16-47b5-a837-2b4e3cde7adf
8
final void method3720(int i, int i_377_, int i_378_, int i_379_, int i_380_, int i_381_, int i_382_, int i_383_, int i_384_, int i_385_) { if (i_379_ != 0 && i_380_ != 0) { if (i_382_ != 65535 && !(((TextureDefinition) ((AbstractToolkit) this).aD4579.getTexture(i_382_, -6662)) .aBoolean209)) { ...
22fca58f-9642-4112-b97e-1a6dac98fc5b
6
public void recursivePrint(SplayTreeNode root, int parentPosition, Node innerNode, Node p) { Node innerParent; int position; if (root != null && root.value != null) { int height = heightRootToNode(root); int nextTop = getRectNextTop(height); if (innerNode !...
704605a8-69da-439c-a2d0-215a667e01fa
7
public void compFinalResult() { do { iStage++; compAllocation(); if (compDistribution()) { /* deadline can not be satisfied */ if (!bDeadline) { System.out.println("THE DEADLINE CAN NOT BE SATISFIED!"); return; } else { System.out.println("\nNEW ROUND WITHOUT CHECKING:"); dEv...
133e4795-56af-48b8-a6cf-bc2dd3a37cd0
2
@Override public void printAnswer(Object answer) { if (!(answer instanceof String[])) return; for (String choice: (String[]) answer){ System.out.print(choice + " "); } }
26694480-3781-48f0-853a-cf05cbe158ea
3
protected byte[] fetchClass(String classname) throws Exception { byte[] b; URL url = new URL("http", server, port, "/" + classname.replace('.', '/') + ".class"); URLConnection con = url.openConnection(); con.connect(); int size = con.getContentLength...
1f0dfd1c-5745-4be2-b7b7-5a8968e99f5f
9
private Node insert(Node h, Key key, Value value, int ht) { int j; Entry t = new Entry(key, value, null); // external node if (ht == 0) { for (j = 0; j < h.m; j++) { if (less(key, h.children[j].key)) break; } } // internal node ...
97a1323e-ea90-49af-94bd-3dffd1ec4f01
7
public static Game updateGame(Game g) { System.out.println("updating game"); PreparedStatement updateGame = null; String updateStatement; if(g.isWinner() || g.isTie) updateStatement = //logic for prepared statement "UPDATE Game SET g_winner = ?, g_playersTurn = ? WHERE g_id = ?"; else ...
39124eb4-93ed-4957-b829-ca5e8ce9c763
1
public Item getItem(int index) { if(index < size) { return itemList[index]; } return null; }
cb928690-1e17-4d1c-a8a9-a2503b8bd7e8
7
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = ""; StringBuilder out = new StringBuilder(); int game = 1; dp = new int[MAX][MAX]; while ((line = in.readLine()) != null && line.length() != 0) { int[] data...
1466e6d4-f727-4ad6-989f-611ba1ac4a40
5
public int getDistancia(Nodo<E> pNodoA, Nodo<E> pNodoB){ int resp=0; Nodo<E> iterador=pNodoA; while(iterador != pNodoB || iterador != null){ iterador= iterador.getSiguiente(); resp++; } if(iterador==null){ resp=0; iterador=pNodoB; ...
b64ba599-8019-4f00-8857-b3ce4b88eae8
9
public static DatabaseFieldConfig fromReader(BufferedReader reader) throws SQLException { DatabaseFieldConfig config = new DatabaseFieldConfig(); boolean anything = false; while (true) { String line; try { line = reader.readLine(); } catch (IOException e) { throw SqlExceptionUtil.create("Could no...
bbfc771f-b164-4a28-9a98-ca33efb8ad88
0
public DragonBoneWarAxe() { this.name = Constants.DRAGONBONE_WAR_AXE; this.attackScore = 16; this.attackSpeed = 21; this.money = 1800; }
4fe5d6c0-bc36-4208-8e06-2085e08fee64
1
public void move(int dx, int dy) { ((Rectangle) shape).x += dx; ((Rectangle) shape).y += dy; for (PathItem pi : this.getLines()) { pi.move(dx, dy); } updateCornerRects(); canvas.repaint(); }
524b5750-b735-4412-94a0-27b5e60fa748
8
private void selectCrew() { squareSelector.reset(); squareSelector.setCriteria(new SquareCriteria() { private final String desc = "Select: Crew"; public String getDescription() { return desc; } public boolean isSquareValid( SquareSelector squareSelector, int roomId, int squareId ) { if ( roomId < 0 |...
01be5e41-1a83-4280-ba23-381ea77103d0
6
StyleRange[] getStyles(InputStream stream) { try { StyleRange[] styles = new StyleRange[256]; int count = 0; BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); String line; while ((line = reader.readLine()) != null) { StringTokenizer tokenizer = new StringTokenizer(line, ";"...
92500b7a-4570-48a0-8afd-a421d28ed176
3
private Collection<Long> readListOfNoteIds() { final File idsFile = getIdsFile(); if( !idsFile.exists() || !idsFile.canRead() ) { return Collections.emptyList(); } BufferedReader r = null; try { r = FileHelper.getBufferedUtf8FileReader( idsFile ); return readListOfNoteIdsFromReader( r ); } catch...
54516e17-9c8a-45e3-bbf6-54c8e134d92e
5
private int[] getBoundaryPositions(ByteBuffer b, byte[] boundary) { int matchcount = 0; int matchbyte = -1; List<Integer> matchbytes = new ArrayList<Integer>(); for (int i = 0; i < b.limit(); i++) { if (b.get(i) == boundary[matchcount]) { ...
968d8f30-400b-4ca5-a15d-3d6bf3e72f1b
4
public boolean isOptOut() { synchronized(optOutLock) { try { // Reload the metrics file configuration.load(getConfigFile()); } catch (IOException ex) { if (debug) { Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.ge...
b6c9bd35-da2e-4d33-9e62-61e6d13c77b3
8
public static IBAN compose(String country, String... parts) { if( country == null ) throw new IllegalArgumentException(); else { final StringBuilder sb = new StringBuilder(); if( !normalize(country, sb) ) throw new FormatException(country, INVALID_CHARACTER); else { final String code = ...
b662169a-7b0a-4699-9103-5befc71a0a23
3
public void parse() { String currentLine = ""; try { String line = reader.readLine(); while (line != null) { currentLine = line; parseLine(line); line = reader.readLine(); } label.setText("Drawing Complete"); } catch (IOException e) { label.setText("IO Exception"); } catch (ParseExc...
8b26608e-a903-41ec-9b73-2f763543a119
8
public int nouvellePalette(LinkedList<Integer> id_colis) { if (id_colis == null || id_colis.size() == 0) { return -1; } try { PreparedStatement ps = co.prepareStatement("INSERT INTO palette DEFAULT VALUES;"); int result = ps.executeUpdate(); ...
15c96538-ca0d-4d88-9c89-38b5568d76ff
1
@Override protected String processContents(File file, String contents) { for (int i = 0; i < matches.size(); i++) { String match = (String) matches.get(i); String replacement = (String) replacements.get(i); contents = StringTools.replace(contents, match, replacement); } //return StringTools.replace(cont...
0cadd8e5-e059-4917-8952-4b15d32383a6
3
private byte[] getBytes(java.io.File file) { byte[] b = new byte[(int) file.length()]; FileInputStream fileInputStream = null; try { fileInputStream = new FileInputStream(file); fileInputStream.read(b); for (int i = 0; i < b.length; i++) { System.out.print((char) b[i]); } fileInputStream.close(...
b23b8dd6-22d7-4a42-aab9-64a9c8206b21
6
static protected void UpdateLineColumn(char c) { column++; if (prevCharIsLF) { prevCharIsLF = false; line += (column = 1); } else if (prevCharIsCR) { prevCharIsCR = false; if (c == '\n') { prevCharIsLF = true; } else line += (column = ...
f792ad9b-a762-4e40-a2d9-da65f71d004a
7
private void check(String permissions, String owner, long size, FileTime lastModified, String name) { if (permissions == null || permissions.isEmpty() || owner == null || owner.isEmpty() || size < 0 || name == null || name.isEmpty()) throw new IllegalArgumentException(); }
cc79f79b-d968-44ab-bb44-0dc4fce489c9
0
public ServerModuleSerialize(String name, StateModule state, Exception exception) { setName(name); setState(state); setException(exception); }
ca10c5e2-574a-4ae9-8032-d4cca73b4f4f
5
public int charat(int x) { int l = 0, r = text.length() + 1; while (true) { int p = (l + r) / 2; int a = advance(p); if ((a < x) && (l < p)) { l = p; } else if ((a > x) && (r > p)) { r = p; ...
9515e243-bc9e-40ce-a21a-d3b02572adfc
5
public void connect() { if (ipAddrS == null || ipAddr == null){ tsLog.appendLine( "Notcher Unit #" + index + " never responded to " + "roll call and cannot be contacted."); return; } tsLog.appendLine("Opening connection with Notcher..."); try { ...
2343e031-4edd-4432-80c1-c347d522df23
3
private void saveAllData() { if (GameData.getCurrentGame() != null) GameData.getCurrentGame().writeData(); if (!Bonus.getAllQuestions().isEmpty()) Bonus.writeData(); if (settings != null) saveSettings(); }
5a107549-21ae-4814-a918-19ef6ca0c498
8
@Test public void testReadWriteDeadlock() throws Exception { System.out.println("testReadWriteDeadlock constructing deadlock:"); SimpleAction p0_read = new SimpleAction(p0, Permissions.READ_ONLY); SimpleAction p1_read = new SimpleAction(p1, Permissions.READ_ONLY); SimpleAction p1_write = new SimpleActi...
870750a9-6cc0-407f-a31f-5222dca1533a
6
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] params) { LinkedList<String> args = new LinkedList<String>(Arrays.asList(params)); if (args.size() == 0) { return false; } CommandSender targetPlayer = sender; if (arg...
0a3a4a15-178e-424b-87b9-ee0853701ddc
9
private boolean isInputValid() { String errorMessage = ""; if (firstNameField.getText() == null || firstNameField.getText().length() == 0) { errorMessage += "No valid first name!\n"; } if (lastNameField.getText() == null || lastNameField.getText().length() == 0) { errorMessage += "No valid last n...
b7bfdcb3-b30d-42b9-925a-ac0e6e625e6f
9
private void printRecord(String s) { StringReader sr = new StringReader(s); LineNumberReader lnr = new LineNumberReader(sr); Font typeface = new Font("Monospaced", Font.PLAIN, 12); Properties p = new Properties(); PrintJob pjob = getToolkit().getPrintJob(this, "Print report", p); if (pjob != nul...
f5c56fd7-da6e-4afe-9202-2dc043bf7c54
6
public void insert(ItemRecord a) { Node newNode = new Node(a); // make new node // newNode.i = a; int id = newNode.iData; if (root == null) { // no node in root root = newNode; size++; return; } else { ...
c32b0f09-eea0-41c7-b195-7063cbb74d13
5
public CheckResultMessage checkTF05(int day) { int r1 = get(20, 2); int c1 = get(21, 2); int r2 = get(23, 2); int c2 = get(24, 2); if (checkVersion(file).equals("2003")) { try { in = new FileInputStream(file); hWorkbook = new HSSFWorkbook(in); if (0 != getValue(r1 + 4, c1 + day, 2).abs().compar...
b4b4d762-f1c0-4b2e-b60e-086d05da8511
3
public void setExtensions(Map<String, Object> exts) { if (exts != null && exts.size() > 0) { if (extensions == null) { extensions = new Extensions(); } extensions.setExtensions(exts); } else { extensions = null; } }
d6982df3-d901-4f32-ad71-80a9604b306e
6
public static Cons getTypes(Stella_Object instanceref, Keyword directorasserted) { { Stella_Object instance = Logic.getInstance(instanceref); Cons result = Stella.NIL; if (instance == null) { return (null); } if (directorasserted == LoomApi.KWD_DIRECT) { { LogicObject d = nu...
a74659bf-e022-4f6b-8eb7-e6bbf6ef1d41
7
public void compareDevsAndMerge() { // System.out.println("Comparamos y vemos si mergeamos"); boolean change = true; while (change) { change = false; for (int i = 0; i < clusters.size() && !change; i++) { for (int j = i + 1; j < clusters.size() && !change; j++) { Cluster c1 = clusters.get(i), c2 = ...
c51ff920-b984-4ba2-81c1-60404920b969
0
private void listen() { ListenThread thread = new ListenThread(); thread.start(); }
92ec66a9-57cf-4095-b902-2c1a9c0b8075
7
public Object nextValue() throws JSONException { char c = this.nextClean(); String string; switch (c) { case '"': case '\'': return this.nextString(c); case '{': this.back(); return new JSONObject(this); ...
e369edb3-ea51-42f1-9960-b7b0028e13fa
4
public static void main(String args[]) throws IOException, FtpIOException, FtpWorkflowException { Logger log = Logger.getLogger("MAIN"); log.setLevel(Level.DEBUG); Properties ptSource = new Properties(); ptSource.setProperty("connection.host","127.0.0.1"); ptSource.setProp...
4b416d7b-f259-43c4-a8de-89ccdf132028
1
public void ballUnderFloorAction() { if (--lifes <= 0) { gameOver(); return; } ballConroll.drawBall(); ballConroll.throwBall(); }
bb91ecd8-bf87-4caa-a848-d2b2c607d5b9
2
public static CtClass[] getParameterTypes(String desc, ClassPool cp) throws NotFoundException { if (desc.charAt(0) != '(') return null; else { int num = numOfParameters(desc); CtClass[] args = new CtClass[num]; int n = 0; int i = 1;...
5672cb12-c1c8-481b-9466-b944580bf30d
6
public static int largestSubarraySum(int[] arr) { int[] sum = new int[arr.length]; int[] start = new int[arr.length]; int startIndex = 0, maxSum = Integer.MIN_VALUE, i, index = 0; String result = ""; for(i = 0; i < arr.length; i++) { if(i - 1 < 0) sum[i] = arr[i]; else { sum[i] = java.lang.Math....
8c999d42-e1fa-4e51-acff-bd30422e9801
7
public static void init() { System.out.println(Runtime.getRuntime().availableProcessors() + " available cores detected"); try { Settings.init(); } catch (IOException e) { e.printStackTrace(); } if (networkConnection == null) { player = new Pla...
0bbed31d-d121-469b-902b-2af65a5d9305
9
public void draw(Object obj, Component comp, Graphics2D g2, Rectangle rect) { Color color = (Color) AbstractDisplay.getProperty(obj, "color"); if (color == null && obj instanceof Color) color = (Color) obj; Color textColor = (Color) AbstractDisplay.getProperty(obj, "textColor"); ...
9135c230-7139-4119-b4d3-07172670a25a
9
private static Collection<Neighbour> getNeighbours(final int[][] matrix, final int i, final int j) { final List<Neighbour> result = new LinkedList<>(); for (int start = i - 1; start <= i + 1; ++start) { for (int startY = j - 1; startY <= j + 1; ++startY) { if (((start == i) && (startY == j)) || (start < 0) |...
0931588a-5f71-42db-b691-f0a85cd82390
6
public void borrarShpFiles(String filename){ String path = Config.get("ResultPath") + "/" + Config.get("ResultFileName"); System.out.println("["+new Timestamp(new Date().getTime())+"] Terminado de leer los archivos "+filename+"."); boolean borrado = true; // Borrar archivo con el mismo nombre si existe, por...
03e464cf-2e62-454a-8475-d885a4694d4e
1
public void visit_iastore(final Instruction inst) { stackHeight -= 3; if (stackHeight < minStackHeight) { minStackHeight = stackHeight; } }
168a7c29-f5a6-4304-9a3e-ddc17e814269
2
public void switchState(EnumState switchToState) { switch(switchToState) { case TITLE_STATE: changeState(title); break; case GAME_STATE: game = new TicTacToe(this); //remakes the game so that the last tile states aren't still maintained ...
9ee4ce4c-1e64-4874-bbbc-bd56ef4bbab9
5
public void update() throws ESellException { if (id == null) // Petition wurde noch nicht mit der DB abgeglichen. throw new ESellException(ESellException.ErrorCode.NO_ENTRY_ERR); makeConnection(); PreparedStatement preparedStatement = null; if (conn != null) { try { // Statement vorbereiten S...
74b6ee1e-636a-4cfd-b48f-4097f8074707
4
public DBObject readCommentsByPhotoId(String id) { DBObject photo = database.getCollection(PHOTO_COMMENT_COLLECTION).findOne(new BasicDBObject("_id", id)); if (photo == null) { photo=new BasicDBObject(); } photo.removeField("favesCount"); photo.removeField("itemOwner"...
429d9d96-5500-467a-b3af-40cdbccb1812
8
private static int cost(int i, int j) { // System.out.println("i" + i); // System.out.println("j" + j); if (cache[i][j] >= 0) return cache[i][j]; if (i + 1 == j) return (input[i] == 'x' ? 0 : 1); // 1 element. if (i == j) return 1; // no elements int minCost = Integer.MAX_VALUE; ...
d3019a97-c9dd-402c-a7d1-bfb945a185be
5
void bfs(node1 n) { q.add(n.data); visited.put(n.data, 1); while(true) { if(q.size()==0) return; elem=q.remove(); System.out.print(elem+" "); ArrayList<String> t=adj.get(elem); if(t.size()>0 ) { Iterator<String> it=t.iterator(); while(it.hasNext()) { String temp=it.next(); if(visited.get(temp)!=1)...
fa950cc5-75a3-45c0-a377-5a9b1599e008
7
public Path<DirectedGraphNode> search(final DirectedGraphNode source, final DirectedGraphNode target, final WeightFunction<DirectedGraphNode> w) { OPEN.clear(); GSCORE.clear(); PARENT.clear(); OPEN.add(source, 0.0); GSCORE.put(sourc...
b727a966-9528-4b06-9ad5-853a1a732c29
0
public String getFilePath() { return filePath; }
f33bc9f4-8639-4d2b-9bae-c162c509784c
9
private CardPower isTwoPairs(int[] valueCounts) { int highCardA = -1; int highCardB = -1; int kickerCard = -1; for (int i = valueCounts.length - 1; i >= 0; i--) { if (valueCounts[i] == 2) { if (highCardA >= 0) { highCardB = i; break; } highCardA = i; } } if (highCardA >= 0 && hig...
7195d2bd-6a7f-4eea-8d44-60fbdca37dc4
8
public void addFigures(int type,int originX,int originY, int width, int height){ if(type == Drawable.LINE){ figures.add(new Line(originX, originY, width, height, figures.size(),toolbox.getBordure())); }else if(type == Drawable.RECTANGLE){ figures.add(new Rectangle(originX, originY, width, height, figures.size...
29ff0bce-432e-497e-8a47-a01a234ab0a7
6
public void jouer() { /* Initialisation de la partie */ this.initialiserJoueurs(); this.distribuerCartes(); this.placerPionsJoueurs(); this.numeroTour = 0; Random generateurLanceDe = new Random(); List<Position> depPossJoueurCourant = new LinkedList<Position>(); /* Début de la partie */ while (!th...
a0cd62f0-dcac-49a1-89d6-c4a3ab2ea18e
4
* @return Returns the label for the given cell. */ public String getLabel(Object cell) { String result = ""; if (cell != null) { mxCellState state = view.getState(cell); Map<String, Object> style = (state != null) ? state.getStyle() : getCellStyle(cell); if (labelsVisible && !mxUtils.isTr...
601c6779-e2ef-4bfa-923b-91f8a2adee0e
5
@Override public void actionPerformed(ActionEvent e) { switch (e.getActionCommand()) { case "Start": Handler.game.startGame(); break; case "Pause": Handler.game.pauseGame(); break; case "Continue": Handler.game.resumeGame(); break; case "Rules": Handler.game.helpGame(); br...
a64ee8e9-26b8-4e92-a840-6f29e369d797
3
private void labelUpdateMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_labelUpdateMouseClicked // check so eveything went ok with the update if (updateNamn() == 1 && updateTel() == 1 && updateMail() == 1) { PanelHelper.cleanPanel(PanelHelper.getMainFrame().getMfRight()); ...
5644563b-d905-435c-b497-4aba28b2b085
4
public static final int getPreferredHeight(Font font, String text) { int height = 0; int length = text.length(); if (length > 0) { int fHeight = getFontHeight(font); char ch = 0; for (int i = 0; i < length; i++) { ch = text.charAt(i); if (ch == '\n') { height += fHeight; } } if (ch...
b6f8c75d-bbab-44b2-bc21-09a62f872edd
0
public void setValidTime(String validTime) { ValidTime = validTime; }
b4307366-c30b-4a5d-ab0d-465aeb616747
4
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Departamento other = (Departamento) obj; if (this.id != other.id) { return false; } ...
008eac30-8b3a-44ad-845a-9e4586c35a7b
1
private boolean jj_2_79(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_79(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(78, xla); } }
f0c7c352-ec46-4caa-96cc-85d4142dad4a
0
public static void main(String [] args) { Human human = new Human("Max"); System.out.println(human.getName()); Student student = new Student("Snaya"); System.out.println(student.getName()); House house = new House(); house.setHuman(student); Teacher teacher = ne...
e750fd65-89cd-4dd6-9768-6703912a68d9
5
@Override public int compare(Object o1, Object o2) { if ((o1.getClass() != Vertex.class && o1.getClass() != Point.class) || (o2.getClass() != Vertex.class && o2.getClass() != Point.class)) return 0; Vertex v1 = (Vertex)o1; Vertex v2 = (...
11d51c41-f0ac-4d7f-81de-3dbcb6763e8a
5
private void assignSlime(int i, int j) { //Roll Over if(i == -1) i = 9; else if(i == 10) i = 0; if(j == -1) j = 9; else if(j == 10) j = 0; //Assignment if(grid[i][j] != RoomState.PIT) grid[i][j] = RoomState.SLIME; }
940247de-9904-42c4-bbca-67f53fadaddb
9
public boolean isPlayerKingPieceInCheck(){ if (isPlayerKingInCheckFromPieceVerticallyUp() || isPlayerKingInCheckFromPieceVerticallyDown() || isPlayerKingInCheckFromPieceHorizontallyLeft() || isPlayerKingInCheckFromPieceHorizontallyRight() || isPlayerKingInCheckFromPieceDiagonallyUpLeft() || isPlay...
ffbea4ff-9ef9-4e07-8b42-4601d4d1fd50
5
public void finishUp(){ while(level > 0) { if (level == 4) { level -= 1; } else if (level == 3) { autoIndentation(); level -= 1; result += "</subsection>\n"; } else if (level == 2) { autoIndentati...
9f74bbd5-0fe1-4549-a1e4-d4c3aa46ce13
0
public boolean isCaptureMove(Piece piece, Field from, Field to) { return piece.canAttack(this.window.board, from, to); }
465f86c5-4018-47bb-b438-a8f6f53359c7
7
private boolean matchesStepFour() { RubiksCube rc = this.initialRcConfig; // First we turn the entire cubie upside down to match the previous steps for (int i = 1; i <= rc.getSize(); i++) { rc.move(new DefinedMove(Move.DOUBLE_ROLL, i)); } if (! matchesStepThreePlaceTheMiddleLayerEdges()) return f...
d1ab2884-4857-40e9-8580-0102751d9866
3
public static boolean substringMatch(CharSequence str, int index, CharSequence substring) { for (int j = 0; j < substring.length(); j++) { int i = index + j; if (i >= str.length() || str.charAt(i) != substring.charAt(j)) { return false; } } return true; }
60baddb3-7577-47e9-a858-01e8631aa5a1
6
@SuppressWarnings("unchecked") public void loadPossibleTreasure() throws IOException, ClassNotFoundException { FileInputStream fis = new FileInputStream(TreasureHunt.getInstance().getDataFolder() + "/numberOfTreasures.xml"); if(fis == null) return; ObjectInputStream ois = new ObjectInputStream(fis);...
bdc626da-9c4a-400a-b7dc-d0f55a8a68b5
2
@Override public Implique getImplique(String iId) throws BadResponseException, InvalidJSONException { Implique i = null; JsonRepresentation representation = null; Representation repr = serv.getResource("intervention/" + interId + "/implique", iId); try { representation = new JsonRepresentation(repr); ...
ac49edc0-8a17-4bc8-9898-5362e2940579
1
public void run () { getEnvironmentData(); getEnvironmentExits(); while (true) { /**try { getEnvironmentData(); Thread.sleep(600000); // 10 minute sleep } catch (InterruptedException e) { // Meh :3 }**/ }...
dd12d3f9-8ff5-4b1e-bd78-1ce377252799
2
public void testToStandardDays_years() { Period test = Period.years(1); try { test.toStandardDays(); fail(); } catch (UnsupportedOperationException ex) {} test = Period.years(-1); try { test.toStandardDays(); fail(); ...