method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
838bc25d-0f5e-4ea6-836f-dd0916c60069
0
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) { }
dddb51d6-71d5-425b-bef6-cf4864c648b4
5
private static HashMap<String, Integer> getCollectionFrequency(String dirName, Normalizer normalizer) throws IOException { // Création de la table des mots HashMap<String, Integer> hits = new HashMap<String, Integer>(); File dir = new File(dirName); String wordLC; if (dir.isDirectory()) { // Liste des fich...
4b494592-0a8d-42e2-9f8d-2b22c6fbe3aa
9
private void parseUrl(String urlStr) throws WebSocketException { try { URI uri = new URI(urlStr); if (!(uri.getScheme().equals("ws") || uri.getScheme().equals("wss"))) { throw new WebSocketException(E3007, uri.toString()); } if (uri.getScheme().equ...
be4fc2d8-2a93-4da1-8d59-3ef73b73ca71
4
Markers findClosestMarker(Marker queryMarker) { int initialExtension = 1000; Chromosome chr = queryMarker.getChromosome(); if ((chr != null) && (chr.size() > 0)) { // Extend interval to capture 'close' markers for (int extend = initialExtension; extend < chr.size(); extend *= 2) { int start = Math.max...
dc884ab0-58f1-46f9-ad62-313fd089ec80
1
@Test public void deltaMatrices_test() { try{ double [][]mat1= {{1.0,2.0}, {3.0,1.0}}; double [][]mat2= {{2.0,1.0}, {1.0,3.0}}; double result = FastICA.deltaMatrices(mat1,mat2); double exp=1.5; Assert.assertEquals(result,exp,0.0); } catch (Exception e) { // TODO Auto-generated catch block fa...
bce6844b-910d-419c-9c25-8ef6defc9dd6
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof Action)) return false; Action other = (Action) obj; if (tiles == null) { if (other.tiles != null) return false; } else if (!tiles.equals(other.tiles)) return fa...
0274f780-bce6-4bd6-8f93-0a0c671bf3e2
4
private boolean isGameEnded() { boolean packEnded = (pack.getCardAmount() == 0); if (((first.getAmountOfCards() == 0) && packEnded) || ((second.getAmountOfCards() == 0) && (packEnded))) { return true; } else { return false; } }
cf7a7fa6-3f9d-471e-a14f-c5670b08e592
0
public void setPersonId(String personId) { this.personId = personId; }
488b40c3-82f7-41b4-aa74-01f06836fce6
9
public boolean isAnswerCorrect() { boolean result = false; final ArrayList<Integer> currentlySelected = new ArrayList<Integer>(); // find the option selected for (int x = 0; x < _checkBoxOptions.size(); x++) { if (_checkBoxOptions.get(x).isSelected()) { currentlySelected.add(x); } } if (currentl...
685c16aa-6cf5-4167-bf77-ecaa9ab06bf1
6
public static void main(String[] args) { //object output stream being used for all output ObjectOutputStream out = null; //ArrayList used to holde classes and test the addClassesFromFile() method of the student class ArrayList<SchoolClass> classes = new ArrayList<SchoolClass>(); ...
3139f5cb-a86f-4940-92f4-a4cf0a3e1f55
3
public FreightCar(Integer grossWeight, String goodsType) throws TrainException{ super(grossWeight); if (!(goodsType.equals("G")|| goodsType.equals("R")|| goodsType.equals("D"))){ throw new TrainException("Invalid goods type for freight car"); } this.goodsType = goodsType; }
182830ad-4a4e-45ee-a676-fa0ef1e8e17b
3
public ConnectionFactory(String archivoXML) { ParseadorDeXML parser = new ParseadorDeXML(); if (!parser.chequearSiExisteXML(archivoXML)) if (archivoXML.equals(ControladorServidor.ARCHIVO_FIREBIRD)) parser.crearXML(ControladorServidor.BACKUP_FIREBIRD, archivoXML); else if (archivoXML.equals(ControladorServ...
53f1105d-4b8c-44b0-8145-1a003ef71eee
6
public void parse() { boolean success = false; // Keep trying if file not found while (!success) { System.out.print("Enter filename (or 000 to exit): "); this.file = in.nextLine(); if(file.trim().equals("000")) { System.out.println("Program Terminated"); System.exit(0); } try { /...
eb19ea92-f053-43ab-a102-4d1728045d8c
3
public static Menu parseMenu(String filePath, String XSDFilePath){ try { DocumentBuilderFactory documentBuilder = DocumentBuilderFactory.newInstance(); documentBuilder.setIgnoringElementContentWhitespace(true); Schema schema = SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI)....
c107bb4b-d5f3-4c19-b4d8-93437bf67a48
3
public String put(final String key, final String value) { String result = null; if (diff.get().containsKey(key)) { result = diff.get().get(key); } else { readLock.lock(); try { if (old.containsKey(key)) { result = old.get(k...
95150923-c59a-4ce2-8f34-c639a25080b5
9
public int getAnzahl(NamiConnector con, String gruppierungsnummer) throws NamiApiException, IOException { if (searches.size() < 1) { return 0; } else if (searches.size() == 1 && filters.isEmpty()) { // es gibt nur eine Suchanfrage und keine Filter // -> d...
2cbdda9a-dbdb-4fbf-86ed-0292688985fc
1
public void render( GameObject object ) { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); object.renderAll( ambientShader, this ); glBlendFunc( GL_ONE, GL_ONE ); glDepthMask( false ); glDepthFunc( GL_EQUAL ); for ( Base...
50192e81-ccc9-49e9-8f2b-c6234a20afeb
4
@Override public String getOpponentChoix(String p) { if(p.equals(player1) && !choise1.isEmpty()) { return choise2; } else if(p.equals(player2) && !choise2.isEmpty()) { return choise1; } return "aucun"; }
00dd5da0-b26a-4ef8-97a7-bdc12b395597
3
public LectureFichier(String path) { try { FileReader reader = new FileReader(path); try(BufferedReader br = new BufferedReader(reader)) { StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); li...
5e204a67-fcee-4d09-b90a-29aa06ea10db
1
@Override public void userChangesNick(String oldNick, String newNick) { boolean isMe = getServerTab().getConnection().getNick().equals(oldNick); String message; if (isMe) { message = "Nyní vystupujete pod přezdívkou " + HTML.bold(newNick) + "."; } else...
90d7e42a-aa50-4d18-89f1-a700698dd254
9
@Override public void solve(DenseMatrix64F B, DenseMatrix64F X) { if( X.numRows != numCols ) throw new IllegalArgumentException("Unexpected dimensions for X"); else if( B.numRows != numRows || B.numCols != X.numCols ) throw new IllegalArgumentException("Unexpected dimensions ...
037ee0e0-bb09-42c6-9298-67eeae545a55
7
private void searchGuestButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchGuestButton2ActionPerformed guestModel.clear(); String firstName = searchFirstNameField2.getText(); String lastName = searchLastNameField2.getText(); ArrayList<Guest> foundGuests = new...
f8804617-4a07-4ccb-93c4-3db2f3f66ff5
3
public boolean isStable() { boolean stable = true; boolean[][] nextGrid = this.nextGeneration(); for (int i = 0; i < grid.length; i++) { for (int j = 0; j < grid[0].length; j++) { stable = stable && (grid[i][j] == nextGrid[i][j]); } } retur...
794cfe3f-20c0-465e-8585-22a62a566366
1
protected double mass(int x) { if (x <= 0) { return 0; } else { return Math.exp(- mu * x) * Math.pow(mu * x, x - 1) / Utils.factorial(x); } }
40ae7ca9-9afc-49f3-ac22-2d6bb00d7ac9
3
public double generateNoise(double var1, double var3, double var5) { double var7 = var1 + this.xCoord; double var9 = var3 + this.yCoord; double var11 = var5 + this.zCoord; int var13 = (int)var7; int var14 = (int)var9; int var15 = (int)var11; if(var7 < (double)var13) { ...
17660d97-5851-4079-83c8-37fc14def3d5
7
@Override public Parameter getParameter(final int parameterIndex) { Parameter parameter; switch (parameterIndex) { case 0: case 1: parameter = super.getParameter(parameterIndex); break; case 2: parameter = time; ...
71658539-7ef9-4f9f-bd47-5db8d725654c
8
public ArrayList getProductionsForPushTwoTransition(Transition transition, Automaton automaton) { ArrayList list = new ArrayList(); String fromState = transition.getFromState().getName(); String toState = transition.getToState().getName(); PDATransition trans = (PDATransition) transition; String toPop = tr...
3b8fa6d6-f417-43c8-b580-831092f2e85c
3
private void loadIcons( ) { try{ if( sPendingImageIcon == null ) sPendingImageIcon = getLoadingImageIcon(); if( sMissingImageIcon == null ) sMissingImageIcon = getNoImageIcon(); }catch( Exception x ) { System.err.println("ImageView: Couldn't load image icons"); } }
ab1b3da8-1632-4757-9274-626a40ee7a46
0
public int getCategoryId() { return categoryId; }
a7092c37-1a14-4060-a964-84253f004ae4
7
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof MavenEntity)) { return false; } MavenEntity other = (MavenEntity) obj; if (groupId.equals(other.getGroupId()) && (artifactId.equals(other.getArtifactId())) && (version.equals(other.getVersio...
ae018843-cdb9-4682-9327-21a822f525c0
1
@Override Integer redactEntity(Criteria criteria, AbstractDao dao) throws DaoException { Integer idTour = (Integer) criteria.getParam(DAO_ID_TOUR); if (idTour != null) { return updateTour(criteria, dao); } else { return createTour(criteria, dao); } }
f4a5e779-e91b-4d4f-bd74-6b8f1eebbb11
5
public ContainerDispenser(IInventory var1, TileEntityDispenser var2) { this.tileEntityDispenser = var2; int var3; int var4; for(var3 = 0; var3 < 3; ++var3) { for(var4 = 0; var4 < 3; ++var4) { this.addSlot(new Slot(var2, var4 + var3 * 3, 62 + var4 * 18, 17 + var3 * 18)); ...
92108b53-5bbc-4cd3-96c5-7c17971078a0
9
public void run() { Thread thisThread = Thread.currentThread(); while (playing == thisThread) { addOneToField(gui.drawings); int draw = Integer.parseInt(gui.drawings.getText()); float numYears = (float)draw / 104; gui.years.setText("" + numYears); int matches = 0...
eba8b778-9488-40c8-8e90-a38ca1472c10
8
public static void main(String[] args) { BinarySearchTree t = new BinarySearchTree(); final int NUMS = 4000; final int GAP = 37; System.out.println("Checking... (no more output means success)"); for (int i = GAP; i != 0; i = (i + GAP) % NUMS) t.insert(new Integer(i)); for (int i = 1; i < NUMS; i += 2)...
74c55e6d-5396-4602-b0c9-c4d1b7d1213b
5
@Override public boolean equals(Object object) { if ( object == null) return false; if ( object == this ) return true; if ( !(object instanceof Operation) ) return false; Operation expression = (Operation) object; return expression.operator == this.operator && expre...
a1ccaf30-c9d6-4975-b07e-974fc333a3ab
3
@After public void teardown () { try { if ( this.server != null ) this.server.close(); } catch ( IOException ignore ) {} if ( this.executor != null ) this.executor.shutdown(); }
88b486dd-ea18-4469-a8d5-cf432159dd14
0
public void renew() { timeout = (System.currentTimeMillis()/1000L)+10; }
0d3b7478-37a8-4584-92f9-a4c00755c359
4
@Override public synchronized void execute() { super.execute(); try { // Write requestBody if any if (this.urlRequest.getHTTPBody() != null) { this.urlRequest.setRequestProperty("Content-Length", "" + Integer.toString(this.urlRequest.getHTTPBody().length)); ...
a3831a83-0bcf-4d0c-9d55-e5b2ba21b53b
3
public boolean serverCom(String portNumber) { Integer port = portNumber.isEmpty() ? 4502 : Integer.parseInt(portNumber); boolean status = false; try { if (available(port)) { ServerSocket serverSocket = new ServerSocket(port); serverTCPSocket = serverSo...
ea19b1a4-a6b4-474d-9d36-f68b39f72d70
2
public JSONObject append(String key, Object value) throws JSONException { testValidity(value); Object object = this.opt(key); if (object == null) { this.put(key, new JSONArray().put(value)); } else if (object instanceof JSONArray) { this.put(key, ((JSONArray) obje...
1c5062eb-5a29-4cc1-b59f-0c8389b090a5
3
public void trace() { Configuration[] configs = configurations.getSelected(); if (configs.length == 0) { JOptionPane.showMessageDialog(configurations, NO_CONFIGURATION_ERROR, NO_CONFIGURATION_ERROR_TITLE, JOptionPane.ERROR_MESSAGE); return; } for (int i = 0; i < configs.length; i++) { TraceWi...
3e3a6e29-a249-4470-a6fa-70159a01b474
8
public void updateWeight(int neuronWinner, Example ex) { //verificar a posição na matriz de vetores int line = neuronWinner/this.neuronsLine; int column = neuronWinner%this.neuronsColumn; System.out.println("Neurônio Vencedor: " + line + "," + column); System.out.println("Atualiz...
0d818aaf-b292-4256-bbd5-4e588bee06b9
6
public void check_for_surrounded_ants(int[] p){ check_for_surrounded_ant_at(p); for (int d = 0; d <= 5; d++){ if(adjacent_cell(p,d)[0]>=0 && adjacent_cell(p,d)[0] < world.getRows() && adjacent_cell(p,d)[1]>=0 && adjacent_cell(p,d)[1] < world.getColumns()){ if(world.getCell(adjacent_cell(p,d)[0],a...
ca6067d3-7fed-4918-9e76-5db9a3bc697e
5
public E remove(int index) throws IndexOutOfBoundsException { if (index < 0 || index > length) { throw new IndexOutOfBoundsException(); } if (length == 1) { return removeOnly(); } if (index == 0) { return removeFirst(); } if (in...
0c6c8571-cee7-4d39-b6dc-5d744a4d036a
4
private static void handleWarp(PrintWriter out, String map, String name, Rectangle bounds, Properties props) { if (out == null) return; String dest = getProp(props, "dest_map", null); if (dest == null) return; int x = getProp(props, "dest_x", -1); if (x < 0) return; int y...
aabbdaed-4063-4ecd-93cf-4148811caee8
6
public String recNombre(String Nick) { //verificar logueo String nombre=""; try { String queryString = "Select nick from Usuarios where nick = ?"; connection = getConnection(); ptmt = connection.prepareStatement(queryString); ptmt.setString(1, Nick); ...
6ab75ebc-e132-44ab-9024-2e688a943d65
8
public ArrayList<Employee> AllManagers() throws UnauthorizedUserException, BadConnectionException, DoubleEntryException { /* Variable Section Start */ /* Database and Query Preperation */ PreparedStatement statment = null; ResultSet results = null; ...
b8897c76-59e4-4d78-b355-c63e647ab94e
8
public DealsResponse getDeals(RequestBean request) throws InvalidRequestParametersException, CitysearchException { validate(request); //Initialize tracking Url's String originalDartTrackingUrl = request.getDartClickTrackUrl(); Properties apiProperties = PropertiesLoader.getAP...
92e5b316-9ae6-4094-9b16-2c7d294ed34e
6
private void lifeCycle() { String s = ""; String time1StringView = ""; String time2StringView = ""; while (isInputActive) { try { s = readInput(); if (s.length()==0) { break; } if (this.isValidInput(s)) { if (!isTimeSet1) { time1StringView = s; this.isTim...
0161f2c8-a68e-420e-b962-499f3d9c7688
2
public static void main(String[] args) { ArrayList<Integer> list = new ArrayList<Integer>(); // List, Collection // HashSet for (int i = 0; i < 10; ++i) list.add(i); //list.add(3); for (Integer i : list) System.out.println(i); }
bf72367b-9936-4a95-ad49-d77d54371a9f
9
public boolean createRandomField() { int count = 0; while (count < RANDOM_PLACEMENT_MAX_TRYS) { count++; // Fill field with zeros. for (int k = 0; k < SIZE; k++) { for (int l = 0; l < SIZE; l++) { fField[l][k] = VALUE_FREE; } } ...
01abda9c-400b-4b93-a034-1d3ac383a0c2
5
public RoyalIRCBot(final RoyalIRC plugin, ConfigurationSection cs, ListenerManager<PircBotX> lm) { final String hostname = cs.getString("hostname"); final int port = cs.getInt("port", 6667); final String password = cs.getString("server_password", ""); Configuration.Builder<PircBotX> cb =...
004b7358-0cc9-4628-8402-940ce2676f05
2
@Override public void play(String audioType, String fileName) { // Java 8 can use Strings in switch switch (audioType) { case "VLC": advancedMediaPlayer.playVLC(fileName); break; case "Mp4": advancedMediaPlayer.playMp4(fileName); break; default: break; } }
43d747a9-a14f-47c4-b9cb-a94ccd722e40
2
public boolean instanceOf(Object obj, String className) throws InterpreterException { Class clazz; try { clazz = Class.forName(className); } catch (ClassNotFoundException ex) { throw new InterpreterException("Class " + ex.getMessage() + " not found"); } return obj != null && clazz.isInstance(obj...
ff1a7461-5dfe-4c91-9fcc-2d974a57fe63
8
public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ColorBar)) { return false; } ColorBar that = (ColorBar) obj; if (!this.axis.equals(that.axis)) { return false; } if (this.col...
e066cbe8-d8c7-4120-8062-64e6d33114ac
0
@Override public void setVorname(String vorname) { this.vorname = vorname; }
a96a82f1-c6bc-4560-881f-5d1e7bf731d4
5
private void resetLater(final ExprInfo exprInfo, final Phi phi) { phi.setLater(false); final Iterator blocks = cfg.nodes().iterator(); while (blocks.hasNext()) { final Block block = (Block) blocks.next(); final Phi other = exprInfo.exprPhiAtBlock(block); if (other == null) { continue; } fi...
497db71e-39ce-4bc0-b5d4-d53866379ab7
6
public static void main( String[] args ) { StockSwag stockSwag = new StockSwag(); // GUI look and feel: /* Set the Nimbus look and feel */ // <editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6)...
80f50f9a-9ae0-4c52-84f7-3b9ba733610d
7
public static boolean setShaderEnable(String clientName, boolean selected) { String ClientFolderPath = Utils.getWorkingDirectory() + File.separator + GlobalVar.itemsServers[GlobalVar.CurrentServer] + File.separator + ".minecraft" + File.separator; if (selected) { File f = new File(ClientFolderPath...
6b3d80d1-1338-4715-b175-fb0fb18c317d
6
private void redirectOutputStreams() { //Redirect standard output OutputStream redirectedStdOutput = new OutputStream() { @Override public void write(final int b) throws IOException { updateTextPane(String.valueOf((char) b)); } @Override ...
aec55ff2-84c1-4d32-b72a-17317a90c77c
0
public boolean isSolid(){ return false; }
084922f0-f208-4562-bc01-bdf55b0b0223
2
@Override public Object execute(HttpServletRequest request, HttpServletResponse response) throws Exception { Contexto oContexto = (Contexto) request.getAttribute("contexto"); oContexto.setVista("jsp/mensaje.jsp"); HiloBean oHiloBean = new HiloBean(); HiloDao oHiloDao = new HiloDao(oC...
f73c37dd-7ba2-4f09-bb35-011fe8d70a04
8
static final AbstractToolkit createOpenglToolkit(Canvas canvas, d var_d, IndexLoader loader, int i, int i_1_) { try { anInt1532++; if (!Class9.method215(27165)) throw new RuntimeException(""); if (!Class348_Sub40_Sub19.method3098(i ^ ~0x158f, "jaggl")) throw new RuntimeException(""); O...
789487d7-4bb0-4e9f-b8d1-35e11f9630e9
8
private void updateCategory() { for (@SuppressWarnings("unused") boolean act : categories) { act = false; } for (ImageLabel act : objects) { if (act != null) { CategoryType tmp = act.getCategory(); switch (tmp) { case BASS: categories[0] = true; case BEATS: categories[1] = true; ...
f1650c01-0e8b-4f57-a30b-bbb93e9232a0
8
public Object getValueAt(int rowIndex, int columnIndex) { switch (columnIndex) {// parcour par colonne case 0://colonne id_Stock return Pharmacies.get(rowIndex).getId_ph(); case 1://colonne id_Stock return Pharmacies.get(rowIndex).getNom_ph(); ...
0d4b8846-8ab1-45ea-b232-84384f8b4b53
4
private String readName() throws JSONException { byte[] bytes = new byte[65536]; int length = 0; if (!bit()) { while (true) { int c = this.namehuff.read(this.bitreader); if (c == end) { break; } bytes...
947592e7-6f72-43bf-8983-be03bc1a73f7
3
public Plant(Terrain terrain, Point position) { this.nodeRenderer = new NodeRenderer(); this.terrain = terrain; this.nodeConnectors = new ArrayList<>(); this.growths = new ArrayList<>(); this.removals = new ArrayList<>(); this.rootRemovals = new ArrayList<>(); this.r...
e34e8363-84b8-4bdd-9530-2bd7b5897ff4
5
public static void main(String[] args) throws IOException { readData(); calculateAverageRatings(); calculateStandardDeviations(); File base = new File(outputDirectory + fileName); if (!base.exists()) base.createNewFile(); FileWriter bw = new FileWriter(base.getAbsoluteFile()); BufferedWriter baseWr...
ed6ecf11-a3a8-44b8-a659-2113e42c0e55
2
public String getGroopString() { // Construct the groop string Collection<String> main = getMainGroops(); Iterator<String> gIt = main.iterator(); StringBuffer groop = new StringBuffer(""); while (gIt.hasNext()) groop.append(gIt.next() + " & "); // Remove the trailing & o...
cb6930f0-5a81-4762-bfa9-7f6690d30975
4
@Override public GenreCollection fetchAllByAlbum(Album album) { GenreCollection genreColl = new GenreCollection(); try { CDOrganizer cdOrganizer = XmlDAOFactory.unmarschallFile(); for (AlbumXML a : cdOrganizer.getAllAlbums()) { if (a.getID() == album.getId()) { for (GenreXML b : a.getGenreList(...
469f19b0-554f-4aac-8f3e-ee1e7460395d
9
private void btnCadastrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCadastrarActionPerformed if (txtNome.getText().equals("") || txtDescricao.getText().equals("") || txtDataInicio.getText().equals(" / / ") || txtDataFim.getText().equals(" / / ...
ba30fc32-0210-4edc-bb0d-4012145d8863
6
public boolean startGame() { boolean crashed = true; try { log("Creating game thread"); this.gameThread = new GameThread(this, "Game Thread"); this.gameThread.run(); while (this.gameThread.isAlive()) { //TODO Add stuff. } if (this.gameThread.didEncounterError()) { throw thi...
de95e53f-9e18-41ee-9ed2-92edb4f44860
1
private void download(ProgressDownload fenProgression) { int valueProgress = 0, pasProgress = 5; fenProgression.setProgression(valueProgress); // Téléchargement des fichiers for (int i = 0; i < this.animaux.size(); i++) { this.animaux.get(i).telechargerFichier(); ...
49807863-ac5b-44ca-9e58-576db62765c1
0
public Inventory getInventory() { return inventory; }
a0a8b3f4-1928-42fa-8d7e-e4ccc2e7a87d
0
protected Stage getStage() { return this.stage; }
39b45d51-cb52-4ab5-bd25-a7ca199b2d8a
9
@Override public <T> T processLine3D(int x0, int y0, int z0, int x1, int y1, int z1, PointHandler3D<T> handler) { int x = x0; int y = y0; int z = z0; T result = handler.handlePoint(x, y, z); if (result != null) return result; final int dx = x1 - x0; final in...
dbde4058-06df-447c-83b8-3a5792df77e3
2
public static long measureSumPerf(Function<Long, Long> adder, long n) { long fastest = Long.MAX_VALUE; for (int i = 0; i < 10; i++) { long start = System.nanoTime(); long sum = adder.apply(n); long duration = (System.nanoTime() - start) / 1_000_000; System...
9836583f-416e-4080-b9a3-ea0868f227d4
1
public String showHand(Player player) { String result = GameSocketServer.SHOW_PLAYERS_HAND + "@cards="; for (ItalianDeckCard card : playerHands[player.getSeatNumber() - 1]) { result += card + "/"; } result = result.substring(0, result.length() - 1); return result; }
f9c1ebea-c85d-425e-a800-732782569533
2
private void assertCard(Card card) { int cardRank = card.getRank().ordinal(); Card[] rankList = ranks[cardRank]; if (rankList == null) { rankList = new Card[NUM_SUITS]; ranks[cardRank] = rankList; } int numRank = numRanks[cardRank]++; rankList[numR...
cd88859f-3bcc-4f70-9524-3f2523154370
6
@EventHandler public void openShopGUI(PlayerInteractEvent event) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { Player player = event.getPlayer(); Block block = event.getClickedBlock(); Cuboid cuboid = Cuboid.getCuboid(player.getLocation()); if (!Level.canUse(UserManager.getInstance().get...
3303c1e4-2722-4c57-9bec-1c5ddcf6fdfd
4
public static String toString(JSONObject jo) throws JSONException { StringBuffer sb = new StringBuffer(); sb.append(escape(jo.getString("name"))); sb.append("="); sb.append(escape(jo.getString("value"))); if (jo.has("expires")) { sb.append(";expires="); s...
02058a46-5c39-43f0-ae27-69847bbb82bb
8
@Override public int Register(String hostAdress, String workerName, int rmiPort) throws RemoteException { ServerNodeInterface newWorker=null; int newId=0; //Import ServerNodeInterface Object try { newWorker = loadServerNodeStub(hostAdress,workerName, rmiPort); } catch (NotBoundException e) {...
dd3aa46b-776c-4ef8-b175-310aa7d8247b
1
public int getModifiers() { if ((status & HIERARCHY) == 0) loadInfo(HIERARCHY); return modifiers; }
ac711669-d917-4280-853f-f29de09825c0
7
@Override public ArrayList<Object> ifPackage(SalesReceiptPO receipt) { // TODO Auto-generated method stub ArrayList<Object> returnPromotions=new ArrayList<Object>(); ArrayList<SalesListItemPO> listItems=receipt.getSalesList(); ArrayList<String> goodsIds=new ArrayList<String>(); for(int i=0;i<listItems.size()...
d8197505-1000-4340-8c79-967491c4613a
9
private boolean r_mark_suffix_with_optional_s_consonant() { int v_1; int v_2; int v_3; int v_4; int v_5; int v_6; int v_7; // (, line 143 // or, line 145 lab0: do { ...
fb6e10fb-616d-4d7b-911a-c75c40bd7230
4
@Test public void testUseMessageQueuesFalseWithSockets() { LOGGER.log(Level.INFO, "----- STARTING TEST testUseMessageQueuesFalseWithSockets -----"); try { server1.setUseMessageQueues(true); } catch (TimeoutException e) { exception = true; } try { ...
33a4db47-5a7a-4c4b-9849-d3625a4c98fd
5
public boolean loadPixelMappingsFromResource(String resourceName) { boolean isSuccessful = false; if (pixelMap.size() == 0) { // Attempt to read the data from the file InputStream resourceStream = Thread.currentThread(). getContex...
20fca10d-891c-4232-b151-f1c4c8c8f2b4
6
@Transactional public void deleteItemTemplate(String id) { List<Recipe> recipes = getAllRecipes(); for (Recipe recipe : recipes) { if (recipe.getResult().getId().equals(id)) { deleteRecipe(recipe.getId()); continue; } for (ItemTempl...
907ecc1e-c2cd-4ea0-97eb-0dac589ca3f2
8
public Map<PII,StateBuffer> executeSingleAttack(StateBuffer in, DelayableMoveFactory moveFactory, AttackActionSegment actionSegment, int goalValue, int minValue, boolean noBins, boolean isB) { AttackActionSegment dummyActionSegment = null; AttackActionSegment aActionSegment = isB ? dummyActionSegment : actionSegmen...
e974495b-0d4e-4c53-9508-3718b197cd92
3
public JSONArray toJSONArray(JSONArray names) throws JSONException { if (names == null || names.length() == 0) { return null; } JSONArray ja = new JSONArray(); for (int i = 0; i < names.length(); i += 1) { ja.put(this.opt(names.getString(i))); } re...
8e73e155-89c8-47e9-b6ef-c8efbcee4e1a
2
public FixedStrategy(int fixed_value){ if(fixed_value<2 || fixed_value>100){ throw new UnauthorizedValue(); } this.fixed_value=fixed_value; }
3a15fcda-d9b4-4b93-98ec-2961b8c9fb21
2
@Override public void initializeService() throws Exception { IRailwayRepository repo = this.getSite().getRequiredService(IRailwayRepository.class); LocalDate tom = new LocalDate().plusDays(1); LocalDate dat = tom.plusDays(1); int flag = 1; for(TrainNumber tn : repo.getTrainNumbers()) { Loc...
26ea38b5-ac54-47f3-819e-761b7b72bba5
0
public RegularGrammar() { super(); setLinearity(-1); }
8b1f4c35-1d7f-4b03-ab9c-cd8f44ff6901
5
public static byte[] decodeLines(String s) { char[] buf = new char[s.length()]; int p = 0; for (int ip = 0; ip < s.length(); ip++) { char c = s.charAt(ip); if (c != ' ' && c != '\r' && c != '\n' && c != '\t') buf[p++] = c; ...
77f5faab-2aa6-4219-9b8c-a20754b17ccb
7
private void showAlbums(Scanner scanner, Application app) { String input = scanner.nextLine(); int selection = -1; try { selection = Integer.parseInt(input); } catch (NumberFormatException e) { // e.printStackTrace(); } System.out.println(); switch (input) { case "exit": { intro(app); break;...
3bed8113-d358-4e35-a815-270b631d1781
3
public static List<PropertiesFile> findFiles(String srcFilename) throws IOException { String dirName = FilenameUtils.getFullPath(srcFilename); final String filename = FilenameUtils.getName(srcFilename); final String baseName = findBasename(filename); File dir = new File(dirName); File[] files = dir.list...
24fac406-6803-496c-a11c-a9aeaa67abe1
7
public void actionPerformed(final ActionEvent e) { if (e.getSource() == timer) { progressBar.setValue(getProgress()); } else { if ("Play".equals(e.getActionCommand())) { playIt(); } else if ("Record".equals(e.getActionCommand())) { recordIt(); } else if ("...
189d0b82-c4e5-4fcb-9ddc-925ccc9cfef3
6
public static void makeGrid(Container parent, int rows, int padding) { SpringLayout layout; try { layout = (SpringLayout)parent.getLayout(); } catch (ClassCastException exc) { System.err.println("The first argument to makeGrid must use SpringLayout."); return;...
f1ac478a-c62e-4f39-a25c-5d9c3a5c9209
1
public void reset() { for (int i=0; i<delayBuffer.length; i++) { delayBuffer[i] = 0; } delayBufferPos = 0; }
693dc91a-7e3a-460f-8522-cdcde9f65907
8
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(false); if (session == null) { session.setAttribute("CurrAct", CAppConsts.LinkLoginPage); RequestDispatcher rd...