method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
c4504a36-00d2-44e8-abe0-a4f4223cfc0f
2
public JSONArray names() { JSONArray ja = new JSONArray(); Iterator keys = this.keys(); while (keys.hasNext()) { ja.put(keys.next()); } return ja.length() == 0 ? null : ja; }
bbdccfec-ceaf-4d22-a73e-f3d1a4477346
4
public Method getMazeGeneratorByAlias(String genName){ Method m = null; Iterator<Method> it = mazeGenerators.iterator(); while(it.hasNext() && m == null){ Method cur = it.next(); MazeGenerator sub = cur.getAnnotation(MazeGenerator.class); for...
ca2fdf96-275a-4b6a-8a61-fcd1b7686d26
4
private void StartHTTPProxy(String MODE) { int port = -1; String fwdProxyServer = ""; int fwdProxyPort = 0; jProxy jp; try { // get the command-line parameters port = Integer.parseInt(HTTPProxySourcePort.getText()); } catch (NumberFormatException ...
7aedecd1-e5f8-4eb4-8b89-6ed79b89989c
7
public Cursor<SyncLogDTOWithRelatedEntities> listLogEntries(final Timestamp onOrAfter, final Timestamp before) throws DBException { PreparedStatementCursor<SyncLogDTOWithRelatedEntities> cursor = new PreparedStatementCursor<SyncLogDTOWithRelatedEntities>(mgr, LIST_ENTRIES_SQL) { @Override protected v...
64bd1eb4-0efd-4d10-8db2-67bfec30b98a
3
public void sendMessage(Message message) { messages.put(message.getSequenceNumber(), message); try { outputStream.writeObject(message); } catch (IOException e) { ClientLogger .error(Client.class, RemoteResourcesLocalization .getMessage( RemoteResourcesMessages.Client_Error_Un...
fbff1f79-5a65-479f-8322-1bbfcd6e10eb
8
static void displayHelp(String input) throws IOException { String helpFunction = input.substring(4).trim(); GuiMain.feedback.setText("Try a valid help option next"); String fileContent; switch (helpFunction){ case "": fileContent = readFile(HELP_TXT); GuiMain.feedback.setText(fileContent); break; c...
19012bf7-31e7-48d3-9042-49a9828f2780
0
public LRParseTablePane(LRParseTable table) { super(table); this.table = table; setCellSelectionEnabled(true); setDefaultRenderer(Object.class, new LRParseTablePane.CellRenderer()); ToolTipManager.sharedInstance().registerComponent(this); }
8a25ef4c-6811-4843-81fb-5c19944ef6f2
5
public boolean kleinerDan(Datum d) { if (this.getJaar() > d.getJaar()) { return false; } else if (this.getJaar() < d.getJaar()) { return true; } else if (this.getMaand() > d.getMaand()) { return false; } else if (this.getMaand() < d.getMaand()) { return true; } else if (this.getDag() > d.getDag())...
691cfc67-c86c-408f-9896-f0241d484175
5
@Test public void testAdjacent_ants(){ World world = new World(150,150); Game game = new Game(world, new BrainParser("C:/Users/mpp27/cleverbrain1.brain"), new BrainParser("C:/Users/mpp27/cleverbrain1.brain")); int i = 0; int y = 0; int[] p = new int[2]; boolean found = false; while(i < world.getRows() &&...
92685925-1537-4c1a-a55e-46c916d1f573
3
private boolean addBranches(Document doc, Element lineElement, List<BranchData> branchDatas) { lineElement.setAttribute("branch", "true"); Element conditionsElement = doc.createElement("conditions"); lineElement.appendChild(conditionsElement); int branches = 0; int branchHits = 0...
099a7117-53d1-4f37-8180-b176f4b8699b
2
public List<Produto> listar() { String sql = "SELECT * FROM PRODUTO"; try { conn = GerenciaConexaoBD.getInstance().getConnection(); PreparedStatement stmt = conn.prepareStatement(sql); ResultSet rs = stmt.executeQuery(); List<Produto> listarProdutos = new ArrayList<Produto>(); while (rs.next()) { ...
0c19d15c-0cb2-4f21-8485-32564416a026
5
private KDTreeNode buildTree(List<Pair> data, final int split){ if(data == null || data.size() == 0) return null; Comparator<Pair> comparator = new Comparator<Pair>(){ public int compare(Pair o1, Pair o2) { double v1 = o1.data_vector[split]; double v2 = o2.data_vector[split]; return v1<=v2?-1:1; ...
d6c4236d-1135-4a4b-8197-d1db16f27a6c
6
public static void create_ENST00000268124_file() throws IOException { Config config = new Config("testENST00000268124", Gpr.HOME + "/snpEff/" + Config.DEFAULT_CONFIG_FILE); config.loadSnpEffectPredictor(); Random rand = new Random(20140129); StringBuilder out = new StringBuilder(); int count = 0; for (Gen...
eb7509ac-42ae-43c4-a1ec-0c89fae33467
4
void createExampleWidgets () { /* Compute the widget style */ int style = getDefaultStyle(); if (flatButton.getSelection ()) style |= SWT.FLAT; if (readOnlyButton.getSelection ()) style |= SWT.READ_ONLY; if (borderButton.getSelection ()) style |= SWT.BORDER; /* Create the example widgets */ combo1 =...
db7e2bec-e736-4579-94c8-ea903ec486c1
1
public void reload() { if (getCartregesReamaining() > 0) { this.setReloading(true); this.reloadRemaining = weapon.getReloadTime(); setCartregesReamaining(getCartregesReamaining() - 1); } else { outOfAmo = true; } }
6f2b6f69-aa9a-42b9-a1bf-2a66db38dd83
7
private void unzip(String file) { final File fSourceZip = new File(file); try { final String zipPath = file.substring(0, file.length() - 4); ZipFile zipFile = new ZipFile(fSourceZip); Enumeration<? extends ZipEntry> e = zipFile.entries(); while (e.hasMoreE...
1ecc3db9-b0bf-463c-9053-f3d5763fd597
7
public static void main(String[] args) { initaliseLogger(); // Check for a defined configuration file argument // String configFilePath = DEFAULT_CONFIG_FILE; if (args != null && args.length > 0 && args[0] != null && args[0].endsWith(".xml") && args[0].length() >...
6aa516ea-d051-4f09-9718-a9284b3bf8e3
3
private static void eliminarMusica() { boolean salir; Integer idMusica; char caracter; do { try { System.out.print( "Introduce el Id del producto Musica: "); idMusica = Integer.parseInt( scanner.nextLine()); System.out.print( "Deseas eliminar toda la informacin del producto en l...
d9ddb780-046b-4bcc-8ec6-903570c95fd4
7
private void doStep() { switch (step) { case 1: // get opcode dfOpcode = dfTempByte; echo("Recieved Opcode: " + dfOpcode); // Status Register Read? if (dfOpcode == 0x57 || dfOpcode == 0xD7) { ...
8066cdaf-3bfa-41e0-8ccc-230b7e00e533
3
boolean loadSerialized(String name) { boolean rval = false; try { String userDir = System.getProperty("user.home"); String serializedDir = "serialized"; File dirFile = new File(userDir, serializedDir); File serFile = new File(dirFile, name + "...
f09da61c-d742-4c6e-a5ab-35fe05589231
7
protected void runTests() { if (isTesting) { return; } final String pathToExecFile = sourceFile.getText(); File execFile = new File(pathToExecFile); if (Config.getBoolean("checkExistence")) { if (!execFile.exists()) { // executable...
8cd4df51-7ba5-4cc4-a044-98eb744a04e1
3
public boolean isInBounds(Point point) { return 0 <= point.getColumn() && point.getColumn() < columns && 0 <= point.getRow() && point.getRow() < rows; }
09390dd2-ac38-4a1e-92fc-1c97b3f219d9
3
public List<Object> getValues() { List<Object>res = new ArrayList<>(); for(JoinDescriptor join:joins) { Object [] obj = join.getValues(); if(obj!=null) { for(Object o:obj) { res.add(o); } } } return res; }
8aaf1c49-000c-43da-b310-f395f0048456
3
@Override public String execute(SessionRequestContent request) throws ServletLogicException { String page = ConfigurationManager.getProperty("path.page.cities"); try { Criteria criteria = new Criteria(); City currCity = (City) request.getSessionAttribute(JSP_CURRENT_CITY); ...
7e042048-c5b2-4127-a3bf-436974c553e7
5
public static void compressFile(String inputFile, String output){ ////Setup//// readCharacters(inputFile);//Get every character in the file generateFrequency();//Generate a frequency map and get every unique character buildTrie();//Build the trie and generate a translation map //Create Header ByteBuffer he...
ac3b5d04-f6b6-43bd-bbbb-f1c3f4b2283f
6
public static void initCraftableStats() { if (blockStatsInitialized && itemStatsInitialized) { HashSet var0 = new HashSet(); Iterator var1 = CraftingManager.getInstance().getRecipeList().iterator(); while (var1.hasNext()) { IRecipe var...
2d760815-6cbb-4918-b530-99e8a122a7ec
2
private void generateEdge(PrintStream out, Relationship relationship) { out.println(" edge ["); out.println(" shape = \"edge\""); out.println(" dir = \"both\""); out.println(" style = \"" + lineStyle2Dot(relationship.getLineStyle()) + "\"");...
fd16f92b-16da-498c-b8e2-a8fb43be8bd9
4
public synchronized static void insertRelease(Release r) { Connection connection = null; Statement statement = null; PreparedStatement pstmt = null; try { Class.forName("org.sqlite.JDBC"); connection = DriverManager.getConnection("jdbc:sqlite:"+Settings.DB_PATH); statement = connecti...
0428306a-f8a7-4215-b750-0e12869dd222
0
public static double distanceBetweenTwoPoints(float x1, float y1, float x2, float y2) { return Math.sqrt(Math.abs(x1 - x2) * Math.abs(x1 - x2) + Math.abs(y1 - y2) * Math.abs(y1 - y2)); }
73c990ef-601c-4cea-ae1f-7db0ed3ade6a
7
public static double tanh(double x) { boolean negate = false; if (x != x) { return x; } // tanh[z] = sinh[z] / cosh[z] // = (exp(z) - exp(-z)) / (exp(z) + exp(-z)) // = (exp(2x) - 1) / (exp(2x) + 1) // for magnitude > 20, sinh[z] == cosh[z] in double precision if (x > 20.0) { return 1.0; } ...
089c5e2e-bfb7-4591-b27b-5330cee6283b
7
public static String lowDequote(String msg) { StringBuffer sb = new StringBuffer(msg.length()); for (int i = 0; i < msg.length(); i++) { if (msg.charAt(i) == MQUOTE && i+1 < msg.length()) { switch (msg.charAt(++i)) { case '0': sb.append(0); break; case 'r': sb.append('\r'); break;...
7eaa6523-e3b9-4006-86f6-7521d67972d5
6
public void write(char[] b, int off, int len) throws IOException { /* Note that setText and append are thread safe! */ if (!initialized) { area.setText(""); initialized = true; } String str = new String(b, off, len); StringBuffer sb = new StringBuffer(len); while (str != null && str.length() >...
3fec7643-7317-4b5c-aebd-1e48117ae7b2
9
public static Object[] decodeValues(String str) throws DecodeException { Object[] res; int i=0; int beginning = i; while (str.charAt(i) != '>') { i++; } String[] types = str.substring(beginning, i).split(":"); i++; beginning = i; ...
80809d18-1e43-4e55-993b-5cd705420496
7
public CryptageParRotation(ConvertisseurCaractereAscii conv, int valeurDuDecalage, Vue vueCourante) throws DecalageTropImportantException { if(valeurDuDecalage > this.alphabetConversion[0].length) throw new DecalageTropImportantException(); this.convertisseur = conv; this.uneVue = vueCourante; int ...
05d9ca27-b28a-4c38-aab3-0bc492ffc4be
7
public static void main(String[] args) { //createNInstances(n, numberOfGenerators, numberOfLoadsForGenerator, R, xmean, delta); /*int[] Ma = {200, 1000, 2000, 10000, 20000, 100000}; int[] na = {100, 100, 100, 100, 100, 20};*/ int[] Ma = {2}; int[] na = {1}; ...
d74b8c77-67a8-44ab-92f0-0f2c05cac9f1
9
public boolean isPalindrome(String s) { if(s==null) return false; s=s.trim(); if(s.length()<=1) return true; s = s.toLowerCase(); int i = 0; int j = s.length()-1; while(i<j) { while(!valid(s, i) &&i<j) i++; while(!valid(s, j)&& i<j) j--; if(i>=j) break; if(s.charAt(i)!=s.charAt(j)) return fa...
043756cb-1ff0-4a75-ae5d-c01bc5b3f358
9
private boolean validateType(Object data){ boolean valid = false; if(type.equals("boolean")) valid = validateTypeBoolean(data); else if(type.equals("integer")) valid = validateTypeInteger(data); else if(type.equals("float")) valid = validateTypeFloat(data); else if(typ...
81f10345-1f9c-4541-bcc9-7618bd6686f4
6
public List<Site> getAdjacents(){ List<Site> adjacents = new ArrayList<Site>(); for(int x = -1; x <= 1; x++){ for(int y = -1; y <= 1; y++){ for(int z = -1; z <= 1; z++){ Site other = landscape.getSite(getX()+x, getY()+y, getZ()+z); if (other != null && other != this && isAdjacent(other)){ adj...
5d0f8579-95ea-4b9c-bd1f-4c75c833086b
2
public K getMax(){ K maxKey = null; Integer maxValue = Integer.MIN_VALUE; for (Map.Entry<K, Integer> entry : map.entrySet()){ if (entry.getValue() > maxValue){ maxKey = entry.getKey(); maxValue = entry.getValue(); } } return...
93e50152-50a7-4298-b25d-4cb0dbd9d356
8
protected static int do_escaped(PrintWriter out, char c) { StringBuffer escape = new StringBuffer(); if (c <= 0xFF) { escape.append(Integer.toOctalString(c)); while(escape.length() < 3) escape.insert(0, '0'); } else { escape.append(Integer.toHexString(c)); while(escape.length() < 4) ...
03a9b4b1-4dd1-41ab-af48-f9780c063e00
8
public void highlightPanel(PanelName panelName) { switch (panelName) { case PANEL_NORTH: northPanel.setBackground(Color.RED); break; case PANEL_SOUTH: southPanel.setBackground(Color.RED); break; case ...
00e870ba-7565-4859-a6d8-c157d856dba8
0
public Point getAnchor() { return anchor; }
432a851e-68c6-4b98-966a-f48e9dfdabad
6
@Override protected boolean canAddChild(int index, Construct child) { // TODO: can I add an array to an array? Look into all these values if(child.getClass() == StringConstruct.class || child.getClass() == BooleanConstruct.class || child.getClass() == FloatConstruct.class || child.getClass() == Inte...
8fd4ed85-47e3-4640-9c70-c72cf22b12f5
5
void addInterval(String id, String type, String chromo, int start, int end, int strand, String geneId, String trId) { // Get chromosome Chromosome chromosome = getOrCreateChromosome(chromo); // Add gene? if (is(type, TRANSCRIPT)) { // Add gene if needed Gene gene = findGene(geneId); if (gene == null) ...
8f31f9c7-bfb9-42a1-8b57-b411b43c57c2
6
public String[] toFile(TimedTextObject tto) { //first we check if the TimedTextObject had been built, otherwise... if(!tto.built) return null; //we will write the lines in an ArrayList, int index = 0; //the minimum size of the file is 4*number of captions, so we'll take some extra space. ArrayList<St...
c81e25a3-5a6c-48be-b655-9d221db4f626
3
public String[] getSelectedNicks() { Object[] objects = nicklist.getSelectedValues(); String[] nicks = new String[objects.length]; String nick; for (int i = 0; i < nicks.length; i++) { nick = (String)objects[i]; if (nick.charAt(0) == '@' || nick.charAt(0) == '+') nick = nick.substrin...
b664515c-9ac9-4e21-b187-bc0f5307921d
0
public void stopGameLoop() { gameLoopRunning = false; }
bc1be29a-3d06-49b4-ac14-18d7326d2ca3
2
public synchronized void print(String name) { for (int i = 0; i < 20; i++) { System.out.printf("%s %s\n", name, i); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } }
785d3950-5cce-4baf-8183-33a5dac037d8
7
private <T> boolean circularInjectAnnotatedSetters(Object bean, Class<T> typeForCircularAutowiring, Object beanForCirularAutowiring) { Method[] methods = beanForCirularAutowiring.getClass().getDeclaredMethods(); boolean methodFound = false; for(Method method : methods){ if(method.isAnnotationPresent(Circul...
dc1eee44-dfbe-4336-b702-4769ff874ffe
9
public static boolean compareFilesRecursive(File f1, File f2) throws IOException { // Same files should be equal, don't need to compare if (f1.equals(f2)) return true; try { if (f1.isFile()) { // if f1 is a file and f2 not, they are not equal if (!f2.isFile()) return false; // if both ar...
091268dd-6ed9-4832-b4c6-f2dbe9a9f58c
8
private int negxW(int dest) { clearFlags(SR_X, SR_N, SR_V, SR_C); int result = -dest - (isExtendedSet() ? 1 : 0); if (msbSetW(result)) setFlag(SR_N); if (!isZeroW(result)) clearFlag(SR_Z); if (msbSetW(dest) && msbSetW(result)) setFlag(SR_V); if (msbSetW(dest) || msbSetW(result)) setFlag(SR_C); ...
9ade426a-8e43-4c40-bb42-b3d820ae6c93
9
public int compareTo( Object obj ) { if( obj == null ) { return( 1 ); } else if( obj instanceof GenKbMemoByUDescrIdxKey ) { GenKbMemoByUDescrIdxKey rhs = (GenKbMemoByUDescrIdxKey)obj; if( getRequiredContactId() < rhs.getRequiredContactId() ) { return( -1 ); } else if( getRequiredContactId() > r...
aaf61e39-bbce-49a7-b89d-b1224af344eb
3
public static boolean valida_login(String login) { String login_pat = "^[A-Za-z0-9ñ_]+$"; if (login == null) { return false; } return login.matches(login_pat) && login.length() >= 4 && login.length() <= 15; }
378cd8f0-6d86-420d-8b8d-2525036e6638
2
@SuppressWarnings("unchecked") ArrayList new9() /* reduce AAclassdecl4Classdecl */ { @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList(); @SuppressWarnings("unused") ArrayList nodeArrayList6 = pop(); @SuppressWarnings("unused") ArrayList nodeArrayList5 = pop(); @Sup...
abab708f-0376-46ce-a4bf-c95a47867074
1
private void setKol(int kol) throws IllegalArgumentException { if (rij <= 0) { throw new IllegalArgumentException("Kolom mag niet onder 0 gaan"); } this.kol = kol; }
55a2ed95-746f-4eea-88f4-b38bc6f217cd
0
public static void main(String[] args) { Runnable r = new Runnable(){ @Override public void run() { System.out.println("My Runnable"); }}; Runnable r1 = () -> System.out.println("My Runnable"); // System.out.println("Run2"); r1....
7d586cfa-0b0f-4ac4-b7ea-4964005cf6de
9
private String jsonString(PositionalBufferedStream in,int quote) throws IOException { StringBuilder b=new StringBuilder(); int c; while(((c=in.read()))!=-1) { if(c=='\\') { switch(c=in.read()) { case -1:throw new IOException("\\ followed by EOF"); case 'n': b.append("\...
930e342d-0430-4d7d-8e59-dfaec7c331c3
2
public String includeGlobalMethodInMenu(Method m, String defaultText) { if(m.getName().equals("reset")) { int size = Tools.getNodeList().size(); if(size == 0) { return null; } else { return "Reset all " + Tools.getNodeList().size() + " nodes"; // a context sensitive menu entry } } return defa...
96366f25-b70b-4b3d-a0a9-fbebd379ed3c
3
private boolean equalArrayLists(ArrayList<LevelItem> a, ArrayList<LevelItem> b) { if (a.size() != b.size()) return false; for (int i = 0; i < a.size(); i++) if (a.get(i) != b.get(i)) return false; return true; }
bc3a82a5-b9ad-4320-9bb9-f301da8b58e8
7
private void submitAndWaitForAllFromNonWorkerThread(final TaskGroup taskGroup) { //** reporting missing while (taskGroup.hasNext()) { // block until a permit is available ComparableFutureTask ftask = taskGroup.next(); if (ftask != null) // workaround possible concurrency issue { boolean done...
a0c8bb04-02cf-4737-9edb-cc2554aa8634
4
public AnnotationMetadata getNamedAnnotation(final Class<? extends Annotation> clzAnnotation) { if (clzAnnotation == null) return null; String annotationQualifiedName = clzAnnotation.getCanonicalName(); for (AnnotationMetadata annotation : annotations) { if (annotation.getQualifiedName().equals(annotationQu...
1eb3a799-2990-4842-be43-305b5d5b056b
5
public void step(double [] vector){ boolean firstNeuron = true; winnerNET = 0; for(NeuronKoh n : neurons) { n.trigger(vector); if ((n.getLastResult() > winnerNET) || (firstNeuron) || ((n.getLastResult() == winnerNET) && (Math.random() > 0.5))) ...
1c969ed9-6e07-497d-b06c-086e4aeb72cb
9
public static Habitat getHabitat(int i) { switch(i) { case 1: return Cave; case 2: return Forest; case 3: return Grassland; case 4: return Mountain; case 5: return Rare; case 6: return Rough_Terrain; case 7: return Sea; case 8: return Urban; case 9: return Waters_Edge; }...
28f1f758-aed7-4b3b-b1c9-1488bdfc7f87
5
protected void test(URL aURL, int[] aDetailCode) { // Zero out any pre-existing exception (not thread-safe obviously) myException = null; // Run a new test try { new WebClient().getPage(aURL); } catch (FailingHttpStatusCodeException details) { int statusCode = details.getStatusCode(); switch (sta...
315661ac-624f-4e0a-9112-cc8578f0d050
0
public byte[] getData() { return data; }
464c58f3-3fa9-4d3f-80f9-97478944ff2f
9
public static void parseAndExecCommand(String args[]) { Command command = Command.UNKNOWN; //required count of arguments for command int argc = 0; if (args.length < 1) { logger.error("Wromg command name"); printUsage(command); System.exit(0); ...
b1bfd530-31e2-430d-a70e-03334f4a2db7
5
public boolean match(Sim_event ev) { if (ev == null) { return false; } boolean result = false; try { // find an event with a matching tag first if ( tag_ == ev.get_tag() ) { Object obj = ev.get_data(); ...
86254112-33d5-4b38-8e30-b7435d960a7c
2
public double[] utteranceWordsScores(String[] units, Boolean[] stresses, Boolean[] boundaries, SubSeqCounter counter) { // Get slices of the stresses and units in this utterance Object[][] wordsUnits = SegUtil.slicesFromAllBoundaries(units, boundaries); Object[][] wordsStresses = SegUtil.slicesFromAllBou...
21253256-3220-4c84-a92f-eeb2fdafd792
8
public static void dispatchOperation(final JTextPane textResult, String operation, String tableName) { if (operation.contains("refresh")) { HTableDdls.listTables(); } else if (operation.contains("disable")) { HTableDdls.disableTable(tableName, textResult); } ...
faf6d80b-d974-44c3-adf2-3b3d36daa29b
6
@Override public boolean move(int row, int col) { // Vertical if (Math.abs(this.row - row) == 1 && this.col == col) { this.row = row; return true; // Horizontal } else if (Math.abs(this.col - col) == 1 && this.row == row) { this.col = col; return true; } else if (Math.abs(this.row - row) == Math...
d7d667f9-5848-4526-903a-23633bff9312
8
public static double incompleteGammaComplement( double a, double x ) { double ans, ax, c, yc, r, t, y, z; double pk, pkm1, pkm2, qk, qkm1, qkm2; if( x <= 0 || a <= 0 ) return 1.0; if( x < 1.0 || x < a ) return 1.0 - incompleteGamma(a,x); ax = a * Math.log(x) - x - lnGamma(a); if( ax < -MAX...
bdd7e378-84e2-4405-82b3-99fb409fa010
4
@Override public void run() { init(); long start; long elapsed; long wait; // game loop while (running) { long now = System.nanoTime(); long updateLength = now - lastLoopTime; lastLoopTime = now; double delta = updateLength / ((double)OPTIMAL_TIME); // update the frame counter lastFp...
faad351a-fd3d-4dee-94fc-746a58010de9
8
@Override public List<ChessPosition> getTargetPos(ChessPosition current) { List<ChessPosition> pos = new ArrayList<ChessPosition>(); int x,y,upBound,lowBound,leftBound,rightBound,value,cy,cx; int Tdx[] = {0,-1,1,2,2,1,-1,-2,-2} ; int Tdy[] = {0,-2,-2,-1,1,2,2,1,-1} ; int dx[] = {0,0,1,0,-1}; int dy[] = {0,...
a1ed1b48-4198-4743-b735-0fd713832337
1
public final String getSimpleName() { String qname = qualifiedName; int index = qname.lastIndexOf('.'); if (index < 0) return qname; else return qname.substring(index + 1); }
60909650-3b98-4c33-916f-090334d98d87
6
@Override public int compare(Resource left, Resource right) { if (left == null) { return -1; } if (right == null) { return 1; } if (left instanceof ParentResource && !(right instanceof ParentResource)) { return -1; } if (!(left instanceof ParentResource) && right ...
ecb6742c-3d39-44f7-806c-d25f5ca0e1f9
7
public void buildPolygon(Point[] points,int mergeDistance) throws IOException{ //can't draw anything out of a single point! if(points.length < 2 ) throw new IOException(); Polygon polygon = new Polygon(); boolean[] pointAdded = new boolean[points.length]; boolean do...
e326ee83-63a5-443b-a4b5-b0e21abdd2b6
7
public void drawHazards(Graphics2D g) { Color colorBorder = Color.BLACK; Color colorFill = Color.BLACK; int h = 0; while (h < main.map.hazards) { h++; switch (main.map.hazard[h].type) { case MapHazard.TYPE_AVOID : ...
f0b0450a-849b-4f53-82aa-a10b60e9d1ab
5
@Override public void incCount(E data) { //First check to see if data is already present in the HashTable //Get hashcode int hashCode = hasherH.hash(data) % table.length; //If data is already present, find it in the table and increment its count //It may not be in the first place we look - if so, use the ...
5fe70b24-1d16-4f44-aaa8-5e4f542b1a1c
5
private static void maxheap(List<Element> a, int i) { left = 2 * i; right = 2 * i + 1; if (left <= n && a.get(left).getValue() > a.get(i).getValue()) { temp = a.get(left).getNumberOfComparison(); a.get(left).setNumberOfComparison(++temp); temp = a.get(i).getN...
68cc14aa-a1a2-4bac-88b3-dcea4c5c5ada
3
public boolean deleteSong(String path, String fileName) throws SQLException { if (connection == null) { connection = getConnection(); } if (deleteSongStmt == null) { deleteSongStmt = connection.prepareStatement("DELETE FROM org.MUSIC " + "WHERE file_name = ? "+ "AND folder_path = ?"); ...
1a07b97e-a088-4eab-b31d-0668856baa99
6
public boolean equals( Object other ) { if ( _set.equals( other ) ) { return true; // comparing two trove sets } else if ( other instanceof Set ) { Set that = ( Set ) other; if ( that.size() != _set.size() ) { return false; // different sizes, no need ...
3fe95658-0441-43ee-839d-e62e3a1d8cbf
4
public static HashMap<String, Integer> countDefects(Scanner ifile1) { /* instantiate HashMap */ HashMap<String, Integer> defectMap = new HashMap<String, Integer>(); /* initialize variables */ int fieldCount = 0; int yearCount = 0; int yearFieldNumber = 4; Str...
98e34e05-3783-4337-987d-442f96a37ff1
6
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); response.setCharacterEncoding("UTF-8"); PrintWriter out = response.getWriter(); out.print("本网站有以下书籍: <br/> "); Map<String, Book> map = DB.ge...
261e96aa-4ad9-4ba0-93d3-9a37ff83efd0
1
public java.security.cert.X509Certificate[] getAcceptedIssuers() { java.security.cert.X509Certificate[] chain = null; try { TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); KeyStore tks = KeyStore.getInstance("JKS"); tks.load(this.getClas...
8059b342-8a94-4742-9b27-2223d1664767
0
public void setUserName(String username) { mUserName = username; }
1e6b0151-e03b-4e20-a033-b160e64e9b8d
2
public ItemStack getIcon(Player viewer) { ItemStack i = new ItemStack(this.getMaterialId(), 1, (short) this.getMaterialData()); ItemMeta meta = i.getItemMeta(); meta.setDisplayName(this.getName()); if (this.lore != null && this.lore.length > 0) { meta.setLore(Arrays.asList(th...
c07a54f9-da41-479c-afab-cee7e2dce97a
5
@SuppressWarnings("deprecation") public boolean onCommand (CommandSender sender, Command cmd, String commandLabel, String[] args) { Player player = (Player) sender; if(commandLabel.equalsIgnoreCase("heal")) { if(sender.hasPermission("basics.command.heal.self")) { if(args.length == 0) { player.setHealth...
4efd815e-f187-48a5-92fa-3f2457d5704b
0
public String getCode() { return code; }
e5bd7135-2155-4f1a-a924-9ef878e40a15
4
protected void transform(final Cursor cursor) { final ColumnMapper mapper = getColumnMapper(); final Field[] fields = Reflection.getNonStaticDeclaredFields(this.getClass()); for (Field field : fields) { if (!isMultiValued(field) && !isTransient(field)) { mapper.setValueToObject(cursor, field, this); } ...
041ae4b3-5965-4774-bcbb-0066405a175b
2
private final void checkDateCounter() { Calendar today = new GregorianCalendar(); today.setTime(Config.getDate()); today.set(Calendar.HOUR, 0); today.set(Calendar.MINUTE, 0); if (countDate.before(today)) { countDate = new GregorianCalendar(); // Set all counters to zero for (Opponent opp : highMone...
4d3fef37-bb22-4e6e-8791-aaac8bfdd5ca
4
@Test public void testToStringServerMessageQueueWithMessages() { LOGGER.log(Level.INFO, "----- STARTING TEST testToStringServerMessageQueueWithMessages -----"); try { server1.setUseMessageQueues(true); } catch (TimeoutException e) { exception = true; } ...
fa5f0fa3-8527-4ed1-9ae1-4287959b38d9
1
@Test public void testparseStringDate() { try { Date d = dformat.parseStringDate(sf,date); assertEquals(date,d.toString()); } catch (ParseException e) { e.printStackTrace(); } }
eee422ab-3f3d-44bd-9544-bd8db31f8229
0
public final String getName() { return _name; }
778a030d-0ad1-47c0-85d1-af46ec712fc4
5
private void cmdFEATURED(ArrayList<String> args) { if (status >= EXPECTING_FEATURED) { if (args.size() >= 0) { clientFeatures = new ArrayList<String>(); for (String a : args) { for (String b : serverFeatures) { if (a.equals(b)) { clientFeatures.add(a); } } } } else { ...
b8138eac-a05e-4750-941d-d0920e23fe2d
5
public void printGame() { final StringBuilder board = new StringBuilder(); for (int y = 0; y < GameBoard.BOARD_LENGTH; y++) { for (int x = 0; x < GameBoard.BOARD_LENGTH; x++) { if (gameBoard.isOwnedByP1(y, x)) { board.append("X"); } if (gameBoard.isOwnedByP2(y, x)) { board.append("O"); ...
9792b86b-d92b-4815-a0e0-9607cb2799e9
2
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((DronePop == null) ? 0 : DronePop.hashCode()); result = prime * result + canHold; result = prime * result + ((loc == null) ? 0 : loc.hashCode()); result = prime * result + state; return result; }
a7d8fd69-9ed3-4bd7-9a31-f05e5068f100
3
@Override protected Value evaluate(ExecutionContext executionContext) throws InterpretationException { Value valA = ((AbsValueNode) this.getChildAt(0)).evaluate(executionContext); Value valB = ((AbsValueNode) this.getChildAt(1)).evaluate(executionContext); if (valA.getType() == VariableTyp...
1a20f4b1-f8b7-4a58-82c4-b1f3116924f5
5
public static void update() { for (int i = 0; i < 6; i++) { if (marqueedLines[i] != null) { marqueedLines[i].doIncrement(); println(i + 1, marqueedLines[i].getPrintableString()); printed[i] = true; } } int queuedLineIndex = ...
e318233d-7abf-4bd9-8206-a0cf53dc5a61
2
public void changeQuote(char newQuote) throws BadQuoteException { if (newQuote == quote) return; // no need to do anything. if (!charIsSafe(newQuote)){ throw new BadQuoteException(newQuote + " is not a safe quote."); } updateCharacterClasses(quote, newQuote); // keep a record of the current quote. quote ...
ce274fa8-3e85-4a8d-ac86-9119fec4c368
5
public void checkBrick(){ Brick brick = (Brick)getOneIntersectingObject(Brick.class); if ( brick != null ) { if (getY() > brick.getY() || getY() < brick.getY()) { changeY = -changeY; // Fixes multi-kill bug setLocation(getX(...