method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
47b1946f-83d1-419c-8540-96aaa426826c
1
public Annotation[] getAnnotations() { try { return new Parser(info, constPool).parseAnnotations(); } catch (Exception e) { throw new RuntimeException(e.toString()); } }
b6f7433e-d284-4798-849f-afa9a3c574d3
3
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; String uri = request.getRequestURI(); HttpSession session = request.getSess...
74ecfef9-840d-40af-ad34-105dce7d2701
1
public void reload(final String... names) { final String reloadDone = "OreLog reloaded!"; final LogOre plugin = this; this.onDisable(); Bukkit.getScheduler().runTaskLater(this, new Runnable() { public void run() { plugin.chandle = null; plugin....
bc41bae9-d687-4c0e-8011-9541e10a1588
6
public char winner() { String slots = ""; for (int[] winComb : winCombs) { for (int aWinComb : winComb) slots += getSlot(aWinComb); if(slots.equals("XXXX") || slots.equals("XXX")) return slots.charAt(0); if(slots.equals("OOOO") || slots.equals("OOO")) return slots.cha...
a056146e-dab3-4515-8b87-bd456c4451dd
7
public byte[] processFrame(byte[] frameData) throws IOException { logger.debug("Hybi07-processFrame"); Hybi07Frame newFrame = new Hybi07Frame(); byte[] unusedData = newFrame.populate(frameData); if(!newFrame.isFinalFragment()){ /*TODO: ADD SUPPORT FOR MESSAGE FRAGMENTATION*/ }else{ OpCode frameType = ne...
370b094e-c16b-41dd-9663-deece6134cb0
5
public void add(Object o) throws PropertyException { if (o instanceof Event) addEvent((Event) o); else if (o instanceof Attribute) addAttribute((Attribute) o); else if (o instanceof Note) addNote((Note)o); else if (o instanceof Source) addSource((Source)o); else if (o instanceof Name) setName((...
29a21f22-3b55-4f11-8e20-30dae096c707
1
public void writeTable() { TranslationTable table = new TranslationTable(); basePackage.writeTable(table, false); try { OutputStream out = new FileOutputStream(outTableFile); table.store(out); out.close(); } catch (java.io.IOException ex) { GlobalOptions.err.println("Can't write rename table " ...
f1d89c44-ce54-40e7-8fb2-343bb74ad70c
6
public void renderWithRotation(float par1) { if (!this.isHidden) { if (this.showModel) { if (!this.compiled) { this.compileDisplayList(par1); } GL11.glPushMatrix(); GL11.glTra...
c1a2713d-79ca-4ef7-aa29-ff224b9c30cb
6
public List<Integer> getRow(int rowIndex) { int[] curRow = new int[rowIndex+1]; int[] preRow = curRow; List<Integer> result = new ArrayList<Integer>(); if(rowIndex == 0){ result.add(1); return result; } for(int i=2; i<=rowIndex+1; i++){ ...
e59f9b0f-c287-45f3-a2b5-3f99b1203056
0
public Tower() { super("Tower of Hanoi"); }
d624d7f2-673f-4351-bd77-94e1ffd8a737
8
private void printData () { char[] parts = new char[17]; int partsloc = 0; for (int i = 0; i < data.length; i++) { int d = ((int) data[i]) & 0xff; if (d == 0) { parts[partsloc++] = '.'; } else if (d < 32 || d >= 127) { parts[par...
496ee40b-3914-451a-9778-cbc1c1264c3c
8
@Override public AlgorithmResult<V, E> start(final V vertex, final V startVertex, final V endVertex) throws IllegalGraphException { if (startVertex == null) { throw new IllegalArgumentException("The start vertex can not be null"); } final AlgorithmResult<V, E> algori...
cd6e3396-6ab1-42fa-83a1-06b8b412fed7
7
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Resistor resistor = (Resistor) o; if (current != resistor.current) return false; if (power != resistor.power) return false; if (resista...
1c8c6bf3-a440-4c47-99da-e7838757c840
4
public void setDrivers(final Map<Class<? extends AggregateRoot<?>>, DomainRepositoryDriver<AggregateRoot<?>, ?>> drivers) { this.drivers = drivers; }
c3e12a60-cc97-43fd-b5b8-a9bc40ba45aa
6
private void displayResult(ArrayList<String[]> answerList) { int totalWellDone = 0; int totalQuestion = 0; String[] legend = { "Question", "Expected answer", "Your answer", "" }; String[][] result = new String[20][4]; int x = 0; for (; x < answerList.size(); x++) { totalQuestion++; if (answerL...
aa13b8fa-535b-46bb-a6ea-07a2a1d1f5e5
2
public boolean isScopeOf(Object obj, int scopeType) { if (clazz.equals(obj) && scopeType == CLASSSCOPE) return true; return false; }
85611c6e-5d7a-4c30-a8e1-20c0171b8d82
2
public ArrayList viewBookingCheckout() { ArrayList temp = new ArrayList(); Query q = em.createQuery("SELECT t from BookingEntity t"); for (Object o : q.getResultList()) { BookingEntity p = (BookingEntity) o; if (p.getAccount().getId() == userId) { temp.ad...
1df8cbe5-b871-4635-8544-9bad9ee284d7
5
private void executeDQDataset(String DQDatasetGUID) throws Exception { ArrayList<DQTestResultRecord> dqTestResults = new ArrayList<DQTestResultRecord>(); DQDatasetDefinitionManager dataSetDefinitionManager = new DQDatasetDefinitionManager(DQDatasetGUID); //Set the mandatory parameters //FIXME this needs t...
5be974ce-9c0c-4aef-87c7-696c61c13461
0
public boolean isMobileDevice() { return deviceType.equals(DeviceType.MOBILE); }
258ae246-f388-4a10-9189-898904a9b240
4
public boolean isOver() { // is battle over? if ( end ) { return end; } else if ( _eInPlay.size() == 0 ) { setEnd( true ); winnings(); //gain things } else if ( teamDead() ) { setEnd(true); System.out.println( "\tGAME OVER" ); System.exit(1); } for ( People p : _user.getTeam() ) { ...
bc7fa1f2-0ca5-4fa6-8952-959bb230bf3b
8
public String getDatos(String clave, beansMiembro miembro){ if(clave.trim().equals("nombre")) return miembro.getNombre(); if(clave.trim().equals("nick")) return miembro.getNick(); if(clave.trim().equals("edad")) return Integer.toString(miembro.getEdad()); if(clave.trim().equals("codigo")) return Int...
42b357ec-2d43-4d8f-8ae6-c05a8a54aff3
6
public void treinamento(Double[][] entradas, Double[] saidaDesejada, Double taxaDeAprendizagem, Integer maxEpocas ){ if(!pesosSetados){ gerarPesos(entradas[0].length); } boolean erro; do{ strResult.append("Epoca = ;"+ (quantEpocas) + "\nPesos = ;"); for (Double peso : pesos) { strResult.append(...
9cce6a6f-5dde-460c-b6f0-0ee7ef09b8fb
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof LocalTrabalho)) { return false; } LocalTrabalho other = (LocalTrabalho) object; if ((this.id == null && other.i...
29a30582-cb04-4e44-9ad2-e7d1403bb9de
9
public void applyBackpropagation(double expectedOutput[]) { // error check, normalize value ]0;1[ for (int i = 0; i < expectedOutput.length; i++) { double d = expectedOutput[i]; if (d < 0 || d > 1) { if (d < 0) expectedOutput[i] = 0 + epsilon...
1b8f38d4-d2db-40df-b1e3-0abceda6242f
5
public static List<String> getMidiOutDriverList(){ Info[] infoArray = MidiSystem.getMidiDeviceInfo(); List<String> deviceList = new ArrayList<String>(); for (Info info : infoArray) { try{ MidiDevice device = MidiSystem.getMidiDevice(info); int recMax = device.getMaxReceivers(); in...
f45aa45d-3e68-41c6-88ba-beb1d9a0b103
9
public static void main(String[] args) throws IOException { if (args.length < 1) { throw new IllegalArgumentException("Parameter(s): <Port> ..."); } // 创建一个选择器 Selector selector = Selector.open(); for (String arg : args) { // 实例化一个信道 ServerSocketChannel listnChannel = ServerSocketChannel.open(); /...
56f3ed6f-e995-4492-8ecc-8adfa4a83e4b
8
private int rowIteration(List<StepSetOperation> categorySet, Map<String, String> fields, String tableName, String sql, Connection memConn) throws Exception { ResultSet rs = null; int upRowNum = 0; long time = System.currentTimeMillis(); try { // 修改后的数据 Map<String, Map<String, Object>> afterRowListMa...
79245e0b-9d45-42be-973f-e8dc1247b905
1
public void setTileID(int x, int y, byte id) { if (!(x < getWidth() & y < getHeight() & x >= 0 & y >= 0)) { setTileSet(resize(Math.max(x + 1, getWidth()), Math.max(y + 1, getHeight()), Math.min(x, 0), Math.min(y, 0))); x -= Math.min(x, 0); y -= Math.min(y, 0); } getTileSet()[x][y] = id; }
e2f95797-243e-45fd-8da5-a6056767f21b
3
public static HashMap<Character,Character> rotateMapping(char[] alphabet, int rot) { HashMap<Character, Character> mapping = new HashMap<Character, Character>(); for(int i = 0; i < alphabet.length; i++) { int x = i+ rot; while(alphabet.length<=x) x -= alphabet.length; while(x<0) x += alphabet.le...
b0fd1f0c-201a-419a-a239-8156f6ee460a
3
public boolean saveFile(String path, String content) throws IOException{ FileWriter fichero = null; PrintWriter pw = null; try{ fichero = new FileWriter(path); pw = new PrintWriter(fichero); pw.print(content); } catch (Exception e) { e.prin...
f36ba4d3-a7e3-4c0a-9f54-7f28bf698b42
7
private static FormatInformation doDecodeFormatInformation(int maskedFormatInfo1, int maskedFormatInfo2) { // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing int bestDifference = Integer.MAX_VALUE; int bestFormatInfo = 0; for (int i = 0; i < FORMAT_INFO_DECODE_LOOKUP.length; i++) { ...
551648fd-06a0-4371-8ced-411d19c66fb3
4
void checkForData( String d ) { if ( data != null ) { byte[] bData = d.getBytes(); if ( bData.length == data.length ) { for ( int i=0;i<bData.length;i++ ) if ( bData[i]==data[i] ) System.out.println("Match"); } } }
611c747c-87bc-4e52-b830-8167ec0e1e12
1
public void doCopy(InputStream is, OutputStream os) throws IOException { byte[] bytes = new byte[64]; int numBytes; while ((numBytes = is.read(bytes)) != -1) { os.write(bytes, 0, numBytes); } os.flush(); os.close(); is.close(); }
938214fc-68a6-4d85-aad2-f773d31b7ee4
2
public void read() throws FileNotFoundException, IOException { bits = this.lire.read(); int mask=0x80; for (int i =0; i<8; i++) if ((bits & mask)==0) { mask=mask>>1; System.out.print(0); } else { mask=mask>>1; ...
98632df1-bb2e-4125-9b1f-4155de85c37f
0
public Taso getTaso() { return taso; }
a67b8255-24da-4e04-927d-69bbd32be3a4
8
void tryMove(Vector<Move> pMoves, int pCell, boolean pKing) { int lR = GameState.cellToRow(pCell); int lC = GameState.cellToCol(pCell); // Try moving downwards if(mNextPlayer == Constants.CELL_RED || pKing) { // Try moving right if(this.get(lR+1,lC-1) == Constants.CELL_EMPTY) { ...
988f5d82-b2cb-4c2b-bf4d-f7c32312d3d1
5
public void saveNeuMail(String user, String host, String message) { Mail email = new Mail(user, host, message); File userMailBox = new File(new File(dir.getAbsolutePath()), user); if (!userMailBox.exists()) { userMailBox.mkdirs(); } File file = new File(userMailBox...
a2cc6cf5-318c-4476-a397-709501e5be73
7
private boolean noSolution(boolean[] lookupA, boolean[] lookupB) { // Note that problem constraint is that // 2 <= sizeA, sizeB < N int prev = 0; for (int i = 1; i <= this.numElementsN; ++i) { if (lookupA[prev] && lookupA[i]) { return true; } if (lookupB[prev] && lookupB[i]) { return true; ...
16478b9e-a342-4b75-aafd-5b0f4b2a3c64
2
@Override protected void setReaction(Message message) { try { reaction.add( loadResponse(message.text) ); } catch (ParseException pe) { setError("Cannot parse output.", pe); } catch (Exception e) { setError("Cannot load given URL.", e); } }
33df6317-1f42-4b40-9f3b-cdd119476d69
0
public void expressionChanged(ExpressionChangeEvent e) { setDirty(); }
5199f7f0-e603-4eda-a81b-15339cd1ebed
6
@Override public void performEdit(EditContext context, NinePatchImage npi) throws Exception { File specFile=new File(npi.source.toString() + ".spec"); if (!specFile.exists()) { System.err.println(" - No spec file found " + specFile); } Properties props=new Properties(); FileInputStream in=new FileInpu...
9508bcd7-04ac-4e05-a5c0-f5784da64a73
7
public void selectAnswer() { Set<Card> toRemove = new HashSet<Card>(); for (Card c : deck) { if (theSolution.person == null && c.cardType == CardType.PERSON) { theSolution.person = c.name; toRemove.add(c); } else if (theSolution.room == null && c.cardType == CardType.ROOM) { theSolution.room = c.n...
249a4a3f-b802-40c0-a035-579bc69779cd
0
@AfterClass public static void tearDownClass() { }
2d177ca0-e41d-4b13-90f9-bee15d885a5f
1
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { CreateBoy frame = new CreateBoy(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
6116e98f-42af-4a39-a529-a4e96b385632
7
@Override public String toString() { String s = "Stats for " + componentName + "\n\t"; if (temperature != null){ s = s + "Temperature: \t" + temperature + "\n\t"; } if (pressure != null){ s = s + "Pressure: \t" + pressure + "\n\t"; } if (controlRodLevel != null){ s = s + "Ctrl Rod Level: " + cont...
768ebd96-0df2-4c6d-af96-45a153894b7b
6
private int sendPacket(Packet packet) throws NotConnectedException, NullPacketException, CouldNotEncodePacketException, PacketIOException { int sequenceNumber = -1; synchronized(CONNECTION_LOCK) { //regardless of whether the packet is valid, if the client is not connected then throw a NotConnectedException if...
248bca30-e99e-4e1b-8dcc-bfc44d631d12
9
public static ArrayList<String> generate(final String statement) { final ArrayList<String> noSpaces = new ArrayList<String>(); for (String split : StringUtilities.split(statement)) { if (!split.equals(" ")) { noSpaces.add(split); } } final ArrayList<String> cleaned = checkFields(noSpaces); double...
c6083232-50c7-4bf6-854c-6512d908b890
0
public void setTotalSeats(long totalSeats) { this.totalSeats = totalSeats; }
8bd13b6c-1f2c-42d8-9996-4e797ed245b0
9
public adminLogInDialog(JPanel a) throws SAXException, ParserConfigurationException {//begin constructor appetizerMenu = new adminEditAppetizerMenu(); breakfastMenu = new adminEditBreakfastMenu(); lunchMenu = new adminEditLunchMenu(); dinnerMenu = new adminEditDinnerMenu(); ...
0d0a9ed5-bf36-441b-b53a-fcc3a0705d21
3
private void addHour(List<QlockWord> timeList, final int HOUR) { if (HOUR == 12) { timeList.add(QlockLanguage.UNE); } else if (HOUR == 5) { timeList.add(QlockLanguage.CINQ1); } else if (HOUR == 11) { timeList.add(QlockLanguage.MIDI); } else { ...
d42caec6-80fb-443b-8324-49083c756536
5
@Test public void testExtract(){ ArrayList<Float> times = new ArrayList<Float>(); ArrayList<Integer> directions = new ArrayList<Integer>(); ArrayList<Feature> features = new ArrayList<Feature>(); times.add((float) 0.0); times.add((float) 0.116133928299); times.add((float) 0.499715805054); times.add(...
24daa3e8-87cf-4858-844f-3c3dda951cf9
7
public static boolean NTclassMember() throws IOException { boolean success = true; success = ErrorRecovery(NonTerminal.classMember); switch (lookahead) { case INTEGER: case REAL: case ID: if (!NTtype()) success = false; if (!match(TokenType.ID)) success = false; if (!NTclassMemberPrime()) ...
5bbce0bb-d405-41e9-906f-3194f02626ee
8
public static void main(String[] args){ Scanner in = new Scanner(System.in); String s = in.next(); StringBuilder result = new StringBuilder(); int resultCount=0; Set<Integer> prevIndexes = new HashSet<Integer>(); boolean first=true; for(int l=1;l<=s.length();l++){ String target = s.substring(0, l...
d25aca6a-3c22-4035-8583-f04b1c93fac7
1
private void RandomGeneration_buttonActionPerformed(java.awt.event.ActionEvent evt) { //this.GenerateQuiz(); if(JOptionPane.showConfirmDialog(null, "Are you sure?")==0){ GenerateQuiz(); status.setText("Quiz generated"); } }
e7285014-3a5c-49f1-bb73-2418105ceab1
2
public void loadTileImages() { // keep looking for tile A,B,C, etc. this makes it // easy to drop new tiles in the images/ directory tiles = new ArrayList(); char ch = 'A'; while (true) { String name = "tile_" + ch + ".png"; File file = new File("images/" ...
ecad701b-389b-4ff1-b221-2cba7cd54ec3
1
public boolean shoot() { if(tsls >= RELOADTIME) { sound.play(); tsls = 0; return true; } return false; }
09898cde-a70f-421c-983d-61775d130212
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...
3ca74eff-c075-4a57-ba95-b3125857d1de
8
public boolean SetBusInActiveStatus(int busNumber, int inputBufferNumber, int packetSequence, int TIME, ConfigFile cfg) { //REMOVE IN CROSSBAR FABRIC TYPE //only one bus present in this fabric type, //busNumber = 0; //ensure valid busNumber chosen if(((busNumber+1)<...
5ce364d3-1c3f-4ee8-b649-be9a18769003
4
public boolean equals(Object toCompare) { if(toCompare == null) return false; if(!(toCompare instanceof TableMarkerMvMapping)) return false; TableMarkerMvMapping mapping = (TableMarkerMvMapping) toCompare; if(mapping.getMvId() == mvId && mapping.getTableMarkerId() == tableMarkerId) retu...
d39ccf63-631e-40ae-bbbf-eef726966b79
0
public void setAppenderName(String appenderName) { this.appenderName = appenderName; }
0b0c6d0a-da6a-4721-aa5a-d1a953baa243
5
private static final long[][] vandermonde (long[] smp, long[] evl, int mA, int mB) { int nrows = mA + mB; int ncols = nrows + 1; long[] pv = new long[(mA>mB?mA:mB) + 1]; long[][] result = new long[nrows][ncols]; pv[0] = 1; for (int i = 0; i < nrows; i++) { fo...
1feb78f4-dea2-44b4-b7a2-41cb401a9dbb
1
public Object pop() { if (currentSize > 0) { Object elem = array[currentSize-1]; array[currentSize-1] = null; checkEnoughCapacity(0); currentSize--; return elem; } return null; }
fbb94ea6-47f7-4f75-a842-f73a302229db
2
@Override public String toString(){ String toReturn = ""; for(int i = 0; i<this.size;i++){ toReturn += this.keys[i]; toReturn+= "->"; toReturn += this.values[i]; toReturn+= "\n"; } if(this.nextLeaf != null){ toReturn+= this.nextLeaf.toString(); } return toReturn; }
5267d42a-34be-44c6-8dca-744ce03b2674
0
public void setResponseFormat(AlgorithmParametersType.ResponseFormat value) { this.responseFormat = value; }
1c709a5b-401e-4881-a564-8b5298c80e2e
2
public SwitchingFabric(int speed, Queue []inputBuffers, Queue []outputBuffers, int VERTICALBUSES) { //set vertical busses this.VERTICALBUSES = VERTICALBUSES; //set the speed of the switching fabric this.speed = speed; //set the input buffers this.inputBuffers = inputB...
5b82a42a-1f49-415e-951d-2845423bda41
6
private static void populateDataObjects(Configuration configuration, Document factory) { NodeList nodeList=factory.getElementsByTagName("dataobjects"); if(nodeList!=null && nodeList.getLength()==1){ Element element=(Element)nodeList.item(0); NodeList executors=element.getElementsByTagName("dataobject"); ...
60c42f8b-a49f-4691-a3b1-bffc0501ab6e
5
private Stmt stmt() throws SyntaxException { Stmt toBeReturned = null; // AssignStmt. So check for FIRST(AssignStmt) = {IDENT} if (isKind(currentToken, IDENT)) { toBeReturned = assignStmt(); } // PauseStmt. So check for FIRST(PauseStmt) = {pause} else if (isKind(currentToken, pause)) { toBeReturned = ...
ebf76ec0-8f36-4518-90b3-341ff7947148
6
@Override public boolean importData(JComponent c, Transferable t) { boolean result = false; if (isLocalDrag()) { // Enables visual feedback on the Mac result = true; } else { try { updateImportCount(t); if (c instanceof mxGraphComponent) { mxGraphComponent graphComponent = (...
36a8f0f7-5f13-4027-a754-f4007229de3b
1
@Override public void keyReleased(KeyEvent e) { // Remove the key from the currently down keys. We test if the key is // was previously tested first because of Key combinations which do not // result in characters, such as action keys like F1 and the HELP key, // do not generate KEY_TYPED events. // We use i...
bbb3a3c0-3bba-4d2f-9def-3de8c716f157
3
private static String new_first_of_sequence(Hashtable<String, Tuple<LinkedList<Integer>, Integer>> queues) { Iterator<String> words = queues.keySet().iterator(); int min = Integer.MAX_VALUE; String min_word = ""; while(words.hasNext()){ String word = words.next(); Tuple<LinkedList<Integer>, Integer> tuple...
61b2ab72-20a5-4e76-ab7d-5c9ece59db1e
5
@Override public void setGeometry(double [] a){ isGeometrySet=true; int i, i0, i1; int nSegment; if(a[0] == a[a.length-2] && a[1] == a[a.length-1]){ // user already closed the polygon for us nSegment = (a.length-2)/2; }else{ nSegment = a.length/2; } ...
498e5db6-3105-485f-a324-962b86c59196
9
private int checkGainRemove(Node removedFeature, TreeNode currentNode, Set<Integer> sampleList) { if (currentNode == null) { return 0; } if (currentNode.feature == null){ if (currentNode.noCorrect != sampleList.size()) unclassified.addAll(samp...
7e575939-0d0a-4d0a-b805-b86d426b30e0
5
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof MyType)) return false; MyType myType = (MyType) o; if (intParam != myType.intParam) return false; if (stringParam != null ? !stringParam.equals(myType.stringParam) : myType.stringPara...
fb36c2f2-c2e5-48e6-a60f-3f96a16a14d1
2
public static String getOptionValue(String option) { if (CommandLineUtilities._command_line.hasOption(option)) return CommandLineUtilities._command_line.getOptionValue(option); if (CommandLineUtilities._properties.containsKey(option)) return (String)CommandLineUtilities._properties.getProperty(option); retu...
89dd5bb9-bb94-4656-aacb-dbf559d6b241
6
private List<Student> parse(final Document doc) { final List<Student> students = new Vector<Student>(); if (doc == null) { return students; } final Element root = doc.getDocumentElement(); final NodeList nodeStudents = root.getChildNodes(); if (nodeStudents != null) { if (nodeStudents.getLength() != ...
b0ea354b-91d3-47e4-a369-ad962adea4c3
6
public static List<String[]> readCSVTable(Readable source, int numOfCells)throws IOException{ final int CELLS = numOfCells; Scanner in = new Scanner(source); List<String[]> vals = new ArrayList<String[]>(); StringBuffer exp = new StringBuffer("^"); for(int i = 0; i < numOfCells; i++){ exp.append("(.*)"); ...
1e23e90b-ed9a-461e-b6cd-502f10ee5015
6
public static boolean dob(String dob){ String[] d = dob.split("[-\\s\\:,]"); if(d[0].length()!=4) return false; if(!digits(d[0])) return false; if(d[1].length()!=2 || d[2].length()!=2) return false; if(!digits(d[1])||!digits(d[2])) return false; return true; }
7f7221fc-f9ff-4bf3-94f5-b149b3466b7f
3
private void storeUpcommingEarningsPages() { try { calendar.setTime(new Date()); for (int i = 0; i < programSettings.daysOfReportsToDownload; i++) { String date = dateFormatForUrl.format(calendar.getTime()); String dateFileFormat = dateFormatForFile.format(calendar .getTime()); String earni...
5a97526b-a050-45a5-8e90-b2078df5adb8
8
public Integer evaluaExpresion(String expresionAEvaluar) { Integer r = 0; //System.out.print(expresionAEvaluar + " = "); i = 0; expresion = expresionAEvaluar + '$'; // Añadimos el caracter de fin de línea (en realidad no haría falta, pero bueno) Estado estadoInicial = new Estado(...
e3b84c52-ae45-428f-ba9a-bfd1fb7a5625
2
public static void main(String[] args){ Scanner in = new Scanner(System.in); int n=in.nextInt(); int m=in.nextInt(); int count = 1; int curr = 0; while(n-->0){ int p=in.nextInt(); if(curr+p>m){ count++; curr=p; } else { curr+=p; } } System.out.println(count); }
6208ca76-e1a2-41f4-b1ab-4ad4820b9b17
4
public Tile getTile(int x, int y) { if (x < 0 || y < 0 || x >= width || y >= height) { return Tile.BOUNDS; } else { return tiles[x][y]; } }
eb478242-b82a-43b6-9350-8dc82b80c0ad
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...
c49d5f6f-b3bf-489c-b6f9-fe5f349961e3
3
public static List<String> getCommaSeperatedValues(String string) { List<String> list = new ArrayList<String>(); if (string.startsWith("none")) return list; String[] values = string.split(","); for (int i = 0; i < values.length; i++) { String value = values[i]; if (value.startsWith(" ")) { ...
3ecf0fbc-5865-440f-b789-78d03d3a584e
1
public void visit_lneg(final Instruction inst) { stackHeight -= 2; if (stackHeight < minStackHeight) { minStackHeight = stackHeight; } stackHeight += 2; }
ef172048-f642-437c-b13a-e7d7498ad631
1
@Override public void draw(FrameBuffer buffer) { buffer.blit(texture, 0, 0, buffer.getOutputWidth() - x, y, width, width, widthDest, heightDest, 0, false, new Color(165, 100 , 50)); primitives.get("Select").blit(buffer); for (MassAttractObject3D obj : world.getSystem()) primitive...
c68e1cdb-22d6-4bb5-91bb-8dfd08fbfd1c
1
@Override public boolean keyExists(final String key) { boolean exist = doKeyExists(key); if (exist) { return exist; } HighLevelCacheCallback callback = new HighLevelCacheCallback() { @Override protected Object doInCache(Cache cache) { return cache.keyExists(key); } }; exist = (Boolean) c...
b34eeb17-0ff3-4251-8e95-7fe1676a2c91
5
public void crawling(String[] seeds){ LinkFilter filter=new LinkFilter(){ //提取网页 @Override public boolean accept(String url){ if(url.startsWith("http://news.qq.com")) return true; ...
948818d8-63c1-44ab-9e15-054753bab5e1
2
static void drawTextOverlay() { for (int i = 0; i < text.size(); i++) { countDowns.set(i, countDowns.get(i) - 1); if (countDowns.get(i) < 1) { text.remove(i); locations.remove(i); colors.remove(i); countDowns.remove(i); ...
c6cec757-4d10-4e57-a2e1-66472c638bd8
5
public static void removeListeners(EventListener... es) { if (es == null) return; for (EventListener e : es) { if (e == null) continue; EventManager m = getEventManager(); if (m == null) continue; m.removeListener(e); if (listeners.contains(e)) listeners.remove(e); } }
5a1da617-4be2-4ffb-8a4c-ee29a7783c2d
6
public void updateTheGraph(Document doc, String clusterID) throws Exception{ Neo4jCluster cluster = this.clustersList.get(clusterID); double numberOfDocumentsInTheCluster = this.clustersList.get(clusterID).getDocumentIDs().size(); ArrayList<Sentence> sentencesList = doc.getSentences(); for (int sentenceInd...
7641afe8-0fe2-408c-85c6-649de5c76926
2
public String toString() { return "GedcomRecord[level=" + level + ", tag=" + tag + ((xref != null) ? ", xref=\"" + xref + "\"" : "") + ((content != null) ? ", content=\"" + content + "\"" : "") + "]"; }
fb29f639-9811-40dc-ada9-d46c47505372
9
public Sacrifice determineSacrifice(GameState state) { List<Scroll> hand = state.getHand(); //are we drawing or ramping? Type type; if(hand.size() == 0) { return new Sacrifice(Type.SKIP, null); } else if(hand.size() > 5) { type = Type.RAMP; } else if(hand.size() == 1) { type = Type.DRAW; }...
f3311bb5-789c-4ee5-aa22-cb8f19a7a753
7
HTTPResponse(byte[] b) { data = b; int contentStartPos = -1; for (int i = 0; i < data.length; i++) { if (data[i] == 10 && data[i - 1] == 13 && data[i - 2] == 10 && data[i - 3] == 13) { contentStartPos = i + 1; break; } } /...
779ea401-dd92-4f7f-bc26-08ee369c38cb
0
public String getHost() { return this.host; }
26c3cf91-9bb4-48af-8be4-6cbbe6ff4f01
3
public void heapSort(T[] array) { size = array.length; heapArray = (T[]) new Comparable[size]; System.arraycopy(array, 0, heapArray, 0, size); for (int k = size / 2; k > 0; k--) { percolatingDown(k); } for (int i = size; i >= 0; i--) { // Swap the top node and the node at i's location, then percolate ...
e4c035bc-8947-4b63-b596-c6737febfd32
0
public BroadcastingService(Neighbor from, Neighbor to, boolean keepalive) { this.from = from; this.to = to; this.keepalive = keepalive; }
5ec847a3-4ddb-47ef-8b28-e995eee74aa1
7
public static Structure Build (ROM program) { int length = 0; int width; int height; int span; int index = 0; //int signs = 0; Schematic.Structure file = new Schematic.Structure (); ErrorLog.debug("Building schematic structure."); height = program.block.length; if (height != 0) { width =...
b57b8c05-01a8-4a94-9ad8-5886a74e6545
5
public static Vector<IncrCmp> sortInstrumented(Comparable[] a) { // Sort a[] into increasing order. int N = a.length; int h = 1; int nIncrements = 0; while (h < N / 3) { h = 3 * h + 1; // 1, 4, 13, 40, 121, 364, 1093, ... nIncrements++; } Vector<IncrCmp> v = new Vector<IncrCmp>(nIncrements); ...
0cba0966-8e91-407b-9123-d4cc6066c401
4
public JSONWriter key(String string) throws JSONException { if (string == null) { throw new JSONException("Null key."); } if (this.mode == 'k') { try { this.stack[this.top - 1].putOnce(string, Boolean.TRUE); if (this.comma) { ...
0e49e641-1fd9-4323-a515-6b196eb3c932
2
public static Version getFromMessage(String message){ for (Version version : values()){ if (version.getMessage().equalsIgnoreCase(message)){ return version; } } return null; }