method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
fb92f4bd-6c41-46a6-bcec-6b1a0e261046
4
@Override public double getValue(int row, int col) throws MatrixIndexOutOfBoundsException { if ((row < 0) || (col < 0) || (row >= mas.length) || (col >= mas[0].length)) { throw new MatrixIndexOutOfBoundsException("Inadmissible value of an index."); } return mas[row][col]; }
b52608e5-186b-48e3-b227-f247dfb0a4d4
3
private void allocateQueueGridlet() { // if there are many Gridlets in the QUEUE, then allocate a // PE to the first Gridlet in the list since it follows FCFS // (First Come First Serve) approach. Then removes the Gridlet from // the Queue list if (gridletQueueList_.size() > ...
038fba52-75eb-47d6-9bd1-c2b7ffee8ece
2
@Override public Byte validate(String fieldName, String value) throws ValidationException { if (value == null) { return null; } try { return Byte.parseByte(value); } catch (NumberFormatException e) { throw new ValidationException(fieldName, value, "not a valid byte", e); } }
d55b86d3-cf40-4172-94c7-af73c61505a1
5
public void roll(Roll newRoll) { if (previousRoll.hasStrikeBonus() && roll.hasStrikeBonus()) { result += newRoll.getFirst(); } if (roll.hasBonus()) { result += newRoll.getFirst(); if (roll.hasStrikeBonus() && !newRoll.hasStrikeBonus()) { result...
ba56cde4-c11d-4678-9098-d9832463bec3
6
public ReportWriterImpl() { String contactPointsStr = PropertyHelper.getProperty("contactPoints", "localhost"); int creditThreads = Integer.parseInt(PropertyHelper.getProperty("creditThreads", "3")); int debitThreads = Integer.parseInt(PropertyHelper.getProperty("debitThreads", "3")); BATCH_SIZE = Integer.parse...
79bcbb4d-93c9-415b-9af8-0be958966a23
5
@AfterGroups("Insertion") @Test(groups = { "BST", "Search" }) public void testBSTSearch() throws KeyNotFoundException, EmptyCollectionException { Integer count = 0; Reporter.log("[ ** BST Search ** ]\n"); try { timeKeeper = System.currentTimeMillis(); for (Integer i = 0; i < seed; i++) { bTree.s...
aa068a1e-8139-492f-a467-59a6e48bdb78
2
public void runMethods (String threadName) { Thread thread = new Thread(new Runnable() { public void run() { try { for (int i = 0; i < methodToInvoke.length; i++) { methodToInvoke[i].invoke(objectToInvokeFrom[i], argsToInvokeWith[i]); } } catch (IllegalArgumentException | IllegalAccess...
ca022eb8-d150-4987-a623-5430c1b7c4ce
0
public void setInfo() { v.add(_port.getText().trim()); v.add(_adress.getText().trim()); v.add(_name.getText().trim()); }
155bef03-abbb-40cc-9d9e-7301f8a074d0
9
public boolean skipPast(String to) throws JSONException { boolean b; char c; int i; int j; int offset = 0; int length = to.length(); char[] circle = new char[length]; /* * First fill the circle buffer with as many characters as are in the ...
b0bca578-beb4-410f-93d2-9ba7c2d7d3a0
8
@SuppressWarnings({ "rawtypes", "unchecked" }) public static void printTranscript() { System.out.println("Please Select Student Matriculation No. to Display Transcript : "); Student s = (Student)chooseChoosable((ArrayList)studentList); for (Course c: s.getCourseList()) {//loop through all courses int total, ...
1efb0103-ad0b-4866-af1b-5858b31ab3a2
8
public void addNote(String s){ BufferedReader reader = null; BufferedWriter writer = null; try { List<String> fileLines = new ArrayList<String>(); reader = new BufferedReader(new FileReader(f)); String line = null; while((line = reader.readLine()) != null){ fileLines.add(line); } ...
8cf89d70-2bc5-418b-b2ce-7cfad20cde12
2
@Override public int matches( int[] sequenceA, int indexA, int[] sequenceB, int indexB, int count ) { for (int i = 0; i < count; i++) { if (sequenceA[indexA + i] != sequenceB[indexB + i]) { return i; } } return count; }
beea8c84-2515-4386-be01-c66ca69e2aa3
3
@Override public void run() { synchronized (match) { if(match.getTempsPeriodeMillSeconde() <= 60 * 1000 * 60) { String s = client.envoyerRequete(Commands.GET_EQUIPES_MATCH.toString() + "/" + match.getId()); String[] answers = s.split("\\|"); if(answers[0].equals(Commands.EQUIPE_MATCH.toStrin...
f8e6ea8d-95e3-4487-ba99-494275de9814
5
private void apporte() { if (this.vide){ this.se_remplis(); } else { if (!(this.al.demande_ressource.isEmpty())){ Cellule plusproche = this.al.demande_ressource.get(0); if (this.curent.coord != plusproche.coord){ this.rapproche(plusproche); } else if (this.curent.objet instanceof ...
058a9739-0705-4093-8e2b-bec7478d7e03
1
private GraphDate countBP_dataGraph(List<Organism> org) throws Exception { List< List<Double>> localError = new ArrayList<List<Double>>(); localError = backPropagation(org); //for graph graph if (localError != null) { int numIterations = getNumIterations(); Graph...
1154279c-2ba6-432d-86c1-edc971a4b2b3
1
public static void printContent(){ int x = 0; while(x < 25){ System.out.println(randlist[x]); x++; } }
c67c526f-a429-452f-9293-f632395f6141
2
public boolean close() throws InterruptedException { if (!isOpen()) // Prevent unnecessary re-closing return false; RS2InterfaceChild child = parent.getChild(childCloseID); if(child != null){ Client c = script.client; return c.moveMouseTo(new RectangleDestination(child.getRectangle()),false, true, false)...
b9c83555-8f47-42c2-bf2c-0cb700bdb8dd
4
@Override public boolean join(String n) { try { Registry reg = LocateRegistry.getRegistry(); m_clientRemote = new CallbackClient(); // Register the client class into the client subscriber m_subscriber = (IClientSubscriber) reg.lookup("client_subscriber"); System.out .println("[CLIENT] Registering...
211a3a4c-a014-467d-a7b4-c9f400c2530c
6
public static void addMembersToGroups(MoodleGroupUser[] users) throws MoodleRestGroupException, UnsupportedEncodingException, MoodleRestException { StringBuilder data=new StringBuilder(); String functionCall=MoodleCallRestWebService.isLegacy()?MoodleServices.MOODLE_GROUP_ADD_GROUP_MEMBERS:MoodleServices...
d3782080-cdf9-48fb-afec-c171e04f499f
7
static public BigDecimal sin(final BigDecimal x) { if ( x.compareTo(BigDecimal.ZERO) < 0) return sin(x.negate()).negate() ; else if ( x.compareTo(BigDecimal.ZERO) == 0 ) return BigDecimal.ZERO ; else ...
8d1b23a8-6cd5-42b7-b262-c858285219cc
9
public void download( final @NotNull Factory<? extends InputConnector> inputConnectorFactory, final @NotNull Factory<? extends OutputConnector> outputConnectorFactory, final @NotNull Iterator<? extends Chunk> chunkIterator, final int streamsCount ) throws Exception { ...
efda48ef-bfff-4918-af12-7897c481113e
8
public void filterBody(int[][] image, int n) { for (int i = 0; i < image.length; i++) for (int j = 0; j < image[0].length; j++) { int red = (image[i][j] >> 16) & 0xff; int blue = (image[i][j] >> 8) & 0xff; int green = (image[i][j]) & 0xff; if (red == 0 && blue == 0 && green == 0) { if (n == 0)...
e425f3b7-c71f-41dc-aba4-63e5f457f55e
1
public boolean open( ) { state = State.PROCESSING; setVisible(true); while (state == State.PROCESSING); return(state == State.OKAY); }
46878b55-2f6d-488e-84e1-e4cc41c9a61c
5
public CheckResultMessage check33(int day) { int r1 = get(39, 5); int c1 = get(40, 5); int r2 = get(43, 5); int c2 = get(44, 5); BigDecimal b = new BigDecimal(0); if (checkVersion(file).equals("2003")) { try { in = new FileInputStream(file); hWorkbook = new HSSFWorkbook(in); b = getValue(r2 +...
30e1b129-6194-4565-a02f-fd9575fdf044
5
public static void makereport(OutputStream outs, Report rep) throws IOException { PrintWriter out = new PrintWriter(new OutputStreamWriter(outs, "UTF-8")); out.print(htmlhead("Error Report")); out.println("<h1>Error Report</h1>"); out.println("<p>Reported at: " + htmlq(dfmt.format(new D...
590e7bac-7b15-4495-8453-c30c96c2d280
5
public int[] nachbarKnoten(int pKnoten) { int lAnzahl = 0; for (int i = 0; i < zN; i++) { if (adjaMa[pKnoten][i] > -1) { lAnzahl++; } } int[] lReturn = new int[lAnzahl]; for (int j = 0; j < lAnzahl; j = j) { for (int i = 0; i < ...
9d337707-eb75-47a2-a6c0-419c0a789ad5
7
public static void main(String[] args) { if (args.length != 1) { System.out.println("Usage: CreateArff prop.properties"); return; } PropertyHandler propHandler = new PropertyHandler(requiredProps); Properties properties = propHandler.readPropertiesFile(args[0]); if (propHandler.checkPr...
9f871116-07f0-4532-953c-588a1a8cdcde
6
static final int method3021(byte i, Class229 class229) { anInt6931++; if (class229 != Class328_Sub3.aClass229_6519) { if (Class167.aClass229_2207 == class229) return 8448; if (class229 == OndemandWorker.aClass229_3196) return 34165; if (Class348_Sub23_Sub2.aClass229_9011 == class229) return 260; ...
0583189e-56b6-4b2a-9730-78f4cb30444b
7
private void updateSpaceBombs() { ArrayList<SpaceBomb> deadSpaceBombs = new ArrayList<SpaceBomb>(); for(int i = 0; i < spaceBombs.size(); i++) { SpaceBomb sb = spaceBombs.get(i); sb.move(); if(CollisionDetector.isColliding(sc, sb)) { if(!sc.isShieldActive()) sc.damaged(sb.getStrength()); ...
8a3bd6d6-6b57-41dd-8fa0-c77965c77301
4
public Instantiation findOwner(final int i) { if (!subroutine.ownsInstruction(i)) { return null; } if (!dualCitizens.get(i)) { return this; } Instantiation own = this; for (Instantiation p = previous; p != null; p = ...
9a50fc60-cb95-48ac-97e9-1050d5297243
6
public static String stringOfArray(Object[] objs, String sep, String prefix, String suffix) { StringBuilder res = new StringBuilder(prefix == null ? "" : prefix); if (objs != null) { boolean first_element = true; for (Object o : objs) { if (o != null) { res.append((first_element ? "" : sep)); re...
edfbf83d-6377-433a-9ff6-5a9b375bf610
1
private boolean packCardHasBeenPressed(Point pressPt) { if (aFaceDownCard.pressPointIsInsideCard(pressPt)) { return true; } return false; }
13fb2cc2-57ed-4028-b1be-ea2427f415d7
5
public static boolean isApacheMD5( String str ) throws NullPointerException { // Format (example): // $apr1$Px0gsAPk$JW2APdbEhGlT5bLfqua2C1 String[] split = str.split( "(\\$)" ); if( split.length != 4 ) return false; if( split[0].length() != 0 ) return false; if( !split[1].equals("apr1") ) ...
06629183-37c9-4e2d-8554-3c826fececcc
1
public void saveDatabase(String BankID) throws FileNotFoundException { File inFile = new File(BankID + ".txt"); inFile.delete(); PrintWriter writer = new PrintWriter(inFile); Set<Integer> keys = accounts.keySet(); for(Integer key: keys) { writer.println(accounts.get(key).g...
154628cb-4b87-41dd-9288-e780cd41f8ef
3
public void sendToClients(){ for(network.ClientData client : clients.values()){ InetAddress ip = client.getIp(); int port = client.getPort(); for (UUID id2 : state.keySet()) { sendBuffer2 = state.get(id2).getBytes(); DatagramPacket sendPacket2 = new DatagramPacket(sendBuffer2, sendBuffer2.length,...
9a0b760b-a970-4160-9585-0d1d6b174994
2
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Voer een geheel aantal seconden in:"); int invoer = scanner.nextInt(); /* * De functie voor het omzetten van seconden naar uren, minuten, seconden. */ int uren, minuten, seconden, restInvoer; uren...
fb42f827-de14-4908-92b1-1ee803638bcb
5
@Override public void onDraw(Graphics G, int viewX, int viewY) { if (X>viewX&&X<viewX+300&&Y>viewY&&Y<viewY+300) { // g.setComposite(new Additive()); G.setColor(Color.ORANGE); for (int i = 0; i < 4; i ++) { G.fillArc((int)X-viewX+(i*2)-...
d73da861-8f0f-437b-aefb-04d9a2be5255
0
@Override public boolean Initialize() { //TODO: Load saved/default preferences. //TODO: Change applications width, height, fullscreen mode, vsync, etc. //TODO: Load all your game assets here. return true; }
f75cf3d0-ac83-477f-927a-f7729ba9285d
6
private ITrieNode findMatchingRootNode(String word, HashMap<Integer,Integer> tmpFrontier) { ITrieNode returnNode = null; if (word != null && word.length() > 0) { char searchChar = word.charAt(0); boolean foundIt = false; for (ITrieNode t: this.children.values()) { ...
f3ec2ec7-8f14-406e-b91c-8f5a04b4e037
7
private static void checkError(String source) { if(checkForErrors) { int errorcode = GL11.glGetError(); String errorstring = null; switch(errorcode) { case GL11.GL_NO_ERROR: return; case GL11.GL_INVALID_ENUM: errorstring = "GL_INVALID_ENUM"; br...
694a5ae5-25e8-4dea-ae81-0a8c96942031
5
private List<TSquare> getEmptySq(int xLeft, int xRange, int lineY) { List<TSquare> sqOccupied = getOccupiedSq(xLeft, xRange, lineY); List<TSquare> sqEmpty = new ArrayList<TSquare>(); if (!sqOccupied.isEmpty()) { //only consider occupied situation, otherwise, it's the edge int xRight = xLeft + xRange; for (i...
a1f90e8a-1f11-4ee4-81af-e142875cdfca
1
public TertiaryPowerFailure(Grid grid, int maxLifetime, SecondaryPowerFailure parentPF) { super(grid, maxLifetime); if (parentPF == null) throw new IllegalArgumentException("The given SecondaryPowerFailure is invalid!"); this.parentPowerFailure = parentPF; getGrid().getEventManager().addListener(this, Ev...
7d1b2270-f838-4b06-93f7-a5e646d62c9e
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(ID())!=null) { mob.tell(target,null,null,L("<S-NAME> already <S...
a2fa05f9-a365-4361-baca-4f0916b1c254
1
private boolean isElementPresent(By by) { try { driver.findElement(by); return true; } catch (NoSuchElementException e) { return false; } }
e519ebea-b5fc-4acc-97f9-83b7be10ee0c
7
public String tradeAutorollover() throws MonkeyTalkFailure{ Application app=new ConnectClass().connect(); try{ app.tabBar().select("Markets"); app.button("Search").tap(); app.input("_searchField").enterText("Soybean Oil", "enter", new Mods.Builder().thinktime(5000).build()); app.label("Trade").tap(...
b307d5ee-acf2-4b12-a2fb-e7c958d2afdd
3
private void defaultStartSimulationButtonListener(){ restart.removeActionListener(restartActionListener); restartActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { if (currentConstructor != null) { synchronized(simulator) { if (simulator.isRunning()) { simu...
8c8ec44b-f037-4b1d-9357-340a982ad849
4
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || getClass() != obj.getClass()) return false; Matrix4 other = (Matrix4) obj; if (!Arrays.deepEquals(m, other.m)) return false; return true; }
d7be7052-d3a0-436c-950d-6396b358902c
1
private static DocumentBuilder newBuilder() { try { DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance(); fac.setNamespaceAware(false); fac.setValidating(false); DocumentBuilder builder = fac.newDocumentBuilder(); return builde...
b88161ac-b3f8-464f-9cc3-90cf03af8ebf
4
public boolean matchWith(State other, int maxN) { for (Predicate p : other.predList) { if(p.getName().equals("USED-RAILWAYS")){ if(occupied == maxN) return false; } else if (!isPredicateInState(p)){ return false; } } return true; }
42aafa94-a57b-40cc-a29e-8f79d3277f76
9
private static ServiceRegistration<?>[] removeServiceRegistration( ServiceRegistration<?>[] regs, ServiceRegistration<?> reg) { for (int i = 0; (regs != null) && (i < regs.length); i++) { if (regs[i].equals(reg)) { // If this is the only usage, then po...
a30f6863-f0e0-4fbf-a87b-f3da8fd6cef3
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...
d9980d2b-cab1-4980-8ad2-87d83e9b746c
6
protected void readData(Reader in) throws IOException{ String line, value; int i, j, s; String label; float curVal[]; while ((line = readLine(in)) != null){ bytesRead += line.length(); float progress = (float)bytesRead / filesiz...
640dbf09-c5c8-41ab-a083-0dd6f00ebce7
6
public ArrayList<ForecastObject> requestForecast() { URL url; HttpURLConnection conn; BufferedReader rd; String line; String result = ""; try { url = new URL("http://api.openweathermap.org/data/2.5/forecast/daily?lat=55.681589&lon=12.529092&cnt...
bf53dc81-07f8-40e3-b918-a94e0da70353
3
private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginButtonActionPerformed String login = loginTextField.getText(); String password = passwordField.getText(); if(login.equals("") || password.equals("")) { Dialogs.ErrorDialog dialog =...
29ee0376-c7ed-429f-ba7b-5c37876ecfc2
5
private boolean addPosition(KrakenState state, XYLocation kingLocation,XYLocation location, ArrayList<KrakenMove> list,XYLocation finalLocation){ if (state.distance(kingLocation, location, finalLocation)){ if (state.isEmpty(finalLocation)){ list.add(new KrakenMove(location, finalLocation)); return fa...
f4ffc551-c916-4b81-baaf-2607ad60d3ff
4
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final TblSalesIdPK other = (TblSalesIdPK) obj; if (!Objects.equals(this.InvoiceNumber, other.InvoiceNumber)) { ...
d83cd0fb-8566-4e50-94cf-e20280176238
1
public String toString() { String ret = ""; for(byte b : blob) { ret += String.format("%02x ", b); } return("Message(" + type + "): " + ret); }
cf061316-e03e-4d39-8d08-ba613e13c86a
2
public void render(){ glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_TEXTURE_2D); if(color != null) color.bind(); if(textures != null) textures[textureIndex].bind(); int x = position.x; int y = position.y; glBegin(GL_TRIANGLES); { glTexCoord2f(0, 0); glVe...
8aa38edf-2f78-44ee-b3a2-d2b4ca098a42
5
public boolean tileTraversible(Point p) { if (p.x < 0 || p.x >= dimension.width || p.y < 0 || p.y >= dimension.height) return false; if (mazeMap[p.x][p.y] == t.WALL) return false; return true; }
78cf368e-7d85-4606-b214-7989507f59e9
0
public static String getFileExtention(String fileName) { return fileName.substring(fileName.lastIndexOf(".") + 1); }
fecc96fc-66cb-4d36-9d3f-448958825106
2
public void build() { if (built) return; root = itemBoundables.isEmpty() ? createNode(0) : createHigherLevels(itemBoundables, -1); // the item list is no longer needed itemBoundables = null; built = true; }
244a8569-8216-48ad-b219-ccb372ad4fe4
9
public boolean renderBlockDragonEgg(BlockDragonEgg par1BlockDragonEgg, int par2, int par3, int par4) { boolean var5 = false; int var6 = 0; for (int var7 = 0; var7 < 8; ++var7) { byte var8 = 0; byte var9 = 1; if (var7 == 0) { ...
21c72b5e-5769-4dd5-bd6b-892d81c37294
4
private String resToString() { if (res == null) return ""; String resultStr = ""; for (String symbol : bn.symbols) { if (res.containsKey(symbol)) { resultStr += "Matches for <" + symbol + ">:\n"; TreeSet<String> matches = res.get(symbol); for (String match : matches) ...
1967420e-e7de-43b0-b136-3afb7d1c2ffc
5
public void checkParameters() { getDriver().findElement(By.xpath(MainPage.FIRST_ITEM)).click(); getDriver().findElement(By.xpath(MainPage.COMPARE)).click(); ItemPage itemPage1 = PageFactory.initElements(getDriver(), ItemPage.class); Microwave microwave1 = itemPage1.grabAllCharacteristics(); System.out.pri...
37396313-6b1d-4f3a-b126-fac9b4267cbb
9
@Override public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) { mv.visitFieldInsn(opcode, owner, name, desc); if (constructor) { char c = desc.charAt(0); boolean longOrDouble = c == 'J' || c == 'D'; sw...
26ba90a0-15ed-4117-8223-885a8680002e
0
public static void printHelp() { System.out.println("java FileSearcher [options] [--] <path> <string pattern>"); System.out.println(" Options:"); System.out.println(" -t <n> \tSet processing threads count to <n> (Default: 5)"); System.out.println(" -b <n> \tSet file-in...
84f078ea-508f-4361-aff4-19b24bbc8883
5
@Override public boolean set(T object) { if (object == null && !this.enableNull) { return false; } if (object == null ? this.obj != object : !object.equals(this.obj)) { if (this.sync) { synchronized (this) { this.obj = object; } } else { this.obj = object...
ecb0d614-1643-4cfe-a72f-0a7faddc1953
9
public List<Event> getEvents() { if (this.events == null) { List<Event> r = new ArrayList<Event>(); if (this.section.poincareStartPoint != null) { r.add(new AproximationEvent(this.section.poincareStartVector[0] + getIntegrator().epoch, this.section, this.systemRef.descriptions, this.sectio...
bbc68544-2751-487d-8215-6476d7dfaf10
6
public static Properties getProperties(String file){ String key = file.substring(file.lastIndexOf("/")+1,file.length()); if(propertyList.containsKey(key)){ return propertyList.get(key); } Properties prop = new Properties(); InputStream is = null; try { is = new FileInputStream(file); } catch (Fil...
775f9017-cc5e-483f-90bd-fbb89cbad3ed
5
@Override public String toString(){ if (hour == 24 && min == 0) { return " "; } return String.format( "%d:%02d",(( hour == 0 || hour == 12) ? 12 : hour % 12),min,(hour< 12?"AM":"PM")); }
21f4d5a9-cd95-4828-8bcb-c1ab0f6ca86d
0
public boolean canEncode(Serializable structure) { return false; }
dc97b71d-4197-4704-9a94-30d20dcfef7e
3
public void run() { init(); while (running) { tick(); render(); if (Display.isCloseRequested() || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) stop(); } }
13cfc673-16ec-4c9c-97ec-232e66994e6c
0
@Override public void windowDeactivated(WindowEvent e) { }
e848a62d-b833-4039-b0f0-6f4f153ac096
1
public void use() throws InterruptedException { // in a real application this would be accessing/manipulating a shared resource if (!inUse.compareAndSet(false, true)) { throw new IllegalStateException("Needs to be used by one client at a time"); } try { Thread.s...
4cf10b96-41cc-422a-a8a5-964545ea6ad9
5
public static final void afterLogin(SeekableLittleEndianAccessor slea, MapleClient c) { final byte c2 = slea.readByte(); final byte c3 = slea.readByte(); if (c2 == 1 && c3 == 1) { // Official requests the pin here - but pins suck so we just accept c.getSession().write(Log...
5af66ec5-cc50-4bd5-bcb4-8d69540c94c6
2
@Override public synchronized void putAll(Map<? extends Object, ? extends Object> arg0) { super.putAll(arg0); }
6d9fb403-12b2-4fa7-a917-e796c49c79ee
1
public treeNode sortedArrayToBST(int[] num) { // put all nodes in an arrayList with originally ascending order; ArrayList<Integer> nodeList = new ArrayList<Integer>(); for (int i = 0; i < num.length; i++) { nodeList.add(new Integer(num[i])); } return generateBalancedBST(nodeList, 0, nodeList.size() - 1);...
e543e67b-88c2-44f7-a6cd-0210f08a1379
9
public List<Integer> parse(String range, int max) { List<Integer> idx = new ArrayList<Integer>(); String[] n = range.split(","); for (String s : n) { String[] d = s.split("-"); int mi = Integer.parseInt(d[0]); if (mi < 0 || mi >= max) { throw n...
160bcd90-6031-4be0-bbb3-397283ae2bb2
9
public static long playerNameToInt64(String s) { long l = 0L; for(int i = 0; i < s.length(); i++) { char c = s.charAt(i); l *= 37L; if(c >= 'A' && c <= 'Z') l += (1 + c) - 65; else if(c >= 'a' && c <= 'z') l += (1 + c) - 97; else if(c >= '0' && c <= '9') l += (27 + c) - 48; } while(l % 37L == 0L...
c614b873-a2ef-4a2a-b8fd-e76eba91599f
3
public ReleaseType getLatestType() { this.waitForThread(); if (this.versionType != null) { for (ReleaseType type : ReleaseType.values()) { if (this.versionType.equalsIgnoreCase(type.name())) { return type; } } } ...
157f608d-175c-4fd7-ae64-9bc9aecafff0
7
public synchronized void drawWaveForm(final Canvas c) { new Thread(new Runnable() { // implement functionality for anstract run public void run() { try { setParent(c); setDisplayMode(new DisplayMode((int) canvassize, 103)); ...
4ab0d4ff-56b3-41f8-a0ed-968a21551401
4
private double testQueueDequeue(int inserts) { System.out.println("Testing queue with " + inserts + " pushes"); long[] times = new long[20]; long startTime; long endTime; for (int i = 0; i < 20; i++) { queue = new Queue(); for (int j = 0; j < inserts; j+...
c14fa9ff-7af7-4ac0-b4db-416eb142cd8f
1
public static double[][] diag( double[] diag ) { int n = diag.length; double[][] res = newMatrix(n, n, 0.0); for ( int i = 0; i < n; ++i ) res[i][i] = diag[i]; return(res); }
65020422-bf79-420d-8984-1ef29ea787fc
5
@Test public void testEndOfGame() { Game g = new Game(new String[] { "p1", "p2", "p3", "p4" }); // p1 buys 5 developments Player p1 = g.getPlayer(0); for (int i = 0; i < 5; i++) { p1.buyDevelopment(i); } for (int i = 1; i < g.getNumPlayers(); i++) { assertTrue(g.nextTurn()); } assertFalse(g.nextT...
3aa1e2ef-51f5-4104-b13e-6488b21dcd74
1
public static void loadResources() { try { PillarEntity.PILLAR_IMAGE = new Image("images/pillar.gif", false, Image.FILTER_NEAREST); } catch (SlickException e) { } }
8cde2496-78df-4046-ab10-abec06d75483
9
public ArrayList leArquivo(){ ArrayList objetos = null; if(this.entidade.equals(Arquivo.AUTOR)){ objetos = new ArrayList<Autor>(); try{ while(br.ready()){ String linha[] = br.readLine().split(Arquivo.TAB); objetos.add(new Autor(linha[0], linha[1])); } }catch (IOException e) { e.printS...
605eabc8-2c24-40b6-8d48-c8a5cfe6a9e1
1
public GradeItem(ResultSet rs) throws Exception { DBConnector db = new DBConnector(); if(rs.next()){ setGradeItemID(rs.getInt("gradeitemid")); setStudent(db.getPerson(rs.getInt("studentid"))); setCourse(db.getCourse(rs.getInt("courseid"))); setTitle(rs.get...
468748a6-0b89-48be-9c78-52a534631a06
1
private JTextField getJTextFieldInnerCharacters() { if (jTextFieldInnerCharacters == null) { jTextFieldInnerCharacters = new JTextField(); jTextFieldInnerCharacters.setText("'"); } return jTextFieldInnerCharacters; }
21027f97-a6c7-4fe5-aaae-a27554b3fcc0
2
@SuppressWarnings("unchecked") public static float[][][] restore3D(String findFromFile) { float[][][] dataSet = null; try { FileInputStream filein = new FileInputStream(findFromFile); ObjectInputStream objin = new ObjectInputStream(filein); try { dataSet = (float[][][]) objin.readObject(); } catc...
6282ad2c-f9fa-431c-803d-66924496170b
5
private DAO() { JdbcConnectionSource connectionSource = null; try { File f = new File(db_name); // if(f.exists()) f.delete(); // create our data source connectionSource = new JdbcConnectionSource(DATABASE_URL); ...
75647769-1a36-4c08-9cf5-0571bc777b02
1
private String prompt(String format) { return parent != null ? format.replaceAll("%p", parent.prompt(format)).replaceAll("%g", getKey()) : getKey(); }
013dd9ec-3ed9-4204-859f-2f49cf286a44
8
public static boolean computeCell(boolean[][] world, int col, int row) { // liveCell is true if the cell at position (col,row) in world is live boolean liveCell = getCell(world, col, row); // neighbours is the number of live neighbours to cell (col,row) int neighbours = countNeighbours(world, col...
967d7eaf-f2e2-45a6-a742-1c1491d497f7
8
public boolean displayModesMatch(DisplayMode mode1, DisplayMode mode2) { if (mode1.getWidth() != mode2.getWidth() || mode1.getHeight() != mode2.getHeight()) { return false; } if (mode1.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI && mode2...
8d29154b-b73c-40d2-9f6e-be707ef6a89c
1
private void loadSourceLines(String baseFileName) throws IOException { sourceLines = new ArrayList<SourceLine>(); sourceLines.add(new SourceLine("")); BufferedReader reader = new BufferedReader(new FileReader(baseFileName + ".x"))...
4520a388-5dd3-4f8b-a7b9-0987a495a199
6
public static int dehexchar(char c) { if (c >= '0' && c <= '9') { return c - '0'; } if (c >= 'A' && c <= 'F') { return c - ('A' - 10); } if (c >= 'a' && c <= 'f') { return c - ('a' - 10); } return -1; }
bb611ca7-a05c-4254-8824-4de5a0394215
0
public TestBean find(Integer id) { return (TestBean) jdbcTemplate.queryForObject("select * from test where id = ?", new ParameterizedRowMapper<TestBean>() { @Override public TestBean mapRow(ResultSet rs, int arg1) throws SQLException { TestBean result = new TestBean(); result.setId(r...
7d4d6f0e-5cc8-4096-90bf-50ed33bf0736
5
private static Region getClosestNeighborToBorder(BotState state, Region inRegion) { List<Region> neighbors = inRegion.getNeighbors(); // In case two neighbors have the same distance pick the higher ranked // one Region closestNeighbor = inRegion; int minDistance = inRegion.getDistanceToBorder(); for (Region...
17805b26-eb75-4b68-b9a5-59d677797c06
3
public Edge<T> getUnvisitedEdge(Vertex<T> n) { for (Edge<T> e : edges) { if ( e.visited==false && e.start.equals(n) ) { e.visited=true; return e; } } return null; }
7895a5ae-bb41-4931-9745-291cdb9623f1
0
public String getExplanation() { return explanation; }
54d569f8-695f-4bc8-a150-e4de1223cfd5
7
public void updateVisitingHours(VisingHoursBean bean){ ResultSet rs=null; Connection con=null; PreparedStatement ps=null; try{ String sql="UPDATE OFFICE_HOURS SET p_id=?, weekday=?, timings=? WHERE office_hour_id=?"; con=ConnectionPool.getConnectionFromPool();; ps=con.prepareStatement(sql); ps.setI...