method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
946dd951-0484-468c-98ba-13c76a3ed453
3
public static String definirDirectorio(JFrame frame) { JFileChooser file = new JFileChooser(); file.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); int result = file.showOpenDialog(frame); switch (result) { case JFileChooser.CANCEL_OPTION: return ""...
e6681f2c-c354-4e64-9caa-8f484ace9782
2
private boolean hasTag(String version) { for (final String string : Updater.NO_UPDATE_TAG) { if (version.contains(string)) { return true; } } return false; }
f348ee38-3ccc-4ced-ac92-4ea4f60e5b39
3
private void throwLoadError() { String s = "ondemand";// was a constant parameter System.out.println(s); try { getAppletContext().showDocument(new URL(getCodeBase(), "loaderror_" + s + ".html")); } catch (Exception exception) { exception.printStackTrace(); ...
f5754977-5fb2-4b79-a489-9327e8918f73
3
public void setKey(String key) { byte[] keybyte = key.getBytes(); if (keybyte == null) { throw new RuntimeException("No key"); } else if (keybyte.length < 16) { throw new RuntimeException("Key too short"); // byte[] newkey = new byte[16]; // for (int i = 0; i < 16; i++) { // newkey[i] = keybyte[i % k...
aee47a02-3093-4ee4-9eb7-807194aa1b68
0
public String buscarAgencia() { System.out.print("entre com a agencia: "); return entrada.leiaString(); }
a2f6ca93-2f8b-4622-a835-5ff8e724d0f2
5
@Override public void keyPressed(KeyEvent event) { if(this.inputBlocked) { return; } switch(event.getKeyCode()) { case KEY_LEFT: case KEY_UP: case KEY_DOWN: case KEY_RIGHT: JOptionPane.showMessageDialog(null, "MOVE"); clearMoveInput(); break; default: } currentInput.put(event.get...
2d3d20ef-55f7-410b-8535-86ac8ab6e874
9
public String authenticate(String username, String password, boolean isAdmin) { try { crs = qb.selectFrom("users").where("username", "=", username).executeQuery(); if (crs.next()){ if(crs.getBoolean("active")==true) { if(crs.getString("password").equals(password)) { if((crs.getBoolean("isAdmin")...
f8d2c46f-5b79-47db-94c3-b6e4b778b869
7
private void displayDebuffEffects() { int var1 = this.guiLeft - 124; int var2 = this.guiTop; int var3 = this.mc.renderEngine.getTexture("/gui/inventory.png"); Collection var4 = this.mc.thePlayer.getActivePotionEffects(); if (!var4.isEmpty()) { int var5 = ...
9504a679-3ce3-464a-96db-274f657ad714
4
public String Tclient(int num) throws SocketException, IOException, InterruptedException{ TelnetService TC; if (num == 1){TC = TC1;TC1.mynum=1;} else {TC = TC2;TC2.mynum=2;} String rtn=TC.getTelnetSessionAsString(Integer.toString(num)); if (rtn.equals("reload")){return rtn;} TC.readit(" "); dw.append("Ser...
e351892a-5e06-4944-bf41-8d6d9b3c774f
2
public List<Statistik> getStatistikzuOrgaEinheitinKWundJahr(int idOrgaEinheit, int kalenderWoche, int jahr) { ResultSet resultSet; List<Statistik> rueckgabe = new ArrayList<Statistik>(); try { resultSet = db .executeQueryStatement("SELECT * FROM Statistik WHERE idOrgaEinheit = '" + idOrgaEinheit...
fbbc161b-a896-4ca3-9149-09f07428c0f5
7
static final public void term() throws ParseException { unary(); label_2: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MULTIPLY: case DIVIDE: ; break; default: jj_la1[3] = jj_gen; break label_2; } switch ((jj_ntk==-1)?jj_ntk(...
20e211cd-6c25-4b98-b8c3-320c4301d8a7
3
private boolean hasAmmo() { if(ammo == null) return true; //no ammo defined, I can shoot. //If I have ammo, I must have enough resource of ammo type to be able to shoot. if(resources.containsKey(ammoId)) if(minAmmo > -1) return resources.get(ammoId) >...
56960133-0103-4433-86f9-6ae0e1dc612c
1
private String serialContactSet(Set<Contact> contactSet) { // Serialises contact sets to a string of their ids. StringBuilder builder = new StringBuilder(); String seperator = ""; for(Contact each : contactSet) { builder.append(seperator).append(each.getId()); sep...
18d31701-f977-43e5-93e8-adea3cbeac58
2
public static void removeMultipleCharacterLabelsFromAutomaton(Automaton automaton) { Transition[] transitions = automaton.getTransitions(); for (int k = 0; k < transitions.length; k++) { FSATransition transition = (FSATransition) transitions[k]; String label = transition.getLabel(); if (label.length() > 1)...
9063e8f3-4487-4565-b1d4-58e5b476913a
9
public GOEPanel() { m_Backup = copyObject(m_Object); m_ClassNameLabel = new JLabel("None"); m_ClassNameLabel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); m_ChildPropertySheet = new PropertySheetPanel(); m_ChildPropertySheet.addPropertyChangeListener (new PropertyChang...
3e6db269-1b00-4a17-aa9a-b1ecb2c6fcfc
8
@Override public void run() { setupSocket(); while(this.running) { try { Thread.sleep(1000); this.connection = this.socket.accept(); InputStream inputStream = this.connection.getInputStream(); this.out = new ObjectOutputStream(this.connection.getOutputStream()); this.out.flush(); this.in...
2a8277ad-e654-45a3-a710-da7e03b1add3
7
public static void readHash3(String type_map, HashMap<String, Double> hashMap) { ArrayList<String> types = new ArrayList<String>(); ArrayList<String> tokens = new ArrayList<String>(); if (type_map != null) { FileUtil.readLines(type_map, types); for (int i = 0; i < types.size(); i++) { if (!types.ge...
4c6dbd77-a452-4538-ac7e-c729a56cd6e2
7
public void apply(Vector v) { Index index = indexer.get(); Vector midpoint = new Vector((float) Math.floor(v.getX()), (float) Math.floor(v.getY())) .add(new Vector(0.5f,0.5f)); Boundary clear = new Boundary(0.25f, midp...
f139d2a7-5763-4f89-86cb-c312aa97696b
4
private void run(Integer screenNum) { initSubsystems(); registerListeners(); InetAddress address = client.discoverHost(54777, 5000); if(address == null){ System.out.println("Error could not find Server on Lan!"); System.exit(0); } System.out.println("Connecting to " + address); client.start...
b726e279-3349-493d-87bc-793fae9e4184
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 Customer)) { return false; } Customer other = (Customer) object; if ((this.customerId == null && other.customer...
80749880-cd4c-4b7c-9f65-c7e1ae01f897
1
private void jComboBoxModifieVilleListItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxModifieVilleListItemStateChanged if (evt.getStateChange() == ItemEvent.SELECTED) { Ville ville = ((Ville) this.jComboBoxModifieVilleList.getSelectedItem()); ...
7ac12dcc-25d8-4638-934a-ffb71120ac2c
7
private int locateMainToken( String token, boolean caseSensitive ) { for( int a = 0; a < this.params.size(); a++ ) { List<List<String>> listB = this.params.get(a); // First token equals the desired token? if( listB.size() != 0 && listB.get(0).size() != 0 && ((caseSensitive && listB.get(0).ge...
5732a9ff-05a3-4df5-91f7-0c7ce4eec4b5
1
public void openDoor() { if(isOpening) return; OpenStartTime = (double)Time.getTime()/(double)Time.SECOND; openTime = OpenStartTime + TIME_TO_OPEN; closingStartTime = openTime + CLOSE_DELAY; closeTime = closingStartTime + TIME_TO_OPEN; isOpening = true; ...
889963e7-b779-4438-95a3-ded11945ed2b
6
public boolean start() { synchronized (optOutLock) { // Did we opt out? if (isOptOut()) { return false; } // Is metrics already running? if (task != null) { return true; } // Begin hitting the s...
3ffffa10-c713-41ae-b3c4-8a7f7952b3ab
9
public DeltaSyncSession login(String username, String password) throws AuthenticationException, DeltaSyncException, IOException { if (username == null) { throw new NullPointerException("username"); } if (password == null) { throw new NullPointerExcep...
c799b42a-21d0-422e-ae4f-cc33cfe365f0
1
public void setNametextZoomedFontstyle(Fontstyle fontstyle) { if (fontstyle == null) { this.nametextZoomedFontStyle = UIFontInits.NAMEZOOMED.getStyle(); } else { this.nametextZoomedFontStyle = fontstyle; } somethingChanged(); }
085a74ad-a9fe-4ed6-b612-979c6178ebcd
1
public static String getInput(String query) { BufferedReader console = new BufferedReader(new InputStreamReader(System.in)); System.out.print(query); try { return console.readLine(); } catch (IOException ioe) { ioe.printStackTrace(); return null; } }
22a8fa09-323e-4241-a6b6-9b8c483d4f15
2
@Override protected void processWindowEvent(WindowEvent e) { if(e.getID() == WindowEvent.WINDOW_CLOSING){ if(JOptionPane.showConfirmDialog(this, "Are you sure you want to close? Unsaved data will be lost", "WARNING", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION){ ...
e589be5f-0e07-4b8f-9a53-5ab49ba21c5e
3
public int[] sortHeap(int[] tmpArray){ // build a heap int[] sortHeap = new int[tmpArray.length]; sortHeap = this.buidHeap(tmpArray); // get one and rebuild again, a easier build procedure completed by max-heap // index of Array for(int i = sortHeap.length-1; i > 0; i--){ // exchange A[i] with A[0], and ...
9fd30ade-540e-4f48-99f0-2788c3e416b3
3
public final JSONObject putOnce(String key, Object value) throws JSONException { if (key != null && value != null) { if (opt(key) != null) { throw new JSONException("Duplicate key \"" + key + "\""); } this.insertOrder.add(key); put(key, value); ...
035fee57-b79d-41ad-964e-fccdbfd7ab30
8
public static void splitBinaryIndex(int x) { FileInputStream fis; BufferedInputStream bis; DataInputStream dis; try { File fIndex = new File(index_dir + "index" + Common.extIDX); fis = new FileInputStream(fIndex); bis = new BufferedInputStream(fis); dis = new DataInputStream(bis); String word1 =...
c41b4ccf-164d-4875-979d-d742b702731d
7
private boolean isClassBox(String owner) { if (!owner.startsWith("java/lang/")) { return false; } String className = owner.substring("java/lang/".length()); return (className.equals("Integer") || className.equals("Double") || className.equal...
20e99338-56ac-4ff7-af42-160c931090a3
3
public void run() { packetProcessor.onSuccessfulStarted(); while ( true ) { try { DatagramPacket packet = new DatagramPacket( new byte[1024], 1024 ); socket.receive( packet ); InetAddress address = packet.getAddress(); int port = packet.getPort...
86b50c0f-c357-481d-9eb1-662120188cc7
4
private void createAndShowGUI() { addButton = new IconButton(new AddItemPopupAction(),"./Resources/test.gif"); setLayout(new GridBagLayout()); GridBagConstraints btn = new GridBagConstraints(); btn.gridx = 1; btn.gridy = 0; btn.anchor = GridBagConstraints.EAST; th...
1edf39e4-d95c-4751-9384-ae89ab1f0021
8
public void weibullTwoParProbabilityPlot(){ this.lastMethod = 12; // Check for negative x values if(this.sortedData[0]<0){ System.out.println("Method weibullTwoParProbabilityPlot: negative x value found - weibullThreeParProbabilityPlot called"); this...
18491d34-9b71-4c3f-aa38-b82fe5548722
3
private boolean isIPBlacklisted(String address, File blacklistFile) { try { String line; BufferedReader br = new BufferedReader(new FileReader(blacklistFile)); while ((line = br.readLine()) != null) { if (line.equals(address)){ return true...
46ae5861-a034-415d-a4a9-f5b85a8ac42f
5
private void skip(int num) throws IOException { while (num > 0) { long result; if (in != null) { result = in.skip(num); } else { result = din.skipBytes(num); } if (result > 0) { num -= result; ...
23979752-01bf-4b3c-9c9a-d55b721dd79b
5
public void characters (char ch[], int start, int length) { if (isTargetQuestion && !mutiAnswers){ ansNum = Integer.parseInt(new String(ch, start, length).trim()); isTargetQuestion = false; }else if ((isTargetQuestion && mutiAnswers) && bAnswer){ ansNumList.add(new String(ch, s...
b76d3cd0-b513-4ed5-99ff-62b439462331
6
public void getList(int rep,String searchText) { String tempQuery = ""; if(rep == 0) { tempQuery = query; } else if(rep == 1) { searchText = searchText.toUpperCase(); tempQuery = "select * from (Select suppid,suppname,contactno1,contactno2,emai...
21218bd5-efb2-476c-8add-5ef195ae9cea
2
private void setLabels() throws IOException { labels = parse.getLine(); if (labels == null) return; labelMap = new HashMap<String,Integer>(); for (int i = 0; i < labels.length; i++){ labelMap.put(labels[i], new Integer(i)); } }
f049997e-b898-449e-9e31-3b74d8dc434e
7
private void checkResponseType(String responseType, Properties propBP, Properties propP) throws Exception { if (responseType.equals("Discrete") || responseType.equals("Optimal") || responseType.equals("Normal")) { if (propBP.get("type") == null) throw new Exception("ERROR: baseline pricing scheme undefi...
b4bf1b87-b877-478a-b9fd-b44f3c665615
4
public static void runTest(String fileInputName, String fileOutputName, double minSupportLevel, double minConfidenceLevel) { String errorFileOutputName = "ER_"+fileInputName; String supMsg = checkLevels(minSupportLevel); String confMsg = checkLevels(minConfidenceLevel); ErrorLogs errorLogs = new ErrorLogs();...
9bbb807d-916c-4940-a257-46e73e2a57d4
4
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final TblSoIdPK other = (TblSoIdPK) obj; if (!Objects.equals(this.InvoiceNumber, other.InvoiceNumber)) { ...
cb3c4ccd-867f-4cf9-b987-a4a9630057ed
4
public void act() { if (Greenfoot.mouseClicked(this)) { switch(WORLD){ case 1: Greenfoot.setWorld(new ShipCoordinator()); break; case 2: Greenfoot.setWorld(new CargoLifter()); ...
aa7c0752-1abd-4012-b92f-f12996487f50
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 ...
2b4aa7cb-a04f-42bb-94eb-277745027f48
5
public static void main(String[] args) { String serviceName = null; String serverIp = null; int serverPort = 0; if (args.length != 3) { System.out.println("Usage: java test.test5Client <ServiceName> <ServerIp> <ServerPort>"); return; } else { serviceName = args[0]; serverIp = args[1]; serverPo...
13253b52-963e-475e-9a1c-d93d8a0b89a5
8
public synchronized void call(int from, int to) { waitEntry[from]++; liftView.drawLevel(from, waitEntry[from]); notifyAll(); while (here != there || here != from || load >= 4) { try { wait(); } catch (InterruptedException e) { e.printStackTrace(); } } ...
0cfc3eab-b283-4f28-9de5-4a18bf8f251f
7
public void checaColision() { //Verifica que la barril no choque con el applet por la derecha if (barril.getPosX() + barril.getAncho() > getWidth()) { barril.setPosX(getWidth() - barril.getAncho()); } //Verifica que barril no choque con el applet por la izquierda ...
bf152bd7-8afe-44c1-8a29-7f17f20a134b
8
public String getRecommendListForTransitionModified(){ String recommend = ""; try { Class.forName("com.mysql.jdbc.Driver"); connect = DriverManager.getConnection("jdbc:mysql://localhost/NETWORK_TEST?" + "user=root&password=root"); connect.setAutoCommit(false); statement = connect.createStat...
2431e27b-c2ff-4915-bce5-71ff15d1acec
8
public void play(Agent other) { int ownAction = getAction(other.getID()); int otherAction = other.getAction(id); // Both agents cooperate. if (ownAction == 1 && otherAction == 1) { this.score += 3; other.addScore(3); } // This agent cooperates, t...
da9b6f4c-41f6-4397-be0d-f11d9e1b2975
5
protected static byte nativeEncoding( Number num ) { if( num instanceof Byte ) { return NE_INT8; } else if( num instanceof Short ) { return NE_INT16; } else if( num instanceof Integer ) { return NE_INT32; } else if( num instanceof Long ) { return NE_INT64; } else if( num instanceof Float ) ...
c6f06876-19da-48dd-9302-ea3aeac235a6
5
@Override public void keyTyped(KeyEvent e) { // Restart when ESCAPE key is pressed twice in a row if (e.getKeyChar() == KeyEvent.VK_ESCAPE) { if (restartFlag) { restartFlag = false; restart(); } else ...
8d22aad8-d4bf-48df-b873-a058ea27889b
5
private static double[] getResistPoints(int curvePoints,int lineNumber, double[] highPrices) { double[] rPoints = new double[lineNumber]; for(int i =0;i<lineNumber-1;i++){ double price = 0; for(int j=-curvePoints;j<=0;j++){ if((i+j>=0) && (i+j<lineNumber-1) && hig...
1019e295-47b7-4499-8fb2-53877330c690
9
private boolean comprobarOsi(String pLineaCodigo, int pPosicion, int pNumeroLinea) { // Verifica que se hay ingresado si despues de la palabra si habia un espacio o '[' if (pLineaCodigo.charAt(pPosicion) == ' ' || pLineaCodigo.charAt(pPosicion) == '[' || pLineaCodigo.charAt(pPosicion) == '\t') { ...
c96f3b24-351e-4af1-bd3e-bdf01759fcf9
2
public static void CONVERTE_HEXA(String entrada){ String resultado = ""; int i = 0; int cont = 1; byte [] LFCR = {0x0D,0x0A}; String tipo = "(byte)0x"; int tam = entrada.length()/2; for (i=0; i < entrada.length(); i+=2, cont++) { resultado = resultado + tipo + entrada.substring(i, i+2) ...
03ec0a1e-103f-4cbc-b39f-43ffb2bee1ad
4
@SuppressWarnings("deprecation") private ItemStack getItem(String name, int stackSize) { int id; int dmg = 0; String dataName = null; if (name.contains(":")) { String[] parts = name.split(":", 2); dataName = parts[1]; name = parts[0]; } try { id = Integer.parseInt(name); } catch (NumberForm...
4b7dc465-eb7a-45eb-8d85-71dfb0ed9c17
3
public boolean isNear(Point point, int fudge) { if (needsRefresh) refreshCurve(); try { if (bounds.contains(affineToText.inverseTransform(point, null))) return true; } catch (java.awt.geom.NoninvertibleTransformException e) { } return false; }
f6049be2-590c-4555-b247-70c553b0f402
5
public Set<ValueType> union(Set<ValueType> set1, Set<ValueType> set2) { Set<ValueType> unionSet = new Set<>(); SetElement<ValueType> current = set1.head; if (!set1.isEmpty()) { while (current != set1.tail.getNext()) { unionSet.addElement(current.getValue()); ...
dc8e060b-376e-4b47-a1b5-5bca8424501e
1
public QuitConfirmDialog(final Skin skin, final boolean openNewSkin, final boolean openChooser) { if (skin.isSkinChanged()) { EventQueue.invokeLater(new Runnable() { @Override public void run() { QuitConfirmDialog.this.setSize(new Dimension(475, 17...
e102a77d-9807-455c-a115-b8361a9680e6
3
private void promoteInSets() { for (Iterator i = predecessors.iterator(); i.hasNext();) { FlowBlock pred = (FlowBlock) i.next(); SuccessorInfo succInfo = (SuccessorInfo) pred.successors.get(this); /* * First get the gen/kill sets of all jumps of predecessor to this * block and calculate the intersec...
f99ab2a3-86ff-48d8-a6d3-0a185543f3e4
8
public static long[] getKPrimesFromN(int n, int k, boolean print) { long[] primes = new long[k+n]; primes[0] = 2; int currPrimeCount = 1; int fromNIndex = k; int indexStartFrom = -1; for(int i=3;fromNIndex>0;i+=2) { // even number cannot be prime boolean isPrime = true; long sqrt = (long) Math.sqrt(i)...
794241d9-208f-4da3-bd63-07c4fd74ac14
0
public void setCreator(EditorPane pane) { myCreator = pane; }
6bbf8a00-d8c5-4e59-9aaa-cadad45ca12b
4
public void makeNonVoid() { if (type != Type.tVoid) throw new alterrs.jode.AssertError("already non void"); ClassInfo clazz = getClassInfo(); InnerClassInfo outer = getOuterClassInfo(clazz); if (outer != null && outer.name == null) { /* This is an anonymous class */ if (clazz.getInterfaces().length > 0...
698d5fa9-d3fc-40f2-9d1c-56b5b7692105
1
protected void flushImpl() { if (source != null) { source.drain(); } }
482f0d76-15ca-459f-9bca-1f09eab5d915
9
public double update_model_expectation() { double logl = 0; int ncorrect = 0; _vme = newArrayList(_fb.Size(), 0.0); for (Sample i : samples) { double[] membp = new double[_num_classes]; int max_label = conditional_probability(i, membp); logl += log(membp[i.label]); // cout << ...
1a645fa2-e430-4fee-8152-8f0c1f1b423a
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...
979554ed-bd25-48b7-8d95-368e84919169
8
public int getLength(String nickname) { int a = nickname.length(); char n[] = new char[a]; int ans = 0; int f = 0; n = nickname.toCharArray(); for(int i = 0;i < a;i++){ if((n[i] == 'a')||(n[i] == 'i')||(n[i] == 'u')||(n[i] == 'e')||(n[i] == 'o')||(n[i] == 'y')){ if(f == 0){ ans++; f = 1;...
c02a8f34-f33b-4fa0-b56d-507b1bc96c76
5
public void nextState() { int[][] newState = new int[gridSize][gridSize]; for(int y = 0; y < gridSize; y++) { for(int x = 0; x < gridSize; x++) { int liveNeighbours = liveNeighbours(x,y); if(liveNeighbours < 2 || liveNeighbours > 3) newState[y][x] = 0; else if(liveNeighbours == 3) newState[...
360f272e-6851-41de-9e38-06ee32111832
3
private void loadProvinces(Path baseDir) throws IOException { Map<Integer, String> provinceNames = loadProvinceNames(baseDir); Path provinceDefinitionsPath = getFilePath(MapFile.DEFINITIONS, baseDir); try(BufferedReader reader = Files.newBufferedReader(provinceDefinitionsPath, MapUtilities.ISO...
348f44b8-0622-4f18-9d0d-be8a1e26c0a0
2
public void run() { try { while(Glory.getInstance().shouldThreadBeRunning()) ; } catch(Exception e) { } }
ed2a04dc-7fec-469d-9134-12eb7eae720b
3
public boolean play(int pos){ valid = true; canResume = false; try{ FIS = new FileInputStream(path); total = FIS.available(); if(pos > -1) FIS.skip(pos); BIS = new BufferedInputStream(FIS); player = new Player(BIS); new Thread( new Runnable(){ public void ...
cc5ca9f3-27f2-46a5-8f44-23eae64d8239
1
final public CycObject sentenceDenotingRepresentedTerm(boolean requireEOF) throws ParseException, java.io.IOException, UnsupportedVocabularyException { CycObject val = null; val = atomicSentenceDenotingRepresentedTerm(false); eof(requireEOF); {if (true) return val;} throw new Error("Missing return sta...
784e792e-0b8f-453b-9783-3b775a29027d
3
private static byte[][] ShiftRows(byte[][] state) { byte[] t = new byte[4]; for (int r = 1; r < 4; r++) { for (int c = 0; c < Nb; c++) t[c] = state[r][(c + r) % Nb]; for (int c = 0; c < Nb; c++) state[r][c] = t[c]; } return state; }
a9db5957-710a-43da-9a4b-312557dca092
5
@EventHandler public void closeInventory(InventoryCloseEvent e) { Player p = Player.class.cast(e.getPlayer()); if(PluginVars.editing.get(p) != null) { PluginVars.editing.get(p).close(); } if(PluginVars.commu_mode.get(p) != null) { PluginVars.commu_mode.get(p).close(false); } if(PluginVars.spectating....
e252a9cd-9fce-4a1d-9b7b-89f4eb049d20
1
public BURodCutting(int n, int price[]) { this.n = n; p = price; r = new int[price.length]; cuts = new String[price.length]; p[0] = 0; r[0] = 0; cuts[0] = ""; for (int i = 1; i < price.length; i++) r[i] = Integer.MIN_VALUE; cutRod(n); }
1fca62ed-809f-44c6-b1c5-4c0ccaec436a
4
@Override public void caseAConstructorHexp(AConstructorHexp node) { inAConstructorHexp(node); if(node.getRPar() != null) { node.getRPar().apply(this); } if(node.getLPar() != null) { node.getLPar().apply(this); } if(node.getI...
60a87e0c-05c4-4b4f-8906-3a2a757505c9
9
private VariableType factor() { VariableType type; Token t = popToken(); switch(t.getTokenType()) { case SCONSTANT: return VariableType.INTEGER; case SSTRING: if(t.getValue().length() == 3) { return VariableType.STRING_LENGTH1; } else { return VariableType.CHAR_ARRAY; } case SFALSE: ca...
780db872-b8ca-4518-85d3-9383b57ca4a0
4
public void dowork(){ Thread t1 = new Thread(new Runnable(){ @Override public void run() { // TODO Auto-generated method stub for (int i=0;i<100000;i++){ increment(); } } }); Thread t2 = new Thread(new Runnable(){ @Override public void run() { // TODO Auto-generated met...
8150361a-15af-47a3-a6ca-16fcf452b5e2
9
public String execute(DataSource source, String classTable, List<String> trainningModelTables, Map<String, Object> params) { StringBuilder sb = new StringBuilder(); // -- app runtime sb.append(SqlGenerator.setSchema(schemaName)); if (params != null) { sb.append(algorithm.updateParams(params)); } s...
acd6604f-d301-4bbe-ac02-c3207f9a8fbe
3
private void setModifier(String mod) { if (mod ==null) return; if (!(mod.equals(BLOCK)||mod.equals(JUMP))) return; this.modifier = mod; }
fbdd27b4-6f99-463e-b88b-8e5257fa7c11
5
@Test public void testMultipleMessagesMultipleSubscribers() { int noOfSubscribers = 2; int noOfMessages = 5; final HashMap<String, AtomicInteger> messages = new HashMap<String, AtomicInteger>(); final AtomicInteger msgCount = new AtomicInteger(0); try { final String message = "TestMessage-testGetMessage_...
8e8838c0-3af7-46d9-a5d9-ea3206502d86
1
public static byte[] hexStringToByteArray(String s) { int len = s.length(); byte[] data = new byte[len / 2]; for (int i = 0; i < len; i += 2) { data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i+1), 16)); } return da...
eeee44e5-185d-473f-82a6-8140e4d3867d
2
@Override public synchronized void start() throws Exception { if (!isActive()) { if (!isInitial()) doInit(); doStart(); } }
39a5791a-d887-4e59-9dff-eb70496dc84f
0
public String name() { return name; }
8a747e8d-4857-425c-83c2-b9f4cd679ebe
0
@Override public String toString() { return "fleming.entity.Hospital[ idHospital=" + idHospital + " ]"; }
17f43507-e3e8-45cf-83bc-2703df97a197
5
public int peekBitToInt(int val, int bit) throws IOException { while (true) { if (bit < availBits) { val <<= 1; if ((getBit + bit) >= BITS_PER_BLURB) { bit = (getBit + bit) % BITS_PER_BLURB; val |= ((buffer[getByte + 1] & (0x80 ...
21b4ee5d-b859-4691-8227-26f8c01e58de
9
private void cleaningText() { int latinCount = 0, nonLatinCount = 0; for(int i = 0; i < text.length(); ++i) { char c = text.charAt(i); if (c <= 'z' && c >= 'A') { ++latinCount; } else if (c >= '\u0300' && UnicodeBlock.of(c) != UnicodeBlock.LATIN_EXTEND...
2a1d666d-2a03-4d36-8a6b-d053b81bcaf1
5
public void calculateHappiness(int totalWins, int totalLosses) { if (totalWins == 0 || totalLosses == 0) { System.out.println("Insufficient Data."); } else if (totalWins > totalLosses) { System.out.println("Yay! You're winning more than you're losing, you " + "must be happy.\...
d0b92319-0076-48d9-9aca-d925ca0c6cbe
1
@Override public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) { CommandContext cc = new CommandContext(sender, cmd, alias, args, annot); try { return (Boolean)mcommand.invoke(cmdinstance, cc); } catch (ReflectiveOperationException e) { throw new CommandException("...
5a7ac38b-fe3e-4157-89cc-340293b1abac
2
private boolean hasTag(String version) { for (final String string : Updater.NO_UPDATE_TAG) { if (version.contains(string)) { return true; } } return false; }
2f3a1639-5aec-4639-8bbf-d2742b9db31c
0
private static void createAndShowGUI() { //Create and set up the window. frame = new JFrame("Towers of Hanoi"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Set up the content pane. addComponentsToPane(frame.getContentPane()); //Use the content pane's default ...
5708ede7-d3ec-4947-bf61-de124e711bf0
0
public int getAdjacentAntsBlack() { return adjacentAntsBlack; }
ac334460-b6cc-413d-b863-6e80bd66bd99
2
public static int getNextId(Class<? extends BaseEntity> clazz) { if (!ID_MAP.containsKey(clazz)) { resetIDtoZero(clazz); } return ID_MAP.get(clazz).getAndIncrement(); }
2e7c80bb-1385-450d-a007-4c95880fcfb2
0
public static void main(String[] args) { Implementor implementorA = new ConcreteImplementorA(); Abstraction abstractionA = new RefinedAbstractionA(implementorA); Implementor implementorB = new ConcreteImplementorB(); Abstraction abstractionB = new RefinedAbstractionA(implementorB); implementorA.operation();...
f22aea95-14ef-4eef-8c3b-5ba018731af1
8
boolean canAccommodate(CommentText comment) { // always accommodate if empty if (comments.size() == 0) { return true; } // cannot accommodate if the last marker was \j, \l, \r, \c, \s if (lastMarker.equals(ALIGN_LEFT_MARKER) || lastMarker.equal...
b142e8cc-923e-4bc9-af54-3437028fb99a
5
@Override public void controlPressed(Command c) { BasicCommand b = (BasicCommand) c; switch(b.getName()) { case "UP": model.up(); break; case "DOWN": model.down(); break; case "LEFT": model.left(); break; case "RIGHT": model.right(); break; ...
a90e1f34-fe45-400b-ab2b-41e8bc1dede2
7
private <T> ObjectConstructor<T> newDefaultConstructor(Class<? super T> rawType) { try { final Constructor<? super T> constructor = rawType.getDeclaredConstructor(); if (!constructor.isAccessible()) { constructor.setAccessible(true); } return new ObjectConstructor<T>() { @Sup...
27214585-a743-431b-8356-cb00f2d4afc6
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Bigram other = (Bigram) obj; if (lastPos == null) { if (other.lastPos != null) return false; } else if (!lastPos.equals(other.lastPos)) ...
bf195d48-864d-41d1-8d9d-bfbbb64816b1
5
public void closeConnection() { try { if (e != null && e.isOpen()) { e.close(); } } catch (IllegalStateException e) { e.printStackTrace(); } if (fac != null && fac.isOpen()) { fac.close(); } }
e0f50d0c-4021-49d0-b40c-489647e4c8cb
3
@Override public void run() { requestFocus(); long lastTime = System.nanoTime(); final double numTicks = 60.0; double nanoSeconds = 1000000000 / numTicks; double delta = 0; int frames = 0; int ticks = 0; long timer = System.currentTimeMillis(); ...