text
stringlengths
14
410k
label
int32
0
9
static int checkDup(String[]input, int n){ int i =0; char[] cArray=new char[n]; int[] indexArray=new int[n]; int c=0; while(i<input.length){ if(input[i]==null){ i++; continue; } cArray[c] =input[i].charAt(0); indexArray[c]=i; c++; i++; if(c==n){ break; } } ...
7
private void drawNodes(Graphics gs) { //bg.setColor(Color.white); //bg.fillRect(0, 0, gs.get, 5000); for (int i = 0; i < timeout.length; i++) { timeout[i]++; } if (nodes == null) { return; } int id = 0; for (Point p : nodes) { ...
7
private void group(CommandSender sender, String[] args) { if (!sender.hasPermission("graveyard.command.group")) { noPermission(sender); return; } else if (!(sender instanceof Player)) { noConsole(sender); return; } Player player = (Player) ...
3
public boolean checkNumber(String text){ String ValidNum = "0123456789"; if (text.length()==0){ return true; } if ((ValidNum.indexOf(text.charAt(0))) == -1){ return false; } if ((ValidNum.indexOf(text.charAt(text.length()-1))) ...
5
private void createMenu() { JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); JMenuItem menuItem = new JMenuItem("New connection"); fileMenu.add(menuItem); menuItem.addActionListener(new AbstractAction() { @Overri...
6
protected void printParameter(String parentParameterFile, String childParameterFile, ArrayList<_Doc> docList) { System.out.println("printing parameter"); try { System.out.println(parentParameterFile); System.out.println(childParameterFile); PrintWriter parentParaOut = new PrintWriter(new File( pa...
6
public void run() { Graphics g = getGraphics(); g.setClip(new Rectangle(width, height)); // BufferedImage img = new BufferedImage(width, height, // BufferedImage.TYPE_3BYTE_BGR); system = new Simulation(); Body ball1 = new Body(new CollisionCircle(20, new Vector(100, 100)...
7
@Override public void run() { //get the socket's output stream for writing try { writer = new PrintStream(socket.getOutputStream()); } catch(IOException e) { System.err.println("Error getting writer: " + e); } //get the socket's input stream f...
7
public String addBlogDetails() { FacesMessage doneMessage = null; String outcome = null; Blog blog = new Blog(); blog.setBlogContent(this.blogContent); blog.setBlogContentLable(this.blogLabel); blog.setCreatedDate(new Date()); if (blogDelegate.saveBlog(blog) !...
1
public static Car createCar(String carType){ if (carType.equals("AutomobileI")){ return new TruckI("black", (int) (Math.random() * 5) ); } else return null; }
1
@Override public void spawnEnemy(String enemyData) { if(!free()) { return; } int r = Application.get().getRNG().nextInt(7) ; GameActor a = Application.get().getLogic().createActor(enemyData); PhysicsComponent pc = (PhysicsComponent)a.getComponent("PhysicsComponent...
2
@Override public IMatrix sub(IMatrix other) { //ako nisu jednake dimenzije, vrati iznimku if (this.getColsCount() != other.getColsCount() || this.getRowsCount() != other.getRowsCount()) { throw new IncompatibleOperandException( "Matrices have not same dimensions."); } for (int row = 0; row < this....
4
private void downSafety(final ExprInfo exprInfo) { final Iterator blocks = cfg.nodes().iterator(); while (blocks.hasNext()) { final Block block = (Block) blocks.next(); final Phi phi = exprInfo.exprPhiAtBlock(block); if (phi == null) { continue; } if (StackPRE.DEBUG) { System.out.println(...
7
public int[] addInstance(BallNode node, Instance inst) throws Exception { double leftDist, rightDist; if (node.m_Left!=null && node.m_Right!=null) { //if node is not a leaf // go further down the tree to look for the leaf the instance should be in leftDist = m_DistanceFunction...
7
public void codageRZ() { for (int i = 0; i < informationRecue.nbElements(); i++) { for (int j = 0; j < nbEchantillon; j++) { if (informationRecue.iemeElement(i)) { if (j < nbEchantillon / 2) informationEmise.add(max); else if (j >= nbEchantillon / 2) informationEmise.add(0f); } els...
7
public static Image add(Image img1, Image img2) { if (img1 == null || img2 == null) { return null; } Image img = img1.shallowClone(); double min = 0, max = 255; for (int x = 0; x < img1.getWidth(); x++) { for (int y = 0; y < img1.getHeight(); y++) { double red = img1.getPixel(x, y, RED) + img2...
4
@FXML private void ConnectButtomAction(ActionEvent event) { this.host = Hostinput.getText(); this.port = Portinput.getText(); this.username = Usernameinput.getText(); this.password = Passwordinput.getText(); this.sid = SIDInput.getText(); int port1 = 0; ...
8
private void setupMicrophone(String name) { Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo(); for (Mixer.Info info : mixerInfos) { if (!info.getName().equals(name)) { continue; } Mixer mixer = AudioSystem.getMixer(info); int maxLines ...
7
@Override public void actionPerformed(ActionEvent e) { //Handle open button action if (e.getSource() == openButton) { openButtonAction(); } else if ((e.getSource() == pathText)) { if (currentState != State.PROCESSING) pathTextEn...
6
public boolean draw(int numToDraw) { for (int i = 0; i < numToDraw; i++) { if (deck.size() <= 0) { this.hasLost = true; return this.hasLost; } this.hand.add(this.deck.remove(0)); } return this.hasLost; }
2
private <T> T find(Class<T> itemClass) { for (Item item : items) if (item != null && item.getClass().equals(itemClass)) return itemClass.cast(item); return null; }
3
void f() throws VeryImportantException { throw new VeryImportantException(); }
0
public void exchangeLeveledLists() { String ID; SPProgressBarPlug.setStatus("Exchange LeveledItems in LeveledList"); for (int i = 1; i < RBS_Main.amountBodyTypes; i++) { ID = RBS_Randomize.createID(i); for (LVLI leveledItem : SkyProcStarter.patch.getLeveledItems()) { ...
6
public void setPanels(ArrayList<Rectangle> panels) { this.panels = panels; }
0
public static Image createSquareImage(int height, int width) { Image binaryImage = new RgbImage(width, height); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { // Analyzes if the point is in the black or white square boolean fitsInSquareByWidth = (x > width / 4 && x < 3 * (width / 4)...
6
private static BigDecimal applyTheDayOfWeekMarketDiscountsAndGetProductPrice( Product product, String day) { // TODO Auto-generated method stub BigDecimal price = product.getPrice(); switch (day) { case "Tuesday": return (!product.isFruit()) ? price : price .multiply(new BigDecimal("0.80")); case "...
8
public static List<CDCRelation> readValidMatrices(){ // load a file containing the matrix description of network String fileName = "ValidM.csv"; //int[][] aWCTList = null; InputStream MatrixStream = CDCComposition.class.getResourceAsStream(fileName);; List<CDCRelation> aMatrixList = new ArrayList<CDCR...
7
private String makeDeckMove(CardGame game) { if (topRow) { return game.moveCardOntoTopRowFromDeck(boardIndexTo); } else { return game.moveCardOntoCardFromDeck(boardIndexTo); } }
1
public List<DetallePunto> ObtenerDetallePunto(String consulta){ List<DetallePunto> lista=new ArrayList<DetallePunto>(); if (!consulta.equals("")) { lista=cx.getObjects(consulta); }else { lista=null; } return lista; }
1
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) { // Week-end setBackground(new Color(255, 220, 2...
6
public void act() { if(life <= 0){ CreatureSimulator cs = (CreatureSimulator)this.getEnvironment(); cs.removeCreature(this); } else { // iterate over all nearby plants Iterable<ICreature> creatures = plantsAround(this); int count = 0; for (ICreature c : creatures) { if (this.distanceFromAPoint...
5
public static List<ABObject> getAllSupporter (List<ABObject> objs,List<ABObject> ob) { List<ABObject> result = new LinkedList<ABObject>(); try { for (int i = 0; i < objs.size(); i++) { List<ABObject> temp = getSupporters (objs.get(i), ob, objs.get(i).depth + 1); if (!result.containsAll(temp)) ...
4
public static void startAlgorithm(Vertex start) { algorithm.initialize(start); }
0
@Override protected void addPlayerOnGrid(Player p) { if (p == null) throw new IllegalArgumentException("The given arguments are invalid!"); super.addPlayerOnGrid(p); if(p instanceof PlayerCTF){ PlayerFlag playerFlag = new PlayerFlag(grid, p); ((PlayerCTF)p).setPlayerFlag(playerFlag); grid.addEleme...
2
public int[] nextInts(int n) throws IOException { int[] res = new int[n]; for (int i = 0; i < n; ++i) { res[i] = nextInt(); } return res; }
1
public static boolean containsOnlyNotNull(Object... values){ for(Object o : values){ if(o== null){ return false; } } return true; }
2
public boolean playVideo(Integer key, boolean fromUser) { if(videos.containsKey(key)){ if(!stoppedVideoKeys.contains(key)){ videos.get(key).pause();; stoppedVideoKeys.add(key); return true; } else { videos.get(key).loop(); stoppedVideoKeys.remove(key); return true; } } /...
2
public ArrayList<Piste> getPisteet() { ArrayList<Piste> pisteet = new ArrayList(); pisteet.add(vasenYlakulma); pisteet.add(oikeaAlakulma); return pisteet; }
0
public void setMaxSpeed(int maxSpeed) throws CarriageException { if (maxSpeed >= 0) { this.maxSpeed = maxSpeed; } else { throw new CarriageException("Maximum speed is under zero"); } }
1
private void filling(){ //获取棋子 HashMap<ChessMan,Integer> map=getAllChessMan(); Random random = new Random(); //横坐标 for(int i=0;i<x;i++){ //纵坐标 for(int j=0;j<y;j++){ int r; if(map.size()==1){ r=0; }else{ r = random.nextInt(map.size()-1); } ChessMan cm = list.get(r); int ...
4
EntrySet(int size) { if(size < 0) this.size = 0; // Can't be any bigger than the array: else if(size > DATA.length) this.size = DATA.length; else this.size = size; }
2
public void start(Archive archive, Client client) { String versionNames[] = {"model_version", "anim_version", "midi_version", "map_version"}; for (int i = 0; i < 4; i++) { byte buf[] = archive.get(versionNames[i]); int len = buf.length / 2; Stream buffer = new Stream(...
9
protected static DateTime entrerDateConsole(){ Scanner sc = new Scanner(System.in); DateTime horaire = null; boolean dateOK = false;//validité de la date au sens chronologique boolean dateFormatOK = false;//validité de la date pour le parsing while(!dateOK){ while(!dateFormatOK){ System.out.print("Entr...
4
public Texture loadTexture(String filename) { String[] splitArray = filename.split("\\."); String ext = splitArray[splitArray.length - 1]; try { int id = TextureLoader .getTexture( ext, new FileInputStream(n...
1
public boolean isExempt(Player p) { if (p.hasPermission("hunger.effects.exempt")) return true; else return false; }
1
private FunctionCompletion createFunctionCompletion() { FunctionCompletion fc = null; if (funcCompletionType!=null) { try { Class<?> clazz = null; if (completionCL!=null) { clazz = Class.forName(funcCompletionType, true, completionCL); } else { clazz = Class.forName(funcComp...
9
private static Farbe farbeZuweisen() { if (!Farbe.ROT.isIstFrei() && Farbe.SCHWARZ.isIstFrei()) { return Farbe.SCHWARZ; } else if (!Farbe.BLAU.isIstFrei() && Farbe.GRUEN.isIstFrei()) { return Farbe.GRUEN; } else if (!Farbe.GRUEN.isIstFrei() && Farbe.BLAU.isIstFrei()) { return Farbe.BLAU; } else if (!Fa...
8
public static void printHex(byte[] b) { for (int i = 0; i < b.length; ++i) { if (i % 16 == 0) { System.out.print(Integer.toHexString(i & 0xFFFF | 0x10000) .substring(1, 5) + " - "); } System.out.print(Integer.toHexString(b[i] & 0xFF | 0x100) .substring(1, 3) + " "); if (i %...
9
private void passToken() { activity = true; if (silence() < Constants.USAGE_TIMEOUT && eventCount > Constants.MIN_OCTETS) { // SawTokenUser // debug("passToken:SawTokenUser"); if (LOG.isLoggable(Level.FINE)) LOG.fine(thisStation + " passToke...
9
@Override protected void setReaction(Message message) { try { String langFrom = getLang(message.text, true); String langTo = getLang(message.text, false); if (isLangAllowed(langFrom) && isLangAllowed(langTo)) { if (langFrom.equals(langTo)) { ...
4
public Items getHead() { return head; }
0
public static void main(String[] args) { Scanner inputScanner = null; try { inputScanner = new Scanner(new File(args[0])); } catch (FileNotFoundException e) { System.err.println("Invalid input file."); } while (inputScanner.hasNextLine()) { String[] outputLine = inputScanner.nextLine().split(" "); ...
4
public int getConstantValue() { if ((accessFlags & AccessFlag.STATIC) == 0) return 0; ConstantAttribute attr = (ConstantAttribute)getAttribute(ConstantAttribute.tag); if (attr == null) return 0; else return attr.getConstantValue(); }
2
@EventHandler public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); final UUID uuid = player.getUniqueId(); final String name = player.getName(); final Database database = plugin.getDatabaseManager().getDatabase(); if (database instanceof YAML...
5
public void drawHead(Graphics graphics, Point position, Point size) { int startAngle = 30; if (getDirection() == Direction.RIGHT) { startAngle = 30; } else if (getDirection() == Direction.LEFT) { startAngle = 210; } else if (getDirection() == Direction.UP) { ...
8
public static ArrayList<Sub> getSubs() { ArrayList<String> tempsubs = new ArrayList<String>(); for(int i = 0; i < file.size(); i++) { if( file.get(i).equals("")) { subs.add(new Sub(id, fromTime, toTime, new ArrayList<String>(tempsubs))); tempsubs.clear(); id = 0; fromTim...
7
protected void Calcula_Tamanho() { int quantidadeAtributos = atributosTabela.size(); for (int k = 0; k < quantidadeAtributos; k++) { TipodeDados A = (TipodeDados) atributosTabela.get(k); switch (A.tipoAtributo) { case (TipodeDados.BOOLEAN): { t...
9
public String getLabel() { if (label == null) label = "while_" + (serialno++) + "_"; return label; }
1
private int neighborCount(int x, int y) { int count = 0; for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { int currentY = y + i; int currentX = x + j; if (currentX != x || currentY != y) { if (currentX >= 0 && currentX < field[0].length && currentY >= 0 && ...
9
@Override public boolean isComplete() { return complete; }
0
public void onTimerEvent() { final List<Customer> customers = customerRepository.getNewCustomers(); final Campaign campaign = new HalfOfCampaign(); final Set<Long> ids = new HashSet<Long>(); if (customers == null) { throw new IllegalArgumentException("No new customers found"...
9
protected void setCurrent(int i) { myCurrent = i; }
0
@Override void update() { x += Math.cos(DIRECTION) * SPEED; y += Math.sin(DIRECTION) * SPEED; AffineTransform tran = new AffineTransform(); tran.translate(x, y); tran.rotate(angle, SIZE / 2, SIZE / 2); painter.drawImage(IMAGE, tran, null); if...
4
public boolean permissible(GuideUserAction currentAction, ParserConfiguration config) throws MaltChainedException { currentAction.getAction(actionContainers); int trans = transActionContainer.getActionCode(); if ((trans == LEFTARC || trans == RIGHTARC) && !isActionContainersLabeled()) { return false; } Dep...
8
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onItemHeldChange(PlayerItemHeldEvent event) { Player player = event.getPlayer(); if (player.isSneaking()) { if ((player.isOp() || player.hasPermission("voxelbar.use")) && plugin.getConfigurat...
6
private void lengthConversionsMenu() throws InterruptedException { System.out.println(); println("Choose a conversion or enter any integer to go back:"); println("0: Centimeters to meters"); println("1: Meters to centimeters"); println("2: Microns to centimeters"); println("3: Centimeters to mi...
8
public String[] getLastMessages() { return previousMessages; }
0
public boolean getTruthValue() { if (!hasTruthValue()) { throw new RuntimeException("Attempt to get the truth value for a result set with non-truth value data."); } return truthValue; }
1
private boolean processSanninCommand(MapleClient c, MessageCallback mc, String[] splitted) { DefinitionSanninCommandPair definitionCommandPair = sannincommands.get(splitted[0]); if (definitionCommandPair != null) { try { definitionCommandPair.getCommand().execute(c, mc, split...
6
public void setNametextZoomedFontsize(int fontsize) { if (fontsize <= 0) { this.nametextZoomedFontSize = UIFontInits.NAMEZOOMED.getSize(); } else { this.nametextZoomedFontSize = fontsize; } somethingChanged(); }
1
public String toString() { if (version == null) { StringBuilder result = new StringBuilder(); for (int i = 0; i < orderedVersionNumbers.size(); i++) { Integer curVersionNumber = (Integer) orderedVersionNumbers.get(i); result.append(curVersionNumber.intValu...
9
public void endLifetime() { if (this.lifetime > 0) this.lifetime = 0; }
1
@Override public void removeUpdate(double delta) { timer += delta; if (timer >= solidityDuration) { getEntity().remove(CollisionComponent.ID); } if (timer >= duration) { getEntity().forceRemove(); } double amt = (duration - timer) / duration; SpriteComponent sc = (SpriteComponent) getEntity().getC...
4
@Override public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) { final String command = buildFormatCommand(obj); try { toAppendTo.append(getCycAccess().converseString(command)); } catch (Exception ex) { throw new RuntimeException("Exception formatting " + obj, ex)...
1
public static void htmlExecuteQuery(KeyValueList querydata, org.powerloom.PrintableStringWriter stream) { { String modulename = ((StringWrapper)(querydata.lookup(StringWrapper.wrapString("MODULE")))).wrapperValue; Module module = Logic.getModule(StringWrapper.wrapString(modulename)); StringWrapper nvalu...
7
public Fraction evaluate(String expression) { IEvaluable ev; try { TokenList tl = tokenizer.tokenize(expression); if (debug) System.out.println("\nBuilding syntax tree..."); ev = tl.parse(); } catch (ParseError e) { throw e; } catch (NumberFormatException e) { throw new ParseError("Invalid n...
5
private void drawLogoLayer() { ctx.clearRect(0, 0, size, size); if (Clock.Design.BOSCH == getSkinnable().getDesign()) { ctx.setFill(getSkinnable().isNightMode() ? Color.rgb(240, 240, 240) : Color.rgb(10, 10, 10)); ctx.fillRect(size * 0.5 - 1, size * 0.18, 2, size * 0.27); ...
4
public int getGladiolos() { return gladiolos; }
0
public HashMap hashResult(String query) throws SQLException { Connection connection = null; Statement statement = null; ResultSet result = null; String key = ""; String val = ""; HashMap hashedList = new HashMap(); try { Class.forName(driver); connection = DriverManager.getConnection(url, use...
6
public static ArrayList<Clientes> sqlSelectTodos() { ArrayList<Clientes> cat = new ArrayList(); if(!BD.getInstance().sqlSelect("SELECT * FROM clientes ORDER BY idclientes DESC")){ return cat; } while(BD.getInstance().sqlFetch()){ cat.add(new Clientes(B...
2
public void refuel(int amount) { if((amount > 0) && ((amount + fuelLevel) <= fuelCapacity) && !infinite) { fuelLevel += amount; } }
3
@Override public void ParseIn(Connection Main, Server Environment) { if(Main.Data.Trade != null) { return; } Room Room = Environment.RoomManager.GetRoom(Main.Data.CurrentRoom); if (Room == null) { return; } int User = Roo...
4
@Override public String remove(String hashKey) { if (manager.remove(hashKey) == null) { return "Error: No match to object!"; } else { if (hashKey.startsWith("A")) { aisleCount--; } else if (hashKey.startsWith("R")) { rackCount--; ...
3
public synchronized void drop_tables() { Connection c = null; try { c = connectionPool.getConnection(); clearSoftState(); Statement stmt = c.createStatement(); for( String t : TABLES ) { try { stmt.executeUpdate("DROP TABLE IF EXISTS " + t); } catch( Exception e ) { logger....
4
public Object getPrice(MaterialData data){ if(data==null) return null; if(prices.containsKey(data)) return prices.get(data); return defaultPrice; }
2
public void setTotalPrice(float totalPrice) { this.totalPrice = totalPrice; }
0
public Request getNextBlock(){ if(complete){return null;} Iterator<SubPiece> itor = data.iterator(); SubPiece last=null; int max = idealSize; if(max > finalPiece.length){ max = finalPiece.length; } //TODO: reduces i think? while(itor.hasNext()){ if(last==null){ last=itor.next(); }else{ ...
9
public int getInt(int index) throws JSONException { Object object = this.get(index); try { return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object); } catch (Exception e) { throw new JSONException("JSONArray[" ...
2
public static void addInventoryInfo(MaplePacketLittleEndianWriter mplew, MapleCharacter chr) { mplew.writeInt(chr.getMeso()); // mesos mplew.write(chr.getInventory(MapleInventoryType.EQUIP).getSlotLimit()); // equip slots mplew.write(chr.getInventory(MapleInventoryType.USE).getSlotLimit()); // u...
9
public void setClobField(Clob clobField) { this.clobField = clobField; BufferedReader reader = null; try { reader = new BufferedReader(clobField.getCharacterStream()); setClobData(reader.readLine()); } catch (SQLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } f...
4
public void addNpe(String className, NpeData data) { String name = className; if(data == null) { data = new NpeData(this); } // Register the MBean ObjectName oName; try { oName = new ObjectName("org.dkhenry.minejmx:type=NpeData,name=" + name); if( mbs.isRegistered(oName) ) { mbs.unregisterMBean...
8
@Override public void testIgnored(Description description) { testStarted(description); final Xpp3Dom testCase = getCurrentTestCase(); testCase.addChild(createResult(TestState.blocked)); final String message = description.getAnnotation(Ignore.class).value(); testCase.addChild(...
0
@Override public void addUnsearchQueue(WebPage unsearchQueue) { // TODO Auto-generated method stub }
0
public JSONWriter array() throws JSONException { if (this.mode == 'i' || this.mode == 'o' || this.mode == 'a') { this.push(null); this.append("["); this.comma = false; return this; } throw new JSONException("Misplaced array."); }
3
public NewMemberGui() { System.out.println("DEBUG: starting NewMemberGui..."); try { mM = MemberManager.getInstance(); System.out.println("DEBUG: mM-instance: " + MemberManager.getInstance()); } catch (FileNotFoundException ex) { L...
4
public IterableGroup(TKey key, Iterable<TElement> source) { this._key = key; this._source = source; }
0
private String extractParameterValue(String str, String parameterName) { int paraIdx = str.indexOf("\""+parameterName+"\""); if (paraIdx < 0) return ""; int startIdx = str.indexOf(":", paraIdx)+1; if (startIdx <= -1) return ""; String value; int en...
3
public double[] rawPersonMaxima(){ if(!this.dataPreprocessed)this.preprocessData(); if(!this.variancesCalculated)this.meansAndVariances(); return this.rawPersonMaxima; }
2
private static void fillPersonFields(Person p, String[] tokens) { int i = 1; //Start in token 1 as token 0 is the field label (MANAGER, PLAYER, etc.) String flag = null, value = null; do { //Get current flag flag = tokens[i]; value = tokens[i+1]; switch(flag) { case "-name": { p.se...
8
public Worker () { //initial settings isInputActive = true; this.keyboard = new BufferedReader(new InputStreamReader(System.in)); System.out.println(MSG_WELCOME); //start this.lifeCycle(); }
0