method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
1d2f415e-f550-4eda-82c1-5cb2b9b4b095
3
@Override public Object decorate(final ClassLoader loader, final Field field) { if (IContainer.class.isAssignableFrom(field.getType())) { return decorateContainer(loader, field); } if (IElement.class.isAssignableFrom(field.getType())) { return decorateElement(loader, field); } if (List.class.isAssigna...
cd0f43c3-a98c-4931-a929-34afc8d8fc39
7
public void merge(String nameI, String nameO) { float[][] data = new float[0][0]; int size = 0; try { DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(nameI))); size = dis.readInt(); data = new float[size][size]; ...
bc2f8c22-4f32-40ec-828a-2e62ca98cece
3
public boolean add(T item, List<T> old) { // Parameters may not be null and the list object provided must initially contain the item // being added to the TimeOutList. if (item == null || old == null || !old.contains(item)) throw new IllegalArgumentException(); // Remove the item from its previous location. ...
d9f18b29-8e06-4d38-94e7-e10f2e0b5612
6
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if(label.equalsIgnoreCase("irc")) { if(args[0].equalsIgnoreCase("help")) { sender.sendMessage(ChatColor.GREEN + "AprilonIrc by HAPPYGOPUCKEY"); ...
8cce3d0f-3e76-4927-8da7-2682d449e665
9
public boolean renderBlockDragonEgg(BlockDragonEgg par1BlockDragonEgg, int par2, int par3, int par4) { boolean flag = false; int i = 0; for (int j = 0; j < 8; j++) { int k = 0; byte byte0 = 1; if (j == 0) { k = 2; ...
87b1481f-df5a-4e13-b2d0-6948001dd8b6
5
@Override public Event findEventByEventId(int eventId) { Event event = null; Connection cn = null; PreparedStatement ps = null; ResultSet rs = null; try { cn = ConnectionHelper.getConnection(); ps = cn.prepareStatement(QTPL_SELECT_BY_EVENT_ID); ...
fb8210a1-8bc9-479b-8ad3-4fa202ae6a1c
5
public static boolean eliminar( Integer id, boolean destruir) throws ObjetoNoEncontradoExcepcion { Cliente cliente = Cliente.buscar( id); if (cliente == null) throw new ObjetoNoEncontradoExcepcion( "El cliente con id " + id + " no existe"); // Se elimina la informacin del producto en las tiendas. ArrayList...
1789d4d2-584a-411c-93f9-4e8c89907611
1
@Override public boolean hasNext() { if (first == null) return false; return !(current == null); }
b9004e76-3014-4862-bfa7-a80034418197
5
private void transferChanges() { //brand new group if (editingFilt == null) { editingFilt = new Group(manager.getUId(), "", 0, null); //original = (Group) editingFilt.clone(); } if (groupList.getSelectedIndex() == 0) { editingFilt.setKey(null); ...
eac97124-0dee-4e23-bdbd-ed3b027ea37e
9
public void CostEstimate(int []vshape,int []pshape,Vector<int[]> shapes, int []start, int []off) throws IOException, WrongArgumentException { DataChunk chunk = new DataChunk(vshape,pshape); Set<DataChunk> chunks = chunk.getAdjacentChunks(start, off); int rsize = 1; for(int i = 0 ; i < start.length; i++) ...
96860a96-4826-45e3-aaba-7a906064cbaa
2
private void drawContentGrid(Graphics g) { for (int i = 0; i < nbRows; i++) { for (int j = 0; j < nbColumns; j++) { visitor.setPosition(i, j); grid[i][j].accept(visitor); } } }
9456098b-20de-4b54-9f48-95504f7525e5
0
private void beginTournamentButtonActionPerformed(java.awt.event.ActionEvent evt) { tourn = new Tournament(brains, worlds); tourn.startNewTourn(gui); }
17285276-b235-49bf-bc42-2b87f93b0b7a
8
@Override public final String toString() { StringBuffer toReturn = new StringBuffer(); switch (this.type) { case DEFAULT_VALUATION: break; case PRECOND_VALUATION: if (this.variable != null) { toReturn.append(this.variable).append(" = "); } toReturn.append("<").append(this.identifier); toReturn.a...
70517eb9-bf8b-423c-bc25-ed57097a1379
3
void hookListeners (Widget widget) { if (logging) { Listener listener = new Listener() { public void handleEvent (Event event) { log (event); } }; for (int i = 0; i < EVENT_INFO.length; i++) { if (eventsFilter [i]) { widget.addListener (EVENT_INFO[i].type, listener); } } } }
7e0457b2-4cb8-4374-864d-6e4831ebd7d5
0
public Document getDocument() {return this.doc;}
36f9cb34-7bda-4d7b-9f7d-cf6283e7ab7a
9
public static Object getValueClass(char ch) { switch (ch) { case '@': return PatternOptionBuilder.OBJECT_VALUE; case ':': return PatternOptionBuilder.STRING_VALUE; case '%': return PatternOptionBuilder.NUMBER_VALUE; ...
c695964e-529c-41b4-8025-af67015b8c42
3
public int doFSK200500_8000FFT (CircularDataBuffer circBuf,WaveData waveData,int start,int ss) { // Get the data from the circular buffer double datao[]=circBuf.extractDataDouble(start,ss); double datar[]=new double[FFT_64_SIZE]; int a; for (a=0;a<datar.length;a++) { if ((a>=12)&&(a<52)) dat...
b5401bf7-001c-466f-9c2a-c284910eb7a4
0
public Iterator<City> iterator(){ return cityList.iterator(); }
f45188dd-8682-4c30-815f-509ef0b0494e
5
public List<List<Object>> cutLeaderboard(List<List<Object>> listToCut) { int cutOff = this.n; int listSize = listToCut.size(); List<List<Object>> listToReturn; if (cutOff < listSize - 1) { int lowestScore = (Integer) listToCut.get(cutOff - 1).get(0); while (cutOf...
0bf5f6ec-6d5d-495b-8970-e8e0548742af
8
private String httpGET(String requestURL) { //Variables URL request = null; HttpURLConnection connection = null; //Scanner scanner = null; BufferedReader reader = null; String s = ""; String response = ""; try { request = new URL(requestURL); connection = (HttpURLConnection) request.openConnecti...
7847aa64-7218-4b2b-b0d8-b30baff0a72f
2
public boolean connect(){ try { socket = new Socket(hostName, port); input = new InputListener(this, socket.getInputStream()); input.start(); output = new OutputWriter(this, socket.getOutputStream()); output.start(); output.write("NICK " + nick + "\r\n"); //output.flush(); output...
ae895563-80b5-41ff-a185-4be40d648277
8
public static boolean CheckKingThreat(ChessPieceBase[][] TheBoard, boolean WhiteMove){ int KingLocationX=0,KingLocationY=0; for (int a=0;a<8;a++){ for (int b=0;b<8;b++){ if (TheBoard[a][b]instanceof KingPiece&& TheBoard[a][b].isWhite==WhiteMove){ KingLocat...
ddf82477-4d46-4fc5-b553-24198f5eea28
7
private JSONWriter append(String string) throws JSONException { if (string == null) { throw new JSONException("Null pointer"); } if (this.mode == 'o' || this.mode == 'a') { try { if (this.comma && this.mode == 'a') { this.writer.write(','); } this.writer.write(string); } catch (IOExcepti...
6dd2690e-84d9-4c84-a99f-c6ed95fb5324
3
@Override protected Dimension getSizeSelf(LayoutSize type) { Dimension[] sizes = getChildSizes(type); Dimension size = new Dimension(getHorizontalGap() * (sizes.length > 0 ? sizes.length - 1 : 0), 0); for (Dimension one : sizes) { size.width += one.width; if (one.height > size.height) { size.height = o...
69c65b0b-fda5-428a-957e-64d27b7494e8
1
public boolean maisDeUmEmS() { boolean res = false; if (lockS.size() > 1) { res = true; } return res; }
e8752842-4cb1-43ac-bac5-f63c0471247e
2
public void run() { while(true) { DatagramPacket packet=null; //ݱUDPĴ byte data[]=weather.getBytes(); //ֽ packet=new DatagramPacket(data,data.length,iaddress,port); //ָݰڴĿռʹСݰĿַ˿ System.out.println(new String(data)); try { socket.send(packet); sleep(3000); }catch(Exception e){ e.prin...
7422ad5b-850e-4da4-883e-96f175d469a5
4
public void run() { /* * ゲームループ */ long beforeTime, afterTime, timeDiff, sleepTime; long overSleepTime = 0L; int noDelays = 0; beforeTime = System.nanoTime(); prevCalcTime = beforeTime; running = true; while (running) { gameUpdate(); gameRender(); paintScreen(); afterTime = System....
08c1e364-03ca-4f26-8498-dd3445400dd4
7
* */ public void restore(final Dockable dockable) { if (dockable.getDockKey().getLocation() != DockableState.Location.MAXIMIZED) { // development error (could have been an assertion). throw new IllegalArgumentException( "Dockable isn't currently in the MAXIMIZED state : " + dockable); } Dockab...
d560ea09-189c-44a6-9fc6-9eff15227360
8
@Override public boolean tick(Tickable ticking, int tickID) { if((unInvoked)&&(canBeUninvoked())) return false; if((tickID==Tickable.TICKID_TRAP_DESTRUCTION) &&(canBeUninvoked()) &&(pit!=null) &&(pit.size()>1) &&(((pit.get(0).numPCInhabitants()>0) ||(pit.get(pit.size()-1).numPCInhabitants()>0)))) ...
8e1a3ea1-fa07-408f-afb8-96c8f0382bb9
3
public boolean equals(Object o) { if (o instanceof Key) { Key k = (Key) o; return tag == k.tag && intData == k.intData && objData.equals(k.objData); } return false; }
63dba58b-78d3-4d78-9234-438d490cc411
7
public void paint(Graphics g) { super.paint(g); if(!started) {Font small = new Font("Helvetica", Font.ROMAN_BASELINE, 20); FontMetrics metr = g.getFontMetrics(small); String msg = "PRESS SPACE"; g.setColor(new Color(255, 255, 255)); g.setFont(small); g.drawString...
5f045345-f5f5-456e-a24f-fbec03ae1e8d
2
public static void handleLabel(Transition transition, Automaton automaton) { /* * FSATransition trans = (FSATransition) transition; String label = * trans.getLabel(); String firstChar = label.substring(0,1); String * restOfLabel = label.substring(1); * * StatePlacer sp = new StatePlacer(); * * ...
09de3f30-efbc-41cf-be43-b9113d6d09e6
4
public static int maxArea(int[] height) { int low = 0, high = height.length - 1; int maxarea = 0; while (low < high) { int w = height[high] > height[low] ? height[low] : height[high]; int area = w * (high - low); maxarea = maxarea > area ? maxarea : area; if (...
ec42a5c4-35e8-4997-90b4-79b10b2a1dd7
9
public void ajoutEquipement() { JFileChooser fc = new JFileChooser("./jars/equipements"); int returnVal = fc.showOpenDialog(this); if(returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); try { AEquipement eq...
2356b196-7a4f-408e-98ba-e5181788f753
5
private void dbgPath(Graphics grphcs){ dbgString("update in: " + pathTime, grphcs); dbgString("last update time: " + level.getLastPathUpdateDuration(), grphcs); PathingGraph graph = level.getPathingGraph(debugPathing); double rad = 0.1f; double transformedDiameter = transformLength(2f * rad); for(PointI p:g...
4cb75e3d-cb4a-4ac3-842a-a2aa54cdb645
0
public Instruction() {}
241257cf-d53d-4e19-a995-654f0b193079
3
public static void next() { try { if(currentPlayback != null && nextTrack != null) { server.onTrackChange(); setCurrentTrack(nextTrack); play(); } } catch (MediaException e) { System.out.println("Invalid media type."); ...
c1957729-81dd-4d2b-8cd7-33e1c4315355
7
public static Double grandDaddy(Double freeEnergy, Double enthalpy, Double temperature, Double entropy) { boolean[] nulls = new boolean[4]; nulls[0] = (freeEnergy == null); nulls[1] = (enthalpy == null); nulls[2] = (temperature == null); nulls[3] = (entropy == null); int nullCount = 0; for(int k = 0; ...
a16048b5-204c-4ef4-b144-74b594e6afd6
4
public List<FrameAdapter> getLateReceivers() { ArrayList<FrameAdapter> result = new ArrayList<FrameAdapter>(); for (AuthFrameAdapter adapter : server.getAdapters()) { if (adapter.isAuthenticated() && adapter.getSessionID() != sender && !receiverList .contains(adapter.getSessionID())) { result.add(adapte...
9f89ca5c-a25c-49bf-824a-53ce67669ee4
6
public int mergeAdjacentFace(HalfEdge hedgeAdj, Face[] discarded) { Face oppFace = hedgeAdj.oppositeFace(); int numDiscarded = 0; discarded[numDiscarded++] = oppFace; oppFace.mark = DELETED; HalfEdge hedgeOpp = hedgeAdj.getOpposite(); HalfEdge hedgeAdjPrev = hedgeAdj.p...
a73b8cc1-35dd-4283-80f6-f36075d788c6
6
public String stats(){ int rAntsFood = 0; int bAntsFood = 0; for(int x = 0; x<world.getRows(); x++){ for(int y = 0; y<world.getColumns(); y++){ Cell c = world.getCell(x,y); if(c.getIsRAntHill()){ rAntsFood += c.getFoodAmount(); } else if(c.getIsBAntHill()){ bAntsFood += c.getFoodAmoun...
8f312a89-5b34-45b6-9e38-e6f1491f906d
8
public static void main(String[] args) { try { test1(); } catch (ArithmeticException e) { e.printStackTrace(); } StdOut.println("--------------------------------"); try { test2(); } catch (ArithmeticExc...
e271eaac-ddc7-4b82-b492-f522cce42884
1
private void setSerialPortParams() { try { serialPort.setSerialPortParams( Integer.parseInt(baudComboBox.getSelectedItem().toString()), SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (Num...
3fa412f4-972a-4d31-b10e-561b6f165b57
9
public boolean skipPast(String to) throws JSONException { boolean b; char c; int i; int j; int offset = 0; int length = to.length(); char[] circle = new char[length]; /* * First fill the circle buffer with as many characters as are in the ...
4d8ac8f1-c16d-49c8-885d-d7440a4ea452
6
public static boolean isListAPalindrome(sNode head){ //If were using doubly linked lists we would first figure out the length then accordingly from the middle //expand to both ends and compare values. This will be done O(n) //However given that this we only have a singly linked list, we would f...
1025b38a-f866-4a11-aa41-6fd58a79924d
6
private void armHealthyPopulation() { int weapons, bulletsPerWeapon; HumanInformation humanInformation; //Calculate the number of healthy humans to give a weapon weapons = Math.min(this.healthyCount, this.configuration.getResources().getWeapon().getArmedPerWeaponKit());...
560a2566-ab4f-40e2-8788-cd95300028af
3
@Override public String getFromNative(long i) { short strLen = stringLengths.getShort(i); if (strLen < 0) return null; long offset = sizeof * i * maxStringLength * CHARSET_SIZE; for (int j = 0; j < strLen; j++) { byteArray[j] = Utilities.UNSAFE.getByte(ptr + offset + ...
bd781a75-d7ba-4ff5-8190-55192c77bde9
3
public static void initDatabase(){ File dbFile = new File(DATABASE_FILE); if(dbFile.exists()){ System.out.println("Warning! Database already exists! To delete, please run resetDatabase()"); return; } try { Class.forName("org.sqlite.JDBC"); ...
a6756ed8-79d9-47e4-a9f4-493af5acf2e5
1
@Override public boolean isDataFlavorSupported(DataFlavor flavor) { return ( flavor.equals(flavors[STRING]) || flavor.equals(flavors[NODESET]) ); }
940b0c22-6430-450b-b4e8-504369c1cd1f
1
public void calculateValue() { HashMap<Integer, Double> featuresVector = getVector(); value = 0; for (int key : featuresVector.keySet()) { value += Math.pow(featuresVector.get(key), 2); } value = Math.sqrt(value); }
b98632cb-4f4a-434c-8b59-eabd9729e722
2
public <T extends AstronomicalObject> String stringInnerObjects(Class<T> type) { String returnedString = ""; if (type.getName().contains("SpacePort")) { List<SpacePort> obj = spacePorts; for (SpacePort t : obj) { returnedString += t.deepToString(); } ...
60303bf7-6ea0-4292-91b7-b4b4b3d72f02
2
@Override public String toString() { StringBuffer ret = new StringBuffer("TITLE: " + getTitle() + "\n"); try { ret.append("LABEL: " + getLabels() + "\n"); ret.append("FORMAT: " + getFormat() + "\n"); ret.append("TYPE: " + getReleaseType() + "\n"); ret.append("...
4601211b-b2dc-451a-bbff-009908ef5a33
2
public void wdgmsg(Widget sender, String msg, Object... args) { if (sender == in) { if (msg == "activate") { wdgmsg("msg", args[0]); in.settext(""); return; } } super.wdgmsg(sender, msg, args); }
d5b0b58b-9a9f-41d9-a24a-5caf6d57710a
2
@Override public Writer addRecordEntry(final String columnName, final Object value) { if (rowMap == null) { rowMap = new HashMap<String, Object>(); } if (!validateColumnTitle(columnName)) { throw new IllegalArgumentException("unknown column: \"" + columnName + "\"");...
8c69131e-5358-4724-8305-22e86609fc38
5
public void run(){ try{ InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line = null; if (type.equals("ERROR")){ while ((line = br.readLine()) != null){ System.out....
64dbae69-0313-48d6-8368-15865e62e7b6
6
private RenderableObject generateImage(Scanner inFile) { Point loc = null; String f = ""; String current = inFile.next(); while (inFile.hasNext() && !(isCloseTag(current) && parseTag(current) == LegalTag.Object)) { if (isOpenTag(current)) { switch (parseTag(current)) { case Location: loc = n...
e0e446a1-d474-4a94-a79c-2f678169565b
0
public void setType(Type type) { this.type = type; }
7cc1f0a8-41e1-49b2-bca6-490b5cb28a1a
8
public static Figure fromChar(char spec) { switch (spec) { case 'a': case 'A': return ASTERIX; case 'o': case 'O': return OBELIX; case 'm': case 'M': return MIRACULIX; case 'l': case 'L': return LEGIONAIRE; default: throw new RuntimeException("Unknown spec: " + spec); } }
d09b4550-a6af-49bb-94a7-7379624062ec
2
private static String getHTML(String text) { String urlToRead = "http://dictionary.yandex.net/dicservice.json/lookup?callback=ya_.json.c(11)&ui=ru&text="+text+"&lang=en-ru&flags=1&sid=546092b1"; URL url; HttpURLConnection conn; BufferedReader rd; String line; String resul...
2109c730-a892-449d-ae3f-3d88136b4cb1
9
private void updateStateLocation(List<Keyword> keywords, List<String> terms) { // assume that we are in canteen adennauerring, others can't be implemented because of lack of infomations String[] lines = {"one", "two", "three", "four", "five", "six"}; String ln = null; if(terms.get(0).contains("line")) { String...
e9e679ee-ef19-4e57-ac7a-93f5f07212e0
0
public void setMapPoint(double latitude, double longtitude, double width, double height) { markerRect = new MarkerRect(longtitude,latitude,width,height); MapGetter.setGoogleMarkers(markerRect); MapGetter.getMapImage(MapGetter.createUrl(0, 0)); repaint(); }
0af1e8ed-19c4-40b5-a128-51819b53eaaf
7
private byte[] crypt_raw(byte password[], byte salt[], int log_rounds) { int rounds, i, j; int cdata[] = (int[])bf_crypt_ciphertext.clone(); int clen = cdata.length; byte ret[]; if (log_rounds < 4 || log_rounds > 31) throw new IllegalArgumentException ("Bad number of rounds"); rounds = 1 << log_rounds; ...
5f0371a2-e9bf-42ea-b684-f0683e0d2822
9
public int countMaxMovesLeft() { if (infiniteGameTree) { return 100; } switch (state) { case 'A': return 3; case 'B': return 2; case 'C': return 2; case 'D': return 1; case 'E': return 1; case 'F': return 1; case 'G': return 1; case 'R': return 1; } r...
6a61554d-643b-49ff-aa28-b5ecf5f847cf
6
protected static Ptg calcGCD( Ptg[] operands ) { if( operands.length < 1 ) { return PtgCalculator.getNAError(); } Ptg[] numbers = PtgCalculator.getAllComponents( operands ); long gcd = 0; try { long n1; if( (n1 = PtgCalculator.getLongValue( numbers[0] )) < 0 ) { return new PtgErr( PtgErr....
e352cc8c-a9dd-4749-8fa8-39b90986ae3c
4
@Override public void connectToService() { if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } try { Remote service = Naming.lookup("//127.0.0.1:1699/quiz"); quizService = (QuizService) service; } catc...
77227d03-86ea-4a9b-9964-d25bcf17c0e1
7
public void remove() { int i=EN-1; if (EN<0) return; O[i]=null; ON--; if (Gap<0 || Gap>i) Gap=i; if (i==OLast-1) OLast--; while (OLast>0 && O[OLast-1]==null) OLast--; if (Gap>=OLast) Gap=-1; }
4054c216-11dc-4f72-8b56-2989c3326e7e
5
public int getInventorySlot(int x,int y){ int totalSlots = player.getInventorySize(); //needed so that it draws in the right position. Placeholder. int offsetY = 285; int offsetX = 52; for(int i = 0; i<totalSlots;i++){ //if the mouse is in the x bounds of one of the inventory slots if(x > inventory...
28ef399d-7ee4-4fc5-a8f2-e1362275fe22
7
public static int discrete(double[] a) { double EPSILON = 1E-14; double sum = 0.0; for (int i = 0; i < a.length; i++) { if (!(a[i] >= 0.0)) throw new IllegalArgumentException("array entry " + i + " must be nonnegative: " + a[i]); sum = sum + a[i]; } if (su...
26030972-483f-497c-aff8-f45f5c8ef5ec
2
@Override public void actionPerformed(ActionEvent e) { if (e.getSource()==subsectionButton1) {//add a question ChooseQuestionsPanel chooseQuestionsPanel=new ChooseQuestionsPanel((SubsectionPanel)this); chooseQuestionsPanel.setVisible(true); }if (e.getSource()==subsectionButto...
d8ecee23-c1e2-4a10-af04-b56f1905318a
4
private void killPlayer(String filename) { synchronized(this) { if(musicPlayer != null && filename.contains("music/")) { musicPlayer.stop(); musicPlayer = null; } else if(soundPlayer != null && filename.contains("sounds/")) { s...
de0fcab5-b08c-4708-b608-4a23b08b1c70
2
public synchronized static void timeAppendTextPane(Color color, String message, JTextPane box) { //Autodo it and build it like normal StyledDocument doc = box.getStyledDocument(); Style style = box.addStyle("style", null); StyleConstants.setForeground(style, color); box.setCa...
04ab65d9-78c1-4dac-aa9a-f0d044499524
2
public void close(){ try{ this.fileChannel.close(); this.fileOutputStream.close(); }catch(Exception e){ e.printStackTrace(); try{ this.fileChannel.close(); this.fileOutputStream.close(); }catch(Exception e1){ e1.printStackTrace(); } } }
c2d86a94-bef9-4bcc-9c3b-99814e93e491
0
@Test public void MaaliEste() { assertTrue("Este oli väärän tyyppinen", t.onkoPisteessaEste(new Piste(350, 350)) == EsteenTyyppi.MAALI); }
fabffe28-dd40-4f44-b059-330cb4d9ea39
5
List<PlayerQuizInstance> determineQuizWinner(List<PlayerQuizInstance> quizPlayInstances) { PlayerQuizInstance maxScore = null; List<PlayerQuizInstance> winners = new ArrayList<PlayerQuizInstance>(); if (quizPlayInstances.isEmpty()) { return winners; } maxScore = Colle...
f538b537-91f9-4af5-8af0-3bb4b61cc2da
2
public static void main(String[] args) throws InterruptedException { Training[] mytn = new Training[1000]; Semaphore mutex = new Semaphore(1); for(int i=0; i < mytn.length; i++) { mytn[i] = new Training(mutex); mytn[i].start(); } for(int i=0; i < mytn.length; i++) { mytn[i].join(); } Sys...
905c0d21-5ae5-4796-bd64-8df7b327ec5b
5
static public ArrayList<Integer> MostFrequentInt (ArrayList<Integer> input) { Hashtable<Integer,Integer> table = new Hashtable<Integer,Integer>(); ArrayList<Integer> result = new ArrayList<Integer>(); if (input.size() == 0) return result; for(Integer i:input) { if (table.containsKey(i)) table.pu...
6dc886d8-7239-40ea-97cc-55fae7385185
1
@Override public int attack(double agility, double luck) { if(random.nextInt(100) < luck) { System.out.println("I just sacrified that monster!"); return random.nextInt((int) agility) * 4; } return 0; }
bf13fe25-8092-4716-a7c3-816f30fcb64a
0
public void remove() { throw new UnsupportedOperationException(); }
364bf9d4-a840-4f19-a320-572365bf4547
7
public void updateTable() { System.out.println("Row: " + tableCheckin.getRowCount()); System.out.println("Col: " + tableCheckin.getColumnCount()); for (int row = 0; row < tableCheckin.getRowCount(); row++) { for (int col = 0; col < tableCheckin.getColumnCount(); col++) { getCheckinModel().setValueAt(null, ...
1ccd612d-6ea8-4898-a9b0-ab1f08528880
5
public Map<String,Integer> bag_of_words(){ //System.out.println("======================="); HashMap<String,Integer> bag = new HashMap<String,Integer>(); for(java.util.Map.Entry<String, String> entry : this.entrySet()){ if(entry.getKey()=="Name" || entry.getKey()=="Birthday" ) cont...
ff0e95f3-0fb9-4375-8ff7-eff9b5c2752b
9
public boolean skipPast(String to) throws JSONException { boolean b; char c; int i; int j; int offset = 0; int length = to.length(); char[] circle = new char[length]; /* * First fill the circle buffer with as many characters as are in the ...
64f5d271-bef3-4466-b746-f45ce9d3b152
2
public LinkInfo setLocalBasePath(String s) { if (s == null) return this; localBasePath = s; if (vid == null) vid = new VolumeID(); lif.setVolumeIDAndLocalBasePath(); return this; }
11fa0ed4-9041-42de-81a6-708cd67019d5
8
private Vector find_smallest_zones( Vector zone_list, int start, int length) { if(zone_list == null) { zone_list = new Vector(); } else { zone_list.setSize(0); } int end = start + length; start = skipSpaces(textByteArray, start, length); end = f...
9aaeddbe-8fd5-47da-b449-33531b870000
7
public static Tile getNewTileFromColor(int color) { Tile tile = null; switch (color) { case SandTile.COLOR: tile = new SandTile(); break; case UnbreakableRailTile.COLOR: tile = new UnbreakableRailTile(new FloorTile()); break; case UnpassableSandTile.COLOR: tile = new UnpassableSandT...
e02bd4af-9ebe-4157-b91c-8d38e538d3ae
2
public void push(int in) { if (!isEmpty() && in > top()) { ++totalRejected; } else { super.push(in); } }
8496e216-f46e-4fa7-8b66-c8ae674e7a9d
6
@EventHandler public void EndermanHeal(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getEndermanConfig().getDouble("Enderman.Heal...
b92d9e39-0272-408f-90fd-42675b7e63d3
1
public static boolean isCached(String name) { if (cache.containsKey(name)) return true; return false; }
f04a9c66-5465-43e9-9ad9-4991618d9137
6
private void updateStateTellWholeRecipe(List<Keyword> keywords, List<String> terms) { //If we came here due to a keyword, there should be a recipe keyword, or the recipe has been set if (keywords != null && !keywords.isEmpty()) { for (Keyword kw : keywords) { if (kw.getKeywordData().getType().equals((KeywordTy...
4af78892-703e-42a3-9cca-8652b384e262
9
public Behaviour jobFor(Actor actor) { if (! structure.intact()) return null ; if (numPatients() == 0 && ! personnel.onShift(actor)) return null ; final Choice choice = new Choice(actor) ; // // Manufacture Stim Kits for later use- final Manufacture mS = stocks.nextManufacture(actor, MEDICINE_T...
fa74d052-a7a3-4360-b2df-5e5e24058fff
8
public MOB getHighestLevelMOB(MOB meMOB, Vector<MOB> not) { if(meMOB==null) return null; final Room R=meMOB.location(); if(R==null) return null; int highestLevel=0; MOB highestMOB=null; final Set<MOB> H=meMOB.getGroupMembers(new HashSet<MOB>()); if(not!=null) H.addAll(not); for(int i=0;i<R.num...
28f4b0b5-d8ba-44c6-a6ef-76f6b071e0c9
2
public CommandGroup addCommands(Command... command) { for(Command c : command) { if(c instanceof CommandGroup) { ((CommandGroup)c).parent = this; } commands.add(c); } return this; }
f8df96db-44bc-4393-b541-4c9b5c282e72
9
int insertKeyRehash(char val, int index, int hash, byte state) { // compute the double hash final int length = _set.length; int probe = 1 + (hash % (length - 2)); final int loopIndex = index; int firstRemoved = -1; /** * Look u...
46e9af8a-db5a-406b-baa9-b4a5d20fa794
4
public static boolean isBlank(String str) { int strLen; if (str == null || (strLen = str.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if ((Character.isWhitespace(str.charAt(i)) == false)) { return false; } } return true; }
81a16e0d-32eb-4ca6-a6ed-f5ea28d006c8
6
private static Integer castInt(Object o) { if (o == null) { return null; } else if (o instanceof Byte) { return (int) (Byte) o; } else if (o instanceof Integer) { return (Integer) o; } else if (o instanceof Double) { return (int) (double) (...
93e90779-8827-4412-a0e3-12c6493babea
4
public static void checkUserFolder() { File f = new File(userFolderPath()); if (!f.exists() || !f.isDirectory()) { f.mkdir(); } f = new File(modulesFolderPath()); if (!f.exists() || !f.isDirectory()) { f.mkdir(); } }
7183729d-fb53-4e83-aee0-bad2c42d0ff5
2
public static String base16ToStr(String bytes) { if (StringUtil.isNullOrEmpty(bytes)) return ""; ByteArrayOutputStream baos = new ByteArrayOutputStream(bytes.length() / 2); // 将每2位16进制整数组装成一个字节 for (int i = 0; i < bytes.length(); i += 2) baos.write((HEX.indexOf(...
7d562f5c-6a3a-4abb-bd8e-2092583533e4
1
public int getDirectionToward(Location target) { int dx = target.getCol() - getCol(); int dy = target.getRow() - getRow(); // y axis points opposite to mathematical orientation int angle = (int) Math.toDegrees(Math.atan2(-dy, dx)); // mathematical angle is counterclockwise f...
e5097241-c64a-4d56-a904-35b6fd74fd7c
7
public static void commandAvatar(Player p, Command command) { if (playersInAvatarState.contains(p)) { if (command.getName().equalsIgnoreCase("airBend")) { //airBend(p); } if (command.getName().equalsIgnoreCase("earthBend")) { earthBend(p); } if (command.getName().equalsIgnoreCase("metalBend")) {...
57570692-8595-43df-a391-0adc21f65138
3
@Override public void addMedicine(MedicineDTO medicine) throws SQLException { Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); session.save(medicine); session.getTransaction().commit()...
53a92bb8-ba0a-42f7-aab8-099b0d7eae6b
3
private void piirraTausta(Graphics graphics) { /** * Ao. yhtälöissä jakolasku johtuu siitä että halajamme viivoihin mageen * parallaksiefektin. * * Ja jooooo for-loopin pituus on kovakoodattu, eli jos pelaaja menee * tarpeeksi kauas vasemmalle, oikealle, ylös tai ala...