text
stringlengths
14
410k
label
int32
0
9
public boolean checkNick(String nick) { Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; try { conn = getConnection(); pstmt = conn .prepareStatement("select nickname from member where nickname=?"); pstmt.setString(1, nick); rs = pstmt.executeQuery(); if (rs.ne...
8
@Override public Vector solve(Basis b) { BigInteger[][] big = convertToBigInteger(b); LLL.integral_LLL(big, big.length, big[0].length); // TODO: Not actually necessary to do this conversion, // because we have to convert to double for solving linear equations int[][] reduc...
8
private void openSerialPort(CommPortIdentifier commPortIdentifier) { if (openedPort != null) { serialPort.close(); } if (commPortIdentifier != null) { try { serialPort = (SerialPort) commPortIdentifier.open("MonitorConsole", 2000); } ...
6
public boolean render(Level var1, int var2, int var3, int var4, ShapeRenderer var5) { boolean var6 = false; float var7 = 0.5F; float var8 = 0.8F; float var9 = 0.6F; float var10; if(this.canRenderSide(var1, var2, var3 - 1, var4, 0)) { var10 = this.getBrightness(var1, var2, var3 - 1, var4); var5.color(v...
6
public Tester(String name) { this.name = name; }
1
public void updateDrawableRect(int compWidth, int compHeight) { int x = currentRect.x; int y = currentRect.y; int width = currentRect.width; int height = currentRect.height; //Make the width and height positive, if necessary. if (width < 0) { width = 0 - widt...
7
public synchronized void update() { //Check the collision of the between the robot and the walls. checkTileMapCollision(); updatePosition(); //Animation if (currentAnimation == SCRATCH) { if (animation.hasPlayedOnce()) { isScratching = false;...
5
public static int floodFill(State s) { // Initialization Queue<Position> fringe = new LinkedList<>(); Set<Position> visitedStates = new HashSet<>(); fringe.add(s.player); visitedStates.add(s.player); while (fringe.size() > 0) { //Pop new state Po...
8
@Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { log.debug("{} public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException:", getClass()); log.debug("params: uri={}, localName={}, qName={}, attrs=...
7
private void GenerateAttackPayloadsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GenerateAttackPayloadsButtonActionPerformed PreparedStatement ps = null, ps_attack = null; ResultSet rs = null; Connection conn = null; String HTTPRequest = "", ParameterName = "", ParameterValue ...
9
public Emage buildEmage(Timestamp lastEmageCreationTime, long windowSizeMS) { filterPointQueueByWindow(windowSizeMS); this.pointQueue.addAll(this.pointStream.getAndClearNewPointsQueue()); Iterator<STTPoint> pointIterator = this.pointQueue.iterator(); GeoParams geoParams = this.pointStream.getGeoPar...
9
@EventHandler public void MagmaCubeWither(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.getMagmaCubeConfig().getDouble("MagmaCube...
6
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 static String clasificar(String path){ DiccionarioXml dic = new DiccionarioXml("/home/borja/proyectos/ecloud/logica/palabras.xml"); String palabras[]=dic.getPalabras(); /*for(String palabra:palabras) System.out.println(palabra); */ ArrayList<Integer> contadoresTema= new ArrayList<Int...
9
public String getQuantity() { return quantity; }
0
public static final void safeShutdown(final boolean restart, int delay) { if (exiting_start != 0) return; exiting_start = Utils.currentTimeMillis(); exiting_delay = (int) delay; for (Player player : World.getPlayers()) { if (player == null || !player.hasStarted() || player.hasFinished()) continue; ...
9
public boolean add(Administrador admin){ PreparedStatement ps; try { ps = mycon.prepareStatement("INSERT INTO Administradores VALUES(?,?,?)"); ps.setString(1, admin.getNombre()); ps.setString(2, admin.getPassword()); ps.setString(3, admin.getDNI()); ...
1
protected void updateEntityActionState() { ++this.entityAge; if (this.entityAge > 100) { this.randomMotionVecX = this.randomMotionVecY = this.randomMotionVecZ = 0.0F; } else if (this.rand.nextInt(50) == 0 || !this.inWater || this.randomMotionVecX == 0.0F && this....
6
public boolean canCreateUnit(int id) { if (id >= 11 && id <= 16 && candy >= candyTable.get(id)) return true; else return false; }
3
public boolean carOnLane(Car fCar, Lane lane) { double x = fCar.getPosition().getX(); double y = fCar.getPosition().getY(); if (x >= lane.getMinX() && x <= lane.getMaxX() && y >= lane.getMinY() && y <= lane.getMaxY()) { return true; } return false; }
4
@Override public void actionPerformed(ActionEvent e) { //System.out.println("EndAction"); OutlinerCellRendererImpl textArea = null; boolean isIconFocused = true; Component c = (Component) e.getSource(); if (c instanceof OutlineButton) { textArea = ((OutlineButton) c).renderer; } else if (c instanceo...
7
public void menuTextAsym() { int choice; do { System.out.println("\n"); System.out.println("Text Cryption Menu"); System.out.println("Select Asymmetric Cryption Methode"); System.out.println("----------------------------------\n"); System.out....
5
public static void readRelevanceJudgments( String p,HashMap < String , HashMap < Integer , Double > > relevance_judgments){ try { BufferedReader reader = new BufferedReader(new FileReader(p)); try { String line = null; while ((line = reader.readLine()) != null){ // parse th...
8
public static void UpdateStateTestImageTransform() { int selection = m_MenuTestImageTransform.UpdateMenuKeys(); switch (selection) { case MENU.TEST_IMAGE_TRANSFORM.OPT_IMAGE_TRANS_NONE: case MENU.TEST_IMAGE_TRANSFORM.OPT_IMAGE_TRANS_ROT90: case MENU.TEST_IMAGE_TRANSFORM.OPT_IMAGE_TRANS_ROT180: case MEN...
9
public static GameMode getGameMode(String gamemode) { if (gamemode.equalsIgnoreCase("survival") || gamemode.equalsIgnoreCase("0")) { return GameMode.SURVIVAL; } else if (gamemode.equalsIgnoreCase("creative") || gamemode.equalsIgnoreCase("1")) { return GameMode.CREATIVE; } else if (gamemode.equalsIgn...
6
@Override public String runMacro(HTTPRequest httpReq, String parm, HTTPResponse httpResp) { final java.util.Map<String,String> parms=parseParms(parm); if(parms.containsKey("CURRENT")) return Integer.toString(httpReq.getClientPort()); if(Thread.currentThread() instanceof CWThread) { final CWConfig config...
7
public boolean isSeed() { return this.torrent.isComplete(); }
0
public int get(int key) { if(map.containsKey(key)){ Node n=map.get(key); if(n.prev!=null){ if(dll.last==n) dll.last=n.prev; n.prev.next=n.next; if(n.next!=null) n.next.prev=n.prev; n.p...
4
public ArrayList<Object> selectPath() { if(paths.size() == 0) { System.out.println("Path not found."); } else { if(paths.size() == 1) { System.out.println("One path founded."); printPaths(); return paths.get(0); } else { Scanner scanner = new Scanner(System.in); boolean ...
6
public void connect() throws ConnectionException, IOException { if(clientConnection == null || clientConnection.isClosed()) { try { clientConnection = new ServerSocket(port); Fluid.log("Target: Accepting connections on port " + port); } catch(BindException e) { throw new ConnectionException(e); ...
7
@Override public void render(PApplet g) { g.pushMatrix(); g.translate(x, y); g.rotate(theta); g.scale(PIXEL_WIDTH, -PIXEL_WIDTH); g.noSmooth(); g.imageMode(PConstants.CENTER); switch (animationState) { case UP: if (!hitOnce) g.image(sprite1, 0, 0); else g.image(hitSprite1, 0, 0); brea...
9
public int jump(int[] A) { int steps = 0, max = 0, next = 0; for (int i = 0; i < A.length - 1 && next < A.length - 1; i++) { max = Math.max(max, i + A[i]); if (i == next) { // ready to jump if (max == next) return -1; // unreachable next = max; steps++; } } return steps; }
4
public int run (String[] args) throws Exception { long startTime = System.currentTimeMillis() / 1000L; for(int i = 0; i < args.length; i++){ System.out.println(i + " : " + args[i]); } if (args.length < 2) { System.err.printf("Usage: %s [Hadoop Options] <d> <maxDimensions> <dataSets> <key> <input>...
6
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 fe...
6
private boolean isElementPresent(By by) { try { driver.findElement(by); return true; } catch (NoSuchElementException e) { return false; } }
1
@Test public void testMetadataRetrieval() throws SQLException { Populator p = new Populator(); System.err.println(p.metaDataDao.tableNames("linse")); System.err.println(p.metaDataDao.foreignKeys()); }
0
public Boolean leftFantasma(int n){ Query q2; switch(n){ case 0: q2 = new Query("leftBlinky"); return q2.hasSolution(); case 1: q2 = new Query("leftClyde"); return q2.hasSolution(); case 2: ...
4
@EventHandler public void CreeperInvisibility(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.getCreeperConfig().getDouble("Creeper...
6
private Point[] getItemCoordinates() { switch (GameLevel.currentLevel) { case 3: Point[] level_3 = {new Point(195, 75), new Point(195, 135), new Point(255, 135)}; return level_3; case 4: Point[] level_4 = {new Point(225, 45), new Point(225...
8
@Override public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if (args.length == 0) { TimeBanHelpCommand command = new TimeBanHelpCommand(plugin); command.setManPage("help"); if(sender != null && sender instanceof...
8
public String getShopAddress() { return shopAddress; }
0
public void setDate(int year, int month, int day) { //verify the year is in bounds if (year < 1867 || year > Calendar.getInstance().get(Calendar.YEAR)){ return; } //verify month if (month < 0 || month > 12) { return; } //v...
6
public String execute(HttpServletRequest request, HttpServletResponse arg1) throws Exception { ResourceBundle bundle = Resource.getInstance().getRequestToObjectMap(); this.txtId = generalTools.NullToEmpty((String)request.getParameter("txtId")); this.txtDescription = generalTools.NullToEmpty((String)request....
9
public static Date getDateParam(SessionRequestContent request, String name){ String param = (String) request.getParameter(name); if (param != null && !param.isEmpty()) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); try { Date currDate = formatte...
3
public boolean isInChannel(String channel, String bot) { for (User user : getUsers(channel)) { if (bot.equalsIgnoreCase("%note") && user.getNick().equalsIgnoreCase("Kitteh")) { return true; } if (bot.equalsIgnoreCase("!note") && user.getNick().equalsIgnoreCase...
8
public static final boolean isNumeric(String str) { int length; if (str == null || (length = str.length()) == 0) { return false; } char[] chars = str.toCharArray(); do { // 48-57 if (chars[--length] < '0' || chars[length] > '9') { return false; } } while (length > 0); return true; }
5
public File unzipFile(ZipFile in, File fileLocationOnDiskToDownloadTo) throws IOException { FileOutputStream dest; Enumeration<? extends ZipEntry> zipFileEnum = in.entries(); while (zipFileEnum.hasMoreElements()) { ZipEntry entry = zipFileEnum.nextElement(); File destFile...
3
public void initWindow(boolean full) { // Create game window... setIgnoreRepaint( true ); setResizable(false); this.addWindowListener(this); // Add the WindowListening events to the GameWindow if(full) { // Disable fullScreen this.setSize(WIDTH, HEIGHT); this.setUndecorated(true); gd.setFullScreenW...
2
public static int arrayDimension(String desc) { int dim = 0; while (desc.charAt(dim) == '[') ++dim; return dim; }
1
private static Date parseDateWithLeniency(String str, String[] parsePatterns, boolean lenient) throws ParseException { if (str == null || parsePatterns == null) { throw new IllegalArgumentException("Date and Patterns must not be null"); } SimpleDateFormat parser ...
8
protected Result parseInsruction(String nextInstruction) { String[] parsed = nextInstruction.split("\\s+"); if (parsed.length > 4){ return Result.createError(Errors.TOO_MANY_PARAMS, nextInstruction); } if(allowableCommands.contains(parsed[CMDINDX])){ //further processing if ( "GET".equals(pars...
8
public Bipartite(Graph G) { marked = new boolean[G.V()]; color = new boolean[G.V()]; isBipartite = true; for (int v = 0; v < G.V(); v++) if (!marked[v]) { dfs(G, v); } }
2
private boolean evaluateBuildRBondClause(String str) { String[] s = str.split(REGEX_SEPARATOR); if (s.length != 3) return false; int n = model.getAtomCount(); double x = parseMathExpression(s[0]); // index of atom 1 if (Double.isNaN(x)) return false; int i = (int) x; if (i >= n) { out(ScriptEvent...
8
@Test public void test2(){ String outputString = ""; String buffer = ""; File data = new File("german"); try { BufferedReader reader = new BufferedReader(new FileReader(data)); while((buffer = reader.readLine()) != null) { outputString += buffer; buffer = null; } } catch (FileNo...
5
public void clear() { final Iterator iter = iterator(); while (iter.hasNext()) { ((Stmt) iter.next()).cleanup(); } super.clear(); }
1
@Override public void startSetup(Attributes atts) { outliner = this; setTitle(atts.getValue(A_TITLE)); // Load Preferences loadPrefsFile(PARSER, ENCODINGS_FILE); // Setup the FileFormatManager and FileProtocolManager fileFormatManager = new FileFormatManager(); fileProtocolManager = new FileProtocolMa...
0
Grid (){ //gen 4x4 grid = new ArrayList<>(4); //gen y then x for (int i = 0; i < 4; i++) { grid.add(new ArrayList<Tile>()); for (int j =0 ; j < 4; j++){ grid.get(i).add(null); } } for (int i = 0; i < 2; i++) { if(!genTile()){ System.err.println("Grid: ctor> Grid full or could not gen ...
4
public void eliminaUltimo(){ if(this.inicio == null){ System.out.println("La lista esta vacia"); }else{ if(this.inicio.getLiga() == null){ this.inicio = null; }else{ Nodo<T> nodoQ = this.inicio; Nodo<T> nodoT = null; while(nodoQ.getLiga() != null){ nodoT = nodoQ; nodoQ = nodoQ.get...
3
@Override public boolean sendDeath() { WorldTasksManager.schedule(new WorldTask() { int loop; @Override public void run() { if (loop == 0) { player.setNextAnimation(new Animation(836)); } else if (loop == 1) { player.getPackets().sendGameMessage( "Oh dear, you have died."); } e...
9
public void setForecastDayAndNight(int aftertoday,Iterator<Element>tempit,WeatherInfo tempweather,int isNight){ Element tempElement; int i=0; while(tempit.hasNext()){ tempElement=tempit.next(); switch (i) { case 0:tempweather.setForecasttype(aftertoday, tempElement.getText(), isNight);break; case 1:te...
4
public static void main(String... args) { int biggestNum = 0; for (int i = 1000 - 1; i >= 100; i--) { for (int j = 1000 - 1; j >= 100; j--) { int target = (i * j); if (isPalindrome(target) && target > biggestNum) { biggestNum = target; ...
4
public void set(int symbol, int freq) { if (symbol < 0 || symbol >= frequencies.length) throw new IllegalArgumentException("Symbol out of range"); if (freq < 0) throw new IllegalArgumentException("Negative frequency"); total = checkedAdd(total - frequencies[symbol], freq); frequencies[symbol] = freq; ...
3
public void activate(Robot paramRobot, int paramInt) { super.activate(paramRobot, paramInt); if (this.state != null) { Vector localVector = this.state.getSpecialProgramParts(); Enumeration localEnumeration = localVector.elements(); while (localEnumeration.hasMoreElements()) if ((lo...
3
private static void readSettings(){ //Checkbox was changed: Save changes to wini Wini ini; //Ini handler boolean firstSetup = false; try{ File settings = new File(NineManMill.settingsfile); if (!settings.exists()) { //If settings file does not exist, leave the default values settings.createNewFile...
5
protected String removeCDATA(String title) { return ( title.indexOf("<![CDATA[") != NOT_FOUND ) ? title.substring(9, title.length() - 3) : title; }
1
private void btnCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCerrarActionPerformed //Cierra la interfaz de registro setVisible(false); }//GEN-LAST:event_btnCerrarActionPerformed
0
@Override public void startUp(GameTime gameTime) { // Call the startUp methods of all the register GameLayers super.startUp(gameTime); // Change the mouse GameEngine.setCustomCursor(GameAssetManager.getInstance().getObject(BufferedImage.class, Configuration.GUI.Misc.GAME_MOUSE)); // Realign all of the m...
2
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed // TODO add your handling code here: String file_name = "storage.txt"; try { ReadFile file = new ReadFile(file_name); String[] aryLines = file.OpenFile...
2
public void setInitialHeight(int initialHeight) { this.initialHeight = initialHeight; }
0
public void setFirstName(String firstName) { this.firstName.set(firstName); }
0
@Override public void dragOver(DropTargetDragEvent event) { TreePanel panel = getPanel(); int x = panel.toHeaderView(new Point(event.getLocation())).x; TreeColumn overColumn = panel.overColumn(x); if (overColumn != null && overColumn != mColumn) { ArrayList<TreeColumn> columns = new ArrayList<>(panel.getCol...
9
private void closeOpenInterfaces() { // clearTopInterfaces outputStream.writeOpcode(130); if (invOverlayInterfaceID != -1) { invOverlayInterfaceID = -1; needDrawTabArea = true; aBoolean1149 = false; tabAreaAltered = true; } if (backDialogID...
2
@Override public void update(double time) { if (Input.getKeyDown(Keyboard.KEY_W) || Input.getKeyDown(Keyboard.KEY_UP)) { if (selectedOption > 0) { selectedOption--; } } if (Input.getKeyDown(Keyboard.KEY_S) || Input.getKeyDown(Keyboard.KEY_DOWN)) { if (selectedOption < 1) { selectedOption++; }...
7
public void run(){ RConsole.openUSB(10000); long updateStart, update; boolean objectDetected = false; boolean obstacle = false; boolean foam = false; int buffer = 0; while (true) { updateStart = System.currentTimeMillis(); ColorSensor.Color vals = censor.getColor(); ColorSensor.Col...
8
private void optimizeMathe(){ //Mathe: 4 hjs mandatory if(myData.subjects[MATHE].writtenExamSubject==false){ int hjsToAdd; if(myData.subjects[MATHE].oralExamSubject==true){ hjsToAdd = 3; //since 13.2 is already in C } else {hjsToAdd = 4;} ...
4
public static void main(String[] args) { System.out.println(ncr(40, 20)); }
0
public static void closeDatabaseEngine() throws SQLException { try { dbProperties.put("shutdown", "true"); DriverManager.getConnection(dbProperties.getProperty("derby.url"), dbProperties); } catch (SQLException ex) { dbProperties.remove("shutdown"); // ...
3
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Stage other = (Stage) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return fals...
6
public void put(Object o) { addFirst(o); }
0
public static void main(String[] args) { // Listは宣言時に値を設定できる。 List<String> list1 = Lists.newArrayList("hoge", "huga", "piyo", "tao", "tarou"); SimpleLogger.debug(list1.toString()); // newHashMapは宣言時に値を設定できない、ImmutableMapはできるけど。 Map<String, Person> map1 = Maps.newHashMap(ImmutableMap.of( // "hoge", n...
2
private int popupSauvegarde () { if ( this.fileName == null ) return JOptionPane.CLOSED_OPTION ; int choix = GUIUtilities.question_YES_NO_CANCEL (Utilities.getLangueMessage( Constantes.MESSAGE_SAUVEGARDER_FICHIER_ENCOURS )) ; if (choix == JOptionPane.YES_OPTION) save(); ...
2
public static Subject[] findFLangSubjects(Data myData) { List<Subject> results = new ArrayList<>(); results.add(myData.subjects[ITA]); for(Subject thisWahlfach:myData.getWahlfaecher()) { if(thisWahlfach.getSubjectType()==FOREIGN_LANG) results.add(thisWahlfach); } i...
3
public void actionPerformed(ActionEvent e) { if (btnReadRow == e.getSource()) { try { readRow(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else if (btnWriteRow == e.getSource()) { writeRow(); } else if (btnReadCol == e.getSource()) { ...
8
private final void method1595(byte i, int i_17_, ByteBuffer class348_sub49) { anInt2852++; if (i >= 5) { if ((i_17_ ^ 0xffffffff) == -2) ((Class218) this).anInt2853 = class348_sub49.getShort(); else if ((i_17_ ^ 0xffffffff) != -3) { if (i_17_ == 3) ((Class218) this).aBoolean2854 = true...
5
public TriangleContainer clone(){ TriangleContainer ret = new TriangleContainer(); if (leftAnglePoint!=null) ret.leftAnglePoint = new Point3D(leftAnglePoint); if (topAnglePoint!=null) ret.topAnglePoint = new Point3D(topAnglePoint); if (rightAnglePoint!=null) ret.rightAnglePoint = new Poi...
8
public static boolean containsElement(Object[] array, Object element) { if (array == null) { return false; } for (Object arrayEle : array) { if (nullSafeEquals(arrayEle, element)) { return true; } } return false; }
3
public DynamicArray() { this.array = new Object[10]; this.size = 0; }
0
public SkillsPanel(EVECharacter character){ this.character = character; setLayout(new BorderLayout()); DBHandler db = new DBHandler(); for(int i=0;i<character.getSkills().size();i++){ Skill currentSkill = character.getSkills().get(i); if( isGroupExists(currentSkil...
9
public static <GInput, GOutput> Converter<GInput, GOutput> conditionalConverter(final Filter<? super GInput> condition, final Converter<? super GInput, ? extends GOutput> acceptConverter, final Converter<? super GInput, ? extends GOutput> rejectConverter) throws NullPointerException { return new Converter<GInput,...
6
private void setCursor(Point point) { Point worldCoords = getWorldCoordinates(point); if (worldCoords != null) { ClientPlayer me = client.getSession().getSelf(); double angle = Math.atan2(worldCoords.y - me.getShooterMount().y, worldCoords.x - me.getShooterMount().x); me.setShooterAngle(angle); AdjustSh...
1
@Override public void run() { if (Updater.this.url != null) { // Obtain the results of the project's file feed if (Updater.this.read()) { if (Updater.this.versionCheck(Updater.this.versionName)) { if ((Updater.this.versionLi...
6
public void test_toFormatter() { DateTimeFormatterBuilder bld = new DateTimeFormatterBuilder(); try { bld.toFormatter(); fail(); } catch (UnsupportedOperationException ex) {} bld.appendLiteral('X'); assertNotNull(bld.toFormatter()); }
1
public void setToolBar(JToolBar newToolBar) { JToolBar oldToolBar = getToolBar(); if (oldToolBar == newToolBar) { return; } if (oldToolBar != null) { headerPanel.remove(oldToolBar); } if (newToolBar != null) { newToolBar.setBorder(B...
3
public static void main(String[] args){ PrintTimes printer = new PrintTimes(); PrintClusters cprinter = new PrintClusters(); TunableParameters params = TunableParameters.getInstance(); int runs = 1; int[][] allClusters = new int[runs][params.getDataSetSize()]; int[][] ...
4
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 ListNode getIntersectionNode(ListNode headA, ListNode headB) { int firstCount = 0; int secondCount = 0; //First number of nodes in first list ListNode A = headA; while (A != null) { firstCount = firstCount + 1; A = A.next; } //Find ...
6
public MergeSort(int[] array){ this.array = array; }
0
@Override public void insert(K k) { // induction basis: BinarySearchTreeItem<K> p; if (root == null) { p = new BinarySearchTreeItem<K>(k); p.left = null; p.right = null; } else { p = root; } // induction step: while (true) { if (p.key == k) { if (p.left == null) { p.left = new B...
9
private static String calculate(String input) throws Exception { if (input.equals("")) { return(input); } double val1, val2, result; String output = null; String symbol; Stack<Double> stack; String[] symbols; stack = new Stack<Double>(); symbols = input.split(" "); for (int i = 0; i < sy...
9
public static int sizeOf(Class<?> cls) { if(cls == boolean.class) return 1; if(cls == byte.class) return 1; if(cls == char.class) return 2; if(cls == short.class) return 2; if(cls == int.class) return 4; if(cls == long.class) return 8; if(cls == flo...
9