method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
d08b2c2a-f713-4edf-8e19-5026898fbce8
7
private void genTerrainFromNoise(ChunkTerrainControl ctc) { Perlin noise = new Perlin(); noise.setFrequency(0.01); noise.setLacunarity(2.0); noise.setNoiseQuality(NoiseQuality.BEST); noise.setOctaveCount(8); noise.setPersistence(0.5); noise.setSeed(DEFAULT_SEED); ...
07ebd323-5bc6-4f88-9598-e62e776c598f
3
public double scoreRackDE(Distribution target, Distribution err_weight){ double sum = 0; for (int i=0; i<cards.length; i++){ double err = Math.abs(target.eval(i) - cards[i]); if (err_weight != null) err *= err_weight.eval(i); sum += err; } //Min err = 0, Max err = rack_size(max_card-rack_size) //...
508a7d5f-7d3c-4d04-ade1-b86cf0624717
2
public int[][] quant(double array[][]) { int result[][] = new int[SIZE][SIZE]; for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { result[i][j] = ceil(array[i][j] / tableQuant[i][j]); } } return result; }
d9bc8d39-de3a-47d4-8121-618b59d43b53
8
private void readConfig(String genomeVersion, String configFileName) { //--- // Read properties file //--- configFileName = readProperties(configFileName); // Get config file directory String cfgDir = ""; try { File configDir = new File(configFileName).getAbsoluteFile().getParentFile(); cfgDir = co...
15b5a59e-d9df-433e-8795-100b463a4e12
2
public static void main(String... args) throws Exception { File file = new File("/Users/babyduncan/github/javanio/files/sourceFile.txt"); File disFile = new File("/Users/babyduncan/github/javanio/files/disFile.txt"); FileInputStream fileInputStream = new FileInputStream(file); FileChann...
5c1e130a-1445-4c04-852b-720410230248
2
public List<String> findFilesWithTime(long startTime,long endTime) { try { List<String> results = new ArrayList<>(); findFileWithTime.setTimestamp(1, new Timestamp(startTime)); findFileWithTime.setTimestamp(2, new Timestamp(endTime)); findFileWithTime.setTimestamp(3, new Timestamp(startTime)); fin...
66692da4-a0e3-47ef-a8ef-3fa42ba51b2e
3
public ResultSet PreparedQuery(String query, String[] params) { PreparedStatement ps; if (!IsConnected) { return null; } try { ps = Conn.prepareStatement(query); // Construct PreparedStatement by adding all supplied params to the query plugin.Debug("SQL Query: " + query); for (int x=0; x < param...
39f3b4fd-6875-4971-b9e1-d15e684da58b
4
public void load(File file){ if ( !file.exists() ){ System.out.println(file + " not found"); return; } BufferedReader data; System.out.println("Loading...."); try{ data = new BufferedReader(new FileReader(file)); while (true){ String line = data.readLine(); if (line==null) {break;} String...
bf286309-0883-4100-b3ae-2ff35106a8e3
6
protected void expandChildren(SearchState oldState, int oldDist) { HashMap<Integer, HashMap<Board, ListStateBuffer>> cache = new HashMap<>(); TetrisStateBuffer buf = stateBufferMap.get(oldState); for (Entry<Short, StateBuffer> stateEntry : buf.getMap().entrySet()) { int pieceIndex = stateEntry.getKe...
35cd495d-a42a-4e75-a7bb-5ae6d2d2273d
0
public JTextField getPsiTextField() { return psiTextField; }
eacfd53e-236c-4809-805b-073cbc0fd080
8
public void run() { try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } // This thread simulate the network. It allows the program to send or // receive messages from another site. System.out.println("-- Starting Network's thread --- \n "); System.out.println(" ...
63451cc2-493c-4826-9298-a8b4200fefae
4
private Matrix augNorm(Matrix mat) { Matrix localMat = new Matrix(new double[mat.numRows()][mat.numColumns()]); for(int doc = 0; doc < mat.numRows(); doc++) { double maxTf = 0; for(int term = 0; term < mat.numColumns(); term++) { double tf = mat.m[doc][term]; maxTf = Math.max(maxTf, ...
90d9663c-6977-45e2-bd21-d61bc45eb295
6
public void strikeByHammer() { if (dead) { return; } strike(ConstantValues.HAMMER); setMessage(MessagePool.getMessage(this, MessagePool.Action.Scream)); reduceComplacencyTimer += 400; shockTimer += 150; suppressionTimer += 140; if (getPartner() !=null) { getPartner().reduceComplacencyTimer+=200; ...
ff9ad7b4-34bc-46b2-9e95-c536dee988a6
8
public static void main (String[] args) { final int ROLLS = 1000; // number of rolls //Declare six integer variables, one for each side int zero = 0; int one = 0; int two = 0; int three = 0; int four = 0; int five = 0; int six = 0; // Declare a Die class type variable called die and create...
94cdfefb-2163-493b-930d-105b521adbff
0
static public boolean borrar (Cuenta actual){ return cuentas.remove(actual); }
6faae4f5-adb9-4762-8e73-4f4e7052fb13
5
private void kill() { for(int i = 0;i < slag.size();i++) { if(!slag.get(i).getLife()) { slag.remove(i); } } for(int i = 0;i < fiender.size();i++) { if(fiender.get(i).getCondition(Consts.DEAD) && fiender.get(i).ge...
174465b9-6083-4d7c-9170-6b2d7391e790
6
@Override public void whatToDo(Character character) { Game currentGame = Game.getInstance(); int rollResult = currentGame.rollDice(3); if (rollResult == 5) { character.incrementMight(2); character.incrementSpeed(2); } if (rollResult == 4) { character.incrementKnowledge(2); character.incrementKn...
88eed988-0858-4dc2-8005-105cf6ee9826
1
public boolean isVisible() { if(frame == null) buildGUI(); return frame.isVisible(); }
0668f86c-f823-4252-9a74-6575191a411c
1
private void sendAsChunked(OutputStream outputStream, PrintWriter pw) throws IOException { pw.print("Transfer-Encoding: chunked\r\n"); pw.print("\r\n"); pw.flush(); int BUFFER_SIZE = 16 * 1024; byte[] CRLF = "\r\n".getBytes(); byte[] buff = new byt...
2a5b682d-e320-4282-89fe-bedc88b02038
8
public int getCosto(){ switch(type_t){ case 1: return 10000; //Como infinito case 2: return 10000; //como infinito case 3: return 10; case 4: return 20; case 5: return 1; //En la casilla inicial hay hierba case 6: return 1; //En la casilla final hay hierba case 7: return 1; case ...
b35a5365-863f-4d0f-9554-3770cf4d15a5
2
public void formTransModeList(SessionRequestContent request) throws ServletLogicException { Criteria criteria = new Criteria(); User user = (User) request.getSessionAttribute(JSP_USER); if (user != null) { criteria.addParam(DAO_USER_LOGIN, user.getLogin()); ClientType typ...
95922341-63d2-4c74-830d-f8504a566f0b
3
@Override protected Value evaluate(ExecutionContext context) throws InterpretationException { Value val = ((AbsValueNode) this.getChildAt(0)).evaluate(context); if (val.getType() == VariableType.ARRAYLIST) { ArrayList<Value> list = (ArrayList<Value>) val.getValue(); list.rem...
7b03ca6f-5675-42ab-8d7c-7ebb8331c900
2
private static void initialize() { Path logDir = FileSystems.getDefault().getPath("./log"); try { if ( !Files.isDirectory(logDir) ) Files.createDirectory(logDir); logger = Logger.getLogger("Client"); handler = new FileHandler("log/error.log", true); ...
4f557830-bed6-4028-9686-f0ee865a57fd
4
private static void copySimpleFile(File inputFile, File outputFile, boolean isOverWrite) throws IOException { // 目标文件已经存在 if (outputFile.exists()) { if (isOverWrite) { if (!outputFile.delete()) { throw new RuntimeException(outputFile.getPath() + "无法覆盖!"); } } else { // 不允许覆盖 r...
10cf0130-2254-499b-9533-7fe67c6253eb
4
public void update(int delta) { if (getY() > Window.HEIGHT - getHeight()) { setY(Window.HEIGHT - getHeight()); speed = -speed; } else if (getY() < 0) { setY(0); speed = -speed; } if (getX() > Window.WIDTH - getWidth()) { setX(Window.WIDTH - getWidth()); speed = -speed...
ebf55c96-dd09-4839-886d-f178b16e4805
1
private static Type lookupType(String name) { try { return new Type(ClassPool.getDefault().get(name)); } catch (NotFoundException e) { throw new RuntimeException(e); } }
5efc264a-f1a4-480b-a87b-529b24373897
7
public void setContentType(String contentType) { if (isCommitted()) return; if (contentType==null) { _mimeType=null; _header.remove(HttpFields.__ContentType); } else { // Look for encoding in contentType ...
5ff6df79-31d2-46d1-ace1-cd787638a09d
4
private void updateStateIngred(List<Keyword> keywords, List<String> terms) { RecipeLearningState nextState; List<Keyword> ingredients = keywordsFromType(KeywordType.INGREDIENT, keywords); if (userSaidEnd(keywords)) { nextState = new RecipeLearningState(RecipeLearning.RL_ASK_FIRST_TOOL); setCurrentDialogState(...
f6313f66-fe66-4772-86b1-02491faf59b0
8
public static Sentence[] extractSentence(String weibo) { String newStr = ""; for (int i = 0; i < weibo.length(); ++i) { newStr += weibo.charAt(i); if (isSplitPunctuation(weibo.charAt(i)) && (i + 1 >= weibo.length() || !isSplitPunctuation(weibo.charAt(i + 1)))) newStr += "\t"; } String[] strList ...
0a530b72-8ba6-4c22-8680-ec5d71d19026
9
public void collideCheck() { if (dead) return; float xMarioD = world.mario.x - x; float yMarioD = world.mario.y - y; float w = 16; if (xMarioD > -16 && xMarioD < 16) { if (yMarioD > -height && yMarioD < world.mario.height) { if...
84f9df73-2948-4229-a9d3-f50b6cd72911
6
@Override public void encode(final ByteBuffer buf, final StringBuilder log) { final int start = buf.position(); final short count = (short) services.length; // Encode service count buf.putShort(count); if (log != null) log.append("UINT count ...
1ced354d-ed3e-49f9-8200-46794305d77f
1
protected void setLocalType(final int local, final Type type) { int index = local - firstLocal; while (localTypes.size() < index + 1) { localTypes.add(null); } localTypes.set(index, type); }
2b09e857-b4c0-4dfc-b86b-f6622802f790
0
public void setType(int type) { this.type = type; }
877c9433-5695-46db-80be-37d3c55e8621
4
public void fermer(){ try{ if(tamponSocket != null) tamponSocket.close(); if(writerSocket != null) writerSocket.close(); if(socket != null) socket.close(); } catch(IOException io){ io.printStac...
d93be34d-142a-433f-bfa3-bc3b7467f039
7
private void removeStep(double startPrice, double endPrice) { if (billingServerSecure == null) { System.out.println("ERROR: You are currently not logged in"); } else { try { billingServerSecure.deletePriceStep(startPrice, endPrice); System.out.println("Step [" + startPrice + " " + (endPrice == 0 ? "IN...
5e47796c-8a7b-4069-a618-a65699d6fe55
8
public void actionPerformed(ActionEvent evt) { /** increased elapsed time */ elapsedSec += 1; /** if elapsed 4 seconds */ if (elapsedSec >= 4) { /** if Java 2 available */ if (Main.J2) { /** stop background music */ BomberBGM....
0be1a430-fd13-4a18-8d66-80740057b0f0
9
protected int findFloorNumber(Room room, Set<Room> done, int floor) { LandTitle title = CMLib.law().getLandTitle(room); if(title == null) return floor; for(int d=0;d<Directions.NUM_DIRECTIONS();d++) { Room R=room.getRoomInDir(d); if((R!=null)&&(!done.contains(R))) { done.add(R); if(d==Direc...
172831cb-00be-4c52-907c-ad23277acc45
6
public static String streamToString(InputStream instream, String charset) { StringWriter writer = new StringWriter(); BufferedReader br = null; try { if (charset != null) { br = new BufferedReader(new InputStreamReader(instream,charset)); } else { br = new BufferedReader(new InputStreamReader(...
e9212eac-0121-4770-9946-2262dbe2bc9d
3
public void checkChars(String msg, String str, MutableString mut) { if (str.length() != mut.length()) { fail(msg + " (strings have different lengths): " + str.length() + " vs. " + mut.length()); } // if the lengths differ for (int i = 0; i < str.length(); i++) { ...
fce52535-8b89-434e-9c96-7f6bc64ebf0e
0
public void draw() { System.out.println("Draw Shape"); }
78c7f66f-5a57-4bc7-a68e-c03ff03f7429
6
private void initializeOutputs() throws IOException, CustomOutputException { if (this.configuration.getLogToConsole()) { this.logger.addOutput(new ConsoleOutput()); } String[] fileOutputs = this.configuration.getLogToFiles(); if (fileOutputs != null) { for (String fileOutput: fileOutputs) { if (!fileO...
a642771b-0611-489e-a8d0-8bc9c40cda8a
4
public MarketSign getMarketSign(Block block) { for (MarketSign sign : sellsigns) { if (sign.getBlock().equals(block)) { return sign; } } for (MarketSign sign : rentsigns) { if (sign.getBlock().equals(block)) { return sign; } } return null; }
9ecac1dd-b9c0-4ca6-9677-7ac3a5c6dc38
9
public void init() { try { Level.loadBehaviors(new DataInputStream(ResourcesManager.class.getResourceAsStream("res/tiles.dat"))); } catch (IOException e) { e.printStackTrace(); System.exit(0); } if(level==nu...
a88094fe-86de-4c8a-b015-87b56dde5d2b
1
public static List<String> getAllRatingDescriptions() { Collection<String> skis = ratingsMap.values(); if (ratings == null) ratings = new ArrayList<String>(skis); return ratings; }
c23ebb58-3eb5-491f-8323-dabef3a10891
2
private boolean hitOne(String S, int index, HashMap<String, Integer> left, int step) { String s = S.substring(index, index + step); if (left.containsKey(s)) { int count = left.get(s); if (count == 1) { left.remove(s); } else { left.put...
72ecd1e1-2270-446b-b4df-87875ab3be26
2
private static HashMap parseAttributes(String s) { StringTokenizer tok = new StringTokenizer(s); HashMap map = new HashMap(); String key = null; String value = null; String garbage = null; while (tok.hasMoreElements()) { key = tok.nextToken("="); garbage = tok.nextToken("\""); value = tok.nex...
7c41249d-c46b-4fb3-a95b-f3de3ae03c32
9
public static String ErrorToString(int error){ switch(error) { case OK: return "OK"; case UNKNOWN_HOST: return "UNKNOWN_HOST"; case INTERNAL_ERROR: return "INTERNAL_ERROR"; case SERVER_ERROR: return "SERVER_ERROR"; case NET_ERROR: return "NET_ERROR"; case ALREADY_EXISTS: return "ALREADY_EXISTS"; case DO...
b620529b-1629-4640-8991-efa339aac9cb
9
public boolean readColorModel(InputStream in) throws java.io.IOException { int len=readInt(in); //System.out.println("len="+len); if(!_isConnected) return false; readBytes(colormap,in,len*3); if(!_isConnected) return false; //we'll do this stupid thing because we can't change an existing color model, and we...
af2062aa-226f-4bc4-9679-427835c5bcd4
9
private static List<Point> readCoordinates(String filename) throws IOException{ BufferedReader br = new BufferedReader(new FileReader(filename)); String line; //Line numbering starts from 1 (not 0) int lineNr = 1; List<Point> points = new ArrayList<Point>(); int coordCount = 0; DecimalFormat format = n...
244936fc-5b10-4008-b56f-112c49ccdb1c
5
public static void main(String[] args) { if (args.length < 1) usage(); int rv = 0; if (args[0].equals("order")) { rv = runorder(args); } else if (args[0].equals("wicked")) { rv = runwicked(args); } else if (args[0].equals("misc")) { rv = runmisc(args); } else if (args[0].equals...
e6a2056b-732e-4574-94cf-84a75fbdeb1e
1
protected void updatePersonalBest(int row) { for(int k = 0; k < position[row].length; k++){ personalBest[row][k] = position[row][k]; } }
3fb949f0-137e-4e31-9f8d-f7697049d412
6
private void initField(Field[][] fields) { for (int i = 0; i < sizeX; i++) { for (int j = 0; j < sizeY; j++) { fields[i][j] = new Field(this, i + j * sizeX); } } for (int i = 0; i < sizeX; i++) { fields[i][0] = new BorderField(fields[i][0]); ...
3d248e0d-c806-4679-90dc-39f5f8d286fe
4
public void setOperand(String var, String op){ if(!Arrays.asList(inLables).contains(var)){ return; } Operand pos = null; for( AbstractUnit unit : units){ if(unit instanceof InputPin){ if(((InputPin)unit).name.equals(var)){ IIns...
a7e9d208-64d9-4ee9-9c13-47667d4add77
3
public void body() { // register oneself to the system GIS super.sim_schedule(GridSim.getGridInfoServiceEntityId(), GridSimTags.SCHEDULE_NOW, GridSimTags.REGISTER_LINK, new Integer(super.get_id()) ); Sim_event ev = new Sim_event(); ...
eb36940f-ab58-4977-9985-5b8ad0cdb6c9
9
public List getRecommandHot() throws Exception{ Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; String sql = ""; List recommandList = null; DataBean bean = null; int k=0; try{ sql="select ROWNUM, b.* from (select * from (select * from board union all select * from food un...
b820392f-4e11-4d35-b49e-710289dc484a
1
public void tick() { if(health <= 0) alive = false; }
72c25279-d7a3-436e-a4da-9791d9f2432a
8
public static String identifyWordFromFrequencyMatrix(double[][] currentCorrelationMatrix) throws Exception { int rowIndex = 0; int columnIndex = 0; double maxCorrelation = PearsonCorrelationCoefficientClass.getMaximumElement(currentCorrelationMatrix); // Get the row and column index o...
d6822ed8-6a5e-49e5-9989-f0c3d0e42859
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...
6b1b3c28-a374-4b5b-9e44-2d21f326fa15
0
@Test public void testGetEdge() { System.out.println("getEdge"); assertEquals(2.0, new Tetrahedron(1.5,2,3.5,12).getEdge(), 0.00001); }
c66ce20d-fcd5-43e2-96d4-47d143e913d3
8
public void runQuery() { // gets search parameters from searchpanel ArrayList<String> ingred = new ArrayList(); String str = searchpanel.getIngredients().getText(); String[] ingreds = str.split(" "); for (int i = 0; i < ingreds.length; i++) { ingred....
8d0e56b3-9977-4769-92b5-681d1ff15cae
4
public StackLocalInfo dup(int count, int depth) { ConstValue[] newStack = new ConstValue[stack.length + count]; ConstValue[] newLocals = (ConstValue[]) locals.clone(); if (depth == 0) System.arraycopy(stack, 0, newStack, 0, stack.length); else { int pos = stack.length - count - depth; System.arr...
ca3ad1f2-5e8a-485d-a532-dca880097059
1
public void configure(JoeTree tree) { // Lazy Instantiation if (!initialized) { initialize(); initialized = true; } this.tree = tree; attPanel.update(this); }
c808ebe6-b255-4e0b-9452-0890bb72fd38
4
public static Component newInstanceWithEntity(Class<?> componentClass, Entity entity) { Constructor<?> ctor; try { ctor = componentClass.getConstructor(); Object instance = ctor.newInstance(); if(instance instanceof Component) { Component ret = (Component)instance; ret.setEntity(ent...
07520d02-49cb-4452-8a1d-6ddb259cd9eb
9
private void prepareWheel() { double effMin = 0; double range = 0; if (!flag(OPT_MINIMIZE)) { effMin = meanValue - stdDeviation * 2; range = maxValue - effMin; wheelBaseValue = effMin; if (range < 0.001) wheelBaseValue = effMin - 20.0; } else { effMin = (meanVa...
e9f296ab-9487-4d0a-854e-3e85f7d03701
3
private boolean allowSelfReference( ConnectionFlavor flavor ) { if( flavor.equals( AssoziationConnection.ASSOZIATION ) ) { return true; } if( flavor.equals( CompositionConnection.COMPOSITION ) ) { return true; } if( flavor.equals( AggregationConnection.AGGREGATION ) ) { return true; } return f...
c1c1e305-3781-4f3b-8f75-0dc06d5b7fb6
4
public void uploadArray(String vname,float defaultValue) throws IOException, WrongArgumentException, InterruptedException { creater = new ArrayCreater(conf, zone, this.shapes.get(this.shapes.size() - 1),vname,this.thread_num,defaultValue); int i ; int []srcShape = new int [chunk.getChunkStep().length]; long tm...
7805c139-fd9b-4dd5-a776-8cd67d7c7834
5
public void lock(String mode) { if (this.state == CellState.MARKED) { this.state = CellState.LOCKED; if (!hasMine()) notifyObservers("errorMarked"); } if (this.state != CellState.CLOSED) return; this.state = CellState.LOCKED; if (hasMine() && mode.equalsIg...
1bb28e23-4664-4c9a-85d2-f24be50f4404
1
@Override public ArrayList<Edge> getEdgeList() { if (edges.isEmpty()) { initDataStructure(); } return edges; }
5d4db60c-5a15-40e9-8345-cb4b2fa1cf82
4
public void updateRecomendations() { eventList.clear(); recomendationType.clear(); view.getResults().clear(); Database db = Database.getInstance(); LinkedHashSet<String>eventListNamesForSameArtist = new LinkedHashSet<String>(); LinkedHashSet<String>eventListNamesForSimilarArtist = new LinkedHashSet<String>(...
0c9c04d8-a304-4e6b-b1d5-c661e57d23d4
8
public void putAll( Map<? extends Float, ? extends Short> map ) { Iterator<? extends Entry<? extends Float,? extends Short>> it = map.entrySet().iterator(); for ( int i = map.size(); i-- > 0; ) { Entry<? extends Float,? extends Short> e = it.next(); this.put( e.getKey...
ce791977-3ae9-40bd-8f39-b703a6afd5bb
1
public void setY(float y) { // check if falling if (Math.round(y) > Math.round(getY())) { onGround = false; } super.setY(y); }
026c1deb-4ca2-4fba-9047-a18d972dcc55
5
public void run() { show(0); State board = new State(); Player[] players = {new AlphaBetaPlayer(7), new MctsPlayer(500)}; while (!board.gameOver()) { int move; if (board.getColorToPlay() == 'X') { draw(board, "Black to play. Click here if no legal move.", 0); move = players[0].move(board); } el...
70171aeb-ba31-493a-971b-5eff8e6d18c8
8
public FontRenderer(GameSettings var1, String var2, TextureManager var3) { this.settings = var1; BufferedImage var14; try { var14 = ImageIO.read(TextureManager.class.getResourceAsStream(var2)); } catch (IOException var13) { throw new RuntimeException(var13); } int...
b5bd3418-978d-493e-ad1d-6a39f7444c33
4
public static void main(String[] args) { List<Integer> numList = new ArrayList(); numList.add(5); int x = numList.get(0); List<String> myList = new ArrayList<>(); myList.add("Guitar"); myList.add("Drums"); myList.add("Singer"); // for(int i = 0;...
429caeb7-9676-45e5-b1db-52f62d6978c4
8
public void normalize() { ListIterator<List<List<Double>>> acItr = dataMatrix.listIterator(); while (acItr.hasNext()) { ListIterator<List<Double>> mItr = acItr.next().listIterator(); while (mItr.hasNext()) { double sum = 0.0; boolean allMissing = true; List<Double> all...
d706a8b6-14b8-4134-88d0-986699538972
9
@EventHandler(priority = EventPriority.NORMAL) public void onBlockBreak(BlockBreakEvent event){ if(!event.isCancelled()) { String test = plugin.findArea(event.getBlock().getX(), event.getBlock().getZ(), event.getBlock().getWorld().getName()); String userTeam = plugin.getTeamPlayer(event.getPlayer()...
a3079c6f-7366-448d-8208-7732059d464e
3
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, Exception { //retardo debug // try { // Thread.sleep(80); // } catch (InterruptedException ex) { // Thread.currentThread().interrupt(); //...
d325e1fa-1a5d-4a95-8e3c-319dc9f2985e
5
@Override public void messageReceived(MessageEvent e) { String svrmsg = e.getMessage(); if (svrmsg.contains("You get some logs.")) { normalsChopped++; System.out.println("Paint: Normal trees chopped: " + normalsChopped); } else if (svrmsg.contains("You get some oak logs.")) { oaksChopped++; System....
e443fabb-73d7-4daa-a3c7-290374ae3878
3
public void addComponent(Entity entity, IComponent component, boolean notifyObservers) { HashMap<Entity, IComponent> entityComponentMap = registeredComponents.get(component.getClass()); if (entityComponentMap == null) { logger.info("No previous occurence of this component existed before.", "Creating new set...
d174d0b7-dab9-4a84-b37c-3c2815cbfa15
3
public void setStock(Stock stock) { if (stock == this.stock) return; if (this.stock != null) { this.stock.removeStorageUnit(this); } this.stock = stock; if (this.stock != null) { this.stock.addStorageUnit(this); } }
a50fdbb0-2a18-4718-b93c-851d92075ed0
7
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //processRequest(request, response); try { if("true".equals(request.getParameter("doFeedback"))){ Transaction _transaction ...
58238e97-a0f0-4ba4-80f4-b8ee2ea49f2f
5
private boolean gameWon() { for(int i = 0; i < PLAYER_AMOUNT;i++) // This for-loop controls if someone has won the game by reaching 3000 { if(playerControl.lastManStanding() > -1) // call lastManStanding to see if the player is the last man standing. The reason for -1, is because 0 is a playerindex { cout.prin...
762d0162-525f-4155-92a5-8a5278758e80
3
public String layer_string() { switch (h_layer) { case 1: return "I"; case 2: return "II"; case 3: return "III"; } return null; }
79242c0e-e453-4e5c-ada4-05ab30edfcfc
0
public static void main( String[] args ) { JFrame cardsJPanel = new CardsTesterJFrame("CARD CLASS TESTER", 10, 10, 500, 400); }
0e3dfaf2-a1ec-4c2e-a89b-2a2bb636c69b
3
public void atAssignExpr(AssignExpr expr) throws CompileError { // =, %=, &=, *=, /=, +=, -=, ^=, |=, <<=, >>=, >>>= int op = expr.getOperator(); ASTree left = expr.oprand1(); ASTree right = expr.oprand2(); if (left instanceof Variable) atVariableAssign(expr, op, (Var...
f1fd5f63-63b9-4aad-b45d-bcfccbb75b5c
3
private static void dfsRec(mxAnalysisGraph aGraph, Object cell, Object edge, Set<Object> seen, mxICellVisitor visitor) { if (cell != null) { if (!seen.contains(cell)) { visitor.visit(cell, edge); seen.add(cell); final Object[] edges = aGraph.getEdges(cell, null, false, true); final Object[] ...
573205be-93c6-493a-bdcb-9f6b43edfe50
4
@Override public void keyPressed(KeyEvent e) { Keys key = Keys.getKey(e.getKeyCode()); keyStates.put(key, true); if(keyListeners.containsKey(key)) { if(exclusiveKeyListener != null) { fireExclusiveKeyListener(key, e.getKeyChar()); } else { fireKeyEvents(key, key, e.getKeyChar()); ...
030db980-8b50-46be-8a56-12c95901b1ae
9
void moveDown(int i, boolean min) { int size = heap.size(); while (i < size) { int p = highDescendant(i, min); if (p < 0) { return; } int cmp = compare(heap.get(p), heap.get(i)); if (i == grandParent(p)) { if (min ? cmp < 0 : cmp > 0) { swap(i, p); ...
df9d828f-72fc-4907-8214-002d9d121666
9
public static void incorporateIncludesModules(Module module, Stella_Object includees) { { Surrogate testValue000 = Stella_Object.safePrimaryType(includees); if (testValue000 == Stella.SGT_STELLA_CONS) { { Cons includees000 = ((Cons)(includees)); { Stella_Object name = null; Con...
b52b5543-2b35-4366-baa2-4800f2afd61d
9
public static String gunzip(String compressedStr) { if (compressedStr == null) { return null; } ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayInputStream in = null; GZIPInputStream ginzip = null; byte[] compressed = null; String decompressed = null; try { compressed = new...
448a130e-0e71-46e3-9e5e-45a270f1f404
1
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { GuiTestingXML frame = new GuiTestingXML(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
ceba4458-4a69-429c-9eb8-9d58e412db09
6
public String justify(String[] w, int x, int y, int cnt, int L) { int n = w.length; String res = ""; if (x == y || y == n - 1) { // left justify銆備袱涓潯浠讹細鍙湁涓�釜鍗曡瘝锛屾垨鑰呮渶鍚庝竴琛屻� res = w[x]; for (int i = x + 1; i <= y; i++) { res += " " + w[i]; } while (res.length() < L) res += " "; return res;...
1effb039-cac9-4a40-9fbc-2791f6928f58
8
private void updateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateButtonActionPerformed // Error handling to ensure that arrival is before departure, and one of the fields aren't empty. if ("".equals(jXDatePickerChangeArrival.getEditor().getText()) || "".equals(jXDatePick...
1d5cc50f-9519-48ef-97db-ac2a7151c6c7
7
public Expr evaluate(IEvaluationContext context, Expr[] args) throws ExprException { assertMinArgCount(args, 2); int len = 0; Expr[] ea = new Expr[args.length]; for (int i = 0; i < args.length; i++) { ea[i] = evalArg(context, args[i]); if (i == 0) { ...
7b509820-ae7e-4f23-83f6-c87f2b9369f3
0
public BinomioEntidadeFake(int k, int n, int coefiente) { super(); this.k = k; this.n = n; this.coefiente = coefiente; }
ec956bbe-e870-44b8-8e64-bac36140afe8
0
public static void main(String[] args) { Target target = new Adapter(new Adaptee()); target.method1(); }
6ab23446-d4c2-4a19-835e-c8e0f8413acd
5
@Override public boolean execute(MessageContext context) { // Validating arguments String rawArguments = getArguments(context); if(rawArguments == "") { sendUsageBack(context); return false; } String[] arguments = rawArguments.split(" "); if(arguments.length != 2) { sendUsageBack(context); r...
bf298637-9f77-4e27-b0a3-64dd3bb0ad79
7
public static int findAnchors(Component base, Container ancestorContainer) { int contact = AnchorConstraints.ANCHOR_TOP | AnchorConstraints.ANCHOR_LEFT | AnchorConstraints.ANCHOR_BOTTOM | AnchorConstraints.ANCHOR_RIGHT; Component comp = base.getParent(); Component child = base; while(comp != null && comp != an...
4606dea8-6310-4714-8ecd-2d201e66a749
5
public void validate() throws IOException { update0(); for (int i = 0; i < files.length; i++) { if (createIfNotExist && files[i].exists()) { files[i].createNewFile(); } if (head != -1 && i == head) { //verify header } ...
e96516c8-6734-4703-8cc7-4d9793e27081
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...