method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
7464810c-fdbf-458b-b516-31c8c7466831
1
public void grab(Boolean hasGold) { this.performance = this.performance -1; if (hasGold) { this.performance = this.performance + 1000; this.setState(WumpusConsts.STATE_GOAL); } }
de8288d7-6ec9-4a62-be2a-d8da74013dec
0
@Override public void addQuestAnswer(String answ) { questAnswer.add(answ); }
74916138-05ea-4583-93f1-bb72b1f7768d
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...
26d597c0-be6a-453b-af96-d4780ced758b
1
private JTextField getJTextField0() { if (jTextField0 == null) { jTextField0 = new JTextField(); } return jTextField0; }
130bd09c-8b18-4d6b-9252-1d76870fc380
7
public final byte[] readBytes(final int amount) throws FileNotOnDiskException, DiskReadException { checkExists(); byte[] buffer = new byte[FILE_READ_BUFFER_SIZE]; final List<Byte> list = new ArrayList<Byte>(); int totalRead = 0; BufferedInputStream reader = null; try { reader = new BufferedInputStream(ne...
67730d53-099d-4a8f-8759-517278995b93
3
public static void main(String[] args) throws InterruptedException { SimpleCreature adam = new SimpleCreature(100.0); List<SimpleCreature> list = new ArrayList<SimpleCreature>(); list.add(adam); List<SimpleCreature> newBorn; while (true) { newBorn = new ArrayList<Simp...
4754ec0c-3481-402c-aa49-a976f5424c48
2
private void pruneBeam(ArrayList<SegResult> beam, ArrayList<SegResult> candidates) { // TODO Implement pruning properly for (SegResult candidate : candidates) { if (beam.size() < beamSize) { beam.add(candidate); } } }
78eefb17-7183-4d21-bc54-f4e04ec34f92
4
@Override public void run() { while (true) { try { Thread.sleep(2000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } for (String b : Network.res.keySet()) { if (Calendar.getInstance().getTimeInMillis()/1000 - Network.res.get(b).time > 15){ ...
b109cb30-276a-4bc6-a138-c6552643e43c
9
@Override public boolean containsDrink() { if((!CMLib.flags().isGettable(this)) &&(owner()!=null) &&(owner() instanceof Room) &&(((Room)owner()).getArea()!=null) &&(((Room)owner()).getArea().getClimateObj().weatherType((Room)owner())==Climate.WEATHER_DROUGHT)) return false; if(liquidRemaining()<1) { ...
6971b3ee-b48a-432c-99b7-a95245331fa0
7
public Set<Map.Entry<Long,V>> entrySet() { return new AbstractSet<Map.Entry<Long,V>>() { public int size() { return _map.size(); } public boolean isEmpty() { return TLongObjectMapDecorator.this.isEmpty(); } public bool...
1d2e2904-1d09-4fff-b73a-d981a8c24027
8
public static void keyReleased(KeyEvent keyEvent) { Iterator<PComponent> it = components.iterator(); while(it.hasNext()) { PComponent comp = it.next(); if(comp == null) continue; if (shouldHandleKeys) { if (comp.shouldHandleKeys()) ...
7dc02562-4400-4d78-809e-5c98b479cead
4
private Object handleCaln(Object tos) { if ((tos instanceof RepositoryRef && ((RepositoryRef)tos).getCallNumber() == null) || (tos instanceof Source && ((Source)tos).getCallNumber() == null)) { return new FieldRef(tos, "CallNumber"); } return null; }
2b9e89b6-c9b1-4a45-93bb-eb3c36c114b3
8
public Component getTreeCellRendererComponent( JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus ) { if ( value instanceof LeafNode ) { JPanel panel = new JPanel(); String text = ( ( (LeafNode) value ).getItem() ).toStri...
5b64cb6f-560e-4c20-8d0c-bb7e41db415e
3
private void loadDataFromFile(String file, InstanceType type) throws IOException { FileReader fr = new FileReader(file); BufferedReader br = new BufferedReader(fr); ArrayList<Double> features = new ArrayList<Double>(); String line = null; while((line = br.readLine()) != null) { String[] tks = line.trim...
2f913ef7-9e59-4aa5-89a2-81637eb02a91
2
public static StringBuffer[] createScoreTemplate() { StringBuffer[] scoreLine = new StringBuffer[2]; for (int i = 0; i < scoreLine.length; i++) { scoreLine[i] = new StringBuffer(); } scoreLine[0].append(IConstants.SCORE_TABLE_TEMPLATE); scoreLine[1].append(IConstants.SCORE_TABLE_TEMPLATE); for (int i =...
3c3e9da4-805a-4e55-b21b-b529cdf58307
6
public String toPrettyString() { PaddingStringBuilder output = new PaddingStringBuilder(); // Settings section PaddingStringBuilder.PaddingSection settingsSection = new PaddingStringBuilder.PaddingSection(true); output .append(" | ").append(settingsSection, "Score limit: ").append(scoreLimit) .append("\...
11a44faf-1b03-4484-afca-e8d97f7aa0ff
3
public boolean isEmptySpace () { int i = 0, j = 0; for (i = 0; i < 16; i++) { for (j = 0; j < 16; j++) { if (entries[i][j].getText().equals("")) { System.out.println("isEmptySpace() returned false at i: " + i + " j: "+j); return false; } } } return true; }
8b4faa52-b622-4725-853e-ca06396aca9c
3
String factorStr() { if (factor > 1000000000) return factor / 1000000000 + "Gb"; if (factor > 1000000) return factor / 1000000 + "Mb"; if (factor > 1000) return factor / 1000 + "Kb"; return factor + "b"; }
2ca9b8b8-87b0-4791-a10e-75a92022208d
8
public static void main(String args[]) throws IOException, InterruptedException { /* 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 fee...
d4a39d2e-6c68-4ca0-967c-7651f0924ecd
7
public Comparable<?> getValue(ResultSet rs) throws Exception { if("int".equals(dataType)) { return rs.getInt(columnName); } if("bigint".equals(dataType)) { return rs.getLong(columnName); } if("nchar".equals(dataType)) { return rs.getString(colu...
67b8f024-2787-4150-862e-775aa2370a60
9
public Move move(boolean[] foodpresent, int[] neighbors, int foodleft, int energyleft) throws Exception { Move m = null; // placeholder for return value // this player selects randomly int direction = rand.nextInt(6); switch (direction) { case 0: m = new Move(STAYPUT); break; case 1: m = new Move(WES...
7c7edca0-5109-48ca-b063-7f0213e8c341
9
protected InputStream getConnectionInputStream(final URLConnection urlconnection) throws DownloadException { final AtomicReference<InputStream> is = new AtomicReference<InputStream>(); for (int j = 0; (j < 3) && (is.get() == null); j++) { StreamThread stream = new StreamThread(urlconnection...
47ef9516-2e09-4d97-b0a8-14f252ef94ad
0
@Override public void attributesVisibilityChanged(OutlinerDocumentEvent e) {}
5c21ac5e-7535-4630-96cb-6b1084805cf5
3
@SuppressWarnings ("unchecked" ) @Override public boolean retainAll( Collection<?> collection ) { final int previousSize = trie.size(); final Trie<E, Object> newTrie = trie.newEmptyClone(); for (Object element : collection) { if (trie.containsKey( element )) { ...
aa8a580a-f020-4f07-b9d4-c9cf25cd5528
0
protected boolean test5 () { return true; }
b7493459-ca06-4980-bc96-e9815eb51bd4
1
public static void copyFile(String src, String dest, boolean keepDate) throws UtilException { try { FileUtils.copyFile(new File(src), new File(dest), keepDate); } catch (IOException e) { throw new UtilException("拷贝文件失败", e); } }
93d441fa-9b08-4310-8db9-483b95a69d1e
8
public static final void SpawnPet(final SeekableLittleEndianAccessor slea, final MapleClient c, final MapleCharacter chr) { slea.skip(4); final byte slot = slea.readByte(); final IItem item = chr.getInventory(MapleInventoryType.CASH).getItem(slot); switch (item.getItemId()) { case 5000047: case 5000028: ...
55edc8ca-70de-4402-957e-09a6fe38f65f
3
private int find_index( int index, int target ){ // divide weight into three groups: Self, Son & Daughter, and test each // Testing self int sum = tree.elementAt(index).chance_weight; if( target < sum ) { return index; // found within self } // else outside self, must be in child...
49c10086-18aa-44b7-a48e-ef25d02006f8
5
void processUnixWay(String argChars, String[] args, boolean shouldFail) { GetOpt getopt = new GetOpt(argChars); int errs = 0; char c; while ((c = getopt.getopt(args)) != 0) { if (c == '?') { ++errs; } else { Debug.println("getopt", "Found " + c); //if (getopt.optarg() != null) // System...
703f7001-8a3a-4b13-a0d0-4ee9bae5b6db
9
private void findCaptureArea(int x, int y, int owner) { if(!isOnMap(x, y)) { return; } if(map[x][y].owner == owner) { return; } boolean mask[][] = new boolean[getXSize()][getYSize()]; for(int i = 0; i < getXSize(); i++) {...
482e40ec-8936-46d5-8f03-967477a7fc78
0
@Test(expected = RuntimeException.class) public void itShouldFailOnAddInteriorRingWithoutExteriorRing() throws Exception { Polygon polygon = new Polygon(); polygon.addInteriorRing(MockData.EXTERNAL); }
b038f147-39f9-40d2-837b-e60608c57d3c
6
public int cdlMorningDojiStarLookback( double optInPenetration ) { if( optInPenetration == (-4e+37) ) optInPenetration = 3.000000e-1; else if( (optInPenetration < 0.000000e+0) || (optInPenetration > 3.000000e+37) ) return -1; return ((( ((( (this.candleSettings[CandleSettingType.B...
73b9c3e6-9f74-4717-9a7c-63d8af93d01f
8
@Override public SQLResult executeSqlQuery(String query) throws Exception { Session session = null; Transaction trx = null; SQLResult result = new SQLResult(); try { session = sessionFactory.openSession(); trx = session.beginTransaction(); PreparedStatement statement = session.connection().prep...
1c96effa-1f44-4c08-953f-30d56f87d429
3
private static TreeMap<String, Tuple<BufferedImage, Integer>> loadTilesetFile(String tilesetFilename) { try { Scanner reader = new Scanner(new FileReader("Resources/Tilesets/" + tilesetFilename)); TreeMap<String, Tuple<BufferedImage, Integer>> tileMap = new TreeMap<String, Tuple<BufferedImage, Integer>>(); w...
47e1b8d1-faaa-4452-8e2a-fcfc081fc858
6
static final void method2554(byte i) { if (i != -45) anInt4032 = 61; anInt4030++; if (Class312.anInt3931 == 1 || Class312.anInt3931 == 3 || (Class312.anInt3931 != Class83.anInt1447 && ((Class312.anInt3931 ^ 0xffffffff) == -1 || Class83.anInt1447 == 0))) { Class348_Sub32.anInt6930 = 0; Cla...
1bcbce47-1f2c-4f3a-a7f2-aff313e865ee
9
public ChannelLPC(BitInputStream is, Header header, ChannelData channelData, int bps, int wastedBits, int order) throws IOException { super(header, wastedBits); this.order = order; // read warm-up samples //System.out.println("Order="+order); for (int u = 0; u < order; u++) { ...
c024795c-28f5-4462-b391-26d6bb933d04
4
private int[] exploreNextMove() { for (int col = 0; col < 7; col++) { if (board.validateStep(col)) { int row = board.availableSpace(col); if (board.checkConnectFour(player1, row, col) || board.checkConnectFour(player2, row, col)) { return new int[] { row, col }; } } } return new int[]...
98410f1d-ac73-4546-892c-5967979e708d
1
private String getDecodedParameterKey() throws IOException { String[] splitOnMark = requestArray[1].split("\\?"); try { String parameters = splitOnMark[1]; String paramsWithSpace = parameters.replaceAll("=", " = "); String paramsWithAmpSpace = paramsWithSpace.replaceAll("&", " "); retur...
d6517ca1-8c15-4b48-9e45-194d66cb39e6
3
public void insertUser() { PreparedStatement st = null; String q = "INSERT INTO users SET email= ?, password = MD5(?), first_name = ?, last_name = ?"; try { conn = dbconn.getConnection(); conn.setAutoCommit(false); st = conn.prepareStatement(q); st...
ebeb16f7-2324-4a76-bb37-0208983d162f
3
@Override public void onAudioSamples(IAudioSamplesEvent event) { if (sectionIterator < randomSections.size()) { VideoSection currentSection = randomSections.get(sectionIterator); Long timeStamp = event.getTimeStamp(currentSection.getTimeUnit()); if (currentSection.getStart() < timeStamp) { if (cur...
52192827-c100-4d66-85d5-c77c85384249
2
public final void onWebsocketClose( WebSocket conn, int code, String reason, boolean remote ) { selector.wakeup(); try { if( removeConnection( conn ) ) { onClose( conn, code, reason, remote ); } } finally { try { releaseBuffers( conn ); } catch ( InterruptedException e ) { Thread.currentTh...
fb8a232d-7f9c-49c5-9800-37ef3378abf6
2
public void restoreItem(T item) { for (TimeOutListItem<T> listItem : this.list) { if (listItem.equals(item)) { listItem.restore(); this.list.remove(listItem); break; } } }
1bd20a7d-765e-4ed1-ba84-9fe6e2f5c310
5
public RegisterWidget() { this.setTitle("Register a UniChat Account"); this.setWidth("50%"); this.setHeight("50%"); this.setShowMinimizeButton(false); this.setIsModal(true); this.setShowModalMask(true); this.centerInPage(); this.setAlign(Alignment.CENTER); ...
94818409-4c87-4600-a58f-068923523169
1
private void stopServer_adbMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopServer_adbMenuActionPerformed try { adbController.stopServer(); } catch (IOException ex) { logger.log(Level.ERROR, "An error occurred while stopping the ADB server!"); ...
84040a24-c01c-4bcb-9322-a26e712ffb1c
9
public static Ball probe(Ball ball, int boxSize, int shiftIncrement, Rectangle2D.Double acceptQuadrant){ Cardinal direction = Cardinal.NORTH; Ball probe = new Ball(new Point2D.Double(ball.getCenterPoint().getX(), ball.getCenterPoint().getY()), ball.getVelocity(), ball.getSpeed(), MyColor.BLACK); //displace the in...
4060a767-3068-4a61-8979-d329379e932a
2
public int RowCount() { try { ResultSet Result = Statement.executeQuery(ClassQuery); return (Result.last() ? Result.getRow() : 0); } catch(SQLException E) { Grizzly.WriteOut(E.getMessage()); return 0; } }
224aba25-eb73-480f-91aa-3f08ab54e490
6
public static void setGamemode(Player player, String playerName, String gamemodePlayerName, String gamemode) { ArrayList<Player> gamemodePlayers = AdminEyeUtils .requestPlayers(gamemodePlayerName); if (gamemodePlayers == null && gamemodePlayerName != null) { StefsAPI.MessageHandler.buildMessage().addSend...
d12d6c82-95cd-4412-8052-a95300ae760c
9
public Value unaryOperation(final AbstractInsnNode insn, final Value value) { int size; switch (insn.getOpcode()) { case LNEG: case DNEG: case I2L: case I2D: case L2D: case F2L: case F2D: case D2L: ...
58075c68-a918-40d0-bfd8-df04eda719b0
0
public OSCPortIn(int port) throws SocketException { super(new DatagramSocket(port), port); }
1d0bca46-5e27-40cb-ae30-d7462c537ebe
9
public static FastStringBuffer decimalToString(BigDecimal value, FastStringBuffer fsb) { // Can't use the plain BigDecimal#toString() under JDK 1.5 because this produces values like "1E-5". // JDK 1.5 offers BigDecimal#toPlainString() which might do the job directly int scale = value.scale(); ...
068d770a-eef9-4348-99c3-821e3cbf2653
0
public void initTable(ITable subtable) { _table = subtable; updateTable(); }
e7cf38af-513b-48e1-9fef-192e780d2f0e
3
IMySQLConnection getConnection() throws SQLException { System.out.println("Connections: " + conns.size()); ++cullTicker; if(cullTicker > CULL_SCHEDULE) { cullTicker = 0; cullConnections(); } for (IMySQLConnection conn : conns) { if(conn.isAvailable()) { return conn; } } return a...
5eb72edb-d565-428b-827f-e39b027ffafb
7
@Override public boolean shadow_hit(Ray ray, FloatRef tmin) { float ox = ray.getOrigin().getX(); float oy = ray.getOrigin().getY(); float oz = ray.getOrigin().getZ(); float dx = ray.getDirection().getX(); float dy = ray.getDirection().getY(); float dz = ray.getDirecti...
37fc745b-3d48-4121-aca8-7a43eda13433
6
private Color setclr(int i){ if(i == 0){ return Color.BLUE; } else if(i == 1){ return Color.RED; } else if(i == 2){ return Color.GREEN; } else if(i == 3){ return Color.ORANGE; } else if(i == 4){ return Color.YELLOW; } else if(i == 5){ return Color.PINK; } else{ return Colo...
c165036e-2432-404a-9e09-c5111333d7c5
5
@EventHandler(priority = EventPriority.NORMAL) public void onBlockPlace(BlockPlaceEvent event) { if (event.isCancelled()) return; Player player = event.getPlayer(); Block block = event.getBlock(); if (plugin.isLifestone(block) == true) { if (!(player.hasPermission("lifestones.breaklifestone"))) { ...
d3bb8e0a-c35a-45b1-98ae-1717e1d4c61c
3
public void run() { try { voyageHandler voyhandlr = new voyageHandler(); SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); hc = (HttpConnection) Connector.open("http://localhost:8080/smartPhp/getXmlAnnonce.php?id="+selectedAnn); dis = new DataInpu...
24a00d97-5a62-4666-8d9d-21358cea9784
4
public static boolean startsWithIgnoreCase(String str, String prefix) { if (str == null || prefix == null) { return false; } if (str.startsWith(prefix)) { return true; } if (str.length() < prefix.length()) { return false; } String lcStr = str.substrin...
af3b5550-1e49-4afe-8b98-58646d8845f4
7
String checkSecurity(int iLevel, javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServletRequest request){ try { Object o1 = session.getAttribute("UserID"); Object o2 = session.getAttribute("UserRights"); boolean bRedirect = false; ...
90a89372-81d0-4926-b448-99b4f26a5963
3
private int computeHeight(TPoint[] points) { int maxY = points[0].y; int minY = points[0].y; for (int i = 1; i < points.length; i++) { TPoint currentPoint = points[i]; if (currentPoint.y > maxY) maxY = currentPoint.y; if (currentPoint.y < minY) minY = currentPoint.y; } // + 1 is to account for d...
a9fb1d6c-0f72-4163-8eb9-adc506a4c8ab
2
public int getGroundDecorationUid(int z, int x, int y) { GroundTile groundTile = groundTiles[z][x][y]; if (groundTile == null || groundTile.groundDecoration == null) { return 0; } else { return groundTile.groundDecoration.uid; } }
95f3d7c4-85e4-4379-a238-087160ec357b
0
public DocumentEvent(Document doc) { setDocument(doc); }
8cbd6d95-a70b-447f-bd24-2581a0bf1c7c
3
public Shape getShape(String shapeName) { // Java 8 can use Strings in switch. switch (shapeName) { case "CIRCLE": return new Circle(); case "RECTANGLE": return new Rectangle(); case "SQUARE": return new Square(); default: return null; } }
149051f8-79dd-4a22-9829-d11e54020d97
5
public static String GetAuthToken(String username, String password) { try { CookieManager m = new CookieManager(); CookieHandler.setDefault(m); URL u3 = new URL("http://www.havenandhearth.com/portal/login"); HttpURLConnection connection3 = (HttpURLConnection) u3 ...
b03577f7-9571-41fb-ac0a-251b1d790551
1
private static void loadRankURIs(URL[] URLs, String urlBase) { for (int i = 0; i < 13; i++) { URLs[i] = ImageManager.class.getResource(urlBase + i + ".svg"); } }
75b96db7-67c9-40e7-b2f9-7d2487903da7
0
public static int d_mht(final int n) { return (int) Math.ceil(log(log(n,2)+1,2)); }
6702d9c4-e6f6-4e0f-8810-6ba179e4342c
4
public static String getText(Categories category) { switch (category) { case SHOES: return "Ботинки"; case SHIRTS: return "Футболки"; case CAPS: return "Головные уборы"; case PANTS: return "Штаны"; ...
d885520c-a447-4f12-aa6c-b355d0a1dba7
3
private void addNode(Position pos, GameNode node) { if(pos.x<mapSize) throw new RuntimeException("X выходит за границы игровой карты"); if(pos.y<mapSize) throw new RuntimeException("Y выходит за границы игровой карты"); node.setPosition(pos); ArrayList<GameNode> col = mainMa...
ba54d0cc-906b-4f97-ac06-cccce8426849
4
private void addVessel(Map<String, EnumElement> board, EnumLine line, EnumColumn column, boolean vertical, EnumElement vessel) throws InvalidPositionException { if (this.validatePosition(line, column, vertical, vessel)) { if (this.notOverrideVessel(board, line, column, vertical, vessel)) { final int ini...
5386d653-f913-4d46-8864-284177e95ee7
9
private int alpha_beta(BoardNode root,int a, int b, int d) { int i,var; BoardNode tmp; if(d==0){/*if reach the max depth, return the static value */ var = this.evaluator.Evaluate(root, this.myClr); return var; } if (root.isMAX){/*for max node*/ for(i=0;i<7;i++) { if((tmp=root.NewNode(i)...
50ae0be3-f4f6-44ee-8d21-69eb4434d365
9
static void Pixel(osd_bitmap bitmap, int x, int y, int spr_number, int color) { int xr, yr, spr_y1, spr_y2; int SprOnScreen; if (x < Machine.drv.visible_area.min_x || x > Machine.drv.visible_area.max_x || y < Machine.drv.visible_area.min_y || y > ...
a0cb6d89-06ba-4084-ac86-c51ed3238116
2
private String Complement(String binaryString) { StringBuilder complementBuilder = new StringBuilder(binaryString); for(int i = 0; i < binaryString.length(); ++i) { char flip = binaryString.charAt(i) == '0' ? '1' : '0'; complementBuilder.setCharAt(i, flip); } return complementBuilder.toString(); ...
c7c884c6-5663-417c-9a33-17f71ca24764
1
public boolean removeModerator(String subForumId, User invoker, User moderator) { if (!invoker.hasPermission(Permissions.REMOVE_MODERATOR)) return false; getSubForumById(subForumId).removeModerator(moderator); save(); return true; }
2976fe12-2010-42e5-9c61-e1219a91c65a
5
private void AIteleport() { if (ball.getX() < 100 && ball.getVx() > 0) { if (tempBallReturned + 1 == player1.getBallReturned() && tempBallReturned != 0) { if (player2.useTeleport()) { createTeleport(); tempBallReturned = 0; } ...
f9083b49-8782-481b-bffb-5e47b487c744
0
public PersonHistory(Person P) { setIconImage(Toolkit.getDefaultToolkit().getImage(PersonHistory.class.getResource("/InterfazGrafica/Images/1418023120_Program-Group.png"))); getContentPane().setBackground(new Color(248, 248, 255)); setBounds(10, 50, 836, 739); getContentPane().setLayout(null); contentPanel.se...
2faa6fa8-2a46-4c5f-8623-be372406b44a
8
@Override public boolean add(T e) { if (e == null) throw new RuntimeException("Does not permit nulls"); int hash =e.cuckooHash(); int hash2 = e.cuckooHashTwo(); int hash3 =e.cuckooHashThree(); hash =hash & mask; hash2 =hash2 & mask; hash3 =hash3 & mask; //inlining for performance. makes add about 2...
00c206ee-5510-4f6f-9b42-2f2f81edc085
3
@SuppressWarnings("unused") @Deprecated private ComplexMatrix strassenMultiply(ComplexMatrix mx) { int n = getRowsNum() / 2; // 0 1 2 3 ComplexMatrix[] m1 = divideMatrixIntoFour(n, n); // a b c d ComplexMatrix[] m2 = mx.divideMatrixIntoFour(n, n); // e f g h if (m1[0].getColsNum...
aa511f6f-b6d8-43c3-a5c2-23ed8a2e55e0
7
private void process() { boolean inEpsilonRange = false; int i = 0; double error = 0; Vector prevV = v; while (i < iterations && !inEpsilonRange) { i++; v = MatrixOps.toVector(A.multiply(v)); if (v.get(1) < 0) { v = v.multiply(-...
8450fd07-fc89-4209-a6d4-8a91c2ba0840
9
private void computeMatch() { /* Phase 1 */ for (int j = 0; j < match.length; j++) { match[j] = match.length; } //O(m) computeSuffix(); //O(m) /* Phase 2 */ //Uses an auxiliary array, backwards version of the KMP failure function. //suffix[i] = the smallest j > i s.t. p...
58e9f34d-218e-4b20-877b-6306222c6cd9
3
void doHit() { if (gameInProgress == false) { message = "Click \"New Game\" to start a new game."; repaint(); return; } playerHand.addCard( deck.dealCard() ); if ( playerHand.getBlackjackValue() > 21 ) { message = "You've busted! Sorry, you lose."; ...
98e0da43-2353-4d95-a7d7-a0ddb2ce5a04
0
public double getRadius() { return radius; }
6edf7a68-4be1-43c5-a2d2-381e3f7e4483
2
public void testPropertyCompareToHour() { LocalDateTime test1 = new LocalDateTime(TEST_TIME1); LocalDateTime test2 = new LocalDateTime(TEST_TIME2); assertEquals(true, test1.hourOfDay().compareTo(test2) < 0); assertEquals(true, test2.hourOfDay().compareTo(test1) > 0); assertEquals...
32e33be7-bc63-43b4-b128-14ab87c8f3e9
0
public void setCount(int count) { this.count = count; }
dc95393a-cb50-432f-84d3-ccbe1dc01572
5
public static byte[] constructPacket(HostRecord hostRecord, int txnId) throws Exception { // calculate packet length String host = hostRecord.getDomainName(); ArrayList<IPAddress> ipAddresses = hostRecord.getIpAddresses(); int headLen = 12; String hostParts[] = host.split("\\."); int questionLen = 5; for ...
1cec5856-b4c3-44f8-9959-4e1102ca5a87
5
public Image getAvatarAsImage(int px) { switch(px) { case 16: return new ImageIcon(gravatar_16px).getImage(); case 32: return new ImageIcon(gravatar_32px).getImage(); case 64: return new ImageIcon(gravatar_64px).getImage(); case 128: return new ImageIcon(gravatar_128px).getImage(); case 256: return new...
17ff653c-7a10-4c7d-8f1e-0a045c374efc
8
public String getAnswer(){ long answer = 0; for(int x = 0; x < 20; x++){ long currentLoop = 1; for(int i = 0; i < 37; i++){ for( int y = 0; y < 13; y++){ char theNum = NUM.charAt((50 * x) + i + y); long number = theNum; currentLoop *= number; } i...
e1f39636-3bde-4ae4-b2fc-feba5c8a4037
7
private void addFeatDialog() { JLabel nameLabel = new JLabel("Feat name"); nameLabel.setAlignmentX(Component.LEFT_ALIGNMENT); JTextField nameField = new JTextField(); nameField.setAlignmentX(Component.LEFT_ALIGNMENT); JLabel descLabel = new JLabel("Feat description"); d...
7646e1ce-fdc3-4c3c-9efa-07214b0e412b
1
public static void configureStandardUI() { System.setProperty("apple.laf.useScreenMenuBar", Boolean.TRUE.toString()); //$NON-NLS-1$ try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) { ex.printStackTrace(System.err); } }
116be7f4-af23-4685-92c8-64477e083dff
7
public List<Integer> match(String pattern, String text) { List<Integer> matches = new ArrayList<Integer>(); int m = text.length(); int n = pattern.length(); Map<Character, Integer> rightMostIndexes = preprocessForBadCharacterShift(pattern); int alignedAt = 0; while (align...
afac2601-5a5e-4538-8518-c8e292df4ec0
4
@Override public void paintComponent(Graphics g) { List<BeeHive> beeHiveList = _temporaryEnvironment.getBeeHives(); for (BeeHive f : beeHiveList) { g.setColor(new Color(255, 0, 0)); g.fillOval( (_fieldSizeX / 2) * _fieldScaleFactor + (((f.getPosition().x * _fieldScaleFactor) - 5) + 15), (_f...
8bdc4930-1b01-4fa5-bf74-bd0e8765059c
3
private void checkForPeakY(double y) { if (isUpPeakY) { if (y < lastY) { peakY = lastY; isUpPeakY = false; } } else { if (y > lastY) { peakY = lastY; isUpPeakY = true; } } lastY = y; }
b43a526d-dbe8-4ce2-b18b-36837e5eb0d1
7
public boolean isScramble(String s1, String s2) { if (s1.equals(s2)) { return true; } char[] one = s1.toCharArray(); char[] two = s2.toCharArray(); Arrays.sort(one); Arrays.sort(two); if (!Arrays.equals(one, two)) { return false; } int len = s1.length(); for (int i = 1; i < len; i++) { Stri...
cebdcaaa-6811-4721-be80-b3815b4a3e22
3
public void addPopup(int x, int y) { JMenuItem item = new JMenuItem(); JPopupMenu menu = new JPopupMenu(); item = new JMenuItem("Rename"); if(list.getSelectedIndex() == -1) item.setEnabled(false); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { @Suppr...
b6156556-c481-4e90-a854-9e57606932e2
0
private String readInput() throws IOException { return this.keyboard.readLine(); }
20d2f0cd-df11-4b6f-93c1-35f6bca1d765
7
@Override public boolean execute(Mob usr) { Container loc = usr.getLoc(); //Search the player's loc for the item's container, if we need to. if(getTargetContainer() != null){ Obj container = search(getTargetContainer(), loc); if (container != null && container.isConta...
309aeef4-5e5f-4aab-8c83-f47eb1fa11f9
5
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { BookService bookService = (BookService) getServletContext().getAttribute("bookService");//呼叫service int booksCount = bookService.getBooksCount();//取得book總數 ...
765c854b-a5c5-4e97-a462-0994a2f3ccde
1
protected void setOutput(String output) { /* * Too careful again. */ if(output == null) myOutput = ""; else myOutput = output; }
b60129e3-85d6-45e1-83c0-e29ad646f6ab
9
private double getCoordinate(String RationalArray) { //num + "/" + den String[] arr = RationalArray.substring(1, RationalArray.length()-1).split(","); String[] deg = arr[0].trim().split("/"); String[] min = arr[1].trim().split("/"); String[] sec = arr[2].trim().split("/"); ...
d6117424-74a4-40d9-acef-60148c96982d
0
public int getplayernum() { return players.size(); }
3b43886b-04ea-4da7-b8c2-1f5856600802
1
@Override public void run() { API api = Plugin.getAPI(); for(Player p : Bukkit.getOnlinePlayers()){ api.setMoney(p, api.getMoney(p) + api.getPlayersJob(p).getSalary()); p.sendMessage("[RP] " + api.getPlayersJob(p).getSalary() + "$ has been added to your wallet!"); } }
afcc7381-7891-46e6-9339-d54538c4f1e7
8
public static boolean validaMesAno (String strMesAno){ if(strMesAno == null || strMesAno.trim().equals("")){ return false; } if(strMesAno.length()!=7) return false; else{ String mes = strMesAno.substring(0, 2); if(validaNumero(mes)){ if(Long.valueOf(mes).compareTo(Long.valueOf("12")) > 0 || Long...