method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
eb290c27-a16f-43a1-8d6a-4af28097b66c
1
public Block loopHeader(final Block block) { if (loopEdgeModCount != edgeModCount) { buildLoopTree(); } return block.header(); }
8131cdc5-65e9-47f5-a2d9-5620c38f2695
1
public static void init(double inMaxSpeed) { if (_singleton != null) { throw new RuntimeException("CreatureFactory already created by " + _singleton.getClass().getName()); } else { _singleton = new CreaturePluginFactory(inMaxSpeed); } }
161463f9-8408-46c3-b57c-4a7a544f05bd
8
public void startProcess() { { ShellProcess self = this; { java.lang.Process process = null; String[] command = self.command; String directory = self.directory; InputStream input = self.inputStream; OutputStream output = self.outputStream; OutputStream error = self.err...
631e964e-385c-4dc1-adf8-c2012a567448
0
public void undo() { this.to.removePiece(this.piece); this.from.addPiece(this.piece); this.piece.decreaseMoveCount(); }
625f5931-2831-4a78-8002-99ddbfc6ad31
2
private void fixArray() { try { if (streamAlive.size() < streamName.size()) { streamAlive.add(false); fixArray(); } } catch (Exception ignored) {} }
8d1dc95f-ed49-4098-96a2-3ca109e92f09
8
public String evaluatePolicy_innerMethod( TransferredFile policyFileToTransfer, TransferredFile dbSQLDumpFileToTransfer, Context initialContext, long gid) { logger.writeLog(Level.ALL,"Method evaluatePolicy_innerMethod, gid:"+gid+", thread number:"+Thread.currentThread().getId()); logger.writeLog(Level.AL...
9e95506c-9822-4e4f-8b2e-35b6c25e22d0
7
public static int findTransform(String s , String e, ArrayList<String> dict){ LinkedList<String> q = new LinkedList<>(); dict.add(e); if (s==null || e==null || s.length() ==0 || e.length()==0 || s.length()!=e.length()) return -1; q.add(s); int dist = 0; while...
4442950d-890b-4fb9-9da8-1fe7a76a0ee4
0
public Game() throws InterruptedException { GUI.println("Start create game"); Main.isPlaying = true; setRolesToUsers(); GUI.println("roles seted"); sendRoles(); GUI.println("roles sended"); TimeUnit.SECONDS.sleep(10); stopSleeping(); // sendgameresult // listen to votes // print votes }
2acae078-6d88-4e2f-929c-bc5de54fd4ed
2
@Test public void test() { Attachment fetchedAttachment = (Attachment) MongoHelper.fetch(attachment, "attachments"); if(fetchedAttachment == null) TestHelper.failed("attachment not found"); fetchedAttachment.setFileName("changed.txt"); if(!MongoHelper.save...
b1b99771-83c1-4765-b074-846202137267
8
void orderVertices(ArrayList<Integer> ColOrd){ Vertex[] V = new Vertex[n]; for (int i=0;i<n;i++) V[i] = new Vertex(i,degree[i]); for (int i=0;i<n;i++) for (int j=0;j<n;j++) if (A[i][j] == 1) V[i].nebDeg = V[i].nebDeg + degree[j]; if (style == 1) Arrays.sort(V); if (style == 2) minWidthOrder(V); if (style ...
d8d62855-d89a-4ab4-ba0d-13c8f572aadd
9
public static void main(String[] args) { int[] A = {1, 3, 4, 6,8,10, 17, 34} ; int[] B = {2, 8, 17, 33, 44, 66, 89, 100, 123}; int largest = A[A.length-1] > B[B.length-1]? A[A.length-1] : B[B.length-1]; int smallest = A[A.length-1] < B[B.length-1]? A[A.length-1] : B[B.length-1]; int i=0,j=0; wh...
00f1fbe8-daa8-4eb9-8f62-8501923ea298
0
KeyEntry(K k, V v){ mKey = k; mValue = v; }
919ae81f-5b6a-4579-b16d-6dada7a9c433
3
public static ArrayList getSerialResumoAssis(String arg_serial) throws SQLException, ClassNotFoundException { ArrayList<String> arra = new ArrayList<String>(); if(arg_serial.length() > 6 ){ arg_serial = arg_serial.substring(arg_serial.length() - 6); } // Assistec:...
5f0e0b11-ba0d-483d-8686-4341a361dca6
3
public Cuckoo getCuckoo(double stepSize, int N) { Random generator = new Random(); int direction; if (generator.nextInt(2) == 0) direction = 1; else direction = -1; this.egg.m += direction * Math.round(stepSize * generator.nextFloat()); if (egg.m <= 0) egg.m = 1; else if (egg.m > N) egg.m = N;...
69d4d210-84f7-43a0-9144-49362c260e7b
3
public static String convertTabSpaceSpecialCharacters(String message) { if (isEmpty(message)) { return message; } if ("\\t".equals(message)) { // Tab return replace(message, "\\t", "\u0009"); } else if ("\\s".equals(message)) { // Space return replace(message, "\\s", "\u0020"); } return message; ...
1d036e2a-2773-43da-b812-6c83999c899a
5
static int faceDirection(Puck puck) { if (puck.getOwnerPlayerId() != -1) { return 7; } if (Math.abs(puck.getSpeedX()) + Math.abs(puck.getSpeedY()) < 0.5) { return 3; } if (puck.getSpeedX() > 0) { if (puck.getSpeedY() > 0) { retu...
d97fe83a-77c7-464e-9855-109e28032fd3
2
@Override public User getUser(String email) throws DaoException { waitCompete(); List<User> usersList = new ArrayList<User>(getEntities().values()); for (User userTmp : usersList) { if (userTmp.getEmail().equals(email)) { return userTmp; } } return null; }
98ae0ceb-071b-4720-8961-8f4a5d41fd18
2
public boolean validSeat(int num) { boolean validity = false; if(num >= 0 && num < seat.length) { validity = true; } else { validity = false; } return validity; }
cb889b26-b6a4-441a-9282-1fcf813cbf4d
1
public void updateAndClearLists() { // Synchronise the waitingEventLists which stores the list of all events // which were collected during the previous logic update and clear each // individual key synchronized (waitingEventLists) { for (Collection<EventHolder> eventHolderList : waitingEventLists.values()) ...
b8342a1f-8167-4baa-a5f3-e517d1e8505b
3
public boolean outsideBoundaries(int x, int y) { return (x>=getMapWidth() || x < 0 || y >= getMapHeight() || y < 0); }
3908d2c8-9d81-40bf-bdd2-41e7b2211361
0
public String getCaption() { return caption; }
de352e88-9ac5-47f5-8c0e-47aa661aa9c9
5
public void add(Circle other) { if (mRadius == other.mRadius) { // Faster way, but only works when radius is the same double x1 = (mX + other.mX) / 2; double y1 = (mY + other.mY) / 2; double x = mX - other.mX; double y = mY - other.mY; double distanceSquared = x * x + y * y; double radiusSquared1...
d959f777-2b11-4d5e-b459-658288a5243c
6
public void readMap(){ try { Scanner scan = new Scanner(new File(maps.get(mapNum))); height = scan.nextInt(); width = scan.nextInt(); tiles = new Cell[width][height]; int tempInt; for(int h = 0; h < tiles.length; h++){ for(int w = 0; w < tiles[0].length; w++){ tempInt = scan.nextIn...
a6d4587d-27ab-45da-a47d-e09d531f97d3
4
@Test public void testIterator() { Set<ActorId> ids = new java.util.HashSet<ActorId>(); ActorSet as = new ActorSet(); for (int i = 0; i < 1024; i ++) as.add(new TestActor(Vector3f.newRandom(100))); for (Actor a: as) { assertTrue(a instanceof TestActor); ...
3fd4ee38-dd5d-4202-9cbe-b49bf46de4bd
4
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || this.getClass() != o.getClass()) { return false; } Index n = (Index) o; return row == n.row && column == n.column; }
5ee85e5c-22d8-4894-b5f0-742c2a365f10
9
private void startEchoServer() { //设置默认的监视端口 int defaultPort = 5555; //新建selector和channel try (Selector selector = Selector.open(); ServerSocketChannel serverSocketChannel = ServerSocketChannel.open()) { //检查是否正常打开 if ((selector.isOpen()) && (serverSo...
93f2ea5a-0c98-448a-895f-08629a6944f6
4
@Override public boolean equals(Object object) { if (object == null || !(object instanceof ContextKey)) { return false; } ContextKey that = (ContextKey) object; return that == this || this.name().equals(that.name()) && this.contextType().equals(that.contextType()); }
849f16fb-9683-4285-af44-40fd155780ad
9
public boolean isValid(){ // 1. do bound check on pts value if(this.width <= 0 || this.height <= 0 || this.no_of_division <= 0 ){ return false; } // 2. do bound check on points to be removed. if(this.removalList != null){ for(Point pt : removalList){ if(pt.getX() < 0 || pt.getX() >= width || ...
8a0829f1-e000-42df-b1f7-f5de1d1eaaac
7
public void computeNewValues() { // This stuff is to ensure that new prices follow a random // but nondivergent path, centered around the reference price double limit = ref / 4.0; int jump = ref / 100; double relDist = (last - ref) / limit; ...
b4ea5cf5-ec6f-43a2-8cca-883add39ede2
9
private String mygettoken() { while (this.index < this.length){ char c = this.line.charAt(this.index); if (this.flag) { if (this.resky.indexOf(c) != -1) { if (this.count > 0) { String t = this.line.substring(this.start,this....
f0496ce4-d7a0-4008-92ef-f888b5fa88c2
4
public void testConstructor_int_int_Chronology() throws Throwable { MonthDay test = new MonthDay(6, 30, GREGORIAN_PARIS); assertEquals(GREGORIAN_UTC, test.getChronology()); assertEquals(6, test.getMonthOfYear()); assertEquals(30, test.getDayOfMonth()); try { new Month...
6f984615-fdee-455e-8908-b20934639621
8
public void newGame() { String s; String name = ""; String type = ""; s = "Welcome to Ye Olde RPG!\n"; s += "\nChoose your difficulty: \n"; s += "\t1: Easy\n"; s += "\t2: Not so easy\n"; s += "\t3: Beowulf hath nothing on me. Bring it on.\n"; s ...
43a2cf11-ef6b-47cf-907b-3296632b5803
8
private void byAttribute() { TokenQueue cq = new TokenQueue(tq.chompBalanced('[', ']')); // content queue String key = cq.consumeToAny("=", "!=", "^=", "$=", "*=", "~="); // eq, not, start, end, contain, match, (no val) Validate.notEmpty(key); cq.consumeWhitespace(); if (cq.isEm...
3095d579-06af-421b-b47a-3a00beb7e4a6
3
public boolean equals(Coordinate c) { if (c == null) return false; else if (this.x == c.x && this.y == c.y) return true; return false; }
4856ccee-aec0-4c64-bf21-f1f3b362efbe
5
private void updateTabla(){ //** pido los datos a la tabla Object[][] vcta = this.getDatos(); //** se colocan los datos en la tabla DefaultTableModel datos = new DefaultTableModel(); tabla.setModel(datos); ...
63885f96-89a0-427f-8d3f-f7ebd2e98d38
4
protected static Ptg calcChoose( Ptg[] operands ) { if( operands.length < 2 ) { return new PtgErr( PtgErr.ERROR_VALUE ); } Object o = operands[0].getValue(); try { Double dd = new Double( o.toString() ); // this can be non-integer, so truncate it if so... double e = dd; int i = (int) e; if( ...
cd1dd927-17c8-4f50-b103-c7b2c14739a2
2
public String getString() throws InvalidBEncodingException { try { return new String(this.getBytes(), "UTF-8"); } catch (ClassCastException cce) { throw new InvalidBEncodingException(cce.toString()); } catch (UnsupportedEncodingException uee) { throw new InternalError(uee.toString()); } }
6117c469-625e-43ac-829a-96f8462a9f02
0
@Override public boolean supportsEditability() {return true;}
4d47df0c-7136-472e-9efb-a0c3355558d0
8
public static List<String[]> getMstxSort() {// 得到美食的全部种类 List<String[]> result = new ArrayList<String[]>(); Connection con = DBUtil.getConnection(); PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = con.prepareStatement("select sid,info_sort from mstx_sort;"); rs = pstmt.executeQuery();...
8fa03e3f-edf3-438b-a814-b3b7d8cf4b7f
5
public static <GInput, GOutput> Builder<GOutput> convertedBuilder(final Converter<? super GInput, ? extends GOutput> converter, final Builder<? extends GInput> builder) throws NullPointerException { if (builder == null) throw new NullPointerException("builder = null"); if (converter == null) throw new NullPointer...
88f2d92d-9f15-433b-b63b-a16a63741ac2
6
public Object getValueAt(int rowIndex, int columnIndex) { switch (columnIndex) {// parcour par colonne case 0://colonne id_Stock return medicaments.get(rowIndex).getId_mdc(); case 1://colonne id_Stock return medicaments.get(rowIndex).getRef(); ...
c7c3ba67-1887-4a09-a44a-5713e56f1beb
7
@Command( name = "pickpocket", aliases = {}, player = true, permission = "masters.pickpocket", description = "Pickpocket a Player's inventory or Ender Chest", usage = "/<command> [-e] <player>" ) public void openInventory(CommandSender sender, String[] args){ if (args.length < 1) throw new Comm...
d940f179-5865-4a5f-b007-0751654d6e5a
1
private ArrayList <Year> createYears (int y,int n) { myYears = new ArrayList <Year> ();//years in the calendar program Year FirstYear = new Year (y,n);//first year myYears.add(FirstYear);//add the first year to the list for (int i = 2;i<=10;i++)//10 years of data { Year previous = myYears.get(i-2); i...
473d96a8-4074-41ad-8477-de3dd48d0fff
1
public void setAll(Map<K, V> values) { for (Entry<K, V> entry : values.entrySet()) { set(entry.getKey(), entry.getValue()); } }
27865628-e15d-47f7-a0d3-0777eaac7c91
1
@Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { isPushed = true; this.row = row; this.col = column; ImageIcon isReadOnly = (ImageIcon) value; if (isReadOnly == OutlineEditableIndicator.ICON_IS_NOT_PROPERTY) { return button; }...
d4bf6302-a63b-48f1-8aba-e8fe3b996d29
1
public boolean Apagar(int id ){ try{ PreparedStatement comando = conexao .getConexao().prepareStatement("UPDATE clientes SET " + "ativo = 0 WHERE id = ?"); comando.setInt(1, id); comando.execute(); comando.getConnection(...
33825abc-a198-4e2b-9010-ec9b84e1878a
7
void initializeMesh(boolean use2Sided) { int vertexCount = currentMesh.vertexCount; Vector3f[] vectorSums = new Vector3f[vertexCount]; if (!isSilent) Logger.debug(" initializeMesh " + vertexCount); /* * OK, so if there is an associated grid point (because the point is so close to one), we now declare tha...
d2be52db-303d-4aca-8bf4-d50c8e92fd9c
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...
35ef9f3e-bb9b-480b-bd5a-daf1ae1f5464
1
public void writetoProperties(){ Properties prop = new Properties(); try { //set the properties value prop.setProperty("database", "localhost"); prop.setProperty("dbuser", "henryc"); prop.setProperty("dbpassword", "password"); //save properties to project root folder pro...
7170b804-db54-446d-bf9c-f0670d3fe6ba
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; WorkerConfig other = (WorkerConfig) obj; if (uid == null) { if (other.uid != null) return false; } else if (!uid.equals(other.uid)) r...
3cc38298-c145-428a-9aa9-3c7ff5d82489
0
public int getTotalNodes() { return totalNodes; }
d55cf3cc-795c-481e-90e9-4db01bdcd953
7
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof ImgEvent)) { return false; } ImgEvent other = (ImgEvent) obj; if (eventname == null) { if (other.eventname != null) { return false; } } else if (!...
26bd0fcd-f7d5-4110-acf4-6caacf42a411
7
public static double[][] readData(String fileName) { BufferedReader b; double[][] data = null; try { b = new BufferedReader(new FileReader(fileName)); String line; // count number of lines int N = 0; while ((line = b.readLine()) != null) { N++; } b.close(); // data is of the form: (us...
1a820dbb-777c-412c-980c-6b93f5c06808
2
protected void removeLayoutObject(T layoutObject){ if (layoutObject == null){ throw new IllegalArgumentException("layoutObject cannot be null"); } removeBuffer.add(layoutObject); layoutObject.deleteObserver(this); SwingUtilities.invokeLater(new Runnable(){ public void run(){ T newLayoutObject = r...
2cf0bd33-7226-4b7a-a2df-31e79ec5a6d6
6
private Image getImage(String filename) { // to read from file ImageIcon icon = new ImageIcon(filename); // try to read from URL if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) { try { URL url = new URL(filename); ...
0721ffa3-d210-4da3-b62b-3666526e44d9
4
public boolean isEntityAt(int x, int y){ if( x > this.x + imageOffsetX && x < this.x + imageOffsetX + imageWidth && y > this.y + imageOffsetY && y < this.y + imageOffsetY + imageHeight){ return true; } return false; }
b9466c2d-8172-48dd-90b5-10eabff61be8
6
public boolean revise() { info("Revising shop \"" + name + "\":"); if (name == null) { setName(DEFAULT_NAME); } if (startCoord == null) { revErr(STARTCOORD); return false; } if (endCoord == null) { revErr(ENDCOORD); ...
c26b9985-5716-4e19-8d14-15a6c4d74c86
9
private void InserirNovoInsecto() { String referencia = jTextFieldReferenciaInsecto.getText(); String nome = jTextFieldNomeInsecto.getText(); String local = jTextFieldLocalInsecto.getText(); boolean estado = true; boolean existeInsectocacador = false; if (referencia.equ...
b072814a-616b-4825-b82c-d2e902077703
3
private void copyPixels(int i, int width, int height, int l, int i1, int k1, int ai[], int pixels[]) { int shiftedWidth = -(width >> 2); width = -(width & 3); for (int i2 = -height; i2 < 0; i2++) { for (int j2 = shiftedWidth; j2 < 0; j2++) { pixels[i++] = ai[i1++]; pixels[i++] = ai[i1++]; pixels[i+...
7bb6121c-3c71-4cca-bd97-39ba3eff6e70
6
public GraphMatcherPersistent addMatches(Edge e) { if((matchQueue == null) || (allMatches == null)) initializeMatching(); /** * Ordered pattern edges, according to label. */ SortedSet<Edge> sortedEdges = new TreeSet<Edge>(new EdgeComparator(monitor)); sortedEdges.addAll(pattern.getEdges()); int edg...
2447ad54-108d-4308-90da-3d428989d8c7
7
public List<Ability> returnOffensiveAffects(MOB caster, Physical fromMe) { final List<Ability> offenders=new Vector<Ability>(); final boolean admin=CMSecurity.isASysOp(caster); Ability A=null; for(int e=0;e<fromMe.numEffects();e++) // personal { A=fromMe.fetchEffect(e); if((A!=null) &&(A.canBeUninvo...
62dee00c-3744-45e5-8f25-d02336d84cfe
5
public String[] PopulateClasses(String[] classes, int linecount){ numunique = 0; boolean newclass = true; String[] classlist = new String[linecount]; for (int i = 0; i < linecount; i++){ for (int j = 0; j < numunique; j++) { if (classes[i] == null || classes[i].equals(classlist[j])) { newclass = fal...
0b86042b-b433-4ecd-9fb3-8f2fce3c6c69
4
public Config(Map<String, String> config) { if(config == null) throw new NullPointerException(); for(String key : config.keySet()) if(key == null) throw new IllegalArgumentException("Null key in config"); else if(config.get(key) == null) throw new IllegalArgumentException("Null value in config"); ...
2c4e6f46-841a-486c-bcf4-3c919613fb47
1
public void clear() { for (int i = 0; i < pixels.length; i++) { pixels[i] = 0; } }
f63325c8-2695-4a43-80a9-fb32686a1a79
8
public static Iterator<Position> get8NeighborhoodIterator(Position center) { ArrayList<Position> list = new ArrayList<Position>(); int row = center.getRow(); int col = center.getColumn(); int r,c; for (int dr = -1; dr <= +1; dr++) { for (int dc = -1; dc <= +1; dc++) { ...
bc5537cb-4377-47c0-ac9c-574b64995b35
4
public void genAlignment(){ rand = new Random(); alignmentRoll = (rand.nextInt(4)+1); if(alignmentRoll == 1){ alignment = "Good"; } else if(alignmentRoll == 2){ alignment = "Evil"; } else if(alignmentRoll == 3){ alignment = "Law"; } else if(alignmentRoll == 4){ alignment = "Chaos"; } }
a7425e80-87ff-424e-b32a-b16d8924fac2
8
public static ArrayList<Class<?>> getClassesFromFolders(File dir, File parentFile) throws ClassNotFoundException, MalformedURLException { final ArrayList<Class<?>> classes = new ArrayList<Class<?>>(); if (dir.isDirectory()) { for (int i = 0; i < dir.listFiles().length; i++) { if (dir.listFiles()[i].is...
6f155d5c-d1ab-4bb9-9583-a10a95d4c982
1
public void visitForceChildren(final TreeVisitor visitor) { if (visitor.reverse()) { target.visitOnly(visitor); expr.visit(visitor); target.visitChildren(visitor); } else { target.visitChildren(visitor); expr.visit(visitor); target.visitOnly(visitor); } }
7b6092ce-b6ef-4f9a-ad8f-bf2c332940a2
7
@Override synchronized public void init () { if (Started) return; // the applet need only start once Started = true; // intialize Global things Global.url(getCodeBase()); Global.readparameter(".go.cfg"); Global.createfonts(); Global.frame(new Frame()); Global.loadmessagefilter(); // see, if there is...
11e022f4-7ba0-4ae4-8eda-f54b5e9d9d42
6
public static void main(String[] args) throws IOException { if (args.length != 2) { System.err.println( "Usage: java EchoClient <host name> <port number>"); System.exit(1); } String hostName = args[0]; int portNumber = Integer.parseInt(...
56bbad2b-5b82-44bb-825a-7cff32c96c42
0
public void setRock(boolean rock) { this.rock = rock; }
352c0879-7d61-49b8-9480-a16e4f889df1
8
private Double getPrice(Basket basket) { double price = 0.0; int howMany = 0; List<Product> products = basket.getProducts(); if (products == null || products.isEmpty()) { return price; } for (Product product : products) { howMany++; ...
c5f84165-ce13-442b-9eaa-14a4ea36a245
8
int readCorner2(int numRows, int numColumns) { int currentByte = 0; if (readModule(numRows - 3, 0, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(numRows - 2, 0, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(numRo...
72785f35-e354-4838-90e3-2948930bc3f1
6
private void getNextPosition() { if(left) dx = -moveSpeed; else if(right) dx = moveSpeed; else dx = 0; if(falling) { dy += fallSpeed; if(dy > maxFallSpeed) dy = maxFallSpeed; } if(jumping && !falling) { dy = jumpStart; } }
3dabb40f-7431-4637-b7a7-30d9100114d6
1
private static void findUser(Role r) throws Exception { RoleDAO rd = new RoleDAO(); // UserDAO ud = new UserDAO(); // User user = (User) ud.findById(u.getId()); List<User> ur = rd.findUser(r); // UserRole o; // Role role; System.out.println("User's roles " + ...
69dce653-d87a-4844-a4d8-4c3e056b772a
5
@Test public void findSolution_methodFindsOptimalSequence() { byte[][] tests = {test1, test2, test3, test4}; Puzzle p = new Puzzle(); for (int i = 0; i < tests.length; i++) { p.setPuzzle(tests[i]); IdaStar idaStar = new IdaStar(p, new ManDist_LinearConflict()); ...
6b8e2615-40e0-494e-84ea-09187cc3a323
7
private void connectPrepOnToRule(int inst, int ruleStart, CABot3Net ruleNet) { int fromStart = inst * nInstCASize; for (int neuron = 61; neuron < 80; neuron++) { int fromNeuron = neuron + fromStart; if (!neurons[fromNeuron].isInhibitory()) { for (int synapse = 0; synapse < 7; synapse++) { //...
b1023aaf-ed9f-45c0-a423-b79d3528c689
2
public int driveTheCar(int distanceTravelled) { if (isCarRented() == true || fuelInCar > 0) { int consumptionRate = distanceTravelled/20; return consumptionRate; } else { return 0; } }
818724ce-f3b7-4f0f-836e-4489962da661
4
public static Dir toWalk(Dir dir) { switch(dir) { case North: return NorthW; case South: return SouthW; case East: return EastW; case West: return WestW; default: return dir; } }
b7abc55c-06a8-4c49-b79c-d54d3b260ba6
2
public static int search(int[] A, int target) { for(int i=0;i<A.length;i++){ if(target == A[i]) return i; } return -1; }
b1fa0a2a-83a5-492d-9710-dbf842658389
5
public void printStreamInfo() throws IOException { OggPacketReader r = ogg.getPacketReader(); System.out.println("Processing file \"" + file + "\""); // Normally there's only one Skeleton stream, but sometimes // there can be more. Collect all of them List<SkeletonStream> skel...
a7953652-2ffb-4233-aadc-2cacc9bfc3c4
6
public double density(double x) { recomputeZ(); if (x < 0 || x > 1) { return 0; } else if (x == 0) { if (alpha < 1) { throw new NumberIsTooSmallException(LocalizedFormats.CANNOT_COMPUTE_BETA_DENSITY_AT_0_FOR_SOME_ALPHA, alpha, 1, false); } ...
10a679f0-284c-466c-85d2-11e502b7bd9d
6
@Override public boolean deleteBook(Book book) { if (doc == null) return false; Element currRoot = doc.getRootElement(); Element books = currRoot.getChild("books"); List<Element> listBooks = books.getChildren(); if (book.getLoanList() != null) for (Loan item : book.getLoanList()) { if (!deleteLoan...
8c3595e2-d430-4197-903c-bd4b8ca19cd3
3
public static void filledSquare(double x, double y, double r) { if (r < 0) { throw new IllegalArgumentException("square side length must be nonnegative"); } double xs = scaleX(x); double ys = scaleY(y); double ws = factorX(2 * r); double hs = factorY(2 * r); ...
d58b30bc-ac4c-42f4-ba40-67ba1e666199
5
private String getFile(final String dirname, final String start, final boolean exactMatch) { String[] array = directories.get(dirname); if (array == null) { array = new File(dirname).list(); directories.put(dirname, array); } final int length = start.leng...
8621454e-133b-40ad-be50-af6237c316dc
2
public boolean shipWorks(Ship ship) { if(shipInBounds(ship) && !collides(ship)) return true; return false; }
fae07113-119d-4695-947c-b2db441cb92b
4
private String completeDeposit(Scanner in) throws FileNotFoundException { String accountInput = in.next(); while(!accountInput.equals("Checking") && !accountInput.equals("Savings")) { System.out.println("Sorry, please enter Savings or Checking: "); accountInput = in.next(); ...
c28f8978-8a97-4dfd-8f81-503ce5b3d2dc
4
public final T getNoodi(int x, int y) { if (x >= 0 && x <= this.leveys && y >= 0 && y <= this.korkeus){ return noodit[x][y]; } else { return null; } }
d3ba8eff-22dd-4bfb-b103-f6975b283925
9
public String nextToken() throws JSONException { char c; char q; StringBuffer sb = new StringBuffer(); do { c = next(); } while (Character.isWhitespace(c)); if (c == '"' || c == '\'') { q = c; for (;;) { c = next(); ...
164530eb-8f54-4191-bd7d-d64b419a1432
0
public int getMaxRANGE() { return maxRange; }
c2123632-e279-4726-934f-761ce16e2d02
2
private void seekAndUpdatePosition(Duration duration) { final MediaPlayer mediaPlayer = musicPlayer.getMediaPlayer(); if (mediaPlayer.getStatus() == Status.STOPPED) { mediaPlayer.pause(); } System.out.println(mediaPlayer.totalDurationProperty().toString()); mediaPlay...
8df76384-0e43-4c5c-8f4a-331302f9ae1e
8
final public void ForUpdate() throws ParseException { /*@bgen(jjtree) ForUpdate */ ASTForUpdate jjtn000 = new ASTForUpdate(JJTFORUPDATE); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); try { StatementExpressionList(); } catch (Throwable jjte000) { ...
9852a54b-62b6-48b7-b2ba-89d998cef652
3
private static String executeUpdateCommand(DataBaseManager dbManager, Command command) { List<String> args = command.getArgs(); String tableName = args.get(0); List<String> params = args.subList(1, args.size()); String msg; try { dbManager.updateByKey(tableName, par...
c01a3e6a-5bde-4712-b058-92838675e806
5
private void clientLoop(){ boolean breakLoop = false; MenuRender mainMenu = new MenuRender(); while(true){ //menuRender is the next state, and returns which thing is clicked on int nextState = mainMenu.menu(sm, errorCode); switch (nextState){ case 1 ://new game startGame(); break; case 2 :/...
45f00119-f0d0-4aaf-849b-667a5fc88311
7
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { final Set<MOB> h=properTargets(mob,givenTarget,false); if(h==null) { mob.tell(L("There doesn't appear to be anyone here worth casting this on.")); return false; } if(!super.invoke(mob,co...
66243b2c-9f11-47a7-b88e-ac9df45ab488
8
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; RelationshipInterestsEntity that = (RelationshipInterestsEntity) o; if (interestsId != that.interestsId) return false; if (interestId != null ?...
d0c744cf-d3ec-48e8-a762-07b11dc44571
9
public boolean walk(Dir dir) { if (isWalking) return false; face(dir); setTextureRegion(sprites.getSprite(getFacing())); boolean c = false; switch (dir) { case North: c = map.collide(trueX(), trueY() + 1, getLayer()); break; case South: c = map.collide(trueX(), trueY() - 1, getLayer()); bre...
a7cb5ce7-eeca-4ea0-aa4a-5a5361fbda72
0
public void go() { frame = new Frame("Grid Layout !"); frame.setLayout(new GridLayout(3,2)); b1 = new Button("1"); b2 = new Button("2"); b3 = new Button("3"); b4 = new Button("4"); b5 = new Button("5"); b6 = new Button("6"); frame.add(b1); frame.add(b2); frame.add(b3); frame.add(b4); ...
91e0244e-394a-463f-9be9-647bd5cf2918
5
public void getFieldMethod() { try { Class<?> clazz = Class.forName("com.rock.reflect.User"); Field[] fields = clazz.getDeclaredFields(); for(Field field:fields) { System.out.println("Field:"+field); } Method[] methods = clazz.getDeclaredMethods(); for(Method method:methods) { System...
40aff03c-3237-4407-b43e-adf0c3af4818
5
void go() { while (submit(sortedSet.iterator(), resultList)) { LockSupport.park(); } for (Case<?> c : orderedList) { // When adding the contains below, the error occurs much faster. if (c.result != null && resultList.contains(c.result)) { c.run(); } } }