method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
56922489-de9f-4dcb-8083-6598de3fcd03
6
private void handle(Resource res) { InputStream in = null; try { res.error = null; res.source = src; try { try { in = src.get(res.name); res.load(in); res.loading = false; res.notifyAll(); return; } catch (IOException e) { throw (new LoadException(e, res))...
4c737055-eba7-4f67-8d53-59883704900f
7
public static String GetDzienNoc() { String dziennoc; Calendar cal = Calendar.getInstance(); int s = cal.get(Calendar.HOUR_OF_DAY); int p; int dn; dn = 0; if (s>=19) { p = 5; dn = 0; } else { ...
76b914ac-f8ec-4ee4-a09a-bc033ddeff9a
8
@Override public void execute() { SceneObject rock = SceneEntities.getNearest(Main.getRockIDs()); if (Inventory.isFull()) { if (BANK_AREA.contains(Players.getLocal().getLocation())) { if (Bank.isOpen()) { Bank.deposit(Main.oreID, 28); } else { Bank.open(); } } else if (MINE_AREA.contain...
a047eb17-bff6-4654-a6d2-557240f7fa3b
6
public boolean insert(int index, E newItem) { if (index < 0 || index > size) return false; Node newNode = new Node(newItem); size++; if (index == 0) { // insert node at head newNode.next = head; head = newNode; if (end == null) // if only item end = newNode; return true; } if (in...
f5274df7-f876-43d7-acb3-e9fce2fef69c
3
public boolean addLink(Link l) { if (this.classes.containsKey(l.getField()) && this == l.getGroup() && this.links.getLinks(l.getField()).size() == 0) { this.links.add(l); l.getTeacher().addLink(l); return true; } return false; }
45bb46d7-624f-4fa3-80bb-dadfc30d5ef8
0
@Transactional public Task getById(Integer taskId) { return tasksDao.getById(taskId); }
4b1140d3-17ed-44eb-9108-99312c14171d
2
public void supprimeCombiImp(Ligne proposition, LigneMarqueur marqueurVerif){ Iterator<Ligne> it = listeCombi.iterator(); Ligne tmpLigne; // Variable tempororaire qui récupèra une lgne pour la comparée for(int i=0; it.hasNext(); i++){ tmpLigne = it.next(); if(!ma...
dfbc0c05-ec66-40f6-bb15-0ccca7b451d7
3
@SuppressWarnings({ "unchecked", "rawtypes" }) public Combo_Box_View_All_Groups() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException { //MAIN FRAME super("Team J's Scheduler | View All Groups"); setBounds(50,50,500,300); setResizable(false); setDefaultCloseOperation(...
022d7efb-68b8-44d0-a36b-03106bf22874
2
private void acao114Declaracao(Token token) throws SemanticError { try { Identificador idVariavel = new Identificador(token.getLexeme()); tabela.add(idVariavel, nivelAtual); if (analisandoRegistro) listaIdsCamposRegistroTemp.add(idVariavel); else listaIdsVariaveis.add(idVariavel); } catch (Ide...
ad5f8d00-2a1a-403f-aeca-9ca0dab529cb
4
public Player GetPlayer1() { boolean test = false; if (test || m_test) { System.out.println("GameBoardGraphics :: GetPlayer1() BEGIN"); } if (test || m_test) { System.out.println("GameBoardGraphics :: GetPlayer1() END"); } return m_player1; }
d497c9e5-d54d-4d81-84b2-4e1d7dc1d47f
5
private void loadState(int state) { if(state == MENUSTATE) gameStates[state] = new MenuState(this); if(state == LEVEL1STATE) try { gameStates[state] = new Level1State(this); } catch (IOException e) { e.printStackTrace(); } if(state == MPSTATE){ try { gameStates[state] = new MPState(this...
073791bd-d6d8-446d-9cd7-e8f0b2a163fe
2
public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); //This is the line that makes the hadoop run locally //conf.set("mapred.job.tracker", "local"); String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs(); if (...
f4b70ba7-eab5-4d9d-b3a4-bb0d418cea54
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; JDK other = (JDK) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; ...
fcebbb9e-9cec-4f01-a815-a0cebdbcd29e
7
private AppenderDto parseAppender(String initLine, BufferedReader br) throws IOException { AppenderDto appenderDto = new AppenderDto(); Parameter param = new Parameter(); Matcher matcher; String currentLine = initLine; while ((currentLine = br.readLine()) != null && ...
90d84a6c-8eda-4369-9dbc-88ab20381491
0
public static void question12() { /* QUESTION PANEL SETUP */ questionLabel.setText("What about the music volume?"); questionNumberLabel.setText("12"); /* ANSWERS PANEL SETUP */ //resetting radioButton1.setSelected(false); radioButto...
cf3c3ca4-0f05-4d31-85ef-8e128677eca4
5
private void setXAxis(int type) { switch (type) { case BookData.TITLE: xAxisLabel = searchMatch.getTitleAxis(); return; case BookData.AUTHOR: xAxisLabel = searchMatch.getAuthorAxis(); return; case BookData.PAGES: xAxisLabel = searchMatch.getPageAxis(); return; case BookData.YEAR: xAxisLab...
9ff45a97-1e52-46e4-9cc2-731d8f4934f3
0
public int getRows() { return rows; }
7eadcc0f-2ca7-4a24-b692-8a204d4e041a
5
private static boolean containsFuncCode(int[] funcCodeClass) { assert(_opCode == 0 || _opCode == 28 || _opCode == 16 || _opCode == 17); for (int i = 0; i < funcCodeClass.length; i++) { if (_funcCode == funcCodeClass[i]) { return true; } } return false; }
d31c0ea3-3943-4564-a446-e4b346debac8
8
void sortSequence() { if (size() < 3) return; Atom[] end = getTermini(); if (end.length != 2) return; clear(); addAtom(end[0]); Atom[] at = model.bonds.getBondedPartners(end[0], true); boolean b; while (at.length == 1 || at.length == 2) { b = false; if (!contains(at[0])) { addAtom(at[0])...
1e052124-a90a-42c5-aa67-5730ee14e24a
1
private PreparedStatement buildDeleteStatement(Connection conn_loc, String tableName, String whereField) throws SQLException { final StringBuffer sql = new StringBuffer("DELETE FROM "); sql.append(tableName); // delete all records if whereField is null if (whereField != null...
e4fc626c-ddb0-4f14-95b6-8224ba7585a6
4
public Cardapio getCardapioDoDiaGson(){ Cardapio cardapio = null; URL serverAddress; try { serverAddress = new URL(ServiceResources.URL_RESOURCE+"/cardapio/hoje"); HttpURLConnection connection = (HttpURLConnection) serverAddress.openConnection(); connection.setRequestMethod("GET"); connection.connec...
3a876bf1-468f-4964-8d32-88419a0075a7
4
public static int tensionUnitStringToIndex(String unit) { switch (unit) { case "N": return 0; case "lbf": return 1; case "kgf": return 2; case "daN": return 3; default: ret...
f8b6538c-6ff4-4ed1-9f50-f9b40d4cdf0e
0
public Object get() { size--; return super.get(); }
6019ae83-d799-4068-b122-82e27b670ca7
8
public synchronized boolean equals(java.lang.Object obj) { if (!(obj instanceof SecurityHeader)) return false; SecurityHeader other = (SecurityHeader) obj; if (obj == null) return false; if (this == obj) return true; if (__equalsCalc != null) { return (__equalsCalc ==...
5f981037-fd97-425c-87cb-bce9631e85d2
2
public beansAdministrador buscarAdmin(String nick){ for(beansAdministrador admin : admins){ if(admin.getNick().equals(nick)) return admin; } return null; }
75e7a7cb-a00f-4cf4-a77b-1f47d0708b22
4
public void actionPerformed(ActionEvent e) { ArrayList b = craft.getBullets(); for (int i = 0; i < b.size(); i++) { PlayerBullet m = (PlayerBullet) b.get(i); if (m.isVisible()) m.move(); else b.remove(i); } for (int i = 0; i < invaders.size...
6ba54d3f-fef4-4536-bead-898c7a0a5bb4
0
public String process(HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession session = request.getSession(); //Validate the Input //for(String name: new String[] {"name", "manufacturer_name", "manufacturer_part_id", "tag", "location_name", "depreciation", "installdate", "note"}){ //if...
b77d8161-3cfa-4f1a-8ba2-56bbdc28207e
6
public Menu(){ // Set up areas setBounds(0,0,Main.WIDTH,Main.HEIGHT); setLayout(null); this.setBackground(new Color(30,30,30)); // Load in graphics ImageIcon loginTextField = new ImageIcon("res/Images/loginTextField.png"); ImageIcon loginButtonImg = new ImageIcon("res/Images/loginButton.png"); Imag...
9991b469-b9c5-46f9-a567-c86c73115096
6
public static void main(String args[]) throws IOException{ // String studentName = Compiler.studentName; String studentID = Compiler.studentID; String uciNetID = Compiler.uciNetID; int publicTestcaseNum = 15; int privateTestcaseNum = 5; int publicPass = 0; for (int i=1; i<=publicTestcaseNum; ++i){...
e63f772f-1be6-450b-88c1-2c1acf7f77a9
5
private boolean needshift() { if (parent instanceof Window) { Window wnd = (Window) parent; if (wnd.cap != null) { String str = wnd.cap.text; if (str.equals("Oven") || str.equals("Finery Forge") || str.equals("Steel Crucible")) { ...
9e20ea0f-67bf-4348-9d49-fb1777bd4b26
6
@Override public void mountSharedFolder(VirtualMachine virtualMachine, String shareName, String hostPath, String guestPath) throws Exception { if (status(virtualMachine) == VirtualMachineStatus.POWERED_OFF) { throw new Exception("Unable to mount shared folder. Machine is not started."); } if (guestP...
aad5b3ad-6359-4f02-91ca-dffb08c7ecbc
8
public void insertEdge(String startKey, String endKey, int weight) { Vertex startVertex = getVertex(startKey); Vertex endVertex = getVertex(endKey); if (startVertex == null) { insertVertex(startKey); startVertex = getVertex(startKey); } if (endVertex == null) { insertVertex(endKey); endVertex = g...
3d7037e8-bdcf-455c-aac8-10e7c7ff2e29
4
private void updateFalling() { int nextPlayerPositionY = theModel.getPlayerPositionY() + theModel.getVerticalStep(); int nextPlayerPositionX = theModel.getPlayerPositionX() + theModel.getHorizontalStep(); if (boardController.collidesWith(nextPlayerPositionX, nextPlayerPositionY, theModel.getPlayerHeight())) { ...
d3ef6a89-2073-45dc-8710-1a969292fe77
0
public Encoder getEncoder() { return encoder; }
e1866e76-bdbe-41bd-a457-f7f604450e6e
7
@Override public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (isVisible() && (e.getSource() == optionPane) && (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) { ...
f756443b-3460-4af3-b9c4-d69ae89b6e99
1
static private float[] load_d() { String s = "0,-0.000442504999227821826934814453125,0.0032501220703125,-0.0070037841796875,0.0310821533203125,-0.0786285400390625,0.100311279296875,-0.5720367431640625,1.144989013671875,0.5720367431640625,0.100311279296875,0.0786285400390625,0.0310821533203125,0.0070037841796875,0.0...
a05c419b-2b24-4987-bfbd-9cc60e0aaba6
1
public E getElement(int index) { if (indexOK(index)) { return (E) array[index]; } return null; }
654f2a75-484d-43fe-91be-fec229879196
4
public static Boolean save(Entry entry, String collectionName) { if(entry == null) return false; MongoCollection collection = getJongo().getCollection(collectionName); Boolean dirty = false; Integer id = entry.getId(); IdTracker tracke...
7d4e201e-7aa8-4a02-8860-d3073c00897e
5
*/ public void setPayload(byte[] payload) { this.payload = new byte[payload.length]; this.payload = payload; //if protocols used, get additional information if(protocols){ //check dispatch header for any 6lowpan-type packet //if 10xxxxxxxx or 11000xxx or 11100xxx or 011xxxxx ---> create a 6lowpan-Pack...
567afcc6-f70a-48a4-8dcc-7d748fd5fe0d
4
private boolean read() { try { final URLConnection conn = this.url.openConnection(); conn.setConnectTimeout(5000); if (this.apiKey != null) { conn.addRequestProperty("X-API-Key", this.apiKey); } conn.addRequestProperty("User-Agent", "Updater (by Gravity)"); conn.setDoOutput(true); final Bu...
6e393983-34a4-47bc-8d3f-f447ad2abe40
3
@Test public void insertLastHandlesTailCorrectly() { l.insertLast(a); for (int i = 1; i < 10; i++) { l.insertLast(new Vertex(i)); } int i = 0; Vertex test = l.min(); while (test != null) { test = l.succ(test); i++; if (i...
8d3b5b7b-54de-4e73-b7c0-69309efe98a0
7
final int[][] method1094(byte i) { anInt1864++; int[] is = new int[256]; int i_10_ = 0; for (int i_11_ = 0; i_11_ < ((Model) this).triangles; i_11_++) { int i_12_ = ((Model) this).anIntArray1824[i_11_]; if ((i_12_ ^ 0xffffffff) <= -1) { if (i_10_ < i_12_) i_10_ = i_12_; is[i_12_]++; } } i...
76cd7ae8-f9f8-4888-969d-ad26c2b3c9cf
7
private String getDowJones () { String dowJones = "0"; try (final Scanner dowJonesWebPage = new Scanner (new URL (FieldGoogleFinance.URL.toString()).openStream())) { boolean lastPriceHasFind = false; boolean changePercentHasFind = false; while (dowJonesWebPage.hasNext() && ((! lastPriceHasFind) |...
f03638b8-90c6-4aeb-ae55-28b53fcfceea
3
@Override public void addAgent() { Random rand = new Random(); int x; int y; lab(environment); do { x = rand.nextInt(environment.taille_envi); y = rand.nextInt(environment.taille_envi); } while (environment.grille[x][y] != null); pacMan = new Point(x, y); environment.grille[x][y] = new PacMan("Pa...
9fc9d013-545b-4f65-8094-fa8e0f85e5ab
2
private void stop() { try { for (Clip c : clips) { c.stop(); c.setFramePosition(0); } } catch (Exception e) { e.printStackTrace(); } }
1412117d-5251-487e-a8ff-c15bc1e74ba7
4
Power(String name, int properties, String imgFile, String helpInfo) { this.name = name ; this.helpInfo = helpInfo ; this.buttonTex = Texture.loadTexture(IMG_DIR+imgFile) ; this.properties = properties ; }
9ecdaaf3-cedb-4132-b36b-383e84eebe22
3
public byte getValueAsByte() throws IllegalArgumentException { if (!isOptionAsByte(code)) { throw new IllegalArgumentException("DHCP option type (" + this.code + ") is not byte"); } if (this.value == null) { throw new IllegalStateException("value is null"); } ...
3253ca0f-cd1a-487d-8777-7aa2dd3f89ca
7
private void performOpen() { JFileChooser chooser = new JFileChooser(lastSave); chooser.setFileFilter(getFileFilter()); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.showOpenDialog(this); File file = chooser.getSelectedFile(); String errorMessage = null; if (file != null && file.isFile() ...
d84ca087-4ca2-4a7e-ae51-1a32ee5011fd
8
public void applyPrefixes(LinkedList<Prefix> pre){ //Apply prefix in graph name if (name.startsWith("<")){ //Apply prefix for (Prefix p:pre){ if (name.startsWith("<"+p.getIriContent())){ name=p.getPrefix()+name.substring(p.getIriContent().length()+1,name.length()-1); break; } } } //Ap...
49118dac-237e-40de-9595-027e102181f0
3
public synchronized void receive (Message m) { long t__recv, dt; double rate; long d; double average, deviation; count += 1; if (count == 1) _t_recv = System.currentTimeMillis(); d = (System.currentTimeMillis() - Long.parseLong(m.getPayload())); /* Accumulate */ delay += d; delaysquared += (doubl...
8632929f-3482-4017-ac3a-db659ff4d880
3
public void preencherTabela() throws Exception { ArrayList<String> colunas = new ArrayList<String>(); colunas.add("id"); colunas.add("nome"); colunas.add("nomeCientifico"); colunas.add("email"); colunas.add("sexo"); colunas.add("classe"); colunas.add("titulacao"); colunas.add("cursoVinculado"); col...
2694ab05-1b0b-490a-93fa-cfa120bbf31e
3
protected static String processUnicode(String text) { boolean big = false; text = text.replace("|הגדלה=ללא", ""); text = text.replace("|הגדלה=לא", ""); text = text.replace("יוניקוד|", ""); if (text.contains("הגדלה")) { big = true; } if (text.contains("...
d217d59b-57d7-4803-bb88-b7f869276530
5
public CheckResultMessage check34(int day) { int r = get(47, 5); int c = get(48, 5); if (checkVersion(file).equals("2003")) { try { in = new FileInputStream(file); hWorkbook = new HSSFWorkbook(in); if (0 != getValue(r + day, c, 12).compareTo( getValue(r + day - 1, c + 5, 12))) { return e...
8fa71527-a5b1-464f-b437-0ecfefcfb4e4
4
@Override public List<WeightedEdge<N, W>> edgesFrom(N... fromList) { LinkedList<WeightedEdge<N, W>> list = new LinkedList<WeightedEdge<N, W>>(); if(fromList.length == 1) { N from = fromList[0]; if(containsNode(from)) { list.addAll(nodes.get(from)); } } else if(fromList.length > 1) { for(int i = 0...
e8927173-d06f-418b-81fe-183f53b74bde
4
@Override public HashMap<String, Sprite> loadAll() { //First get a hashmap of all images ImageLoader loader = new ImageLoader(); HashMap<String, BufferedImage> imageMap = loader.loadAll(); //Create a hashmap of sprites HashMap<String, Sprite> spriteMap = new HashMap<String, Sprite>(); //Declare a buf...
29a271d6-91ed-48a9-8074-c761e9af7579
6
private void checkCollision() { if (r.intersects(StartingClass.hb.r)){ visible = false; if (StartingClass.hb.health > 0){ StartingClass.hb.health -= 1; } if (StartingClass.hb.health == 0){ StartingClass.hb.setCenterX(-100); StartingClass.score += 5; } } if (r.intersects(StartingClass.hb...
83498a65-9a4a-4bc6-b2d9-1cb19fcf5532
3
public void openAlgorithm() { int value = programLoader.showOpenDialog(null); if (value == JFileChooser.APPROVE_OPTION) { File file = programLoader.getSelectedFile(); AlgReader algReader = null; try { algReader = new AlgReader(file); } cat...
c3844c7c-4ad0-44b1-902b-8384bf021ebc
6
void loadProfile(int profile) { try { switch (profile) { case 1: { String text = openFile(TextEditor.class.getResourceAsStream("text.txt")); //$NON-NLS-1$ StyleRange[] styles = getStyles(TextEditor.class.getResourceAsStream("styles.txt")); //$NON-NLS-1$ styledText.setText(text); if (style...
ac129f31-3284-48ea-ac04-f0991dc37c4c
1
protected void createFrame() { MyInternalFrame frame = new MyInternalFrame(); frame.setVisible(true); desktop.add(frame); try { frame.setSelected(true); } catch (java.beans.PropertyVetoException e) {} }
cb57b341-38da-4228-827a-5036b3504ed3
2
public void setUsertilePosition(Position position) { if (position == null) { this.usertilePosition = UIPositionInits.USERTILE.getPosition(); } else { if (position.equals(Position.NONE)) { IllegalArgumentException iae = new IllegalArgumentException("Position none ...
862418d4-eb3a-43de-a952-be53625ca752
9
private String individualMonsterDetails() { String string = ""; string = string.concat("Monster HP:"); for (int i = 0; i < stage.getMonsters().size(); i++) { string = string.concat(" " + stage.getMonsters().get(i).getHealth()); } string = string.concat("\nMonster AP:"); for (int i = 0; i < stage.getMonst...
14066544-cc77-4f50-85cf-b422f2816d0f
7
@Override public Token getToken(MPFile file) { Token t = null; int state = 1; String lexeme = ""; char current = 0; while (state != 3) { if (!file.hasNextChar() && state == 2) { state = 3; } else { switch (state) { ...
d2a734b6-4b93-46c1-9cae-6f270d4f5608
0
public BSTNode getRoot() { return root; }
6fdd7be2-f96f-4dd8-ac98-8ef5f0cd0904
8
@Override public boolean getPoint(int mouseX, int mouseY){ int newX = -1; int newY = -1; if (mouseX < 800){ int cx = Boot.getPlayer().getX(); int cy = Boot.getPlayer().getY(); newX = cx + (mouseX / Standards.TILE_SIZE) - 12; newY = cy + ((Standards.W_HEIGHT - mouseY) / Standards.TILE_SIZE) - 12; ...
1648ab68-06c4-4018-a464-b88970370928
2
@Override public String toString(){ String s = "List of Buttons\n"; for (int i=0;i<bHandler.length;i++){ if (bHandler[i] != null) s += bHandler[i].getEntity().getName() + "\n"; } s += "END OF LIST\n-----------------\n\n"; return s; }
15e99557-5883-48d7-9e9a-7bb271ac958d
8
@Override public void actionPerformed(InputEvent event) { super.actionPerformed(event); if (event.key.id == input.down.id && event.type == InputEventType.PRESSED) { selectedEntry++; } if (event.key.id == input.up.id && event.type == InputEventType.PRESSED) { selectedEntry--; } if (selectedEntry ...
afda8657-54a8-4cbb-819e-23f39cf5eb11
8
public boolean PieceNotInWay(int targetX, int targetY, boolean color, Board chessBoard, Game game) { int incrementX = 0, incrementY = 0; int curX = this.curX, curY = this.curY; if (targetX == this.curX) { if (targetY > this.curY) { incrementY = 1; } else { incrementY = -1; } } else if (targ...
7884f58b-b222-49e7-b6a7-1bb9eecc9d08
9
public static void enviarMensajes(String factoriaConexiones, String colaMensajes, String nombreProductor, int numMensajes) { Context contextoInicial; ConnectionFactory factoria; Connection conexion = null; Session sesion = null; Queue cola; ...
35ff372d-61db-4eb2-861a-89ec6a66c852
0
@Test public void testGetCuenta() { System.out.println("getCuenta"); Cuenta instance = new Cuenta(); String expResult = ""; String result = instance.getCuenta(); assertEquals(expResult, result); // TODO review the generated test code and remove the default call to fai...
3791ccb1-1c44-491c-846b-90271e8b661c
2
public Map<RedisBigTableKey, byte[]> getAll(byte[] table) throws RedisForemanException { if (tableExists(table)) { Map<byte[], byte[]> map = instance.hgetAll(table); Map<RedisBigTableKey, byte[]> toReturn = new HashMap<RedisBigTableKey, byte[]>(); for (Entry<byte[], byte[]> ent : map.entrySet()) { ...
9c63de9b-8120-4364-91f3-50344adb5acb
1
@Override public String getToolTipText(MouseEvent event, Rectangle bounds, Row row, Column column) { if (getPreferredWidth(row, column) - H_MARGIN > column.getWidth() - row.getOwner().getIndentWidth(row, column)) { return getData(row, column, true); } return null; }
78b5f9ba-b24f-4617-bc0b-392df4b46d92
2
public CycSymbol getIntermediateStepValidationLevel() { Object rawValue = get(INTERMEDIATE_STEP_VALIDATION_LEVEL); if (rawValue instanceof CycSymbol) { return (CycSymbol) rawValue; } else { rawValue = getDefaultInferenceParameterDescriptions().getDefaultInferenceParameters().get(INTERMEDIATE_STE...
6e930ae4-5237-4af1-99fc-f0cccb9211f5
5
private static void postProcessConfig() { createDirAtHome(); normalizeVariableContent("UrbanoSHPPath"); normalizeVariableContent("RusticoSHPPath"); try { CatExtractor.extract(Config.get("UrbanoSHPPath")); CatExtractor.extract(Config.get("RusticoSHPPath")); } catch (IOException ioe){ ioe.printStackT...
b44b85b6-83d3-4cc9-a31d-137894bd7e53
8
public int binarySearchPredictable(T[] a, int from, int limit, T query, BSTYPE type) { if (from >= limit) { return from; } int mid = (from + limit) / 2; int compared = comparator == null ? query.compareTo(a[mid]) : comparator.compare(query, a[mid...
357f2c8d-f376-48c8-a088-f959123cc7fb
1
public void initTableau() { tableau = new ArrayList<>(); for(int i=0 ; i<256 ; i++) tableau.add(i); }
6dbdb656-d4db-4e2f-b5ca-a2f8c597f8dd
3
private void jButtonSourceNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSourceNextActionPerformed try{ MultiSyntaxDocument syntax = new MultiSyntaxDocument(); if(sourceCurrentPosition==(sourceMatchOffsets.length-1)){ JOptionPane optionPane ...
718eb467-f84c-4d4f-bc56-8b2bb486f8d6
6
public static int doSevenLoop(Deck deck, PlayerHuman playerHuman, PlayerCPU playerCPU, int plCount) { Card card; int n = 2; // number of cards will be pulled int cp; // current player while (true) { cp = plCount % 2...
ef32f429-d38a-4b5c-9dd9-5ee0a03c8838
6
public static void countWithStateless() throws NamingException, InterruptedException { int i, lostTimes = 0; long threadId = Thread.currentThread().getId(); RemoteSLSB slb = lookupRemoteSLSB(); boolean lost = false; System.out.println(threadId + ": Obtained a remote stateless bean for invocation."); l...
c38ab0ad-00e7-4ef2-a252-c4eaac1ece6d
6
public static boolean getChoice () { String message = ""; boolean chosen = false; Scanner sc = new Scanner (System.in); boolean inputOK = false; while (! inputOK) { String choice = sc.nextLine(); choice = choice.toUpperCase(); if (choice != null) { if ( choice.equals("Y") || choice.equals("N")) {...
708c28da-6983-42f4-a521-f8b1ba86a828
3
public void drawEdges(Graphics2D g, Edge[] edges) { if (edges == null) return; for (Edge e : edges) { if (e != null) g.drawLine(e.from.x, e.from.y, e.to.x, e.to.y); } }
da39cca8-675d-46e9-b761-ece73102d498
7
private static void test2_1() throws FileNotFoundException { String test1 = "new game\n"+"examine cell key\n"+"quit\n"+"yes\n"; HashMap<Integer, String> output = new HashMap<Integer, String>(); boolean passed = true; try { in = new ByteArrayInputStream(test1.getBytes()); System.setIn(in); out = ne...
4f99c410-10d4-470a-a585-99ccc91228af
1
private static void inputCustomerChoice() { if (scanner.hasNext()) { beverageChoice = scanner.nextLine(); } }
c9f52ec4-9fbe-4680-907a-b2b26aae86ca
4
public boolean equals(Object other) { if ( (this == other ) ) return true; if ( (other == null ) ) return false; if ( !(other instanceof TrabajaderaId) ) return false; TrabajaderaId castOther = ( TrabajaderaId ) other; return (this.getIdtrabajadera()==castOther.getIdtrabajadera()) && (t...
5ccfcc18-6690-4aa4-8b84-643689889eaa
2
public void setInOut(String[] command) { int id = Integer.parseInt(command[0]); boolean bool = Boolean.parseBoolean(command[1]); for (int i = 0; i < entradas.getLength(); i++) { Entrada entrada = entradas.get(i); if (entrada.equals(id)) entrada.change(bool); } ...
427b4891-9698-4907-95b1-5be0e62f94bc
4
public static Right get(String value) throws IllegalArgumentException { if (value.equalsIgnoreCase("read")) { return read; } else if (value.equalsIgnoreCase("write")) { return write; } else if (value.equalsIgnoreCase("exec")) { return exec; } ...
f76d6f7a-29ce-43ef-b7cf-c81e4b7e5192
9
protected void showContent(String name) { toolBarName = ""; TitledBorder nameBorder = BorderFactory.createTitledBorder( name); MainView.contentPanel.setBorder(nameBorder); mainView.getCardLayout().show(mainView.getContentPanel(), name); // refresh visible card panel JPanel card = null; for (Component...
c03097ed-5b05-40cf-9d7f-c887bb5473f2
4
public static void main(String[] args) { final int length = 10; int intArray[] = new int[length]; Random generator; generator = new Random(); for (int i = 0; i < intArray.length; i++) { intArray[i] = generator.nextInt(9) + 1; } System.out.print("Origin...
4d5f7ce2-465f-4cd2-893b-56da59cd4321
0
public void clickChooseCharacters(Scanner scanchoice, ArrayList<MainMenuHeroSlot> heroies) { state.clickChooseCharacters(scanchoice, heroies); }
8955fb74-01e2-460b-a4e6-aae307e6002f
3
public Object next() { Object o = null; // Block if the Queue is empty. synchronized (_queue) { if (_queue.size() == 0) { try { _queue.wait(); ...
0616cbc5-42bf-4365-ba28-ae3d208271d3
8
public static void decompressFile(String input, String output){ byte[] data = new byte[0];//All the bytes from the input //Read the input try{ data = Files.readAllBytes(Paths.get(input)); }catch(Exception e){ e.printStackTrace(); } ArrayList<Character> unique = new ArrayList<Character>();//Local uniq...
16b3f04d-2a00-4bed-b1ed-1a5645039ff3
5
@Test public void testSubClauses() throws Exception { PersistenceManager pm = new PersistenceManager(driver,database,login,password); ConnectionWrapper cw = pm.getConnectionWrapper(); //add data with two sortable fields for(int x = 0;x<100;x++) { long dec = x/10; double rem = x%10; SimpleObject so ...
759a3426-fa50-42f1-8a98-57a12f587653
7
@Override public void input( float delta ) { Vector2f centerPosition = new Vector2f( Window.getWidth() / 2, Window.getHeight() / 2 ); if ( Input.getKey( unlockMouseKey ) ) { Input.setCursor( true ); mouseLocked = false; } if ( Input.getMouseDown( 0 ) ) { Input.setMousePosition( centerPosition );...
2252389d-94d0-4744-b9c0-c159e8132786
7
private void toggleRemoveSelection(TreePath path){ Stack<TreePath> stack = new Stack<TreePath>(); TreePath parent = path.getParentPath(); while(parent!=null && !isPathSelected(parent)){ stack.push(parent); parent = parent.getParentPath(); } if(parent!=null...
f0b55804-aca5-486d-9da1-93e035cc0231
0
public static void main(String[] args) throws Exception { Document document = new Document(); //同时修改多个变量 Alt + shift + r Element root = new Element("学生手册"); document.addContent(root); Attribute attr = new Attribute("班级","2"); Element student = new Element("学生").setAttribute("学号", "1...
182c50ea-571a-4db9-a036-c8145ee7e594
1
static public jlp createInstance(String[] args) { jlp player = new jlp(); if (!player.parseArgs(args)) player = null; return player; }
54909b6f-e720-421a-a40c-7a5d17d97027
2
private void addProjectDependenciesToClassRealm(ExpressionEvaluator expressionEvaluator, org.codehaus.classworlds.ClassRealm containerRealm) throws ComponentConfigurationException { Set<String> runtimeClasspathElements = new HashSet<String>(); try { runtimeClasspathElements.addAl...
f14d9df0-2304-48fc-9b09-74b8f19a9d2a
8
public int largestRectangleArea(int[] height) { int len = height.length; if( len <= 0){ return 0; } if( len == 1){ return height[0]; } Comparator<Integer> OrderIsdn = new Comparator<Integer>(){ public int compare(Integer o1, Integer ...
cf71317b-cbb8-4b05-9a30-fc0838f4d7ab
7
public NoClaimReason canClaimForSettlementReason(Tile tile) { int price; NoClaimReason reason = canOwnTileReason(tile); return (reason != NoClaimReason.NONE) ? reason : (tile.getSettlement() != null) ? NoClaimReason.SETTLEMENT : (tile.getOwner() == null) ? NoClaimReason.N...
d3069b2e-6591-4988-991c-f1f7063f7706
4
public void shift(Direction direction, int i) { switch (direction) { case UP: pos1 = pos1.addY(-1); pos2 = pos2.addY(-1); break; case DOWN: pos1 = pos1.addY(1); pos2 = pos2.addY(1); break; ...
324b5303-0b37-43bd-8864-0dd80c0971d0
9
public final void switchStmt() throws RecognitionException { AST ast1 = null, ast2 = null; try { // CPP.g:415:3: ( 'switch' '(' expr ')' stmt ) // CPP.g:415:5: 'switch' '(' expr ')' stmt { this.match(this.input, 50, FOLLOW_50_in_s...