method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
f869ced1-758c-41bb-a3bf-7e94040220f6
1
public static void initLogging() throws IOException{ //создаем общую папку с логами Logs в корне программы String curDir = new File(".").getAbsolutePath(); File LogsDir = new File(curDir.replaceAll(".", "") + "Logs"); try{ LogsDir.mkdir(); LogDir = LogsDir.getAbso...
3e9a0db5-0092-4669-8d26-8a6ab4f2efd0
1
XmlWriter writeEntity(String name) throws IOException { closeOpeningTag(true); this.closed = false; for (int tabIndex = 0; tabIndex < stack.size() + indentingOffset; tabIndex++) this.writer.write(INDENT_STRING); this.writer.write("<"); this.writer.write(name); ...
ad19b1c0-f4f1-421b-9d41-688974d60dc4
8
public static void main(String[] args)throws Exception { clients = new ArrayList<Socket>(); sendToP1 = new ArrayList<String>(); sendToP2 = new ArrayList<String>(); // create server socket ServerSocket welcomeSocket = new ServerSocket(25000); System.out.println("The server is listening on: " + welcomeSocket)...
7adf084c-c701-402a-9160-36526e4cd2dd
5
public Behaviour jobFor(Actor actor) { if ((! structure.intact()) || (! personnel.onShift(actor))) return null ; final Choice choice = new Choice(actor) ; // // Consider upkeep, deliveries and supervision- choice.add(Deliveries.nextDeliveryFor(actor, this, services(), 10, world)) ; choice.add(n...
1a0a0724-1e78-4e95-a160-ef8f34ddea99
3
void print(Node t, int n, boolean p) { if (p) { printBegin(t, n); } else { if (n > 0) { for (int i = 0; i < n; i++) System.out.print(" "); } System.out.println("(begin "); ...
af43fd10-0ce9-4989-ab03-1a1210d0e0aa
1
double VectorNorm2(double[] v) { double sum = 0; for (int i = 0; i < v.length; i++) { sum += (v[i] * v[i]);//*v[i]; } return Math.sqrt(sum);//Math.sqrt(sum); }
e1a3b147-3b24-4068-aea6-ac7cd3a58c48
9
private void readNext() { try { String line = input.reader().readLine(); if(line != null){ Matcher matcher = headerPattern.matcher(line); if(state == HaplotypeFileLineType.HEADER && matcher.matches()){ processHeader(matcher); } else if (state != HaplotypeFileLineType.HEADER) { if(st...
50e53220-fd47-49e0-8413-f0cbaf070031
0
public void setNode(Node node) { this.node = node; }
2bda063e-2528-4d29-bdd0-4a74f2bdd4e3
7
public static void main(String[] args) throws Exception { final int BOX_SIZE = 200; final int ANIM_SCALE = 5; final int TIMEOUT = 10; final int BORDER_LINE_WIDTH = 3; final int ANIM_LINE_WIDTH = 10; final Color ANIM_COLOR = Color.RED; final Color OUTLINE_COLOR = Color.GREEN; final boolean REVERSABLE...
209e02d1-a81e-4684-b399-9d15e36107ec
4
private BufferedImage getFontImage(char ch) { // Create a temporary image to extract the character's size BufferedImage tempfontImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = (Graphics2D) tempfontImage.getGraphics(); if (antiAlias == true) { graphics.setRenderingHint(Rend...
63f4a497-8627-4a61-ab88-e33ef927f5d3
0
public JLabel getjLabelPrenom() { return jLabelPrenom; }
0d0899ca-e53e-433a-a13d-81f84392cb94
4
String nextString() throws StorageReaderException { try { String line = file.readLine(); while(isCommentString(line)) { line = file.readLine(); } if(line == null) { throw new EndOfFileException(fileName); } if(isEndOfBlock(line)) { throw new EndOfBlockException(fileName); } String ...
8a0a610b-0a05-48ae-a5e6-4f7e4af71911
6
private void placeStreets(){ for(int x=0;x<=15;x++){ for(int y=0;y<=15;y=y+3){ buildingMap[x][y].setBldgType(BType.StreetBackslash); //Place vertical streets } } for(int x=0;x<=15;x=x+3){ for(int y=0;y<=15;y++){ buildingMap[x][y].setBldgType(BType.StreetSlash); //Place horizontal streets } ...
8c0aa4ca-0074-4c60-840a-c4d8515e82d8
3
public void saveStreamVector() { String savePath = new Control_GetPath().getStreamRipStarPath(); XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); try { XMLEventWriter writer = outputFactory.createXMLEventWriter( new FileOutputStream(savePath+"/Streams.xml" ), "UTF-8"); XMLEventFactory even...
268ed891-3560-4884-9716-5a4c5b05af97
3
public void printGrid() { for (int i = 0; i < grid.length; i++) { for (int j = 0; j < grid.length; j++) { if (grid[i][j].getObject() != null) { System.out.println(grid[i][j].getObject().getStartPos() + ", " + grid[i][j].getObject().getEndPos() + ", " + grid[i][j].getObject()); } } } }
07799683-8a09-419e-ac8d-0980f0959920
7
public boolean playPause() { if (player == null) return false; Status status = player.getStatus(); if (status == Status.UNKNOWN || status == Status.HALTED) { // don't do anything in these states pending = true; return false; } if (status == Status.PAUSED || status == Status.READY || status == Sta...
aa9c8796-05c2-45e1-a840-8448cef0d9cc
2
public static ArithmeticParameter getArithmeticBySymbol(char symbol) { for (ArithmeticParameter parameter : ArithmeticParameter.values()) { if (parameter.getSymbol() == symbol) return parameter; } return null; }
9b919b78-353a-41d5-9cad-45512c6b245c
4
private Vector calcMapScreenOffset(float interpol) { Vector interpolCamPos = Vector.add(cameraPosition,Vector.scalar(interpol,cameraVelocity)); if (interpolCamPos.x < 0) interpolCamPos.x = 0; else if (interpolCamPos.x > mapDims.width - screenDims.width) interpolCamPos.x = mapDims.width - screenDims.width...
c22f3f0d-a805-4bc5-a0bf-ee250136de40
7
private void addActions() { this.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { UserInterface.AbstractInterface.Action act = null; if (square.hasMine()) act = factory.getAction("GameOver"...
b51f593f-6d50-4272-8059-74692770c137
5
@Override public void render() { this.parent.getMaterials().getMaterial(getMaterialName()).bindTexture(); for (Face f : faces) { glColor3f(1, 1, 1); if (f.is4f()) { glBegin(GL_QUADS); } else { glBegin(GL_TRIANGLES); } FaceIndex index = null; for (int i = 0; i < f.getIndecies().size(); i+...
22824048-5e48-440e-8e5c-6f37b8d2294e
4
@Override public boolean execute(final CommandSender sender, final String[] split) { if (sender instanceof Player) { if (MonsterIRC.getHandleManager().getPermissionsHandler() != null) { if (!MonsterIRC.getHandleManager().getPermissionsHandler() .hasCommand...
689dd026-d3c7-4889-b942-0bbf0ee8a54b
7
private <V, E, G extends Digraph<? extends V, ? extends E>> Map<V, Cluster<V,E,G>> createClusters( G digraph, DotProvider<V, E, G> provider, DigraphProvider<? super V, G> subgraphs) throws IOException { Map<V, Cluster<V,E,G>> clusters = new HashMap<V, Cluster<V,E,G>>(); if (subgraphs != null) { for (V v...
7b53d0f4-820b-4fc9-a236-e6da369025a1
1
public Token getToken() { if (token == null) token = new Token(); return token; }
d2763e63-3c18-42f4-b39a-fe904c8683c4
5
@Override public int[][] findMatching(DeviceGraph graph) { ObjectGraphBuilder ogb = new ObjectGraphBuilder(); HashSet<Requestor> unsortedRequestors = ogb.buildObjectGraph(graph); int requestorCount = unsortedRequestors.size(); TreeSet<Requestor> requestors = new TreeSet<Requestor>(new RequestorComparator()); ...
f34d4468-ed4c-4f7b-ac6f-747b4cfb7114
4
private boolean check3(int i, int j) { int first = getMatrix(i, j); if (first == 0 || first == -1) { return false; } int second = getMatrix(i + 1, j + 1); int third = getMatrix(i + 2, j + 2); if (first == second && first == third) { return true; } return false; }
ce9b6b66-6d09-415f-922c-74c8c7863f6f
6
public void create(Depto depto) throws PreexistingEntityException, RollbackFailureException, Exception { EntityManager em = null; try { em = getEntityManager(); em.getTransaction().begin(); Area areaareidArea = depto.getAreaareidArea(); if (areaareidArea !...
1f3e682f-29e5-47b8-b6c0-43d6d67baf1d
0
public locationGroup(String id) { super(id); }
c65e4f6b-91d2-4c83-9883-80e8a8b33757
5
private void crclRound(List<Player> plyr){ boolean found=false; boolean round=false; for (int i = 0; i < plyr.size(); i++) { if(plyr.get(i).isSmlblnd()){ found=true; if(round){ break; } round=true; System.out.println("game begine ------------"); System.out.println(found); }...
2cfbdf8e-4656-44da-baea-821ec793d841
8
public static XmlElement coerceToXmlElement(Stella_Object regiontag) { { Surrogate testValue000 = Stella_Object.safePrimaryType(regiontag); if (Surrogate.subtypeOfSymbolP(testValue000)) { { Symbol regiontag000 = ((Symbol)(regiontag)); return (Stella.makeXmlElement(regiontag000.symbolName, ...
704d75b6-d743-4e27-aac5-bb2910ae6539
1
public Coord rootpos() { if (parent == null) return (new Coord(0, 0)); return (xlate(parent.rootpos().add(c), true)); }
3c1c202a-8a96-4fcf-bc8b-d32e37c82902
3
public void calculateInertiaTensor() { if (collisionObject instanceof SphereObject) { double d = 2D / 5D * mass * ((SphereObject) collisionObject).getRadius() * ((SphereObject) collisionObject).getRadius(); setInertiaLocal(new Matrix3d(d, 0, 0, 0, d, 0, 0, 0, d)); } else if (collisionObject instance...
6ea588e4-2246-4b85-ab02-d6c73d17b4ff
4
@Override public void actionPerformed(ActionEvent e) { if (rdbtnOppilas == e.getSource()) { tfEtunimi.setVisible(true); tfSukunimi.setVisible(true); cbRyhma.setVisible(true); lblEtunimi.setVisible(true); lblSukunimi.setVisible(true); lblRyhm.setVisible(true); } else if (rdbtnYllpito == e.getSourc...
c2b82edd-7532-40c4-b6c9-157f44dfb8fb
6
private JPanel buildTimeEditPanel() { JPanel inputPanel = new JPanel(); inputPanel.setLayout(new FlowLayout()); toField = new TimeField(); fromField = new TimeField(); inputPanel.add(new JLabel("from: "),FlowLayout.LEFT); inputPanel.add(fromField, FlowLayout.CENTER); inputPanel.add(toField, Flo...
61f6e995-7e1c-4883-8660-a5d28ae4954b
4
private void writeChars0 ( int ln, String sc ) { int l = sc.length(); int ml = Math.min(ln,l); try { fidx.writeBytes( (l==ml ? sc : sc.substring(0,ml)) ); } catch (IOException e) { e.printStackTrace(); } if(ln>l) { try { fidx.write(new byte[ln-l]); } catch (IOException e) { e.printStackTrace(); } ...
fd60d8f2-8683-4e6c-a7a6-50fdf3f82f81
0
@Test public void fetchDuplicatesFromURI() throws SameAsServiceException { Equivalence equivalence = this.service .getDuplicates(URI.create("http://www.bbc.co.uk/music/artists/e9dfc148-d5f6-425e-b80b-f99ed2bd7c09")); assertNotNull(equivalence); assertEquals(9, equivalence.get...
5d929e84-ff7f-4a38-8818-9e21402ebe79
0
@Override public void documentRemoved(DocumentRepositoryEvent e) {}
421baa45-e032-4c4a-9dcb-e37e4c924593
5
private void initGraphics() { hBox = new HBox(); hBox.getStyleClass().setAll("vu-meter"); hBox.setSpacing(getSkinnable().getLedSpacing()); vBox = new VBox(); vBox.getStyleClass().setAll("vu-meter"); vBox.setSpacing(getSkinnable().g...
9e8282f9-1874-48b7-9051-0c6ef8555b9c
2
@Override protected void doWrite(byte[] data, final Runnable fn) { Request.Options opts = new Request.Options(); opts.method = "POST"; opts.data = data; Request req = this.request(opts); final PollingXHR self = this; req.on(Request.EVENT_SUCCESS, new Listener() { ...
39e86947-636f-4910-84b5-761ba2f9c0d0
6
public static BufferedImage getSubImageFromIndex(BufferedImage bi, int width, int height, int index) { if ((bi.getWidth() != 0 && bi.getHeight() != 0) && (bi.getWidth() % width != 0 || bi.getHeight() % height != 0)) { DystopiaLogger.logSevere("It looks like there was a problem retrieving a subimage. :("); Displ...
1c044445-0a61-48a7-8c40-6e1cd106551d
6
public static void main(final String... args) { final ICodeMap[] maps = { new CodeMap31(), new CodeMap3y(), new CodeMap3x(), new CodeMap3(), new CodeMap42(), new CodeMap4(), new CodeMap2(), new CodeMap8(), new CodeMapT4<Integer>(), new CodeMapArrayList(), new CodeMapArrayList(0x100), new CodeMapL<ArrayList<In...
b14ad5b3-253d-4804-bb45-9ec2c17133bf
6
public void connect(String address, int port) throws CouldNotConnectException { logger.fine("Connecting to " + address + ":" + port + "..."); boolean disconnected = false; try { synchronized(CONNECTION_LOCK) { if(isConnected) { logger.fine("Disconnecting from " + serverAddress + ":" + serverPort + " s...
a97f4561-d019-4af0-a302-dd96bf21f1c4
2
public void showMatrix() { for(int i=0; i<columns; i++) { System.out.println(); for(int j=0; j<rows; j++) { //System.out.print(matrix[i][j]+" "); } } f.add(matrix[0][0]); s.add(matrix[0][1]); }
40a1890a-cbe0-40f9-9bfc-5d94a5955079
5
public void testGetCop() throws PostServiceNotSetException { System.out.println("getCop"); try { int numberOfGenerators = 3; int numberOfLoadsForGenerator = 4; int R = 1; double xmean = 0.5; double delta = 0.1; PowerGrid instance = ...
10e6cc65-92fe-41d5-a60e-3f8c3b7268c2
5
public void remoteUpdate(String remoteListLine) { String[] splitline = remoteListLine.split(" "); if (splitline.length >= 4 && splitline[2].equals("Auction")) { /* * The client doesn't process the whole auctions list, but each line * individually and this method is called for each line. * Therefore ...
41303ee2-c840-4e24-9687-942d9de4c8b6
5
private String GetIndexableFileType(File f) { String end = f.getName().substring(f.getName().lastIndexOf('.') + 1).toLowerCase(); String fname = f.getName(); String check_ft = null; for (int i = 0; i < ProjectScanner.FILETYPE_EXTENSIONS.length; i++) { if (ProjectScanner.FILETYPE_EXTENSIONS[i].equalsIgnore...
7e8cd8cb-5e63-4f43-94f3-bac87517f0a3
4
@Override public List<Integer> generatePrimeUpTo(int boundary) { List<Integer> primeNumbers = new ArrayList<Integer>(); // only positive boundaries boundary = Math.abs(boundary); int pp = 2; primeNumbers.add(2); while (pp < boundary) { pp++; boolean test = true; for (int i : primeNum...
f23dfb53-c31e-451d-97e6-fe34722cb8ea
5
public Flower createFlower(String type, String color){ Flower flower = null; if(type.equalsIgnoreCase("rose")){ flower = new Rose(defineColor(color)); } else{ if(type.equalsIgnoreCase("tulip")){ flower = new Tulip(defineColor(color)); }...
5f840dd1-f2e3-4ea1-8c1f-f88aa1b12bb3
4
public final boolean des_is_weak_key(byte[] key) { for (int i = 0; i < weak_keys.length; i++) { int j; for(j = 0; j < DES_KEY_SZ; j++) if (weak_keys[i][j] != key[j]) break; if (j == DES_KEY_SZ) return true; } return false; }
e0a1f902-3130-4750-a6aa-11d1546fbf87
1
public PhiJoinStmt(final VarExpr target, final Block block) { super(target); this.block = block; this.operands = new HashMap(); final Iterator preds = block.graph().preds(block).iterator(); while (preds.hasNext()) { final Block pred = (Block) preds.next(); final VarExpr operand = (VarExpr) target.clo...
afe9033d-8ae8-406b-8c20-0567d7b70d27
5
public int lengthOfLastWord(String s) { int n = s.length(); if (n==0){ return 0; } int result = 0; for (int i=n-1;i>=0;i--){ if(s.charAt(i)==' '&&result!=0){ break; } else if(s.charAt(i)!=' '){ result...
08fef34d-eb9d-4592-b63f-377cf4706b45
1
public void getMin(int front, int rear){ //first time, first and last compare if(arr[front] < arr[rear]){ System.out.println("min: "+arr[front]); }else { //it is rotated getMinRecur(front,rear); } }
64d1e3bc-ad9f-4f86-b5f9-c7852af53119
5
@Override protected void channelReadHttpObject(ChannelHandlerContext ctx, HttpObject msg) { switch (currentState) { case INITIAL: readInitialRequest((HttpRequest)msg); break; case WAITING_OUTBOUND_CONNECTION: case WAITING_ESTEBLISHED_RESPON...
7333ed33-cd0a-4c6f-869a-85f177c541b9
4
public void sendMessage(IActor from, String to, TupleExpression msg) throws CruiseRuntimeException { IActor target = null; if (to.equals("^Self")) { target = from; } else { if (actors.containsKey(to)) { target = actors.get(to); } else { throw new CruiseRuntimeExce...
159ba51b-5496-4176-9304-d7559ea7c603
3
public static void main(String[] args) throws IOException{ ServerSocket readerSocket = new ServerSocket(portno); while(true){ System.out.println("server"); Socket clientSocket = readerSocket.accept(); if(clientNum<5){ clientNum++; new ClientHandler1(clientSocket).start(); //client handler ...
6dfd1096-2b30-45c1-8ef5-548687634784
3
public void InicializaVerticesDoColider() { Colider colider = this.getColider(); getColider().setQuantDePontos(17); for (int i = 0; i < colider.pontos.length; i++) { colider.pontos[i] = new Point(); } colider.pontos[0].x = pos.x + 45; colider.pontos[0].y = pos...
e404df0a-c325-46ce-9f05-b492764e0658
8
@Override protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { DatabaseManager manager=DatabaseManager.getManager(); try { People people = manager.getPeopleDao().queryForId( Integer.parseInt(request.getParameter(ID))); if(people==null){ ...
37e6e21a-f9cc-4317-b3a1-ae992a1ca911
7
public CronDefinition(String definition) throws IllegalArgumentException { // Überflüssige Leerzeichen entfernen definition = definition.replaceAll("\\s*,\\s*", ","); definition = definition.replaceAll("\\s*/\\s*", "/"); definition = definition.replaceAll("\\s*-\\s*", "-"); // In 5 Teile Auftrennen _segmen...
96e097d0-3d71-4d3b-97f9-96cb243d21e9
5
public void tooManyOrTooLittleNeighbours(CellStructure cell) { if (cell.isStateAlive()) { int aliveNeighbours = 0; for (int i = 0; i < cell.getCellNeighbours().size(); i++) { if (cell.getCellNeighbours().get(i).isStateAlive()) { aliveNeighbours++; } } if (aliveNeighbours > 3 || aliveNeig...
db9faed6-0073-433a-8bdd-deffe508868e
6
public static void createConfigXML(String path){ configXML = path; String xml = "<?xml version=\"1.0\"?>\n"; xml+= "<task>"; if(indentation){ xml+="\n"; } for(int i =0; i<inputFiles.size(); i++){ if(indentation){ xml+=" ...
8c7abcb6-ff58-4786-a50e-e7def3fcc199
5
private void init() { JPanel content = new JPanel(); content.setLayout(new BorderLayout()); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BorderLayout()); JPanel spacerPanel = new JPanel(); spacerPanel.setLayout(new GridLayout()); if (m_allowAdd) { JButton addButton = n...
f890e3cf-2647-4612-a26c-bd716a1f984a
1
@Override public void addNotify() { super.addNotify(); if (thread == null) { thread = new Thread(this); addKeyListener(this); thread.start(); } }
9fd0fd72-f063-482c-a321-1197281e7f0c
7
public BookVO getBookByUniqueId(BookVO requestbookVO) throws LibraryManagementException { PreparedStatement preparedStatement = null; ResultSet resultSet = null; ConnectionFactory connectionFactory = new ConnectionFactory(); BookVO bookVO = null; String sqlQuery = "select * from BOOK"; if (requestbookVO....
e5398531-2c59-46d1-bf57-6e584854f815
4
public synchronized int deregisterKey(final String base64PublicKey) throws NoSuchUserException { if( peers.remove(new KeyRegistrationRecord(base64PublicKey)) == false ) { throw new NoSuchUserException(base64PublicKey); } if( key_to_record.remove(base64PublicKey) == null ) { logger.warning("Inconsisten...
4a212bf9-329c-4d2e-92af-d34ca384ba88
0
public int getMaxEvaluation(){ return maxEvaluation; }
b65b22dc-bc45-4570-b2fc-51f7c8786706
0
public String getMessage() { return message; }
eb8d2b67-c237-43ce-85d9-bee2e73b7b9c
3
private void sendPacket(final Channel channel, ByteBuf packet) { channel.writeAndFlush(packet).addListener(new GenericFutureListener<Future<? super Void>>() { @Override public void operationComplete(Future<? super Void> future) throws Exception { if (future.cause() != nul...
f63f1e86-6ed7-421d-822e-9c14ef6a2a11
4
private TreeNode rotateRight(TreeNode rotatingNode) { TreeNode rotatedTreeRootNode = rotatingNode.left; rotatedTreeRootNode.parent = rotatingNode.parent; rotatingNode.left = rotatedTreeRootNode.right; if (rotatingNode.left != null) { rotatingNode.left.parent = rotatingNode; } rotatedTreeRootNode.righ...
15c01326-a775-4ce9-8009-384bf7a32d67
7
private void animationLoop() { while (Thread.currentThread() == animationThread) { try { double frameStartTime = System.nanoTime(); animateNextFrame(); double currentFrameTime = System.nanoTime() - frameStartTime; int timeToNextFrame = (int) ((timePerFrame - currentFrameTime) / 1000000); if (ti...
e16c5f76-a134-4bd0-9496-97a9c6310ab0
4
public boolean equals(DescrittoreMossa ds){ boolean res = vmaxEF == ds.getVmaxEnemyForest() && ndmaxEF == ds.getNdmaxEnemyForest(); res = res && vittoria == ds.isWinner() && evolvi == ds.isChangedToDama() && avvicinando == ds.getAvvicinando(); return res; }
578952c3-552a-414b-81d7-600cc4109dd9
0
public boolean isDone() { return done; }
16afbe4d-1856-4e40-9c16-92ea8e97666c
6
private static String calculateRelativePath(Vector<String> homeList, Vector<String> unknownList) { // Step 1: Walk the ends of the lists to find the common root between the two lists // Step 2: Walk what remains of the homeList do determine how much to add backwards traversals (ie: ../ ) // Ste...
eb0d724e-091a-4a6b-8ac3-f3ccd73b2ab1
5
private static List<String> readFile(File f) { List<String> list = new ArrayList<String>(); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(f)); String text = null; while ((text = reader.readLine()) != null) { list.add(text); } } catch (FileNotFoundException e) {...
04545ee9-29a1-4b87-9fb8-3ace38619f33
7
private boolean isContentValid(String content) { if (content.equals(WumpusConsts.ACTION_DEREGISTER) || content.equals(WumpusConsts.ACTION_REGISTER) || content.equals(WumpusConsts.ACTION_GRAB) || content.equals(WumpusConsts.ACTION_MOVE) || content.equals(WumpusConsts.ACTION_SHOOT) || content.eq...
1e0679b5-53f3-45b4-a5a4-29d24f1ef5c8
0
public boolean isUnanimous() { return results.size()==1; }
23500c4f-19b1-4483-982d-d9fc90c05f95
7
private double[][] computePredictions(int index_to_change, boolean add) { double[][] predictions = new double[m_models[0].length][m_models[0][0].length]; for (int i = 0; i < m_bagSize; ++i) { if (m_timesChosen[i] > 0) { for (int j = 0; j < m_models[0].length; ++j) { for (int k = 0; k < m_models[0][j]....
af7cc29d-7b47-4902-a206-ca71e6c4895b
3
public boolean findMe(String str) { if(str.equalsIgnoreCase(name) || str.equalsIgnoreCase(surname) || str.equalsIgnoreCase(phoneNumber)) return true; else return false; }
d96c647a-0e76-476a-b3b4-e1678eae3699
1
public static void main(String[] args) { Bank b = new Bank(NACCOUNTS, INITIAL_BALANCE); int i; for (i = 0; i < NACCOUNTS; i++) { TransferRunnable r = new TransferRunnable(b, i, INITIAL_BALANCE); Thread t = new Thread(r); t.start(); } }
bb00a4b4-33b2-4c5f-b4df-f3778194d3e8
0
public int getSuppliercode() { return this.suppliercode; }
16c8fc02-b390-4ba9-a04c-21b6229d553f
1
@Test public void distanceTest() { Point p1 = new Point(0,0); Point p2 = new Point(3, 4); Point p3 = new Point(-3, -4); assertEquals(5, p1.distance(p2), PRECISION); assertEquals(5, p2.distance(p1), PRECISION); assertEquals(5, p1.distance(p3), PRECISION); assertEquals(5, p3.distance(p1), PRECISION); ...
673ee2a4-6373-4a48-9e31-d52cabf8bd2c
3
public static Vector max(Vector a, Vector b){ return new Vector((a.getX() > b.getX() ? a.getX() : b.getX()), (a.getY() > b.getY() ? a.getY() : b.getY()), (a.getZ() > b.getZ() ? a.getZ() : b.getZ())); }
71a2eab1-55e4-48cc-8b5e-a76c5b74e73a
2
@Override public void Actualizar(Object value) { Session session = null; try { Ejecutivo ejecutivo = (Ejecutivo) value; session = NewHibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); session.update(ejecutivo); ...
c2270e58-2bd7-4317-be3c-c7de1301e7e0
8
@Override public int hashCode(){ int res=0; if(n==2){ for(int i=0;i<valeurs.length;i++){for(int j=0;j<valeurs[0].length;j++){if(valeurs[i][j]){res = (2*res)+1;} else {res = 2*res ;}}} return res;//max 65536 } else{//plus que 0(1)? res = (hautGauche.adress() + hautDroit.adress()+basDroit.adress()+basGa...
5cc5cf63-4903-403f-a97b-cd0e0fe19fd0
2
public boolean forward() { Integer opcode = this.getOpcodeValue(); //Get opcode value from superclass to pass to queue try { getPC().incrementPC();//For testing, as wait() statements are removed, this needs to be placed after queue.put() //in order to prevent missing branch targets. this.fireUpdate("...
abd409f0-b939-4ba1-8cbd-2cfa446a4207
3
public static void literals(EntityManager manager) { System.out.println("THE WHERE CLAUSE AND LITERALS"); System.out.println("--------------------------------"); System.out.println("SELECT c FROM Customer AS c"); System.out.println("WHERE c.creditCard.creditCompany.name = 'Capital One'"); ...
38fd5cca-fc59-4618-b1ea-dbd5f3f5f4bc
9
@Override public Location find(String query) throws DataDefinitionException { String path = query; String nepticalProtocol = "neptical://"; NSpace currentSpace = rootLocation; DataModule parentModule = null; boolean changeNSpace = StringUtils.startsWith(path, nepticalProtocol) && !StringUtils.startsWit...
848e3069-8657-47a7-8baf-d7f00d5a76b0
1
public BTPosition<T> insertRight(Position<T> p, T ele) throws InvalidPositionException { BTPosition<T> rp = checkPosition(p); Position<T> rightP = rp.getRight(); if (rightP != null) throw new InvalidPositionException("Node already has a right child"); BTPosition<T> newNode = new BinaryTreeNode<T>(ele, nul...
840fd522-dafc-403c-93ac-77e4ee42cc38
8
public final String toString() { StringBuffer text = new StringBuffer(); text.append(ARFF_ATTRIBUTE).append(" ").append(Utils.quote(m_Name)).append(" "); switch (m_Type) { case NOMINAL: text.append('{'); Enumeration enu = enumerateValues(); while (enu.hasMoreElements()) { te...
9231b902-a608-452f-9ff8-8d15f593e2b9
7
@Override public Shape paintLayer(Graphics g, int p0, int p1, Shape viewBounds, JTextComponent c, View view) { g.setColor(getColor()); p0++; // Workaround for Java Highlight issues. // This special case isn't needed for most standard Swing Views (which // always return a width of 1 for modelToView() ...
7b4697c8-881d-4ff9-859f-d1aa766b06ec
1
public void paint(Graphics g, JComponent c) { Dimension size = c.getSize(); if (textArea == null) return; textArea.setBackground(c.getBackground()); rendererPane.paintComponent(g, textArea, c, 1, 1, size.width - 1, size.height - 1, true); }
3ab35040-da27-4585-855b-0421bff41c29
5
public int maxProduct(int[] A) { if(A==null || A.length==0) return 0; if(A.length==1) return A[0]; int max=A[0]; int[] endMax=new int[A.length]; int[] endMin=new int[A.length]; endMax[0]=A[0]; endMin[0]=A[0]; for(int i=1;i<A.length;i++){ ...
41122d76-a5c1-4b10-9383-d27427564a11
1
public void load() throws IOException { URL url2 = new URL(url); int begin = url.lastIndexOf("/"); if (begin == -1) { System.out.println("index of url = -1"); return; } String name = url.substring(begin + 1, url.length()); Path path = Paths.get("im...
7ef07c7f-7e48-43f2-ac0e-e191c14932f8
9
public static int from(String roman) throws ParseException { if (!RomanNumeral.properlyFormatted(roman)) throw new ParseException( new Diagnosis().append("diagnosis.roman-numeral-from-invalid-value", roman), ParseException.ParseType.GENERIC ); ...
b436177b-8541-4b00-b996-3626156534a0
7
public ListNode removeNthFromEnd(ListNode head, int n) { List<ListNode> lns = new ArrayList<ListNode>(); ListNode node = head; while(lns.add(node)&&node.next!=null){ node=node.next; } int size = lns.size(); if(n==0||n>size){ return lns.get(0); }else if(n!=0&&n<size){ ListNode removeNode = lns.ge...
fc455a56-8384-4c88-9a09-5eecb2f9a1fb
1
public static final String chompLastSegment(String path){ path = clean(path); if(path == EMPTY_STRING){ return path; } String lastSegment = lastSegment(path); path = path.substring(0, path.length() - lastSegment.length()); return clean(path); }
2644d617-3cae-4bc8-8630-220274aa1e68
4
public static void main(String[] args) { try { if (args.length < 6) { System.out.println("parameters error!"); showHelp(); System.exit(0); } else { txtPath = args[1]; xmlPath = args[2]; StanfordInputpath = args[3]; metamapPath = args[4]; outputPath = args[5]; } if(args[...
94dd37e9-fc4e-411c-bce5-6dc4f0185b66
1
private static float doFloat(String value) { try { return Float.parseFloat(value); } catch (Exception e) { return Float.NaN; } }
49a14c82-4ed5-4c69-a3d5-4902eafca297
2
public void newZombie() { basicZombieList.add(new BasicZombie(start, this, player)); if (new Random().nextFloat() > 0.8f) { for (int i = 0; i < 10; i++) { basicZombieList.add(new BasicZombie(start, this, player)); } } }
63bfa311-867f-4008-97f1-9a9fb0492249
6
public static String longestSubstringUnrepeatedChar(String inputString) { StringBuilder longestSoFar = new StringBuilder(); String longestSubstringResult = ""; if (inputString.isEmpty()) { return ""; } else if (inputString.length() == 1) { return inputString; } Map<String, Integer> map = new HashMa...
797d77e4-5cf6-41a3-ae57-afdc0306ce07
4
public static int[] bubbleSort(int[] a) { int tmp; boolean switched; for (int j=1; j <= a.length; j++) { switched = false; for (int i=0; i<a.length-j; i++) { if (a[i] > a[i+1]) { tmp = a[i]; a[i] = a[i+1]; a[i+1] = tmp; switched = true; } } if (!switched) { break; } ...
6a66b864-4ca3-4016-ad64-6543fe9a706b
4
public void updateStudent(Student student) throws InstanceNotFoundException { boolean found = false; Iterator<Student> iter; iter = students.iterator(); while (iter.hasNext() && !found) { Student s = iter.next(); if (s.equals(student)) { found = true; s.setHouseHold(student.getHouseHold()); s....