method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
b329167a-8e7e-4648-90bb-4b803f11e47d
9
public static User getUserFromJson(JSONObject obj){ if(obj == null) return null; User user = new User(); Object value = obj.get("id"); if(value != null) { user.setId(value.toString()); } value = obj.get("id_room"); if(value!=null) { user.setId_room(value.toString()); } val...
6b4d5550-14ff-4191-9423-24e817121fb0
6
public static int getDepth(Node<Integer> p){ if(p == null) return 0; int h1 = getDepth(p.left); if(h1 == -1) return -1; int h2 = getDepth(p.right); if(h2 == -1) return -1; if(h1 >= h2){ if(h1 - h2 < 2) return h1 + 1; return -1; } else { if(h2 - h1 < 2) return h2 + 1; return -1; ...
db339697-dd5e-46ff-a4d0-5a0b04b2c587
9
protected void readChildren(XMLStreamReader in) throws XMLStreamException { Settlement oldSettlement = settlement; Player oldSettlementOwner = (settlement == null) ? null : settlement.getOwner(); settlement = null; super.readChildren(in); // Player settlement list i...
d378fddb-dfb6-4be2-8f03-29b5f795734f
6
public int diff_xIndex(LinkedList<Diff> diffs, int loc) { int chars1 = 0; int chars2 = 0; int last_chars1 = 0; int last_chars2 = 0; Diff lastDiff = null; for (Diff aDiff : diffs) { if (aDiff.operation != Operation.INSERT) { // Equality or deletion. chars1 += aDiff.text.length(); } if (aDiff...
df474600-0d99-4a71-9d31-dbbc43d9c683
8
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerTeleport(PlayerTeleportEvent event){ Player player = event.getPlayer(); String playerName = player.getName(); Location location = event.getFrom(); String worldName = location.getWorld().getName(); if (!worldName.equals(plugin.lobbyWorld))...
1a87ed71-2a72-44a4-bb7f-3d69e2ff1a4d
2
private void getPicturesPath(JTextField field) { JFileChooser chooser = new JFileChooser(); if(ProjectMainView.actualFolder!=null) chooser.setCurrentDirectory(ProjectMainView.actualFolder); chooser.setDialogTitle("Chose JPEG file"); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setAcceptAll...
735c363f-54e2-4b59-81b3-b0b256d13ca4
0
public int getOrthoHeight() { return 600; }
b9794e59-04cf-4499-8000-7fcb4a2c2e5c
6
public void fixOutOfBounds() { // prevent any invalid permeabilities if(perm > 100) perm = 100; if(perm < 0) perm = 0; // prevent any invalid temperatures if(temp > maxTemp) temp = maxTemp; if(temp < minTemp) temp = minTemp; // prevent any invalid pressures if(pres > maxPres) pres ...
be0b8f3c-f7e1-4a67-86aa-79502779de8f
4
void floyd() { int rows = d.length; for (int k = 0; k < rows; k++) for (int i = 0; i < rows; i++) for (int j = 0; j < rows; j++) if (d[i][j] > d[i][k] + d[k][j]) { d[i][j] = d[i][k] + d[k][j]; } }
4d84d5ba-cf0b-4d36-97dd-6b42f9ef1d07
1
public ImageProcessor canny(ImageProcessor ip){ //Filter out noise ImageProcessor result = ip.duplicate(); result.blurGaussian(sigma); //Compute the intensity gradient using Sobel ImageProcessor Gx = xGradient(result); ImageProcessor Gy = yGradient(result); //Compute the magnitude of the gradient F...
bfae6a3c-fc3b-4db2-a58a-1fa44fff134f
7
public static long parseTimeInterval(String str) { try { int len = str.length(); char suffix = str.charAt(len - 1); String numstr; long mult = 1; if (Character.isDigit(suffix)) { numstr = str; } else { numstr...
baf70604-86a8-49ee-ab72-05d370e23b85
5
public void cellRCDraw(int x, int y){ if( y % 2 == 1 ^ x % 2 == 1){ if(!sedna.getSelected() ||sedna.getSelection(x,y)){cellDraw(x,y);}} else{ if(!sedna.getSelected() ||sedna.getSelection(x,y)){cellRandDraw(x,y);}} }
1c088fe4-cbbf-490e-b2f5-d08fd8f301ac
7
public void keyPressed(int code) { if (onMenuScreen) return; else { if (code >= 37 && code <= 40) { // ARROW KEYS int dn = code - 38; if (dn == -1) dn = 3; character.startMoving(directions[dn]); } if (code == 32) { // SPACEBAR if (jump > 0) { character.jump(); jump--; ...
915f092a-f167-4144-9e10-bdb2669eb1b4
4
public Wave(int n, int d){ waveNumber = n; difficulty = d; waveHealth += waveNumber*10; strengthInNumbers += waveNumber; if (waveNumber % 10 == 0){ boss = true; strengthInNumbers = 1; } if (waveNumber % 3 == 0){ status = "Heavy"; } else if(waveNumber % 4 == 0){ status = "Light"; }...
7c2782ec-f259-4295-a455-649ccd066c23
0
public void setTrainingName(String trainingName) { this.trainingName = trainingName; }
b4b0eed7-2901-4770-8f08-fb62f10671ee
0
public int getQuestTimeout() { return QuestTimeout; }
4348595e-d421-4396-8f58-932436e36d79
7
private boolean encercleAdversaire(Couleur uneCouleur, Position unePosition, Direction uneDirection) { Position laPositionVoisine = unePosition.obtenirVoisine(uneDirection); if (!this.plateau.estPositionValide(laPositionVoisine)) return false; Case laCaseVoisine = this.plateau.obtenirCase(laPositionVois...
5c2f7c68-8658-43f3-a298-4c980c1e9313
0
public void create(int roomNumber) { this.setRoomNumber(roomNumber); }
6e8f9e49-082a-4ae6-8976-442d3c45888b
9
public CmdAbst getCmdInstance(String xml) throws CumExcpIllegalCmdXML, CumExcpIllegalCmdDoc { Document doc = getDom(xml); Node cmdNode = getCmdNode(doc); String type = getCmndType(cmdNode); String action = getAction(cmdNode); Class<? extends CmdAbst> myClass = classMap.get(getClassName(type, action)); ...
de0d5daf-21a8-4f6a-87da-0857f42b7eef
7
public static void printTime() { // Store the minutes, seconds and milliseconds of each lap int[] minutes = new int[lapTimes.length]; int[] seconds = new int[lapTimes.length]; int[] milliseconds = new int[lapTimes.length]; // For each lap, calculate the minutes, seconds and milliseconds for (int lap = 0; ...
683f6976-1fde-450e-9344-4315cb08c094
4
private void notifySearchListeners(){ String recipeName = recipeList.getSelectedValue(); boolean match = false; Recipe foundRecipe = null; for( Recipe recipe : recipes ){ if ( recipe.getName().equals(recipeName)){ foundRecipe = recipe; match =...
9408138b-bb5a-4df1-867f-370b625ec195
7
public Object nextValue() throws JSONException { char c = this.nextClean(); String string; switch (c) { case '"': case '\'': return this.nextString(c); case '{': this.back(); return new JSONObject(this); ...
79a8c2e5-c929-4d41-9a12-a4d5f6a67af1
1
@Override public void paint(Graphics g) { super.paint(g); Graphics2D g2; g2 = (Graphics2D) g; g2.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP); if (activeLeftPanel) { g2.setColor(...
feea748f-1f01-4f23-835d-ab087e560320
9
public boolean setInputFormat(Instances instanceInfo) throws Exception { super.setInputFormat(instanceInfo); m_DeltaCols.setUpper(getInputFormat().numAttributes() - 1); int selectedCount = 0; for (int i = getInputFormat().numAttributes() - 1; i >= 0; i--) { if (m_DeltaCols.isInRange(i)) { ...
eb0e49fa-e746-4dcf-9ec8-0ff8589cf626
3
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String input = request.getParameter("input"); ArrayList<Result> values = new ArrayList<Result>(); for(String key : context.getMapKeys()){ if(input.toLowerCase().contains(key.toLo...
97f3f845-63a0-4b32-9e07-97d6c0b82a64
2
public int cld(Model model){ int res = 0; for(Generalization g : model.getGeneralization()){ if(g.getIdentifier().equals(this.identifier)){ res = cheminPlusLongVersFeuille(model, g); } } //System.out.println(res); return res; }
c4085f5d-091d-4986-b143-a3b7bae7ca85
9
public Boolean checkNewRoom(Tile cTile, Room nRoom){ int newRoomX = 0; int newRoomY = 0; /* if (cRoom.getXPos()+nRoom.getDX() + 1 > newMap.getDim() || cRoom.getYPos()+nRoom.getDY() + 1 > newMap.getDim()){ return false; } if (cRoom.getXPos()-nRoom.getDX() - 1 < 0 || cRoom.getYPos()+nRoom.getDY() - 1 < 0){...
4aa89d9c-f76d-4062-bc31-891fea550a1b
3
public static Collection<SerialPortChannel> findAll() throws ChannelException { try { Collection<SerialPortChannel> all = new ArrayList<>(); Enumeration portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { CommPortIdentifier...
b8538f72-c66b-4a20-8ea0-9bc816d16b03
7
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { Player player = (Player) sender; if (commandLabel.equalsIgnoreCase("Heavy") && sender instanceof Player){ if (player.hasPermission("EasyPvpKits.Heavy")){ if (!plugin.kits.contains(player.getName())){ playe...
d56eaf3d-5ba2-43da-beb3-132028b0587b
3
public int stringHeight(String str) { if (str == null) return 0; int height = 0; int length = str.length(); for (int i = 0; i != length; ++i) { int h = charHeight(str.charAt(i)); if (height < h) height = h; } return height; }
2826c28b-4588-4783-b1d4-42a5dfe0c7ac
1
public Boolean update(String query) { if(this.autoCommit){ return writeData(query.replace(" ", "+")); } this.queries +=query.replace(" ", "+")+"\n"; return null; }
db42c257-c043-4ada-81e5-157d7d27c814
4
public void IndexCedd(String indexLoc){ System.out.println("-----Indexing images for CEDD descriptor in: " + FileLocation + "-----"); //Get all files from sub-directory ArrayList<String> imagePaths = getFilesFromDirectory(); //Create standard config file for the index writer IndexWriterCo...
e791bb03-7fda-4018-9b7c-680d0c4be9bf
2
public void draw(int x_offset, int y_offset, int width, int height, Graphics g) { //int xleft = x_offset + 1 + (x * (width + 1)); //int ytop = y_offset + 1 + (y * (height + 1)); //g.drawImage(lab, xleft, ytop, width, height, null); if(contains(Mho.class)) { ((Mho)occupant).draw(x_offset, y_offset, width, hei...
1db6c386-0581-4999-bb55-cae4213a3417
6
private static int getFormat(AudioFormat streamFormat) { int format = -1; if (streamFormat.getChannels() == 1) { if (streamFormat.getSampleSizeInBits() == 8) { format = IAudioDevice.FORMAT_MONO_8; } else if (streamFormat.getSampleSizeInBits() == 16) { format = IAudioDevice.FORMAT_MONO_16; } } els...
509dbddf-a54c-45fd-85da-99dc609af4fa
5
public void moveOnFinalPath(int moveRemaning) { System.out.println("Coin.moveOnFinalPath() " + this); LudoRegion region = LudoRegion.values()[this.getBlockNo().getRegion() - 1]; System.out.println(this.getBlockNo().getRegion() + " Coin.moveOnFinalPath() region " + region); if(moveRemaning > 6){ //invalid mov...
d9e134af-6647-45cf-9e95-9369ed2780d9
3
public void vaikutaTilanteeseen(int poistetutRivit) { if(poistetutRivit > 0) { int edellisetPisteet = pelinTila.arvo(Pelitilanne.Tunniste.PISTEET); int seuraavatPisteet = edellisetPisteet + 2 * (poistetutRivit - 1) + 1; pelinTila.aseta(Pelitilanne.Tunniste.PISTEE...
8f97e125-b59c-4f9e-b6d9-6759d865a43a
9
public IndexedModel toIndexedModel() { IndexedModel result = new IndexedModel(); IndexedModel normalModel = new IndexedModel(); HashMap<OBJIndex, Integer> resultIndexMap = new HashMap<OBJIndex, Integer>(); HashMap<Integer, Integer> normalIndexMap = new HashMap<Integer, Integer>(); ...
655f1fad-554c-44b6-93e4-f41181c9d10e
1
public void removeNew(int where) throws CannotCompileException { try { byte[] data = new NewRemover(this.get(), where).doit(); this.set(data); } catch (BadBytecode e) { throw new CannotCompileException("bad stack map table", e); } }
19294c68-2bf4-4543-b9d9-0a7b49eb5736
5
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Servico other = (Servico) obj; if (this.IdServico != other.IdServico && (this.IdServico == null || !this....
98b0a418-590c-4679-a5d8-f74b0f8a1dda
7
public void game() { /* Update the game as long as it is running. */ while (canvas.isVisible() && !restart && !player.isLevelCompleted()) { if (!pause) { /*If the player have lives left and have not won*/ if((player.getNumLives() > 0) && !(player.getWon())) { updateWorld(); // Update the world }...
2dff79b9-be89-4ebf-8fbb-e69d1c204a98
3
public static void noSpace(String string) throws JSONException { int i, length = string.length(); if (length == 0) { throw new JSONException("Empty string."); } for (i = 0; i < length; i += 1) { if (Character.isWhitespace(string.charAt(i))) { throw new JSONException("'" + string +...
c4c6c9ac-c478-4058-b2f1-7b0b2750ad9d
3
private String constructPWhashForIPboard(String salt, String pw) { //$hash = md5( md5( $salt ) . md5( $cleaned_password ) ); /* this is how IPboard constructs the hash $hash is the value stored in the database column members_pass_hash. $salt is the value stored in the database column me...
f3283e97-10c7-4c7e-86db-228a09ea8c87
1
public void testForID_String_old() { Map<String, String> map = new LinkedHashMap<String, String>(); map.put("GMT", "UTC"); map.put("WET", "WET"); map.put("CET", "CET"); map.put("MET", "CET"); map.put("ECT", "CET"); map.put("EET", "EET"); map.put("MIT", "Pa...
7c895b00-b13d-41c0-9cee-b501b0b07100
0
public void setItemcode(String itemcode) { this.itemcode = itemcode; }
75f5798c-7481-4b20-ad62-21e166112ccc
9
public int[][] combatBfs(List<Tile> queue, int[][] weights) { // Initialize costMap array with 0's. // 0 = unchecked tile. // Anything above 0 = already checked tile // (since cost has been assigned to it) int[][] costMap = createEmptyCostMap(); // loop through open set and assign...
13ede6f1-b312-4d3a-a0ed-490d92660bda
7
@Test public void testConnection() throws Throwable { final String PIPE_NAME; if (OS.startsWith("Windows")) { PIPE_NAME = "\\\\.\\pipe\\libuv-java-pipe-handle-test-pipe"; } else { PIPE_NAME = "/tmp/libuv-java-pipe-handle-test-pipe"; Files.deleteIfExists(Fi...
bf597bd4-d41a-435e-a70f-33a32b764eb5
6
public Server() throws HeadlessException, UnknownHostException { super("A Hole In The Universe Server " + InetAddress.getLocalHost().getHostAddress()); setSize(1300, 700); setLocationRelativeTo(null); setLayout(new GridLayout(1, 2)); // The program will close when the window is closed setDefaultCloseOpe...
b0256fa5-0173-467c-8cc4-600ac4d0e690
8
@Override public String toString() { return "Installation {" + (extReferences != null ? " extReferences [" + extReferences + "]" : "") + (cls != null ? " cls [" + cls + "]" : "") + (recommendedValue != null ? " recommendedValue [" + recommendedValue + "]" : "") + (quality != null ? " quali...
46b73acb-b304-4ffb-9128-809223882e14
0
private void centerScreen() { int width = this.getWidth(); int height = this.getHeight(); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); int x = (screen.width - width) / 2; int y = (screen.height - height) / 2; setBounds(x, y, width, height); }
3a048317-3eba-4f18-a654-8f45b7632293
3
private static boolean isX86() { String arch = System.getenv("PROCESSOR_ARCHITECTURE"); String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432"); boolean isX86; if (arch.endsWith("64") || ((wow64Arch != null) && wow64Arch.endsWith("64"))) { isX86 = false; } else { ...
ddc35179-0306-4671-9212-6f8ca56732d0
2
public void omniData(Object m){ rover = head; while(rover != null){ if(rover.status == 1){ rover.sendObject(m); } rover = rover.next; } }
a8f09ce7-a36a-4f6f-93d5-551566c6c3db
2
public void run() { String importantInfo[] = { "Mares eat oats", "Does eat oats", "Little lambs eat ivy", "A kid will eat ivy too" }; try { for (int i = 0; i < importantInfo.length; i++) { // Pause for 4 seconds Thread.sleep(4000); // Print a message threadMessage(importantInfo[i]); ...
791a0b05-2220-4eef-8e3e-daadaf86a89d
1
private void updateWindow() { if (Mission.getLastInstance() != null) { Mission.getLastInstance().emitUpdateWindowSignal(this); } }
be1afbc2-088f-4346-b456-5d090ace723f
4
public List<String> anagrams(String[] strs) { List<String> result = new ArrayList<String>(); Map<String,List<String>> map = new HashMap<String,List<String>>(); for (int i = 0; i < strs.length ;i++ ) { char[] c = strs[i].toCharArray(); Arrays.sort(c); List<Stri...
8a3af8ea-bfda-4c1b-ae71-2c0c543f482d
6
@EventHandler public void PigZombieWither(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.getPigZombieConfig().getDouble("PigZombie...
3df91101-9e89-43b7-95f7-c0328ce18aa0
7
private static void Move(IHIPathfinderValues values) { values.Tiles[values.X[values.BinaryHeap[1]]][values.Y[values.BinaryHeap[1]]] = 2; values.BinaryHeap[1] = values.BinaryHeap[values.Count]; values.Count--; short location = 1; while (true) { short hig...
138df0e8-6c36-44e5-ac3b-4301179c3b45
6
public void mousePressed(MouseEvent e) { buttonSelected = controller.buttonSelected; if (buttonSelected == null) return; pointClicked = e.getPoint(); // MAKING A SELECTION if (buttonSelected == ButtonSelected.SELECT) { // a shape has already been selected and now the handles have been selected if ...
ddf238b0-0bc4-48ba-b940-31911fbd1e87
9
private void newChannelGroup(String args[]){ int i = 2; String name = ""; if(args[i].startsWith("\"")){ while(!args[i].endsWith("\"") && i < args.length-1){ if(!name.isEmpty()) name += " "; name += args[i]; i++; } if(!name.isEmpty()) name += " "; name += args[i]; i++; na...
8c5cef17-fabd-4122-b3e4-1d5653e8fc8e
4
public void stop(StageFlipper flipper) { if (flipper.packageID == 102) { if (flipper.jm.GameType.equals("TicTacToe")) { this.lastMsg = flipper; this.stage = 20; } else if (flipper.jm.GameType.equals("Achtung Die Kurve")) { this.lastMsg = flipper; this.stage = 30; } } else if (flipper.pack...
6eb42668-41c2-42a7-9e17-ecfa7a8bef4c
6
private void pressed(KeyEvent e, String text) { int key = e.getKeyCode(); //VK_SPACE = space bar if(key == KeyEvent.VK_SPACE && !drawingLevel) { fired = true; } //VK_UP = Up arrow if (key == KeyEvent.VK_UP) { upArrowPressed = true; } if (key== KeyEvent.VK_X) { superJumpPressed =...
7deba770-9854-4d95-b813-5418509ef4e2
5
public synchronized Client editClient(Client client) { if (client != null) { for (Client clientAux : listClient) { if (clientAux.getMail().equals(client.getMail())) { listClient.remove(clientAux); try { listClient.put(client); } catch (InterruptedException e) { e.getMess...
8822a1db-d760-4244-a00b-3e80df2b8b48
4
private BufferedYamlConfiguration loadConfig(final File base, final String world) { BufferedYamlConfiguration config = this.configuration.get(world); if (config != null) return config; final File source = (world == null ? base : new File(base, world + ".yml")); try { config ...
97aeeb75-f351-4e4e-914c-8be630fbf67d
8
@Override public String getStat(String code) { if(CMLib.coffeeMaker().getGenItemCodeNum(code)>=0) return CMLib.coffeeMaker().getGenItemStat(this,code); switch(getCodeNum(code)) { case 0: return "" + powerCapacity(); case 1: return "" + activated(); case 2: return "" + powerRemaining(); case ...
42f2b067-661e-48ca-bef0-74a3a88a7844
6
public static EnumOs getPlatform() { String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH); if(osName.contains("win")) { return EnumOs.WINDOWS; } if(osName.contains("mac")) { return EnumOs.MACOS; } if(osName....
abe16752-663b-4c65-a3b2-21e8275b381e
0
public BallIterator(BallContainer ballContainer) { this.ballContainer = ballContainer;// 将操作的“盆”传入,参考上面的代码 this.index = 0; }
0d112c30-f4dc-4598-8e1e-449bcc42955c
1
public String getParts(int index){ try{ return parts.get(index); } catch (IndexOutOfBoundsException e){ } return null; }
8c9b95c8-a8f7-4517-801e-6ea9aaa01035
6
public Track(HtmlMidNode parent, HtmlAttributeToken[] attrs){ super(parent, attrs); for(HtmlAttributeToken attr:attrs){ String v = attr.getAttrValue(); switch(attr.getAttrName()){ case "default": defaultt = Default.parse(this, v); break; case "kind": kind = Kind.parse(this, v); br...
bfba6b0a-77aa-49d0-a022-abec760b883a
5
public static void main(String[] args) { if (args.length == 0) { UI.run(path); } else if (args.length == 1) { path = args[0]; UI.run(path); } else if (args.length == 2) { path = args[0]; tries = Integer.parseInt(args[1]); Launcher.launchBatch(path, mode, tries); }else if (args.length == 3) { ...
7153ba43-a297-40a2-b172-0afb02b3bcee
5
public void insertarCuenta(int numCuenta){ try { r_con.Connection(); String fechaDesde=campoFecha.getText(); String fechaHasta=campoFecha1.getText(); int numAsiento=-1; ...
f68c6bd0-4783-4665-8583-9490562cf49d
1
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed JFileChooser chooser = new JFileChooser("/"); int returnVal = chooser.showOpenDialog(this); if(returnVal == JFileChooser.APPROVE_OPTION) { jTextField3.setText(chooser.g...
f628fe36-e8d2-46f4-9db2-27153f149105
8
private void mergeArray(int start, int mid, int end) { if(mid<start || end<mid+1) { return; } int[] tmp = new int[end-start+1]; int tmpIdx=0; int i = 0; int j = 0; while(i<mid-start+1&&j<end-mid) { if(array[start+i]<array[mid+1+j]) { tmp[tmpIdx++] = array[start+i]; i++; } else { tm...
cb7b3248-e78a-4106-9790-dd232da1ebbf
2
public Fornecedor buscarFornecedor(String nome) { for (Fornecedor f : fornecedores) { if (f.getNome().compareToIgnoreCase(nome) == 0) { return f; } } return null; }
e77f0776-1917-4e62-8b2b-cf7603a9a756
0
public boolean getIncludeSubDirs() { return this.includeSubDirs; }
5e18929c-cdd4-4778-a9a5-5867be56ebbf
7
public AudioFormat[] getTargetFormats(final AudioFormat.Encoding targetEncoding, final AudioFormat sourceFormat) { if (sourceFormat.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && targetEncoding instanceof SpeexEncoding) { if (sourceFormat.getChannels...
8cd0974c-12e6-4282-9ee4-93cf6ecc6579
6
public void promptMove(GoEngine g) { List<Coord> moves = new ArrayList<Coord>(); g.board.calculateTerritory(); for(int i=0;i<9;i++){ for(int j=0;j<9;j++){ if(g.board.checkValid(i,j,piece)&&g.board.getTerritory(i, j)!=piece){ moves.add(new Coord(i,j)); } } } if(moves.size()!=0){ Coord mov...
b71bfee8-c21e-44ac-8c4a-365eb337ebb3
2
public void testPropertyCompareToMonth() { YearMonthDay test1 = new YearMonthDay(TEST_TIME1); YearMonthDay test2 = new YearMonthDay(TEST_TIME2); assertEquals(true, test1.monthOfYear().compareTo(test2) < 0); assertEquals(true, test2.monthOfYear().compareTo(test1) > 0); assertEqual...
d9312bbc-7042-4dd2-96db-dcf856c3ff0f
0
public Connection getConnection(){ return connection; }
82bbf000-a1bb-4832-9970-92a1c3c7616c
2
public int powerMod(String binaryKey, Integer caracter, Double n){ BigInteger a = BigInteger.valueOf(caracter); BigInteger aux = BigInteger.valueOf((int)caracter); for (int i=1;i<binaryKey.length();i++){ System.out.print( aux +" "); if(binaryKey.charAt(i)=='1'){ ...
26dcf2f7-ce49-4382-8527-3a88ee13df8d
0
public String getVisiteur() { return visiteur; }
c605fafd-0ead-4e1b-a1c7-f8cb8b8271ab
7
public void saveSettings() { FileWriter xmlfile; String line; // Open the default file settings // try { xmlfile=new FileWriter("rivet_settings.xml"); // Start the XML file // line="<?xml version='1.0' encoding='utf-8' standalone='yes'?>\n<settings>\n"; xmlfile.write(line); // Invert line="<in...
354c4627-7bf7-4bf0-a5fd-43727192f518
9
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // consulta de la base de datos try { //Establece los valores para la sentencia SQL Connection c=con.conectar(); PreparedStatement consultar = c.prepareStat...
6dc41e2e-d7d8-4ee6-8b1b-8b1445e8486f
2
public List<Disciplina> consultaDisciplinasPorPreferenciaPorProfessor( String matriculaProfessor, int nivelPreferencia) throws ProfessorInexistenteException, PreferenciaInvalidaException { List<Disciplina> listaRetorno = new ArrayList<Disciplina>(); for (Professor p : professores) { if (p.getMatricula()....
81ae24a2-5263-4e2b-acc5-f3b090fc69f6
0
public AutomatonAction getRestoreAction() { return restoreAction; }
e4108f7d-6cee-4aef-afb9-97f93a5f9221
6
private static void tryDo(String s, int i, int j){ int len = j-i; int sLen = s.length(); for(int k=0;k<len;k++){ if((j+k<allowed && j+k>=sLen) || (i+k<sLen && j+k<sLen && s.charAt(i+k)==s.charAt(j+k))){ continue; } else { return; } } max = Math.max(len*2, max); }
21aa331c-fffc-42ac-9a2c-2d8837efe6f4
5
private void processPlayers() { for (HostedConnection each : getClients()) { Boolean init = each.getAttribute(AttributeKey.INIT); if(init==null) { continue; } if (!init) { // Player p = pf.producePlayer(); ...
cdd18512-bd03-4cf8-b051-444670a10421
1
private static String toString(ArrayList<String> al) { String string = ""; for(String str : al) { String build = string; string = build + str; } return string; }
37425285-4ef2-4df2-8378-d1a2a1485c00
4
private static Field findDeclaredField(Class<?> inClass, String fieldname) throws NoSuchFieldException { while (!Object.class.equals(inClass)) { for (Field field : inClass.getDeclaredFields()) { if (field.getName().equalsIgnoreCase(fieldname)) { return field; } } inClass = inClass.getSuperclas...
561267b8-00fd-4279-816d-9decabc29780
3
static Direction clockwise(Direction direction) { if (direction == NORTH) return EAST; if (direction == EAST) return SOUTH; if (direction == SOUTH) return WEST; return NORTH; }
7972b6b0-3416-4339-acb2-ffc12e9786c4
7
private static BigInteger[] fraction(double val){ long bits = Double.doubleToLongBits(val); int sign = ((bits >> 63) == 0) ? 1 : -1; int exp = (int)((bits >> 52) & 0x7ffL); if(exp == 2047){ throw new ArithmeticException("The double value "+val+" is Infinity or NaN, can't be represented as rational number"); ...
6e4f63b7-f981-4817-9060-fa9e944ae111
2
@Override public boolean free(ByteBuffer buffer) { boolean cached = false; // If caching this buffer will go over the maximum allowable cached // buffer memory then simply free the buffer and return the result. if (usedMemory.get() + buffer.capacity() > maxMemory.get()) { onFree(buffer); } // Try cach...
368c2524-4440-40ba-bc6b-f95571a52725
4
public void rightClick(Tile tile, boolean shift, Point target, Point worldBound){ if(shift) { setCamera(target,worldBound); } else { if(selected == null || selected.getClass().getSuperclass() == Terrain.class) { setCamera(target...
0c9fe196-e2bb-475a-ae08-435f752fafd5
7
public DMemeGrid getRigorData() { DMemeGrid dmg = new DMemeGrid(); String sql = "SELECT \n" + " BP.accountID, MSP.projectID, MSP.siteID, BP.name AS projectName\n" + ", BSite.disname AS districtName, BSite.schname AS schoolName\n" ...
5b28afd7-be80-4e2f-b58c-b9f302063355
8
private void setState(Request request, Response response, String status) { for (String s : request.getValidStates()) { if (status.equals(s)) { response.setMatchOk(true); break; } } if (!response.isMatchOk() && request.getErrorStates() != null) { for (String s : request.getErrorStates()) { if...
dfa1040a-4522-4ebf-8f23-43835bea6ece
9
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if(sprung) return super.okMessage(myHost,msg); if(!super.okMessage(myHost,msg)) return false; if((msg.amITarget(affected)) ||((msg.tool()!=null)&&(msg.tool()==affected))) { if((msg.targetMinor()==CMMsg.TYP_ENTER) ...
5d8a236b-bccc-4499-a5ba-4c807029b76b
2
@Override protected void generateLevel() { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { tilesInt[x + y * width] = random.nextInt(4); } } }
cb9c76cd-c7be-473c-a3bb-0f5ea6f1046d
4
public Component getListCellRendererComponent( JList jlist, Object e, int index, boolean isSelected, boolean cellHasFocus) { this.viewer.setObject(e); Color background; Color foreground; // check i...
9267aea7-9fb3-4777-be10-1dcc9db3c0e8
5
@Override public void mouseDragged(MouseEvent event) { if (isEnabled()) { Row rollRow = null; try { int x = event.getX(); mSelectOnMouseUp = -1; if (mDividerDrag != null && allowColumnResize()) { dragColumnDivider(x); JScrollPane scrollPane = UIUtilities.getAncestorOfType(this, JScrollPan...
158de135-946e-4416-84c5-6c11b087fdba
8
public Gleitpunktzahl add(Gleitpunktzahl r) { /* * TODO: hier ist die Operation add zu implementieren. Verwenden Sie die * Funktionen normalisiere, denormalisiere und die Funktionen add/sub * der BitFeldklasse. Achten Sie auf Sonderfaelle und die Einschraenkung * der Funktion BitFeld.sub. */ if (th...
71acde98-38e9-42e4-9f52-bf92437b6955
8
private RatingResult predictUserRating(DBObject reviewObject) { if (reviewObject == null) return null; if (!reviewObject.containsField(CollectionReview.KEY_USER_ID) || !reviewObject .containsField(CollectionReview.KEY_BUSINESS_ID) || !reviewObject.containsField(CollectionReview.KEY_STARS)) { ret...
391a076c-47cf-45a5-853e-2364d6508da7
7
public static void main( String[] args ) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, NoSuchFieldException { // 1 access static class System.out.println( "directly " + StaticExample....