text
stringlengths
14
410k
label
int32
0
9
void generateRandomDistributions(int nNodes, int nValues) { // Reserve space for CPTs int nMaxParentCardinality = 1; for (int iAttribute = 0; iAttribute < nNodes; iAttribute++) { if (m_ParentSets[iAttribute].getCardinalityOfParents() > nMaxParentCardinality) { nMaxParentCardinal...
9
public boolean commitCustomers(Connection conn) throws SQLException { boolean status = true; try { // Start of system transaction conn.setAutoCommit(false); BookingMapper bm = new BookingMapper(); status = status && bm.addNewCustomer(newCustomers, conn); ...
3
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; RubiksCube other = (RubiksCube) obj; if (config == null) { if (other.config != null) return false; } else if (!config.equals(other.confi...
7
public ConfigurationSection save(ConfigurationSection c){ for(Field f:this.getClass().getFields()){ if(f.isAnnotationPresent(config.class)){ try{ if(f.get(this) instanceof Location){ c.set(f.getName() + ".world", ((Location)f.get(this)).getWorld().getName()); c.set(f.getName() + ".x", (...
7
private void renderKingPile(Graphics2D g) { double x = X_BOARD_OFFSET + CARD_WIDTH + CARD_X_GAP; double y = Y_BOARD_OFFSET; g.setColor(Color.white); g.drawString("King Down", (int) x, (int) y - 1); for (List<Card> kingPile : game.getKingPiles()) { if (kingPile.size()...
2
private static void generate() { for (int i = 0; i < ROW; i++) Arrays.fill(C[i], -1); for (int i = 0; i < MAX; i++) BEST[i] = i; for (int i = 1; i < COLUMN; i++) C[0][i] = 1; for (int i = 1; i < ROW; i++) C[i][0] = 1; ...
9
@Override public TextureRegion getFrame(float stateTime) { wait--; if (x > 800) x-=1; if (dying > 0) { dying--; if (dying == 0) { this.x = 1100; this.y = 240; } return treeDie.getKeyFrames()[dying / 24]; } if (firing > 0 && x<=800) { rooting = 0; firing--; if (firing ...
9
public static void makeTreeDirected(mxAnalysisGraph aGraph, Object startVertex) throws StructuralException { if (isTree(aGraph)) { mxGraphProperties.setDirected(aGraph.getProperties(), false); final ArrayList<Object> bFSList = new ArrayList<Object>(); mxGraph graph = aGraph.getGraph(); final mxIGraphMo...
4
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Coordinate other = (Coordinate) obj; if (coordX != other.coordX) return false; if (coordY != other.coordY) return false; return true; ...
5
public void start() { System.out.println("Timer is restarting ..."); startTime = System.currentTimeMillis(); }
0
public int Run(RenderWindow App){ boolean Running = true; Text scenario = new Text(); Font Font = new Font(); try { Font.loadFromFile(Paths.get("rsc/font/mrsmonsterrotal.ttf")); } catch (IOException e) { e.printStackTrace(); return (-1); ...
7
public CommandCwformat(CreeperWarningMain plugin) { this.plugin = plugin; }
0
public static String GetLoLFolder() { File file = null; String path = null; try { JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setDialogTitle("Please set your Location of \"lol.launcher.exe\""); cho...
4
private void copyRGBtoBGRA(ByteBuffer buffer, byte[] curLine) { if (transPixel != null) { byte tr = transPixel[1]; byte tg = transPixel[3]; byte tb = transPixel[5]; for (int i = 1, n = curLine.length; i < n; i += 3) { byte r = curLine[i]; ...
6
public void initMethod(State state) { try { Method[] mets = mod.getClass().getMethods(); for (Method met : mets) { if (met.isAnnotationPresent(Initialization.class) && met.getAnnotation(Initialization.class).value() == state) { met.invoke(mod); } } } catch (IllegalAccessException |...
4
public Dictionary parseDictionaryFromFile(File file) throws FileNotFoundException, IOException { Dictionary lexicon = new Dictionary(); int linenum = 0; if (file.getName().endsWith("txt")) { String filename = file.getPath(); lexicon.setFile(file); Logger.get...
6
public void removeFromParent() { if (mParent != null) { mParent.removeChild(this); } }
1
public void GiveExperience(int ammount, Room Room, RoomUser PetUser) { Experience += ammount; ServerMessage Message = new ServerMessage(); Room.Environment.InitPacket(609, Message); Room.Environment.Append(Id, Message); Room.Environment.Append(PetUser.VirtualId, Message); ...
6
@CLNames(names = { "-abcstat", "-STAT" }) @CLDescription("Old way of adding stats. Deprecated") public void addStat(String[] statAndConfig) { String statName = statAndConfig[0]; // turn this into a class in 2 ways. if it contains no . try using this // package as a prefix Class type = null; try { String ...
9
private void initializeSlaveMapping() throws BookStoreException { Properties props = new Properties(); slaveServers = new HashSet<String>(); try { props.load(new FileInputStream(filePath)); } catch (IOException ex) { throw new BookStoreException(ex); } String slaveAddresses = props.getProperty(BookS...
4
public static TicketingFacilityEnumeration fromValue(String v) { for (TicketingFacilityEnumeration c: TicketingFacilityEnumeration.values()) { if (c.value.equals(v)) { return c; } } throw new IllegalArgumentException(v); }
2
public ContactIterable(Iterable<T> s1, Iterable<T> s2) { this._s1 = s1; this._s2 = s2; }
0
void headerOnPaint (Event event) { CTableColumn[] orderedColumns = getOrderedColumns (); int numColumns = orderedColumns.length; GC gc = event.gc; Rectangle clipping = gc.getClipping (); int startColumn = -1, endColumn = -1; if (numColumns > 0) { startColumn = computeColumnIntersect (clipping.x, 0); if (start...
6
@Override public GameState choose(Player player, GameState[] states, Card card) { for(GameState s : states) { s = findSetToTrue(s,card); } //If there's only one choice, we have no choice but to do it if(states.length == 1) { return states[0]; } int alpha = Integer.MIN_VALUE; int beta =...
4
public void insertNewFact(String name, String text) { PreparedStatement ps = null; try{ stat.setQueryTimeout(30); ResultSet rs = stat.executeQuery("Select * from Fact " + "where Name = '"+name+"' OR Text ='"+text+"'"); if(!rs.isBeforeFirst()) ...
3
public static boolean validPalindrome(String s) { if(s == null) { return false; } int left = 0; int right = s.length()-1; while(left < right) { while(left < right && !Character.isLetterOrDigit(left)){ left ++; } w...
8
public long getLong(int index) throws JSONException { Object object = this.get(index); try { return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object); } catch (Exception e) { throw new JSONException("JSONArray["...
2
public Component getTableCellRendererComponent (JTable table, Object value, boolean selected, boolean focused, int row, int column) { super.getTableCellRendererComponent(table, value, selected, focused, row, column); if (column == 0 || column == 6) { //Weekend rende...
6
public int getPacketTime() { return lastPacketTime; }
0
private void loop(Scanner sc, Server server, ServerNetworkListener listener) { String line = sc.nextLine(); if(line.startsWith("/")) { String command = line.substring(1); if(command.equals("stop")) { running = false; server....
9
public Element generateElement(Document document) { Element key = document.createElement(mxGraphMlConstants.KEY); if (!keyName.equals("")) { key.setAttribute(mxGraphMlConstants.KEY_NAME, keyName); } key.setAttribute(mxGraphMlConstants.ID, keyId); if (!keyName.equals("")) { key.setAttribute(mx...
4
public void deposit(BigInteger amount) throws IllegalArgumentException { if ( (amount == null) || (amount.compareTo(BigInteger.ZERO) <= 0) ) throw new IllegalArgumentException(); setBalance(this.getBalance().add(amount)); }
2
private MouseListener mouseListener(){ return new MouseAdapter() { @Override public void mousePressed( MouseEvent e ) { closeMenu(); if( e.isPopupTrigger() ){ popup( e.getX(), e.getY(), e.getComponent() ); } } @Override public void mouseReleased( MouseEvent e ) { if( e.isPopupT...
2
private void checkValuePlacement( String text ) throws RrdException { Matcher m = VALUE_PATTERN.matcher(text); if ( m.find() ) { normalScale = (text.indexOf(SCALE_MARKER) >= 0); uniformScale = (text.indexOf(UNIFORM_SCALE_MARKER) >= 0); if ( normalScale && uniformScale ) throw new RrdException( "C...
5
public void paint(Graphics g) { if (handles != null && isHandlesVisible()) { for (int i = 0; i < handles.length; i++) { if (isHandleVisible(i) && g.hitClip(handles[i].x, handles[i].y, handles[i].width, handles[i].height)) { g.setColor(getHandleFillColor(i)); g.fillRect(handles...
5
@Override public String getName() { return NAME; }
0
private boolean canShootMoreTargets() { if (attackData.getEnemiesTowerCanShootAtTheSameFrame() > attackData.getEnemiesTowerHasShoot()) { return true; } return false; }
1
public void buttonPress(int function) { if(function == 1) { new EventGUI(myDay,combo.getSelectedIndex(),gui); gui.reformat(); this.hide(); } if(function == 2) { if(myDay.getEvents().size() != 0) myDay.getEvents().remove(0); gui.reformat(); this.hide(); } if(function == 3) { gui....
5
@Override public ArrayList<String> getAllCategories() { ArrayList<String> categories = new ArrayList<String>(); TypedQuery<Category> categoryQuery = emgr.createNamedQuery("Category.findAll", Category.class); List<Category> categoriesList = (List<Category>) categoryQuery .getResultList(); for (int i = 0;...
1
public void attachHost(GridSimCore entity, PacketScheduler sched) { String msg = super.get_name() + ".attachHost(): Error - "; if (entity == null) { System.out.println(msg + "the entity is null."); return; } if (sched == null) { Sy...
4
public static Vector3 getVec3fromYamlObject(Object yamlObject) { if (!(yamlObject instanceof List)) throw new RuntimeException("yamlObject not a List"); List<?> yamlList = (List<?>)yamlObject; return new Vector3( Float.valueOf(yamlList.get(0).toString()), Float.valueOf(yamlList.get(1).toString()), ...
3
public void event (ZoneEvent event) { switch (event.getType()) { case MOTION: env.getNotifyService().sendMotion(name); action(event); possibleAlarm(event); break; case OPENED: env.getNotifyService().sendDoorOpen(name); action(event); ...
9
public void setSelectionCrossoverOp(String selectedSelectionCrossoverOp) { try { Class crossoverClass = Class.forName(selectedSelectionCrossoverOp); selectionCrossoverOp = (Selection) crossoverClass.newInstance(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e...
3
public static byte[] toByteSequence(String data) throws Exception{ /* Counter for making sequence. */ int j=-1; /* Size of the byte array. */ int byteArrSize = data.length()/8; /* Checks if the byte array size is adequate. */ if (data.length()%8 != 0) byteArrSize++; ...
5
public HaxagonUI() { Toolkit toolkit = Toolkit.getDefaultToolkit(); Point hotSpot = new Point(0,0); Image cus = toolkit.getImage(getClass().getResource("Pic/iconse.png")); //Image curs = toolkit.getImage(getClass().getResource("Pic/Wand.png")); //Cursor oriCursor = toolkit.createCustomCursor(curs, hotSpot, "...
2
public static void playGame() { for (Player p : playerList) { int bet; System.out.printf("%s, you have $%.2f in your wallet.\n", p.getName(), p.getWallet()); System.out.print("How much do you want to bet? "); do { try { bet = scan.nextInt(); } catch(InputMismatchException e) { be...
8
private static String escapeJSON(String text) { StringBuilder builder = new StringBuilder(); builder.append('"'); for (int index = 0; index < text.length(); index++) { char chr = text.charAt(index); switch (chr) { case '"': case '\\': ...
8
public void select() { listButtons(true); }
0
private String getLabel(Instrument instrument, Calendar calendar) { String label = instrument.name(); label = label.substring(0, 3) + label.substring(3, 6); label = label + "_" + df.format(calendar.getTime()); return label; }
0
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Person person = (Person) o; if (favouriteNumber != null ? !favouriteNumber.equals(person.favouriteNumber) : person.favouriteNumber != null) ...
9
public Page getPage(TreePath path) { Object[] way = path.getPath(); PageInfo page = (PageInfo)way[0]; for (int i = 1; i < path.getPathCount(); i++) { boolean found = false; for (PageInfo p : page.getSubPages()) { if (way[i] == p) { page...
4
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException { boolean isValueNumeric = false; try { if (value.equals("0") || !value.endsWith("0")) { Double.parseDouble(value); isValueNumeric = true; ...
5
public void copyPicture(final SimplePicture sourcePicture) { Pixel sourcePixel = null; Pixel targetPixel = null; // loop through the columns for (int sourceX = 0, targetX = 0; (sourceX < sourcePicture.getWidth()) && (targetX < this.getWidth()); sourceX++, targetX++) { // loop through the rows for (in...
4
public static void dijkstra(int start) { int[] distances=new int[p]; boolean[] visited=new boolean[p]; Comparator<vertexButter> vComp = new VertexButterComparator(); PriorityQueue<vertexButter> queue = new PriorityQueue<vertexButter>(p, vComp); for(int i=0; i<p; i++) { if(i!=startp[start]) { distances[...
8
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Exit other = (Exit) obj; if (!Objects.equals(this.name, other.name)) { return false; ...
5
public boolean equals(Object configuration) { if (configuration == this) return true; try { if (!super.equals(configuration)) return false; Tape[] tapes = ((TMConfiguration) configuration).myTapes; if (tapes.length != myTapes.length) return false; for (int i = 0; i < tapes.length; i++) if...
6
public PreparedStatement build(Connection connection) throws SQLException { if (this.sqlCache == null) { this.sqlCache = builder.toString(); } PreparedStatement preparedStatement = connection.prepareStatement(sqlCache); for(int i = 0; i != parameters.size(); ++i) { preparedStatement.setObject(i + 1,...
2
public Case(int a, int x, int y){ setSize("54px", "54px"); if (a == 1) { setStyleName("caseSol"); } else if (a == 2) { add(new SiegeButton("images/siege2.png",x,y,false)); } else if (a == 3) { add(new DecoButton("/images/table2.png")); } else if (a == 4) { add(new CafeButton()); } else if (a == 5...
8
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(); ...
9
public static byte[] executeFunction(byte[] block, byte[] subkey) throws IllegalArgumentException { if (block.length != 4) throw new IllegalArgumentException("Block should be 4 bytes long."); else if (subkey.length != 6) throw new IllegalArgumentException("Key should be 6 bytes l...
2
public int lookup(PageId pageNo) { // Instantiate a new entry BufHTEntry entry; int index; // If the page does not exist return an INVALID_PAGE if (pageNo.pid == INVALID_PAGE) return INVALID_PAGE; // Determine which bucket in Page Table array that the pageNo would be in index = hash...
3
public boolean hasRoute(Node to) { if (dij != null) { return dij.hasPathTo(to); } return false; }
1
private Content retrieveInheritedDocumentation(TagletWriter writer, ProgramElementDoc ped, Tag holderTag, boolean isFirstSentence) { Content replacement = writer.getOutputInstance(); Configuration configuration = writer.configuration(); Taglet inheritableTaglet = holderTag == null ?...
7
public Wall(int x,int y) { super(x,y); URL loc = this.getClass().getResource("/karel/themes/LTTPWall.png"); ImageIcon iia = new ImageIcon(loc); image = iia.getImage(); this.setImage(image); }
0
@Override public void deleteAndCopyHistory(MediaUrlModel mediaUrlModel) { try { String query = "INSERT INTO " + TABLE_HISTORY_NAME; query += " (original_id, url,search_word,twitter_user_name, created_at,updated_at) VALUES (?,?,?,?,?,?) "; PreparedStatement stmt = con.prepareStatement(query); stmt.setI...
1
public PlatformCompatibility() {}
0
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(args.length == 0) { return noArgs(sender, command, label); } else { final String subcmd = args[0].toLowerCase(); // Check known handlers first and pass to them f...
4
public static void main(String [] args){ boolean found=false; int [] values={1,5,11,25,9,3}; Arrays.sort(values); int low=0; int high=values.length-1; int pos=0; int searchedNumber=11; while(low<=high&&!found){ pos=(low + high)/2; ...
5
public void supprimer(int debut, int fin) { if (debut == fin && debut > 0) { contenu.deleteCharAt(debut - 1); position = debut - 1; } else if (debut == fin) { if (debut > 0) { contenu.deleteCharAt(debut); position = debut; }...
6
private void processMessage(String message) { if (message.equals(TOOLKIT_SETTINGS_REQUEST)) { sendToolkitSettings(); } else if (message.startsWith("<toolkit")) { processToolkitSettings(message); } else if (remoteToolkitSettings == null) { sendCommand(TOOLKIT_SETTINGS_REQUEST); } else if (m...
8
@Test public void WhenStaticUnionCollections_ExpectResultUnion() throws UnknownHostException { ArrayList<Host> list0 = new ArrayList<Host>(1); Host host0 = new PGridHost("127.0.0.1", 3333); list0.add(host0); ArrayList<Host> list1 = new ArrayList<Host>(1); Host ho...
1
@Override public void onDisable() { }
0
public int size() { return myCards.size(); }
0
public static boolean isObjectIdValid(String s) { if (s == null) return false; final int len = s.length(); if (len != 24) return false; for (int i = 0; i < len; i++) { char c = s.charAt(i); if (c >= '0' && c <= '9') continue; if (c >= 'a' && c <= 'f') continue; if (c >= 'A' && c <= '...
9
public Map<String, String> downloadTaskContext(TaskAttribute attribute) throws TaskContextDownloadException { // filepath, submitter Map<String, String> taskContextMap = new HashMap<>(); // check if the directory to download all task contexts is existing File f = new File("MylynContexts"); if (!f.exists(...
9
@AfterClass public static void tearDownClass() { }
0
private void setLeaf() throws Exception { //this will fill the ranges array with the number of times //each class type occurs for the instances. //System.out.println("ihere"); if (m_training != null ) { if (m_training.classAttribute().isNominal()) { FastVector tmp; //System.out.pri...
8
public TD01Knapsack(int capacity, int w[], int v[]) { int n = w.length; // capacity ranges from 0 to 'capacity' vKnapsack = new int[capacity + 1]; contentsKnapsack = new String[capacity + 1]; for (int i = 0; i <= capacity; i++) { vKnapsack[i] = Integer.MIN_VALUE; contentsKnapsack[i] = ""; } vKna...
2
void calculateShipPosition(){ this.shipCoordinates[0][0] = this.shipPosition_x; this.shipCoordinates[0][1] = this.shipPosition_y; /*For vertical ships*/ if(this.shipOrientation == 'v' || this.shipOrientation == 'V'){ for(byte x = 1; x < this.shipSize; x++){ this.shipCoordinates[x][0] = this.shipPosition...
4
private void interpolatePrecisely(int iLower, int iUpper) { int dx = (int) Math.floor(txRaster[iUpper]) - (int) Math.floor(txRaster[iLower]); if (dx < 0) dx = -dx; float dy = (int) Math.floor(tyRaster[iUpper]) - (int) Math.floor(tyRaster[iLower]); if (dy < 0) dy = -dy; if ((dx + dy) <= 1) return; f...
8
private void jButtonDetailsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDetailsActionPerformed ctrlCR.DetailsPraticien(); }//GEN-LAST:event_jButtonDetailsActionPerformed
0
public JLabel getjLabelAdresse() { return jLabelAdresse; }
0
public int maxSubArray(int[] A) {// O(n) space if (A == null) return 0; int[] buffer = new int[A.length]; buffer[0] = A[0]; int max = buffer[0]; for (int i = 1; i < A.length; i++) { buffer[i] = Math.max(A[i], buffer[i - 1] + A[i]); max = Math.max(buffer[i], max); // keep track of the largest sum ...
2
private void jLabel3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel3MouseClicked jTextPane1.insertIcon(new ImageIcon(getClass().getResource("/picture/2.jpg"))); pos.add(jTextPane1.getText().toString().length()-1); pic.add("}"); }//GEN-LAST:event_jLabel3MouseClick...
0
@Override public void process(SimEvent event) { NodeReachedEvent _event = (NodeReachedEvent) event; this.setPosition(_event.getPosition()); //Sets the actual position to the one provided by the event. System.out.println(getName() + "@" + getEngine().getCurrentTime() + ": reached node (" + getPosition().getX() + ...
9
public boolean updatePosition(float pf_width, float pf_height, Player player, Vector<Brick> bricks, Vector<BrickConfiguration> brickConfigurations, BreakoutCanvas canvas) { /*Update the shot's position*/ x += xVel;//(speed * xDir); y += yVel;//(speed * yDir); int score_sum = 0; boolean bricksStillInPlay = ...
4
public int maxProfit(int[] prices) { int[] A = prices; if (A.length < 2) return 0; int max = 0; for (int i = 1; i < A.length; i++) { int diff = A[i] - A[i - 1]; max = diff > 0 ? max + diff : max; } return max; }
3
public List findByRecordCode(Object recordCode) { return findByProperty(RECORD_CODE, recordCode); }
0
public void increment() { System.out.println("Other increment operation"); }
0
public static String generateTripKML(LinkedList<Trip> trips) { String output; output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n" + " <Document>\n" + " <name>Paths</name>\n" + " <Style id=\"testStyle\">\n" + " <LineStyle>\n" + " ...
6
public String getSource() { return this.source; }
0
private void clearPosition() { StreamsterApiInterfaceProxy proxy = new StreamsterApiInterfaceProxy(); Position[] positions = new Position[0]; try { positions = proxy.getPositions(); } catch (RemoteException ex) { Logger.getLogger(JobTradeUpGBPJPY.class.getName())....
4
public boolean getHasVisited() { return hasVisited; }
0
public void connect_event () { boolean err = false; SocketChannel fd = null; try { fd = connect (); } catch (ConnectException e) { err = true; } catch (SocketException e) { err = true; } catch (SocketTimeoutException e) { ...
7
public String getAlgorithm() { return algorithm; }
0
private String getLANIpAddress() { // returns IP address in wifi network try { boolean firstAddress = true; Enumeration<NetworkInterface> networkInterfaces = NetworkInterface .getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { NetworkInterface networkInterface = networkInterface...
7
@Override public Screen respondToUserInput(KeyEvent key) { int k = key.getKeyCode(); if (k == KeyEvent.VK_ESCAPE) return game; else if (k == KeyEvent.VK_DOWN || k == KeyEvent.VK_J || k == KeyEvent.VK_NUMPAD2) { if (pos<8) pos++; } else...
9
public void insertStudent(String Name,String Address) throws SQLException { String insertTableSQL = "INSERT INTO school.student " + "(name, address) " + "VALUES" + "('"+Name+"','"+Address+"')"; try { MyConnection mc=new MyConnection(); dbConnection=mc.getConnection(); stateme...
3
public Collection<V> values() { List<V> values = new ArrayList<>(); for(Set<V> valueSet : mValuesByKey.values()) { for(V value : valueSet) { values.add(value); } } return values; }
2
@Override public int compareTo(letterAndFrequency o) { // TODO Auto-generated method stub if(this.frequency < o.frequency){ return -1; } else if(this.frequency == o.frequency){ return 1; } return 0; }
2