method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
ff0ba124-51dc-4477-b302-f5aa29ed2ca6
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Message)) { return false; } Message other = (Message) object; if ((this.messageId == null && other.messageId !=...
78906067-8181-47b4-a479-0e26a8bbab8b
8
public double getValue (double x, double y, double z) { // This method could be more efficient by caching the seed values. Fix // later. x *= frequency; y *= frequency; z *= frequency; int xInt = (x > 0.0? (int)x: (int)x - 1); int yInt = (y > 0.0? (int)y: (int)y - 1); ...
e4ba748d-57aa-4413-a7e9-5552d9e7063e
0
public static void setNow(long timestamp) { timeDiff = timestamp - new Date().getTime(); }
5132ebd7-629d-4a0b-9c91-f53385afe703
0
public void setStatus(int status) { this.status = status; }
01d6f57b-2247-4c42-ae2a-ebedf8de5655
7
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { Physical target=mob; if((auto)&&(givenTarget!=null)) target=givenTarget; if(target.fetchEffect(this.ID())!=null) { mob.tell(mob,target,null,L("<T-NAME> <T-IS-ARE> already affected by @x1.",...
cdc38d03-053f-4610-9484-f1b04b1d0c78
9
private ArrayList<Desire> findDesires() { ArrayList<Desire> returnDesires = new ArrayList<Desire>(); for (Agent a : level.agents) { if (!getToBoxDesireCompleted(a)) { for (Box b : level.boxes) { //System.err.println("adding box goal with " + b.getId()); if (a.getColor() == b.getColor() && !...
f0c5e6cd-57ae-4c8c-ab9c-7fa4e59b843a
5
private static PrintStream getStream(String type) { if (type == null) return null; if (type.equals("stdout")) { return System.out; } else if (type.equals("stderr")) { return System.err; } else if (type.startsWith("file:")) { String relativeDir = Settings.get(Settings.DEBUG_DIR); try { return ...
c0a3529d-1d2f-466d-9a19-1eac33c8f904
4
public Hashtable getDictionary(Hashtable dictionaryEntries, String key) { Object o = getObject(dictionaryEntries, key); if (o instanceof Hashtable) { return (Hashtable) o; } else if (o instanceof Vector) { Vector v = (Vector) o; Hashtable h1 = new Hashtable();...
4dca6bc8-123c-42f2-bc04-843182ed29ee
9
protected Apply(Element apply, FieldMetaInfo.Optype opType, ArrayList<Attribute> fieldDefs, TransformationDictionary transDict) throws Exception { super(opType, fieldDefs); String functionName = apply.getAttribute("function"); if (functionName == null || functionName.length() == 0) { /...
a740d621-3f9f-4388-bb73-05659c1a89e9
8
private Map<String, Object> values(final int type, final ValueVisitor defaultVisitor) { Class<?> clazz = getClass(); final FieldDefinitionImpl thiz = this; final Map<String, Object> map = new HashMap<String, Object>(); SpringReflectionUtils.doWithFields(clazz, new SpringReflectionUtils.FieldCallback() { ...
e80f64ce-5ea6-4001-a0e2-a8c724e24473
2
public void simulateGrowth() { for (Planet p: planets){ if(p.Owner() == 0) continue; Planet newp = new Planet(p.PlanetID(), p.Owner(), p.NumShips()+p.GrowthRate() , p.GrowthRate(), p.X(), p.Y()); planets.set(p.PlanetID(), newp); } }
06115791-2e7f-463e-a23e-2ba5de5ae7f4
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Comment)) { return false; } Comment other = (Comment) object; if ((this.commentID == null && other.commentID !=...
7231cae2-8c2d-471b-b34f-2e5d448a37c3
5
public void tick(){ gsm.tick(); if (FallingBlocks.lives <= 0) { Sound.playGameOverSound(); gameOverB(); } if (SinglePlayerState.p1Score == 10) { Sound.playGameOverSound(); gameOverS1(); } if (SinglePlayerState.compScore == 10) { Sound.playGameOverSound();...
703e5457-3419-4de9-99f0-a7bb60994583
6
private void updateGraphics() { if (isInit) { setBorder(BorderFactory.createTitledBorder("init")); } else { setBorder(null); } switch (aspect) { case POINT: setBackground(Color.yellow); setIcon(new ImageIcon("dot.jpg")); break; case VIDE: setBackground(Color.white); setIcon(null); b...
5c804fed-0d77-4438-bab7-0a8a7f24d095
8
@Override public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException { String parm = (commands.size() > 1) ? CMParms.combine(commands,1) : ""; if((!mob.isAttributeSet(MOB.Attrib.AUTODRAW) && (parm.length()==0))||(parm.equalsIgnoreCase("ON"))) { mob.setAttribute(MOB.At...
d45aac0c-9933-446a-87ef-95268e68ebc9
5
@Override public BMPImage apply(BMPImage image) { BMPImage filteredImage = new BMPImage(image); int redGap = 256/redBits; int greenGap = 256/greenBits; int blueGap = 256/blueBits; BMPImage.BMPColor[][] bitmap = image.getBitMap(); BMPImage.BMPColor[][] filteredBitmap =...
3bc134eb-1ce9-4698-ab53-8e0657d31cdd
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Vertex other = (Vertex) obj; if (id == null) { if (other.id != null) return false; } else if (!...
d529fd35-94fd-472b-87d1-d7578ce9e116
3
private void moveCursorLeft(boolean shiftDown) { if (shiftDown) { int start = textField.getSelectionStart(); if (start > 0) { textField.setSelectionStart(start - 1); } } else { int pos = textField.getCaretPosition(); if (pos > 0) textField.setCaretPosition(pos - 1); } }
09d1e5c0-df2f-48c0-b359-84a9fbc92072
2
private void selectMove(int selected) { IMove[] moves = battle.getPlayer().getPokemon().get_moves(); System.out.println(selectedMove + " - " + moves.length); if(selected >= moves.length) selectedMove = 0; else if(selected < 0) selectedMove = moves.length - 1; else selectedMove = selected; System.ou...
ebe0758d-d6df-44fa-98e4-8ca4be3065ec
9
public void run() { short ret = MsgDumperCmnDef.MSG_DUMPER_SUCCESS; MsgDumperCmnDef.WriteDebugFormatSyslog(__FILE__(), __LINE__(), "Thread[%s]=> The worker thread is running", worker_thread_name); while (!exit.get()) { synchronized(this) { // wait for input data try { wait(); // Move th...
53e79d6b-3400-4796-b441-eafe6f70c181
0
@Test public void isEmptyReturnsFalseAfterSingleEnqueue() { q.enqueue(0); assertFalse(q.isEmpty()); }
5f19742c-6c4a-4836-beb0-452a7fa700d4
8
public int longestValidParentheses(String s) { if (s == null || s.length() == 0) { return 0; } List<int[]> spans = new LinkedList<>(); Deque<Integer> deque = new LinkedList<>(); int maxSpan = 0; for (int i = 0; i < s.length(); i++) { char c = s....
092f536c-4617-447a-b132-bdfe74ff6a99
6
private void copyRGBtoABGR(ByteBuffer buffer, byte[] curLine) { if (transPixel != null) { byte tr = transPixel[1]; byte tg = transPixel[3]; byte tb = transPixel[5]; for (int i = 1, n = curLine.length; i < n; i += 3) { byte r = curLine[i]; ...
3d95939d-dd19-44a8-bd86-44148a654126
8
public Unit getUnitAt(Position p) { if ( p.getRow() == 2 && p.getColumn() == 3 || p.getRow() == 3 && p.getColumn() == 2 || p.getRow() == 3 && p.getColumn() == 3 ) { return new StubUnit(GameConstants.ARCHER, Player.RED); } if ( p.getRow() == 4 && p.getColumn() == 4 ) { return new ...
51244953-9295-41d4-a767-1e3a930ec46c
6
public void dispose(boolean cache) { if (streamInput != null) { if (!cache) { try { streamInput.dispose(); } catch (IOException e) { logger.log(Level.FINE, "Error disposing stream.", e); } ...
2a6f199b-22f1-4296-9c2a-3d4183700a79
8
private void decodeLobbyLogin(InputStream buffer) { int clientRev = buffer.readInt(); int rsaBlockSize = buffer.readShort(); // RSA block size int rsaHeaderKey = buffer.readByte(); // RSA header key System.out.println(" " + rsaBlockSize + " " + rsaHeaderKey + " " + clientRev); int[] loginKeys = new int[...
ba428af5-5650-43f3-8d68-5274d045a043
2
public OutputStream getOutputStream () { if ("bulk" != getType () || isInput ()) throw new IllegalArgumentException (); spi = getDevice ().getSPI (); return new BulkOutputStream (spi, getEndpoint ()); }
744a70a6-43a8-4aad-b399-e540e357186c
8
@EventHandler public void onDamage(EntityDamageEvent event) { if (event.getEntity() instanceof Player) { if (MPlayer.getElement((Player) event.getEntity()).equals(Element.EARTH) && event.getCause().equals(DamageCause.FALL)) { event.setCancelled(true); } else if (MPlayer.getElement((Player) event.getEntity(...
8e472a28-bf59-41ae-a7d6-1912d5375fe5
9
@Override public boolean tick(Tickable ticking, int tickID) { if(tickID==Tickable.TICKID_MOB) { if(affected instanceof MOB) { final MOB mob=(MOB)affected; if(!mob.isInCombat()) if((mob.amFollowing()==null) ||(mob.location()==null) ||(mob.amDead()) ||((invoker!=null) &&((mob...
0ccb3ee9-2439-4d8e-87cc-fa3db31ff68c
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Tenant)) { return false; } Tenant other = (Tenant) object; if ((this.id == null && other.id != null) || (this.i...
683cb0fa-8569-4e77-8cc8-b00a9cbdc785
2
public static boolean isLich (Entity entity) { if (entity instanceof Skeleton) { Skeleton lich = (Skeleton) entity; LeatherArmorMeta chestMeta; ItemStack lichChest = new ItemStack(Material.LEATHER_CHESTPLATE, 1, (short) - 98789); chestMeta = (LeatherArmorMeta) lic...
19328dea-e663-4eb9-bae9-2c1dd56f640e
6
private IpInfo jsoupParser(String Html) { IpInfo ipLookup = new IpInfo(); int count = 0; Document doc = Jsoup.parse(Html); Elements e = doc.getElementsByTag("input"); for (int i = 0; i < e.size(); i++) { if (i == 1) { Element element = e.get(i); ...
c1d5407b-50e8-49df-8151-85310b448a66
1
public static Gender buildGender(String genderStr) { return genderStr.equals(MALE_DESC) ? MALE : FEMALE; }
874f62fe-71de-464c-8257-145c5aa27e22
1
@Override public void notifySubscription(String file, int number) throws RemoteException { System.out.println("Notification: "+file+" got downloaded "+number+" times!."); try { shell.writeLine("Notification: "+file+" got downloaded "+number+" times!."); } catch (IOException e) { // TODO Auto-generated catc...
8240dae1-dab8-4dc0-b53b-822c878dabe9
0
public void setRoadHaul(String roadHaul) { this.roadHaul = roadHaul; }
3d2a5efb-ec2d-423f-871e-2bc8c390a93d
8
private void writeJSON(Object value) throws JSONException { if (JSONObject.NULL.equals(value)) { write(zipNull, 3); } else if (Boolean.FALSE.equals(value)) { write(zipFalse, 3); } else if (Boolean.TRUE.equals(value)) { write(zipTrue, 3); } else { ...
df38571f-892d-4b59-b0f8-06a69c7cc0b9
9
private TokenString tokenizeCurrentLine() { TokenString tokenString = new TokenString(); boolean finishedLine = false; // Sorts through the list of TokenTypes, ordering them from longest to shortest. TokenType[] types = TokenType.values(); Arrays.sort(types, Comparator.comparing...
3566d7b9-5c63-4095-bc00-84fcd1a85e6b
8
public boolean nextToCell(int x, int y, IMapCell cell) { int xL = x - 1; int xR = x + 1; int yL = y - 1; int yR = y + 1; if (xL >= 0 && getCell(xL, y).equals(cell)) { return true; } if (xR < getX() && getCell(xR, y).equals(cell)) { return ...
4bb06ae8-91c4-4ea4-8e27-1b80960bd16a
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 fe...
f329884c-f6e0-4fc6-80c1-0470d507c394
1
public static String getString() throws BadInput{ //return System.console().readLine(); try { return br.readLine(); } catch(IOException e) { throw new BadInput("Couln't get input. IO problem?"); } }
8ed09c07-07e8-4977-8248-6bcd2ea01455
5
public boolean isMatch(String s, String p) { if (s == null || p == null) return false; if ("".equals(p)) { if ("".equals(s)) return true; return false; } this.s = s; this.p = p; f = new Boolean[s.length() + 1][]; for (int i = 0; i <= s.length(); i++) f[i] = new Boolean[p.length() + 1]; f...
f1d8ff33-df88-4fbb-92a0-221d2094269e
7
public static void makePlayerList() { final int MAX_PLAYERS = 3, MIN_PLAYERS = 1; int numPlayers; String playerName; System.out.print("How many people are playing (1-3)? "); do { try { numPlayers = scan.nextInt(); } catch(InputMismatchException e) { numPlayers = -1; } scan.nextLin...
5677d483-bb6d-496b-b304-c58a9afb14d8
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Transactions)) { return false; } Transactions other = (Transactions) object; if ((this.id == null && other.id !...
8cf3d204-5861-4dbc-afd0-877a54f562a2
3
public Level(String name) { double checkRatioEnemyType = 0; for(double e : ratioEnemyType) checkRatioEnemyType += e; if( checkRatioEnemyType != 1.0) { System.out.println("La somme des ratios des types d'ennemies du level " + name + " est différente de 1. (" + checkRatioEnemyType + ")"); System.exi...
dd373cbc-1f4b-4e65-a0e5-c005c5bee20d
1
public void toggleConnectionActions(boolean setVisible) { if (setVisible) { String name = InputHandler.getCurrentServerTab().getTabName(); disconnectFromServer.setText("Odpojit od " + name); } joinToChannel.setVisible(setVisible); disconnectFromAll.setVisible(set...
bfaa98dd-a07f-4055-86a4-4a49a1af49d2
7
public static String findMLIA() { String fmlmsg = ""; try { HttpURLConnection con = (HttpURLConnection) new URL("http://mylifeisaverage.com/" + getPage()).openConnection(); StringBuilder sb = new StringBuilder(); con.connect(); InputStream input = con.get...
38911e62-f372-48be-aef3-56f19bef4995
6
@Override public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { g.setAntiAlias(true); g.setColor(new Color(255, 255, 255)); if (!terrainMode) { g.setColor(new Color(209, 217, 224)); } g.fillRect(0, 0...
0a054cd4-bbf1-4e2b-a702-1e3020c307f9
9
public CellElement getPointerWithPolicy(int policy) { if (m_pointers.size() == 0) { return null; } CellElement retCell = null; switch (policy) { case POINTER_POLICY_ANY: retCell = (CellElement) m_pointers.firstElement(); break; ...
dfbcc4f8-4b93-4f39-addd-39d3bfb3bcb3
4
public void addToOutput(String message) { try { Element p = houtput.getParagraphElement(houtput.getLength()); houtput.insertAfterEnd(p, "<div align=left> "+message+" </div>"); } catch (NullPointerException e) { e.printStackTrace(); } catch (BadLocationException e) { e.printStackTrace(); } catch (IOE...
49f261a5-0fa6-47c3-b86d-24a2dc74e113
9
public static long f( int h, int w ){ if(h>=0 && w < mem[h].length && mem[h][w]!=-1) return mem[h][w]; if( w == 1 && h == 0 ) return mem[h][w]=1; if( h>=1 && w==0 ) return mem[h][w]=1; if( w < 0 || h < 0 ) return 0; else return mem[h][w]=f( h-1, w )+f( h+1, w-1 ); }
4c77c0ec-179f-421a-9fde-fa2665f54772
0
@AfterClass public static void tearDownClass() { }
c444081f-a572-4a2d-b876-99df5e5fc869
0
@Override public Object getWatchKey() { return watchKey; }
fac2d940-9d6d-415c-b0a4-f0eadc04aa02
3
public int[] getSucc(int i) throws ArrayIndexOutOfBoundsException{ if ((i<0) || (i>=nbVertices)) throw new ArrayIndexOutOfBoundsException(); int[] tab = new int[succ.get(i).size()]; for(int j=0;j<tab.length;j++){ tab[j] = succ.get(i).get(j); } return tab; }
09a2a196-d684-4b6b-9e93-c44e7a81737f
5
public final void filter(final Object o) throws JSONException { if (o instanceof Element) { Element element = (Element) o; String elemName = element.getName(); List children = element.getContent(); List attribute = element.getAttributes(); Iterator ita = attribute.iterator(); Iterator itc = children...
05531cb5-b34a-48b6-a8b6-5b59658e3cd6
4
@Override public final void set( GraphSite site ) { if( this.site != null ) { for( GraphItem item : children ) { this.site.removeItem( item ); } removeFrom( this.site ); } this.site = site; if( site != null ) { addTo( site ); for( GraphItem item : children ) { site.addItem( item ); } ...
4bd1fdad-13e5-41b1-b36d-87a5e2cc7ce0
1
private void simpleSetLocal(int index, Type type, Frame frame) { frame.setLocal(index, type); if (type.getSize() == 2) frame.setLocal(index + 1, Type.TOP); }
a7acf043-c563-4dda-9a29-d53d48335579
7
public void mouseClicked(int x, int y, MouseHelper helper) { if (helper == MouseHelper.LEFT_CLICK) { if ((x >= theComponent.getX()) && ((x <= (theComponent.getX() + buttonWidth)))) { if ((y >= theComponent.getY()) && (y <= (theComponent.getY() + buttonHeight))) { ...
f4ea5226-6fe1-484b-a6f5-cf8068340812
8
public boolean isUpgradeable(ItemStack is){ if(!(is.getType() == Material.WOOD_SWORD || is.getType() == Material.GOLD_SWORD || is.getType() == Material.IRON_SWORD || is.getType() == Material.DIAMOND_SWORD))return false; if(is.hasItemMeta()){ ItemMeta im = is.getItemMeta(); if(im.hasLore()){ for(String ...
741d35bd-2675-436c-92bc-d867a00e65e0
0
private static int getShortLittleEndian(byte[] a, int offs) { return (a[offs] & 0xff) | (a[offs + 1] & 0xff) << 8; }
befd4b5b-fb64-48d0-8652-7bd205ba802a
2
public void addCollectable(int tileX, int tileY, int tileType) { Tile collectable = null; if(tileType == TileTypes.DIAMOND) { collectable = new TileCollectableDiamond(tileX * Tile.TILE_SIZE, tileY * Tile.TILE_SIZE, true); } else if(tileType == TileTypes.GOLD) { collectable = new TileCollectableGol...
c4f7aded-5c94-4986-b131-04d2757e8eaa
2
private static PixImage array2PixImage(int[][] pixels) { int width = pixels.length; int height = pixels[0].length; PixImage image = new PixImage(width, height); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { image.setPixel(x, y, (short) pixels[x][y], (short) pixels[x][y], (sh...
950f0202-ebc0-43e0-a9a4-cebaceafe61f
5
@Override public void drawShape(Graphics graphics) { int xn, yn, xm, ym; int xa, ya, xb, yb, xc, yc, xd, yd; // xn and yn is the first point the user clicked // xm and ym is the second point the user clicked xn = super.getXi(); yn = super.getYi(); xm = super....
c1a304f7-0871-493b-b11d-ba5ac1e95cde
9
public boolean checkCanMove(Block[][] boardMatrix, int firstBlockX, int firstBlockY, int secBlockX, int secBlockY, int thirdBlockX, int thirdBlockY, int fourthBlockX, int fourthBlockY) { for (int i = 0; i < getBlocks().length; i++) { Block tempBlock = getBlocks()[i]; int x = tempBlock.getX(); int y = tem...
3c4745df-aeb3-4480-84c9-2692515d91ab
6
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } Subscription o = (Subscription) obj; return (edition == null ? o.edition == null : edition.equals...
5500c704-dae9-4956-8aeb-d5bee881f1de
6
private void listen( HttpServletRequest request, HttpServletResponse response ) { RequestDispatcher dispatcher = null; ChatClientHelper helper = null; int action = 0; try { if( request.getParameter( "action" ) == null ){ logger.info( "No action parameter, redirecting to default action" ); a...
0e275400-2f4c-44d9-a8d1-bfec49ddfb40
8
private void submitSQL(ArrayList<VulnLocation> params, String url, String method) { String sqlAttack = "' OR 1=1; --"; String response = ""; String normalResponse = ""; SubmitForm submitForm = new SubmitForm(url); SubmitForm submitNormalForm = new SubmitForm(url); try { for(VulnLocation vuln:para...
53c52be1-a429-480d-854c-714fec581999
1
protected void calculateMean() { double sum = 0.0; for (double a : data) { sum += a; } mean = sum / size; }
d83b9233-2669-4d07-b020-72c18ce2be0b
4
@Override public boolean isAllowedToBorrow(Loan loan, StockController stockController) { if (stockController.numberOfLoans(this) < 1) { if (loan.getQuantity() < 2) { if (CalendarController.differenceDate(loan.getStart(), loan.getEnd()) < 8) { ...
9300a3a8-8aeb-4548-b9d9-2990618437f7
6
public void addListener( Object listener ) { Class<?> listenerClass = listener.getClass(); for (Class<?> listenerInterface : listenerClass.getInterfaces()) { RemoteInterface ri = listenerInterface.getAnnotation( RemoteInterface.class ); if (ri != null) {...
b2a096e9-90d2-4e1d-892d-df24ae6b6221
6
public static int majorityElement(int[] arr) { if(arr.length == 0 || arr.length == 1) { System.out.println("Error: Input array's length is less than 2."); System.exit(0); } Integer count; Map<Integer, Integer> map = new HashMap<Integer, Integer>(); for(int i = 0; i < arr.length; i++) { if((count = ma...
a3b2f52c-9d85-4a25-bdb9-2434b70ef779
5
private void doCommand(String cmd) { if (cmd.startsWith("S")) { doSleep(Integer.parseInt(cmd.substring(1))); } else if (cmd.startsWith("X")) { doShutdown(); } else if (cmd.startsWith("R")){ doRecovery(); } else if (cmd.equals("help")) { doH...
748b27e0-04a1-410d-8337-6dbab7e71d93
5
public ArrayList<Activity> orderActivitiesByTime(ArrayList<Activity> activities, LinkedHashSet<Integer> activityIds) { ArrayList<Activity> reorderedActivities = new ArrayList<>(); // if (activityIds != null) { for (int i : activityIds) { for (Activity a : activities) { if (i == a.getIdActivity()) { ...
c252c523-1853-41d1-8ddc-87ee4cb3e581
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...
fdb106c5-319a-4185-ad85-32d22d3f37f3
1
private void compute_pcm_samples11(Obuffer buffer) { final float[] vp = actual_v; //int inc = v_inc; final float[] tmpOut = _tmpOut; int dvp =0; // fat chance of having this loop unroll for( int i=0; i<32; i++) { final float[] dp = d16[i]; float pcm_sample; pcm_sample = (float)(((vp[11 ...
55da44b5-f0e8-4e97-b84b-bd720da53a7c
1
public int reverse(int x) { // 无需处理符号位 int y = 0; while(x !=0){ y = y*10 + x % 10; x = x/10; } return y; }
c1d61d04-87b1-442b-b56d-0707ce5c2228
4
public void input() { if (Input.getKeyDown(Keyboard.KEY_UP)) { System.out.println("We've just pressed up!"); } if (Input.getKeyUp(Keyboard.KEY_UP)) { System.out.println("We've just released up!"); } if (Input.getMouseDown(1)) { System.out.println("We've just pressed RMB @" + Input.getMousePosition(...
a5f8298e-de8f-4229-b52b-31929197ebe3
2
public ArrayList<Double> FDWT(ArrayList<Double> _pic) { ArrayList<Double> _temp = new ArrayList<Double>(_pic.size()); //Initialize _temp _temp = (ArrayList<Double>) _pic.clone(); for (int j = _pic.size(); j >= 2; j = j / 2) { for (int i = 0; i < j / 2; i += 1) { ...
d7b0efbb-7dbd-4b1c-85ca-2ed676db5da8
5
public static void NewGame(GameType type, GameModes mode, InetAddress addr, int nPlayers, int nPlanets, int nRows, int nCols) { if(type == null || mode == null) { System.err.println("Must select a type and mode!"); return; } Instance.gameType = type; Instance.gameMode = mode; if(debug) System.out.print...
501940be-f8b4-4e6a-9e39-027ee1fa7e5f
6
@Override public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if (commandLabel.equalsIgnoreCase("censor")) { if (sender instanceof Player) { Player p = (Player) sender; if (p.hasPermission("cens...
b35695ae-3a50-4c7e-89b5-18dd1488c169
9
@Override public void draw(Graphics g) { if (state) { if (color == 1) g.drawImage(imgred, pos_x, pos_y, width, height, null); else if (color == 2) g.drawImage(imgblue, pos_x, pos_y, width, height, null); else if (color == 3) g.drawImage(imgwhite, pos_x, pos_y, width, height, null); else if ...
3b92152a-86a3-42bd-aea8-ae2d37e86ea5
8
@Override public boolean tick(Tickable ticking, int tickID) { if(!super.tick(ticking, tickID)) return false; if((affected!=null)&&(affected instanceof Room)) { final Room R=(Room)affected; if(isRaining(R)) for(int i=0;i<R.numInhabitants();i++) { final MOB M=R.fetchInhabitant(i); if(M!=nul...
8f3c55da-d8fc-45d4-8545-986a5ec03041
1
@Test public void TestRemoveStudent() throws InstanceNotFoundException { try { familyService.removeStudent(1); } catch (InstanceNotFoundException e) { e.printStackTrace(); } assertEquals(familyService.getStudents().size(), 3); }
cf9ef043-d304-412a-aba2-e711c1c0cff3
8
public void loadSchema(String catalogFile) { String line = ""; try { BufferedReader br = new BufferedReader(new FileReader(new File(catalogFile))); while ((line = br.readLine()) != null) { //assume line is of the format name (field type, field type, ...) ...
1a6a9c4b-13ef-4955-a236-9955ec5c6e03
3
public int hashCode() { int hc = 13 * sort; if (sort == OBJECT || sort == ARRAY) { for (int i = off, end = i + len; i < end; i++) { hc = 17 * (hc + buf[i]); } } return hc; }
5ae6d502-2dce-483d-a240-b25cc37626a0
8
static int checkStyleBit(Shell parent, int style) { int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL; if ((style & SWT.SHEET) != 0) { style &= ~SWT.SHEET; if ((style & mask) == 0) { style |= parent == null ? SWT.APPLICATION_MODAL : SWT.PRIMARY_MODAL; } } if ((style & ma...
c0283c52-5d01-4180-8d44-847e360c3264
2
private void createTablesIfNotExist(Connection cnn) { if (tableExists("cb_users", cnn)) { logger.info("table cb_users already exists"); } else { logger.info("create table cb_users"); String sql = "CREATE TABLE `cb_users` ( \n" + ...
3f30f0e8-9a39-4380-985d-de09b323ef67
5
public CycList allIndicesOf(Object elem) { CycList result = new CycList(); if (elem == null) { for (int i = 0; i < size(); i++) { if (get(i) == null) { result.add(i); } } } else { for (int i = 0; i < size(); i++) { if (elem.equals(get(i))) { resu...
60d2ccff-ba40-4d4c-b8f3-46169ededaf9
8
private void go() throws IOException { // Create a new selector Selector selector = Selector.open(); // Open a listener on each port, and register each one // with the selector for (int i=0; i<ports.length; ++i) { ServerSocketChannel ssc = ServerSocketChannel.open();...
44143879-d27b-4a44-a186-64b2d43fc923
7
public ArrayList<FeatureResult> extractFeaturesFrom(MouseLogParser parser) { ArrayList<FeatureResult> fr=new ArrayList<FeatureResult>(); fr.addAll(parser.getUserProfile().extract()); try { // want to dynamically 'load' feature set //so we can add features without having to modify this code. //All feature...
e6e0955b-1593-44fc-8764-e124d1f4790a
0
public int getImgWidth() { return imgWidth; }
f1a9a02a-2288-47ba-8e1e-4694df15832d
1
private static void registerGeneral(String field, Class<? extends FrameNode> type, Property prop) { generalFields.add(new GeneralNameValueConfig(field,type,prop)); }
3183897a-57a2-4d36-a7f4-71f5cfeb9d12
9
private static Set<Trace> checkArgs(String[] args) { boolean error = false; if (args.length != 2) { error = true; } else { if (args[0].equals("d")) { switch (args[1]) { case "L1": return Utils.demoL1eventLog(); ...
76274130-b699-4045-82de-0d56ba2e09f1
4
public static void main(String[] args) throws FileNotFoundException, InvalidCantidadDeTokensDeLookaheadException, BufferDeTokensVacioException, IOException, ElementoFueraDeIndiceEnBufferException { // Menú de prueba para probar el Lexer, Parser y Traducción. int i = 1; Buffered...
d5c0963c-775c-498a-af49-19203ca0a77f
8
@Override public void Throttle(double value) { double forward = 2.1; double center = 1.50; double reverse = 1.00; double ms; value = (value > 1) ? 1 : value; value = (value < -1) ? -1 : value; switch (direction){ case Posi...
1f86d6a5-f4f2-485b-b150-58f80c202f7a
1
public void testConstructor_ObjectStringEx3() throws Throwable { try { new YearMonth("10:20:30.040"); fail(); } catch (IllegalArgumentException ex) { // expected } }
69bfa3c9-acdb-4ba4-89e7-513da57ef330
0
public Node<K> getLeft() { return left; }
659f0e18-9594-4997-9ce3-72dd497c016a
3
public boolean isInUserAgentString(String agentString) { for (String alias : aliases) { if (agentString != null && agentString.toLowerCase().indexOf(alias.toLowerCase()) != -1) return true; } return false; }
17392726-2272-4f24-9405-dfbdbf38f6ef
8
public Image getCurrentImage() { DefaultFont font = DefaultFont.getDefaultFont(); Image[] charecters = font.getStringImage(currentInput); Image currentImage = (isSelected) ? selectedImage : unSelectedImage; int[] pixels = currentImage.getPixels(); int IWidth = currentImage.getWidth(); int IHeight = current...
3cebdeca-09e5-4859-b1e8-de458593d1ef
7
public static OOXMLElement parseOOXML( XmlPullParser xpp, Stack<String> lastTag, WorkBookHandle bk ) { BodyPr b = null; P para = null; try { // need: endParaRPr? int eventType = xpp.getEventType(); while( eventType != XmlPullParser.END_DOCUMENT ) { if( eventType == XmlPullParser.START_TAG )...
14a9d18a-6a6e-4d12-ba59-872f7f3cea31
2
private void doParse(String contents) { try { InputSource xmlParserSource = new InputSource(new StringReader(contents)); reader.parse(xmlParserSource); } catch (IOException ioe) { System.out.println("IOException when running parser."); ioe.printStackTrace(); System.out.println("IOException when runni...