text
stringlengths
14
410k
label
int32
0
9
public boolean transitionsFromTuringFinalStateAllowed() { return transTuringFinal; }
0
public void jsFunction_waitCraft(String wnd, int timeout) { deprecated(); int cur = 0; while (true) { if(cur > timeout) break; if (UI.instance.make_window != null) if ((UI.instance.make_window.is_ready) && (UI.instance.make_window.craft_name.equals(wnd))) return; Sleep(...
5
public static void getSubString(String input){ HashSet<String> usedset = new HashSet<String>(); HashSet<String> validSet = new HashSet<String>(); for(int i=1; i<=input.length();i++){ for(int j= 0; j+i<= input.length();j++){ String sub = input....
7
public String getMove() { switch(move){ case 1: return "up"; case 2: return "down"; case 3: return "left"; case 4: return "right"; } return ""; }
4
public boolean isSymmetric(TreeNode root) { if (root == null) { return true; } Stack<TreeNode> leftStack = new Stack<>(); Stack<TreeNode> rightStack = new Stack<>(); leftStack.add(root.left); rightStack.add(root.right); while (!le...
7
public static BufferedImage fsDithering(BufferedImage input, int numberOfRedHues, int numberOfGreenHues, int numberOfBlueHues) { BufferedImage result = new BufferedImage(input...
6
public static Object invokeMethodWithString(Object o, String methodName, String value) { if (o == null) return null; if (Functions.isEmpty(methodName)) return null; Object retObj; try { Class<?> c = o.getClass(); if (c == null) return null; Method m = c.getMethod(methodName); Object arglist...
5
private void btnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalirActionPerformed System.exit(0); }//GEN-LAST:event_btnSalirActionPerformed
0
public Tile getTile(int x, int y) { if(x >= width || x < 0 || y >= height || y < 0) return null; return World.tiles[map[x][y]]; }
4
public void setIdPrueba(Integer idPrueba) { this.idPrueba = idPrueba; }
0
public List<ExtensionsType> getExtensions() { if (extensions == null) { extensions = new ArrayList<ExtensionsType>(); } return this.extensions; }
1
@Override public void actionPerformed(ActionEvent event) { try { Desktop.getDesktop().open(mFile); } catch (IOException exception) { WindowUtils.showError(null, exception.getMessage()); } }
1
@Test public void testRollbackSucceededState() throws ProcessExecutionException, ProcessRollbackException { IProcessComponent<?> comp = TestUtil.executionSuccessComponent(true); // use reflection to set internal process state TestUtil.setState(comp, ProcessState.ROLLBACK_SUCCEEDED); assertTrue(comp.getState(...
5
protected String[] getViewChoices() { return new String[] { "Noninverted Tree", "Derivation Table" }; }
0
public String getDirFilterExclude() { return this.dirFilterExclude; }
0
protected static void mult_BYTE_COMP_Data(WritableRaster wr) { // System.out.println("Multiply Int: " + wr); ComponentSampleModel csm; csm = (ComponentSampleModel) wr.getSampleModel(); final int width = wr.getWidth(); final int scanStride = csm.getScanlineStride(); fin...
4
public void setBoxDate(Date boxDate) { this.boxDate = boxDate; }
0
@Override public void paintComponent(Graphics g) { BufferedImage bufferedImage = new BufferedImage( this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_RGB ); Graphics tmpG = bufferedImage.createGraphics(); super.paintComponent( tmpG ); tmpG.setColor( Color.green ); ...
8
public List tools(AutomatonPane view, AutomatonDrawer drawer) { List list = new java.util.ArrayList(); list.add(new MooreArrowTool(view, drawer)); list.add(new MooreStateTool(view, drawer)); list.add(new TransitionTool(view, drawer)); list.add(new DeleteTool(view, drawer)); ...
0
private String processStringValues(String rawValue, HashSet<String> stopHash){ if(rawValue.equals("")){ return rawValue; } StringBuilder sb = new StringBuilder(); rawValue = rawValue.toLowerCase(); String[] strArray = rawValue.split(" "); Arrays.sort(strArray); for(String str : strArray){ if(stopHas...
3
@SuppressWarnings("rawtypes") @Override public boolean equals(Object o) { if (o instanceof Entry) { Entry other = (Entry) o; return (key == null ? other.getKey() == null : key.equals(other.getKey())) && (value == null ? other.getValue() == null : value.equals(other.getValue())); ...
4
private void evaluateNFATransition(Transition transition, ExecutionState candidate, String candidateWord, List<ExecutionState> worklist) { // Add to the worklist any state according to the current state // and the position reached into the candidate word. s...
9
final void send(ByteBuffer buffer) { mLastActivity = System.currentTimeMillis(); if (isSecure()) { try { mSSLSupport.processOutput(buffer); } catch (Throwable throwable) { Log.error(this, throwable); } } else { mServer.send(mChannel, buffer); } }
2
public HotKeyFlags setKey(String k) { if (k != null && !k.equals("")) low = keysr.get(k); return this; }
2
public String longestPrefixOf(String s) { if (s == null || s.length() == 0) return null; int length = 0; Node x = root; int i = 0; while (x != null && i < s.length()) { char c = s.charAt(i); if (c < x.c) x = x.left; else if (c > x.c) x = x...
7
public ChatRmiClient () { client = new Client(); client.start(); // Register the classes that will be sent over the network. Network.register(client); // Get the Player on the other end of the connection. // This allows the client to call methods on the server. player = ObjectSpace.getRemoteObject(clien...
5
@Test public void findDuplicateTypeHand_whenNoPairExists_returnsHighCardHand() { Hand hand = findDuplicateTypeHand(kingQueenNineSixFourThreeTwo()); assertEquals(HandRank.HighCard, hand.handRank); assertEquals(Rank.King, hand.ranks.get(0)); assertEquals(Rank.Queen, hand.ranks.get(1)); assertEquals(Rank.Nine, ...
0
private void registerPermissions () { this.getServer().getScheduler() .scheduleSyncDelayedTask(this, new Runnable() { public void run () { PluginManager pm = instance.getServer().getPluginManager(); Map<Str...
5
public static String readParamInXmlFile(String paramName, String fileName){ ArrayList<String> params = new ArrayList<String>(); try{ File fXmlFile = new File(fileName); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder; dBuilder = dbFactory.newDocumentBu...
4
public static void modifierSujet(Sujet sujet, String nouveauSujet, String nouveauMessage, Utilisateur utilisateur) throws ChampInvalideException, ChampVideException { if (!sujet.peutModifier(utilisateur)) throw new InterditException("Vous n'avez pas les droits requis pour modifier cette ...
3
public void setAllProducts(List<Product> allProducts) { this.allProducts = allProducts; }
0
public void setMemory(Integer memory) { this.memory = memory; }
0
public static DbHelper getDbHelper() { if(dbHelper == null){ dbHelper = new DbHelper(); } return dbHelper; }
1
public SimpleDateFormat getFormatter() { return formatter; }
0
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Tipo other = (Tipo) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; if (n...
9
public Class<?> getColumnClass(int col) { return getValueAt(0, col).getClass(); }
1
public static void main(String[] args) { int[] A = {3,4,5,1,4,2}; int[] B = {9,9,9}; int[] C = {1,2}; int target = 6; Solution sl = new Solution(); //int[] result = sl.twoSum(A, target); // int[] result = sl.PlusOne(A); // for(int i=0;i<result.length;i++){ // System.out.println(result[i]); // } // //...
0
public Set entrySet() { accessTimes.clear(); // we're redoing everything so we might as well touch(map.keySet()); return map.entrySet(); }//entrySet
0
public static String encodeURI (String argString) { StringBuilder uri = new StringBuilder(); // Encoded URL char[] chars = argString.toCharArray(); for (char c : chars) { if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || mark.indexOf(c) != -1) { ...
8
@Override public void characters( char[] ch, int start, int length ) throws SAXException { if( length > 0 ){ String value = new String( ch, start, length ); String old = stack.getFirst().getValue(); if( old != null && old.length() > 0 ){ ...
3
private void setVoltageMode() { if (!m_voltageMode) { if(m_robotDrive != null) { m_robotDrive.setMaxOutput(12); } try { if (_leftFrontMotor != null) { _leftFrontMotor.changeControlMode(CANJaguar.Con...
7
public boolean isValidField(char row, byte column) { if(row >= 97 && row <= 104 && column <= 7 && column >= 0) { return true; } return false; }
4
public void getRoutes(IntTreeNode p_root, int p_currentSum) { // TreeNode l_cloned = new TreeNode(p_root.getValue()); int l_sumForSubTree = p_currentSum - p_root.getValue(); if (l_sumForSubTree == 0 && p_root.getLeft() == null && p_root.getRight() == null) { for (int l_i = 0; l_i <...
8
@Override public void mouseDragged(MouseEvent event) { if (isEnabled()) { boolean wasPressed = mPressed; mPressed = isOver(event.getX(), event.getY()); if (mPressed != wasPressed) { repaint(); } } }
2
public String getId() { return id; }
0
public void keyPressed(int k) { if(k == KeyEvent.VK_LEFT) player.setLeft(true); if(k == KeyEvent.VK_RIGHT) player.setRight(true); if(k == KeyEvent.VK_UP) player.setUp(true); if(k == KeyEvent.VK_DOWN) player.setDown(true); if(k == KeyEvent.VK_W) player.setJumping(true); if(k == KeyEvent.VK_R) player.setScrat...
7
public static boolean Read(String hostname) { try { BufferedReader prefixes = new BufferedReader(new FileReader(PrefixesFile)); String line; while((line = prefixes.readLine()) != null) { System.out.println("prefixes - readli...
9
protected JTable createTable(Transition transition) { JTable table = super.createTable(transition); if (!blockTransition) { TableColumn directionColumn = table.getColumnModel().getColumn(2); directionColumn.setCellEditor(new DefaultCellEditor(BOX) { public Component getTableCellEditorComponent(JTable tabl...
2
@Override public void dataModificationStateChanged(Object obj, boolean modified) { if (modified) { setIcon(StdImage.MODIFIED_MARKER); setToolTipText(MODIFIED); } else { setIcon(StdImage.NOT_MODIFIED_MARKER); setToolTipText(NOT_MODIFIED); } repaint(); JRootPane rootPane = getRootPane(); if (root...
3
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { performTask(request, response); }
0
public double distance(Color color, int mode) { if (mode == RGB_DISTANCE) { int red = this.getRed()-color.getRed(); int green = this.getGreen()-color.getGreen(); int blue = this.getBlue()-color.getBlue(); return Math.sqrt(red*red + green*green + blue*blue); } else if (mode == HSV_DISTANCE) { return...
2
private static Object[] compare(Scanner testOutputScanner, Scanner correctFileScanner, boolean hadError) { StringBuilder correctOutputStrBldr = new StringBuilder(); StringBuilder testOutputStrBldr = new StringBuilder(); boolean correct = true; while (testOutputScanner.hasNextLine()) { String correctLine = c...
8
private void relaxLength(Edge e, Node prevNode) { Node nextNode; if (prevNode.equals(e.getFromNode())) { nextNode = e.getToNode(); } else { nextNode = e.getFromNode(); } double g_Score = prevNode.getDistTo() + e.getLength(); if (g_Score < nextNode.getDistTo()) { edgeTo.put(nextNode, e); ...
2
static Point2D interseccionSq(Line2D l1,Line2D l2){ Point2D p=interseccionLn(l1, l2);if(p==null)return null; double p1x=l1.getX1(),p1y=l1.getY1(),p2x=l1.getX2(),p2y=l1.getY2(),q1x=l2.getX1(), q1y=l2.getY1(),q2x=l2.getX2(),q2y=l2.getY2(),px=p.getX(),py=p.getY(); if(px<=Math.max(p1x,p2x)&&px>=Math.min(p1x,p2x)&&p...
9
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...
6
public boolean incrementIndexes() { if ( fixedRow && fixedColumn || !fixedRow && rowIndex >= maxSize - 1 || !fixedColumn && columnIndex >= maxSize - 1 ) { return false; } if ( !fixedRow ) { rowIndex++; } if ( !fixedColumn ) { columnIndex++; ...
8
AddRecord (MainWindow p) { parent = p; textFields = new ArrayList<JTextField>(0); String[] months = { "January","February","March","April","May","June", "July","August","September","October","November","December" }; int currentYear = Calendar.getInstance().get(Calendar.YEAR); int currentMonth = ...
9
private void kingTopPossibleMove(Piece piece, Position position) { int x1 = position.getPositionX(); int y1 = position.getPositionY(); if((x1 >= 0 && y1 >= 0) && (x1 < maxWidth && y1 <= 6)) { if(board.getChessBoardSquare(x1, y1+1).getPiece().getPieceType() != board.getBlankPiece().getPieceType()) { ...
6
CtNewClass(String name, ClassPool cp, boolean isInterface, CtClass superclass) { super(name, cp); wasChanged = true; String superName; if (isInterface || superclass == null) superName = null; else superName = superclass.getName(); c...
4
private int compareFuncSanitise(int func) { switch (func) { case NEVER: return 0; case LESS: return 1; case LEQUAL: return 2; case GREATER: return 3; case GEQUAL: return 4; case EQUAL: return 5; case NOTEQUAL: return 6; case ALWAYS: return 7; default: th...
8
@Override public void setAccounting(Accounting accounting) { setAccountTypes(accounting == null ? null : accounting.getAccountTypes()); setAccounts(accounting == null ? null : accounting.getAccounts()); // could be popup.setAccounting() with constructor call in this.constructor popu...
3
public void studentCategorySubscribe(String userid, String categoryName){ int catId = CategoryDao.getCategoryIdByName(categoryName); int id = PersonDao.fetchPersonId(userid); //deleteSubscribedCategories(id); ResultSet rs=null; Connection con=null; PreparedStatement ps=null; try{ String sql="INSERT ...
7
public Entity findEntityGlobal(int ID) { for (Layer L : gameLayers) { for (Entity e : L.getEntList() ) { if (e.getID() == ID) { return e; } } } return new Entity(-1); }
3
@Override public void run() { Type type = game.getType(); Player player = game.getPlayer(); String name = type.getName(); Double cost = type.getCost(); Double won = 0.0; Stat stat; ArrayList<Reward> results = getResults(); if(!results.isEmpty()) { // Send the rewards for(Reward rewar...
7
@Override public String getCity() { return super.getCity(); }
0
public void doExplosionB(boolean par1) { this.worldObj.playSoundEffect(this.explosionX, this.explosionY, this.explosionZ, "random.explode", 4.0F, (1.0F + (this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.2F) * 0.7F); this.worldObj.spawnParticle("hugeexplosion", this.explosionX, t...
8
@Override public void simpleRender(RenderManager rm) { }
0
public static void UpdateGeneratorPath(String profile, String genername, String generpath) { File file = new File(profile); if (file.exists()) { try { // Create a factory DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); // Use ...
7
public List<Book> getBooksByBookCategory(int branch_id, int [] bookcategory_id) { List<Book> list = new ArrayList<>(); Connection con = null; Statement stmt = null; try { DBconnection dbCon = new DBconnection(); Class.forName(dbCon.getJDBC_DRIVER()); ...
6
private void bellmanFord(int source, int[] dist, HashMap<Integer, HashMap<Integer, Integer>> g){ dist[source]=0; for(int i=1;i<dist.length;i++){ for(int j=1;j<dist.length;j++){ if(dist[j]<Integer.MAX_VALUE){ for(int neighbor:g.get(j).keySet()){ if(dist[neighbor] > dist[j]+g.get(j).get(neighbor)){ ...
5
@Before public void putDataCountingSort(){ a = new int[MAX]; for(int i = 0; i < MAX; ++i){ a[i] = i + 1; } shuffleIntArray(a); }
1
public void executeSetMethod(Object instance, Method method, Object value) { if(method == null) return; try { method.invoke(instance, value); } catch (IllegalArgumentException e) { System.err.println("<ClassInspect> Failed to execute SET Method <" + method.getName() + ">. Arguments passed to method is wr...
4
private JMenuBar createMainMenu(ActionListener listener) { JMenuBar menuBar = new JMenuBar(); JMenu menu, submenu; JMenuItem menuItem; // // File Menu // menu = new JMenu(language.getString("menu_file")); menu.setMnemonic(KeyEvent.VK_F); menuBar.add(menu); if (controller.isRunningAsApplet()) { ...
2
public void clickBlock(int par1, int par2, int par3, int par4) { if (this.creativeMode) { this.netClientHandler.addToSendQueue(new Packet14BlockDig(0, par1, par2, par3, par4)); PlayerControllerCreative.clickBlockCreative(this.mc, this, par1, par2, par3, par4); thi...
9
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Facility)) { return false; } Facility other = (Facility) object; if ((this.facilityID == null && other.facility...
5
public void testSetText() { try { ISOChronology.getInstanceUTC().year().set(0, null, java.util.Locale.US); fail(); } catch (IllegalFieldValueException e) { assertEquals(DateTimeFieldType.year(), e.getDateTimeFieldType()); assertEquals(null, e.getDurationFi...
6
@Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { String name = method.getName(); if (name.equals("close")) { boolean previouslyClosed = closed.getAndSet(true); if (config.isEnabled(Check.RESULT_SET_DOU...
9
public void onLivingUpdate() { if (!this.worldObj.isRemote) { if (this.isWet()) { this.attackEntityFrom(DamageSource.drown, 1); } --this.heightOffsetUpdateTime; if (this.heightOffsetUpdateTime <= 0) { ...
9
public int getsockopt(int option_) { if (ctx_terminated) { ZError.errno(ZError.ETERM); return -1; } if (option_ == ZMQ.ZMQ_RCVMORE) { return rcvmore ? 1 : 0; } if (option_ == ZMQ.ZMQ_EVENTS) { boolean rc = process_...
9
Type constantType(int id){ Object o = constants.nth(id); Class c = o.getClass(); if(Modifier.isPublic(c.getModifiers())) { //can't emit derived fn types due to visibility if(LazySeq.class.isAssignableFrom(c)) return Type.getType(ISeq.class); else if(c == Keyword.class) return Type.getType(Keyw...
7
public static double[] erlangCresources(double nonZeroDelayProbability, double totalTraffic) { double[] ret = new double[8]; long counter = 1; double lastProb = Double.NaN; double prob = Double.NaN; boolean test = true; while (test) { prob = Stat.erlangCprobability(totalTraffic, counter); if (prob <=...
4
public void buildClassifier(Instances insts) throws Exception { m_Filter = null; if (!isPresent()) throw new Exception("libsvm classes not in CLASSPATH!"); // remove instances with missing class insts = new Instances(insts); insts.deleteWithMissingClass(); if (!getDoNotReplaceMi...
8
private static void printFileReaders(String prefix, Map<String, FileReadingMessageSource> fileReaders) { Assert.notNull(fileReaders, "Mandatory argument missing."); for (String key : fileReaders.keySet()) { FileReadingMessageSource readTarget = fileReaders.get(key); File inDire...
2
private ParserResult limitConditionAmount(boolean limited, ParserResult result, SyntaxAnalyser analyser) throws GrammarCheckException { result = this.replaceNick(result, analyser); boolean conditionsIsOk = result.getConditions().size() == result .getDimensionLevelInfo().size(); if (!conditionsIsOk) { ...
5
public StageWelcome(StageManager stageManager, Map<String, String> data) { super(stageManager, data); try { welcome = ImageIO.read(getClass().getResourceAsStream("/graphics/loading/Welcome.png")); } catch (IOException e) { e.printStackTrace(); } }
1
public void startMoving(Direction dir) { move(dir); int last = queuedMoveDirectionPreferences.length - 1; int dirIndex = last; for(int i = 0; i < last && dirIndex == last; i++) if(queuedMoveDirectionPreferences[i] == dir) dirIndex = i; for(int i = dirIndex; i >= 1; i--) queuedMoveDirectionPreference...
4
protected void onChannelInfo(String channel, int userCount, String topic) {}
0
public Connection getConnection(String dbname){ PropertiesReader p = PropertiesReader.getInstance(); // 驱动程序名 String driver = p.getValue("mysql.driver",R.Constants.mysql_driver); // URL指向要访问的数据库名scutcs String url = p.getValue("mysql.url"); url = url.replaceAll("\\$\\{d...
2
public String getLocation_id() { return location_id; }
0
public void moveCharacters() { for (Character character : characters.values()) { ArrayList<Room> neighboursList = character.getLocation().getNeighbours(); boolean found = false; // if character's hostile, stay if player's in the same room. If not, sense if player's in a nearb...
8
public static void readStrings (String [] strings, String file) { BufferedReader bufferedReader=null; try { bufferedReader = new BufferedReader (new FileReader(file)); } catch (FileNotFoundException e) { System.out.print(e+"\n"); } ...
7
@Override public void marshal(Object o, HierarchicalStreamWriter writer, MarshallingContext mc) { if (normal == true) { for (Field f : mInfo.getAllFields()) { writer.startNode(f.getName()); if (treatAsReferences.contains(f.getType())) ...
5
/** @return The default configuration. */ public String getDefaultConfig() { if (mDefaultConfig == null) { mDefaultConfig = getConfig(); } return mDefaultConfig; }
1
private void parseStatus(String status, Map<String, Object> pageVariables) { switch (status) { case ExceptionMessages.EMPTY_DATA: case ExceptionMessages.FAILED_AUTH: case ExceptionMessages.NO_SUCH_USER_FOUND: case ExceptionMessages.SQL_ERROR: case Exce...
8
public void addIfaces(Collection result, ClassIdentifier ancestor) { ClassInfo[] ifaceInfos = ancestor.info.getInterfaces(); for (int i = 0; i < ifaceInfos.length; i++) { ClassIdentifier ifaceident = Main.getClassBundle() .getClassIdentifier(ifaceInfos[i].getName()); if (ifaceident != null && !ifaceident...
3
public void optimize(ArrayList<House> houses) { if (created) { int start = (int) System.currentTimeMillis(); Optimum opt = new Optimum(this, houses); this.grid = opt.getBestSolution().getGrid(); this.mapObjects = opt.getBestSolution().getMapObjects(); int area = 0; for (int i = 0; i < grid.length...
9
public static void init() { int count = 0; String s; try { BufferedReader in = new BufferedReader(new FileReader("../word-values.txt")); while ((s = in.readLine()) != null) { words[count] = s.trim(); count++; } in.close(); } catch (Exception e) { e.printStackTrace(); } int total...
9
public Node getNode(String expression, Object context) throws XPathExpressionException { assert(expression != null); if(context == null) { assert(document != null); context = document; } return (Node) xpath.evaluate(expression, context...
1
private void broadSearch(int maxdepth, Vector<Integer> Row) { //Warteschlange die die Knoten bereithaelt LinkedList<Vector<Integer>> Queue = new LinkedList<Vector<Integer>>(); //Startknoten beginnen Queue.add(Row); //Loop sucht nach dem Ziel while(!Queue.isEmpty()) { //Begrenzung der Suchtiefe...
6
public void filterPacks() { packPanels.clear(); packs.removeAll(); currentPacks.clear(); packMapping.clear(); int counter = 0; selectedPack = 0; packInfo.setText(""); // all removed, repaint packs.repaint(); // not really needed //m...
5