method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
8af760b5-cadb-4a6c-8803-d35c0eedf269
5
public final void des_set_key(byte[] key, int[] schedule) throws SecurityException { int c,d,t,s; int inIndex; int kIndex; int i; if (des_check_key) { if (!check_parity(key)) { throw new SecurityException("des_set_key attempted with incorrect parity"); } if (des_is_weak_key(key)) { ...
c2ab62f1-2ef1-4cbc-9917-5205bd62c096
4
public Matrix minus(Matrix B) { Matrix A = this; if (B.M != A.M || B.N != A.N) { throw new RuntimeException("Illegal matrix dimensions."); } Matrix C = new Matrix(M, N); for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) { C.data[i][...
0362dd03-5b7d-469c-9e2a-69785f2c1546
6
@Override protected int runTest(StdConverter.Operation oper) throws Exception { if (oper == null) { throw new RuntimeException("Internal exception: no operation passed"); } final boolean doRead = (oper != StdConverter.Operation.WRITE); final boolean doWrite = (oper !...
90458e31-7ae1-46d4-98ab-07071d0d0214
1
public boolean _setName(String name) { if(name != null) { sprite._setSpriteLabel(name); return true; } else { return false; } }
babe9042-60b1-48ea-837f-f537908700dc
5
@Test(expected=NotEnoughOperandsException.class) public void evaluatePostfix5() throws DAIndexOutOfBoundsException, DAIllegalArgumentException, NumberFormatException, NotEnoughOperandsException, BadPostfixException { try { postfix.removeFront(); String result = calc.evaluatePostfix(postfix); } ...
42b5dfda-2b5b-4f0a-9c4b-50338ab0ae11
7
protected static boolean writeFile(Path file, List<String> lines, boolean append) { assert (file != null) && (lines != null) && (lines.size() > 0); OpenOption[] options; Charset charset = Charset.defaultCharset(); if (append) { options = new OpenOption[] { StandardOpenOption...
e10ec161-8059-4fd0-a1b1-8c9c61399064
9
* @param iRow index of row in table * @param iCol index of column in table */ public void setValueAt(Object oProb, int iRow, int iCol) { Double fProb = (Double) oProb; if (fProb < 0 || fProb > 1) { return; } m_fProbs[iRow][iCol] = (double) fProb; double sum = 0; for (int i = 0; i < m_fProb...
49775612-925c-41da-9a48-e25d1f369c8c
1
public static void drawEmptyCircle(Graphics g, int x, int y){ // d = EMPTY_CIRCLE // center (x + EMPTY_CIRCLE) / 2 , (y + EMPTY_CIRCLE) / 2 // for (int i = 255; i >= 0; i-= (255/10)){ // g.setColor(new Color(i,0,255)); // // } for (int i = 10; i >= -10; i--){ g.setColor(new Color(Math.abs(i * (127 / 1...
813d486c-88b9-4fdc-b097-f14cffcbbf55
9
protected ArrayList<Placement> densityMapping(Field[][] map, int c) { shootDensity.clear(); for (int y = 0; y < map.length; ++y) { for (int x = 0; x < map[y].length - shipValue + 1; ++x) { int tmp = 0; for (int z = 0; z < shipValue; ++z) { ...
77df6c45-e6ed-42c1-9220-5c659ac9ed61
0
@Override public int update(Integer idMetier, Secteur objetMetier) throws Exception { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. }
cab1ff9b-30c8-40f2-92f4-792a2cb716ed
5
public static boolean compare(Node lhs, Node rhs) { // search each node in trees Depth first. if (lhs == null) { return (rhs == null) ? true : false; } else { if (rhs == null) { return false; } } if (lhs.data == rhs.data) { if (compare(lhs.left, rhs.left)) { return compare(lhs.r...
1094c37c-2ec3-43a7-ab67-e6ffaece4d8b
9
private boolean extraEntity(String outputString, int charToMap) { boolean extra = false; if (charToMap < ASCII_MAX) { switch (charToMap) { case '"' : // quot if (!outputString.equals("&quot;")) extra = true; ...
2090134f-0464-44c3-b69b-6e9ae08837d9
4
static void generate() { String[] players = {"mosquito.g1.WalkTowardsTheLight", "mosquito.g2.G2Dragonfly", "mosquito.g3.G3Player", "mosquito.g4.Exterminator", "mosquito.g5.G5Player", "mosquito.g6.MosquitoBuster", "mosquito.g7.ZapperPlayer"}; String[] boards = { "Blank", "BoxesAndLin...
0371aeec-f7ea-4ec5-97f2-a548b97bd52a
4
public void reapplyRowFilter() { if (mRowFilter != null) { ArrayList<Row> list = new ArrayList<>(mSelection.getCount()); int index = mSelection.firstSelectedIndex(); while (index != -1) { Row row = getRowAtIndex(index); if (mRowFilter.isRowFiltered(row)) { list.add(row); } index = mSelec...
33e126c2-c9bc-4849-9d2e-d23c455648f7
7
private void insertClientToRouteThatMinimizesTheIncreaseInActualCost(int client,int depot,int period) { double min = 99999999; int chosenVehicle =- 1; int chosenInsertPosition =- 1; double cost; double [][]costMatrix = problemInstance.costMatrix; int depotCount = problemInstance.depotCount; ArrayLi...
dd448c2f-a4fa-491a-aed4-8ece6e5d1c06
3
@Override public List<Autor> ListBySobrenome(String Sobrenome) { Connection conn = null; PreparedStatement pstm = null; ResultSet rs = null; List<Autor> autores = new ArrayList<>(); try{ conn = ConnectionFactory.getConnection(); pstm = conn.prepareStat...
af8ed57e-9234-4b5d-a0fa-6f44f49fcb55
5
@Test public void depthest01opponent5() { for(int i = 0; i < BIG_INT; i++) { int numPlayers = 6; //assume/require > 1, < 7 Player[] playerList = new Player[numPlayers]; ArrayList<Color> factionList = Faction.allFactions(); playerList[0] = new Player(chooseFaction(factionList), new SimpleAI()); ...
0fe6976e-6fa5-47f8-a12e-56a8436605d1
3
private Planet generateNewPlanet() { if(++planetNameIndex >= PLANET_NAMES.length) planetNameIndex = 0; String name = PLANET_NAMES[planetNameIndex]; int bottom = 5000; if(Math.random() <= 0.5) bottom = 3000; else if(Math.random() <= 0.5) bottom = 7000; return new Planet(model, name, false, Planet.getStandard...
26e57530-8931-4bbc-8271-e48fc7d58e81
2
public boolean isJoined(String a, String b) { ArrayList<String> aList = joinedTables.get(a); if (aList != null) { if (aList.contains(b)) { return true; } } return false; }
43a3383e-1385-4698-b574-29929cb6b8f2
7
public static String escapeHTML(String s) { if (s==null) return ""; StringBuffer sb=new StringBuffer(s.length()+100); int length=s.length(); for (int i=0; i<length; i++) { char ch=s.charAt(i); if ('<'==ch) { sb.append("&lt;"); } else if ('>'==ch) { sb.append("&g...
d6352c77-9c02-4e6f-a7da-328e7ee429ff
7
protected boolean arvoreBinariaBuscaValidaAux(Nodo nodo){ if(nodo != null){ Nodo left = nodo.getLeft(); Nodo right = nodo.getRight(); if((left != null && left.getKey() > nodo.getKey()) || (right != null && right.getKey() < nodo.getKey())){ return false; ...
773140f6-a3d9-49d2-9fb7-f2e62be97a86
7
public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) { return; } Class cl = obj.getClass(); try { if (_writeReplace != null) { Object repl; if (_writeReplaceFactory != null) repl = _writeReplace.invoke(_writeReplaceFactory...
85aa3004-58cb-4f31-b145-46c6f2a1103d
3
private static void objectArrayAppend(StringBuilder sbuf, Object[] a, Set<Object> seenSet) { if (!seenSet.contains(a)) { seenSet.add(a); final int len = a.length; for (int i = 0; i < len; i++) { deeplyAppendParameter(s...
ed7d0025-4498-496f-8e4f-4b5c34aa248f
4
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if ( this.isEnabled() ) { if ( command.getName().equals("sheepfeed") ) { // check for permission if ( !this.canInfo(sender) ) { sender.sendMessage("You are not allowed to use this command."); ...
3297ba43-83b2-47f2-9210-8fc39902a741
9
void clean(QNode pred, QNode s) { Thread w = s.waiter; if (w != null) { // Wake up thread s.waiter = null; if (w != Thread.currentThread()) { LockSupport.unpark(w); } } /* * At any given time, exactly one node on list cannot be deleted -- the * last inserted node. To accommodate this, if we c...
1630b752-20c6-4818-9889-91bbd8a719b6
3
public void gameRun() //gameRun is the true core of the game, this method is called in Main. { boolean gameQuit = false; // player initialization process, below. playerControl.setPlayers(); //Ask for player names //---------------------------------------------- // Main game loop below. while(gameQuit != true)...
eb20d3ca-6247-4091-8c1f-f22a353dbc1f
3
private BufferedImage load(String file){ if(textureMap.get(file) != null) return textureMap.get(file); BufferedImage image = null; try { image = ImageIO.read(getClass().getResourceAsStream(file)); } catch (IOException e) { try { image = ImageIO.rea...
9471ce91-049f-4a79-acc3-7b5d2e683c0c
4
public AST V() { // V -> D | W | ( L ) List<String> emp = Collections.<String>emptyList(); // an empty list String next = toks.peek(); if ( isNumber(next) ) { // D double d1 = D(); return new Value(new Quantity(d1, emp, emp)); } else if ( isAlphabetic(nex...
d2afb98a-3078-4b9c-8039-a841d745eaed
1
public void update(long dt) { Widget next; for (Widget wdg = child; wdg != null; wdg = next) { next = wdg.next; wdg.update(dt); } }
ed7a9047-4914-4987-95eb-a2529bcc8ab1
1
public AlgorythmFile deleteFile(int index){ AlgorythmFile file = dataBaseFiles.remove(index); if(file != null) return file; else return null; }
aaf692ab-51e3-477c-a687-97648b62f5ef
0
@Test public void testSetRock() { System.out.println("setRock"); Cell instance = new Cell(0,0); instance.setRock(false); boolean expResult = false; boolean result = instance.getRock(); assertEquals(expResult, result); instance.setRock(true); ...
0e6c778f-48d5-498f-8c28-1ff7febc7771
7
private void generateChests() { Random rand = new Random(); Point[] chests = new Point[rand.nextInt(5) + 1]; for (int i = 0; i < chests.length; i++) { boolean a = rand.nextBoolean(); chests[i] = new Point(); chests[i].x = ((a) ? rand.nextInt(w - 2) + 1 : ((rand.nextBoolean()) ? 1 : w - 2)); chests[i]....
6e2230fe-b150-474a-9305-5b3eace5eafe
0
public boolean isAdmin() { return _prefix.indexOf('a') >= 0; }
4c265e58-1a8d-48d0-85d8-98000e33da1d
5
public Vue(Joueur[] joueurs, org.polytech.nantes.monopoly.manager.Case[] cases) throws Exception { // controle des paramètres if(!(joueurs.length == 2 || joueurs.length == 4)) { throw new Exception("nombre de joueurs renseigné incorrect"); } this.setTitle("Monopoly"); this.setDefaultCloseOperation(JF...
ea20f3d8-80f4-49a3-8187-8fd232d09cda
9
static final void method1903(int i, int i_0_, int i_1_, int i_2_, int i_3_, int i_4_, int i_5_, int i_6_) { anInt6866++; int i_7_ = 0; int i_8_ = i_2_; int i_9_ = 0; int i_10_ = -i_3_ + i_0_; int i_11_ = i_2_ + -i_3_; int i_12_ = i_0_ * i_0_; int i_13_ = i_2_ * i_2_; int i_14_ = i_10_ * i_10_; int i...
27a97c14-405e-464e-b95b-6ffaf12a2bf7
3
private static String exec(String ...cmd) { try { ProcessBuilder pb = new ProcessBuilder(cmd); Process process = pb.start(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); InputStream stdout = process.getInputStream(); int readByte = std...
c7190fcb-0d58-4c7d-962d-737734ffb9d8
1
@Override public Object getRequiredService2(Class serviceType) throws Exception { Object rs = this.getService2(serviceType); if (rs == null) { throw new MissingRequiredServiceException(serviceType); } return rs; }
77bc52b3-852e-4acb-aecb-66bacf80ad69
8
void snapshot() { if (Page.isApplet()) return; boolean b = false; if (implementMwService()) { Method method; Object c = null; try { method = applet.getClass().getMethod("getSnapshotComponent", (Class[]) null); if (method != null) { c = method.invoke(applet, (Object[]) null); } } ...
c81425d7-48ba-41a1-97c5-e321d0ad32cc
1
public void visitZeroCheckExpr(final ZeroCheckExpr expr) { if (expr.expr == from) { expr.expr = (Expr) to; ((Expr) to).setParent(expr); } else { expr.visitChildren(this); } }
c11a8e7b-081b-450e-b725-96207e31ac0b
3
public void actionPerformed(ActionEvent e){ Object object = e.getSource(); if(object == button_calc) { this.supsendBenchmarkLog(); SwingUtilities.invokeLater(new Runnable() { public void run(){attack.outerAttack(key);} }); } else if(object == button_key_length) { key = new BsGs_Key(((key_length)co...
02bdf9b6-9ea3-4f23-ad43-a1087553ee24
0
public boolean canEncode(Serializable structure) { return true; }
104667fc-1870-4e26-b20d-30ffa77b9505
4
@Override public Multiple build() { try { Multiple record = new Multiple(); record.intField = fieldSetFlags()[0] ? this.intField : (java.lang.Integer) defaultValue(fields()[0]); record.floatField = fieldSetFlags()[1] ? this.floatField : (java.lang.Float) defaultValue(fields()[1]); recor...
660670d5-5ec3-45c9-b719-5fa3441ed5eb
9
private void markExploredCell(String descriptor) throws ArenaTemplateException { String binStr = null; try{ binStr = hexToBinaryStr(descriptor); }catch(NumberFormatException e){ throw new ArenaTemplateException(2, "The descriptor contains some non-hex digit"); } if(binStr.length() != this.rowCount *...
a47541a9-d9b0-48ff-9399-75cdca1b9a9e
3
static void downloadFailedFile(final String url) throws IOException { synchronized (downloadedUrls) { if (downloadedUrls.contains(url)) { SparkUtils.getLogger().info("url already downloaded:" + url); return; } else { downloadedUrls.add(url); synchronized (downloadedUrlWriter) { downloadedU...
194c5984-7789-4919-a350-30cd03c4cf03
7
public void validate() throws InvalidMenuException{ if(style == null || mainColor == null || titleColor == null || pageColor == null || title == null){ throw new InvalidMenuException("Property null"); } if(usePrefix && prefix == null){ throw new InvalidMenuException("Prefix null and enabled"); } }
c994766d-9b04-4dca-a358-9d95cceab81b
4
public static void main(String[] args) { Random r = new Random(); ArrayList<Integer> ArrayA = new ArrayList<Integer>(); ArrayList<Integer> ArrayB = new ArrayList<Integer>(); ArrayList<Integer> ArrayC = new ArrayList<Integer>(); ArrayA.add(r.nextInt(10)); ArrayA.add(r.nextInt(10)); ArrayA.add(r.nextInt(10)...
624c46ab-fde5-4fbf-bfbb-ed6fae734900
2
public int FindRouterPacket(int seq) { int result = -1; //search for the sequence number for(int x=0; x<internalMemory.size();x++) { //compare each packet sequence with the sequence number if(internalMemory.get(x).GetSequenceNumber() == seq) { ...
50141569-aac0-47c1-a708-e00372d596a9
1
public String getString(String expression, Object context) throws XPathExpressionException { assert(expression != null); if(context == null) { assert(document != null); context = document; } return (String) xpath.evaluate(expression, ...
424fb3ce-e17b-463d-8e56-c52697278141
2
public void compileShader() { glLinkProgram(program); if (glGetProgram(program, GL_LINK_STATUS) == 0) { System.err.println(glGetShaderInfoLog(program, 2024)); System.exit(1); } glValidateProgram(program); if (glGetProgram(program, GL_VALIDATE_STATUS) == 0) { System.err.println(glGetShad...
f44d6999-171e-4281-97ca-f4935b430473
8
public static void main (String[] args) throws IOException { // starts the REPL boolean repl = true; while (repl) { try { // split input on semicolons, only grab and interpret statements before the first semicolon Scanner scan = new Scanner(System.in)....
473045d9-f0a5-4580-bea0-ce16032294f3
8
int getDifference(Image image, Colour q, int x1, int y1, int x2, int y2) throws ImageTooSmallException { if (image.getWidth() <= x1 || image.getHeight() <= y1 || image.getWidth() <= x2 || image.getHeight() <= y2 || x1 < 0 || x2 < 0 || y1 < 0 || y2 < 0) { throw new ImageTooSmallException(); } return image.ge...
a41cc94f-7a50-44c5-8f57-d37c69073d66
1
@Override protected void doRemoveAll() { try { cache.removeAll(); } catch (Throwable e) { CacheErrorHandler.handleError(e); } }
9a860a29-b9dd-47a3-b2c2-24d7954476be
4
public Vector2 GetLightPos(int j) { int i = 0; ComputedPlace p = null; while ((p = places[i++][j]) == null) ; double max = p.h * p.w; for (; i < places.length; i++) { ComputedPlace t1 = places[i][j]; if (t1 != null) { double t2 = t1.h * t1.w; if (t2 > max) { max = t2; p = ...
89d73964-9e50-4248-9ebd-c283bb68032b
2
public double getAttenuationConstant(){ if(this.distributedResistance==0.0D && this.distributedConductance==0.0D){ this.generalAttenuationConstant = 0.0D; } else{ this.generalAttenuationConstant = Complex.sqrt(this.getDistributedImpedance().times(this.getDistributedAdmitt...
fadc63ab-75b7-4e32-8fac-2915ab77bd2e
9
protected boolean[] datasetIntegrity( boolean nominalPredictor, boolean numericPredictor, boolean stringPredictor, boolean datePredictor, boolean relationalPredictor, boolean multiInstance, int classType, boolean predictorMissing, boolean classMissing) { ...
fb4e79f0-9471-45a4-b126-856fc812f351
4
private boolean containsExcludeToken(String agentString) { if (excludeList != null) { for (String exclude : excludeList) { if (agentString != null && agentString.toLowerCase().indexOf(exclude.toLowerCase()) != -1) return true; } } return false; }
3dd4b261-d0d5-4235-adcb-7f2f9cbaae64
9
private void parseID3v1ExtendedTag(byte[] tagInput) { int runningIndex = -1; // find header "TAG" for (int i = 0; i < tagInput.length; i++) { boolean foundT = tagInput[i] == (byte) 'T'; boolean foundA = (tagInput.length > i + 1 && tagInput[i + 1] == (byte) 'A'); boolean foundG = (tagInput.length > i + 2...
5b06ee00-68b0-4318-bb23-709d57f757e4
9
void compress(int init_bits, OutputStream outs) throws IOException { int fcode; int i /* = 0 */; int c; int ent; int disp; int hsize_reg; int hshift; // Set up the globals: g_init_bits - initial number of bits g_init_bits = init_bits; // ...
583defc1-6079-4e57-b59f-4812ce46be01
3
public boolean hasNext() { if (iit == null || !iit.hasNext()) { if (!it.hasNext()) { return false; } Map.Entry<K, ArrayList<Long>> item = it.next(); key = item.getKey(); iit ...
82b838b0-b8d7-45ef-8c03-a3532f0a14b5
8
protected void loadResource(ResourceSpecs<T> specs) { if (specs == null) return; String uri = specs.getUri(); if (uri == null || uri.length() == 0) { if (isVerbose()) Log.d(TAG, "1. Resource was not loaded, uri is empty"); specs.onLoaded(null, true, false); r...
a49c349a-0f98-48a3-949c-2d113a038855
2
public String printLineNumber(boolean printAlso){ currentLineNumber = lineNumber++; return printLineNumber && printAlso ? String.valueOf(currentLineNumber) + ". " : ""; }
10ca7065-a75b-4d7a-9eaa-5bc9eb31a770
4
public static boolean exportHover(double xPos,double yPos) { int check = 0; if((xPos > exportXborderL) && (xPos < exportXborderR)) check+=1; if((yPos > exportYborderT) && (yPos < exportYborderB)) check+=1; return check == 2; }
6b4ac68a-0e19-4860-91c4-ea4dc2a2a655
8
private void serialize(OutputStream out) throws IOException { LinkFlags lf = header.getLinkFlags(); ByteWriter bw = new ByteWriter(out); header.serialize(bw); if (lf.hasLinkTargetIDList()) idlist.serialize(bw); if (lf.hasLinkInfo()) info.serialize(bw); if (lf.hasName()) bw.writeUnicodeString(nam...
9ade372c-75cf-45ca-856d-a1f6aad7d0ae
4
public void gridletSubmit(Gridlet gl, boolean ack) { // update the current Gridlets in exec list up to this point in time updateGridletProcessing(); // reset number of PE since at the moment, it is not supported if (gl.getNumPE() > 1) { String userName = GridSim....
2c159eb5-0244-435b-ba65-0cc97d0999ca
9
void insert(String key, T value) { if (key.isEmpty()) { this.value = value; return; } char c = key.charAt(0); String substr = key.substring(1); if (c < character) { if (left == 0) { left = createNode(buffer, c, substr.isEmpty() ? value : null); } buffer.get(left).insert(key, value); } e...
cf4d9a7d-e03e-404a-a484-df0d87afe67d
9
public boolean isValidMove(Direction d) { if(d == Direction.DOWN) { if(compare(currentBlock, blockRow, blockCol, 1, 0) == true) return true; else return false; } else if(d == Direction.RIGHT) { if(compare(currentBlock, blockRow, blockCol, 0, 1) == true) return true; else return fa...
4a4586b8-f4e5-4230-8297-f4394c555d85
8
@org.junit.Test public void testBlocking() throws com.grey.base.GreyException, java.io.IOException { FileOps.deleteDirectory(rootdir); final com.grey.naf.BufferSpec bufspec = new com.grey.naf.BufferSpec(0, 10); final String rdwrdata = "This goes into an xmtpool buffer"; //deliberately larger than IOExecWriter'...
ca38e52b-ce41-4fb5-b2dd-c857aff44b77
1
public boolean open( ) { state = State.PROCESSING; setVisible(true); while (state == State.PROCESSING); return(state == State.OKAY); }
e9e37b12-c4e8-44f7-ac75-1ff8619f5d25
8
@Override public boolean tick(final Tickable ticking, final int tickID) { if((flag==State.STOPPED)||(amDestroyed())) return false; tickStatus=Tickable.STATUS_START; if(tickID==Tickable.TICKID_AREA) { tickStatus=Tickable.STATUS_BEHAVIOR; if (numBehaviors() > 0) { eachBehavior(new EachApplicable...
b3abe617-5a9e-4614-b89f-730108b7b903
7
public void scaleUp(){ switch (polygonPaint) { case 0: line.ScaleUp(); repaint(); break; case 1: curv.ScaleUp(); repaint(); ...
fd90d595-ce5f-4dc2-9647-6998283147c6
6
public void getCurrentRooms(CommandSender sender) { ArrayList <String> current = new ArrayList <String> (); Player [] player = Bukkit.getServer().getOnlinePlayers(); for (int i = 0; i < player.length; i++) { if (current.contains(config.getConfig().getString("Player."+player[i].getName()+".CR"))) { } els...
8667d089-01a1-49dd-87e3-edb2b9f33be8
7
public static Tetromino generatePiece() { Random r = new Random(); Tetromino t; switch (r.nextInt(7)) { case 0: t = TypeI; break; case 1: t = TypeL; break; case 2: t = TypeJ; break; case 3: t = TypeO; break; case 4: t = TypeT; break; case 5: t = TypeZ; break; case...
36924d72-0e51-429d-bf64-f37ad741fdc0
1
public static void loadWhitelistConfigYAML(MainClass mainClass) { File file = new File(path + "Whitelist/config.yml"); FileConfiguration f = YamlConfiguration.loadConfiguration(file); for(String str : f.getStringList("Whitelist")) { mainClass.whitelist.add(str.toLowerCase()); } }
8bb4979f-5052-4c96-b521-2574fef23953
2
private String getNbrString() { String r = ""; for (NbrCostPair ncp : nbrList) { if (r.length() > 0) r += ", "; r += ncp.getNbr().getId() + "[" + ncp.getCost() + "]"; } return r; }
1bf77d81-b49f-4c78-b40a-8bdb6597546b
6
private String getErrors(String algChoice, String matroidChoice, String oracleType) { error = new String[] {"", "", "", ""}; boolean runFailed = false; if (algChoice.length()==0) { error[0] = "an algorithm,\r"; runFailed = true; } if (matroidChoice==null) ...
75df3fe3-4045-4e44-878c-f34a2d655be9
5
private void list_movesMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_list_movesMousePressed current_move=null; current_sprite=null; hitbox_index_selected=-1; frame_index_selected=-1; //Add frames listOfMoves_main_file = main_doc.getElementsByTagName("Move"); DefaultListMode...
49c059db-2cf3-4931-b9ae-b5a91a225143
3
public boolean avoidAsteroid(){ boolean hit=false; for(int b=0;b<objects.size();b++){ if(objects.get(b).kind!=0) continue; boolean obstacle = collisionCircle((int)(x+vx),(int)(y+vy),h/2,(int)(objects.get(b).x),(int)(objects.get(b).y),(int)(objects.get(b).h/2)); ...
8c0f43f2-f5ad-4e64-ad2c-1b915a3003f7
1
private JPanel createSortingPane() { JPanel sorting = new JPanel(); sorting.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); sorting.setLayout(new BoxLayout(sorting, BoxLayout.PAGE_AXIS)); JSlider slider; String[] props = controller.getParametersBean().getSortingProperties(); for (String prope...
6efb81d9-7a22-4465-9740-928f94a6f5ab
8
public void setRenderer(int row, int column) { if(column == 0) setHorizontalAlignment(SwingConstants.CENTER); else if (column == 1) { setHorizontalAlignment(SwingConstants.RIGHT); for (int i=0;i<highlightIndex.size(); i++) { i...
9e1ddfc2-483d-444f-aa78-9fdf0ef5ca96
6
private void handleSelectedAction() { if (!Commons.get().isKeyPressed() && (Keyboard.isKeyDown(Keyboard.KEY_RETURN) || Mouse .isButtonDown(0) && isMouseOnSelection(currentSelection))) { Commons.get().setKeyPressed(true); switch (currentSelection) { case YES: Sounds.get().playAccept(); ...
3aa6783a-0fae-47f7-9576-8497305db32b
6
public static void main(String[] args) { Scanner input = new Scanner(System.in); String[] words = input.nextLine().toLowerCase().split("[\\W\\d]+"); TreeMap<String, Integer> wordsHashMap = new TreeMap<>(); for (String word: words) { if (wordsHashMap.containsKey(word)) { wordsHashMap.put(word, wor...
9a37abf7-4ba7-4932-b15d-4767808d1ba1
6
public boolean existeCliente(String nick, String email){ getLista g = new getLista(); ListaClientes = g.getListaCliente(); ListaProveedores = g.getListaProveedor(); for(int i = 0;i<ListaClientes.size();i++){ if(ListaClientes.get(i).getNick().equals(nick) || ListaClientes.get(i)....
51897c0a-2cc7-46c9-854f-ae0965db97d7
4
public static String md5(String str) { try { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(str.getBytes()); byte[] byteDigest = md.digest(); int i; StringBuffer buf = new StringBuffer(""); for (int offset = 0; offset < byteDigest.length; offset++) { i = byteDigest[offset]; i...
a7b41b97-8308-4c2e-8901-87a6026762cf
6
public String XMLtoResources (int number){ try { String path = new File(".").getCanonicalPath(); FileInputStream file = new FileInputStream(new File(path + "/xml/resources.xml")); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); ...
643d317e-5e3c-40db-b3d0-a9fa3195e930
9
public boolean symmetricalEqual(TreeNode a, TreeNode b){ if(a == null && b == null) return true; else if(a != null && b == null || a == null && b != null) return false; else if(a.val == b.val) return true && symmetricalEqual(a.right, b.left) && symmetricalEqual(a.left, b.right); else return fa...
fc206896-3d2a-4271-9c21-d4a3fbc4a987
5
private TableData join(HashMap<String, TableData> result) { //Queue<String> todo=new LinkedList<String>(); //Queue<String> temp=new LinkedList<String>(); String leftId=idsTobeJoin.remove(idsTobeJoin.size()-1); int index=idsTobeJoin.size()-1; String rightId; ArrayList<String> finishedId=new ArrayList<Str...
64a36609-9860-4750-85a9-5ae27fd5aaf1
2
@EventHandler public void onPlayerInteract(PlayerInteractEvent event) { if (event.getPlayer().getItemInHand().getType() == Material.SLIME_BALL && event.getAction() == Action.RIGHT_CLICK_BLOCK) { plugin.debugMessage("Block name: " + event.getClickedBlock().getType()); plugin.debugMess...
688d4294-01d1-4ed8-8970-552f2c07eecd
1
public static List<Venue> createFromResultSet(ResultSet result) throws SQLException { List<Venue> rtn = new ArrayList<Venue>(); while(result.next()) { rtn.add(createOneFromResultSet(result)); } return rtn; }
8221c88f-6969-4405-842c-b497683f31b2
0
public int calcPayment() { return ((int)(this.getEffMult()*this.getBase())); }
d73226da-7a33-44f9-a5f6-49e95305f213
9
public void setRASOutput() throws BadLocationException { if (rasChecker.isSimpleNet()) { simplePNLabel.setText("OK"); simplePNLabel.setForeground(RASConst.greenColor); } else { simplePNLabel.setText("False"); simplePNLabel.setForeground(RASConst.redColor);...
98fdd191-9c86-4bff-8e4a-899aac30471b
4
private boolean isContactAdded(Contact contact) { for(int i=0; i<addedContactCount; i++) { Contact addedContact = contacts[i]; if(addedContact.getFirstName().equalsIgnoreCase(contact.getFirstName())) { if(addedContact.getLastName().equalsIgnoreCase(contact.getLastName())) { if(addedContac...
bf808245-7ab9-48cd-9385-e9470132fda6
7
@Override public File execute(File wd, String[] cmd) { // TODO Auto-generated method stub try { if (cmd.length == 3) { File f1 = new File(wd, cmd[1]); if (!f1.exists()) throw new FileNotFoundException(); File f2 = new File(wd, cmd[2]); if (f2.exists()) throw new IOException(); ...
69c1e3a2-cc1e-49ed-9e83-d184900c5b63
0
protected Class getTransitionClass() { return MealyTransition.class; }
f7df1ca5-71c5-4d37-84d1-b572ccd2ae6a
2
public static int indexOf(final String s, final char searchChar, final int beginIndex, final int endIndex) { for (int i = beginIndex; i < endIndex; i++) { if (s.charAt(i) == searchChar) { return i; } } return -1; }
9739ca4b-ba84-4ccf-910d-dd8f05494ea3
8
public static void testDomainTheory(Symbol relationName, Symbol className) { { Surrogate renamed_Class = Logic.getDescription(className).surrogateValueInverse; Proposition prop = null; Cons consQuery = Stella.NIL; QueryIterator query = null; List instances = Logic.allClassInstances(renamed_C...
6cc1fb8c-046b-4474-98f8-4d8e4a352066
2
public void setSizeY(int y) { ySize = y; image = new BufferedImage(xSize, ySize, BufferedImage.TYPE_INT_RGB); for (int i = 0; i < xSize; i++) { for (int j = 0; j < ySize; j++) { image.setRGB(i, j, 0xffffff); } } }
90b85da9-d494-4f15-87fb-1de4588bcc9e
8
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { final MOB target=this.getTarget(mob,commands,givenTarget); if(target==null) return false; if(!super.invoke(mob,commands,givenTarget,auto,asLevel)) return false; final boolean success=prof...
b4726bcd-12f9-41dc-b6a2-36067b78fd41
6
private void generate() { rand = new Random(); MazeNode initial = grid[rand.nextInt(x_Dim)][rand.nextInt(y_Dim)][rand .nextInt(z_Dim)]; MazeNode current = initial; current.setVisited(true); int count = 1; int size = x_Dim * y_Dim * z_Dim; // checks if all nodes in maze have been visited; continues o...
f5f0f0d0-c195-4a4d-8f1f-946ef5880155
7
private void showCommandPrompt() { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.print(localName + "# "); String inputCommand; try { while ((inputCommand = in.readLine()) != null) { String[] tokens = inputCommand.split(" "); if ("show".equals(tokens[0])) { ...
455758d0-13bb-4716-aee5-409de70cb09e
5
@Test public void testPropertiesFile() { String[] testPropsAFF = {"duration", "title", "author", "album", "date", "comment", "copyright", "ogg.bitrate.min", "ogg.bitrate.nominal", "ogg.bitrate.max"}; String[] testPropsAF = {"vbr", "bitrate"}; try { File file = new Fi...