method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
4afad216-c54f-414c-b218-167b6a3a09d1
2
public static int findKth( LinkedListNode head, int k ) { if ( head == null ) { System.err.println("head cannot be null!"); } if ( k < 0 ) { System.err.println("Invalid k!"); } // the initial value for the accumulator should be zero. return findKthHelper( head, k ); }
963fac86-dec3-43d1-aea4-b984509249f6
9
@Override public boolean proficiencyCheck(MOB mob, int adjustment, boolean auto) { if(auto) { isAnAutoEffect=true; if((mob!=null)&&(!mob.isMine(this))) setProficiency(100); return true; } isAnAutoEffect=false; int pctChance=proficiency(); if(mob != null) { if(CMSecurity.isAllowed(mob,mo...
abba3071-7310-4951-8507-9067bfd3d299
1
private void menuFichierQuitter() { try { Jdbc.getInstance().deconnecter(); } catch (Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage(), "CtrlPrincipal - fermeture connexion BD", JOptionPane.ERROR_MESSAGE); } finally { System.exit(0); ...
ef8b58dc-dade-4bc8-89d6-93e2d30f9e23
7
public void undo(){ //if the is nothing on the undo-stack, we can not undo anything if(undo.size() == 0) return; //get the moves from the top of the stack int dx = undo.get(undo.size()-1).get(0); int dy = undo.get(undo.size()-1).get(1); int moved = undo.get(undo.size()-1).get(2); // 0 = did not move a...
3c4b9cdd-8d3b-4a5b-8fbf-64358d6b26c5
6
protected String extractType(Engine engine) { if (engine.type() == Engine.Type.NONE) { return "none"; } else if (engine.type() == Engine.Type.MAMDANI || engine.type() == Engine.Type.LARSEN) { return "mamdani"; } else if (engine.type() == Engine.Type.TAKAGI_SUGENO) { ...
edeeb3b6-e94f-45cd-a395-03b2f9e8c7f1
3
public static boolean isWhitespace(final String string) { final int string_length = string.length(); if (string_length == 0) return false; for (int i = 0; i < string_length; i++) { if (! Character.isWhitespace(string.charAt(i))) return false; } return true; }
f4bf03f7-1d0d-4bdf-b159-6f7d482d6431
7
public XMLCache(String xmlFileName) { Logger l = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); Document doc = null; if (xmlFileName==null || xmlFileName.isEmpty()) throw new IllegalArgumentException(); try { xmlFile = Paths.get(xmlFileName); if (Files.exists(xmlFile)) { org.jdom2.input.SAXBuilder...
ea94853b-2034-4c66-a511-008c3d5096ea
3
public int getCap(int size){ if (resource1==1){ if (size==1){ return sgenrate1; } else if (size==2){ return mgenrate1; } else { return lgenrate1; } } else{ return 0; } }
6711182d-f893-496b-8ad0-86541b02462d
6
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Luodaan timeksi muuttamista varten SimpleDateFormat. SimpleDateFormat aika = new SimpleDateFormat("HH:mm"); // Luodaan myös Date-muotoiset oliot. Date arkialku = new Date(); Date arkilo...
ec10fc65-7046-467d-b6f8-6af97a11514a
2
public void statistics(double dbl){ FileWriter fWriter = null; BufferedWriter writer = null; try { fWriter = new FileWriter("statistics.txt",true); writer = new BufferedWriter(fWriter); String s=""; for(int l=0; l < bestArch.length; l++) s+=bestArch[l]+" "; writer.write(...
09d88a2f-fba7-46ff-8d90-95bdec4e6613
7
private void performLanding(World world, Box2D site) { if (! (dropPoint instanceof Venue)) { // // Clear any detritus around the perimeter, Claim tiles in the middle as // owned, and evacuate any occupants- for (Tile t : world.tilesIn(site, false)) { if (t.owner() != null) t.owner(...
85dacda8-401b-41f2-aa40-95d20233e243
6
public Point rotate( Direction d, int w, int h ){ switch( d ){ case down: return create( w - _x - 1, h - _y - 1 ); case flipH: return create( _x, h - _y - 1 ); case flipV: return create( w - _x - 1, _y ); case left: return create( _y, w - _x - 1); case right: return create( h - _y -1 , _x ); case ...
d8edb344-e716-409e-8e42-ab0fbde8d8c7
4
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // CHANGE: The EJB is instantiated automatically // CourseModel model = CourseModelImpl.getInstance(); String path = request.getServletPath(); if (path.equals("/ProgramController")) ...
c4e89c5f-6b69-4c04-90cc-edc807ed628a
7
public static void makeCompactGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad) { SpringLayout layout; try { layout = (SpringLayout)pa...
1f7cc368-1c87-495c-be6e-8030adacdeda
6
public static void flatten(TreeNode root) { if(root == null){ return ; } Queue<TreeNode> currentLevel = new LinkedList<TreeNode>(); TreeNode newNode = new TreeNode(root.val); TreeNode head = newNode; TreeNode empty = new TreeNode(0); currentLevel.add(root); ...
f5bb1f58-ca5b-41f4-b9e6-3290a9a1eb71
5
public void buildPathHelper(Tile curr) { if (curr.getNextTile().size() != 0) { if (!path.contains(curr)) path.add(curr); else return; for (int i = 0; i < curr.getNextTile().size(); i++) { buildPathHelper(curr.getNextTile().get(i)); } } if (path.size() != 0 && curr.getNextTile().size() == 0...
532d5b1e-e8f6-44b1-9615-243a18fb5299
3
public static Object fromByteArray(final byte[] objectData) { ByteArrayInputStream bais = new ByteArrayInputStream(objectData); ObjectInputStream ois = null; try { ois = new ObjectInputStream(bais); final Object obj = ois.readObject(); return obj; ...
41aca327-192a-490f-bd35-48dd0575ad28
5
private List<JarEntryData> filterEntries(List<JarEntryData> entries, JarEntryFilter[] filters) { List<JarEntryData> filteredEntries = new ArrayList<JarEntryData>(entries.size()); for (JarEntryData entry : entries) { AsciiBytes name = entry.getName(); for (JarEntryFilter filter : filters) { name = (filt...
8eb7bbc3-6452-483f-96e7-ac01e20692c1
1
@Test public void validateBudgetContainsSalaryValue() throws Exception { Budget budget = createAnnualBudget("Annual Budget", null); try { calculateBudgetBreakdown.calculateBreakdown(budget, budgetBreakdown); fail("Salary value is missing from budget."); } catch (Sala...
091b13bd-fd0a-420d-87e9-c7965a15b7e1
6
public Names inflectTo(Names names, Case $case) { Gender gender = names.gender == null ? Gender.detect(names.middleName) : names.gender; CaseInflection inflection = new CaseInflection(this.provider, gender); return new Names( inflection.i...
d97c65ff-dd2c-4c38-acb7-ad4d6f9fb9bf
3
private PDFObject findResource(String name, String inDict) throws IOException { if (inDict != null) { PDFObject in = resources.get(inDict); if (in == null || in.getType() != PDFObject.DICTIONARY) { throw new PDFParseException("No dictionary called " + inDict +...
94d6b654-70ca-4c6e-b281-fa5d2682b252
0
public PDANondeterminismDetector() { }
154207ec-169d-4b42-82cd-37baddc87625
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
36348070-ec95-4232-9602-ea754a455ae4
5
private void addAllUniforms( String shaderText ) { HashMap<String, ArrayList<GLSLStruct>> structs = findUniformStructs( shaderText ); final String UNIFORM_KEYWORD = "uniform"; int uniformStartLocation = shaderText.indexOf( UNIFORM_KEYWORD ); while ( uniformStartLocation != -1 ) { if ( !( uniformStartLoca...
4826e1fe-39f9-408c-bfae-a15a68ded2ca
0
public Integer interpret(Context con) { return left.interpret(con) * right.interpret(con); }
9f9f3e3c-411d-476d-b4b4-e457e571852b
2
public static String GetJsonToString(Statement statement,String UID) { List<ParkRelation> parkList = new ArrayList(); String resultString = null; String sql; String result = null; sql = "select * from parkrelation where UID = '" + UID +"'"; try { ResultSet rs = statement.executeQuery(sql); while (...
6882cabd-4176-4fc6-a7f1-8372de901c8b
7
public void fill(MyList blankPos,String stillWalking,Board board){ Set set = owner.keySet(); Iterator it = set.iterator(); int[][] binds = new int[17][9]; for (int[] row : binds) Arrays.fill(row, -1); while (it.hasNext()) { Hexpos hp = (Hexpos) it.next(); if (owner.get(hp) != null) { System.out....
e7427a14-9ff5-40b9-80a6-186bbc245902
2
@Override public String toString() { return isStable() ? super.toString() + "." + patch : build != 0 ? super.toString() + "." + patch + "-" + qualifier + "." + build : super.toString() + "." + patch + "-" + qualifier; }
6d418e06-f43f-417e-84c3-bc78cea06d6c
3
public tempAlg(Calendar sDate) { database.openBusDatabase(); startDate = sDate; endDate = (Calendar)startDate.clone(); endDate.add(Calendar.DATE, 6); routeIDs = BusStopInfo.getRoutes();//get all routes driverIDs = DriverInfo.getDrivers();//get all drivers busIDs = BusInfo.getBuses();//get ...
12a64f02-1429-4e08-b6f8-03798864682b
6
public PidServerImpl(PidServerConfig psc) throws NoSuchAlgorithmException { if (psc.epicServerUrl == null) throw new IllegalArgumentException("configuration parameter `epicServerUrl` is null"); if (psc.localPrefix == null) throw new IllegalArgumentException("configuration paramet...
a619124c-e330-45b2-8d0f-a716970002e2
1
public Object clone() { final LocalExpr[] t = new LocalExpr[targets.length]; for (int i = 0; i < targets.length; i++) { t[i] = (LocalExpr) targets[i].clone(); } return copyInto(new InitStmt(t)); }
b2c53daa-ec20-4bab-a350-f5c50a0967e0
5
public boolean shotTest(Element node, Map<String, Double> ensAttr) throws DataConversionException { boolean res = false; if(ensAttr.isEmpty()) return true; if (node.getAttributeValue("type").equals("leaf")) { Element leaf = node.getChild("population"); System.out.println(leaf.getAttribute("L0"...
d9c7d4ab-f44b-4bb8-8b56-f7aeab7a66b7
2
public boolean isGas() { for(int i = 0; i < eGas.length; i++) if(eGas[i] == protons) return true; return false; }
542613a2-e10d-4875-aadb-3e4d963b2ca0
2
public double evaluate(double x){ double y = 0.0; if(this.deg==0){ y = this.coeff[0]; } else{ y = this.coeff[this.deg]; for(int i=this.deg-1; i>=0; i--){ ...
ad0b1638-a05b-476f-a24a-60e894313c3a
5
public static void getAssociateLink(String genre, String title, StringBuilder sb) { Matcher m_href = p_wikiparen.matcher(title); String href_2 = m_href.find() ? (m_href.group(3) == null ? m_href .group(2) : m_href.group(3)) : title; String word; if (p_dvd.matcher(genre).find()) word = "&index=dvd"; ...
02df4d2b-bf00-412e-bab6-698980986cf1
8
public String ValidarCampo(ComprobanteVenta BEEntidades) { Result rs = new Result(); StringBuilder sb = new StringBuilder(); //sb.append(Common.IsMinorOrEqualsZero(BEEntidades.getConcepto())? "nombre inválido,": ""); sb.append(Common.IsMinorOrEqualsZero(BEEntidades.getNumero())? "Num...
11dcbe97-fe9c-4ad9-aff6-668b10158a65
9
@Override public boolean canMove(Board board, Move move) { Direction moveDirection = move.getDirection(); // TODO Re add that //if(moveDirection.getY() != direction.getY()) { //moving the wrong way //return false; //} Piece piece = board.get(move.get...
713eae3e-f296-44d2-881a-182df22bd443
4
public double[] LivingProbabilities(){ double[] output = new double[NumPlayers]; for(int n = 0; n < NumPlayers; n++){ double ProbLiving = 0; for(int i = 0; i < 4 + NumWolves; i++){ if((i == 2) || (i == 3)) { // These are dead roles, ignore. } else { ProbLiving += Probabilities[n][i]; } ...
3e62cd37-d379-4882-9668-9a8ed21601a3
9
public void performAction(String eventName, Object value) { SubGraph sd = Select.getSelection(blackboard); if (sd == null) sd = new SubGraph(); for (Vertex v : sd.vertices) if (!last.vertices.contains(v)) { select(v); last.vertices.add(v); ...
e80d8e59-a930-4274-aeca-f3349b3d9087
6
public void initialize() { mPortId = null; @SuppressWarnings("rawtypes") Enumeration portEnum = CommPortIdentifier.getPortIdentifiers(); //First, Find an instance of serial port as set in PORT_NAMES. while (portEnum.hasMoreElements()) { CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextEl...
787d0330-dd61-41e0-9f5d-95cbb5ffc38b
3
public void reorderList(ListNode head) { ListNode dummy = new ListNode(0); dummy.next = head; ListNode p = dummy; ListNode dummy1 = new ListNode(0); int l = 0; while(p.next != null){ if(++l % 2 == 0){ ListNode tmp = p.next; p.next = tmp.next; tmp.next = dummy1.next; dummy1.next = tmp; ...
bfca4a9b-f39d-419b-b0b1-e65f9e03b5e6
3
@Override public void run() { while (!stop) { try { // attempt masking at this rate Thread.sleep(1); } catch (final InterruptedException iex) { iex.printStackTrace(); } if (!s...
921cbbfd-09a1-432b-9c16-c10e47a2ea60
4
public void addUser(User u){ boolean exists = false; User existingUser = null; LinkedList<User> userCopy = new LinkedList<>(); for(User usr : users){ userCopy.add(usr); } for(User user : userCopy){ if(user.getIP().getHostName().equals(u.getIP().get...
3ba20187-a018-4e25-aff0-775bde26c74f
8
private void gameLoop() { long beginTime, timeTaken, timeLeft; //used to control the timing. while(true) { beginTime = System.nanoTime(); if (state == State.GAMEOVER) { System.out.println("GAME OVER"); } else if (state == State.NEW_GAME) { findNewGame(); } else if (state == State.WA...
d5dd891f-b54b-47ad-86c3-4dfce6ce0f76
4
public com.novativa.www.ws.streamsterapi.Order[] getOrders() throws java.rmi.RemoteException { if (super.cachedEndpoint == null) { throw new org.apache.axis.NoEndPointException(); } org.apache.axis.client.Call _call = createCall(); _call.setOperation(_operations[2]); ...
b33167ad-9e52-4231-a8a1-e9820532bcff
6
public final void spawnBlockParticles(Level var1, int var2, int var3, int var4, int var5, ParticleManager var6) { float var7 = 0.1F; float var8 = (float)var2 + random.nextFloat() * (this.x2 - this.x1 - var7 * 2.0F) + var7 + this.x1; float var9 = (float)var3 + random.nextFloat() * (this.y2 - this.y1 - var7 * 2.0F)...
0e17a6c3-e424-45db-9333-15e104f6ae14
5
public void updateEntityRenderList(World world) { entitiesToRender.clear(); for(Entity ent : world.getEntityList()) { Vector2f c = ent.getCoords(); if((c.x >= (cLoc.x - (cameraWidth / 2) - ent.getWidth()) || c.x <= (cLoc.x + (cameraWidth / 2) + ent.getWidth())) || (c.y >= (cLoc.y - (cameraHeight / 2) ...
3ff35079-8023-4c80-99f4-8b0fbac574bc
3
@Override public Study getDefaultStudy() { // See if file exists File storage = new File("./studies/.defaultstudy"); if(!storage.exists()) return null; // No .defaultstudy file String name; try { // Read name from file name = new S...
0308e087-7dab-46f9-9d84-9dd37971af80
3
@Override public void keyPressed(KeyEvent ke) { switch(ke.getKeyCode()) { case KeyEvent.VK_UP: isUpPressed = true; break; case KeyEvent.VK_DOWN: isDownPressed = true; break; case KeyEvent.VK_SPACE: isSpacePressed = true; break; ...
c789568a-fa6b-4c7e-89ce-319af62bd176
3
public void setScale(double newScale) { if (newScale == this.scale) { return; } this.scale = newScale; if (newScale != 1.0) { this.scaledImage = toBufferedImage(originalImage.getScaledInstance( (int) (newScale * originalImage.getWidth()), (int) (newScale * originalImage.getHeight()), Ima...
32467b6d-c411-46ce-95d4-9e8c9f9805cf
7
public static String checkSquare(String[] input){ Integer startIdx, endIdx, length; for(int i=0; i<input.length; i++){ if(input[i].indexOf("#") != -1){ startIdx = input[i].indexOf("#"); endIdx = input[i].lastIndexOf("#"); length = endIdx - startIdx + 1; if (!checkLine(input[i], startIdx, endId...
531b007a-48a0-4ed9-9712-98ba056a0e51
5
public static void crowdsim(Map map)//working crowd simulation { //uses three cells per person, one to start, one to be the move and one to clear the old cell personCell3=personCell;// sets 3 to 1 personCell2=map.getnextperson(personCell); // sets the next cell to the lowest adjacent cell to the curr...
521f4fd1-d102-4a00-8e04-bd0b2090a6fd
5
private void doMouseDraggingCheck(){ if (Mouse.isButtonDown(0)) { int mX = Mouse.getX(); int mY = GameApplication.getScreenHeight() - Mouse.getY(); int[] rect = computeDraggingRect(); if (mX >= rect[0] && mX <= rect[2]){ if (mY >= rect[1] && mY <=...
f6e53b4c-1785-4b52-85c9-a88853d82004
9
private void setInitVars(RootStatement root) { boolean thisVar = !method.hasModifier(CodeConstants.ACC_STATIC); MethodDescriptor md = methodDescriptor; if (thisVar) { StructClass cl = (StructClass)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS); VarType clType = new VarType(Code...
89639fb2-b838-4c8b-8e07-e00a6458a83c
1
private static boolean insertPrescription(Prescription bean, PreparedStatement stmt) throws SQLException{ stmt.setDate(1, bean.getStartDay()); stmt.setDate(2, bean.getThisDay()); stmt.setString(3, bean.getDose()); stmt.setInt(4, bean.getQuantity()); stmt.setInt(5, bean.getRefill()); stmt.setInt(6, bean.g...
35db3745-8043-4009-b109-dbc0527ba5bb
3
public static AI createAI(Game game, int AItype, boolean color) { // TODO Auto-generated method stub if(AItype==RANDOM) { return new RandomAI(game, color); }else if(AItype==AI.RANDOM_AGGRESSIVE) { AI answer = new RandomAggressive(game,color); return answer; }else if(AItype==AI.BAD_THINKER) { r...
d04d96e7-76bb-4e18-a8ef-3d6a30e8f746
3
public boolean contains(String search){ for (int f = 0; f < width; f++){ for (int k = 0; k < height; k++){ if (inventory[f][k].returnName().equals(search)){ return true; } } } return false; }
b7212572-a3e0-45f4-8c87-5d2d15a9850d
0
public List<Client> getClient() { return client; }
d6a3e68b-5150-4e5b-a4aa-16d69b1607f0
4
public TreeNode getSecondMax() { TreeNode current = root, parent = null; if (current == null) return null; while (current.right != null) { parent = current; current = current.right; } if (current.left != null) { current = current.left; while (current.right != null) { current = current.ri...
fa63fbb4-2d4d-465b-bf99-a1eeebbb6dc7
1
public void testFormatAppend_PrinterParser_null_null() { try { new PeriodFormatterBuilder().append(null, null); fail(); } catch (IllegalArgumentException ex) {} }
4eceba26-fb7f-4fe0-bb23-c656e1e73711
1
@Override public void render() { super.render(); /* Collection<ShopItem> items = Application.get().getLogic().getGame().getShop().getAvailableItems(); int indx = 0; for(ShopItem i : items) { itemSlots.get(indx).setItem(i); indx++; } */ ...
8430ed92-21d8-47db-b05f-988c07624fe0
0
public BinaryDataType getSecret() { return secret; }
09d4399f-dd5b-46be-88b2-9100abb52f9c
0
public void setY(int newY) { this.y = newY; }
18d78ef2-966f-4037-91d2-dfd7566415db
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://downl...
47a9c951-2582-40f5-ba13-651391d10429
9
public static String unquote(String string) { if (string.startsWith("'") && string.endsWith("'")) { string = string.substring(1, string.length() - 1); if ((string.indexOf("\\n") != -1) || (string.indexOf("\\r") != -1) || (string.indexOf("\\'") != -1) || (string.indexOf("\\\"") != -1) || (...
cf5a0e1f-7678-4fae-a05a-2f0c42952c07
1
protected void count(int read) { if(read != -1) { bytesRead = bytesRead + read; } }
76fe0fd9-ee4e-42c6-bdde-a72854cef0f7
2
private static void parseNext(final Iterator<String> argIter) { final String flag = argIter.next(); if ("--license".equals(flag)) { printFile(LICENSE_FILE, System.out); System.exit(0); } else if ("--help".equals(flag)) { printFile(USAGE_FILE, System.out); ...
5840559e-1c5d-40ab-8fd3-43dcdbd5cad9
0
@Override public void mouseExited(MouseEvent e) {}
56aa5691-b97e-486f-b91c-565ecb638e69
5
private static void merge(Comparable[] array, int low, int middle, int high) { Comparable[] tempArray = new Comparable[array.length]; int i = low; int j = middle + 1; for(int q = low; q <= high; q++) { tempArray[q] = array[q]; } for(int q = low; q <= high; q++...
35f2d2e2-7409-454b-827c-07dc20766644
3
private void declaration() { if (have(NonTerminal.VARIABLE_DECLARATION)) { variableDeclaration(); } else if (have(NonTerminal.FUNCTION_DEFINITION)) { functionDefinition(); } else if (have(NonTerminal.ARRAY_DECLARATION)) { arrayDeclaration(); } }
46d9c2a4-d655-4139-9272-f04d4f4a51db
5
public void reloadDonatorCommands() { donatorcommands.clear(); try { ClassFinder classFinder = new ClassFinder(); String[] classes = classFinder.listClasses("net.sf.odinms.client.messages.commands.donator", true); registerDonatorCommand(new HelpDonatorCommand()); // r...
80b09d3b-3695-4143-b476-289a10867a62
0
public TableTextSizeSlider(JTable table) { super(FONT_SIZE_MIN, FONT_SIZE_MAX, FONT_SIZE_INIT); this.addChangeListener(new SliderListener()); setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), TABLE_SIZE_TITLE)); myTable = table; }
a9a69770-cc07-42af-80c8-e884eadbe869
1
public static void deleteCookie(HttpServletRequest request, HttpServletResponse response, Cookie cookie) { if (cookie != null) { cookie.setPath(getPath(request)); cookie.setValue(""); cookie.setMaxAge(0); response.addCookie(cookie); } }
ad7c1933-c9c7-408e-a048-1881757145af
3
public static void bubble_srt( int a[], int n ){ int i, j,t=0; for(i = 0; i < n; i++){ for(j = 1; j < (n-i); j++){ if(a[j-1] > a[j]){ t = a[j-1]; a[j-1]=a[j]; a[j]=t; } } } }
b7967779-7e15-49ff-b9b9-bafaf961c4a1
3
private static final String stripDots(String path){ path = path.trim(); if(path.charAt(0) == DOT){ path = path.substring(1); } if(path.charAt(path.length() - 1) == DOT){ path = path.substring(0, path.length() - 1); } //jvm, neptical, and a few supporting fram...
a3d5825f-9385-4bfd-a3f7-a8a13e0c47eb
8
void drawGun(Graphics g) { gunDirLocation(); switch(gunDir) { case U: g.drawLine(x+width/2, y+heigth/2, x+width/2, y-GUN_LENGTH);; break; case D: g.drawLine(x+width/2, y+heigth/2, x+width/2, y+heigth+GUN_LENGTH); break; case L: g.drawLine(x+width/2, y+heigth/2, x-GUN_LENGTH, y+heigth/2); bre...
0976ac4e-acc9-4512-bad0-fc57672fb362
1
@Test public void filtersByAddressWorks() { citations.add(c1); filter.addFieldFilter("address", "Helsinki"); List<Citation> filtered = filter.getFilteredList(); assertTrue(filtered.contains(c1) && filtered.size() == 1); }
c9947143-23fd-4d38-82cb-2e487296e3a6
4
@Override protected void decode( ChannelHandlerContext ctx, ByteBuf in, List<Object> out ) throws Exception { in.markReaderIndex(); byte[] data = new byte[3]; for (int i = 0; i < data.length; ++i) { if (!in.isReadable()) { in.resetReaderIndex(); return; } data[i] = in.readByte(); ...
5a5012c8-e177-41f5-9b7b-047fd3e5a795
7
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
5e81f64a-c80b-4272-98ba-1b83a72960eb
6
public boolean collision(Tetromino tetromino){ boolean isCollision = false; //going right if ((tetromino.getLeft() + tetromino.getWidth() > strengthMap[0].length)){ return true; } //going left if (tetromino.getLeft() < 0){ return true; } //reached bottom if (tetromino.getBottom() > stre...
02bcb651-c1e1-47bd-82e5-70a73b16afc7
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 ...
5e84d261-3f73-44a1-b9d2-48e499c61070
4
@Override public void run() { try { dataConnectionSocket = new Socket(address, port); inputStream = new ObjectInputStream( dataConnectionSocket.getInputStream()); DataMessage message = (DataMessage) inputStream.readObject(); while (message != null) { if (message.getDataMessageType() == DataMessa...
3668db69-f8f3-42ba-a621-ef22c969abc5
0
public void setQuantity(int quantity) { this.quantity = quantity; }
505da89a-ac06-4fcb-98f9-791e8b763554
6
public synchronized void updateDownload( Download download ) { LeafNode node = getNode( download ); if ( download.isActive() && node == null ) { treeModelDL.insertNodeInto( new LeafNode( download ), ( (DefaultMutableTreeNode) treeModelDL.getRoot() ), ...
849f9ea8-a23d-4366-a874-049d4cf3655a
7
@Override protected void connected(Socket socket) { sock = socket; try { sock.setTcpNoDelay(true); try { sock.setTrafficClass(0x10); } catch(SocketException e) { System.out.println("Connection Error! >> " + e.getMessage()); } ...
c6d7db26-30d1-489f-84d1-5aef55d7ba8a
8
public void onKeyPressed(KeyEvent e) { switch (e.getKeyCode()) { case VK_UP: case VK_W: // Arrow up key: move direction = forward (infinitely) moveDirection = 1; moveAmount = Double.POSITIVE_INFINITY; break; case VK_DOWN: case VK_S: // Arrow down key: move direction = backward (infinitely) ...
27cc01f0-4609-4443-9091-8adb8a5d571c
9
private void decideBlockedLaneChangeDecision() { Segment adjacentSeg = getAdjacentSegment(vehicle.getHeadSegment()); if (adjacentSeg == null) return; Lane adjacentLane = adjacentSeg.getLane(); if (adjacentLane.getVehicles().isEmpty()) { // if the adjacent lane ...
8b629265-8e8e-4997-ac9d-c1acf0ae6d5e
5
public SQLiteJDBC() { try { Class.forName("org.sqlite.JDBC"); } catch (ClassNotFoundException e) { System.err.println(e); } Connection connection = null; try { // create a database connection connection = DriverManager.getConnection("jdbc:sqlite:Presets.db"); Statement statement = connection.cr...
77d499b9-86b0-4aaa-8fc0-1bd7c9451459
0
public void setGeometry(GeoJsonObject geometry) { this.geometry = geometry; }
6d5322ba-760d-4184-9d30-b48bb3903e89
2
public static boolean setProtection(Path file, boolean activated) { boolean ret = false; if (!FileUtil.control(file)) { return ret; } if (activated) { ret = WindowsFileProtection.resetProtection(file); } else { ret = WindowsFileProtection.re...
af967ee9-3297-4e42-a116-ae674d4dbe14
8
public static void handleEvent(int eventId) { // Do nothing because same screen is being selected if(eventId == 1) { } // Do nothing because same screen selected else if(eventId == 2) { System.out.println("Exit Ship Shop Main menu to Engines Ship Shop Menu selected"); Main.ShipShopMenu.setVi...
4ef7f15a-48ca-4173-8473-3ac65c775a64
7
private void openConfigWindow() { if (configFrame == null) { configFrame = new JFrame("Admin Helper Agent - configure"); configFrame.setSize(400, 200); configFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); configFrame.setLayout(new BorderLayout()); actionListener = new ActionListener() { pub...
ddc269ab-b76d-4b6a-9b91-5d85610bd855
6
@SuppressWarnings("unchecked") public static HashMap<?,?> sortByValue(HashMap<?,?> map, final int flag) { // flag = 0 decreasing order otherwise increasing List list = new LinkedList(map.entrySet()); Collections.sort(list, new Comparator() { public int compare(Object o1, Object o2) { if(flag == 0 ) r...
c3fd7482-613c-4d34-91a3-1ec35dd46967
9
public static void main(String args[]) { /* * Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* * If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and fe...
69a9b8f0-d44e-44b1-8ec4-db523e0b2385
0
public void eatIncrement(){ eat++; }
f9164080-bde8-4f01-8b32-1bbe513a1514
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
7e5f88e0-4037-4a18-bd9d-15d77c239d62
5
private static void strategyProdGreater(int nbrProductor,int nbrConsumer ,Productor[] productors, Consumer[] consumers){ final Integer differenceProdCons = nbrProductor - nbrConsumer; final Integer boxSize = nbrConsumer; final MultiBox<Integer> sharedMultiBox = new MultiBox<Integer>(boxSize); ...
a3d72ec1-d606-4a82-a0bc-62eff31b7db7
1
public void initialise(){ for(int i=0; i < tabMarq.length; i++){ // On initialise le tableau this.tabMarq[i] = 0; } }
ee1cf490-5c8f-4120-9c11-fba77c760535
7
public void processRequest(Order order, int x){ int orderSize = 0; /*if(stockMap.get("steak").amount > 0){ //if(stockMap.get("steak").amount >= order.cookInventory.get("steak").capacity){ orderSize = order.cookInventory.get("steak").capacity - order.cookInventory.get("steak").amount; if((stockMap.get...
b91f5b99-03ed-40ab-b503-151f8e1b5413
9
protected Variable getVariableImpl(String name, boolean recurse) throws UtilEvalError { Variable var = null; // Change import precedence if we are a class body/instance // Get imported first. if (var == null && isClass) var = getImportedVar(name); if (var == null && variables != null) var = (Variable)...