text
stringlengths
14
410k
label
int32
0
9
@Override public FileBlob getBlob( String urn ) { Matcher m = SHA1EXTRACTOR.matcher(urn); if( !m.find() ) return null; if( !dataDir.exists() ) return null; String sha1Base32 = m.group(1); String postSectorPath = sha1Base32.substring(0,2) + "/" + sha1Base32; File[] sectorFileList = dataDir.listFiles...
5
public GenericDAOXml(String filename, Class<T> klass) throws DaoException { super(filename); this.klass = klass; }
0
public CmpPoint(int x, int y) { this.x = x; this.y = y; }
0
@Basic @Column(name = "taxable") public int getTaxable() { return taxable; }
0
public void heapSort() { // decreasing order, since this is maxHeap for (int i = 0; i < heap.size(); i++) { BTPosition<T> tmp = remove(); System.out.println("Removed: " + tmp.element()); } }
1
private void searchWordTxtBoxKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_searchWordTxtBoxKeyPressed // 入力されたキーを取得 int keycode = evt.getKeyCode(); // Enterキーを入力した場合 if (keycode == KeyEvent.VK_ENTER) { // ファイルオブジェクト File objFile = new File(POST_COD...
9
public Component getComponentForDataSection(TaskObserver taskObserver, String dataSectionName) throws InterruptedException { if (dataSectionName == DATA_SECTION_UNKNOWN0) { return getGeneralPanel(taskObserver); } else if (dataSectionName == DATA_SECTION_VISIBLE_MAP_1) { return getVisibleMapPanel1(ta...
7
public void connect(String host, int port) { try { if (host.length() > 4) setConnection(new Socket(host, port)); } catch (UnknownHostException e) { chatLogWrite("Impossible to find your mate's host :C. Check twice his Ip :) "); e.printStackTrace(); } catch (IOException e) { e.printStackTrac...
3
@Override public int attack(double agility, double luck) { if(random.nextInt(100) < luck) { System.out.println("I just created a darkness jupitel!"); return random.nextInt((int) agility) * 2; } return 0; }
1
public static String LCS2(String s1, String s2, String[][] LCSArray, int index1, int index2){ if(index1 == -1 || index2 == -1) return ""; if(s1.charAt(index1) == s2.charAt(index2)){ if(LCSArray[index1][index2]=="") LCSArray[index1][index2] = LCS2(s1, s2, LCSArray, index1-1, index2-1); LCSArray[index1+1][...
7
public void refaz(int esq, int dir) { int j = esq * 2; int x = this.fp[esq]; while (j <= dir) { if ((j < dir) && (this.p[fp[j]] > this.p[fp[j + 1]])) j++; if (this.p[x] <= this.p[fp[j]]) break; this.fp[esq] = this.fp[j]; this.pos[fp[j]] = esq; esq = j; j = esq * 2; } this.fp[esq] = x...
4
public static void main(String[] args) { int origem = 0; int destino = 0; try { totalVertices = countLines("arquivo.txt"); System.out.println("O vertice de indice mais alto tem valor: " + totalVertices); Scanner scanner = new Scanner(System.in); System.out.println("Informe os vertices de ori...
5
@Override public void Draw(Graphics2D g2d) { switch (gameState) { case PLAYING: game.Draw(g2d, mousePosition()); break; case GAMEOVER: game.DrawGameOver(g2d, mousePosition()); break; case MAIN_MENU: ...
5
public static void addEventInTime(Event e)//adds the passed in event into the date in history { Day d = cursor.getDayStored();//the current the c d.addEvent(e); CalendarProject.saveEvents(cursor);//saves the file into text // ArrayList <Day> listOfDays= currentMonth.getDays(); // listOfDays.set(d.getNu...
0
@Override public void onEvent(Event event) { // If this event happens to be a ScannedRobotEvent... if (event instanceof ScannedRobotEvent) { onScannedRobot((ScannedRobotEvent) event); } }
1
protected void fileArrestResister(Law laws, Area myArea, LegalWarrant W) { if((W.criminal()!=null) &&(W.arrestingOfficer()!=null) &&(!W.arrestingOfficer().amDead()) &&(!W.crime().equalsIgnoreCase("pardoned")) &&(!CMLib.flags().isInTheGame(W.criminal(),true)) &&(isStillACrime(W,false))) { if(laws.basic...
7
final void setEnabled(final boolean enabled) { if (isEnabled != enabled) { isEnabled = enabled; if (isEnabled) { onEnable(); } else { onDisable(); // delete all the locals if (MiniPythonPlugin.mashUpJython) { ...
5
public static String md5(byte[] data) throws NoSuchAlgorithmException { MessageDigest digest = MessageDigest.getInstance(MD5); digest.update(data); byte[] bytes = digest.digest(); int length = bytes.length; StringBuffer buffer = new StringBuffer(length * 2); // 把密文转换成十六进制的字符串形式 for (int j = 0; j < length...
1
@Override public String toString() { return ToStringBuilder.reflectionToString(this,ToStringStyle.MULTI_LINE_STYLE); }
0
public static void main(String[] args) { final Statistic statistic = new StatisticImpl(); statistic.setStartTime(new Date()); QuestionGenerator generator = makeGenerator(); Formatter<Statistic> formatter = new StatisticFormatter(); final ManifestReader manifest = new ManifestRead...
4
public ArrayList<Rectangle> getPanels() { return panels; }
0
public FileRecv( String addr, String name ) { srcaddr = addr; srcname = name; }
0
public int queueLengthIter(){ PatientDL temp = this; int count = 0; while (temp != null){ temp = temp.nextPatient; count++; } return count; }
1
protected void initiateCandidateSolutions() { int columns = objectiveFunction.getVariables(); position = new double[numberOfParticles][columns]; velocities = new double[numberOfParticles][columns]; for(int i = 0; i < numberOfParticles; i++){ for(int k = 0; k < columns; k++){ velocities[i][k] = 0; if(...
3
@Override public void e(float sideMot, float forMot) { if (this.passenger == null || !(this.passenger instanceof EntityHuman)) { super.e(sideMot, forMot); this.W = 0.5F; // Make sure the entity can walk over half slabs, // instead of jumping return; } EntityHuman human = (EntityHuman) this.passe...
8
public static boolean isValid(char[] input) { LinkedList<Character> stack = new LinkedList<>(); for(int i=0; i< input.length; i++) { if(stack.peek() != null) { // get the top element char c = stack.peek(); //switch the top element ...
8
static void prob8() { /* * Find the greatest product of five consecutive digits in the * 1000-digit number. * * 73167176531330624919225119674426574742355349194934 * 96983520312774506326239578318016984801869478851843 * 85861560789112949495459501737958331952853208805511 * 1254069874715852386305071...
8
static void removeEdge(HashSet<String> subgraph) { double min_jaccard = 99999; int max_union = 0; String min_a = null; String min_b = null; for (String from : subgraph) { for (String to : graph.get(from)) { if (subgraph.contains(to)) { double jaccard = jaccard(from, to); if (jaccard == 0) { ...
6
private void goBack() { try { myCurrentPosition--; String url = (String) myURLHistory.get(myCurrentPosition); setDisplay(url); } catch (Throwable e) { myCurrentPosition++; } }
1
public Transition<TransitionInput> findFirstValidTransition(TransitionInput input) { for(Transition<TransitionInput> transition : transitions) { if(transition.isValid(input)) { return transition; } } return null; }
2
public Model createRDF(ArrayList<GeoEvent> geoArray){ Database db = Database.getInstance(); Model model = db.getModel(); for(GeoEvent geoEvent : geoArray){ String venueURL = geoEvent.getVenue().getUrl(); //Resource event and adding it's properties Resource event = model.createResource(geoEvent.getEve...
5
public long[][] loadArrays(String filename) { long [][] result=null; try (InputStream input = new FileInputStream(filename)) { List<String> lines = IOUtils.readLines(input); int count=0; for(String line:lines){ String[] numbers = line.split(" "); if(numbers.length>count){ count=numbers.length;...
5
public void testParseLocalDateTime_simple() { assertEquals(new LocalDateTime(2004, 6, 9, 10, 20, 30), g.parseLocalDateTime("2004-06-09T10:20:30Z")); assertEquals(new LocalDateTime(2004, 6, 9, 10, 20, 30), g.parseLocalDateTime("2004-06-09T10:20:30+18:00")); assertEquals(new LocalDateTime(2004, 6,...
1
public void play(Board board) { int[] sizes = board.getSizes(); for (int x = 0; x < sizes[0]; x++) { for (int y = 0; y < sizes[1]; y++) { for (Board.DIRECT direct : Board.DIRECT.values()) { Board.BoardIterator iterator = board.iterator(x, y); ...
8
public static Semester findBestSubjectSemester(Subject thisSubject){ int bestMark = -1; Semester bestSemester = null; for(Semester thisSemester:thisSubject.semesters){ if(thisSemester.mark > bestMark && thisSemester.usedState == Semester.UsedState.none){ ...
3
private List<ColumnConceptMappingDTO> getDicoFromConfiguration(final DataSetApplication datasetApp, final String dicoToFind) throws SitoolsException { List<ColumnConceptMappingDTO> colConceptMappingDTOList = null; // Get the list of dictionnaries related to the datasetApplication final List<Dicti...
4
public void visitCallMethodExpr(final CallMethodExpr expr) { expr.visitChildren(this); genPostponed(expr); int opcode; if (expr.kind() == CallMethodExpr.VIRTUAL) { opcode = Opcode.opcx_invokevirtual; } else if (expr.kind() == CallMethodExpr.NONVIRTUAL) { opcode = Opcode.opcx_invokespecial; } else i...
4
public CheckResultMessage checkG12(int day) { return checkReport.checkG12(day); }
0
@Override synchronized public void adjustClock(Clock receivedTimeStamp) { if (receivedTimeStamp == null) System.out.println("---------------------------debug: received group clock null!!"); Hashtable<String, Integer> tmpTimeStamp = (Hashtable<String, Integer>) receivedTimeStamp.getClock(); for (String tmpKey ...
4
public void setElement(ZElement elem, String index) { super.setElement(elem, index); if (elem != null) { MCDObjet obj = (MCDObjet) elem; obj.addLink(this); } if (elem1 instanceof MCDObjet && elem2 instanceof MCDAssociation) inverseZElements(); ...
3
public boolean fGuiCheckChildObjectExistence(WebElement objParent, String strDesc){ //Delimiters String[] delimiters = new String[] {":="}; String[] arrFindByValues = strDesc.split(delimiters[0]); //Get Findby and Value String FindBy = arrFindByValues[0]; String val =...
9
public float[] ProjectionHistograms() { // Horizontal Histogram float[] featureVector = new float[rows+columns]; int[] m_HorizontalFeatureVector = new int[rows]; int[] m_VerticalFeatureVector = new int[columns]; for (int i = 0; i < rows; i++) { int count = 0; for (int j = 0; j < columns; j++) { i...
8
private boolean isPhoneNumberAdded(PhoneNumber phoneNumber) { for(int i=0; i<addedPhoneNumberCount; i++) { PhoneNumber addedPhoneNumbers = phoneNumbers[i]; if(addedPhoneNumbers.getCountryCode() == phoneNumber.getCountryCode()) { if(addedPhoneNumbers.getAreaCode() == phoneNumber.getAreaCode()) ...
5
public void soundToggle(){ if(soundToggled){ soundToggled = false; } else { currentTime = beginTime; soundToggled = true; } }
1
public void SerializeRoom(ServerMessage Message, Room Room, int UsersNow, int Score) { Environment.Append(Room.Id, Message); if(Room.Event != null) { Environment.Append(true, Message); // is event Environment.Append(Room.Event.Name, Message); } else ...
7
public void loadFile(String filename) throws Exception { Map<String, Map<Integer, Double>> userMaps = new HashMap<>(); Map<String, Map<Integer, Double>> resMaps = new HashMap<>(); BookmarkReader reader = new BookmarkReader(0, false); reader.readFile(filename); List<Map<Integer, Integer>> userStats = Utilitie...
4
public void setcoef(float parseFloat) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. }
0
public boolean isAccept() { return getUnprocessedInput().length() == 0; }
0
public void setConnection( CommentConnection connection ) { if( this.connection != null ) { if( this.connection.getTargetItem() != null ) { this.connection.getTargetItem().removeDependent( this ); } } this.connection = connection; if( connection != null ) { if( connection.getTargetItem() != null ...
4
@Override public void keyPressed(KeyEvent e) { if ((Bildschirm.this.kenntEreignisanwendung != null) && (Bildschirm.this.kenntEreignisanwendung.fuehrtAus()) && (e.getKeyCode() != 17)) { if ((e.isActionKey()) || (e.getKeyCode() < 32) || (e.getKeyCode() == 127)) { Bildschirm.this.ke...
6
public boolean hasTeam(String team) { return TEAM_1.toString().equals(team) || TEAM_2.toString().equals(team); }
1
@Override public Settings clone() { Settings s = new Settings(); s.action_panel_color = new Color(this.action_panel_color.getRGB()); s.display_word_count = this.display_word_count; s.editor_path = this.editor_path; s.editor_use_env = this.editor_use_env; s.font_smoothing_value ...
4
private void setAptitud(String operacion, ArrayList<ArrayList<Integer>> restricciones) { int auxAptitud = 0; boolean bandera = true; for (int i = 0; i < restricciones.size(); i++) { int contador = 0; auxAptitud += restricciones.get(i).size(); for (int j = 0;...
7
public String convert(String s, int nRows) { int rows = nRows; Generator indexGenerator = new Generator(rows); StringBuffer[] buffers = new StringBuffer[rows]; for (int i = 0; i < rows; i++) buffers[i] = new StringBuffer(); int stringSize = s.length(); for (in...
3
public void addNewCircleData(int origX, int origY, int imgWidth, int imgHeight) { sortRequired = true; double pointsToPlot, angleIncrement; for(int radius = minR; radius <= maxR; radius++) { Circle c = new Circle(new Coordinate2D(origX, origY), radius); pointsToPlot = c.getPerimeter(); angleIn...
6
public boolean setPasswordButtonWidth(int width) { boolean ret = true; if (width < 0) { this.buttonPW_Width = UISizeInits.PW_BTN.getWidth(); ret = false; } else { this.buttonPW_Width = width; } somethingChanged(); return ret; }
1
public int compareTo(PolygonNew o) { if (compareArray(o.xpoints, xpoints) && compareArray(ypoints, o.ypoints) && npoints == o.npoints && r == o.r && g == o.g && b == o.b && transparency == o.transparency && order == o.order) { return 0; } else if (this.order > o.order) { return -1; } else { r...
9
static void db(Object o) { if (true) System.err.println(o); }
1
private boolean checkForChildren() throws ParsingException { XMLEvent e; try { do { e = eventReader.peek(); if (e.isCharacters()) { Characters c = e.asCharacters(); // Ignore empty content if (c.isWhiteSpace()) { eventReader.nextEvent(); } else { ...
4
private static void writeItems( final Collection itemCollection, final DataOutput dos, final boolean dotted) throws IOException { int size = itemCollection.size(); Item[] items = (Item[]) itemCollection.toArray(new Item[size]); Arrays.sort(items); for (int i =...
2
private Set<Card> nonStraightFiveFlush() { return convertToCardSet("TS,7S,9S,4S,8S,KC,QC"); }
0
public void send(String data, int port) { byte[] byte_data = data.getBytes(); DatagramPacket sendPacket = new DatagramPacket(byte_data, byte_data.length, host, port); try {sock.send(sendPacket);} catch (Exception e){} }
1
@Override protected void setReaction(Message message) { try { String query = getQuery(message.text); String response = loadResponse(query); reaction.add(message.author + ": " + response); } catch (Exception e) { setError(e); } }
1
public double getDexterity() { return dexterity; }
0
public void update(){ super.update(); if(getPosition()[0] < 0 && getVelocity()[0] < 0){ vel.setX(-vel.getX() * .8); } if(getPosition()[0] + sprite.W > Game.WIDTH/Game.scale && getVelocity()[0] > 0){ vel.setX(-vel.getX() * .8); } if(getPosition()[1]...
8
private int getLineCount(String text) { int count = 0; for (String line:text.split("\n")){ if (!line.equals("")){ count++; } } return count; }
2
public void finishReport(int rId, double similarity, String endTime) { try { String strStatement = ""; connect(); DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(Locale.GERMAN); otherSymbols.setDecimalSeparator('.'); DecimalFormat df = new DecimalFormat("###.##", otherSymbols); strSt...
2
public void run() { if (i <= n) { g2.clearRect(-150, -150, 300, 300); for (Line l : lines) { Complex tmp1 = f.evaluate(l.c1); double re1 = ((n - i) * l.c1.getRe() / n + i * tmp1.getRe() / n); double im1 = ((n - i) * l.c1.getIm() / n + i * ...
3
public void upadte() { time++; if (time == Integer.MAX_VALUE) time = 0; if (time % rate == 0) { if (frame >= legnth - 1) frame = 0; else frame++; sprite = sheet.getSprites()[frame]; } }
3
public String toString() { StringBuilder out = new StringBuilder(); if (items != null) { for (String s : items) { out.append(s); out.append("/"); } } return out.toString(); }
2
private boolean generalDevCardPreconditions(int playerIndex) { if (serverModel.getTurnTracker().getStatus().equals("Playing") && serverModel.getTurnTracker().getCurrentTurn() == playerIndex && !serverModel.getPlayers().get(playerIndex).hasPlayedDevCard()) { return true; } else { return false; } }
3
public static boolean arithmeticGreaterTest(NumberWrapper x, NumberWrapper y) { { Surrogate testValue000 = Stella_Object.safePrimaryType(x); if (Surrogate.subtypeOfIntegerP(testValue000)) { { IntegerWrapper x000 = ((IntegerWrapper)(x)); { Surrogate testValue001 = Stella_Object.safePrimaryT...
6
public void visitNewArrayExpr(final NewArrayExpr expr) { if (previous == expr.size()) { previous = expr; expr.parent.visit(this); } }
1
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { try { if (!(sender instanceof Player)) { return true; } Player player = (Player)sender; if (!HyperPVP.getGameSessions().containsKey(player.getName())) { sender.sendMessage(ChatColor.RED + ...
6
public void receivePacket(Cell cell) { for (Packet packet : cell.getPackets()) { if (packet.getDestination() == this) { if (!receiveLengths.containsKey(packet.getSource())) { receiveLengths.put(packet.getSource(), packet.getLength()); receiveCh...
9
@Override public boolean mayIntersect(S2Cell cell) { if (numVertices() == 0) { return false; } // We only need to check whether the cell contains vertex 0 for correctness, // but these tests are cheap compared to edge crossings so we might as well // check all the vertices. for (int i =...
7
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { try { sunJSSEX509TrustManager.checkServerTrusted(chain, authType); } catch (CertificateException excep) { excep.printStackTrace(); /* * Pos...
1
public void setLater(final boolean flag) { later = flag; if (SSAPRE.DEBUG) { System.out.println(this); } }
1
static public int emptyFolder(File folder, boolean ignoreCannotDel) throws IOException { int counter = 0 ; if(folder.exists() && folder.isDirectory()) { File[] child = folder.listFiles(); for(int i = 0; i < child.length; i++) { File file = child[i] ; if(file.isDirectory()) counter += emptyFolder(f...
6
/* */ public static boolean ClassListEqual(Class<?>[] l1, Class<?>[] l2) { /* 189 */ boolean equal = true; /* */ /* 191 */ if (l1.length != l2.length) return false; /* 192 */ for (int i = 0; i < l1.length; i++) { /* 193 */ if (l1[i] != l2[i]) { equal = false; break; /* */ } /* ...
5
@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 Report)) { return false; } Report other = (Report) object; if ((this.reportId == null && other.reportId != null...
5
public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) { if (par1World.getBlockMaterial(par3, par4, par5) != Material.water) { return false; } else { int var6 = par2Random.nextInt(this.numberOfBlocks - 2) + 2; ...
7
@EventHandler public void SnowmanMiningFatigue(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getsnowgolemConfig().getDouble("Snow...
6
@Override public int compareTo(Schedule sched) { int result = 0; if(this.fitness<sched.fitness) result = 1; else if(this.fitness>sched.fitness) result = -1; return result; }
2
@Override public int compare(Player a, Player b) { return a.hand.highCard.value < b.hand.highCard.value ? -1 : a.hand.highCard.value == b.hand.highCard.value ? 0 : 1; }
2
public void testFormatSuffixPlural4() { try { builder.appendSuffix(" hour", " hours"); fail(); } catch (IllegalStateException ex) {} }
1
@Override public boolean equals(Object pObj) { if(pObj != null) { if(pObj instanceof String) { return mName.equalsIgnoreCase((String) pObj); } if(pObj instanceof Namespace) { return mName.equals(pObj.toString()); } } return false; }
3
public ListNode mergeKLists(ArrayList<ListNode> lists) { ListNode superHead = new ListNode(0); ListNode insert = superHead; for (int i =0;i<lists.size();i++){ if (lists.get(i)==null){ lists.remove(i); i--; } } while (lists.s...
6
@Override public void repaint(Graphics2D g) { if (font == null) font = g.getFont(); if (scheme != null) g.setColor(scheme.text); g.setFont(font); String largestString = ""; int offset = 0; for (String str : leftColumn) { if (str == ...
7
public final LDAPConnection getConnection(final LDAPResource resource) throws LDAPException, InvalidBindPasswordException, InvalidBindUserException, ...
7
public static JsonObjectBuilder rewriteJson(JsonObjectBuilder copyInto,JsonValue tree,String key){ /** * Helper function used to parse json */ switch(tree.getValueType()){ case OBJECT: JsonObject obj = (JsonObject) tree; for(String name : obj.keySet()){ copyInto = rewriteJson(copyInto,obj.get(name...
3
@Override public Board getBoard() { return field; }
0
public double standardError_as_Complex_ConjugateCalcn() { boolean hold = Stat.nFactorOptionS; if (nFactorReset) { if (nFactorOptionI) { Stat.nFactorOptionS = true; } else { Stat.nFactorOptionS = false; } } Complex[] cc = this.getArray_as_Complex(); double standardError = Stat.standardErrorCon...
2
private static void uruchomTest(List lista, Integer iloscWatkow, Long czasOpoznienia) { LinkedList<Thread> testujace = new LinkedList<Thread>(); for (int i = 0; i < iloscWatkow; ++i) { testujace.add(new WatekTestujacy(lista)); } long startTime = System.currentTimeMillis(); for (Thread thread : testujace) {...
4
public Piece(int t, boolean w, int x, int y) { type = t; white = w; this.x = x; this.y = y; }
0
public static ArrayList<Token> buildTokens(String word, int line, int position) { ArrayList<Token> tokensOut = new ArrayList<>(); while (!"".equals(word)){ Token token; int wordLen = word.length(); char first = word.charAt(0); // Try building an identifier if (Character.isLetter(first)) token = ...
4
public void personsSearchAction() { String search = guicontroller.getPersonSearch(); ArrayList<User> validPersons = new ArrayList<User>(); for(User loopingUser:allUsers) { boolean valid = true; for(int i=0;i<loopingUser.getName().length() && i<search.length();i++) { if(!(search.charAt(i)==loopingUser.ge...
5
public double getMean(int i){ return getCell(i).getMean(); }
0
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } HLLWritable other = (HLLWritable) obj; if (!Arrays.equals(M, other.M)) { return false; } ...
8
public String toString(){ StringBuffer sb = new StringBuffer(); switch(type){ case TYPE_VALUE: sb.append("VALUE(").append(value).append(")"); break; case TYPE_LEFT_BRACE: sb.append("LEFT BRACE({)"); break; case TYPE_RIGHT_BRACE: sb.append("RIGHT BRACE(})"); break; case TYPE_LEFT_SQUARE: ...
8