method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
903bdd1a-c43a-418a-ad3a-133bfaad15f3
1
@Override public void addAlias(String alias) { if(!dynamicAliases.contains(alias)) { dynamicAliases.add(alias); } }
e62ec08a-9af2-4981-a000-97d0aacd9ab3
2
protected void processMouseEvent(MouseEvent e) { if (e.getID() == e.MOUSE_PRESSED) { if (hasFocus()) { int code = InputManager.getMouseButtonCode(e); mapGameAction(code, true); } else { requestFocus(); } ...
c7e9e624-7403-459a-a81e-47262337447c
2
public ArrayList<Coordinates> getCoordinates() { ArrayList<Coordinates> coordinates = new ArrayList<>(); for (int i = 0; i < getSize(); i++) { if (getOrientation() == eOrientation.Horizontal) { coordinates.add(new Coordinates(startPoint.getX() + i, startPoint.getY())); ...
1b59c5fa-2cc4-4651-bf08-0725dba0ade5
9
public void moveForward() { if (onBoard) { // store the last upper right & lower left; i use this in barrier // conflicts to tell which way I hit the barrier Rectangle bulletBox = getBoundingBox(); lastUpL = bulletBox.getLocation(); lastLowR = new Poin...
c5b772ce-6586-4d3f-95ea-5f4067819645
6
public <T extends JTextField> void rangeFix(T text){ try { double value = Double.parseDouble(text.getText()); double min = 0; double max; if (text != field_freq && text != field_volume) max = 1; else if(text == field_freq) max = 10000; else max = 100; if (value > max) v...
24a69e30-dc10-45f0-b58a-ec33de9c37c0
0
public SourceLine(String line) { sourceLine = line; possibleBreakpoint = false; breakpointSet = false; }
adc3f3f2-0e29-4937-917c-c3380ee44229
3
private static String findRealEncoding(String presetEncoding, URLConnection connection) { String realEncoding = connection.getContentEncoding(); if (realEncoding != null) return realEncoding; String type = connection.getContentType(); if (type != null) { final St...
e542054e-8f13-4283-9a9b-72cf4f74717b
8
public static void copy(InputStream input, File target) throws IOException { if (target.exists()) { throw new IOException("File already exists!"); } File parentDir = target.getParentFile(); if (!parentDir.exists()) { if (!parentDir.mkdirs()) { throw new IOException("Failed at creating directories!")...
908e6e0f-0c65-4c9a-a85a-492fd4353bdb
9
@Override public ArrayList<Chord> run() { int bar = 0; // For each bar up to 8 generate a random chord while (bar < 8) { switch ((int)(Math.random()*7)) { case 0 : chordProg.add(mapping.newChord(1, 0)); break; case...
4dcf8a80-0912-4948-8995-ec3259671899
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...
dc515d8d-0257-4498-a99c-8032a0bedb2e
2
public void testGetField() throws Throwable { MockPartial mock = new MockPartial(); assertEquals(BuddhistChronology.getInstanceUTC().year(), mock.getField(0)); assertEquals(BuddhistChronology.getInstanceUTC().monthOfYear(), mock.getField(1)); try { mock.getField(-1);...
7bbed50e-7af0-42cd-adb4-13e807fa4aae
2
public boolean equals(Object obj) { if (obj != null) { if (obj instanceof Task) { return title.equals(((Task) obj).getTitle()); } } return false; }
57cc7768-35ff-4a49-87e6-a0dcc46e147a
3
public static FilesParsed getFileByPath(String customerGroupNumber, String absolutePath) throws IOException { try { Connection con = connection; final Statement stmt = con.createStatement(); final ResultSet rs = stmt.executeQuery("SELECT * FROM files_parsed WHERE customerGroup = " + customerGroupNumber ...
c38164f2-8f6d-47f6-abe8-cc8eab6752f8
9
private boolean validAddress(String s) { if (s != null && (s.length() > 26 && s.length() < 35) && (s.startsWith("1") || s.startsWith("3")) && !s.contains("0") && !s.contains("O") && !s.contains("I") && !s.contains("l")) return true; else return false; }
9a8bd5f7-5dcc-4dfe-9a08-aa5f309750a2
1
@Override protected void validateTestMethods(List<Throwable> errors) { List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(Test.class); for (FrameworkMethod eachTestMethod : methods) { eachTestMethod.validatePublicVoid(false, errors); } }
ed839e7d-66c5-4d27-8dfb-a00b17306d29
4
@Override public boolean containsBoolean(String name) { JOSObject<? , ?> raw = this.getObject(name); if(raw == null) return false; if(raw.getName().equalsIgnoreCase(BOOLEAN_NAME)) return true; return false; }
7328ac15-550d-4d19-8dc4-c32bc533bd68
1
public int getRightmostData( ) { if (right == null) return data; else return right.getRightmostData( ); }
3a31c7a1-b44e-4218-8ad0-366a7836cbd5
2
public void dumpInstruction(TabbedPrintWriter writer) throws java.io.IOException { if (!isEntered) writer.println("MISSING MONITORENTER"); writer.print("synchronized ("); if (object != null) object.dumpExpression(writer.EXPL_PAREN, writer); else writer.print(local.getName()); writer.print(")"); ...
36f86fa0-be88-4cb9-91f5-3953b92e4dac
4
public static Object div(Object o1, Object o2){ if (o1 instanceof Integer && o2 instanceof Integer){ return ((Integer)o1) * ((Integer)o2); } else if (o1 instanceof Number && o2 instanceof Number){ return ((Number)o1).doubleValue() * ((Number)o2).doubleValue(); } return 0; }
5fd287bc-1160-4523-bbe3-67eb7dfe1bad
6
public void removeAnimal(Entity e){ Set<String> farmers = plugin.getAnimalData().getConfigurationSection("Farmer").getKeys(false); for(String farmer : farmers){ Set<String> farmeranimals = plugin.getAnimalData().getConfigurationSection("Farmer." + farmer + ".Animals").getKeys(false); for(String farmanim...
85bd3b4f-b67d-42bb-a0fb-e03a29ee622b
6
public static void main(String args[]) { Scanner sc = new Scanner(System.in); int T=sc.nextInt(); int testCase = 0; while(T>0) { T--; int N=sc.nextInt(); testCase++; long mile = 0 ,juice=0; while(N>0) { ...
0e712948-fcab-49a7-8f1b-c53cdfec35e8
7
public static final int ban(final String banMe) { if((banMe==null)||(banMe.length()<=0)) return -1; final List<String> banned=Resources.getFileLineVector(Resources.getFileResource("banned.ini",false)); if((banned!=null)&&(banned.size()>0)) for(int b=0;b<banned.size();b++) { final String B=banned.get(b)...
6f29b352-338b-45d4-bc36-ca307c061a81
2
public void run() { try { sleep(10000); // 10s until work starts. while (true) { System.out.println(theBuffer.getLine()); } } catch (Exception e) {/* Let thread terminate. */}; } // run
2e78f459-7a36-47ba-9031-2cbb08575045
7
@Override public boolean accept(CourseRec rec) { if (!this.active) return true; // Has at least one self-paced offering. boolean selfPaced = rec.isSelfStudy(); for (OffRec ofr : rec.getOfferings()) selfPaced = selfPaced || ofr.isSelfPaced(); if (selfPaced && selected.contains(SELF_PACED)) return tru...
e7110a6c-297e-44c3-af08-736ac4f057f1
6
public void paint() { BufferStrategy bs = getBufferStrategy(); if (bs == null) { createBufferStrategy(3); return; } Graphics2D g = (Graphics2D) bs.getDrawGraphics(); g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints....
58a534c7-86c1-433a-a01c-6bfb831c45d2
1
public void secondPassed(Planet nearbyPlanet) { if (nearbyPlanet == null) { // What?! No nearby planet? It's madness! At least not worht being simulated. return; } final Gravity currentGravity = nearbyPlanet.getGravity(); // this is the specified bouncing algorithm. It is terribly wrong though, a ball c...
4edede14-ea9e-4a85-99c0-108d6a937617
7
private void btnRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveActionPerformed // TODO add your handling code here: try { int d = jList3.getSelectedIndex(); int e = jList3.getLastVisibleIndex(); int f = jList3.getFirstVisibleIndex(); int i = jList3...
e593fa4e-b702-4b99-b8fd-fd70a3c6033d
7
public static final int getExpRate(byte village) { switch (village) { case 0: return 1000; case 1: return 1000; case 2: case 3: case 4: return 600; case 5: return 750; ...
36bf7a7c-6a64-49d0-97e1-171bf8ba62d5
1
public void remove(UsuarioBean oUsuarioBean) throws Exception { try { oMysql.conexion(enumTipoConexion); oMysql.removeOne(oUsuarioBean.getId(), "usuario"); oMysql.desconexion(); } catch (Exception e) { throw new Exception("UsuarioDao.removeCliente: Error: ...
4d570569-347f-418c-86c3-024c01aac41d
8
public void render() { for(Interactable i: addons) { int [] image = i.getCurrentPixelArray(); for(int xx=0;xx<i.getWidth();xx++) { for(int yy=0;yy<i.getHeight();yy++) { if(i.getX()+yy>=0 && i.getY()+yy<height && i.getX()+xx>=0 && i.getX()+xx<width) { if(image[xx + yy* i.getWidth()]...
5f5d1246-9a9e-4df8-9298-d471ef870280
1
protected Integer calcDataSecCnt() { int TotSec; if (BPB_TotSec16 != 0) { TotSec = BPB_TotSec16; } else { TotSec = BPB_TotSec32; } dataSecCnt = TotSec - (BPB_ReservedSecCnt - (BPB_NumFATs * FATSz) + RootDirSectors); System.out.println("Data...
c4d0345d-c153-4f21-98be-6511e7c2f7c8
5
public String toString(){ Method[] methods = this.getClass().getMethods(); String output = ""; int nbMethods = methods.length; for( int i= 0; i< nbMethods; i++){ Column col = methods[i].getAnnotation(Column.class); Class<?>[] parameters = methods[i].getParameterTypes(); if (parameters.length ...
a617f56c-c400-44ab-8ea7-7abe2fd86e37
7
private MapEntry findFreeEntryByLength(int index, int realLength) throws IOException { FreeEntry freeEntry = freeEntries[index]; if (freeEntry.count > 0) { // possible candidate synchronized(freeEntry) { if (freeEntry.count > 0) { FreeNode p = freeEntry.first; FreeNode q = p; ...
e6d734a0-d4ef-4342-b8ae-44fb2a25c568
6
@Override public void processPacket(Client c, int packetType, int packetSize) { if (c.inTrade) { if(!c.acceptedTrade) { Misc.println("trade reset"); c.getTradeAndDuel().declineTrade(); } } Client o = (Client) Server.playerHandler.players[c.duelingWith]; if(o != null) { if(c.duelStatus >= 1 &&...
c3e69def-8a22-46c0-af1a-3e3b2162256b
5
public static void writeJSON( Writer writer, String string ) throws IOException { writer.write( '"' ); for( int i = 0; i < string.length(); i++ ) { char c = string.charAt(i); switch( c ) { // There are double quotation marks, so there is no need to escape single quotes. // Additionally esc...
e0e3e8ae-83fe-45e1-9cd2-9b736599762d
4
private TileSet unmarshalTilesetFile(InputStream in, String filename) throws Exception { TileSet set = null; Node tsNode; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder builder = factory.newDocumentBuilder(); ...
4c41dc6d-8b1c-4939-a0fe-53302e46b49f
1
public void testConstructorEx2_Type_int_Chrono() throws Throwable { try { new Partial(DateTimeFieldType.dayOfYear(), 0, ISO_UTC); fail(); } catch (IllegalArgumentException ex) { // expected } }
6ed625c4-36e1-4159-8a89-b3c941715c2c
9
private void endOfOperandFormatBlockErrorCheck() throws AssemblerException { // Error checking after all lines of an operandFormat declaration have been read ArrayList<String> instructionFormat = currentMnemFormat.getInstructionFormat(); int totalBits = 0; for (String instruction : instructionFormat) { ...
0eca01c4-27f7-405d-89ba-01c55201254e
7
@Override public List<String> getStageCodes(String baseExpertiseCode) { String key=null; if(baseExpertiseCode==null) return new ReadOnlyVector<String>(1); baseExpertiseCode=baseExpertiseCode.toUpperCase(); if(!baseEduSetLists.containsKey(baseExpertiseCode)) { synchronized(("ListedEduBuild:"+baseExpert...
5dd32015-ce42-4a08-aa9d-4249817e2a51
2
public void tick(){ if(SubTerra.getLevel()!=null && SubTerra.f!=null){ SubTerra.f.gp.update(); } }
ec5a24be-29a0-4a80-871c-4a1c63b6a780
9
protected boolean createTunnelToTarget(HttpRoute route, HttpContext context) throws HttpException, IOException { HttpHost proxy = route.getProxyHost(); HttpHost target = route.getTargetHost(); HttpResponse response = null; for (;;) { ...
a9d2ae1c-b0a8-4038-a43b-24c15ba94adb
2
public ArithmeticDecoder(BitInputStream in) throws IOException { super(); if (in == null) throw new NullPointerException(); input = in; code = 0; for (int i = 0; i < STATE_SIZE; i++) code = code << 1 | readCodeBit(); }
de78126a-2868-419f-ad03-bb8f472f8988
1
public void SheepToBatiment(List<Sheep> sheeps){ for(Sheep sheep:sheeps){ sheep.setBatiment(this); } this.sheeps = sheeps ; }
16c8df03-6845-4b19-96af-fc51dc77cb20
0
public Integer getFoo() { return foo; }
66cf5438-d842-460c-a49a-93998f65baf8
8
@Override public EObject create(EClass eClass) { switch (eClass.getClassifierID()) { case actionPackage.ATACK: return createAtack(); case actionPackage.SET_TROOPS: return createSetTroops(); case actionPackage.COIN_CARDS: return createCoinCards(); case actionPackage.MOVE_TROOPS: return createMoveTroops();...
ba0b5296-e316-47be-9e90-17b65f245867
2
public NetworkGameScreen(JFrame parent, NetworkGameType networkGameType) { this.networkGameType = networkGameType; this.parent = parent; this.width = parent.getContentPane().getWidth(); this.height = parent.getContentPane().getHeight(); super.setSize(width, height); this....
89224eaf-a1e7-4e4e-8865-44927f8061cf
6
private void paintWinOrLoseMessage(Graphics2D g2d) { g2d.scale(getWidth() / 53, getHeight() / 36); if( Field.isWin && Field.isLose) { g2d.setColor(Color.BLUE); g2d.drawString("Ничья", 11, 20); } else if (Field.isWin && !Field.isLose) { g2d.setColor(Color.DARK...
fd6ff5ba-1614-4db0-bab0-62f98a734e87
6
public static Set<Node> decodeSet(String input) throws IllegalArgumentException { // System.out.println("Decoding:"); // System.out.println(input); String[] split = input.split("\\n",2); if (!split[0].equals("Set")) throw new IllegalArgumentException(); String curInput = split[1].trim(); split = c...
679cd765-d763-4606-b962-21e0c6e193f2
5
void merge( FragList fl, ArrayList<Version> sigla, ArrayList<Group> groups, BitSet constraint ) throws Exception { if ( !fl.isEmpty() && isEmpty() ) this.fragments = fl.fragments; else if ( !fl.isEmpty() && !isEmpty() ) { // ensure that the edit script is fre...
395ea4f0-a593-4daf-ab0c-94fe2d161a26
0
public void handleUpdate(Logger log) { log.log(this.level, this.message); }
96761333-298a-493d-ba86-f8692f911064
2
public static void main( String[] args ) { FabrykaElementowGraficzny fabryka = new FabrykaElementowGraficzny(); ArrayList<GraphicObject> document = new ArrayList<GraphicObject>(); HashSet<String> test = new HashSet<String>(); test.add( "darek" ); test.add( "dybka" ); ...
50211140-2b68-4b51-afa9-8fba45488554
7
public int minDepth(TreeNode root) { if (root == null) return 0; int level = 1; int currentLevel = 0, nextLevel = 0; Queue<TreeNode> nodes = new LinkedList<TreeNode>(); nodes.add(root); currentLevel++; while (nodes.size() > 0) { TreeNode node = nodes.poll(); currentLevel--; if (node.left == nu...
c8d8385e-9692-4d9c-bad4-af66628e0c02
5
public static void disposeImages() { // dispose loaded images { for (Image image : m_imageMap.values()) { image.dispose(); } m_imageMap.clear(); } // dispose decorated images for (int i = 0; i < m_decoratedImageMap.length; i++) { Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decora...
3207ec05-eb84-49d8-95c6-e51534a8eebe
3
private int jjMoveStringLiteralDfa8_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 7); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return jjMoveNfa_0(0, 7); } switch(curChar) { case 45: return jjMoveStringLiteralD...
8472a68a-8801-4f36-882e-91f743c7c95c
7
static JMenuItem createJMenuItem(ResourceManager rm, String itemId) { final boolean autoMnemonic = rm.getInt("auto-mnemonic") == 1; final String itemKey = "item." + itemId; final char mn = rm.getChar(itemKey + ".mnemonic"); final String shortcutKey = itemKey + ".shortcut"; final ...
375ba25a-9a97-43bb-a66d-fee433a93de7
0
public void setInfoLog(LogFile infoLog) {this.infoLog = infoLog;}
3054f910-fce7-4fe2-a12b-ea53c5521e8e
7
private static List<String> getCommonCharacters(String string1, String string2) { List<String> lstReturnCommons = new ArrayList<String>(); HashMap<String, Integer> unique = new HashMap<String, Integer>(); char[] char1 = string1.toCharArray(); char[] char2 = str...
c56c6075-741c-44a2-83ef-c70aa1719956
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...
d042ea07-c851-4425-b84e-5ca754e092b4
5
private boolean isAllEmpty() { return (artistNameTextArea.getText().length() == 0) && (genreTextArea.getText().length() == 0) && (areaTextArea.getText().length() == 0) && (recordingTextArea.getText().length() == 0) && (releaseTextArea.getText().length() == 0) && (mediumTextArea.getText().length() ...
2e0dc2bc-34eb-43a3-9c98-5a196ceea366
7
public void create(Patients patients) throws RollbackFailureException, Exception { if (patients.getConsultsCollection() == null) { patients.setConsultsCollection(new ArrayList<Consults>()); } EntityManager em = null; try { utx.begin(); em = getEntityManager(); Collection<Consults> attachedConsultsCo...
69399ba6-a3ab-4110-ab80-ea49556114ff
6
private String nextQuotedValue(char quote) throws IOException { // Like nextNonWhitespace, this uses locals 'p' and 'l' to save inner-loop field access. char[] buffer = this.buffer; StringBuilder builder = new StringBuilder(); while (true) { int p = pos; int l = limit; /* the index of ...
f776ca24-b24e-41f9-819b-68b59b07f142
5
public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = ""; StringBuilder out = new StringBuilder(); fillSet(); d: do { line = br.readLine(); if (line == null || line.length() == 0) break d; long n = Long....
559d718a-6ba6-497c-8a41-a0edcdf612fb
4
private void iniciarElTablero(){ for (int i = 0; i < tablero.length; i++) { for (int j = 0; j < tablero[i].length; j++) { tablero[i][j]="|__|"; //░ } } for (int i = 0; i < tablero[1].length; i++) { tablero[1][i]="|PN|"; ...
92d1d282-8312-4905-ad9a-df32f9528398
2
public static void onEvent(Event event) { if (event instanceof ScannedRobotEvent) { onScannedRobot((ScannedRobotEvent) event); //send scan event to it's method } else if (event instanceof RobotDeathEvent) { onRobotDeath((RobotDeathEvent) event); //send death event to it's method ...
1af24716-2f8e-42fb-bd86-23b2f7141d9a
3
public int cdlRickshawManLookback( ) { return ((( ((( (this.candleSettings[CandleSettingType.BodyDoji.ordinal()].avgPeriod) ) > ( (this.candleSettings[CandleSettingType.ShadowLong.ordinal()].avgPeriod) )) ? ( (this.candleSettings[CandleSettingType.BodyDoji.ordinal()].avgPeriod) ) : ( (this.candleSettings[Candl...
c4c99a1b-9892-47ee-a7cb-355bf7910214
6
*/ public void applyConfig(String config) { try { StringTokenizer tokenizer = new StringTokenizer(config, "\t"); //$NON-NLS-1$ if (getInteger(tokenizer, 0) == OutlineModel.CONFIG_VERSION) { int count = getInteger(tokenizer, 0); List<Column> columns = mModel.getColumns(); boolean needSort = false; ...
37ad9bef-001b-4703-acf5-edbcc2e2548e
7
public void load(JavaPlugin plugin) { File file = new File(plugin.getDataFolder(), FILE); if (file.exists()) { FileInputStream fileStream = null; ObjectInputStream objectStream = null; try { fileStream = new FileInputStream(file); objectStream = new ObjectInputStream(fileStream); PluginConfig...
d33fd6ba-39f1-4493-baa8-cff27ed1837e
1
public void testWriteStringWiderThanColumnDefinition() throws Exception { final StringWriter out = new StringWriter(); final Writer writer = new FixedWriterFactory(this.getMapping()).createWriter(out); try { writer.addRecordEntry("STATE", "THISISTOOLONG"); Assert.fail("wr...
4e020fc1-3299-40b6-b1fa-e6fafd3b3050
5
private void transResult(Map<String, Object> map, Object obj){ for(String key : map.keySet()){ key.toLowerCase(); } for (Field field : obj.getClass().getDeclaredFields()) { final String name = field.getName(); if (name.equalsIgnoreCase("serialVersionUID")) { continue; } field.setAccessibl...
621a6d14-1948-4128-a4e7-bf9c8f968402
6
@Override public Result value(final Function<Double, Double> function) { Result result = null; try { HashMap<Integer, Double> values = new HashMap<Integer, Double>(); double lowerBound = this.getRegion().getLowerBound(); double length = this.getRegion().ge...
dccd7a6a-c5c3-4f51-924a-481c48514134
7
public void UpdateRecentFiles(String filename) { int cnt = recentFiles.length; String [] newFiles = new String[cnt]; newFiles[0]=filename; int i,j=1; for(i=0;i<cnt;++i) { if(!filename.equals(recentFiles[i]) && recentFiles[i] != "") { newFiles[j++] = recentFiles[i]; if(j == cnt ) break; } ...
63d89e72-b25a-4b90-a11c-fd30cc0b41ae
6
public void setCurrent(int numberResults, Double timeInSeconds) { if(run>=0 && timeInSeconds>=0.0) { int queryNr = queryMix[currentQueryIndex].getNr()-1; int nrRuns = runsPerQuery[queryNr]++; aqet[queryNr] = (aqet[queryNr] * nrRuns + timeInSeconds) / (nrRuns+1); avgResults[queryNr] = (avgResults[queryNr...
8956a50f-2bd1-474b-901f-0622b7d1bd72
7
public void selectionChanged(SelectionChangedEvent event) { super.selectionChanged(event); try { ISelection selection = event.getSelection(); if (!selection.isEmpty()) { Object element = ((IStructuredSelection)selection).getFirstElement(); int column; int line; int length = 1; if ((...
4aae4339-3ec1-4052-9d25-e7724627fd6d
2
public void deselect() { if (selectedNode instanceof Shape3D) { ((Shape3D) selectedNode).setAppearance(selectedAppearance); } else if (selectedNode instanceof Primitive) { ((Primitive) selectedNode).setAppearance(selectedAppearance); } selected = null; selectedNode = null; selectedAppearance = null; ...
e3b02379-f0c3-441d-a065-250e56cd7c34
4
public void test(int down, int left, int right) { if(down == fill){ sum ++; return; } int canNot = down | left | right; if(canNot == fill) return; for (int i = 0; i < n; i++) { int put = 1 << i; if ((canNot & put) == 0)...
1aedde91-c761-4723-8143-299699c9c8f2
7
public GrepServer() { //System.out.println("Listen: Construct Start"); for (int i = 1024; i < 1500; i ++) { try { sock = new ServerSocket(i); } catch (IOException e) { System.err.printf("Could not listen on port: %d, Trying %d\n", i, i+1); continue; } break; } //System.ou...
917f369f-4d50-491a-b9b0-18c574888607
1
public void disconnectMySQL (){ try { conn.close(); System.out.println("DB Closed!"); } catch (SQLException e) { e.printStackTrace(); } //conn = null; }
aba0b28d-638d-48af-8823-4e43b6f48fb6
5
public char[] read(int index, int count) throws Exception { char[] returnValue; //Prevent overflow if(oft.getCurrentPosition(index) + count > oft.getLength(index)) returnValue = new char[oft.getLength(index) - oft.getCurrentPosition(index)]; else returnValue = new char[count]; int counter = 0; whi...
06309dd4-8369-4e43-9d0a-bc510d0d01fe
5
public static void doit() { mainGui.start(); //GUI is needed as a thread to enable better user experience do { while (mainDatabase.getUserInput() == null) { //wait fot the userInput to be set try { Thread.sleep(100); } catc...
7895d7f3-1821-4ccf-a1b7-a13032d17ec5
1
static void verify(boolean invariant, String message) { if (!invariant) { System.out.println("*** ERROR: " + message); Thread.dumpStack(); } }
02517306-483b-4bed-a87c-5461f2d568a6
7
public static long parseTimeInterval(String str) { try { int len = str.length(); char suffix = str.charAt(len - 1); String numstr; long mult = 1; if (Character.isDigit(suffix)) { numstr = str; } else { numstr...
a5520204-13a4-457a-9407-fdb07c3a6f83
8
private void append(String text) { if (text.startsWith("\n")) width = 0; // reset counter if starts with a newline. only from formats above, not in natural text if (text.equals(" ") && (accum.length() == 0 || StringUtil.in(accum.substring(accum.length() - 1), ...
bb9ca03b-ffff-4684-9280-2753555d9daa
0
public Tile(Sprite sprite, String id){ this.sprite = sprite; this.id = id; }
9941bd33-807a-4c5f-927a-03aac9cbbfc9
5
public void getStats() { Iterator sentenceIterator = sentenceMap.entrySet().iterator(); Iterator wordsIterator; while(sentenceIterator.hasNext()) { Map.Entry sentencePair = (Map.Entry) sentenceIterator.next(); Sentence sentence = (Sentence) sentencePair.getValue(); ...
8f1412cb-f5b7-44e1-8ea3-e52071f0054c
3
public void print(TreeNode current) { if(current.hasChild()==false) { } else { Hashtable<Character, TreeNode> currentChildHash = current.getChildHash(); Enumeration<Character> currentChilds =currentChildHash.keys(); while(currentChilds.hasMoreElements()) { Tr...
3808998d-c475-4dc9-90d7-809e5f1c5026
9
@Override public void run(int interfaceId, int componentId) { if (stage == -1) { sendEntityDialogue(SEND_1_TEXT_CHAT, new String[] { player.getDisplayName(), "I'm hoping this is worth the time Reaper." }, IS_PLAYER, player.getIndex(), 12379); stage = 1; } else if (stage == 1) { sendEntity...
2b3e197f-f04d-42cb-b14b-fc15a633772d
4
public void simulateVoltageAndCurrentLevels() { // hss wip // for simulation purposes -- should remove double deltaSim; // simulate value for voltage leds deltaSim = (5 * Math.random()) - 2.5; voltSimLevel += deltaSim; if (voltSimLevel < 0) { voltSimLevel = ...
29868b16-503c-4167-9afb-f4ed346e46c7
6
@Override public void writeAVLData(OutputStream out) { PrintStream ps = new PrintStream(out); ps.print("\nSECTION\n"); // SECTION | (keyword) ps.printf(locale, "#Xle Yle Zle Chord Ainc Nspan Sspace\n" + fo...
ab1af2f9-4c83-4ec7-8f4e-2cdda9d8277e
7
public static void main(String[] args) throws IOException { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { e.printStackTrace(); } DateFormat dateFormat =...
d4e7ffb7-8a9c-4005-b415-6638f0c0f8d0
2
@Test public void preAuth() throws BeanstreamApiException { CardPaymentRequest paymentRequest = getCreditCardPaymentRequest( getRandomOrderId("GAS"), "120.00"); PaymentResponse response = beanstream.payments() .preAuth(paymentRequest); if (response.isApproved()) { PaymentResponse authResp = beanstrea...
0252d440-7fe4-4307-a84d-8a140126ad3a
0
public static Printer03 getInstance() { return singleton; }
d0d5488a-6647-4367-920d-57453bbfef5f
8
private int straightFlashValue(byte[] cards) { boolean[] exists = new boolean[56]; for (byte value : cards) { exists[value + 4] = true; if (value >= 48) { exists[value - 48] = true; } } for (int i = 55; i >= 16; i--) { if (exists[i] && exists[i - 4] && exists[i - 8] && exists[i - 12] && ex...
378c422c-ed0b-4a9e-8ff0-6bf15662d3d7
1
private boolean isPalindrome(int number) { int count = (int) (Math.log10(number) + 1); int res = 0; int tmp = number; for (int i = 1; i <= count; i++) { int dec = tmp % 10; res = res * 10 + dec; tmp = tmp / 10; } return res == number; }
a5eba761-c682-4371-ba66-8d83c8adff6c
2
public Double getDouble() { Object gotValue=getValue(); if (gotValue != null) { if (!Double.class.isAssignableFrom(gotValue.getClass())) { throw new ClassCastException("don't know how to convert " +gotValue.getClass().getName()+" to Double"); ...
8330f6b6-e770-4b78-a050-42afdfb56c64
8
double GetNextDataPoint(int mlist) // mlist < 0 means no list { double val=0; int e; switch (PlotMode) { case 0: break; case 1: // Plot spectrum and Actually displayed marker spectra if (mlist < 0) { if (data3d.GetProjectionMode(2)...
cfea6d6c-43a5-40a3-8b3b-c91d94157dba
9
@Override protected void doPost(final Request request) throws ServletException, IOException, SQLException, IllegalArgumentException, IllegalAccessException { if (!request.getSession().isLoggedIn()) throw new LoginRequiredException("Not logged in"); // Process request, depending on action final String a...
69f4e8d4-0991-4f09-adb6-dd31ecc6354c
1
@Override public String getId() { String id = properties.get(Strings.ID); return id == null ? "" : id; }
9f8227e0-018f-4a2f-b9e6-bf3f29844c4d
9
private static boolean isAssignable(Class<?>[] formal, Class<?>[] actual) { if (formal.length != actual.length) { return false; } for (int i = 0; i < formal.length; i++) { if (actual[i] == null) { if ((formal[i].equals(int.class)) || (...
6464483a-5c8e-49ad-b3ce-e109f9ec04d3
2
public String getDateAndPlace() { return ((date == null) ? "Date unknown" : date.toString()) + ((place == null) ? ", place unknown" : ", " + place.toString()); }
05cab4fb-1245-4e48-bc38-256d6ff32011
2
public static void main(String[] args) { ThreadA threadA = new ThreadA(); threadA.start(); System.out.println("这是主线程:"); ThreadB threadB = new ThreadB(); new Thread(threadB).start(); System.out.println("这是主线程:"); ThreadC threadC = new ThreadC(); FutureT...