method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
58e41228-ed02-4779-8a3a-b4e35a4b1e31
5
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Funcionario other = (Funcionario) obj; if (this.Id != other.Id) { return false; } ...
48e0e318-a829-4692-a35d-a8a1d77296b4
8
private boolean depthFirstSearchRecursive(VertexType vertex, VertexType fromVertex, PreWorkPostWorkHandler<VertexType> handler) throws InvalidVertexException { //TODO:Implementing non-recursive version //int vertexId = vertex.getId(); vertex.setMark(true); if (handler != null...
ab8902e0-a980-4ad5-825d-94fecba2c9f8
4
@Override public <T> T getObject(Class<T> clazz, Long id) { Session session = null; T obj = null; try{ session = sessionFactory.getCurrentSession(); session.beginTransaction(); obj = (T)session.get(clazz, id); ...
ca4b5fe4-ed51-49f9-854b-ea720707ce7e
3
private int FindTileCol(int mouseX) { for (int i = 0; i < tileCol; i++) { if(mouseX > i * tileWidth && mouseX < (i + 1) * tileWidth) { return i; } } return -1; }
62d58ed6-d507-4ec9-b34b-7f9e0a943a75
0
public Stage getPrimaryStage() { return stage; }
60c7cbe4-47ff-4ed0-bc7f-15674f97a9da
0
@Override public void endResizingFrame(JComponent f) { //System.out.println("endResizingFrame"); super.endResizingFrame(f); }
1e2784a8-5fb8-4e1b-98bc-6ea6b93701dd
9
@Override public int castingQuality(MOB mob, Physical target) { if(mob!=null) { if(target instanceof MOB) { final Room R=((MOB)target).location(); boolean found=false; if(R!=null) for(int r=0;r<R.numInhabitants();r++) { final MOB M=R.fetchInhabitant(r); if((M!=null)&&(M!=mo...
fae01190-0e12-4b03-bd5f-367676448718
4
@Test public void whoIsTheBiggest() { for (int n1 = 999; n1 > 0; n1--) { for (int n2 = 999; n2 > 0; n2--) { int candidate = n1 * n2; if (PalindromicNumber.isPalindromic(candidate)) { if (candidate > biggest) { biggest = candidate; } } } } System.out.println(biggest); }
caaf0570-e110-44e7-9137-a152341c05e7
4
public DataTable getDataTable() throws Exception { int l = bitString.length(); int bits[] = new int[l]; // Initialize both arrays that will contain // the voltage and the time axis. int ticks = DIVISIONS * l; x = new Double[ticks]; y = new Double[tick...
56ea8842-f872-4edd-92c6-31e1bf0b70ae
5
@Override public boolean removeItem(String itemID) { Statement stmt = null; try { stmt = con.createStatement(); if (itemID.length() == 9) { // item is a book stmt.executeUpdate("delete from Book where ISBN = " + itemID); } else if (itemID.length() == 8) { // item is a periodical stmt.executeUpdat...
cdbc7729-f10b-417a-a86d-edb3661585f1
9
private boolean move(int d) { boolean changed = false; int in, out; if (d % 2 == 0) { out = col; in = row; } else { out = row; in = col; } int[] line = new int[in]; for (int o = 0; o < out; o++) { for (int i = 0; i < in; i++) { ...
71d167a9-268d-4065-bacf-65efc3d82910
9
public Location[] findAvailableMoves(char[][] board){ Location[] available_locations_l; boolean[][] available_locations = new boolean[4][12]; // Track how many are available int count = 0; // Check every spot for (int i = 0; i < 4; i++){ for (int j = 0; j < 12; j++){ // Anywhere is legal on fi...
33bd183d-a601-4144-bfa2-0275a623c0b0
5
private String getDuration() { if (this.start == 0) return "not started"; if (this.stop == 0) return "not finished"; // calculate duration and matching unit double duration = this.stop - this.start; String unit = "ms"; if (duration > 1000) { duration /= 1000; unit = "sec"; if (duration > 6...
110de194-a8d1-4c2d-9e0c-8af0c17e502e
4
private String resolveOperation(String field) { if (field.endsWith("!")) return "!="; if (field.endsWith(">")) return ">"; if (field.endsWith("<")) return "<"; if (field.endsWith("%")) return " LIKE "; return "="; }
ded137a4-e2f8-4f9d-9ca5-c7d81301546c
0
public int getAdjacentAntsRed() { return adjacentAntsRed; }
15c09e22-750b-4484-9f70-558b43777da9
1
private ProfilesAPI getProfilesApi() { if (profilesApi == null) { profilesApi = new ProfilesAPI(config); } return profilesApi; }
b94fc989-d487-436e-9e78-87ea390897e2
4
private boolean resolveCollision(String name) { int row = 0; for (Row i : ((KeystrokeTableModel) myTable.getModel()).rows) { if (i.key.equals(name) && row != myRow) { boolean ret = JOptionPane.showConfirmDialog(null, String.format(Runner.editorInterface.getS...
dec0495f-944c-4021-bf9f-d4754bc18960
9
public void performSetupMenu(User u) throws MenuExitException{ String menuString = "Configure Spot The Fed Game:\r\n"; menuString += "(01) Add Player \r\n"; menuString += "(02) Remove Player \r\n"; menuString += "(03) List Players \r\n"; menuString += "(04) Config Round Times \r\n"; menuString += "(05) Star...
bc407b5d-338d-4fc5-bc8b-712e48e9510b
8
private void addStreets(int[][] temp, int startx, int starty) { for(int i = 0; i < 6; i++) { int roadX = startx - (random.nextInt(3) + 1) * 3 + 3; int roadY = starty - (random.nextInt(3) + 1) * 3 + 3; int roadW = (random.nextInt(2) + 1) * 3; int roadH = (random.nextInt(2) + 1) * 3; for(int x = roadX; x...
0fcbe220-164f-4e47-87d8-ebce0f2f18bc
4
protected boolean sendCancelGridlet(int tag, Gridlet gl, int gridletId, int destId) { if (tag != GridSimTags.GRIDLET_CANCEL) { return false; } long gridletSize = 0; if (gl != null) { gridletSize = gl.getGridletOutputSiz...
a6e22163-6ec4-4127-bb46-5173e44ff75f
9
public static Severity fromLevel(final Level level) { if (level == null) { throw new IllegalArgumentException("Level cannot be null"); } final int levelValue = level.intValue(); if (levelValue >= org.jboss.logmanager.Level.FATAL.intValue()) { ...
1faa9806-3523-4832-a86a-2f91eceac7f8
6
public static String getSourceByLanguage(Language lang) { if(lang == Java) return ".java"; else if(lang == Pascal || lang == Delphi) return ".pas"; else if(lang == Cplus) return ".cpp"; else if(lang == C) return ".c"; else if(lang == Python) return ".py"; else return ".tx...
695ce620-8e64-4688-b522-f9e43c426878
1
public static PropertyDescriptor[] listPropertyDescriptors(Object o) { final BeanInfo beanInfo; try { beanInfo = Introspector.getBeanInfo(o.getClass()); } catch (IntrospectionException e) { throw new AnnoYAMLException(e); } PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors(); return ...
8d42068a-d20a-4613-98fb-51ad15dbb5cd
9
public static String stringToHTMLString(String string) { StringBuffer sb = new StringBuffer(string.length()); // true if last char was blank boolean lastWasBlankChar = false; int len = string.length(); char c; for (int i = 0; i < len; i++) { c = string.charAt(i); ...
8426ba2d-646b-4466-b252-33fa56d78e6b
5
public units.Base CreateUnit(int type, int owner, int xx, int yy, boolean active) { switch (type) { case 0:return new units.Infantry(owner, xx, yy, active); case 1:return new units.Mechanic(owner, xx, yy, active); case 2:return new units.SmallTank(owner, xx, yy, active); case 3:return new units.Artillery(...
10132694-15eb-45dd-ad71-461108ffe84f
2
public SongEntry [] getSongs () throws IOException { int temp = getFirstFreeEntryOffset (); // a lot of these calculations feel quite odd // they're from the c code int blocks = temp / BLOCKSIZE; int count = 8 * blocks; temp %= BLOCKSIZE; if (temp > 0) blocks++; count +...
a2eb12ef-aa90-43e3-af5b-cef303193882
8
public static double[][] readMatrix(Path path, HamaConfiguration conf, int rows, int columns, int blockSize) { int finalRows = getBlockMultiple(rows, blockSize); int finalCols = getBlockMultiple(columns, blockSize); double[][] matrix = new double[finalRows][finalCols]; SequenceFile.Reader reader = null; ...
246fe2aa-83d3-48a0-b49f-73bd320c3d83
4
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((hasHead() && head() != null) ? head().hashCode() : 0); result = prime * result + ((hasTail() && tail() != null) ? tail().hashCode() : 0); return result; }
03af0f97-e910-42ee-98a5-68a05369eacb
0
public void setServiceEmployeeId(String serviceEmployeeId) { this.serviceEmployeeId = serviceEmployeeId; setDirty(); }
99a87973-db6f-4652-b522-e9d8426e9dc1
3
private void validaData(Date dateToValidate) throws ValidacaoException { if (!validacao.obrigatorio() && dateToValidate == null) { return; } SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); String result = sdf.format(dateToValidate); if (result.length() != 1...
ac10f8d2-cd8c-4e8a-8bde-c6b3cd7efed1
2
public TreeWorker (String jsonPath, String saveFolder, String name, String type, boolean createTree, boolean save) throws IOException{ this.jsonPath = jsonPath; this.saveFolder = saveFolder; this.name = name; this.type = type; if(createTree)createJsonTree(); if(save)saveTreeWorker(); //experimental - save...
9d5be7d4-2521-4f5a-876d-6b97d1489c3c
0
public void setType(TypeEntity types) { this.types = types; }
b0609fae-c65c-4170-8846-e4070fdc13ee
9
public static PatchGroup read(final InputStream inputStream) throws IOException { int line = 1; final BufferedReader in = new BufferedReader(new InputStreamReader( inputStream)); try { final int patchCount = Integer.parseInt(in.readLine()); line++; final PatchGroup result = new PatchGroup(); fo...
cf2a2248-b06c-4816-bda1-41cd8a85ad81
9
public List<Integer> findSubstring(String S, String[] L) { List<Integer> list = new LinkedList<>(); if (S == null || L == null) return list; Map<String, Integer> covered = new HashMap<String, Integer>(); ArrayList<Integer> res = new ArrayList<Integer>(); int wordlength = L[0].length(); int wordnum = L.le...
3f93a9da-9434-41ea-9995-e619b841503b
6
private Boolean addOperator(CalculatorReader expressionReader) throws BinaryOperatorException { String el = expressionReader.getSymbol(); BinaryOperator lastBinaryOperator = expressionStack.binaryOperator.get(el); if (null != lastBinaryOperator) { expressionReader.incPosition(); ...
98e30900-f847-4398-9785-5526d7ebba73
4
private List<Reducer> estimateReducers(List<Mapper> newMapperList, boolean useRuntimeMaxJvmHeap) { int fReducerNum = finishedConf.getMapred_reduce_tasks(); if(fReducerNum == 0) return null; //if(isMapperConfChanged == false && isSplitSizeChanged == false && isReducerConfChanged == false) // return job.getR...
82dc3484-0794-426b-9aef-3f8df03e8d74
8
public void action(GraphData graphData) { GraphModel g1 = graphData.getGraph(); GraphModel g2 = new GraphModel(false); g2.setIsEdgesCurved(true); for(Vertex v : g1.getVertexArray()) { Vertex tmp = new Vertex(); tmp.setLocation(v.getLocation()); g2.ad...
3fa27599-479a-4562-8ed7-6726c153e747
5
public void displayBoard(Board board) { this.board = board; int gridNums = 1; int rows= board.rows; // pass these values in int columns=board.columns ;// pass these values in int nums [][] = new int [rows][columns]; for (int i=0; i<rows; i++){ ...
9ba69a69-e3d8-4f18-8358-a10eb829f562
2
public void valueChanged(ListSelectionEvent lse) { selectedAccount = null; if (!lse.getValueIsAdjusting() && lijst.getSelectedIndex() != -1) { selectedAccount = lijst.getSelectedValue(); } boolean accountSelected = (selectedAccount != null); accountDetails.setEnabled(...
c2c5d3f0-8a6f-49e9-bc95-ad268f2035a3
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof EtlLink)) { return false; } EtlLink other = (EtlLink) object; if ((this.id == null && other.id != null) || (thi...
48a4d146-c683-44f6-9c45-c956fb8f0d41
5
public CheckResultMessage checkDayofMonth9() { int r1 = get(13, 5); int c1 = get(14, 5); date(); if (checkVersion(file).equals("2003")) { try { in = new FileInputStream(file); hWorkbook = new HSSFWorkbook(in); if (!(getValueString(r1 + maxDay, c1 - 1, 3).equals(maxDay + "日"))) { return...
cd1c5476-035a-42d5-b143-9ea38f12838d
4
public static void makeLevel2() { int size = 25; initializeLevel(size, 22, 12); //First for loop for(int i = 1; i<5; i++){ matrix.rowWall(i, 4, 12); matrix.rowWall(i, 16, 19); } matrix.rowWall(4, 1, 19); //Second for loop for(int i = 4; i<9; i++){ matrix.columnWall(i, 4, 7); matrix....
7b33614c-7b79-48e7-9b16-44ad8e569cb0
8
private void appendFieldToTheDS(Object object, Field field, StringBuilder signature) throws IllegalAccessException { if (!field.isAccessible()) { field.setAccessible(true); } Object fieldValue = field.get(object); if (null != fieldValue) { if (fieldValue instanceo...
8bbba27e-fdd5-490f-b765-56810455b624
7
@Override public void handleStartTag(Tag tag, MutableAttributeSet attributes, int pos) { if (Tag.TABLE.equals(tag) && !gotFirstTable) { gotFirstTable = true; } if (Tag.TR.equals(tag) && !gotFirstRow) { gotFirstRow=true; } ...
dc42f2c2-88b9-4ef7-870c-77217947432d
7
public boolean isOutOfBound(short n, Dimension bound) { if (n < 0) throw new IllegalArgumentException("n<0"); if (n >= path.length) throw new IllegalArgumentException("overflow"); if (bound == null) return false; if (x[n] < -bound.width / 2 || x[n] > bound.width / 2 || y[n] < -bound.height / 2 || y[n] ...
4df3eb0d-205e-4d29-a785-e25ef90ea12f
4
@Override public void MacOSXDriverNotFound(String installer) { String text = "fuse4x is required in order to get the file system working.\n\nI'm launching the installer, which requires additional rights."; switch (usemode) { case GUI: JOptionPane.showMessageDialog(null, text); break; case CONSOLE:...
0d4df56a-a4df-43ad-9ba3-a3bfd42c6e0d
9
public void paintComponent(Graphics g) { g.clearRect(0, 0, getWidth(), getHeight()); int y = 30; g.setColor(Color.black); g.drawString("Species tree", 20, y); y+=30; g.setColor(Color.black); g.drawString("species tree", 50, y); g.setColor(ParamManager.cLineagesIn); g.fillRect(15, y-15, 30, 2...
492f0350-5a60-40d0-8cdf-5e1c0197918f
9
@SuppressWarnings("unused") public void sendNotificationToUser(String nick, String message) { byte[] buf = new byte[1000]; String str = (ServerMain.cypher .doCeaserCypher("##NOTIFICATION~[Server]: ~" + message)); int q = 1000; int w = 0; int e = 0; // Logger.writeInfo(str.length() + ""); if (true) {...
ebe19077-8513-45f8-9dd8-886721d5d581
5
public static void main(String[] args) throws FileNotFoundException { int num_rows = 15; String filename = "problem018.txt"; int[] [] pyramid_array = new int[num_rows] [num_rows]; File txtfile = new File(filename); Scanner pyramid = new Scanner(txtfile); for (int i=0; i<num_rows; i++) { for (int j=0...
d93803f5-8755-4f48-8c61-8935fcb0b5aa
9
public static int choosePivot(int offset, int len, int type) { int pivot; switch (type) { //choose the first element case 0: pivot = offset; break; //choose the last element case 1: pivot = offset + len - 1; break; //choose the median case 2: if (len < 3){ pivot = offset; ...
6186555b-2623-478d-9e11-1108cf14f602
0
protected void onPart(String channel, String sender, String login, String hostname) {}
0e95663d-d038-4434-8d4f-245fd8abaac4
0
public static Contents contents() { return new ParcelContents(); }
521449b4-7df3-4e85-85ed-d3e7643008f2
8
private Dimension layoutSize(Container target, boolean preferred) { synchronized (target.getTreeLock()) { // Each row must fit with the width allocated to the containter. // When the container width = 0, the preferred width of the container // has not yet been calculated so lets ask for the maximum. int ...
928d01b9-4844-4daa-884a-d6fed84a2b0b
5
public int findMaxValue(int sackSize, int N, int val[], int wts[]) { int maxVals[][] = new int[N+1][sackSize+1]; for(int i=0; i<=N; i++) { for(int w=0; w<=sackSize; w++) { if(i==0 || w==0) maxVals[i][w] = 0; else if(wts[i-1]>w) maxVals[i][w] = maxVals[i-1][w]; else { maxVals[i]...
6a1df8c1-222a-4e43-b36c-7e3b924565cc
1
public void visitMultiANewArrayInsn(final String desc, final int dims) { buf.setLength(0); buf.append(tab2).append("MULTIANEWARRAY "); appendDescriptor(FIELD_DESCRIPTOR, desc); buf.append(' ').append(dims).append('\n'); text.add(buf.toString()); if (mv != null) { ...
e9053b4f-4d3e-42c3-bafa-527cfe817d72
9
private String int2str(int value){ if(value==512) return "N"; if(value==1536) return "S"; StringBuilder sb = new StringBuilder(); int baseValue = value>>9; char base='E'; char base2='N'; switch (baseValue){ case 0: base='E'; ...
40919072-d273-4b06-a224-c81797785ac7
1
public void createLogsFolderAndFile() { try { LOG_PATH = PROJECT_PATH + OS_SEPARATOR + "logs"; LOG_PATH = createFolder(LOG_PATH); LOG_FILE_NAME = LOG_PATH + OS_SEPARATOR + "AutomationLog_" + resultFileNameSf.format(dt) + ".log"; createFile(LOG_FILE_NAME); ...
a9c4d4f4-9229-45dd-85a9-6e432551bfab
0
@Override public boolean supportsComments() {return false;}
e73e4436-120d-423c-9005-8d468bfa7499
4
public static void main(String[] args) throws Exception { boolean server = (args.length == 1 && args[0].compareTo("--server") == 0); String id = UUID.randomUUID().toString(); Window window = new Window((server) ? "server" : "client"); window.setVisible(true); Game game = new Game((server...
2c88c9bf-85f0-4b22-9cb9-c70a84b98abe
8
private boolean update(ClassPool cp, String oldName, String typeName) throws BadBytecode { if (typeName == null) return false; else if (oldName == null) return true; else if (oldName.equals(typeName)) return false; else if (...
5457516d-9cb4-4fb2-85df-e7aafd5b02db
8
public static boolean isInterComparable(Iterable<?> objects) { Iterator<?> iter = objects.iterator(); if (!iter.hasNext()) { return true; } Object o = iter.next(); if (o == null || !(o instanceof Comparable)) { return false; } while (iter.h...
d0fa97df-8a08-4aa2-b02f-00ee358fff82
4
public void playDraw(int card, boolean fromDiscard, int new_discard, boolean visible){ animate_visible = true; animate.visible = visible || fromDiscard; animate.x = fromDiscard ? pile_discard.x : pile_draw.x; animate.y = fromDiscard ? pile_discard.y : pile_draw.y; animate.card = card; if (fromDiscard)...
dec57cef-051a-4f19-961c-dac57314d306
1
public void insertBeforeMethod(CtMethod origMethod, CtMethod beforeMethod) throws CannotCompileException { try { transformers = new TransformBefore(transformers, origMethod, beforeMethod); } ...
7b0b161f-9bac-4c2d-a12f-9742df316f22
4
public void addSaldo(double monto, boolean registrarComoDeposito){ if(activa){ this.saldo+=monto; if(registrarComoDeposito){ montoDepositos+=monto; } }else{ saldo+=(monto-(monto*0.2)); if(registrarComoDeposito){ montoDeposit...
9984558b-6bd6-47f6-9297-fc1f23f4cec3
4
int f(int k, int[] prices) { //这种解法的最大时间复杂度为 N*N*1/k 其中k是大于2的常数 if (prices.length < 2) return 0; //dif代表要达到"宇宙"最大收益 还需要(不够)的买入卖出机会 int dif = prices.length / 2 - k; for (int i = 0; i < dif; ++i) { prices = merge(prices); } int result = 0; for (int ...
2b3aa997-da48-4922-9b40-a2eeadb9f1da
5
public void UpdateMenu(){ if(start){ start = false; switch(menuItem){ case 0: Host(); break; case 1: Join(); break; case 2: break; case 3: menuRunning=false; gameRunning=false; System.exit(0); break; ...
543c79a5-1d96-478b-a0ca-869c9bfb27f5
5
private List<Gate> getPreparedCircuit(List<Gate> gates, int n1, int addedInputs, int startOfP2Output, int m2, int gatesToBeAdded) { for (Gate g: gates) { int leftIndex = g.getLeftWireIndex(); int rightIndex = g.getRightWireIndex(); int outputIndex = g.getOutputWireIndex(); if (outputIndex >= startOfP...
a905ae4e-2c8b-4b43-8874-8bfe2e69ab70
3
@Test public void RegularGrid() { //Make two identical models but one parallel and one sequential AbstractModel paraModel=DataSetLoader.getRegularGrid(100, 800, 40, new ModelParallel()); AbstractModel seqModel=DataSetLoader.getRegularGrid(100, 800, 40, new Model()); //Step through each model stepNumber step...
ee8a9e93-ecb5-41e2-a823-e2c1ff7a2db5
0
public TravelTrip() { }
c590ded7-dc1e-4696-ac2c-0791d6870470
5
private void downloadFile(String adress, String localFileName) { OutputStream out = null; URLConnection conn; InputStream in = null; try { URL url = new URL(adress); out = new BufferedOutputStream( ...
efa25256-974b-4d58-9624-2d5a69a525e8
9
private void generateMoveList() { moveList = new ArrayList<Integer>(); int curX = startX, curY = startY; boolean upperCase = startUpperCase; for(int i=0;i<name.length();i++) { char c = name.charAt(i); int newX = getCharX(c); int newY = getCharY(c); if(newX == -1 || newY == -1) throw new RuntimeE...
f0e76a32-2b36-4267-8901-a393efb64279
3
public void deleteDupNode(ListNode head){ if(head == null) return; Hashtable table = new Hashtable(); ListNode pre = null; while(head.next!=null){ if(table.contains(head.val)){ pre.next = head.next; }else{ table.put(head.val,true); ...
c35a4a27-accb-4997-8b6d-405d40531d0f
1
@Override public List<Integer> save(List<Country> beans, GenericSaveQuery saveGeneric, Connection conn) throws DaoQueryException { try { return saveGeneric.sendQuery(SAVE_QUERY, conn, Params.fill(beans, (Country bean) -> { Object[] objects = new Object[3]; objects...
1e50ef55-0d55-423f-8c98-78cf95bc3eb2
7
@Override public String toString() { String map = ""; for (int i = 0; i < 15; i++){ for (int j = 0; j < 11; j++){ if (rooms[i][j] != null && (rooms[i][j].hasVisited() || isAdjacent(rooms, i, j))) if (i == currentY && j == currentX) map += "[*]"; else map += rooms[i][j]; else m...
a2d23a26-a2ae-4ed8-bd9c-b18076aff4ed
4
public static void save(String filename) { File file = new File(filename); String suffix = filename.substring(filename.lastIndexOf('.') + 1); // png files if (suffix.toLowerCase().equals("png")) { try { ImageIO.write(offscreenImage, suffix, file); } catch (IOExce...
880bb696-69e3-474e-8404-13b24dad36f4
2
public User getUser (String username) throws SQLException { String uName = null; String uIp = null; int uStatusInt = 0; String getUser = "SELECT * " + "FROM " + tableName + " WHERE " + keyUsername + "=\"" + username + "\""; ResultSet rs = this.database.statement.executeQuery(getUser); while (rs.next...
8f1f626a-c668-455a-8b8f-f3a32135c7dd
9
@Override public void positionnementAleatoire() { Iterator iterator = this._partie.getParametre().getBateaux(this._partie.getParametre().getEpoque()).keySet().iterator(); while(iterator.hasNext()) { Random rand = new Random(); int sens = rand.nextInt(2)+...
70a3f4dd-63ed-48d2-a858-ef2ff0b10f46
9
public int longestValidParentheses(String s) { if (s == null || s.isEmpty()) { return 0; } Stack<Integer> parenthese = new Stack<Integer>(); boolean []pos = new boolean[s.length()]; for (int i = 0; i < pos.length; i++) { pos[i] = false; } char[] allStr = s.toCharArray(); for (int i = 0; i < allS...
fe52c5a1-abbf-4f34-a2b6-6379b8df87f7
5
private boolean isValidKeyboardInput(int keycode){ return keycode == KeyEvent.VK_SPACE || keycode == KeyEvent.VK_DOWN || keycode == KeyEvent.VK_RIGHT || keycode == KeyEvent.VK_LEFT || keycode == KeyEvent.VK_UP || keycode == KeyEvent...
1587f3fd-beac-43e5-8012-c14d0f8e9280
5
private DATAPacket receiveRRQanswer() { byte[] data = new byte[DEFAULT_PACKET_SIZE]; DatagramPacket dtg = new DatagramPacket(data, data.length); try { //écoute de la réponse du serveur this.getSocket().receive(dtg); if (DATAPacket.isDataPacket(dtg)) { ...
760690c2-d99a-4f6c-bb2c-17097d27893d
4
@Override public void register() throws ServiceRegistrationException { try { POA rootPOA = POAHelper.narrow(orb_.resolve_initial_references("RootPOA")); RepairHandlePOA repairServant = provider_.get(); rootPOA.activate_object(repairServant); String[] ID = Repa...
8d9b4b59-41e9-472c-90bb-86de7502b506
3
public static HelloCorba.Hello narrow (org.omg.CORBA.Object obj) { if (obj == null) return null; else if (obj instanceof HelloCorba.Hello) return (HelloCorba.Hello)obj; else if (!obj._is_a (id ())) throw new org.omg.CORBA.BAD_PARAM (); else { org.omg.CORBA.portable.Delegate...
10eab6e2-b10f-4152-a1f5-3f0604d30fa0
4
private float[][] getQuad(int x, int y, int size) { float[][] quad = new float[size][size]; float element; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { if ((y + i) >= height || (x + j) >= width) { element = 0; ...
fe42b191-9939-4750-b362-ffeab4bb53f5
0
public Automaton getAutomaton() { return myAutomaton; }
3c759c5e-d930-4a2d-b0cf-d639f8cec373
0
public void setUrl(String url) { this.url = url; }
7b84322e-d5e1-49cb-a0b6-52013e54ef90
2
@Override public Token login(String username, String password, String... scopes) throws IOException { if (username == null || password == null) { throw new IllegalArgumentException("username or password is null"); } final Request request = addScope(Request.to(Endpoints.TOKEN).with( ...
8fa34d12-fcfb-433e-b683-857dcf56ae5d
6
@Override public void onBlockPlace(BlockPlaceEvent event) { final Block block = event.getBlock(); final Player player = event.getPlayer(); final PlanArea area = BuildingPlanner.plugin.areaManager.getAffectedArea(block); if (area == null) { return; } if (!area.checkPermission(event.getPlayer(), OpType.MO...
abe7c96b-3c1d-458e-ac7e-7990d22ce39d
4
public static List<String[]> readCSVContentAll() { CSVReader reader = null; List<String[]> list = null; try { // 读取指定文件中的信息 reader = new CSVReader(new FileReader(CSV_SOURCE)); // 跳过首行header信息 reader.readNext(); // 读取剩余所有信息内容 list = reader.readAll(); } catch (FileNotFoundException e) { logge...
98d2debe-315e-4e1a-a86b-9a4c13201052
9
private void setupToolBar() { // Create a transparent panel to hold the toolbar content toolbarPanel = new CustomPanel(toolBarFile); toolbarPanel.setOpaque(false); // Create a transparent panel for the toolbar panel to hold toolbarContent = new JPanel(); toolbarContent.setOpaque(false); // Setup the hea...
1a35bd53-70e4-492a-845a-5412b06a459b
6
@EventHandler public void SlimeResistance(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getSlimeConfig().getDouble("Slime.Resista...
5a505d96-6038-46c8-82b1-f2f0d412d34c
6
public static boolean zipFile( String sourceDir, String destinationFile, String... excludes ) { File srcDir = new File( sourceDir ); if( !srcDir.exists() ) return( false ); // Delete the file if it exists. File destFile = new File( destinationFile ); if( destFile.exi...
9bd60cd3-52bf-4720-9216-1356463b2d37
1
private static boolean getMouseDown(int mouseButton) { return getMouse(mouseButton) && !lastMouse[mouseButton]; }
66db4ed3-c6ba-4a58-8ae6-ecec652ff622
7
public static void main(String[] args) { // TODO Auto-generated method stub String failureSettingFile = ""; GetOpt getopt = new GetOpt(args, "i:f:"); serverId = 1; try { int c; while ((c = getopt.getNextOption()) != -1) { switch(c) { case 'i': serverId = Integer.parseInt(getopt.get...
696a0dd4-8670-48ae-a35b-3eaf577ad21d
5
private void startActionPerformed(ActionEvent e) { String location = locationBox.getSelectedItem().toString(); String dropbank = dropOrBank.getSelectedItem().toString(); String chop = treeBox.getSelectedItem().toString(); if (location.equals("Edgeville") && chop.equals("Yew")) { MahTreez.activeTree = Tree.Y...
88998a23-a8cc-449d-83dd-56bbe16e0ae9
1
public static List<String> getAllSkills() { Collection<String> skis = skillsMap.values(); if (skills == null) skills = new ArrayList<String>(skis); return skills; }
b708760a-4edb-45c3-bdc7-1364593caf4d
9
public void setSelection(int i, double s, int mode) { if (!data.isDB) propagate(i, s, mode); else switch (mode) { case Selection.MODE_STANDARD: hilite[i] = s; //System.out.println("REPLACE at: "+i+" with: "+s); ...
2fbdf4ad-883d-4730-9bbf-985c758424e4
2
public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); Node h = null; Node curr = h; while(n-->0){ if(h==null){ h = new Node(in.nextInt()); curr = h; } else { curr.next = new Node(in.nextInt()); curr = curr.next; } } printList(h); ...
ad0513f3-de85-482b-8ed5-a7673ebd2b79
2
public synchronized void signalStatus(HTSMsg msg, int clientId){ Subscription s = getSubscription((Long) msg.get("subscriptionId"), clientId); HTSPServerConnection c = monitor.getServerConnection(s.serverConnectionId); msg.put("subscriptionId", s.serverSubscriptionId); try { c.send(msg); } catch (IOExcepti...
965098a0-a240-4eab-af0d-49aa1117ad9b
7
@Override public void keyPressed(KeyEvent e) { int input = e.getKeyCode(); switch (input) { case KeyEvent.VK_UP: localGame.rotateClockwise(); network.sendKey(ProtocolConstants.UP); break; case KeyEvent.VK_DOWN: localGame.rotateCounterClockwise(); network.sendKey(ProtocolConstants.DOWN); break...
6d0517ab-4ef0-4c1a-b0f7-76fa6f5c8be6
1
public Desktop(){ frame = new JFrame(Settings.title); frame.setAlwaysOnTop(false); frame.setSize(800,600); frame.setLocationRelativeTo(null); frame.setResizable(true); frame.setLayout(new BorderLayout()); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowListe...