text
stringlengths
14
410k
label
int32
0
9
public boolean isOfSameType(Type t) { if (t == null) return true; if ((t.isConstant || isConstant) && !t.actualType.equals("nil") && !actualType.equals("nil")) { String tbaseType = t.actualType; String baseType = actualType; if (dimensions != null) { baseType = actualType.split("...
9
public void ParseSource(String source) { this.Source = source.replaceFirst(":",""); String[] source_nicksplit = Source.split("!"); Nick = source_nicksplit[0]; String[] source_hostnamesplit = source_nicksplit[1].split("@"); Ident = source_hostnamesplit[0]; ...
0
@Override public void startSetup(Attributes atts) { super.startSetup(atts); addActionListener(this); }
0
public boolean peutAttaquerUnTerritoire(Territoire to){ List<Territoire> occupes = this.peuple.getTerritoiresOccupes(); // Recherche d'un territoire pouvant attaquer if (occupes.size() > 0) { Iterator<Territoire> it = occupes.iterator(); while (it.hasNext()) { Territoire tmp = it.next(); ...
3
public Polynomial gcd(Polynomial x) throws Exception { Polynomial a = monic(); Polynomial b = x.monic(); while (true) { if (a.degree() < b.degree()) { Polynomial t = a; a = b; b = t; } if (b.degree() < 0) re...
3
@Override /** * This function has to apply some change to colorArr Color c is curColor in * GridPanel */ public ArrayList<Delta> apply(Color c, int x, int y, Color[][] colorArr) { dMap = new ArrayList<>(); this.colorArr = colorArr; q = new LinkedList<>(); q.push(ne...
1
public CardPane() { }
0
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Observation other = (Observation) obj; if (!Arrays.equals(capteurs, other.capteurs)) return false; return true; }
4
private void fugit() { for(int i = 0;i < robotar.size();i++) { robotar.get(i).increaseLifetime(); } for(int i = 0;i < rp.size();i++) { rp.get(i).increaseLifetime(); } for(int i = 0;i < sp.size();i++) { sp.get(i).incr...
5
public static ArrayList<MusterReaction> findMusterReactionByTestId(ArrayList<MusterReaction> musterReactions, int id) { ArrayList<MusterReaction> outputReactions = new ArrayList<MusterReaction>(); for(MusterReaction mr:musterReactions) { if(mr.muster==id) { outputReactions.add(mr); } } return outputRe...
2
public static void main(String[] args) { new Compare().search( 5, 3, 4); }
0
private void qs(int low, int high){ int i = low; int j = high; //select middle element as a pivot int pivot = elements[ low + ((high - low)/2) ]; // split elements into two list while (i <= j){ // iterate through the left side, searching for elements // that are bigger...
6
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed // TODO add your handling code here: if(!jTextField7.isEnabled()){ jTextField7.setText(""); } if(!jTextField8.isEnabled()){ jTextField8.setText(""); ...
5
@Before public void setUp() { dynamicArray = new DynamicArray(); arrayList = new ArrayList(); }
0
public void drop(DropTargetDropEvent dtde) { // Method Instances boolean doChangePosition; TreePath pathAfter; int idxNew, idxOld; BrowserItems.DefaultTreeItem itemParent; BrowserItems.DefaultTreeItem itemSource; BrowserItems.DefaultTreeItem itemAfter; QueryTokens._Exp...
8
@Override public int hashCode() { int hash = 0; hash += (sucursalidSucursal != null ? sucursalidSucursal.hashCode() : 0); return hash; }
1
public void obterArvoreCMC(int raiz) throws Exception { int n = this.grafo.numVertices(); this.pesoAresta = new double[n]; int vs[] = new int[n + 1]; this.antecessor = new int[n]; for (int u = 0; u < n; u++) { this.antecessor[u] = -1; pesoAresta[u] = Double.MAX_VALUE; vs[u + 1] = u; } pesoA...
5
@Override // Viento HORA ESTADO KMS/H public InterfazCommand parse(String nombre) { double velViento = 0; String hora; InterfazCommand c = null; String[] atributos = nombre.split("\\s"); if (atributos.length >= 3) { if (atributos[0].equalsIgnoreCase("viento")) { hora = atributos[1]; Syst...
6
public static void initTimer(final int streamServerID, final String streamKey, final String id ){ timer = new Timer(); timer.schedule(new TimerTask() { public void run() { try { JGroovex.markStreamKeyOver30Seconds(0, streamServerID, streamKey, id); } catch (IOException e) { e.printStackTrace(...
1
public void visitMethodInsn( final int opcode, final String owner, final String name, final String desc){ if(mv != null) { mv.visitMethodInsn(opcode, owner, name, desc); } pop(desc); if(opcode != Opcodes.INVOKESTATIC) { Object t = pop(); if(opcode == Opcodes.INVOKESPECIAL && name.charAt(0) == '<'...
9
public void bfs(Node rt) { Queue<Node> q = new ArrayDeque<Node>(); if(rt != null) q.add(rt); while(!q.isEmpty()) { Node tNode = q.remove(); System.out.print(tNode.value+" "); if(tNode.left!=null) q.add(tNode.left); if(tNode.right!=null) q.ad...
4
private void initializeCommonRegions(int x) { this.commonRegions = new long[2][6][x]; for(int i=0; i<this.commonRegions.length; i++) { for(int j=0; j<this.commonRegions[0].length; j++) { for(int k=0; k<this.commonRegions[0][0].length; k++) { this.commonReg...
3
public static Field getField(Class cls, String fieldName) { Assert.notNull(cls, "cls cannot be null"); Assert.notNull(fieldName, "fieldName cannot be null"); // First check for public field using getField() Field field = null; try { field = cls.ge...
5
private static Object processJsonArrayAsCollection(JsonElement jsonElement, Class<?> parameterClass, Class<?> genericClass) throws JsonException, IllegalAccessException, InstantiationException { if (jsonElement.getType() != JsonType.ARRAY) throw new JsonException("Json Element is not Array"); if (!Coll...
7
public double backPropagate(double[] input, double[] output) { double new_output[] = execute(input); double error; int i; int j; int k; /* doutput = correct output (output) */ // Calcoliamo l'errore dell'output for(i = 0; i < fLayers[fLayers.length - 1].Length; i++) { error = output[i] - new...
7
private boolean setupPermissions() { RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class); perms = rsp.getProvider(); return perms != null; }
0
private static int calcLight(int radius, int radiusSq, int distX, int distY, double dither, Color color) { int distCenterSq = distY * distY + distX * distX; if (distCenterSq > radiusSq) { return 0; } return toData(((double) radius / (double) (distCenterSq)), dither, color); }
1
@Override public void mouseDragged(MouseEvent e) { List<GuiControl> controlList = new ArrayList<GuiControl>(); controlList.addAll(this.controlList); for (GuiControl c : controlList) c.mouseDragged(e); if (e.getModifiersEx() == MouseEvent.BUTTON3_DOWN_MASK) { scrollX -= e.getX() - diffX; scrollY -...
6
public static OpCode parseOpCode(String str) { for (OpCode op : values()) if (op.toString().equalsIgnoreCase(str)) return op; return null; }
2
public int integerBreak(int n) { if(n==2) return 1; if(n==3) return 2; int n3=n/3; int left=n-3*n3; int n2=0; if(left==1){ n3-=1; n2=2; }else if(left==2){ n2=1; } return Double.valueOf(Math.pow(3, n3) * Math.po...
4
@Override public void actionPerformed(ActionEvent e) { String teksti = syotekentta.getText(); if (!teksti.isEmpty()) { teksti = teksti.substring(0, teksti.length() - 1); syotekentta.setText(teksti); } }
1
public void createStatement(){ try { stmt = con.createStatement(); } catch (SQLException e) { e.printStackTrace(); } }
1
public static KernighanLin processWithVertices(Graph g, Set<Vertex> vertexSet) { Graph newG = new Graph(); for (Vertex v : vertexSet) newG.addVertex(v); for (Edge e : g.getEdges()) { Pair<Vertex> endpoints = g.getEndpoints(e); if (vertexSet.contains(endpoints.first) && ...
4
public boolean isSpaceAboveRobot() { if(robot.getLocation().y <= 0) return false; if(robot.getLocation().y <= GROUND_LEVEL) return true; for(Rectangle hole:holes) { if(((hole.y + hole.height) == robot.getLocation().y) && (robot.getLocation().x == hole.x)) { return true; } } return false; }
5
@Override public double convertTo(int type) { switch (type) { case UnitConstants.FEET_SECOND: return getValue() * 3.28084; case UnitConstants.FEET_MINUTE: return getValue() * 196.8504; case UnitConstants.MILES_MINUTE: return...
8
public GutterIconInfo[] getTrackingIcons(int line) throws BadLocationException { List retVal = new ArrayList(1); if (trackingIcons!=null) { int start = textArea.getLineStartOffset(line); int end = textArea.getLineEndOffset(line); if (line==textArea.getLineCount()-1) { end++; // Hack } f...
6
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ChangesetCounter that = (ChangesetCounter) o; if (counter != that.counter) return false; if (day != that.day) return false; if (hour !=...
8
private boolean bottomLeftCorner(int particle, int cubeRoot) { for(int i = 0; i < cubeRoot; i++){ if(particle == i * cubeRoot * cubeRoot){ return true; } } return false; }
2
@Override public void paint(Graphics g) { g.setColor(super.getBackground()); g.fillRect(0, 0, this.getWidth(), this.getHeight()); if(autosize) { if(selected) { Image tmp = this.highlighted.getImage().getScaledInstance(this.getWidth(), this.getHeight(), java.awt.Image.SCALE_SMOOTH); g.drawImag...
3
public void visitForceChildren(final TreeVisitor visitor) { if (visitor.reverse()) { expr.visit(visitor); } else { expr.visit(visitor); } }
1
static void v(DangerousMonster d) { d.menace(); d.destroy(); }
0
private void updateLiteralRuleAssociationList_addRule(final Rule newRule) throws TheoryException { // Set<Literal> literalList = newRule.getLiteralList(); Map<String, Rule> ruleList = null; // theory type checking if (newRule.hasTemporalInfo()) theoryType = TheoryType.TDL; else if (newRule.hasModalInfo() && ...
9
@Override public void prepareInternal(int skips, boolean assumeOnSkip) { //System.out.println("DelayUntil "+skips); if(isCachable()) { if (!assumeOnSkip) { move.prepareInternal(0, false); while(true) { State s = curGb.newState(); boolean ret = move.doMove(); curGb.restore(s); if(ret...
8
@Override public void update(Observable arg1, Object arg2) { if (this.controller != null) { LOGGER.log(Level.FINE, "Updating GUI"); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { LOGGER.log(Level.FINE, "Number of connected clients: " + client.getUsers().size()); ...
4
public void onKeyReleased(int key) { keys[key] = false; if (key == Keyboard.KEY_RIGHT && !keys[Keyboard.KEY_LEFT]) { player.setSpeed(0.0f, player.speed.y, player.speed.z); } if (key == Keyboard.KEY_LEFT && !keys[Keyboard.KEY_RIGHT]) { player.setSpeed(0.0f, player.speed.y, player.speed.z); } if (k...
9
private TokenizerProperty searchString(String image, boolean removeIt) { char startChar = getStartChar(image.charAt(0)); PropertyList list = getList(startChar); PropertyList prev = null; while (list != null) { TokenizerProperty prop = list._property; String ...
8
private void btnExcelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExcelActionPerformed final int totalFilas = this.table_ticket.getRowCount(); if (totalFilas > 0) { final String rutaExcel = dir.getRuta_excel(); final ArrayList<Ticket> tickets...
5
public boolean sendPocsagMessage(PocsagMessage message) { String tmp; if (serialPort == null ) { serialPort = openConnection(Config.btsPort, Config.btsBauds); if (serialPort == null) { return true; } } try { BufferedReader in = new BufferedReader(new InputStreamReader(serialPort...
8
private int buildMatchHistory(int match, JPanel panel, int maxRounds) { Vector columns = cdata.getColumnData(match); int numRounds = cdata.getNumRounds(match); int firstRound = 0; // for (int i=firstRound; i<numRounds; i++) { for (int i = numRounds - 1; i >= 0; i--) { Color backColor; // if ((i % 2 == ...
9
private void drawMenu(Graphics2D g){ g.setColor(Color.WHITE); g.drawString("ASTEROIDS", (getWidth()-fm.stringWidth("ASTEROIDS"))/2, 100); if (mainMenuTextAreas[0].contains(MouseInfo.getPointerInfo().getLocation())) g.setColor(Color.RED); else g.setColor(Color.WHITE); g.drawString("Play", (getWidt...
5
public static void convertFolderToXML(String dir, boolean recursive) { File file = R2DFileUtility.getResource(dir); if(!file.exists() || !file.isDirectory()) return; R2DFileFilter filter = new R2DFileFilter(); for(File f : file.listFiles()) { //Log.debug(f.isFile()+" "+filter.accept(file, f.getName()))...
8
private String needAbort(String transaction, Set<String> conflicts) { transactionEntity thisone = transInfo.get(transaction); for (String conflict : conflicts) if (thisone.timestamp > transInfo.get(conflict).timestamp) return conflict; return null; }
2
public boolean isValid() { return this.valid; }
0
public String getCameraType () { switch (statusTable [1]) { // case 0: ? // case 1: return "DC-50"; // case 2: return "DC-120"; // case 3: return "DC-200"; // case 4: return "DC-210/215"; case 5: return "DC-240"; case 6: return "DC-280"; // FIXME: case 7: return "DC-3400 (?)"; ca...
4
public static void main (String args[]) { Map<String, String> map = new HashMap(); fillData(map); for (String key : map.keySet()) { System.out.println(key + " " + map.get(key)); } map.put("Added lately", "testing"); map.remove("Intellij"); for (Str...
2
public static void main(String[] args) { for (int i = 1; i <= 1000; i++) { /** * This is true if the number is divisible by 3. */ final boolean fizz = i % 3 == 0; /** * This is true if the number is divisible by 5. */ ...
5
public static void defend(SimulatedPlanetWars simpw) { //send ships from the lowest growing planet to the best one // Tested int maxGR = 0; int minGR = 5; Planet source = null; Planet dest = null; for (Planet p : simpw.MyPlanets()){ if (p.GrowthRate()>maxGR){ maxGR = p.GrowthRate(); dest = p; ...
5
private void doFinishAction() { switch (finishAction) { case (NONE) : break; case (HIDE) : { if (component instanceof GUIComponentGroup) { ((GUIComponentGroup) component).hide(); } break; } case (...
7
public Boolean isStringValid(String in) { //System.out.println("M " + in + " M"); Boolean returnVal=Boolean.TRUE; if (in==null || in.length()==0) return returnVal; Stack<Character> stk=new Stack<Character>(); try { for (Character x: in.toCharArray()) { if (startChars.indexOf(x)!=-1) stk.push(...
9
public static boolean isServerUpdateAvailable() { if( Settings.isOfflineMode() ) return false; File tempFile; boolean missingFile = false; boolean outOfDateFile = false; refreshLookupValues(); // Loop over local and remote application versions // If there is a difference in the version, there...
6
public Read() throws IOException { byte [] b = new byte [50000]; String fileName = System.getProperty("user.dir") + "/output/test.mp3"; File inputFile = new File(fileName); InputStream is = new FileInputStream(inputFile); is.read(b,0,50000); for...
5
private int[] defaultRgbArray(int width, int height) { int[] rgbs = new int[width * height]; // fill everything with UnpassableSandTiles Arrays.fill(rgbs, 0xffA8A800); // add SandTiles for player bases for (int y = 0 + 4; y < height - 4; y++) { for (int x = (width / 2) - 5; x < (width / 2) + 4; x++) { ...
4
public boolean initGUI() { InventoryOpenEvent ioe = new InventoryOpenEvent(this); Bukkit.getPluginManager().callEvent(ioe); if(ioe.isCancelled()) return false; cont.setLayout(ContainerType.OVERLAY).setAnchor(WidgetAnchor.CENTER_CENTER).setWidth(width).setHeight(height).setX(-width/2).setY(-height/2); con...
5
protected void drawDays() { Calendar tmpCalendar = (Calendar) calendar.clone(); tmpCalendar.set(Calendar.HOUR_OF_DAY, 0); tmpCalendar.set(Calendar.MINUTE, 0); tmpCalendar.set(Calendar.SECOND, 0); tmpCalendar.set(Calendar.MILLISECOND, 0); Calendar minCal = Calendar.getIns...
9
public static void main(String[] args) { EntityManagerFactory emf = Persistence.createEntityManagerFactory("GSB-2014-eq1_initialPU"); }
0
public ColorPallet(ColorPalletState initColorPalletState) { // WE'LL KEEP THE STATE, SINCE WE'LL USE // IT EVERY TIME WE REFRESH state = initColorPalletState; XMLUtilities xmlloader = new XMLUtilities(); Document palletSettings = null; try { palle...
7
public void chgDir() { switch(dir) { case 0: sprt = img1.getImage(); if(Game.tickCount2 == game.DELAY){ dir = 1; } break; case 1: sprt = img2.getImage(); if(Game.tickCount2 == game.DELAY){ dir = 0; } break; case 2: sprt = img3.getImage(); if(Game.tickCount...
8
public void setUserlistImagePadding(int[] padding) { if ((padding == null) || (padding.length != 4)) { this.userlistImg_Padding = UIPaddingInits.USERLIST_IMAGE.getPadding(); } else { this.userlistImg_Padding = padding; } somethingChanged(); }
2
public String getSource() { return Source; }
0
private final String getChunk(String s, int slength, int marker) { StringBuilder chunk = new StringBuilder(); char c = s.charAt(marker); chunk.append(c); marker++; if (isDigit(c)) { while (marker < slength) { c = s.charAt(marker...
5
@Override public void execute() { p.setBackground(Color.white); }
0
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub JSONObject jb = new JSONObject(); InputStreamReader reader = new InputStreamReader(request.getInputStream(), "utf-8"); String receivedString = ""; ...
6
@Override public void setForeground(Color color) { mColor = color; if (mLink == null || mLink.getClientProperty(ERROR_MESSAGE_KEY) == null) { super.setForeground(color); } }
2
public static double evaluateState(SimulatedPlanetWars pw){ // CHANGE HERE double enemyShips = 1.0; double myShips = 1.0; for (Planet planet: pw.EnemyPlanets()){ enemyShips += planet.NumShips(); } for (Planet planet: pw.MyPlanets()){ myShips += planet.NumShips(); } return myShips/en...
2
public static void EndTimeReport() { FileWriter fstream =null; BufferedWriter out =null; String ENDTIME = now("hh:mm:ss").toString(); try { fstream = new FileWriter(filename, true); out = new BufferedWriter(fstream); out.write("<table border=1 cellspaci...
1
public int lengthOfLongestSubstring(String s) { if(s.length()==0) { return 0; } int j=1; for(; j<s.length(); j++) { int i=0; for(; i<j; i++) { if(s.charAt(i)==s.charAt(j)) { break; } } ...
6
public IntNode getLink( ) { return link; }
0
public static void main(String args[]) { //<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://download.oracle.com/java...
3
public JSONArray toJSONArray(JSONArray names) throws JSONException { if (names == null || names.length() == 0) { return null; } JSONArray ja = new JSONArray(); for (int i = 0; i < names.length(); i += 1) { ja.put(this.opt(names.getString(i))); } re...
3
public static String typeName(char _typeChar) { String returnName = null; switch (_typeChar) { case SIGC_VOID: returnName = "void"; break; case SIGC_INT: returnName = "int"; break; case SIGC_DOUBLE: returnName = "double";...
9
public synchronized void actionPerformed(ActionEvent event) { Object target = event.getSource(); if (target instanceof MenuItem) { MenuItem item = (MenuItem)target; int[] indexes = fOnlineList.getSelectedIndexes(); if (indexes...
8
public void setAddress2(String address2) { this.address2 = address2; }
0
private void trInsertionSort (final int ISA, final int ISAd, final int ISAn, int first, int last) { final int[] SA = this.SA; int a, b; int t, r; for (a = first + 1; a < last; ++a) { for (t = SA[a], b = a - 1; 0 > (r = trGetC (ISA, ISAd, ISAn, t) - trGetC (ISA, ISAd, ISAn, SA[b]));) { do { SA[b +...
6
public PainelDesenho() { super(); this.addMouseListener(new EventosMouse()); objetos = new ArrayList<FiguraGeometrica>(); }
0
public void writeFile() { File file=new File("monsters.dat"); FileOutputStream fout; ObjectOutputStream out; try { fout=new FileOutputStream(file); out=new ObjectOutputStream(fout); out.writeObject(current_id-2); out.flush(); for(int i=0; i<current_id-1; i++){ out.writeObject(monsters.get...
3
public Tea() { this.setName("Coffee"); this.setPrice(new BigDecimal(15)); }
0
public static Session getInstance() { if (instance == null ) { instance = new Session(); } return instance; }
1
private static void writeToFile(String out) { if (fileWriter == null) { try { fileWriter = new FileWriter("out.log"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } try { fileWriter.write(out); } catch (IOException e) { // TODO Auto-generated cat...
4
public void setjTextFieldCP(JTextField jTextFieldCP) { this.jTextFieldCP = jTextFieldCP; }
0
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; PacketVO other = (PacketVO) obj; if (packetId != other.packetId) return false; return true; }
4
public void update() { Window window = Window.getInstance(); JPanel panel = window.getPanel(); if (pauseDelay > 0) pauseDelay--; if (keyboard.isDown(KeyEvent.VK_P) && pauseDelay <= 0) { if (!paused) { ...
9
public String getBackground() { if (styles == null) { return null; } else { return styles.get("bg"); } }
1
public short evaluate_short(Object[] dl) throws Throwable { if (Debug.enabled) Debug.println("Wrong evaluateXXXX() method called,"+ " check value of getType()."); return 0; };
1
public double[] rawItemMedians(){ if(!this.dataPreprocessed)this.preprocessData(); if(!this.variancesCalculated)this.meansAndVariances(); return this.rawItemMedians; }
2
private void printFinals(int maxRound, ArrayList<Match> finals, ArrayList<Match> sFinals, ArrayList<Match> qFinals) throws SQLException { /* * Quarter Finals */ if (maxRound >= 7) { printShowQFinalHeader(); for (Match m : qFinals) { ...
6
public TarHeader readNextFileHeader() throws IOException { if(this.lastHeader != null) { throw new RuntimeException("Must first read file content of last entry"); } // Read a complete File entry byte[] header = new byte[512]; do { if(-1 == Util.readBloc...
3
private long neuerZaehler(char operation, Bruch tmpBruch2) { // Anhand der übergebenen Operation wird die Rechnugn durchgeführt switch (operation) { case '+': return (this.zaehler * tmpBruch2.nenner) + (tmpBruch2.zaehler * this.nenner); cas...
4
public static void zoom(Model3D m, double d, int w, int h) { if (h < 6 || w < 6) return; m.setDecalageX(w / 2); m.setDecalageY(h / 2); double smlX = w, hgX = 0, smlY = h, hgY = 0; for (int i = 0; i < m.getPoints().size(); i++) { if (m.getPoints().get(i).x < smlX) { smlX = m.getPoints().get(i).x; ...
8
public Person2(int id, String Name, Double height) { this.id = id; this.Name = Name; this.height = height; }
0
public boolean isProduction(Production production) { return myProductions.contains(production); }
0