method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
103d5370-39cc-4c26-90e5-769744fbede8
5
@Override public int next() { int n = -1; if (start < cs.length()) { n = cs.charAt(start++); offset++; if (n == '\r') { lines++; columns = 0; } else if (n == '\n') { if (offset < 2 || cs.charAt(offset-2) != '\r') { lines++; columns = 0; } } else { columns++; } } el...
6f9b0cb2-0ec6-4447-845a-9d95f112f29f
2
private static boolean linearSearch(Long number) { for(int j = 0; j < unsorted.length; j++) { if(unsorted[j] == number) { return true; } } return false; }
c2818c82-9614-4b1e-a2b9-f38ad95b82c0
0
@Test public void isEmptyReturnsTrueAfterEnqueueDequeue() { q.enqueue(0); q.dequeue(); assertTrue(q.isEmpty()); }
91acde0b-d954-4c1c-814e-c745453373db
0
public static void setStartTime(CallInfo ci, Date start){ ci.setStart(start); }
f6d9221d-b048-4826-bcf1-41dab2ff0a8d
4
public static void editMember(Member m){ try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } Adress a = m.getAdress(); try{ conn.setAutoCommi...
59afc81c-3560-423c-9200-93ff54cdb7f3
9
public void teleport(LOGONode argx, LOGONode argy, boolean setX, boolean setY) { if (!setX && !setY) return; if (setX && setY) { Double retx = runAndCheckDouble(argx, "SETXY"); if (LOGOPP.errorhandler.error()) return; Double rety = runAndCheckDouble(argy, "SETXY"); if (LOGOPP.errorhandler.error()...
1383217b-4639-4ff2-b1ca-7eb88dd74555
0
public void setServerVersion(String serverVersion) { this.serverVersion = serverVersion; }
b72c6538-ddd6-4bff-a7b7-bc69f105829a
7
public void clearArea(ImageFrame img_frame, int x, int y, int width, int height) { //clear this area from main picture Image img = img_frame.getJIPTImage().getImage(); //get main image int totalWidth = img.getWidth(main_frame); //get main picture width int totalHeight = img.g...
38509ec2-249a-4f74-b833-2098b0b814dd
4
public static void binarySearch(int key, int lowerbound, int upperbound, List<Integer> list){ System.out.println("Key: "+ key); int position = (lowerbound + upperbound)/2; while(list.get(position) != key && lowerbound <= upperbound){ position = (lowerbound + upperbound)/2; if(list.get(position) < key...
4baf847a-3a47-441d-84af-ac663dce3855
3
private static void importGliderPosition() throws IOException, SQLException, ClassNotFoundException { String s; while((s = br.readLine()) != null) { String[] gliderPositionData = s.split(",",-1); GliderPosition importer = new GliderPosition(gliderPositionData[1], gliderPositionDa...
6378e5c1-e57b-4185-b7ed-2af3665d19dc
8
private void delete(RBNode z) { RBNode x = factory.create(); // work node to contain the replacement node RBNode y; // work node // find the replacement node (the successor to x) - the node one with // at *most* one child. if(z.getLeft() == sentinelNode || z.getRight() == sentinelNode)...
b196bd51-c803-4e17-867e-c640fd62e991
0
@Override public ProductA factoryA() { return new ProductA2(); }
3dc05bf0-d138-4942-b68c-993d97447e42
1
* @return <tt>true</tt> if CycFort GENL is a genl of CycFort SPEC * * @throws UnknownHostException if cyc server host not found on the network * @throws IOException if a data communication error occurs * @throws CycApiException if the api request results in a cyc server error */ public boolean isGenlOf...
9202feb4-d030-4343-bebd-8eba13ada111
5
public static String getProcessOutput(String... command) { String out = null; try { ProcessBuilder pb = new ProcessBuilder(command); pb.redirectErrorStream(true); Process process = pb.start(); final BufferedReader bufferedReader = new BufferedReader(new In...
e27f136c-35fd-46eb-981f-765ea2c6117b
9
private String criarMetodoSalvarAtualizar(String tableName, ResultSetMetaData rsMetadata, String pkey) throws Exception { StringBuilder insertUpdateMetodo = new StringBuilder(); insertUpdateMetodo.append("\n private void salvar" + tableName + "(List<" + tableName + "> lista" + tableName + ") throws E...
c255a374-94c3-473a-838e-44cd30a8bde6
1
public void testConstructorEx2_Type_int() throws Throwable { try { new Partial(DateTimeFieldType.dayOfYear(), 0); fail(); } catch (IllegalArgumentException ex) { // expected } }
98f8c3e5-d721-4bb4-bbf9-f13949ae12db
4
public void onKeyTyped(char c, int i) { if(i == KeyEvent.VK_ESCAPE || (int)c == KeyEvent.VK_ESCAPE) { if(this.currentGui == null) this.setCurrentGui(new GuiMainMenu(null, 0, 0, this.getWidth(), this.getHeight())); else this.setCurrentGui(null); } if(this.currentGui != null) this.currentGui....
a7fce712-ff25-48cd-958b-aa1843483aa8
6
public void update(float dt) { this.timeElapsed += dt; if (timeElapsed > 1) { this.canBeCaptured = true; } if (this.getBody() != null) { Body body = this.getBody(); if (body.getPosition().x < 0 || body.getPosition().y < 0 || body.getPosition().x > Gdx.graphics.getWidth() / Constants.WORLD_SCALE ...
12a735ac-cc9b-4328-b21e-fe216735f860
3
private static void handeClient() { Socket link = null; try { /* * Step 2: put the server into a waiting state */ link = serverSocket.accept(); /* * Step 3 : set up input and output streams between the server and * the client */ Scanner input = new Scanner(link.getInputStream()); ...
573dbbfe-3947-4b95-bf25-a01959d0de1b
2
public Connection getConnection() { if (conn == null) { if (openConnection()) { System.out.println("Connection opened"); return conn; } else { return null; } } return conn; }
88c472eb-1780-4956-9636-434cd1cdcbe6
9
public void reorderList(ListNode head) { if (head == null || head.next == null) return; ListNode fast = head, slow = head; while (fast != null && fast.next != null) { fast = fast.next.next; if (fast != null) { slow = slow.next; } } ...
7d0536e5-ec2a-4a81-93ed-8ba1ff03108e
2
protected synchronized Runnable getTask() throws InterruptedException { while (taskQueue.size() == 0) { if (!isAlive) { return null; } wait(); } return (Runnable)taskQueue.removeFirst(); }
2839ed6b-ea31-4f25-99a7-4d4cea098afc
2
private static boolean isPanlindrome(String s){ for(int i=0;i<s.length()/2;i++){ if(s.charAt(i) != s.charAt(s.length()-i-1)) return false; } return true; }
edae5062-ba07-4dc5-8263-c27e9ff3a68e
5
public void setPriority(T item, double newPriority) throws NoSuchElementException { int index; try { index = map.get(item); } catch (NullPointerException npe) { throw new NoSuchElementException(); } ...
a91e12d0-43db-45a1-8000-3bd97ab02621
9
private boolean doesIntersectInternal(AbstractLineSegment other) { final double d1 = direction(other.getP1(), other.getP2(), this.getP1()); final double d2 = direction(other.getP1(), other.getP2(), this.getP2()); final double d3 = direction(this.getP1(), this.getP2(), other.getP1()); final double d4 = direction...
7c36ddfe-dfd7-41a4-8529-2f6eaff10bc3
1
public void add(K key, V value) { List<V> values = this.map.get(key); if (values == null) { values = new LinkedList<V>(); this.map.put(key, values); } values.add(value); }
d890160c-2cc9-492c-9066-69f988a11975
1
public void testMaximumValue() { DateMidnight dt = new DateMidnight(1570, 1, 1, GJChronology.getInstance()); while (dt.getYear() < 1590) { dt = dt.plusDays(1); YearMonthDay ymd = dt.toYearMonthDay(); assertEquals(dt.year().getMaximumValue(), ymd.year().getMaximumValue...
07b0aabd-216d-4e07-809a-a24a7d2288c8
8
@Override public void getResults(Course curr, StyledDocument doc) { // TODO Auto-generated method stub // Load the default style and add it as the "regular" text Style def = StyleContext.getDefaultStyleContext().getStyle( StyleContext.DEFAULT_STYLE ); Style regular = doc.addStyle( "regular", def ); /...
91321fea-d456-43ec-96fd-e858fb064597
6
public void setAdditionalDisplay(JComponent additionalComponent) { if (currentAdditionalDisplay == null && additionalComponent != null) { if (flowLayout) flowLayoutGatesPanel.setVisible(false); else nullLayoutGatesPanel.setVisible(false); } ...
4b3ca50c-926c-4771-bcf5-a461835f78f0
8
@Override public void paintComponent(Graphics g) { super.paintComponent(g); // paint background // setBackground(Color.BLACK); world.setUnit(player); String report = ""; String victims = ""; for(AUnit u:player.getVictimList()){ victims = victims + " <br> " + u.getUnitName() + " was sunk !!! by " + playe...
023d8174-e689-416b-9687-868c3c2647f6
0
public WordProcessing() { }
48d91f52-3829-43db-948c-c00fadc553c1
9
public int compare(String[] o1, String[] o2) { int result = 0; for (int i=0;i<o1.length && i<o2.length;i++) { String s1 = o1[i]; String s2 = o2[i]; if (s1 == null) { if (s2 == null) { result = 0; } else { result = 1; } } else { if (s2 == null) { result = -1; } else { ...
e5de9c8b-bc45-4aa2-9546-3ea7c242a180
0
public UpgradeMenu(ProBotGame game) { super(game); bodypartPanel = new JPanel(); upgradePanel = new JPanel(); }
26e33cb6-1e50-47fe-8f58-b8f04a3ab662
0
public void setTransitionsFromTuringFinalStateAllowed(boolean t) { transTuringFinal = t; transTuringFinalCheckBox.setSelected(t); }
1165d739-c68a-431f-98b7-9e8fd69f01ed
7
public JSONObject getQuestionsTag(int USER_ID) { try { Class.forName(JDBC_DRIVER); conn=DriverManager.getConnection(DB_URL,USER,PASS); Statement stmt2=conn.createStatement(); stmt=conn.createStatement(); json=new JSONObject(); json.put(SUCCESS, 1); ResultSet rstemp=stmt2.exe...
3d1b6b93-aa8a-4897-aedb-25e3470a5bd9
4
public boolean logar(String login,String senha) throws UnknownHostException, IOException{ if(!login.equals("") && !senha.equals("") && login!=null && senha!=null){ Usuario usuario = new Usuario(); usuario.setSenha(senha); usuario.setUsuario(login); Conexao conexao = new Conexao(12345); conexao.conectar...
7d0aa04e-8253-4a4d-8dd7-08ed7da0ca64
3
@Override protected List<URI> parseInternal(BufferedReader in) throws IOException { try { SAXSearchResultParser parser = new SAXSearchResultParser(); parser.parse(new InputSource(in)); List<String> resultStrings = parser.getResults(); List<URI> results = new ArrayList<>(resultStrings.size()); for ...
c730167f-6401-4964-b78c-6b5a574ff2c5
3
public int peek(boolean fromDiscard){ if (fromDiscard) return discard_count == 0 ? 0 : discard[discard_count-1]; return draw_count == 0 ? 0 : draw[draw_count-1]; }
7b1c7655-9dba-4b80-a21b-3cf49e5362c3
7
public void outputReport() throws IOException { ListMultimap<String, String[]> commonMap = Multimaps.newListMultimap( new TreeMap<String, Collection<String[]>>() , new Supplier<ArrayList<String[]>>() { @Override public ArrayList<String[]> get() { return new ArrayL...
61362052-f2bf-490c-9161-bf0c53267fa5
1
private static String getFileContents(String filename) throws IOException, FileNotFoundException { File file = new File(filename); StringBuilder contents = new StringBuilder(); BufferedReader input = new BufferedReader(new FileReader(file)); try { String line = ...
a6f77a91-8842-489a-9dc4-6aaffb22b1f1
3
private double parseAngleFields(JTextField degrees, JTextField minutes, JTextField seconds) { double d, m, s; try { d = Double.parseDouble(degrees.getText()); } catch (NumberFormatException nfe) { d = 0.0; } try { m = Double.parseDouble(minutes.getText()); } catch (NumberFormatException nfe) {...
e6b358a7-a813-4ab0-964d-1090ab44e1eb
2
@EventHandler(priority = EventPriority.NORMAL) public void onPlayerDeathInArena(PlayerDeathInArenaEvent evt) { Player victim = evt.getVictim(); if (evt.getCause() == DeathCause.ENVIRONMENT) { String lastAttacker = SE.getStorage(victim.getName()).getLastHit(); @SuppressWarnings("deprecation") Player killer...
5936367f-8bc0-476d-9706-3165a64588c8
2
public synchronized void addCommandLineListener(CommandLineListener listener){ List<CommandLineListener> listeners = new ArrayList<CommandLineListener>(); if (this.listeners != null){ listeners.addAll(this.listeners); } if (!listeners.contains(listener)){ listeners.add(listener); } this.listeners =...
d81c8891-59e8-448f-9451-a4061e17397f
8
@Test public void testBigMerge() { Random r = new Random(260379); TreeMap<Integer, Integer> leftSet = new TreeMap<Integer, Integer>(); TreeMap<Integer, Integer> rightSet = new TreeMap<Integer, Integer>(); // There must be collisions and also some omissions for(int i=0; i < ...
08b8fceb-0fa4-42fa-ad5d-a86665d42770
2
public Object newArray(String type, int[] dimensions) throws InterpreterException, NegativeArraySizeException { if (type.length() == dimensions.length + 1) { Class clazz; try { clazz = TypeSignature.getClass(type .substring(dimensions.length)); } catch (ClassNotFoundException ex) { throw new...
2d8dc8cc-fc0c-40ed-9d80-f5bb0a2ab754
6
private void selectWord(MouseEvent e) { if (selectedWordEvent != null && selectedWordEvent.getX() == e.getX() && selectedWordEvent.getY() == e.getY()) { // We've already the done selection for this. return; } Action a = null; RTextArea textArea = getTextArea(); ActionMap map = textArea.getAction...
e84b1ca8-0456-4b27-a71d-95e3d750ace2
2
@Override public String toString() { StringBuffer buf = new StringBuffer(); for (int i = 0; i < data.length; i++) { if (i != 0) { buf.append(this.delimiter); } buf.append("" + data[i]); } return buf.toString(); }
cac8f95e-0109-43fc-bed3-9053c8298842
2
public void addEdge(Vertex v, Vertex w) { if (!adjMap.containsKey(v)) { adjMap.put(v, new HashBag<Vertex>()); } if (!adjMap.containsKey(w)) { adjMap.put(w, new HashBag<Vertex>()); } adjMap.get(v).add(w); adjMap.get(w).add(v); }
9405e00c-2d39-4978-b06b-1f9a146db535
1
public void draw(Graphics2D g) { if (gameStates[currentState] != null) gameStates[currentState].draw(g); else { g.setColor(Color.BLACK); g.fillRect(0, 0, GamePanel.WIDTH, GamePanel.HEIGHT); } }
c3cd5f89-9e2a-4e6c-98a9-12c810950ac3
4
@Override public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet) { if (npc instanceof L2ChestInstance) { final L2ChestInstance chest = ((L2ChestInstance) npc); // If this has already been interacted, no further AI decisions are needed. if (!chest.isInteracted()) { ...
6c67dee4-e302-45eb-837c-28c0fb364d96
0
public String getUniversity() { return this.university; }
a8d26999-d362-4630-a22a-b64bf39d02ab
4
private PropertyDescriptor getWriteMethod(Field field) throws Exception { PropertyDescriptor descriptor = null; String fieldName = field.getName(); try { PropertyDescriptor[] descriptors = Introspector.getBeanInfo(clazz).getPropertyDescriptors(); for (PropertyDescriptor p...
77e792f5-26e3-4ce1-a7a2-c6dc61852c5b
0
public static void main(String[] args) { AccessRight accessRight = AccessRight.MANAGER; AccessRight accessRight1 = AccessRight.valueOf("DEPARTMENT"); chechAccess(accessRight); chechAccess(accessRight1); }
43ede8e0-6b6c-444a-ae01-236cd149183b
6
private void btnModificarEmpleadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarEmpleadoActionPerformed //creamos un empleado temporal, a partir del renglón seleccionado en la tabla: Empleado empleadoTemporal = obtenerInformacionDeRenglonSelecccionado(); /*Si el ...
ae91c4be-d9bb-4cc0-959c-0241d44da0b7
0
public int getAttemptsLeft(){ return ReconnectAttempts; }
c4b0dc82-af30-49d6-bceb-e02bca8534ed
3
public void destroy() { if (!stopped) { try { worker.join(); } catch (InterruptedException e) { } try { selector.close(); } catch (IOException e) { } } }
cfc47928-3ed8-46b4-8c35-7aae751f2594
0
public DisPane(){ super(); }
e504742e-6e86-4e67-b6c7-3134e3428a78
5
@SuppressWarnings("unchecked") private <T> TypedStringConverter<T> findConverterQuiet(final Class<T> cls) { if (cls == null) { throw new IllegalArgumentException("Class must not be null"); } TypedStringConverter<T> conv = (TypedStringConverter<T>) registered.get(cls); if ...
a1a74364-2c85-4df5-83a6-5fef8636cd2d
7
private void writeSymbolMap() throws IOException { BZip2BitOutputStream bitOutputStream = this.bitOutputStream; final boolean[] blockValuesPresent = this.blockValuesPresent; final boolean[] condensedInUse = new boolean[16]; for (int i = 0; i < 16; i++) { for (int j = 0, k = i << 4; j < 16; j++, k++) { ...
5909d81d-d18e-4f07-95e4-59e2527740dc
6
public boolean checkRoom(int... pos) { if (pos.length != 2) return true; if (openedRooms[pos[0]][pos[1]]) return false; if (openedRoomsCount >= structure.getRoomsCount()) // cant happen return true; Room room = structure.getRooms()[pos[0]][pos[1]]; if (room == null) return true; opened...
1dce131e-8d2e-4244-aac6-f043cc758f58
2
@Override public int compareTo(final TPair64 p) { return u == p.u ? 0 : ((u < p.u) ^ (u < 0) ^ (p.u < 0)) ? -1 : 1; // unsigned 64-bit comparison }
cc4d94ec-966d-4a46-81b8-2dd0fff3ec12
6
public void findBestSystem() { for (SoftwareSystem softwareSystem : systems) softwareSystem.refine(); bestSoftwareSystemEP = systems.get(0); bestSoftwareSystemW = systems.get(0); worstSoftwareSystemEP = systems.get(0); worstSoftwareSystemW = systems.get(0); for (SoftwareSystem softwareSystem : systems) {...
6b9de967-ef83-4e7a-b911-90197eb4833e
4
public boolean hasOverdueItems(){ boolean overdueItemFound = false; for(Copy copy : itemsBorrowed){ if(copy.isOverdue()){ overdueItemFound = true; } } for(Copy copy : booksBorrowed){ if(copy.isOverdue()){ overdueItemFound = true; } } return overdueItemFound; }
8a21bd55-8121-42af-82c7-6d601f6bae69
0
public void setExtraData(String extraData) { this.extraData=extraData; }
f21b164a-50ea-4379-a126-fed8bb3bf967
7
public static void main(String args[]) { Scanner sc = new Scanner(System.in); int H, U, D, F; while (true) { H = sc.nextInt(); if (H == 0) { break; } U = sc.nextInt(); D = sc.nextInt(); F = sc.nextInt(); ...
f8f9bdb9-ba02-4ebf-afb8-857aa793bfdc
6
@EventHandler public void IronGolemHunger(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.getIronGolemConfig().getDouble("IronGolem...
9ec19b05-05b8-4188-9207-4d4d712d84e8
8
@Override public void paintComponent(Graphics g) { // couleur de fond pour le rectangle qui est affiche pour // ne pas avoir de trainee mais un objet qui bouge g.setColor(Color.WHITE); g.fillRect(0, 0, this.getWidth(), this.getHeight()); //on dessine flakboy g.setCol...
e33660f7-8cf8-4e06-8564-adb14c82daed
8
public void startWave() { if(stage != Stages.RUNNING) return; int currentWave = getCurrentWave(); player.getInterfaceManager().sendTab(player.getInterfaceManager().hasRezizableScreen() ? 11 : 0, 316); player.getPackets().sendConfig(639, currentWave); if(currentWave > WAVES.length) { if(currentWave == 37...
06b0eb68-7ca0-4816-8146-ab4459ef580e
7
@Override public void unInvoke() { if(canBeUninvoked()) { if(affected instanceof MOB) { final MOB mob=(MOB)affected; if((buildingI!=null)&&(!aborted)) { if(messedUp) { if(activity == CraftingActivity.LEARNING) commonEmote(mob,L("<S-NAME> fail(s) to learn how to make @x1.",...
9fa53a8e-9957-46c0-b15d-b4a981dd599a
4
public void keyReleased(KeyEvent e) { //Para la entrega Alpha, una vez que se haya inicado el juego, se presiona la tecla 2 para ir al nivel 2, la tecla 3 para ir al nivel 3 // y la tecla G para terminar el juego if (nivel > 0) { if (e.getKeyCode() == KeyEvent.VK_G) { ...
6ac65ec0-4f19-4cb0-99a3-e6582e721f30
2
public int getType() { if (doc != null) { return TYPE_DOC; } else if (file != null) { return TYPE_FILE; } else { return TYPE_UNKNOWN; } }
b2548f4b-5718-4395-9448-1d0c5630be25
0
public CheckResultMessage checkJ02(int day) { return checkReport.checkJ02(day); }
0e56806d-985b-4fa0-967c-453ee43cc523
4
public void resize(int x, int y){ Patch[][] newGrid = new Patch[y][x]; for (int i = 0; i<y; i++){ for (int j = 0; j<x; j++){ if (i<getHeight() && j<getWidth()){ newGrid[i][j] = _grid[i][j]; } else newGrid[i][j] = new Patch(this, j, i); } } _grid = newGrid; }
e0b9361d-17a0-48c3-8a5c-756e824c2be2
4
public boolean isAuthorized(String password) { if (encryptionDictionary.getRevisionNumber() < 5){ boolean value = standardEncryption.authenticateUserPassword(password); // check password against user password if (!value) { // check password against owner passw...
e91207a5-32bd-4638-8b90-ac1387dd7752
0
@After public void tearDown() { eventBus = null; }
dd9daf24-8a11-4697-a319-7052a30f86e2
9
@Override public void run() { final IdFactory _id = IdFactory.getInstance(); _idConection = _id.newId(); getLogger().log(Level.INFO, "Client Thread Started ..."); try { _connection.sendPacket(new SHello(_idConection, "09928")); boolean _while = true; ...
8d78a04e-ee20-456e-8983-bc1069b899d1
2
public String mapSignature(String signature, boolean typeSignature) { if (signature == null) { return null; } SignatureReader r = new SignatureReader(signature); SignatureWriter w = new SignatureWriter(); SignatureVisitor a = createRemappingSignatureAdapter(w); ...
7822d7ec-69c2-4db4-b9ff-f9f3ea14fcf3
0
public void setLastName(String lastName) { LastName = lastName; }
4a0f7d0a-dba9-4d3d-a6a5-a595688f799f
1
public static void add(String playerUUID, String regionName) { ArrayList<String> places = Spectacles.storedPlayerData.get(playerUUID); if (!places.contains(regionName)) { places.add(regionName); } Spectacles.storedPlayerData.put(playerUUID, places); save(Spectacles.st...
d997c9a7-6e46-4e6e-af0c-456bca4aeccf
0
public static void Severe(String s){ log.info("[AprilonIRC] " + s); }
a2a2991f-099b-4c9a-bd98-87e6cebe9eef
1
private void checkTypeName( String typeName ) { if( !typeName.matches( "[a-zA-Z0-9]+" ) ) { throw new IllegalArgumentException( "typeName contains not supported characters: " + typeName ); } }
61adf38e-c949-4b77-9369-fb9eaf5f41d8
6
public static void validateUser(UserTO userTO) throws ParameterValidationException{ System.out.println("Validating userTO"); //Evaluating name System.out.println("Evaluating name"); String name = userTO.getName(); if(!name.matches("[a-zA-Z ]+")){ throw new ParameterValidationException("The name cannot con...
1d0d3650-403b-4e3a-b37b-e4d0b5b38b41
5
public double maxValue(KrakenState state, String player, double alpha, double beta) { if (expandedNodes==maxNodesExpand || game.isTerminal(state)){ if (heuristics==null) return heuristic.h(state); else return getHeuristicFusion(state); } expandedNodes++; double value = Double.NEGATIVE_INFINITY; ...
35deace5-75d1-4379-b52f-8e051bd6887e
2
public int getInt(String key) throws JSONException { Object object = this.get(key); try { return object instanceof Number ? ((Number)object).intValue() : Integer.parseInt((String)object); } catch (Exception e) { throw new JSONException("JSO...
98198157-04d4-45fe-b5fe-941c12ed89ae
3
public static List<Integer> divisors(int n){ List<Integer> divisors = new ArrayList<Integer>(); for(int i =1;i<Math.sqrt(n);i++){ if(n%i == 0){ divisors.add(i); if(i != 1) divisors.add(n/i); } } return divisors; }
f5e593a5-10eb-4938-9b4c-5d43523b13ef
3
@Override public String strip(String s) throws Exception { int length = s.length(); char[] oldChars = new char[length + 1]; s.getChars(0, length, oldChars, 0); oldChars[length] = '\0'; // avoiding explicit bound check in while // find first non-printable, // if there...
3c713fa6-32ac-4d1b-96af-725ac060363d
5
@Override public void run() { while(!manager.stopThreads){ try { //Delay for interval amount of seconds Thread.sleep(1000 * this.getInterval()); System.out.println("Sending HTTP GET to Tracker."); generateTrackerURL(); getTrackerResponse(); if (manager.stopThreads) break; decodeTr...
127aa9f3-9587-4390-aa93-f4dffa7c7885
9
public Double evaluate(HashMap<String, Double> histogram) { if (histogram == null) { return null; } double total = 0.0; for (Double value : histogram.values()) { if (value != null) { if (value >= 0) { total += value; } else { return null; } ...
f8405253-3590-46dc-8495-5088b8433c3c
0
@Override public void setCanceled(boolean isCanceled) { this.isCanceled = isCanceled; }
b40d5a11-54f0-4728-8840-b6352cfc55c7
0
public Map<String, Object> getSymbolsFunctionEnvironmentRecord() { return environmentStack.peek().getSymbolsSymbolTable(); }
5177520b-f2b7-45f3-bd80-eee4da837c43
9
public void create(Usuario usuario) { if (usuario.getVendaList() == null) { usuario.setVendaList(new ArrayList<Venda>()); } if (usuario.getReservaList() == null) { usuario.setReservaList(new ArrayList<Reserva>()); } EntityManager em = null; try { ...
f163ec2d-98ae-4596-a317-1eddd5297606
5
private void setupActionListeners() { openBookListener = new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { mainMenuShowing=false; frame.requestFocusInWindow(); layers.setVisible(true); String chosenBook = mainMenuPanel.getChosenBook(); if(chosenBook!=null) ...
b3f30bdf-0fc5-4857-85d0-60d5f1e62b22
0
public void updateOsoba(int index, Osoba newOsoba) { data.set(index, newOsoba); fireTableRowsUpdated(index, index); }
f286af16-0bf9-4614-97a9-be78ab18adcd
2
public void addDataType(String parameterCode){ String dataType = AirNowDataPoint.getDataTypeName(parameterCode); if (dataType != null) if (dataTypes.indexOf(dataType) == -1) dataTypes.add(dataType); }
512db671-7af8-4ff5-8a50-9092961ba70a
9
public static void main(String[] args) { int n=Integer.parseInt(JOptionPane.showInputDialog("Ingrese el rango del vector")); int[] arreglo=new int[n]; int c=0; for (int i = 0; i < arreglo.length; i++) { int numero=Integer.parseInt(JOptionPane.s...
1b7ac123-0b80-438e-b5ce-4e1991567506
6
public static Board parse(String filename) throws IOException { Preconditions.checkNotNull(filename, "filename cannot be null"); String line; StringBuilder boardBuilder = new StringBuilder(); // Read input file BufferedReader reader = new BufferedReader(new FileReader(filename)); while...
ca68fd39-e065-4bf3-91fa-6bde681eb38e
2
@Override public void onPacketSending(PacketEvent event) { switch (event.getPacketID()) { case 0x03: PacketContainer packet = event.getPacket(); String message = packet.getSpecificModifier(String.class).read(0); message = (PerPlayerChatFilter.getI...
ddfc3f68-e3ab-4ad5-b4b8-621afcb03233
1
public void paint(Graphics g) { g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(Color.WHITE); FontMetrics m = g.getFontMetrics(); int y = 0; g.drawString("An error has occurred.", 0, y + m.getAscent()); y += m.getHeight(); g.drawString(status, 0...
5b215522-21f6-4141-a5f4-eaa11cdac439
4
public void kopioiKuvaUlosJarResourcesTiedostosta(String lahde, String maaranpaa) { File kohdeTiedosto = new File(maaranpaa); if (kohdeTiedosto.exists()) { System.out.println("Tiedosto " + kohdeTiedosto.getPath() + " on jo tallennettuna"); } else { try { ...
bcff4b2b-6e72-4a88-923f-02fd4d448b16
7
@Override public String getColumnName(int column){ String name = "??"; switch (column){ case 0: name ="medArbId"; break; case 1: name ="Fornavn"; break; case 2: name ="EfterNavn"; break; case 3: name ="TelefonNr"; break; case 4: name ="Rolle Id"; break; ca...