method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
f3416b17-65ef-43f3-9a78-3ac380ff24c6
5
public void normalizeSquared(int col) { double sqr = 0.0f; for(int j=0; j < nrows; j++) { double x = (double) getValue(j, col); sqr += x * x; } System.out.println("Normalize-squared: " + col + " sqr: " + sqr); float div = (float) Math.sqrt(sqr); S...
c6b8ef77-f81d-42e4-947a-f0b233a24c70
3
@Override public void actionPerformed(ActionEvent e) { OutlinerDocument doc = (OutlinerDocument) Outliner.documents.getMostRecentDocumentTouched(); OutlinerCellRendererImpl textArea = doc.panel.layout.getUIComponent(doc.tree.getEditingNode()); if (textArea == null) { return; } Node node = textArea.n...
6b3fd0af-0684-4c29-896d-0eb5165ca6e9
0
public String getId() { return id; }
f40de6f3-ba42-4795-8f5b-28d1dd4abc3d
9
@SuppressWarnings({ "unused", "unchecked" }) private HashMap<String, ActionPattern> buildActionPatterns(Agent agent, HashMap<String, Competence> competences2, HashMap<String, ActionPattern> actionPatterns2) { //HashMap<String, ActionPattern> returnActionPatterns = new HashMap<String, ActionPattern>(); Has...
a7fc131e-fd42-4c43-899c-d0fe5865a3cc
9
double[] recPositions(int chrom) { //get all recPositions of the first haplotype: double[] recpos = new double[0]; for (int p=0; p<getPloidy(); p++) { ArrayList<Double> hrecs = haplostruct[chrom][p].getRecombPos(); int rp=0; //index to recpos for (int hp=0; hp...
a559dd18-0750-4b26-8464-b628ae775d4c
9
public void writeVariant(Variant var) throws IOException { if (var.isStringType()) { writeString(var.getString()); } else if (var.isObjectType()) { out.append('{'); writeln(); boolean first = true; for (Map.Entry<String, Variant> e : var.varOb...
0751eb4c-ed9f-4093-9a94-7b6e76e72a2a
5
public static void update(GameContainer container, int delta) throws SlickException { if (isInputPressed(Controls.DEBUG)) { setDebug(!isDebug()); } if (transition != null) { transition.update(game, container, delta); ...
04d65ad6-4362-4e85-9628-556a20d2865c
4
@Raw public World(double width, double height, boolean[][] passableMap, Random random) throws IllegalArgumentException { if (!isValidDimension(width, height)) throw new IllegalArgumentException("The dimension provided isn't a valid dimension for a World"); if(random == null) throw new IllegalArgumentExcep...
3e794cb6-e131-40aa-b1d3-79b8170a7974
2
private String getTripText (Integer trip) { String s = "Gruppe: " + tripsOfDay.get(trip).getGroupNumber().toString(); s += " Fluss: " + tripsOfDay.get(trip).getRiver().getRiverName(); s += " WW" + tripsOfDay.get(trip).getRiver().getWwLevel() + "\n"; s += "Start: " + tripsOfDay.get(t...
7736262a-1f82-4947-b214-25161b960dcc
1
private boolean jj_2_21(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_21(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(20, xla); } }
4b28e552-5192-4e94-969c-f500a24f5342
5
public void printTable() { Setup.println(" DISTANCE TABLE"); Setup.println("----------------------------------------------------------"); for (String n : dv.keySet()) { Setup.print("\t" + n); } Setup.println(); // print mine Setup....
ae55588f-a161-4e99-a0e3-ce53d0fc50ca
9
protected void backfitHoldOutInstance(Instance inst, double weight, Tree parent) throws Exception { // Insert instance into hold-out class distribution if (inst.classAttribute().isNominal()) { // Nominal case if (m_ClassProbs == null) { m_ClassProbs = new double[inst.numClasses()]; } ...
fb47c8a7-df31-4419-a744-3ed974f6425d
8
public int getSearchArticleCount(String search,String val, int area) throws Exception{ Connection conn = null; PreparedStatement pstmt = null; Statement stmt = null; ResultSet rs = null; int x = 0; try{ conn = getConnection(); val = new String(val.getBytes("iso_8859-1"),"utf-8"); String sql = "sele...
30f9cc13-61a1-4f04-a905-272aa0518ea8
5
@SuppressWarnings("unchecked") @PUT @Produces( { "application/json", "application/xml" }) @Path("/mood/title/{title}/{username}/{valence}/{arousal}") public void putMoodByName(@PathParam("title") String title, @PathParam("username") String username, @PathParam("valence") double valence, @PathParam("arousal") ...
36c08e12-67f1-4f8a-9b5a-efa4045cb8b9
6
@Override public void actionPerformed(ActionEvent e) { if (e.getSource().equals(jbEscolha)) { String strMsg = validaFormulario(); if (!strMsg.equals("")) { JOptionPane.showMessageDialog(rootPane, strMsg); } else { if (jrbDocAnalise.isSelect...
404600f9-749d-44b6-8651-6523b7d41bae
9
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { MOB target=mob; if((auto)&&(givenTarget!=null)&&(givenTarget instanceof MOB)) target=(MOB)givenTarget; if(target.fetchEffect(this.ID())!=null) { mob.tell(target,null,null,L("<S-NAME> <S-IS...
a25eb782-6230-42cc-ade9-fc93e733356f
7
public boolean existII(char[][] board, String word) { if (board == null || board.length == 0 || word.length() > board.length * board[0].length) return false; char c = word.charAt(0); for (int i = 0; i < board.length; i++) { for (int j = 0; j < board[i].length; j++) { if (c == board[i][j]) { boolean...
046f3ae3-9e14-4c58-8711-fb9741f8b2c8
6
@EventHandler public void SilverfishNausea(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.getSilverfishConfig().getDouble("Silverf...
eada5247-2b41-4708-9d68-74c138146cb9
7
public boolean doHashCheck (DownloadInfo asset, final List<String> remoteHash) throws IOException { String hash = DownloadUtils.fileHash(asset.local, asset.hashType).toLowerCase(); List<String> assetHash = asset.hash; boolean good = false; if (asset.hash == null) { if (remote...
258d0975-4be4-4aed-a7fa-c6f2bb81ed25
8
public static void main (String[] args) throws FileNotFoundException { Scanner key = new Scanner(System.in); // System.out.println("enter title name"); // String input = key.nextLine(); File htmlDir = new File("G:/Code/htmls/"); File[] htmls = htmlDir.listFiles(); ...
44c6f5b1-c21e-475c-9707-8a4ea9643b77
5
public void run(){ while(true){ try { try { Thread.sleep(1000); } catch (InterruptedException ex) {} System.err.println("Deamon"); Transporte tr = new Transporte(100); DatagramPacket p = tr.receberDatagramPacket(receiveSocket);...
7b1b138b-ebbe-4315-96b9-d88dfa6324e6
5
public boolean isReady(){ return ( !resultReady && !isPlaceHolder(addr_comp[0]) && !isPlaceHolder(addr_comp[1]) && ( !is_store || (is_store && !isPlaceHolder(addr_comp[2])) ) ); // force store to wait for register value }
2c20f763-d38a-4dd7-a8f4-d856efb255a0
9
private static void diffDefaultValues(final PrintWriter writer, final PgView oldView, final PgView newView, final SearchPathHelper searchPathHelper) { final List<PgView.DefaultValue> oldValues = oldView.getDefaultValues(); final List<PgView.DefaultValue> newValues...
4cc53ed1-e0f8-4a2a-8262-759b6e91fcc1
7
public static void M(Topic root) { ArrayList<SparseMatrix> edges = root.Get_edgeset(); float[][] eijk = root.clone2df(root.Get_edgeweight()); int ii = eijk.length; // number of edges int jj = eijk[0].length; // number of topics //float[] rho_z_M = root.clone1df(root.Get_rho_z()); float[] rho_z_M = ...
add1772f-00fd-474f-ac3a-326c4fbedf0c
7
public void testThreadSafety() throws Exception { rnd = newRandom(); final int numThreads = 5; final int numDocs = 50; final ByteArrayPool pool = new ByteArrayPool(numThreads, 5); Directory dir = new RAMDirectory(); final IndexWriter writer = new IndexWriter(dir,...
c2d5d947-0cd1-456f-af54-48fb63e062fe
2
public void close() { if(socket != null) { try{ socket.close(); ServerHelper.log(LogType.NETWORK, "ServerSocket geschlossen"); } catch(IOException e) { ServerHelper.log(LogType.ERROR, "Fehler beim Schließ...
8409b190-0e71-46f2-bf56-28d633d638ec
9
@Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { if (dir.toString().equalsIgnoreCase(ROOTDIR)) return CONTINUE; String name = "" + dir; String[] comps = name.split("/"); String tmp = comps[comps.length - 1].toLowerCase(); if (related.length == 0) { ...
36394461-62ea-4a1c-b7fd-a882e84190d9
5
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringBuilder out = new StringBuilder(); String line = ""; while ((line = in.readLine()) != null && line.length() != 0) { double xm = Double.parseDouble(line.trim()); doubl...
034494ab-cebb-4496-a49f-a1316bf5c8a4
7
public static final int getDropRate(byte village) { switch (village) { case 0: return 20; case 1: return 10; case 2: return 10; case 3: return 30; case 4: return 10; ...
f4b4584a-3f56-423e-9ca2-02028b64fc12
1
public void removeEdge(final GraphNode v, final GraphNode w) { final Block src = (Block) v; final Block dst = (Block) w; if (FlowGraph.DEBUG) { System.out.println(" REMOVING EDGE " + src + " -> " + dst); } super.removeEdge(src, dst); cleanupEdge(src, dst); }
5848d7a7-4167-486f-8597-407e3fb8b0de
3
public static Matrix getMatrix(int rows, int cols, DataType dataType) { Matrix matrix = null; switch (dataType) { case INTEGER: matrix = new MatrixInteger(rows, cols); break; case DOUBLE: matrix = new MatrixDouble(rows, cols); ...
146476bb-e032-4fb2-a937-e8a08d721c32
8
public static void main(String[] args) throws NoSuchMethodException, IOException { ExpressionFactory factory = new ExpressionFactoryImpl(); SimpleContext context = new SimpleContext(); // variables e, pi context.setVariable("e", factory.createValueExpression(Math.E, double.class)); context.setVariable("pi",...
17f00d0f-68b3-4ded-bee1-a938727b53c5
5
public double score(StringWrapper s,StringWrapper t) { computeTokenDistances(); BagOfTokens sBag = (BagOfTokens)s; BagOfTokens tBag = (BagOfTokens)t; double sim = 0.0; for (Iterator i = sBag.tokenIterator(); i.hasNext(); ) { Token tok = (Token)i.next(); double df = getDocumentFrequency(tok); if ...
fa948757-1da4-437c-947f-e75110e04c64
8
public boolean checkForNewVersion(boolean notifyNoUpdate) { String currentVersion = versionManager.getVersion(); String newVersion = versionManager.checkForNewVersion(); boolean newVersionAvailable = false; if (newVersion != null && currentVersion != null) { if (Version.compare(newVersion, currentVersion) ...
5e0b0841-cd74-41a5-8970-f36562863d51
5
public void editAcc() throws FileNotFoundException, IOException { System.out.println("Which Account do you want to edit? (Account Number)"); Scanner impor = new Scanner(System.in); String editLine = "hi"; int ach = impor.nextInt(); String path = accDir+ach+".txt"; String newline = System.getProp...
39a10e50-5821-4e96-b470-c0e58942087c
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 + " is negative: " + a[i]); sum = sum + a[i]; } if (sum > 1.0 + EP...
bc04a0dd-6388-43cc-8cd6-db0d0eb82af5
7
public boolean isLine(){ int countUnblocked=0; for(int i = 0; i < corridor.length; i++) { if(corridor[i].getWeight()==1){ countUnblocked++; } } if(countUnblocked == 2) { if(corridor[0].getWeight() == 1 && corridor[2].getWeight() == 1){ return true; } else if(corridor[1].getWeight() == 1 &...
0891cb54-d49e-443f-b655-834dd087a650
8
private void drawTooltip() { if (menuActionCount < 2 && itemSelected == 0 && spellSelected == 0) { return; } String text; if (itemSelected == 1 && menuActionCount < 2) { text = "Use " + selectedItemName + " with..."; } else if (spellSelected == 1 && menuAc...
169f2b0d-7133-4578-b222-7e04645debfb
7
SortedSet<Dimension> read() throws CubeXmlFileNotExistsException, IOException, DocumentException { Configuration conf = CubeConfiguration.getConfiguration(); FileSystem hdfs = FileSystem.get(conf); Path dimensionXmlFile = new Path(PathConf.getDimensionXmlFilePath()); if (!hdf...
0744cbd2-7962-4fac-8daa-ef061bb5159c
5
private int jjMoveStringLiteralDfa11_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(9, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(10, active0); return 11; } switch(curChar) { case 10...
baec9ba4-2500-4631-b75e-56df8909dc2c
4
/* */ public void update(int time) /* */ { /* 58 */ if ((Math.abs(this.x - this.targetX) < 5.0F) && (Math.abs(this.y - this.targetY) < 5.0F)) { /* 59 */ this.speedX = 0.0F; /* 60 */ this.speedY = 0.0F; /* 61 */ this.active = true; /* */ } /* 63 */ this.x += this.speedX; /* 64 ...
357047fd-a758-4dcf-98af-758bda241d38
9
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } RangeConstraint other = (RangeConstraint) obj; i...
78612850-6c03-45ef-93d2-1601a2b5eb29
4
private void updateViews() { if(!cardViews.isEmpty()) { for(CardView temCard : cardViews) { remove(temCard); } cardViews.clear(); } MouseListener mouseListener = new MouseListener(); List<Card> cards = player.getCardGroup().getCardList(); CardView cardView; for(Card card : cards) { cardVi...
12e56ff9-8066-47a8-af15-061fb7aba17a
0
public Rectangle getAbsoluteRect() { Rectangle absRect = new Rectangle(); int unitVal = unit.value; absRect.x = x * unitVal; absRect.y = y * unitVal; absRect.width = width * unitVal; absRect.height = height * unitVal; return absRect; }
a18d4eea-413e-49b2-8507-b0da965cae05
7
public boolean setInputFormat(Instances instanceInfo) throws Exception { super.setInputFormat(instanceInfo); // Make the obfuscated header FastVector v = new FastVector(); for (int i = 0; i < instanceInfo.numAttributes(); i++) { Attribute oldAtt = instanceInfo.attribute(i); Attribute n...
9ad4d89b-45e7-482e-8c9b-202966665746
0
public LogWindow() { super("Game History"); setLayout(new FlowLayout()); setSize(WIDTH, HEIGHT); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setResizable(false); list = new JList<String>(listModel); list.setLayoutOrientation(JList.VERTICAL); JScrollPane listScroller = new JScrollPane(l...
6f154e4f-9943-4029-a06a-17f05b6f626f
4
public static void main (String args[]) { System.out.println("HTTPServer.java"); ServerSocket Server = null; try { Server = new ServerSocket (5000, 10, InetAddress.getByName("192.168.43.247")); } catch (UnknownHostException e) { System.out.println("Unknown host"); } catch (IOException e) { ...
7679bc71-29fd-4078-92ab-a2e3306513cb
7
private Array createFixedWaysPath(Ways way, Array start, GameContainer container, StateBasedGame game) throws SlickException { Array currrentNode = start; Array newNeighboor = null; for (int i = 0; i < MIN_WAY_SIZE + (int) (Math.random() * MAX_WAY_SIZE); i++) { switch (way) { case NORTH: newNeighboor...
dff2c2b0-de1d-4bcd-ac36-46cc011924c6
6
public boolean equals( Object o) { if ((o == null) || !(o instanceof DERUnknownTag)) { return false; } DERUnknownTag other = (DERUnknownTag)o; if(tag != other.tag) { return false; } if(data.length != other.data.length) { ret...
78d82a97-f741-4901-a2ba-bd00715ca406
4
public AudioServer(String [] args) { isRunning = true; isPlaying = true; /* Check port exists */ if (args.length < 1) { System.out.println("Usage: ChatServerMain <port>"); System.exit(1); } /* Create the server socket */ try { serverS...
15cd4f2c-11e0-4f8b-ac70-021af3e8ada3
6
private void jButtonPesquisarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPesquisarActionPerformed Cidadao cidadao = new Cidadao(); Bairro bairro = new Bairro(); Cidade cidade = new Cidade(); Estado estado = new Estado(); cidade.setEstado(estado); ...
e35d086c-4bfa-4df0-92f1-b6ad7e5cc9e0
4
public void setCells(Object[] cells) { if (cells != null) { if (singleSelection) { cells = new Object[] { getFirstSelectableCell(cells) }; } List<Object> tmp = new ArrayList<Object>(cells.length); for (int i = 0; i < cells.length; i++) { if (graph.isCellSelectable(cells[i])) { ...
53faebf7-539d-4fb6-8083-0c7c62ff58cc
0
@Test public void testGetX() { System.out.println("getX"); assertEquals(1.0, new Orb(4,12,1,1).getX(), 0.00001); }
4e595696-6c6f-4689-bb5f-d94eeead7b77
1
public static void disposeColors() { for (Color color : m_colorMap.values()) { color.dispose(); } m_colorMap.clear(); }
871587c8-0ffd-4b3a-b368-a46a7900bd54
9
public static Equation parseEquation(String strEquation) throws InvalidEquationException{ //Create a list of expressions ArrayList<Expression> expressionList = new ArrayList<Expression>(); //Create a queue of integers LinkedList<Integer> digits = new LinkedList<Integer>(); //for each character in the answer ...
298a0c08-5da4-4e89-a5a9-ca5da27b8b21
3
public Vector<BaseRace> getRankedRaces(int rank) { Vector<BaseRace> br = new Vector<>(); for (ClassMap item : _classMap) { if (item.getClassType().getName().equals(_class.getName())) { if (item.getAverage() == rank) { br.add(item.getRace()); ...
44cdb0ff-992b-450e-aec9-de07747e6179
2
public static void main(String... args) throws IOException { ServerSocket serverSocket = new ServerSocket(13800); Socket socket = serverSocket.accept(); InputStream inputStream = socket.getInputStream(); Scanner scanner = new Scanner(inputStream); OutputStream outputStream = sock...
0fa714c3-fa5f-453b-a760-3e8731e1e0f5
8
public static void main(String[] args) { try { File file = new File(Path); Scanner scanner = new Scanner(file); scanner.useDelimiter("#NEW RECORD\n"); int counter = 0; while (scanner.hasNext()){ String document = scanner.next(); ...
225f39d4-28c9-43b0-908d-461c255715bb
2
public void test_convertText() { BaseDateTimeField field = new MockBaseDateTimeField(); assertEquals(0, field.convertText("0", null)); assertEquals(29, field.convertText("29", null)); try { field.convertText("2A", null); fail(); } catch (IllegalArgumentExc...
97d27f6a-c51c-4b69-8e8e-80bd758065f2
6
private <T> StringConverter<T> findAnnotatedConverter(final Class<T> cls) { Method toString = findToStringMethod(cls); // checks superclasses if (toString == null) { return null; } MethodConstructorStringConverter<T> con = findFromStringConstructor(cls, toString); Me...
ff95c8bc-8152-4577-a4bd-860b0cb39914
3
public void cargarProductos() { try { Connection conn = Conexion.GetConnection(); try { st = conn.createStatement(); pro = st.executeQuery("SELECT * FROM Productos"); } catch (SQLException e) { JOptionPane.showMessageDialog(this...
f9bf6b21-6d83-4b99-9bc6-5d537537faa5
3
public static boolean isCyclicUndirected(mxAnalysisGraph aGraph) { mxGraph graph = aGraph.getGraph(); mxIGraphModel model = graph.getModel(); Object[] cells = model.cloneCells(aGraph.getChildCells(graph.getDefaultParent(), true, true), true); mxGraphModel modelCopy = new mxGraphModel(); mxGraph graphCopy = n...
82950cca-72c6-44ee-a860-201de2f07db4
5
public List<Tuple<Integer,Integer>> reconstructPath ( HashMap<Tuple<Integer,Integer>,Tuple<Integer,Integer>> cameFrom, Tuple<Integer,Integer> currentNode ) { int delayNearEndpoints = 3; int roomNearEndpoints = 3; //log.trace("reconstructPath: cameFrom size:" + cameFrom.size() ); List<Tuple<Integer,Integer>> ...
064856a8-bf60-456e-9719-cc1e10654d5e
6
public void nextPermutation(int[] nums) { if(nums.length <= 1) { return; } int i = nums.length - 2; for(; i >= 0; i--) { if(nums[i+1] > nums[i]) { break; } } if(i == -1) { reverse(nums, 0, nums.length-1); ...
6c983ad0-c78a-4308-b3d7-4b40bbc841be
7
public final DirkExpParser.equalityExpr_return equalityExpr() throws RecognitionException { DirkExpParser.equalityExpr_return retval = new DirkExpParser.equalityExpr_return(); retval.start = input.LT(1); CommonTree root_0 = null; Token set9=null; DirkExpParser.relationalExpr_re...
8731abfd-0a0f-41f4-8720-ce6371d49c1c
5
public static boolean check(Robot paramRobot) { return (robotContainsBeacon(paramRobot)) || (lostOnlyPart(paramRobot, new Hermes().getClass())) || (lostOnlyPart(paramRobot, new Launcher().getClass())) || (lostOnlyPart(paramRobot, new Arachnae().getClass())) || ( (noRobotsLeft()) && (cantMakeAC...
fa779757-004d-48d3-89ec-e4b42b359b8b
2
public List<String> getIP(String url) throws IOException{ URL u = new URL(url); BufferedReader br = new BufferedReader(new InputStreamReader(u.openStream())); String s = ""; List<String> ipList = new ArrayList<String>(); String regex = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"; Pattern p = Pat...
a47158f6-97aa-4473-8bb2-6cf43b050e6d
0
public static void main(String[] args) { new Main(); }
338aee82-b1b0-4691-9759-10562eb84195
1
public E element() { E rv; if((rv = peek()) == null) throw(new NoSuchElementException()); return(rv); }
defe827e-17aa-4fbc-b307-65d53d8458cb
4
public GUI() { try { for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exc...
19edf8bd-3252-4ed2-b411-408580a86cd5
2
public static Object nartSubstitute(Object cyclObject, CycAccess access) throws IOException { if (!DefaultCycObject.isCycLObject(cyclObject)) { throw new RuntimeException(DefaultCycObject.cyclify(cyclObject) + " is not a valid Cyc object."); } if (!(cyclObject instanceof CycObject)) { // @todo need ...
ea78d171-f7d8-4da0-8cbd-23b852983538
9
public Alphabet( String path, String texFile, String alphaFile, String mapFile, int numLines, int lineHigh ) { // Basic initialisation routine here. The list of individual characters // must be loaded first for comparison with scanned character blocks. int charMap[] = null ; final int m...
b736f215-cdf0-4e5b-953b-808593ba0338
8
public void colorBiddableLand(Graphics g){ String player = Requests.teamName; String owner; Grid grid = request.operator.getGrid(); Point p; for(int i = 0; i < s; i++){ for(int j = 0; j < s; j++) { p = new Point(j,i); owner=grid.getOwner(p); if(!grid.exists(p)||owner==null){ //If no o...
3ca3f832-d163-4302-bf67-0a6754915dd6
1
@Test public void construction() { int size = 30; List<Calendar> dates = new ArrayList<>(30); for (int i = 0; i < size; i++) { dates.add(Calendar.getInstance()); } IntervalList list = new IntervalList(dates); assertEquals(size / 2, list.size()); }
dc3008d9-6a43-42af-ba1f-9adfd3f98c18
9
public void maintenence()// well, kind of what it sounds like. Kings pieces, // checks for draws, etc... { for (int x = 0; x < 8; x++)// kinging. { if (theBoard[x][7].getPiece() == '@') { theBoard[x][7].king(); } else if (theBoard[x][0].getPie...
1806b5c0-a6ef-4a31-b9a5-38033b7c8c16
6
public static void main(String[] args) { int[] vals; Scanner scan = new Scanner(System.in); try { while (true) { try { System.out.print("How long would you like the array to be? "); int count = scan.nextInt(); ...
12d93968-83b7-4a9b-9149-acb683c8b4df
7
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
7e9d2355-a758-46c4-a08f-434f9d00d95b
2
public void testPropertySetDayOfWeek() { DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0); DateTime copy = test.dayOfWeek().setCopy(4); assertEquals("2004-06-09T00:00:00.000+01:00", test.toString()); assertEquals("2004-06-10T00:00:00.000+01:00", copy.toString()); try...
20528fc6-297f-434b-82ae-02fbc27b98e2
5
public static int[][] adjoint(int[][] matrix){ //preconditions if(matrix == null)throw new IllegalArgumentException("matrix must not be null"); for(int i = 0; i < matrix.length; i++){ if(matrix.length != matrix[i].length)throw new IllegalArgumentException("matrix must be square!"); } int[][] newMatrix =...
be0cb1c4-5399-40cc-98dc-75bff4cd5340
4
public String toString() { String strType; switch (type) { case _AVERAGE: strType = STR_AVERAGE; break; case _MIN: strType = STR_MIN; break; case _MAX: strType = STR_MAX; break; case _LAST: strType = STR_LAST; break; default : throw new RuntimeException("Thi...
cb6f4aa0-c235-4291-862e-02bf36b07f8b
5
public PolyEquationImpl(final BigInteger[] inCoeffs) { if (inCoeffs.length <= 0) { throw new SecretShareException("Must have at least 1 coefficient"); } coefficients = new BigInteger[inCoeffs.length]; for (int i = 0, n = inCoeffs.length; i < n ; i++) ...
803bb309-e490-4a5b-93bf-999f674dd06c
4
public void addOpdrachtToList(Opdracht opdracht) { try { if (opdrachten.size() != 0) { if (!opdracht.equals(null) || !opdrachten.contains(opdracht)) { Opdracht o = opdrachten.get(opdrachten.size() - 1); opdracht.setId(o.getId() + 1); } } else { opdracht.setId(opdrachten.size() + 1); } ...
4d5706f4-e8f3-4209-9ca7-3f7c81e449ab
4
@SuppressWarnings("resource") public static void denyRdr() throws IOException{ if (!dnames.exists()){dnames.createNewFile();} BufferedReader rfile = new BufferedReader(new FileReader(dnames)); String nme=null; for (int i=0;i<6;i++){ nme=rfile.readLine(); if (nme!=null && !nme.isEmpty())...
79597992-3cc3-404a-812f-e4c7a94e2cd8
9
public void finalizeMap(){ for (int i = 0; i < tiles.length; i++) { for (int j = 0; j < tiles.length; j++) { if (tiles[i][j] == 'S') { myX = 25 + i * 50; myY = 25 + j * 50 ; } if (tiles[i][j] == 'R') { mySecondX = 25 + i * 50; mysecondY = 25 + j * 50; } } } int count=0; ...
a8e8b1ac-e026-4785-a17d-8bf6ea286198
8
protected static int partition(double[] arrayToSort, double[] linkedArray, int l, int r) { double pivot = arrayToSort[(l + r) / 2]; double help; while (l < r) { while ((arrayToSort[l] < pivot) && (l < r)) { l++; } while ((arrayToSort[r] > pivot) && (l < r)) { r--; } ...
2ab75ca5-aeca-4d01-a293-c549906ca90c
2
public void testPropertyCompareToYear() { YearMonth test1 = new YearMonth(TEST_TIME1); YearMonth test2 = new YearMonth(TEST_TIME2); assertEquals(true, test1.year().compareTo(test2) < 0); assertEquals(true, test2.year().compareTo(test1) > 0); assertEquals(true, test1.year().compar...
682feec3-45c0-4d45-9e82-f4118129ad63
3
private boolean hasSerialArrayListFlavor(DataFlavor[] arrDfIn) { if (this.dfSerial == null) return false; for(int iCnt = 0; iCnt < arrDfIn.length; iCnt ++) { if (arrDfIn[iCnt].equals(this.dfSerial)) return true; } return false; }
1eeda8ac-2a0c-4f14-bec2-abd070ddb8d7
2
public Berechtigung getBerechtigungzuidBerechtigung(int idBerechtigung) { Berechtigung rueckgabe = null; ResultSet resultSet; try { resultSet = db .executeQueryStatement("SELECT * FROM Berechtigungen WHERE idBerechtigung = '" + idBerechtigung + "'"); if(resultSet.next()) rueckgabe = new Berec...
632dea74-6def-49ef-9864-5cffb63c8672
8
public static int removeHandler(Board theBoard, Army army, String team) { int r, c; if(army.getCapacity() == army.getRemaining()) { System.out.println("No armies to remove."); return 0; } else { System.out.print("Enter row of piece to remove: "); r = Integer.parseInt(""+input.next().charAt...
19140b24-d100-4d45-bfe5-d2f7c0f7301f
8
public boolean actionBuild(Actor actor, Venue built) { // // Double the rate of repair again if you have proper tools and materials. final boolean salvage = built.structure.needsSalvage() ; final boolean free = GameSettings.buildFree ; int success = actor.traits.test(HARD_LABOUR, ROUTINE_DC, 1) ? 1...
7b68db99-79a6-483b-9124-b4f41f3c4938
4
public void attack(){ for(int i = 0; i<enemies.size(); i++){ if((Driver.player.getX() > enemies.get(i).getX()-enemies.get(i).getRange()) && (Driver.player.getX() < enemies.get(i).getX()+enemies.get(i).getRange()) && (enemies.get(i).getY() == Driver.player.getY())) enemies.get(i).attack(); } }
db642b61-09d5-4052-8139-4a7a13df4b3f
9
public void paint(Graphics g) { // clear previous image g.setColor(Color.WHITE); g.fillRect(0, 0, getWidth(), getHeight()); // draw grid BufferedImage myImage = null; try { java.net.URL myImageURL = TicTacToe.class .getResource("images/grid.png"); myImage = ImageIO.read(myImageURL); } catch (IO...
987de6d1-2103-439f-9d76-1b489360c21d
4
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { try { if (!(sender instanceof Player)) { sender.sendMessage(ChatColor.RED + "The server doesn't have a PIN!"); return true; } Player player = (Player)sender; if (HyperPVP.getStorage().readS...
1837b7b2-9389-4574-a308-04bcf87fe6f4
3
public void svg2pngUsingInkscape(File svgFile, File pngFile) throws ConverterException { if(inkscapePath==null) throw new ConverterException("No runtime defined for Inkscape"); // inkscape classDiag.svg -e classDiag.png -d 200 ProcessBuilder pb = new ProcessBuilder( ...
1ebe0062-7b51-4162-ab5e-39fd3a8a9b57
3
@Override public void update(GameContainer container, StateBasedGame sbg, int delta) throws SlickException { xpos=container.getInput().getMouseX(); ypos=container.getInput().getMouseY(); bonusButton.update(delta); updateEntities(delta); if(time > 0){ time -= delta*1/1000f; if(time%10 == 0){ coun...
95185200-9f39-4a92-978f-a0cfc218817d
1
int putIndexed(int tag, Object obj1, int index1, int index2) { Key key = new Key(tag, obj1, index2); Integer indexObj = (Integer) entryToIndex.get(key); if (indexObj != null) { /* Maybe this was a reserved, but not filled entry */ int index = indexObj.intValue(); indices1[index] = index1; indices2[ind...
c2475e00-515f-426f-9ac3-2cffe61e7a0b
2
@Override public void init(boolean isServer) { timer = 0; tiles = new Tile[99][99]; for(int x = 0; x < tiles.length; x++) for(int y = 0; y < tiles[x].length; y++) tiles[x][y] = new Tile(this, x, y); entities = new ArrayList<Entity>(); //for(int i = 0; i < 7; i++) //entities.add(new RandomWalkEnti...
379a48fc-3c02-4593-8609-b7d38df4f4b4
4
public void disconnect() { //windowController.getSendTextArea().setDisable(true); //windowController.getSubmitButton().setDisable(true); shutdownReconnectWorker(); if(connectionCheckTimer != null) { connectionCheckTimer.cancel(); } if(!echoSocket.isClosed()) { preDisconnect(); ...
93147196-631c-4611-a6b5-706b78a8d6a6
5
private void pop(char c) throws JSONException { if (this.top <= 0) { throw new JSONException("Nesting error."); } char m = this.stack[this.top - 1] == null ? 'a' : 'k'; if (m != c) { throw new JSONException("Nesting error."); } this.top -= 1; ...
32b4122c-03f1-4758-88c4-efe651a38aab
1
public static void main(String[] args) { Integer i = new Integer(253); if((i & 0x01) == 1){ System.out.println("CARRY"); } System.out.println(Integer.toBinaryString(i)); i = i >> 1; System.out.println(Integer.toBinaryString(i)); }