method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
d1910735-e1cf-4fb8-9c81-9fa05e935545
4
public void shutdown() { System.out.println("Stopping Object Remote Service"); lrs.stop(); System.out.println("Joining Service Thread"); try { tp.join(); System.out.println("Thread " + tp.toString() + "succesull closed"); } catch (InterruptedException e1){ e1.printStackTrace(); } i...
1959ec83-405d-4a23-9e4d-903473d6384d
6
protected void UpdateLineColumn(char c) { column++; if (prevCharIsLF) { prevCharIsLF = false; line += (column = 1); } else if (prevCharIsCR) { prevCharIsCR = false; if (c == '\n') { prevCharIsLF = true; } else line += (column = 1); ...
3053ed22-42c2-4c3f-805b-d8dd2c59af44
3
public void register(Class<? extends Command> c) { CommandInfo info = c.getAnnotation(CommandInfo.class); if (info == null) return; try { commands.put(info.pattern(), c.newInstance()); } catch (Exception e) { e.printStackTrace(); } }
0af12a30-a8e8-46ba-88ae-d172e27816fb
5
public String depict() { switch (type) { case CONQUER: return "The army of " + subject() + " conquering " + gobject(); case DEFEAT: return "The army of " + subject() + " vanquishing the army of " + gobject(); case RESTING: return subject() + " sleeping"; case SEXING: return subject() + " mating with " + gobje...
50bb4366-4660-4beb-9fb3-e92e0fc71363
1
public void dfsRec(Node rt) //prefix traversal & DFS seems same { if(rt == null) return; else { System.out.print(rt.value+" "); dfsRec(rt.left); dfsRec(rt.right); } }
966520d1-dcce-48b7-ae61-89fbdd9700e5
9
private Map<String, Set<String>> mergeIdentities( Collection<PersonIdent> persons) { Map<String, Set<String>> namesToEmails = new TreeMap<String, Set<String>>( caseInsensitveComparator); namesToEmails.putAll(RepositoryUtils.mapNamesToEmails(persons)); Map<String, Set<String>> emailsToNames = RepositoryUtil...
94f61031-b929-4e52-84ba-eaf8ba5754c5
4
protected static String normaliseTag(String tag) { StringBuffer nt = new StringBuffer(); for(char c : tag.toLowerCase().toCharArray()) { if((int)c >= 0x20 && (int)c <= 0x7d && (int)c != 0x3d) { nt.append(c); } } return nt.toStri...
a69d5cf5-efa8-45b3-86dd-e3095b0baad6
8
public boolean scramble(String a, String b, int p, int q, int len) { if (flag[len][p][q] != 0) return (flag[len][p][q] == 1 ? true : false); // 已经计算过 if (a.substring(p, p + len + 1).equals(b.substring(q, q + len + 1))) { // 子串相等 flag[len][p][q] = 1; return true; } for (int i = p + 1; i < p + len + 1; i...
c9a88b3d-252a-4990-af38-f3e3bb5f253d
5
@SuppressWarnings("unchecked") public synchronized long generateWayId(String key, List<Long> nodes, List<String> shapes ){ Long id = null; if (totalWays.get(key) == null) totalWays.put(key, new ConcurrentHashMap<WayOsm, Long>()); if (!totalWays.isEmpty()) id = totalWays.get(key).get(new WayOsm(nodes)); ...
8d390bc4-7f1d-4b53-920a-7bf7c0ffb585
3
public boolean getBoolean(int index) { Object value = get(index); if (Boolean.TRUE.equals(value) || value instanceof String && "true".equalsIgnoreCase((String) value)) { //$NON-NLS-1$ return true; } return false; }
48208a16-fdc4-42f5-9585-65e17f7659a4
3
public ArrayList<String> connect(String tableName) { Connection con = null; ResultSet rs = null; Statement st = null; String url = "jdbc:mysql://musoni.c4leprqodag9.eu-west-1.rds.amazonaws.com/musoni"; String user = "student"; String password = "cfg2014!"; try { Class.forName("com.mysql.jd...
feb5bade-97a0-479a-be1d-eb1d5e15c575
5
public void run() { java.net.Socket socket; // accept a connection try { socket = server.accept(); } catch (java.io.IOException e) { System.out.println("Class Server died: " + e.getMessage()); e.printStackTrace(); return; } // create a new thread to accept the next conn...
50b8156c-af96-4d48-b72d-dbab69df8ef6
4
protected void adaptNegative(){ int newOriginX = originX, newOriginY=originY, newWidth=width, newHeight=height; if(width<0 && height<0){ newOriginX = originX+width; newOriginY = originY+height; newWidth = width*-1; newHeight = height*-1; }else if(width<0){ newOriginX = originX+width; newWidth = ...
0677f6b7-e82f-4661-9186-7b0cabf34342
6
public Token scan() { Token tok; SourcePosition pos; int kind; boolean isDiv; currentlyScanningToken = false; while(currentChar == '/' || currentChar == ' ' || currentChar == '\n' || currentChar == '\r' || ...
03b0d4b4-a838-43ff-b940-2e918496b97e
2
public int removeAt(int index) { if(isEmpty()) throw new ArrayIndexOutOfBoundsException(); int temp = ListArray[index]; for(int i = index; i < size; i++) ListArray[i] = ListArray[i+1]; size--; System.out.print("Removed Element: " + temp + "\n"); System.out.println(" "); return temp; }
4110d7ee-c6b9-45a3-8fd3-2e5849b28e5c
5
private Location findFood() { Field field = getField(); List<Location> adjacent = field.adjacentLocations(getLocation()); Iterator<Location> it = adjacent.iterator(); while(it.hasNext()) { Location where = it.next(); Object animal = field.getObjectAt(where); ...
ac571502-81e5-4082-b1c8-925424a7df2a
6
public void processSrcDirMessage(OMMMsg respMsg) { // *_log<<"Received source directory response"<<endl; myCallback.notifyStatus("Received source directory response"); if (respMsg.getMsgType() == OMMMsg.MsgType.REFRESH_RESP || respMsg.getMsgType() == OMMMsg.MsgType.UPDATE_RE...
ae4c2588-96f0-4537-ac51-548ac325f000
2
public void removePoints(ArrayList<Point> points) { for (int i = 0; i < attachedPoints.size(); i++) { if (points.contains(attachedPoints.get(i))) attachedPoints.set(i,null); } attachedPoints.removeAll(Collections.singleton(null)); }
980f0965-26e2-4b97-9da5-f5a65f84352b
9
public int doRTTY_8000FFT (CircularDataBuffer circBuf,WaveData waveData,int start,int ss,double baud) { // 45.45 baud if (baud==45.45) { // Get the data from the circular buffer double datar[]=circBuf.extractDataDouble(start,FFT_176_SIZE); fft176.realForward(datar); double spec[]=getSpect...
d95ef201-fc34-4e84-b65a-d9af2f467dc2
4
public int minimumTotal(ArrayList<ArrayList<Integer>> triangle) { if(triangle == null ) return 0; List<Integer> list = triangle.get(triangle.size()-1); int[] min = new int[list.size()]; for(int i = 0 ; i < list.size(); i++) min[i] = list.get(i); for(int i ...
d26cf10d-eb3b-4210-b4b6-fa88007ed3cd
6
@Override public int compareTo (Result o) { if (value == null) { return o.value == null ? 0 : 1; } if (o.value == null) { return -1; } if (value.getClass() == o.value.getClass()) { if (value instanceof String) { return ((String) value).compareToIgnoreCase((String) o.value); } if (value ins...
765936da-1468-4c01-af66-e5ca97227828
7
private boolean isAppendable(final AngleUnitFlapPattern pattern, final int from, final Piece piece) { int tailOfAddition = from + piece.size() - 1; // overlength. if (tailOfAddition > tailIndex) { trace("not appendable: index overrun"); return false; } // empty? for (int i = from + 1; i < tailOfAdd...
7419453a-5d43-4fb1-96fe-439b97915c76
6
public Point2D.Float locatePoint() { final int TIME_UP = 600; AIPlane thisP = AIPlane.this; GameWorld world = thisP.getGameWorld(); Point2D.Float p = thisP.getCenterPoint(); if(currentMode == RANDOM_MODE) { if(point.distance(p) < 2.0) //CONSTANT { currentMode = FIND_MODE; time ...
7168bbac-0dd2-4ecd-8936-484cb4a49a41
1
public void visitThrowStmt(final ThrowStmt stmt) { print("throw "); if (stmt.expr() != null) { stmt.expr().visit(this); } println(" caught by " + stmt.catchTargets()); }
40e9279e-6e3b-4353-8bb7-a4631f978cbd
1
private byte[] Encode (int input[], int len) { int i, j; byte out[]; out = new byte[len]; for (i = j = 0; j < len; i++, j += 4) { out[j] = (byte) (input[i] & 0xff); out[j + 1] = (byte) ((input[i] >>> 8) & 0xff); out[j + 2] = (byte) ((input[i] >>> 16) & 0xff); out[j + 3] = (by...
b06a3fc2-39d8-4853-82c9-08155e0f5414
4
public static void main(String args[]) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch ...
31e8e233-145c-4241-aa61-7e72a5f0033c
3
public static void main( String[] argv ) { ProcessableResource pr = null; try { java.util.List<String> command = new java.util.LinkedList<String>(); // This will print the directory contents of cwd (Linux only) //command.add( "ls" ); //command.add( "-l" ); // This will call the PHP interpr...
22239c12-c35f-4b44-8f79-70a1a02e6db0
7
* @param direction The direction in which to attack. */ private void moveAttack(Unit unit, Direction direction) { clearGotoOrders(unit); // Extra option with native settlement Tile tile = unit.getTile(); Tile target = tile.getNeighbourOrNull(direction); IndianSettlement...
52d52cb4-f540-47db-b385-f421ad7df2be
1
public PacketIOException(IOException e, Packet packet) { super("IOException sending packet" + (e == null ? "." : "--" + e.getMessage()), packet); wrappedException = e; }
b0c83c0e-91a7-4bf9-b17d-a72007a7e8a1
1
public synchronized List<Long> getNodesIds(int pos){ if (nodes.size()>pos) return nodes.get(pos); else return null; }
6b8c1c91-6e56-4651-a009-c5f86d1d28ee
8
public static String coerceToModuleName(Stella_Object namespec, boolean warnP) { { Surrogate testValue000 = Stella_Object.safePrimaryType(namespec); if (Surrogate.subtypeOfStringP(testValue000)) { { StringWrapper namespec000 = ((StringWrapper)(namespec)); return (namespec000.wrapperValue);...
639301fb-dfac-4e71-8305-f3abbdbf2c2f
2
public int getInt(String key) throws JSONException { Object object = this.get(key); try { return object instanceof Number ? ((Number)object).intValue() : Integer.parseInt((String)object); } catch (Exception e) { throw new JSONException("JSO...
83e7e943-17e8-453f-82ba-640244870f74
5
public BEValue peerAnswerAsBEValue(TrackedPeer peer) throws UnsupportedEncodingException { Map<String, BEValue> params = new HashMap<String, BEValue>(); params.put("interval", new BEValue(this.announceInterval)); params.put("complete", new BEValue(this.seeders())); params.put("incomplete", new BEValue(this.l...
7f29d619-5bb0-45f1-a358-94fb88ae4b51
8
public static void main(String[] args) { String traceFile, ignoreFile, knownFile, tmp; int stackLimit = 50; CommandLine cmd = null; Options options = new Options(); options.addOption("f", "trace_file", true, "dalvik method profiling trace file"); options.addOption("i", "ignore_pattern_list", true, "...
3439d9fe-28d5-48fd-ac4d-ca951f5ba1f1
7
public static void main(String[] args) { if (args.length == 0 || "-h".equals(args[0]) || "--help".equals(args[0])) { System.out.println("Purpose: Transforms the POM files to use Debian versions."); System.out.println("Usage: [option] <poms>"); System.out.println(""); ...
71e4439f-1152-4052-b647-e124e1763bad
3
@Override public void execute(HttpServletRequest request, HttpServletResponse response) { DaoFactory daoFactory = MySqlFactory.getDaoFactory(); OrderDao orderDao = daoFactory.getOrderDao(daoFactory.getConnection()); HttpSession session = request.getSession(); try { List<O...
a330f57d-2605-4fa1-a83c-ea21d08aaa85
1
public synchronized void close() { if (isOpen()) { closeImpl(); setOpen(false); decoder = null; } }
feda5052-47a2-4af1-a0ef-59b21979f444
1
public void writeImage(String path, String ext, BufferedImage img) { try { File f = new File(path); f.delete(); ImageIO.write(img, ext, f); } catch (Exception e) { ConsoleHelper.appendError("Error while saving file."); ConsoleHelper.appendErro...
3cab597a-3d77-4fd7-8f19-db01ea2bceb7
5
/* */ @EventHandler /* */ public void onPlayerDamage(EntityDamageEvent event) /* */ { /* 148 */ if ((event instanceof EntityDamageByEntityEvent)) /* */ { /* 150 */ EntityDamageByEntityEvent event1 = (EntityDamageByEntityEvent)event; /* */ /* 152 */ if ((event1.getDamager()...
c3d9b228-fc71-420a-ab42-5008881fa3f1
1
long nthWeekday(int n, int weekday, int year, int monthOfYear, int dayOfMonth) { if (n > 0) { return 7 * n + weekdayBefore (fixedFromGJ(year, monthOfYear, dayOfMonth), weekday); } else { return 7 * n + weekdayAfter (fixedFro...
bbb6181f-6b1d-4392-b699-ab90dfbd402e
6
public final void setSliderPercent(int sliderIndex, double sliderPercent) { // Check sliderIndex is within array bounds, // if not create exception. if (sliderIndex < 0 || sliderIndex >= sliders.size()) { Tools.errorWindow(new IndexOutOfBoundsException( "The index you passed into the '...
fe46d9de-cd56-4093-a982-c6c35911f68b
0
public void turnDown() { turnOffCommand.execute(); }
16368956-f4c1-4626-9c3d-24919845dbf4
9
private void workOutServer() { try { Set<SelectionKey> keySet = ((Selector) this.serverTable.get(curServer)[1]).selectedKeys(); for (SelectionKey key : keySet) { // System.out.println("new Key!"); if ((key.readyOps() & SelectionKey.OP_READ) == SelectionKey....
f9797dde-112b-42b1-83d9-4fdcba1cf44d
5
public void writeKnownAttributes(GrowableConstantPool gcp, DataOutputStream output) throws IOException { if (constant != null) { output.writeShort(gcp.putUTF8("ConstantValue")); output.writeInt(2); int index; if (typeSig.charAt(0) == 'J' || typeSig.charAt(0) == 'D') index = gcp.putLongConstant(cons...
11716de8-3e6c-4599-a0cf-a42d977a5f62
5
public File createProjectFilename( TProject project ) { File file = project.getProjectFile() ; if ( file == null ) { TProjectFileList fList = project.getProjectData().getAvailableLangs() ; if ( fList.size() > 0 ) { TLanguageFile lFile = fList.get( 0 ) ; if ( lFile != null...
c3c110c2-90cf-4fff-ba94-93d623e8f56a
5
public static ArrayList<Reservation> getAllReservations(){ try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ArrayList<Reservation> reservationL...
40bc67ef-4717-4c29-9d52-f96eeaaa177b
1
public void nextQuestion() { if(i == QuestionCount -1 ) { i = 0; } else { // Current Question Id incremented by 1 i++; } // Display question in form this.setUp(); }
bffbd54e-e4fa-4c21-95aa-1a5b13c31530
8
@Override public Matrix run(Matrix coef, Matrix free) { assert(free.getWidth() == 1); Matrix b1 = new Matrix(coef.getHeight(), coef.getWidth()); Matrix b2 = new Matrix(coef.getHeight(), coef.getWidth()); Matrix ieb = new Matrix(coef.getHeight(), coef.getWidth()); Matrix c = n...
93480c19-9cc2-4586-8e5f-d05230774bae
1
public boolean getLimiteEnlace() { if(this.jRadioButton1.isSelected()) return true; return false; }
b5f7c730-3f5b-40e8-8e36-68614a6ddf46
3
public void printGridletList(boolean detail) { LinkedList list = receiveList_; String name = name_; int size = list.size(); Gridlet gridlet = null; String indent = " "; System.out.println(); System.out.println("============= OUTPUT for " + name + " ======...
2a617281-8b66-480a-b1bd-7102c93a3b9d
5
public Object getObject(int x, int y) { if (x < 0 || x >= WIDTH || y < 0 || y >= HEIGHT) { if (ChristmasCrashers.isDebugModeEnabled()) System.err.println("Failed to retrieve the object at the tile location (" + x + ", " + y + ") - index out of bounds.\nThe x value must be between 0 and " + (WIDTH - 1) + ", and...
1e3ac5dc-5f83-4e88-85c6-1c06c5f98c02
6
public static void generateContextAndBlanks(GRESCTask task, List<String> context, List<List<GRESCBlank>> blanks) { String[] tokens = task.getSentence().split(" "); for (String token : tokens) { if (! GRESCTask.GRE_FORMAT_BLANK_INDICATOR.equals(token)) { context.add(token); } } List<GRESCOption> opt...
58119cbb-88a6-4599-b8eb-07868ea60169
4
public void readMap(){ try { Scanner scan = new Scanner(new File(file)); width = scan.nextInt(); height = scan.nextInt(); tiles = new Tile[height][width]; int temp; for(int h = 0; h < height; h++){ for(int w = 0; w < width; w++){ temp = scan.nextInt(); if(temp == 2){ ...
d95defe9-6164-4792-81d2-750f477855ef
0
public void setVitality(double vitality) { this.vitality = vitality; }
8236a0d9-9b4b-4a02-9ec8-0f55e4e5429f
5
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attr) { String name = "" + file; if (!name.toLowerCase().contains("sopa")) { return CONTINUE; } if (attr.isRegularFile()) { if (name.endsWith(".tx...
b540421c-c39f-461e-ad94-c85bf18dbea6
4
private int getCommentsNum(File file) { if(!file.exists()) { return 0; } try { int comments = 0; String currentLine; BufferedReader reader = new BufferedReader(new FileReader(file)); while((currentLine = reader.readLine()) != nu...
336b139c-4928-4224-8a5f-2d14a118c119
1
public void visitCode() { if (mv != null) { mv.visitCode(); } }
192301cb-d0b5-437d-bcca-05c683e82086
6
@Override public View create(Element elem) { String kind = elem.getName(); if (kind != null) { if (kind.equals(AbstractDocument.ContentElementName)) { return new LabelView(elem); } else if (kind.equals(AbstractDocument.ParagraphElemen...
75924efe-806b-4f59-8bfa-4e1545cfa2f0
2
void checkIndex(int index) { if(index < 0 || index >= size) throw new IndexOutOfBoundsException("index = " + index + " size = " + size); }
b1531660-08c0-4e42-a6ec-a857db8187b7
1
public void visitForceChildren(final TreeVisitor visitor) { if (visitor.reverse()) { end.visit(visitor); start.visit(visitor); array.visit(visitor); } else { array.visit(visitor); start.visit(visitor); end.visit(visitor); } }
99d55a9b-578c-46f3-9d0f-a8578e218181
7
public boolean tick(double speed) { // XXX note that we use inGameStateNextFrame here, because this is an // indication of whether the timer should exist for the upcoming // frame. However, another timer in the timer set may change the // state, so there's actually a race condition here. if (parent_state!=nu...
c0b2556d-ba82-4340-9feb-6ac830a65fd0
3
public E peek() { E rv = null; int mp = 0; for(E e : this) { int ep = e.priority(); if((rv == null) || (ep > mp)) { mp = ep; rv = e; } } return(rv); }
4d88f824-731f-4dff-8929-10b26e6e9a3f
2
public void LoadDictionary(String dictionaryPath){ BufferedReader reader = null; try { String word; reader = new BufferedReader(new FileReader(dictionaryPath)); while ((word = reader.readLine()) != null) { this.dictionary.put(word, word); } } catch (Exception ex){ ex.printStackTrace(); } }
36fd9088-d7ae-4249-b18f-14385b62ee69
5
@Override public void actionPerformed(ActionEvent e) { try { conn = DriverManager.getConnection(Utils.DB_URL); PreparedStatement checkStat; checkStat = conn.prepareStatement("select name from section where name = ?"); checkStat.setString(1, newSectionTextField...
ba9fe939-7116-4841-938e-7997b0831b08
6
private void sendAsFixedLength(OutputStream outputStream, PrintWriter pw) throws IOException { int pending = data != null ? data.available() : 0; // This is to support partial sends, see serveFile() pw.print("Content-Length: "+pending+"\r\n"); pw.print("\r\n"); pw.flush(...
9a2cbbe4-f222-4828-9382-ff9a07b4954c
3
public void createChunk() { for (int x = 0; x < sizeX; x++) { for (int y = 0; y < sizeY; y++) { for (int z = 0; z < sizeZ; z++) { tiles[x][y][z] = Tile.Grass.getId(); } } } }
577671a0-1cb6-4837-baa2-838d1b88686e
5
@Override protected void inspectContents(File file, String contents) { StringBuffer buf = new StringBuffer(); // Split it into lines StringSplitter splitter = new StringSplitter(contents, getLineEnding()); // Scan each line int totalMatchesForThisFile = 0; int lineCount = 1; while (splitter.hasMore...
88dd2389-e67e-471f-a6cd-2607920ee356
4
public void actionPerformed(ActionEvent e) { if( e.getSource() == cancel) this.setVisible(false); else if( e.getSource() == ok){ int selected = this.recordTable.getSelectedRow(); System.out.println(selected); if( selected == -1){ JOptionPane.showMessageDialog(this, "请选择一条记录", "警告", 1); }else{ ...
ae051794-c617-4e9c-ad88-275364d8df1e
0
public static void main(String[] args) { LinkedList<Pet> pets = new LinkedList<Pet>(Pets.arrayList(5)); System.out.println(pets); // Identical: System.out.println("pets.getFirst(): " + pets.getFirst()); System.out.println("pets.element(): " + pets.element()); // Only differs in empty-list behavior: Sys...
ebadd713-88eb-4300-af17-e631fbe5f7ff
5
/* */ public void handleCollision() /* */ { /* 300 */ for (int i = 0; i < Core.bunkers.size(); i++) { /* 301 */ Bunker bunker = (Bunker)Core.bunkers.get(i); /* 302 */ if (bunker.collision.intersects(this.collision)) /* */ { /* 304 */ if (bunker.collision.x + bunker.collisio...
4aa015bb-8261-4dbd-9854-86347efe4f46
3
static void checkForCycle( SimpleQueue<Node> list, Arc a, int limit ) throws MVDException { if ( list.contains(a.to) ) throw new MVDException("Cycle: node"+a.to.nodeId+" already encountered"); else if ( limit > 0 ) { ListIterator<Arc> iter = a.to.outgoingArcs(); while ( iter.hasNext() ) { Arc b...
ec55eeef-108a-4240-ac57-6d39ee779089
6
@EventHandler public void CreeperHeal(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getCreeperConfig().getDouble("Creeper.Heal.Do...
82720669-2c7a-4673-9c54-26ba48ac368e
5
public static void main(String[] args) { System.out.println("Starting."); if (args.length > 0 && args[0] != null) { testHostName = args[0]; } if (args.length > 1 && args[1] != null) { testBasePort = Integer.parseInt(args[1]); } try { TestRunner.run(suite()); } catch (Throwa...
5de0beb6-9c9e-4ca5-8bdc-94ae9213d3df
1
public BufferedImage createCompatibleImage(int w, int h, int transparancy) { Window window = device.getFullScreenWindow(); if (window != null) { GraphicsConfiguration gc = window.getGraphicsConfiguration(); return gc.createCompatibleImage(w, h, transpa...
75ee5282-c346-4c5a-ab75-b980808e9c14
3
private void handleCurveDeletion(Point clickedPoint) { List<Curve> curves = Main.getCurveManager().getCurves(); int i = curves.size() - 1; boolean found = false; while (i >= 0 && !found) { selectedPoint = curves.get(i).checkMouseCollision(clickedPoint); if (selectedPoint != -1) { curves.remove(i); ...
189c827c-3c60-4104-b041-6cb5bbcb00bb
5
public int getLargestChildIndex(int n) { int leftChildIndex = getLeftNode(n); //with passed in index, get the left child index int rightChildIndex = getRightNode(n); // get the right child index Comparable leftChild = getLeftKid(n); // get the left child itself from the get left me...
01313eee-7ec8-4b41-b16c-8c68af2187da
3
private void moveUp() { if (facingEast()) { turnLeft(); if (frontIsClear()) { move(); turnLeft(); } } else { turnRight(); if (frontIsClear()) { move(); turnRight(); } } }
a072ed38-557c-4096-8f33-908a6d2e79b4
2
private boolean isListSorted(List tl) { // tl must be populated with DateTime objects. DateTime lhDT = (DateTime)tl.get(0); DateTime rhDT = null; Long lhVal = new Long( lhDT.getMillis() ); Long rhVal = null; for (int i = 1; i < tl.size(); ++i) { rhDT = (DateTi...
dc3c21e8-98e4-4098-9f05-444b915125ab
6
public boolean startTraining() { if (allData == null || facit == null) { return false; } int iterate = 0; do { iterate++; Collections.shuffle(allData); populateLists(); for (FaceData f : trainingData) { buildNetwork(f); for (int i = 0; i < 4; i++) { double act = calculateActivation...
4ef946f4-0cd9-42f3-b8a7-31f0dc30194a
8
public int findFarthest(){ int index=-1; for(int q=0;q<objects.size();q++) { if (objects.get(q) == this||objects.get(q).kind==kind||objects.get(q).kind==0) continue; int searchRadius = 400; //radius of whether the object will be findable boolean search...
6107cc67-a6d9-4ca8-a021-1b9c2f6a666b
4
public void doTurn() { if (!isPlayerOver) { System.out.println("Your score:" + player.getScore()); System.out.println("Hit? 1:Yes 0:No"); Scanner in = new Scanner(System.in); int input = in.nextInt(); if (input == 1) { player.add(deck.getRandomCardFromDeck()); } else { isPlayerOver = tru...
47843002-ce25-47c7-9766-0b01467c80bb
2
public void saveProgramAs(){ File file = askForFileName(); if (file != null){ LogoDocument program = getProgram(); program.setFile(file); try { program.save(); } catch (IOException e) { e.printStackTrace(); } } }
6b99d83b-bac8-4ed0-a56c-9d332fae28b8
0
public ReverseIterator(List<T> source) { this._source = source; this._position = this._source.size()- 1; }
41dae9f1-e159-4023-8df4-a9313451fbb6
3
public int getNbOfReservationsOfClient(String client) { int nbOfReservations = 0; for (Car car : this.cars) for (Reservation reservation : car.getReservations()) if (reservation.getCarRenter().equals(client)) nbOfReservations++; ...
6397b3e1-2461-40e9-8e10-6eadb0398d58
7
private static void initializeSupport(String wavType) { String waveFamily = ""; // Create the string for the wavelet family int ordBegin = -1; for (int i = 0; i < wavType.length(); i++) { char currentChar = wavType.charAt(i); if (Character.isDigit(currentChar)) { ordBegin = i; break; } el...
c888d93b-e175-4d6f-8d69-76363070676b
7
public void savePurchasedItems(ArrayList<Item> shoppingCart, int receiptid) { Connection con = null; try { con = ConnectionService.getConnection(); String query = "INSERT INTO PURCHASEITEM VALUES(?,?,?)"; PreparedStatement ps = con.prepareStatement(query); for (Item items : shoppingCart) { ps.setIn...
c1fd7fcd-295c-45a5-a43f-b97575fa7517
5
@Override public void emettre() throws InformationNonConforme { int i = 1, j = 0; float sum = 0.0f; int nbBits = informationRecue.nbElements() / nbEch; Boolean[] tabBool = new Boolean[nbBits]; for (i = 0; i < nbBits ; i++) { for (j = 0; j < nbEch; j++) { sum += informationRecue.iemeElement((i*nbE...
f016f7d5-e647-43b7-bc95-4400c68be2cc
8
public void paintMonitoAbajo(Graphics g) { if (tipo == 1 || tipo == 3 || tipo == 4 || tipo == 5 || tipo == 7 && monitosSentados.size() > 3) { Silla aux = (Silla) sillas.get(3); try { if (aux.isOcupada()) { monitosSentados.get(3).paintSentado(g, aux, th...
46f92bc5-7122-4720-a2c5-7998ad446017
0
public boolean getActive() { return active; }
0c03bd19-af70-4f0b-ab9f-03e988875ae6
7
public void compressStates() { StateHistory.compressTimestampHistory(lcdc, true); StateHistory.compressTimestampHistory(wy); StateHistory.compressTimestampHistory(wx); StateHistory.compressTimestampHistory(scy); StateHistory.compressTimestampHistory(scx); for (int i = 0; i < 0x800; i++) if...
b0dac61b-6c7d-4ca0-9a55-764aa22d1697
7
public boolean equals(Object other) { if ( (this == other ) ) return true; if ( (other == null ) ) return false; if ( !(other instanceof RelHermanoPasoId) ) return false; RelHermanoPasoId castOther = ( RelHermanoPasoId ) other; return ( (this.getDni()==castOther.getDni()) || ( this.getDn...
b2f86e62-a362-4840-81f1-5b60037e5bfe
7
@Override public void actionPerformed(ActionEvent e) { //Si il s'agit du bouton d'envoi a la pioche ouverte if ( e.getSource() == selected.getToOpenPickButton() && selected.hasSelection()) { //Demande au serveur si il est possible d'envoyer a la pioche ouverte try { this.client.sendMessage("SEND_TO_O...
8ad39941-abe4-4937-a3c3-2864a0514054
0
@Override public boolean isEmpty() { return bestPlays.isEmpty(); }
3338e9a2-1df9-484a-a820-f114f7794b3e
9
private static String getRemoveHardLinkCommandTemplate() throws IOException { //read rdpro.properties in the user home's folder? String homeDir = System.getProperty("user.home"); Properties config = new Properties(); InputStream input = null; try { input = new FileInputStream(homeDir+"/rdpro.properties"...
1db6c329-d810-41e5-94c9-47ac0cd3dc1e
7
public static Planet buildPlanet(PlanetEnum type) { Planet planet = null; switch(type) { case TERRESTRIAL: planet = new TerrestrialPlanet(); break; case GAS: planet = new GasPlanet(); break; case VOLCANIC: planet = new VolcanicPlanet(); break; case JUNGLE: planet = new JunglePlanet(); ...
3bbe067e-b2d9-451c-8b0b-00fbf3343876
0
public static List<Praticien> selectAllOrderPraNum(EntityManager em) throws PersistenceException { List<Praticien> lesPraticiens = null; Query query= em.createQuery("select pra from Praticien pra order by pra.numero"); lesPraticiens = query.getResultList(); return lesPraticiens; }
cad482a5-633b-418c-b26b-8859defeb8bf
7
public boolean commit(){ if(writes.size()==0) return true; Write primary=writes.get(0); if(!prewrite(primary,primary)) return false; for(int i=1;i<writes.size();i++){ if(!prewrite(writes.get(i),primary)) return false; } commit_ts=OracleTimestampEmu.getCurTimestamp(); Write p=primary; BigTab...
c3b71d90-fcb2-4f3e-8c18-2bb314d21de4
9
public boolean blockBishop(int ex, int ey) { if (ex > x && ey > y) { bishopNW(ex, ey); } if (ex > x && ey < y) { bishopSW(ex, ey); } if (ex < x && ey > y) { bishopNE(ex, ey); ...
a10160e1-e86a-40df-b413-f0e4a340c251
5
private void backTrackToUnit() { if (myUnitStepMap==null) return; int index=0; while (index<myAnswer.size()) { for (ArrayList <Production> key: myUnitStepMap.keySet()) { if (myUnitStepMap.get(key).equals(myAnswer.get(index))) { myAnswer.remove(index); int c=0; for (Production p ...
29e1348a-81f8-43ce-9d43-5f1ceb15bea6
0
@Override public String getCur() {return cur;}