method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
2145e377-2996-4fb2-acd6-c7e8ba9e5f7d
4
public void add(String word) { if (word == null || word.isEmpty()) return; Node localRoot = root; for (int i = 0; i < word.length(); i ++) { Character c = word.charAt(i); if (localRoot.children.containsKey(c)) { localRoot = localRoot.children.g...
0efc2ad1-b6e6-4927-bfb2-72ba48c9be93
3
public static void main(String[] args) { Random random = new Random(); for(int i=1;i<=100;i++){ if(i%10 == 0){ try { Thread.sleep(random.nextInt(5)*1000); System.out.println(); } catch (InterruptedException e) { e.printStackTrace(); } } System.out.print(i + "\t"); } }
d553a6fe-ab5d-435f-8660-dd2ef2bb7c8d
6
EditDialog(Editable ce, CircuitSimulator f) { super((Frame)null, "Edit Component", false); cframe = f; elm = ce; setLayout(new EditDialogLayout()); einfos = new EditInfo[10]; noCommaFormat = DecimalFormat.getInstance(); noCommaFormat.setMaximumFractionDigits(10); ...
c8e49bee-4db0-47d2-8ee1-127a8438c483
2
void makeEquiv(final Node node1, final Node node2) { final Set s1 = equivalent(node1); final Set s2 = equivalent(node2); if (s1 != s2) { s1.addAll(s2); final Iterator iter = s2.iterator(); while (iter.hasNext()) { final Node n = (Node) iter.next(); equiv.put(n, s1); } } }
69cc5c48-1e18-44db-816a-69688fd12153
4
public Dispatcher () throws InterruptedException { workers = new ArrayList<Worker>(); for (int x=0;x<10;x++){ JobImpl1 j = new JobImpl1(); j.id="Job-"+x; qManager.push("Queue1",j); } for (int x=0;x<10;x++){ Worker w1 = new Worker1(qManager,x); workers.add(w1); w1.start(); }...
683d735d-d252-4047-b86f-5b0cf707e677
9
public final GalaxyXDefinitionParser.expression_return expression() throws RecognitionException { GalaxyXDefinitionParser.expression_return retval = new GalaxyXDefinitionParser.expression_return(); retval.start = input.LT(1); int expression_StartIndex = input.index(); CommonTree root_0 =...
18da18c5-e01c-4a35-9d3c-4642f5df186c
6
public Cabin getCabin(int cabin_id) { Cabin cabin = new Cabin(); ResultSet rs = null; try{ statement = connection.createStatement(); String sql = "select * from cabins where cabin_id = " + cabin_id + ";"; rs = statement.executeQuery(sql); while(rs.next()){ cabin.setName(rs.getString("cabin_name")...
e42c90be-0bc4-4586-9186-34f0ea6ec5c6
3
@Override public EventCommentType getTypeByName(final String name) throws WrongTypeNameException { if (name == null) { throw new WrongTypeNameException("Type name is empty"); } switch (name) { case BEFORE_COMMENT_TYPE_NAME: case AFTER_COMMENT_TYPE_NAME: ...
dab48841-8972-468d-a179-37ddeb491a7b
9
public boolean verificarMovimientoValido(Operador operador){ char direccion=operador.getDireccion(); int[] coordenada=matriz.retornarCoordenadaDe(matriz.getSortingRobot().getId()); if(coordenada!=null){ //Izquierda if(direccion=='l'){ ...
dd7a0f69-b5ab-4e5d-a618-61eaf23f12c8
6
public static String tempban(String muter, String mutedPlayerName, double days){ // Initial message String regex = RPSystem.chatConfig.getString("format.ban"); int realDays = 0; // Token replacement regex = regex.replaceAll("%t", Timestamp.NOW()); regex = regex.replaceAll("%banner", muter); if(days >= ...
b7d83d06-867b-4bfc-8613-029d696d2210
7
public Object nextValue() throws JSONException { char c = this.nextClean(); String string; switch (c) { case '"': case '\'': return this.nextString(c); case '{': this.back(); return new JSONObject(this); ...
c9109c70-4b26-4264-a722-f687c85b8d2e
5
public static Colour lightValue(World world) { final float dayValue = dayValue(world) ; if (dayValue == 1) return DAY_LIGHT ; if (dayValue == 0) return NIGHT_LIGHT ; final Colour a, b ; final float w ; if (dayValue > 0.5f) { a = DAY_LIGHT ; b = isMorning(world) ? MORNING_LIGHT :...
9b5f09b3-7d4a-479d-8b7a-89d039932c89
4
public synchronized int addPlayer(Player player) { if (game != null && playerCount < players.length) { player.setSeatNumber(game.addPlayer(player)); players[playerCount++] = player; addGameListener((GameListener) player.getUser().getGameSocket()); if (playerCount == 1) { for (GameLawEnforcer game : ga...
d9d36e93-da0c-4259-a438-72981a65339b
5
public String buscarDocumentoPorTipoNumero(String tipo, String numero) { ArrayList<Venta> geResult= new ArrayList<Venta>(); ArrayList<Venta> dbVentas = tablaVentas(); String result=""; try{ for (int i = 0; i < dbVentas.size() ; i++){ if (dbVentas.get(i).getTi...
fdaefd3f-3a18-43aa-bb4a-5c832c55bb4c
7
public void move(Box toBox) { if (!(this instanceof gameLogic.Movable)) { return; } if (!getBox().isAdjacentTo(toBox)) { return; } Box oldBox = getBox(); try { getBox().getChart().place(this, toBox); } catch (BoxBusyException e) { return; // TODO: handle exception } // Strea...
c6ee22bf-e332-4cd3-ac44-95ee9239bc28
8
public void createUnits(int gridXlength, int gridZlength, Grid grid, float gridHeight){ if (side){ lines = 0; // the variable lines is added to check if it's player 1 or player 2 position, if it's player 2 it starts on the other edge of the grid } else { lines = gridXlength; lineStart = lines; // lineS...
b0ef8da2-1971-4d35-a9f0-21be9dc71734
1
private void adjustVolume(boolean volumeOn, int volume) { Signlink.midivol = volume; if (volumeOn) { Signlink.midi = "voladjust"; } }
9f03f3c5-9e68-4392-8b62-ed5b2ebe940e
2
public ActivityManagementWindow(MainWindow mainWindow, Student stu) { setTitle("Modificar actividades de un alumno"); setResizable(false); this.mainWindow = mainWindow; this.student = stu; setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(100, 100, 457, 326); contentPane = new JPanel(); con...
9fdbe192-520c-4d04-97ea-0ba88a5c5ca2
8
@Override public void mousePressed(MouseEvent e) { try{ double childX =0; double childY =0; double parentX=0; double parentY=0; double childW=0; double childH=0; double parentW=0; double parentH=0; Object child = graphComponent.getGraph().getSelectionCell(); Object ...
acb14fd7-19db-4bee-b05b-a74daf571979
5
public String addParameter(int position, String parameter){ String lastParameter = IVPValue.NULL; if(arguments.size() >= position && position != 0){ lastParameter = (String) arguments.get(position); } if(arguments.size() <= position && position != 0){ arguments.add(position, parameter);...
4b492cb0-6530-4c10-ae75-4c4a5a965a52
9
public Wave35CinnabarGym(){ super(); MobBuilder m = super.mobBuilder; for(int i = 0; i < 1700; i++){ if(i < 2000){ if(i % 17 == 0) add(m.buildMob(MobID.RAPIDASH)); else if(i % 11 == 0) add(m.buildMob(MobID.NINETALES)); else if(1 % 3 == 0) add(m.buildMob(MobID.VULPIX)); else if(i ...
74029194-b455-42ee-bd80-a0372722c942
2
public static void main(String args[]){ ArrayList<String> lines=new ArrayList(); lines.add("First line"); lines.add("Second line"); lines.add("Third line"); Iterator iter=(Iterator) lines.iterator(); while(iter.hasNext()){ System.out.println(iter.next()); } Collections.reverse(lines); i...
bc18229b-b6b8-41de-85de-a8c4e0aee0dc
5
private void doShowContextMenu(MouseEvent event) { // grab the item or category under the mouse events point if there is // there is an item or category under this point. Object itemOrCategory = getItemOrCategoryUnderPoint(event.getPoint()); // if there was no item under the click, then...
1945d122-10f7-4eb9-bd04-8d812be895f6
7
private static int printSourceNumber(String source, int offset, StringBuffer sb) { double number = 0.0; char type = source.charAt(offset); ++offset; if (type == 'S') { if (sb != null) { int ival = source.charAt(offs...
9e4f7ebc-f681-41b8-aabb-4eef208c12dd
8
public void CaptureBlackPiece(int r1, int c1, int r2, int c2) { // Check Valid Capture assert(Math.abs(r2-r1)==2 && Math.abs(c2-c1)==2); // Obtain the capture direction MoveDir dir = r2>r1?(c2>c1?MoveDir.forwardRight:MoveDir.forwardLeft) :(c2>c1?MoveDir.ba...
d5d1b7dc-4c43-4a66-9ee4-82e72b1e1924
5
public void genEnergyType(){ rand = new Random(); energyRoll = (rand.nextInt(5)+1); if(energyRoll == 1){ energyType = "Acid"; } else if(energyRoll == 2){ energyType = "Cold"; } else if(energyRoll == 3){ energyType = "Fire"; } else if(energyRoll == 4){ energyType = "Electricity"; } else if(e...
dbffb4cb-13da-4c39-8f67-51e7c571ad30
1
public static Singleton getInstancia() { if (singleton==null) { singleton= new Singleton(); } return singleton; }
b1cd84fc-85b1-42c7-be4d-6b4d01108952
0
public void update() { }
e72a099a-5164-44ca-b1e9-98d63e050e51
9
@Override public int compare(Invocation c1, Invocation c2) { MethodCall o1 = c1.getMethodCall(); MethodCall o2 = c2.getMethodCall(); // First compare on names { int value = comp(nameMatches(o1), nameMatches(o2)); if (value != 0) { return value; } } // Compare on method signature { int va...
5ac7e287-1248-4f72-bc21-06a5e902b80f
3
private static Long seatClassToLong(Ticket.seatClass sc) { if (sc == Ticket.seatClass.SEAT_CLASS_ECONOMIC) return 1L; else if (sc == Ticket.seatClass.SEAT_CLASS_BUSINESS) return 2L; else if (sc == Ticket.seatClass.SEAT_CLASS_FIRST) return 3L; else return 1L; }
052ca869-0607-4454-a171-b1b8badfe6ca
8
public static void pprintQuantifiedVariables(Vector variables, boolean includetypesP, org.powerloom.PrintableStringWriter stream) { if (variables == null) { return; } stream.print("("); Native.setIntSpecial(OntosaurusUtil.$PPRINT_INDENT$, ((Integer)(OntosaurusUtil.$PPRINT_INDENT$.get())).intValue(...
07f4ebf5-c98b-424c-a150-ac77614297ab
7
public boolean surLeSol(Body body) { if (world == null) { return false; } // collision avec le perso est apparu? CollisionEvent[] evenementCollision = world.getContacts(body); for (int i = 0; i < evenementCollision.length; i++) { // si le point de la collision est proche des pieds if (evenementColl...
fb336b71-1d9b-4d1c-9cc0-18065c4639c8
1
public JSONArray getJSONArray(String key) throws JSONException { Object o = get(key); if (o instanceof JSONArray) { return (JSONArray)o; } throw new JSONException("JSONObject[" + quote(key) + "] is not a JSONArray."); }
9f5405c7-d0ed-44bc-8793-febded83836a
4
public boolean metaValid() { return !(this.title.isEmpty() || this.artist.isEmpty() || this.creator.isEmpty() || this.version.isEmpty() || this.source.isEmpty()); }
df7f47fb-1058-4229-9c8f-8b39e64b2d51
5
@Override public void run() { //System.out.println("Log thread started"); while (!terminated || (strings.size() != 0)) { if (strings.size() != 0) { try { out.write(strings.get(0)); out.newLine(); } catch (IOException...
07ae7d9b-83ab-4804-8acc-a24d1746ba8a
7
public void changeHairAllFemales() { createHairListsOutOfWhiteLists(); int counter = 0; int max = SkyProcStarter.merger.getNPCs().getRecords().size(); for (NPC_ n : SkyProcStarter.merger.getNPCs()) { counter++; SPProgressBarPlug.setStatusNumbered(counter, max, "de...
557178f4-8370-43b3-9499-2b22d2e50037
6
@EventHandler public void onInventoryClick(InventoryClickEvent e){ Player p = (Player) e.getWhoClicked(); // Player who clicked ItemStack clicked = e.getCurrentItem(); // Item clicked Inventory inventory = e.getInventory(); // Inventory clicked // Cosmetics Menu if (inventory.getName().equals(CosmeticM...
7af9aa4a-058a-4e59-87c8-f9fa48192eeb
8
@Override public void run() { int compteur = 0; FileReader fr; try { fr = new FileReader(new File(Common.DIRRSC + corpus)); BufferedReader br = new BufferedReader(fr); String line = br.readLine(); while (line != null) { try { HashMap<String, Short> tf_doc; String[] doc = line.split("\...
51a120d1-2f8a-400c-8c4a-e53ec9f392ba
1
public Object get(Object key) { processQueue(); SoftReference ref = (SoftReference)hash.get(key); if (ref != null) return ref.get(); return null; }
f1dbb190-b755-44f4-9197-31c36f4fb7ca
2
private void initExistingBonus() { List<BonusQuestion> list = Bonus.getAllQuestions(); GameData g = GameData.getCurrentGame(); setWeekSpinner(Bonus.getMaxWeek(), g.getCurrentWeek()); if (list == null || list.size() == 0) { return; // nothing to load } setQuestionSpinner(1, Bonus.getNumQuestionsI...
ed15388c-edf4-4431-b8dd-86dde68c2d8f
5
private void run() { long time = 0, lastTime = 0, currentFPSSample = 0, lastFPSTime = 0; isRunning = true; while(isRunning) { if(Window.isCloseRequested()) isRunning = false; // Input Stuff game.input(); if(Input.isKeyPressed(Input.KEY_F1)) screenshot(); Input...
0db481b3-8ce1-4a22-97f7-064d5bff7a92
9
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (localName.equalsIgnoreCase("node")) { inNode = true; CoastlineNode node = getNodeInformation(attributes); if (node != null) { // ...
17a0940b-8574-454d-a945-7de12c8567f1
8
public void renderProjectile(int xp, int yp, Projectile p) { xp -= xOffset; yp -= yOffset; for(int y = 0; y < p.getSpriteSize(); y++) { int ya = y + yp; for(int x = 0; x < p.getSpriteSize(); x++) { int xa = x + xp; if(xa < -p.getSpriteSize() || xa >= width || ya < 0 || ya >= height) { break; ...
1b18f37e-f0d7-4547-9463-be4f5d85481d
7
public boolean isValidPosition(Point p){ if (p.x < 0 || p.x >= width || p.y < 0 || p.y >= height) return false; if (map.get(p.y).get(p.x) == BLOCK || map.get(p.y).get(p.x) == START || map.get(p.y).get(p.x) == EXIT) return false; return true; }
ec933a47-7c29-4016-8812-40c7de95a3ea
3
private Raum waehleNeuenRaum(ServerKontext kontext, Raum raum) { // Normaler Weise zwei Felder weiter, es sei denn, im ersten Feld ist // der Spieler Raum neuerRaum1 = selectRaumOhneKatze(raum.getAusgaenge()); // Kann sich die Katze nicht bewegen? if(neuerRaum1 == null) return raum; // Katze auf Spiel...
04ac4131-382f-44af-bdea-5b5e7c6433d8
7
public void start() throws IOException { myServerSocket = new ServerSocket(); myServerSocket.bind((hostname != null) ? new InetSocketAddress(hostname, myPort) : new InetSocketAddress(myPort)); myThread = new Thread(new Runnable() { @Override public void run() { ...
90fdfff6-e99c-4eb2-a823-df88c271c2c7
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 ObjectFields)) { return false; } ObjectFields other = (ObjectFields) object; if ((this.id == null && other.id !...
3c63f540-3623-4a18-9d5d-7b678b5569e6
3
public void updateSharkHealth(){ if(sharkCanTakeDamage) { for (int i = 0; i < sharks.size(); i++) { sharks.get(i).updateHealth(); if (sharks.get(i).getDead() == true) { killshark = true; updateScore('a'); bui...
567b8c8c-de5b-4c3e-b6de-41c60b72544a
8
public int run() { String indexValue = "0"; // Get the index value. if (register.equalsIgnoreCase("1")) indexValue = ASCView.getIndex1(); else if (register.equalsIgnoreCase("2")) indexValue = ASCView.getIndex2(); else if (register.equalsIgnore...
7d428b1c-a1f6-4096-9c4a-d3748690eb28
9
public String nextToken() throws JSONException { char c; char q; StringBuilder sb = new StringBuilder(); do { c = next(); } while (Character.isWhitespace(c)); if (c == '"' || c == '\'') { q = c; for (;;) { c = next(); ...
5ecbe3ff-276b-4036-a91c-383cb3ad7dcb
7
public double calculate(Accession a1, Accession a2) { double value = getMemoizedValue(a1.getId(), a2.getId()); if (value != MISSING_VAL) { return value; } ListIterator<List<Double>> m1Itr = a1.getSSRValues().listIterator(); ListIterator<List<Double>> m2Itr = a2.getSSRValues().listIterator(); double marker...
0f7ebe3a-290f-4429-b6c3-8d5f189bb22c
9
void setStateFromLocalConnState(int localCallState) { switch (localCallState) { case 1: setConnectionState(84, null); setTermConnState(98, null); break; case 2: setConnectionState(83, null); setTermConnState(97, null); break; case 3: setConnectionState(88, null); setTermConnState(98, nul...
f497994e-2ad6-489c-a9ff-48298ac65cb6
3
public AbstractInsnNode[][] findGroups(String regex) { try { Matcher regexMatcher = Pattern.compile(processRegex(regex), Pattern.MULTILINE).matcher(representation); if (regexMatcher.find()) { AbstractInsnNode[][] result = new AbstractInsnNode[regexMatcher .groupCount() + 1][0]; for (int i = 0...
48d40101-20ed-4524-b094-7a469035a7f5
2
public int findMaximum(ArrayList <Employee> employee, int i) { int j, max = i; for(j = i + 1; j < employee.size(); j++) { if (employee.get(j).getGrossPay() > employee.get(max).getGrossPay()) max = j; } return max; }
73846e95-a42f-4a6f-b517-bed307243b18
6
public boolean method577(int i) { if (anIntArray776 == null) { if (anIntArray773 == null) return true; if (i != 10) return true; boolean flag1 = true; for (int k = 0; k < anIntArray773.length; k++) flag1 &= Model.method463(anIntArray773[k] & 0xffff); return flag1; } for (int j = 0; j <...
b05cbca0-eeb2-4ee5-abb5-3ecef4bc862e
7
public static List<Tile> loadMap(String filename) { ArrayList<String> lines = new ArrayList<String>(); int width = 0; InputStream is = MapLoader.class.getClassLoader().getResourceAsStream( filename); System.out.println(is.toString()); BufferedReader reader = new BufferedReader(new InputStreamReader(is));...
7b847cae-bcb7-4cb8-a5a9-4aa305860982
8
private void createRivers() { for (int i = 0; i < bounds.width / 2; i++) { Corner c = corners.get(r.nextInt(corners.size())); if (c.ocean || c.elevation < 0.3 || c.elevation > 0.9) { continue; } // Bias rivers to go west: if (q.downslope.x > q.x) c...
02defccc-d25a-4b57-9501-fbd1a447b7f0
8
public static void cleanAll() { for (Shit s: shitList) { s.remove(); } for (Vomit v: vomitList) { v.remove(); } for (ObjEX oex: Food.objEXList) { if (((Food)oex).isEmpty()) oex.remove(); } for (Body b: bodyList) { if (b.isDead()) b.remove(); } for (ObjEX oex: Stalk.objEXList) { ...
58ee31be-2ce5-41ac-9d5e-6ea1ef1f93fe
6
public int PosToInt(int x, int y, int z) { if (x < 0) { return -1; } if (x >= width) { return -1; } if (y < 0) { return -1; } if (y >= height) { return -1; } if (z < 0) { return -1; } if (z >= depth) { return -1; } return x + z * width + y * width * depth; }
c5901b52-44ad-4368-b958-0be9281509e2
8
private boolean execLoadFeatures(VectorMap queryParam, StringBuffer respBody, DBAccess dbAccess) throws Exception { boolean success = true; int clntIdx = queryParam.qpIndexOfKeyNoCase("clnt"); String clientName = (String) queryParam.getVal(clntIdx); //System.out.println( "clnt = " + clie...
c30e36b7-7329-4bcf-9870-353e30cb3b72
6
public static void write(String outFilePath, int start, int end, String inFilePath) throws Exception { HashSet<String> set = new HashSet<String>(); BufferedReader reader = new BufferedReader(new FileReader(new File(inFilePath))); BufferedWriter writer = new BufferedWriter(new FileWriter(new File( outFilePa...
cc24168a-0ebe-41a4-8651-eccf20fee853
8
public DwgObject getDwgSuperEntity(DwgObject entity) { if(entity.hasSubEntityHandle()){ int handleCode = entity.subEntityHandle.getCode(); int offset = entity.subEntityHandle.getOffset(); int handle = -1; DwgObject object; switch(handleCode){ // TODO: case 0x2: // TODO: case 0x3: case 0x4: ...
2315a6fd-910c-4810-a906-577431576ae1
0
public void setExecute(boolean execute) { this.execute = execute; }
298617a5-acce-4829-982d-f766922eabb2
7
private static void connectOption() throws UnspecifiedErrorException, IOException, InvalidHeaderException { final Pattern pattern = Pattern.compile("(.+):(\\d+)"); System.out.println(String.format("\n%s > %s >\n" , SHELL_TITLE, Options.CONNECT.getTitle())); boolean validInput; Matcher input = null;; ...
1f40ab8c-8304-400a-9e23-7a45e7264c9f
2
public DataProcessor(int option) { // polymorphism switch (option) { case 0: // initialize as a string processor cp = new StringCompressor(); ep = new StringEncryptor(); break; case 1: // initialze as a file processor cp = new FileCompressor(); ep = new FileEncryptor(); break; } }
62679d51-404e-4cce-935a-821fb81c323c
1
@Override public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { return orientation == SwingConstants.VERTICAL ? visibleRect.height : visibleRect.width; }
ed4c5719-61e5-488f-8e42-e713ec15ffc1
2
public PathManager() { if (System.getProperty("os.name").equals("Linux")) { standardPath = "/" + standardPath.substring(0, standardPath.length() - 1); } else if (System.getProperty("os.name").toLowerCase().equals("mac")) { standardPath = "/" + standardPath.substring(0, standardPath.length() - 1); } }
e95ab0f2-5702-417d-ad83-9087f8dc3548
2
public void testFactory_parseMinutes_String() { assertEquals(0, Minutes.parseMinutes((String) null).getMinutes()); assertEquals(0, Minutes.parseMinutes("PT0M").getMinutes()); assertEquals(1, Minutes.parseMinutes("PT1M").getMinutes()); assertEquals(-3, Minutes.parseMinutes("PT-3M").getMin...
b9ca4692-91a2-41b9-abd4-0343bdac1266
4
public void setzeMaeuse(int anzahlMaeuse) { ArrayList<Raum> kannMausEnthaltenRaum = new ArrayList<Raum>(); for(Raum raum : _connections.keySet()) { if(raum.getRaumart() != RaumArt.Ende && raum.getRaumart() != RaumArt.Start) kannMausEnthaltenRaum.add(raum); } if(kannMausEnthaltenRaum.size() > 0)...
cc0668c4-c340-4571-bee0-a70ae8974069
2
final protected boolean dropChild(PropertyTree childMatch) { boolean found=false; for(Iterator<PropertyTree> c=children.iterator();c.hasNext();) { if(c.next() == childMatch) { c.remove(); } } return found; }
7ac1d098-e643-415e-94c2-def74e6d9be2
4
public static void readFile(){ File file=new File("monsters.dat"); FileInputStream fin; ObjectInputStream in; try { fin = new FileInputStream(file); in=new ObjectInputStream(fin); int numMonsters=in.readInt(); current_id=numMonsters+2; for(int i=0; i<numMonsters; i++){ Monster m=(Monster...
a2e5ea55-d17b-493e-80f7-bd3c346e8ad8
2
public void damageTile(int hitpoints, AIConnection dealingPlayer){ Debug.highlight(coords.getCompactString(), 255, 0, 0); if(playerOnTile == null){ return; } else { if(tileType == TileType.SPAWN){ Debug.info("Hit spawn tile, no damage received."); } else { playerOnTile.damagePlayer(hitp...
e2238e00-50ae-46af-aa55-40118ec7ceb8
5
public static boolean azionePossibile(ICard card, List<ICard> tableCards, List<ICard> presa) { //Butto una carta e non faccio prese if(presa.size() == 0) { boolean esistePresa = existPresa(card, tableCards); if(esistePresa){ log("Non puoi usare la carta " + card.getCardStr() + ", una presa e' possibile...
27ed1016-bb68-4523-b332-81cd621f111d
7
public static String getPhotoList(String date, String keyword) { DB db = _mongo.getDB(DATABASE_NAME); DBCollection coll = db.getCollection(COLLECTION_PHOTOSEARCH); BasicDBObject query = new BasicDBObject(); if (date != null && !date.equals("")) { query.put("startDate", "" + getYear(dat...
c63fd326-4004-4e5a-8d2b-3f300b3f34f2
4
private void DFS(List<Integer>[] adjacentVertices, Integer vertex, List<Integer> currentComponent) { explored[vertex] = true; if(currentComponent != null) currentComponent.add(vertex); List<Integer> adjacentVertexList = adjacentVertices[vertex]; if(adjac...
892509b7-4025-49ad-924b-ceda0ae31b3b
9
private void writeName(String uri, String localName, String qualifiedName) throws SAXException { try { if (uri == null || uri.length() == 0) { if (qualifiedName == null || qualifiedName.length() == 0) { output.write(localName.getBytes("UTF-8")); } ...
4bd2a4e2-b143-41bd-b0be-f0c84ad75039
6
public static void main(String[] args) { BufferedImage bi = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB); Graphics g = bi.getGraphics(); g.setColor(new Color(0, 0, 0)); g.fillRect(0, 0, 128, 128); try { ImageIO.write(bi, "PNG", new FileOutputStream(new File("terrain.png")))...
2a37aca4-189d-4358-9f2c-3e309b1d4b10
6
public static void DividiFileR() { RegistraTempo rt = new RegistraTempo(); rt.Start(); try { Scanner scanner = new Scanner(System.in); System.out.println("Divisione file puliti da R"); System.out.println("Sicuro?"); String sel ...
e6b48956-3d77-4a68-9d36-93ceef87e37a
5
public CheckResultMessage checkJ03(int day) { int r1 = get(17, 2); int c1 = get(18, 2); int r2 = get(20, 2); int c2 = get(21, 2); BigDecimal b = new BigDecimal(0); if (checkVersion(file).equals("2003")) { try { in = new FileInputStream(file); hWorkbook = new HSSFWorkbook(in); b = getValue(r2 ...
684c27af-eaef-4a63-bb0b-9f4c5e3aac60
8
private void writeObject(String name, Object obj, StringBuffer sb, String prepend) { if( name != null) { sb.append(prepend+_json_quote+name+_json_quote+":"); } if(obj instanceof JSONObject) { JSONObject o = (JSONObject)obj; o.pre_serialize(); if( name == null) { sb.append(prepend); } sb.appe...
6d4f9e3d-d51b-491f-a65e-dde87094a37d
4
public String getReadableName() { if ((firstname==null)||(firstname.isEmpty()) || (lastname==null)||(lastname.isEmpty())) { return username; } return MessageFormat.format("{0} {1}", firstname, lastname); }
925da642-e9db-4a9d-af27-15a58a111681
6
@Override public void innerRun() { while (true) { printShell(); String queryString = readQuery(); if (queryString == null || queryString.equals("")) { continue; } else if (queryString.equals(QUIT_COMMAND)) { return; ...
95708d5b-b19b-45a0-8c51-903363ffad08
1
@Override public String toString() { String ret = String.format("%s - %s", id, name); if (error != null) ret += "error: " + error; return ret; }
70f43f15-cd3e-4d47-aa24-83cea54db99b
4
private FormData readFormData_wwwFormURLEncoded( String contentType, HeaderParams headerParams ) throws IOException, HeaderFormatException, DataFormatException, UnsupportedFormatException { // Retrieve the Content-Length header from the request to determine the number of bytes ex...
8dd146c7-6dcc-4255-879f-a2e1f718a600
1
@Test public void dequeueTest() { for (int i = 1; i < 8; i++) { System.out.println(""); printTime(testArrayDequeDequeue(100000 * (int) Math.pow(2, i))); printTime(testQueueDequeue(100000 * (int) Math.pow(2, i))); } }
90e1ea70-bcd8-4190-b5f7-73d2873e585e
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 { ...
2cea35a8-edc1-4f93-98f0-3b39eb73e177
8
public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); // 生成公用的随机向量文件 RandomGeneration.randomVector(conf); FileSystem hdfs = FileSystem.get(conf); hdfs.delete(outputFolder, true); hdfs.delete(outputFolder2, true); // 获取分布式缓存文件路径 DistributedCache.addCacheF...
d73b528e-2d39-414b-af2d-edb6b9d33c02
4
private void writeLights(Document document) { for (int i = 0; i < lights.size(); i++) { Element lightNode = document.createElement("light"); Element color = document.createElement("color"); color.appendChild(document.createTextNode(write3Tuple(lights.get(i) .getColor()))); lightNode.appendChild(color...
17822c1a-2f01-49d8-97a8-350f96711a43
0
@BeforeClass public static void setUpClass() { }
9853409a-7977-4a8c-902d-43bb3afcbe8e
1
public UnionFind(int N) { componentCount = N; // Initially assume that all nodes are in different // components, components containing just themselves id = new int[N]; // allocate memory height = new int[N]; sz = new int[N]; // Initialise for (int i = 0; i < N; i++) { id[i] = i; height[i] = 0; ...
5a2cdcb7-e427-49e1-b1d8-f6a4e0d9e6d4
0
public String getLogin(){ return login; }
b900cd37-2a60-4188-b94a-b91174ffeca1
6
public boolean getBoolean(int index) throws JSONException { Object object = this.get(index); if (object.equals(Boolean.FALSE) || (object instanceof String && ((String) object) .equalsIgnoreCase("false"))) { return false; } else if (object.equal...
f4133976-6329-471d-9239-e368c96da9cb
3
@Override public void shoot(Point targetPoint) { if (actionMode != ActionMode.ATTACKING) { actionMode = ActionMode.ATTACKING; } if (canFire) { registry.getProjectileManager().createProjectile(this, "FireBall", 10, ...
d9b23288-ea14-4af9-9502-958c23a729a3
7
public List<Producto> getProductos() { Connection connection = null; Statement stmt = null; ResultSet rs = null; try { connection = pool.getConnection(); stmt = connection.createStatement(); rs = stmt.executeQuery("select...
f081b803-2f72-415a-a220-0157aebce3b0
9
private void adaptNewSetsMembership() throws ServerException { Connection conn = null; boolean startedTransaction = false; Iterator<SetInfo> newUserDefinedSetInfosIterator = this.newUserDefinedSetsMap.values().iterator(); while (newUserDefinedSetInfosIterator.hasNext()) { ...
b4d3d06e-56b7-483a-8f31-4033e6a5a115
2
@Override public int hashCode() { int hash = 5; hash = 79 * hash + ( this.left != null ? this.left.hashCode() : 0 ); hash = 79 * hash + ( this.right != null ? this.right.hashCode() : 0 ); return hash; }
069b3a26-dbb7-4fdb-b5d8-552ff4f5f5eb
2
private HashMap<Integer, String> LoadTimestampDiffsFromFile() { try ( InputStream file = new FileInputStream("timestamps.ser"); InputStream buffer = new BufferedInputStream(file); ObjectInput input = new ObjectInputStream(buffer);) { //deserialize the ...
d4bafaac-33f4-4836-98cf-884462454ce9
1
public String toString() { return newObj != null ? newObj.toString() : "" + value; }
8b22cdb1-0b19-41c3-b950-01e3a7dc0296
3
public ByteBuffer loadIcon(String filename, int width, int height) throws IOException { BufferedImage image = ImageIO.read(new File("./res/icons/"+filename)); // load image // convert image to byte array byte[] imageBytes = new byte[width * height * 4]; for (int i = 0; i < height; i++) ...
4e8049d4-87b5-4013-a08e-4079f3e07a52
8
public boolean execute(Closure closure){ // get the internal thread number int i = getInternalThreadId(); // ####################################################################### // guard stage // ####################################################################### // mark this thread as active a...