method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
bfb29280-e6c8-4808-a9b5-17f33d58b462
2
private void resetArgs() { if (Options.Size == GameSize.C8) { R8.setSelected(true); } else if (Options.Size == GameSize.C7) { R7.setSelected(true); } else { R6.setSelected(true); } }
5dc6eb2e-7a31-428a-a9df-55af6974dd4e
9
public ArrayList<Person> getPersonV2(String value) { ArrayList<Person> fundnePersoner = new ArrayList<>(); for (Person p : personer) { if (p.getCpr().equalsIgnoreCase(value)) { fundnePersoner.add(p); return fundnePersoner; } else if (p.getFornavn().equalsIgnoreCase(value)) { fundnePersoner.add(p); } else if (p.getMellemnavn().equalsIgnoreCase(value)) { fundnePersoner.add(p); } else if (p.getEfternavn().equalsIgnoreCase(value)) { fundnePersoner.add(p); } else if ((p.getFornavn() + " " + p.getEfternavn()).equalsIgnoreCase(value)) { fundnePersoner.add(p); } else if ((p.getFornavn() + " " + p.getMellemnavn() + " " + p.getEfternavn()).equalsIgnoreCase(value)) { fundnePersoner.add(p); } else if ((p.getFornavn() + " " + p.getMellemnavn()).equalsIgnoreCase(value)) { fundnePersoner.add(p); } else if ((p.getMellemnavn() + " " + p.getEfternavn()).equalsIgnoreCase(value)) { fundnePersoner.add(p); } } return fundnePersoner; }
ee654660-2ff3-45fc-9b4d-03afbb52cc77
0
public PBKDF2ParameterType.Salt createPBKDF2ParameterTypeSalt() { return new PBKDF2ParameterType.Salt(); }
199c762c-a21f-49f9-a94e-10d368074564
2
public static void setOutputFilePath(String outputFilePath) { if (CommonUtil.isNull(outputFilePath)) { return; } if (!outputFilePath.endsWith("/")) { outputFilePath += "/"; } CrawlerManager.outputFilePath = outputFilePath; HttpUtil.setOutputFilePath(); }
47b19eee-9df3-4057-8233-131fc3ee9ead
2
public void SetAPIHost(String apiHost) { if (null == apiHost || apiHost.length() < 2) throw new IllegalArgumentException("Too short API host."); _requestUri = "http://" + apiHost + ".alchemyapi.com/calls/"; }
866f52e0-a691-4b3a-9584-5571acdf457c
5
public static void add(ArrayList<Track> newSongs) { boolean lastTrackCase = false; if(newSongs == null) return; if(playQueueTracks.size() != 0) { if(currentTrack.equals(playQueueTracks.get(playQueueTracks.size()-1))) { lastTrackCase = true; } } playQueueTracks.addAll(newSongs); if(playQueueTracks.equals(newSongs)) setCurrentTrack(playQueueTracks.get(0)); if(lastTrackCase) { int currentIndex = playQueueTracks.indexOf(currentTrack); setNextTrack(playQueueTracks.get(getNextTrackIndex(currentIndex))); currentPlayback.setOnEndOfMedia(new Runnable() { @Override public void run() { setCurrentTrack(nextTrack); play(); } }); } }
bef2407e-9153-4b6e-a309-8f4d7f639306
6
public static ClassInfo forName(String name) { if (name == null || name.indexOf(';') != -1 || name.indexOf('[') != -1 || name.indexOf('/') != -1) throw new IllegalArgumentException("Illegal class name: " + name); int hash = name.hashCode(); Iterator iter = classes.iterateHashCode(hash); while (iter.hasNext()) { ClassInfo clazz = (ClassInfo) iter.next(); if (clazz.name.equals(name)) return clazz; } ClassInfo clazz = new ClassInfo(name); classes.put(hash, clazz); return clazz; }
30291c99-3fa0-43f8-b62b-d7f4dcca2725
6
public static String escape(String string) { StringBuffer sb = new StringBuffer(); for (int i = 0, length = string.length(); i < length; i++) { char c = string.charAt(i); switch (c) { case '&': sb.append("&amp;"); break; case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; case '"': sb.append("&quot;"); break; case '\'': sb.append("&apos;"); break; default: sb.append(c); } } return sb.toString(); }
d4410bba-ebbf-4216-84a7-b7ccc8c678b4
6
public ListNode rotateRight(ListNode head, int n) { if(head==null||n<=0){ return head; } ArrayList<ListNode> box = new ArrayList<ListNode>(); ListNode temp = head; while(temp !=null){ box.add(temp); temp = temp.next; } if(n>=box.size()) n= n%box.size(); if(box.size()==1||n==0) return head; else { head = box.get(box.size()-n); box.get(box.size()-1).next = box.get(0); box.get(box.size()-n-1).next = null; } return head; }
4bdc9166-26d5-4ba5-bc2b-2e7a324d3a10
6
public void focusGained(FocusEvent e) { Object oggetto = e.getSource(); for (int i=0; i<calcoli; i++) { if (oggetto.equals((Object)txtSpazio.get(i))) { JTextField tmp = txtSpazio.get(i); tmp.selectAll(); txtSpazio.set(i, tmp); } else if (oggetto.equals((Object)txtTempo.get(i))) { JTextField tmp = txtTempo.get(i); tmp.selectAll(); txtTempo.set(i, tmp); } else if (oggetto.equals((Object)txtVelocita.get(i))) { JTextField tmp = txtVelocita.get(i); tmp.selectAll(); txtVelocita.set(i, tmp); } else if (oggetto.equals((Object)txtMassa.get(i))) { JTextField tmp = txtMassa.get(i); tmp.selectAll(); txtMassa.set(i, tmp); } else if (oggetto.equals((Object)txtEnergia.get(i))) { JTextField tmp = txtEnergia.get(i); tmp.selectAll(); txtEnergia.set(i, tmp); } } }
70540648-2f6d-423b-8644-41abb0146fd2
2
public boolean belongsTo(GUIComponent component) { return (this == component) || (superGroup != null && superGroup.belongsTo(component)); }
88eb7f79-7586-4511-b3fc-553f9e954bc8
7
@Override public long whereCantWear(MOB mob) { long where=super.whereCantWear(mob); final Wearable.CODES codes = Wearable.CODES.instance(); if(where == 0) { for(long code : codes.all()) { if((code != 0) && fitsOn(code) &&(code!=Item.WORN_HELD) &&(!CMath.bset(where,code))) { if(hasFreePiercing(mob, code)) return 0; else where = where | code; } } } return where; }
80071817-d68b-4ba9-bad5-bab4482734c0
5
public void draw() { UI.clearGraphics(false); UI.setColor(c); for (int h = 0; h < map.length; h++) { for (int w = 0; w < map[0].length; w++) { if (map[h][w] != null) UI.fillRect(w * Cell.CELL_WIDTH, h * Cell.CELL_HEIGHT, Cell.CELL_WIDTH, Cell.CELL_HEIGHT, false); } } if (charX >= 0 && charY >= 0) UI.drawImage(charImg, charX, charY, Crayon.CRAYON_WIDTH, Crayon.CRAYON_HEIGHT, false); UI.repaintGraphics(); }
6ee6b6b3-b118-41f6-9a7a-2d17cec4e352
5
private final void method779(boolean bool) { anInt1301++; anInt1291 += ++anInt1294; for (int i = 0; (i ^ 0xffffffff) > -257; i++) { int i_13_ = anIntArray1296[i]; if ((i & 0x2) != 0) { if ((0x1 & i ^ 0xffffffff) == -1) anInt1293 ^= anInt1293 << -853467134; else anInt1293 ^= anInt1293 >>> 1323677776; } else if ((0x1 & i) != 0) anInt1293 ^= anInt1293 >>> 1187700998; else anInt1293 ^= anInt1293 << -931969203; anInt1293 += anIntArray1296[0xff & 128 + i]; int i_14_; anIntArray1296[i] = i_14_ = (anIntArray1296[Class139.bitAnd(255, i_13_ >> 1990278754)] - (-anInt1293 - anInt1291)); anIntArray1289[i] = anInt1291 = i_13_ + anIntArray1296[(Class139.bitAnd(261268, i_14_) >> 278777480 >> 242087490)]; } if (bool != false) method776(-33, -56, 52); }
e8d6097a-bba2-4a87-a3b0-f3b0b4aedeab
1
public void updatePhysics() { clock++; if(clock > fullTime) { activated = false; climber.lostPower(getState()); } }
dff6af8e-c86a-4bce-9d54-a6084323aa7e
1
@Override public void documentAdded(DocumentRepositoryEvent e) { // local vars int whichOne = isThisOneOfOurs(PropertyContainerUtil.getPropertyAsString(e.getDocument().getDocumentInfo(), DocumentInfo.KEY_PATH)); // if it's one of ours ... if (whichOne != DOCUMENT_NOT_FOUND) { // mark it open docOpenStates[whichOne] = true; } // increment ourDocsOpen counter ourDocsOpen ++ ; }
54e9eeda-6c95-4f16-9db2-5ed9ff8e2834
9
private static Set<EEnum> getAllEEnumerations(EClass sysmlClass, LinkedHashSet<EEnum> linkedHashSet) { for (EAttribute eAttribute : sysmlClass.getEAllAttributes()) { if (eAttribute.getEType() instanceof EEnum) { EEnum eEnum = (EEnum) eAttribute.getEType(); linkedHashSet.add(eEnum); } } for (EReference eReference : sysmlClass.getEAllReferences()) { // System.out.println("\t\t\t" + eReference.getName()); if (eReference.getName().startsWith("base")) { // System.out // .println("\t\t\t\t" + eReference.getEType().getName()); EClassifier umlClassifier = eReference.getEType(); if (umlClassifier instanceof EClass) { EClass umlType = (EClass) umlClassifier; for (EAttribute umlAttribute : umlType.getEAllAttributes()) { if (umlAttribute.getName().equals("eAnnotations")) { continue; } if (umlAttribute.getEType() instanceof EEnum) { EEnum eEnum = (EEnum) umlAttribute.getEType(); linkedHashSet.add(eEnum); } } for (EClass eSuperType : umlType.getESuperTypes()) { getAllEEnumerations(eSuperType, linkedHashSet); } } } } return linkedHashSet; }
20f0dd9e-934a-4df0-83fc-f5dbaeaae412
2
protected void quitterTerritoire(Territoire t) { this.territoiresOccupes.remove(t); t.setOccupant(null); if (this.enDeclin && this.territoiresOccupes.size() == 0) { joueur.pertePeupleEnDeclin(); Partie.getInstance().remettreBoite(this); } }
07aaae81-1f78-4be9-8c8c-2658e93c9fb3
7
public static void main(String... args) throws IOException { MyScanner sc = new MyScanner(); int h = sc.nextInt(); int w = sc.nextInt(); int k = sc.nextInt(); int counter = 0; int max = 0; int a = 1; int b = 1; int t = 1; for (int i = 1; i <= w * h; i++) { if (counter == max) { max = (k == 1) ? w * h - i + 1 : 2; counter = 0; k--; } if (counter == 0) { if (i != 1){ System.out.println(); } System.out.print( + max + " "); } System.out.print(a + " " + b + " "); b += t; if (b == 0 || b == w + 1){ a++; t *= -1; b += t; } counter++; } System.out.println(); }
cfc40029-80b8-4786-b673-b447184eb959
5
@Override public void deserialize(Buffer buf) { super.deserialize(buf); short flag1 = buf.readUByte(); showExperience = BooleanByteWrapper.getFlag(flag1, 0); showExperienceLevelFloor = BooleanByteWrapper.getFlag(flag1, 1); showExperienceNextLevelFloor = BooleanByteWrapper.getFlag(flag1, 2); showExperienceFightDelta = BooleanByteWrapper.getFlag(flag1, 3); showExperienceForGuild = BooleanByteWrapper.getFlag(flag1, 4); showExperienceForMount = BooleanByteWrapper.getFlag(flag1, 5); isIncarnationExperience = BooleanByteWrapper.getFlag(flag1, 6); experience = buf.readDouble(); if (experience < 0) throw new RuntimeException("Forbidden value on experience = " + experience + ", it doesn't respect the following condition : experience < 0"); experienceLevelFloor = buf.readDouble(); if (experienceLevelFloor < 0) throw new RuntimeException("Forbidden value on experienceLevelFloor = " + experienceLevelFloor + ", it doesn't respect the following condition : experienceLevelFloor < 0"); experienceNextLevelFloor = buf.readDouble(); if (experienceNextLevelFloor < 0) throw new RuntimeException("Forbidden value on experienceNextLevelFloor = " + experienceNextLevelFloor + ", it doesn't respect the following condition : experienceNextLevelFloor < 0"); experienceFightDelta = buf.readInt(); experienceForGuild = buf.readInt(); if (experienceForGuild < 0) throw new RuntimeException("Forbidden value on experienceForGuild = " + experienceForGuild + ", it doesn't respect the following condition : experienceForGuild < 0"); experienceForMount = buf.readInt(); if (experienceForMount < 0) throw new RuntimeException("Forbidden value on experienceForMount = " + experienceForMount + ", it doesn't respect the following condition : experienceForMount < 0"); rerollExperienceMul = buf.readInt(); }
bd7aeb25-8c08-4097-b907-0ba75fe3e0af
4
private STNode<Key, Value> balance(STNode<Key, Value> x) { switch (getShape(x)) { case LLEFT: return rotateRight(x); case LRIGHT: x.left = rotateLeft(x.left); return rotateRight(x); case RRIGHT: return rotateLeft(x); case RLEFT: x.right = rotateRight(x.right); return rotateLeft(x); default: // System.out.println(x.key + " Balanced"); return x; } }
296dc206-853a-41d9-bba4-0e97482703c3
9
public static ArrayList<Node> execute(Node node) { ArrayList<Node> results = new ArrayList<Node>(); // If defining a constant, then add it to the runtime stack. If defining a procedure, do nothing. if (node.getToken() != null && node.getToken().getType() == TokenType.KW_DEFINE) { String variableId = node.getCdr().getToken().getText(); // Get name of variable SymTabEntry entry = symTabStack.lookup(variableId); // Get corresponding SymTabEntry Node variable = (Node) entry.get(Attribute.VARIABLE_NODE); SymTabEntry newEntry = runTimeStack.enterLocal(variableId); // Go into this block to determine if the variable refers to a procedure or constant if (variable != null) { entry = getVariableType(variable); } newEntry.putAll(entry); // Copy the Attributes from the original SymTabEntry } // Execute if define is not the CAR of the list. This also means it is a procedure call. else { Node root = updateRunTimeEnvironment(node); // Note that we are getting the CDR twice. When running built in functions, manually // create these inside processResult() executeProcedure(root.getCdr().getCdr(), results); // Relink runtime stack and runtime display SymTab symTab = runTimeStack.pop(); int level = symTab.getNestingLevel(); SymTab predecessor = runTimeStack.getPredecessor(level); if (predecessor != null) { runTimeDisplay.set(level, predecessor); } else { runTimeDisplay.pop(); } // If current nesting level = 1, then the top level list has finished executing, so print it if (runTimeStack.getCurrentNestingLevel() == 1) { System.out.println("\n*** Results ***\n"); for (Node resultNode : results) { if (resultNode.getToken() != null && resultNode.getToken().getType() == TokenType.SS_QUOTE) { resultNode = resultNode.getCdr(); } // If the token is null, then this is a list. if (resultNode.getToken() == null) { new TreePrinter().printList(resultNode.getCar(), 0); } else { System.out.print(resultNode.getToken().getText()); } } System.out.println(""); } } return results; }
2d95945a-6d8a-4bf7-af85-5a2bf0998eac
8
public boolean displayModesMatch(DisplayMode mode1, DisplayMode mode2) { if (mode1.getWidth() != mode2.getWidth() || mode1.getHeight() != mode2.getHeight()) { return false; } if (mode1.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI && mode2.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI && mode1.getBitDepth() != mode2.getBitDepth()) { return false; } if (mode1.getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN && mode2.getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN && mode1.getRefreshRate() != mode2.getRefreshRate()) { return false; } return true; }
ba0f3e93-d152-423c-a5ef-a46914e5e7e5
0
public Component getFirstComponent(Container container) { return m_Components[0]; }
eb1a745e-87b8-4fe8-85f9-0d2301c4df58
2
public static void main(String[] args) { LinkedListNodeIterator<String> list = new LinkedListNodeIterator <String>(); list.addFirst("p"); list.addFirst("a"); list.addFirst("e"); list.addFirst("h"); System.out.println(list); LinkedListNodeIterator<String> twin = list.copy3(); System.out.println(twin); System.out.println(list.get(0)); // System.out.println(list.get(4)); //exception list.addLast("s"); Iterator itr = list.iterator(); while(itr.hasNext()) System.out.print(itr.next() + " "); System.out.println(); for(Object x : list) System.out.print(x + " "); System.out.println(); list.insertAfter("e", "ee"); System.out.println(list); System.out.println(list.getLast()); list.insertBefore("h", "yy"); System.out.println(list); list.remove("p"); System.out.println(list); }
e69aac16-2fc0-4b39-bb65-d2711bf3d685
2
public boolean fromDiscard(Game g, Rack r) { int index = indexer.index(g, r); int newDrawState = index; int newDrawAction = drawStates[index].getLeastVisited(); if (oldDrawState != -1) { drawStates[oldDrawState].updateReward(drawStates[newDrawState], oldDrawAction); } oldDrawState = newDrawState; oldDrawAction = newDrawAction; if (newDrawAction == 0) return false; else return true; }
b98b09f3-8be8-4837-91d4-258bbdf151c0
8
@Override public void sendRequest(String request) throws Exception { int retriesLeft = REQUEST_RETRIES; while (retriesLeft > 0 && !Thread.currentThread().isInterrupted()) { LOGGER.info("Sending request " + request); requester.send(request); int expect_reply = 1; while (expect_reply > 0) { PollItem items[] = {new PollItem(requester, Poller.POLLIN)}; int rc = ZMQ.poll(items, REQUEST_TIMEOUT); if (rc == -1) { break; // Interrupted } if (items[0].isReadable()) { try { String response = requester.recvStr(); retriesLeft = 0; expect_reply = 0; LOGGER.info("Handling response"); this.handler.handle(response); } catch (Exception e) { LOGGER.warn("Error during request/response", e); if (e instanceof ZMQException) { LOGGER.error("Will close request socket"); requester.close(); ctx.close(); LOGGER.info("Closed request socket, which was connected to " + responder); throw new Exception("Error during request/response", e); } } } else if (--retriesLeft == 0) { LOGGER.error("Service " + responder + " seems to be unavailable"); throw new Exception("Service " + responder + " seems to be unavailable"); } else { LOGGER.warn("No response from " + responder); requester.close(); LOGGER.info("Reconnecting request socket to " + responder); connect(); } } } }
395ce2bd-eba9-41e7-a240-0500dbd9f6fc
5
public static boolean deleteRecursively(File root) { if (root != null && root.exists()) { if (root.isDirectory()) { File[] children = root.listFiles(); if (children != null) { for (File child : children) { deleteRecursively(child); } } } return root.delete(); } return false; }
c9ea32aa-c2ee-4b09-95dd-6099738f53e9
4
public static int[] removeDuplicates(int[] input){ int j = 0; int i = 1; //return if the array length is less than 2 if(input.length < 2){ return input; } while(i < input.length){ if(input[i] == input[j]){ i++; }else{ input[++j] = input[i++]; } } int[] output = new int[j+1]; for(int k=0; k<output.length; k++){ output[k] = input[k]; } return output; }
4648e7d9-4302-40f0-b9b8-0e86d5fe4277
4
private void addCustomIngredient(){ Ingredient ingredient; try{ ingredient = db.retrieveIngredient(ingredientTextField.getText()); } catch (DataStoreException e){ showErrorMessage("There was a problem retrieving the ingredient from the data store", "Data store error"); return; } if( ingredient == null ){ showErrorMessage("Could not find an ingredient called '" + ingredientTextField.getText() + "'", "Unknown ingredient" ); return; } if( ingredient.isCommon() ){ showErrorMessage("The ingredient (" + ingredientTextField.getText() + ") is considered a common item and is not searchable'", "Common ingredient" ); return; } if ( customIngredients.add(ingredient) ){ ingredientLabel.setText(ingredientLabel.getText() + ingredient.getSingular() + "; "); } }
98c04c3e-09d4-4a84-8240-14301f771fd5
1
public void setCatchBlock(StructuredBlock catchBlock) { this.catchBlock = catchBlock; catchBlock.outer = this; catchBlock.setFlowBlock(flowBlock); if (exceptionLocal == null) combineLocal(); }
2c346a69-ded4-4d47-b5ba-2595fae4dffb
4
private void moveWindow(Packet pkt){ int seqNum = pkt.getSeqnum(); if (windowBuffer.peek().getSeqnum() > pkt.getSeqnum()){ return; //ack for an old packet } Packet head = windowBuffer.poll(); while (head != null && head.getSeqnum() != seqNum){ head = windowBuffer.poll(); } aBase = (head == null) ? aNextSeqNum : head.getSeqnum() + 1; }
b4f5c9e8-fd0b-4034-b8c6-6b140f5792b3
1
public CommandGroup addUngroupedCommands(Command... command) { for(Command c : command) { ungroupedCommands.add(c); } return this; }
1cb2be50-166d-4b01-b7b4-acbbf17e820c
4
private void drawTerrain() { int width = UIGlobals.getScreenWidth(); int height = UIGlobals.getScreenHeight(); int cameraX = UIGlobals.camera_x; int cameraY = UIGlobals.camera_y; int tileSize = UIGlobals.tileSize; int xOff = -(tileSize + ((cameraX % tileSize) - tileSize)); int yOff = -(tileSize + ((cameraY % tileSize) - tileSize)); // graphical x and y int x = xOff; int y = yOff; int cameraLocationX = Map.pixelToLocation(cameraX); int cameraLocationY = Map.pixelToLocation(cameraY); int cameraWidthOff = (int)(Map.pixelToLocation(width)/2); int cameraHeightOff = (int)(Map.pixelToLocation(height)/2); for (int map_x = cameraLocationX-cameraWidthOff, map_x_end = cameraLocationX+cameraWidthOff+3; map_x < map_x_end; map_x++){ for (int map_y = cameraLocationY-cameraHeightOff, map_y_end = cameraLocationY+cameraHeightOff+3; map_y < map_y_end; map_y++){ int terrain = map.getTileAt(map_x, map_y); if (terrain != -1) { Resource.MAP_TERRAIN[terrain].draw(x, y, tileSize, tileSize); if (map.isFogOfWar(map_x, map_y)) { //Resource.MAP_FOG.draw(x, y, tileSize, tileSize); } } y += tileSize; } x += tileSize; y = yOff; } }
4b6fb44a-37f4-462a-9f84-40ebed061409
9
public static void affecter(GestItineraire gestItineraire, Plan plan, NoeudItineraire entrepot, PlageHoraire plageHoraireInitiale) { List<Livraison> livraisonsInitiales = plageHoraireInitiale.getLivraisons(); List<List<Livraison>> clusters = kmeans(livraisonsInitiales,2); boolean clustersValides = false; List<List<Livraison>> prochainsClusters = new ArrayList<List<Livraison>>(); List<List<Livraison>> clustersFinaux = new ArrayList<List<Livraison>>(); while(!clustersValides) { prochainsClusters.clear(); clustersValides = true; for(List<Livraison> cluster : clusters) { Double poidsTotal = 0.0; Double volumeTotal = 0.0; for(int i = 0 ; i < cluster.size() ; i++) { poidsTotal += cluster.get(i).getPoids(); volumeTotal += cluster.get(i).getVolume(); } if(poidsTotal > Constantes.POIDS_STOCK_DRONE_EN_KG || volumeTotal > Constantes.VOLUME_STOCK_DRONE_EN_L) { if(cluster.size() <= 1) { System.out.println("ERREUR"); } List<List<Livraison>> newClusters = kmeans(cluster,2); prochainsClusters.add(newClusters.get(0)); prochainsClusters.add(newClusters.get(1)); clustersValides = false; } else { if(cluster.size() != 0) { clustersValides = clustersValides && true; clustersFinaux.add(cluster); } } } clusters = new ArrayList<List<Livraison>>(prochainsClusters); } for(int i = 0 ; i < clustersFinaux.size() ; i++) { PlageHoraire plage = new PlageHoraire(plageHoraireInitiale.getHeureDebut(), plageHoraireInitiale.getHeureFin(), clustersFinaux.get(i)); List<PlageHoraire> plages = new ArrayList<PlageHoraire>(); plages.add(plage); Itineraire itineraire = new Itineraire(plan, entrepot, plages); itineraire.setEtat(EtatItineraire.NON_CALCULE); gestItineraire.ajouterItineraire(itineraire); } /* // Itineraire 1 List<Livraison> livraisons1 = new ArrayList<Livraison>(); livraisons1.add(livraisonsInitiales.get(0)); livraisons1.add(livraisonsInitiales.get(1)); PlageHoraire plage1 = new PlageHoraire(plageHoraireInitiale.getHeureDebut(), plageHoraireInitiale.getHeureFin(), livraisons1); List<PlageHoraire> plages1 = new ArrayList<PlageHoraire>(); plages1.add(plage1); Itineraire itineraire1 = new Itineraire(plan, entrepot, plages1); itineraire1.setEtat(EtatItineraire.NON_CALCULE); gestItineraire.ajouterItineraire(itineraire1); // Itineraire 2 List<Livraison> livraisons2 = new ArrayList<Livraison>(); livraisons2.add(livraisonsInitiales.get(2)); livraisons2.add(livraisonsInitiales.get(3)); PlageHoraire plage2 = new PlageHoraire(plageHoraireInitiale.getHeureDebut(), plageHoraireInitiale.getHeureFin(), livraisons2); List<PlageHoraire> plages2 = new ArrayList<PlageHoraire>(); plages2.add(plage2); Itineraire itineraire2 = new Itineraire(plan, entrepot, plages2); itineraire2.setEtat(EtatItineraire.NON_CALCULE); gestItineraire.ajouterItineraire(itineraire2); // Itineraire 3 List<Livraison> livraisons3 = new ArrayList<Livraison>(); livraisons3.add(livraisonsInitiales.get(4)); livraisons3.add(livraisonsInitiales.get(5)); PlageHoraire plage3 = new PlageHoraire(plageHoraireInitiale.getHeureDebut(), plageHoraireInitiale.getHeureFin(), livraisons3); List<PlageHoraire> plages3 = new ArrayList<PlageHoraire>(); plages3.add(plage3); Itineraire itineraire3 = new Itineraire(plan, entrepot, plages3); itineraire3.setEtat(EtatItineraire.NON_CALCULE); gestItineraire.ajouterItineraire(itineraire3);*/ }
ed8ac6f9-b8db-4095-874e-e7774d46b3a8
3
@Override public boolean equals(Object obj) { return obj != null && obj instanceof Token && ((Token) obj).character == character && ((Token) obj).type == type; }
b4807299-18f5-4c6f-84d6-cae31ce62864
6
public void executeEvents(){ if(activeEvents.isEmpty()) return; for(Job event : activeEvents){ if(event instanceof InterruptableEvent && ((InterruptableEvent)event).shouldEnd() || event instanceof RecurringEvent){ continue; } if(((DatedEvent)event).execute() == Job.EXECUTOR_FINALIZE){ ((DatedEvent)event).finalise(); } } }
93feaa10-866a-4224-8b98-74a4f15751df
3
public static void close(){ try { rs.close(); } catch (SQLException e) { System.out.println("Close ResultSet Failed :" + e); e.printStackTrace(); } try { stmt.close(); } catch (SQLException e) { System.out.println("Close Statement Failed :" + e); e.printStackTrace(); } try { conn.close(); } catch (SQLException e) { System.out.println("Close Connection Failed :" + e); e.printStackTrace(); } }
cdcf1082-2434-4bc5-88ad-67ed8042cd80
0
public static EllipseEquation newInstance(float a, float b, float h, float k) { return new EllipseEquation(a, b, h, k); }
95397da8-fbe5-41fd-bc19-cabe34ec33ad
0
public void setUitleningen(List<Uitlening> uitleningen) { this.uitleningen = uitleningen; }
b31bb312-cc18-4e58-8786-b3688194869c
3
public static void main(String[] args) { Scanner s = new Scanner(System.in); Integer2 i2 = new Integer2(); System.out.println("Enter a number: "); String str = s.nextLine(); int i = Integer.parseInt(str); i2.setValue(i); System.out.println("The number you entered is :"); if(i2.isEven()){ System.out.println("Even."); } else if(i2.isOdd()){ System.out.println("Odd."); } else{ System.out.println("Undefined! Your code is buggy!"); } int parsedInt = Integer.parseInt(i2.toString()); if(parsedInt == i2.getValue()){ System.out.println("Your toString() method seems to work fine."); } }
7c40301d-2ec2-49f9-9ac4-a38a8699b979
9
public static BanEntry func_73688_c(String par0Str) { if (par0Str.trim().length() < 2) { return null; } String as[] = par0Str.trim().split(Pattern.quote("|"), 5); BanEntry banentry = new BanEntry(as[0].trim()); int i = 0; if (as.length <= ++i) { return banentry; } try { banentry.func_73681_a(field_73698_a.parse(as[i].trim())); } catch (ParseException parseexception) { field_73696_b.log(Level.WARNING, (new StringBuilder()).append("Could not read creation date format for ban entry '").append(banentry.func_73684_a()).append("' (was: '").append(as[i]).append("')").toString(), parseexception); } if (as.length <= ++i) { return banentry; } banentry.func_73687_a(as[i].trim()); if (as.length <= ++i) { return banentry; } try { String s = as[i].trim(); if (!s.equalsIgnoreCase("Forever") && s.length() > 0) { banentry.func_73691_b(field_73698_a.parse(s)); } } catch (ParseException parseexception1) { field_73696_b.log(Level.WARNING, (new StringBuilder()).append("Could not read expiry date format for ban entry '").append(banentry.func_73684_a()).append("' (was: '").append(as[i]).append("')").toString(), parseexception1); } if (as.length <= ++i) { return banentry; } else { banentry.func_73689_b(as[i].trim()); return banentry; } }
55030cfb-c412-4c15-8f71-3eb38562c485
1
public boolean open( ) { state = State.PROCESSING; setVisible(true); while (state == State.PROCESSING); return(state == State.OKAY); }
0e63fe5a-3ffb-4972-b987-e937d65063a9
7
protected boolean approachingTurn(Segment s) { Segment overlappingSegment = findOverlappingSegment(s); if (desire == Desire.STRAIGHT) { return false; } if (desire == Desire.TURN_LEFT && !vehicle.getLane().canTurnLeft()) { return false; } if (desire == Desire.TURN_RIGHT && !vehicle.getLane().canTurnRight()) { return false; } if (overlappingSegment != null) { int distanceFromTurn = (overlappingSegment.id() - s.id()); if (distanceFromTurn < (CORNER_STOP_DISTANCE + CORNER_STOP_TIME_DISTANCE)) { return true; } else { return false; } } return false; }
2fe38b2a-c4fb-4c1c-9cf8-82726beed841
5
private void clearOldBlocks(Player player, boolean effTimeUp){ Iterator<Block> iceIter = null; final HashSet<Block> nearPlayer = new HashSet<Block>(9); Block startBlock = player.getLocation().getBlock().getRelative(BlockFace.DOWN); for(BlockFace bFace : bCheck){ nearPlayer.add(startBlock.getRelative(bFace)); } Block b = null; try { iceIter = iceBlocks.iterator(); } catch (IllegalStateException e) { Messaging.send(player, "There was an error with the frost path!"); } while (iceIter.hasNext()){ b = iceIter.next(); if(!nearPlayer.contains(b) || effTimeUp){ b.setType(Material.WATER); } } }
efcf6448-50d0-4eef-9b66-da6da1c4a634
2
public void setSurfaceChargeDensity(double sigma){ if(this.psi0set){ System.out.println("You have already entered a surface potential"); System.out.println("This class allows the calculation of a surface charge density for a given surface potential"); System.out.println("or the calculation of a surface potential for a given surface charge density"); System.out.println("The previously entered surface potential will now be ignored"); this.psi0set = false; } this.surfaceChargeDensity = sigma; this.sigmaSet = true; if(this.surfaceAreaSet){ this.surfaceCharge = sigma*this.surfaceArea; this.chargeSet = true; } }
636b0c5f-037a-4d8e-8817-5a7702302a07
7
public static void main(String a[]) throws IOException { TreeMap<BigInteger, BigInteger> map = new TreeMap<BigInteger, BigInteger>(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int test = Integer.valueOf(br.readLine()); while(test!=0) { int N = Integer.valueOf(br.readLine()); int arr[] = new int[N]; for( int i=0 ; i<N ; ++i) arr[i] = Integer.valueOf(br.readLine()); int count = 1; Arrays.sort(arr); boolean flag = true; int i = 0 , j =1; for( ; i<N && j<N; ++i){ flag =false; for(; j<N ;++j){ if(arr[j] > arr[i] ){ ++j; flag =true; break; } } } if(flag) System.out.println(j-i); else System.out.println(j-i+1); --test; } }
b252314f-7358-4d5b-94c7-c4209bc02999
5
private void drawPlayers(Graphics g){ g.setColor(Color.BLACK); for(int i=0; i<grid.length; i++){ for(int j=0; j<grid[0].length; j++){ for(GameMatter itm: grid[i][j].getItems()){ if(itm instanceof Bandit){ if(itm.equals(player)) g.setColor(Color.MAGENTA); g.fillRect(j*widthBlock+padding, i*heightBlock+padding, bandit, bandit); break; } } } } }
245c76e9-ba8a-40fb-943b-bd3c3f6b7597
2
private void calculateEnabledState(JoeTree tree) { if (tree.getComponentFocus() == OutlineLayoutManager.ICON) { setEnabled(true); } else { if (tree.getCursorPosition() == tree.getCursorMarkPosition()) { setEnabled(false); } else { setEnabled(true); } } }
0e87696b-21a7-4bb0-9ee7-552095037b35
5
public synchronized boolean openSlot(int slotID) { if (!_isOpen) { return false; } if ((slotID < 0) || (slotID >= _slots.size())) { return false; } if (!_slots.get(slotID).isClosed()) { return false; } _slots.get(slotID).setOpen(); ArrayList<ClientThread> clients = new ArrayList<>(_clients.values()); for (ClientThread client : clients) { client.send("openSlot"); client.send(slotID); } return true; }
820c0f10-d6f8-4281-b726-1a8b0d4bbd18
5
@Override public ElectionState getElectionState() { // gets the current date Date date = new Date(); if (openNominationsDate == null || date.before(openNominationsDate)) return ElectionState.NOT_STARTED; else if (date.before(startDate)) return ElectionState.NOMINATIONS_OPEN; else if (date.before(endDate)) return ElectionState.STARTED; else if (!published) return ElectionState.ENDED; else return ElectionState.PUBLISHED; }
6bbb8607-fb1f-477d-8dfd-8c0750d04c1f
7
public static List<GraphNode> generateGraph(List<String> values) { GraphNode head = null; List<GraphNode> nodes = new ArrayList<GraphNode>(); for (int i = 0; i < values.size(); i++) { GraphNode node = new GraphNode(values.get(i)); if (null == head) head = node; nodes.add(node); } for (GraphNode node : nodes) { for (GraphNode neighbor : nodes) { if (node != neighbor && !node.neighbors.contains(neighbor) && isDiffChar(node.lab, neighbor.lab)) { node.neighbors.add(neighbor); neighbor.neighbors.add(node); } } } return nodes; }
bfa10fe8-f083-4349-9ffc-782952b12620
6
@Override public void checkAssocAddRestriction(ClassSubInstance source, ClassSubInstance target, ModelSubInstance m) throws RestrictionException { Iterator<Map.Entry<Integer, AssociationSubInstance>> it = m.assocs.entrySet().iterator(); while(it.hasNext()) { AssociationSubInstance a = it.next().getValue(); if(a.target.equals(target) && a.source.equals(source)) throw new RestrictionException("Can not repeat associations!"); } String type = ""; for(int i = 0; i < source.meta.enums.size(); ++i) if(source.meta.enums.get(i).meta.name.equals("GroupKind")) type = source.meta.enums.get(i).chosen_value; if(type.equals("Alternative")) { handleAlternative(m, source); } }
284bed83-f309-4233-8b23-9bf20a4b49cd
5
public void update(Observable o, Object arg) { // update garage.occupancy and the garage.isOpen status as needed // the garage observes both the entry and exit in order to // keep occupancy correct if ((String)arg == "entry") { currentOccupancy++; } else if ((String)arg == "exit") { currentOccupancy--; if (currentOccupancy < 0 ) {currentOccupancy = 0;}; } // update the occupancy of the garage ui view garageUI.setMessage("Current Occupancy:" + currentOccupancy); Date timeNow = new Date(); dataStorage.updateOccupancyData(timeNow, currentOccupancy); // If the garage reaches max occupancy, close it down by // notifying the sign and the entryKiosk if (currentOccupancy >= systemPreferences.getMaxOccupancy()) { this.isOpen = false; this.setChanged(); this.notifyObservers("GarageFull"); } else if (this.isOpen == false) { this.isOpen = true; this.setChanged(); this.notifyObservers("GarageOpen"); } }
bbda7c3d-861e-4861-8815-535d080bda4b
8
public RobotType getRobotType(IRobotItem robotItem, boolean resolve, boolean message) { IRobotClassLoader loader = null; try { loader = createLoader(robotItem); Class<?> robotClass = loader.loadRobotMainClass(resolve); if (robotClass == null || java.lang.reflect.Modifier.isAbstract(robotClass.getModifiers())) { // this class is not robot return RobotType.INVALID; } return checkInterfaces(robotClass, robotItem); } catch (Throwable t) { if (message) { logError("Got an error with " + robotItem.getFullClassName() + ": " + t); // just message here if (t.getMessage() != null && t.getMessage().contains("Bad version number in .class file")) { logError("Maybe you run robocode with Java 1.5 and robot was compiled for later Java version ?"); } } return RobotType.INVALID; } finally { if (loader != null) { loader.cleanup(); } } }
4cf23c2c-c109-47e4-aa99-87bcb9a9d79c
7
@Override public void update(final int delta) { if (!isActive && !Game.getInstance().getCurrentLevel().isWon()) return; pos.y -= 400. * delta / DURATION; timeLeft -= delta; if (timeLeft < 0) { kill(); if (Game.getInstance().getCurrentLevel().getLevelType() == Level.LEVEL_COMPLEX) { World.getInstance().addEntity(new ActionRocketEntity(startPos, color)); } for (int x = -2; x <= 2; x++) { for (int y = -2; y <= 2; y++) { if (x + y == 0) continue; World.getInstance().addEntity(new SparkEntity(pos, new Vector2d(x, y), color)); } } } }
38c4f5b2-e98c-4be5-9e19-a85b4e9b3958
1
public void sendMessage(byte[] message) { try { to_peer.write(message); to_peer.flush(); } catch (IOException e) { System.err.println("Error sending message: " + message.toString() + "/nto peer located at: " + peer_ip); } }
17e36787-6a72-4824-9f99-97f7c5bceaf9
5
public void update(Map userCredentials) throws AuthenticationException { if (passwordFile == null) throw new AuthenticationException("update()", new IllegalStateException()); try { String userName = (String) userCredentials.get(Registry.SASL_USERNAME); String password = (String) userCredentials.get(Registry.SASL_PASSWORD); String salt = (String) userCredentials.get(SRPRegistry.SALT_FIELD); String config = (String) userCredentials.get(SRPRegistry.CONFIG_NDX_FIELD); if (salt == null || config == null) { passwordFile.changePasswd(userName, password); } else { passwordFile.add(userName, password, Util.fromBase64(salt), config); } } catch (Exception x) { if (x instanceof AuthenticationException) { throw (AuthenticationException) x; } throw new AuthenticationException("update()", x); } }
f4f321bf-41c2-42c5-ad13-23cbbd9615b8
8
private static String getRelativeLink( String fromDir, String toDir ) throws IOException { StringBuffer toLink = new StringBuffer(); // up from fromDir StringBuffer fromLink = new StringBuffer(); // down into toDir // create a List of toDir's parent directories List parents = new LinkedList(); File f = new File( toDir ); f = f.getCanonicalFile(); while ( f != null ) { parents.add( f ); f = f.getParentFile(); } // walk up fromDir to find the common parent f = new File( fromDir ); if ( !f.isDirectory() ) { // Passed in a fromDir with a filename on the end - strip it f = f.getParentFile(); } f = f.getCanonicalFile(); f = f.getParentFile(); boolean found = false; while ( f != null && !found ) { for ( int i = 0; i < parents.size(); ++i ) { File parent = (File) parents.get( i ); if ( f.equals( parent ) ) { // when we find the common parent, add the subdirectories // down to toDir itself for ( int j = 0; j < i; ++j ) { File p = (File) parents.get( j ); toLink.insert( 0, p.getName() + "/" ); } found = true; break; } } f = f.getParentFile(); fromLink.append( "../" ); } if ( !found ) { throw new FileNotFoundException( fromDir + " and " + toDir + " have no common parent." ); } return fromLink.append( toLink.toString() ).toString(); }
b6b6c31e-4118-4641-ac22-f003c7e7eaa8
7
private static Code[][] convertStringArrayToCodeArray2D(String[] strArray) { int len = strArray.length; // Make histogram of sizes int[] codeLengths = new int[64]; for (int i = 0; i < len; i++) { int entryLength = strArray[i].length(); codeLengths[entryLength]++; } // Make a 2d array of Code objects, where the first index is for // the length of the Code, and the second index differentiates // between all Code objects with that length // In this way, we separate all Code objects by their length, // and can thus reduce the search space // In theory, we could then sort each sublist, and do a binary search... int largestLength = codeLengths.length - 1; while (largestLength > 0 && codeLengths[largestLength] == 0) largestLength--; Code[][] codeArray = new Code[largestLength + 1][]; for (int i = 0; i < codeArray.length; i++) codeArray[i] = new Code[codeLengths[i]]; for (int i = 0; i < len; i++) { int entryLength = strArray[i].length(); Code[] entries = codeArray[entryLength]; for (int j = 0; j < entries.length; j++) { if (entries[j] == null) { entries[j] = new Code(strArray[i], i); break; } } } return codeArray; }
24fc1f29-74e4-4ba3-9852-91b564c9c0f3
5
public static void randomVector(Configuration conf) { FSDataOutputStream output = null; BufferedWriter outputBR = null; try { FileSystem hdfs = FileSystem.get(conf); output = hdfs.create(EntityDriver.randomVectorPath, true); outputBR = new BufferedWriter(new OutputStreamWriter(output,"UTF-8")); Random random = new Random(); boolean[][] randomVector = new boolean[EntityDriver.RANDOM_VECTORS][EntityDriver.DIMENSION]; for (int i = 0; i < EntityDriver.RANDOM_VECTORS; i++) { for (int j = 0; j < EntityDriver.DIMENSION; j++) { randomVector[i][j] = random.nextBoolean(); if (randomVector[i][j] == true) { outputBR.write("1"); } else { outputBR.write("0"); } } outputBR.write("\n"); } } catch (IOException e) { e.printStackTrace(); } finally { try { outputBR.flush(); outputBR.close(); output.flush(); output.close(); } catch (IOException e) { e.printStackTrace(); } } }
edb82973-9953-4225-b8dd-b3ca647a1562
2
public Acceptor(int port, ConcurrentLinkedQueue<AIConnection> globalClients, int backlogArg, boolean isGraphicsManagerArg, GraphicsContainer graphicsContainer){ try { acceptorSocket = new ServerSocket(port); acceptorSocket.setReuseAddress(true); graphics = graphicsContainer; backlog = backlogArg; globalClientList = globalClients; isGraphicsManager = isGraphicsManagerArg; if(isGraphicsManager){ Debug.info("listening on port " + acceptorSocket.toString() + " for the GUI"); } else { Debug.info("listening on port " + acceptorSocket.toString() + " for players"); } } catch(IOException e){ Debug.error("Error binding to port: " + e); } }
fc79bc3b-cae5-4a10-b413-a742a7a90efa
2
/* */ public static void close() /* */ { /* 187 */ for (Map.Entry entry : playerMap.entrySet()) /* */ { /* 189 */ ArrayList<BlockState> blockStateList = (ArrayList<BlockState>)entry.getValue(); /* */ /* 191 */ for (BlockState blockState : blockStateList) { /* 192 */ blockLoad(blockState); /* */ } /* 194 */ blockStateList.clear(); /* */ } /* */ /* 197 */ playerMap.clear(); /* */ }
75bf2178-93a9-4907-a99d-ae68b760e6f8
6
public static void test3() { String databaseName = "mytest"; MySQLIdentity mytestAtMytest = MySQLService.createMyIdentity("localhost",databaseName, "mytest", "password"); try { MySQLService.createConnectionPool(mytestAtMytest); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } Vector<TestThread> threads = new Vector<TestThread>(); for(int index = 0; index < 10; ++index) { TestThread t = new TestThread(); t.start(); threads.add(t); } // Long delay for(int j = 0; j < 100000000; ++j) { for(int k = 0; k < 1000000; ++k) { }; }; while(threads.size() > 0) { TestThread t = threads.lastElement(); t.cmd_stop = true; while(t.state_stopped == false) {}; threads.removeElement(t); } }
5c7cec4f-4212-4f3a-9258-0ed114aa0d6e
1
public JMenuItem getMntmDesconectar() { if (mntmDesconectar == null) { mntmDesconectar = new JMenuItem("Desconectar"); } return mntmDesconectar; }
03a363e6-26f2-4777-ab19-56033d8ceed9
4
protected void updateList(List<Hunter> hunters) { if(log.isLoggable(Logger.INFO)) log.log(Logger.INFO, "updateList(), size: " + hunters.size()); this.model = hunters; rowData = new String[10][4]; for (int i=0; i<10; i++) { tableModel.setValueAt("", i, 0); tableModel.setValueAt("", i, 1); tableModel.setValueAt("", i, 2); tableModel.setValueAt("", i, 3); } Hunter hunter = null; for (int i=0; i<this.model.size() && i<10; i++) { hunter = hunters.get(i); tableModel.setValueAt(String.valueOf(hunter.getId()), i, 0); tableModel.setValueAt(hunter.getName(), i, 1); tableModel.setValueAt(String.valueOf(hunter.getPerformance()), i, 2); tableModel.setValueAt(hunter.getState(), i, 3); } }
0273fd02-697c-4a29-9a7e-9bfbb9a69619
7
protected void loadJarURLs() throws Exception { state = 2; String jarList = "lwjgl.jar, jinput.jar, lwjgl_util.jar, client.zip, " + mainGameUrl; jarList = trimExtensionByCapabilities(jarList); StringTokenizer jar = new StringTokenizer(jarList, ", "); int jarCount = jar.countTokens() + 1; urlList = new URL[jarCount]; URL path = new URL(setting.loadLink); for (int i = 0; i < jarCount - 1; i++) { urlList[i] = new URL(path, jar.nextToken()); } String osName = System.getProperty("os.name"); String nativeJar = null; if (osName.startsWith("Win")) nativeJar = "windows_natives.jar.lzma"; else if (osName.startsWith("Linux")) nativeJar = "linux_natives.jar.lzma"; else if (osName.startsWith("Mac")) nativeJar = "macosx_natives.jar.lzma"; else if ((osName.startsWith("Solaris")) || (osName.startsWith("SunOS"))) nativeJar = "solaris_natives.jar.lzma"; else { fatalErrorOccured("OS (" + osName + ") не поддерживается", null); } if (nativeJar == null) { fatalErrorOccured("lwjgl файлы не найдены", null); } else { nativeJar = trimExtensionByCapabilities(nativeJar); urlList[(jarCount - 1)] = new URL(path, nativeJar); } }
723242e1-d4ae-4268-8a35-da04b082eb0e
2
public void changeHeight(int height) { for(int i=0;i<markers;i++) { if(marker[i].isSelectedHeight()) { marker[i].changeHeight(height); } } }
602af59b-8d2e-4595-ab49-c34e4ce44097
3
public String[] getLatLon(int id){ /* * epistrefei tis suntetagmenes enos oximatos */ String[] oxima=new String[2]; try { pS = conn.prepareStatement("SELECT * FROM oximata WHERE id=?"); pS.setInt(1, id); rs=pS.executeQuery(); if(rs.next()){ oxima[0]=rs.getString("lat"); oxima[1]=rs.getString("lon"); } } catch (SQLException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return oxima; }
81009ce9-2331-4384-90c6-fcc60bf7b7c5
3
private void jButton1ActionPerformed(ActionEvent evt) { try { socket = new Socket("127.0.0.1",2009); login = jTextField1.getText(); password = new String(jPasswordField1.getPassword()); LoginCheck lc = new LoginCheck(socket); IDcheck = lc.Check(login, password); if (!IDcheck){ JOptionPane.showMessageDialog(this, "Bad login and/or password."); } else{ t2 = new Thread(new ChatWindow(socket,login)); t2.start(); this.dispose(); } } catch (UnknownHostException e) { System.err.println("Can't connect to address "+socket.getLocalAddress()); } catch (IOException e) { System.err.println("No server listening on port "+socket.getLocalPort()); } }
8f14d2fd-38a9-46ee-a4a1-5877241586c2
2
public void saveUser(User user) { File f = new File(users, user.getUserID() + ".sav"); try { if (!f.exists()) f.createNewFile(); ObjectOutputStream out = new ObjectOutputStream( new FileOutputStream(f)); out.writeObject(user); out.flush(); out.close(); } catch (Exception ex) { ex.printStackTrace(); } }
fec0a77f-6b4c-4c20-9141-26b8a9955994
8
private void showTP() { Object o = logic .showTPStatus(((DeptVO) deptChooser.getSelectedItem()).deptName); if (o instanceof Feedback) { JOptionPane.showMessageDialog(null, ((Feedback) o).getContent()); } else if (o instanceof TPDeptVO) { if (((TPDeptVO) o).isCommitted) { lb.setLabelText(((TPDeptVO) o).fileName); lb.setForeground(Color.BLUE); lb.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { Feedback fb = logic .downloadTPFile(((DeptVO) deptChooser .getSelectedItem()).deptName); if (fb == Feedback.OPERATION_SUCCEED) { JOptionPane.showMessageDialog(null, "文件已打开,请另存。"); } else { JOptionPane.showMessageDialog(null, fb.getContent()); } } }); } else { lb.setLabelText("教学计划未提交"); lb.setForeground(Color.BLACK); } String status = null; if (((TPDeptVO) o).isCommitted) { switch (((TPDeptVO) o).tpState) { case 0: status = "未审核"; fBtn[0].setEnabled(true); fBtn[1].setEnabled(true); break; case 1: status = "审核通过"; fBtn[0].setEnabled(false); fBtn[1].setEnabled(false); break; case 2: status = "审核不通过"; fBtn[0].setEnabled(false); fBtn[1].setEnabled(false); break; default: status = "错误代码" + ((TPDeptVO) o).tpState + ""; fBtn[0].setEnabled(false); fBtn[1].setEnabled(false); } showTeachingPlan(); } else { DefaultTableModel dtm1 = new DefaultTableModel(1, 1); dtm1.setValueAt("教学计划未提交。", 0, 0); table1 = new CommonTable(dtm1); table1.setEnabled(false); js1.setViewportView(table1); cl.show(cardp, "1"); } lb2.setText(status); lb2.setForeground(Color.BLACK); } }
d17c6737-92e8-493a-9c3c-c747c920c332
9
public ImmReg(ImmRegOp operation, long leftOperand, Register rightOperand) { switch(rightOperand.width()) { case Byte: if(leftOperand < Byte.MIN_VALUE || leftOperand > Byte.MAX_VALUE) { throw new IllegalArgumentException("immediate operand does not fit into byte"); } break; case Word: if(leftOperand < Short.MIN_VALUE || leftOperand > Short.MAX_VALUE) { throw new IllegalArgumentException("immediate operand does not fit into word"); } break; case Long: if(leftOperand < Integer.MIN_VALUE || leftOperand > Integer.MAX_VALUE) { throw new IllegalArgumentException("immediate operand does not fit into double word"); } break; default: // this case is always true by construction } this.operation = operation; this.leftOperand = leftOperand; this.rightOperand = rightOperand; }
b3930e0f-954e-4d51-92b4-629d249e1be9
1
public static void main(String arg[]) throws IOException{ Xls_Reader datatable = null; datatable = new Xls_Reader("C:\\CM3.0\\app\\test\\Framework\\AutomationBvt\\src\\config\\xlfiles\\Controller.xlsx"); for(int col=0 ;col< datatable.getColumnCount("TC5"); col++){ System.out.println(datatable.getCellData("TC5", col, 1)); } }
3c6ba56f-71d5-44bb-ac16-3637257654f2
7
public boolean intersects(Dimension d) { int x1 = (int) source.drawx; int y1 = (int) source.drawy; int x2 = (int) destination.drawx; int y2 = (int) destination.drawy; return (((x1 > 0 || x2 > 0) && (x1 < d.width || x2 < d.width)) && ((y1 > 0 || y2 > 0) && (y1 < d.height || y2 < d.height))); }
314f6127-e2aa-4240-91d6-46afbbfc8d1b
7
public static AccessToken getAccessToken(String path, Configuration config) { AccessToken at = null; String token = "325878645-W8s04eclPdOy1QOjyh4WTcdHkeCNttPYTiUIDlAZ"; String tokenSecret = "3M0lrV45DRqZCd5BxCrDHEik5wThOLmkrhc7yqWZYjs"; at = new AccessToken(token, tokenSecret); if (at == null) { try { Twitter tw = new TwitterFactory(config).getInstance(); RequestToken requestToken = tw.getOAuthRequestToken(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (at == null) { // pop up a dialog box to give the URL and wait for the PIN JFrame frame = new JFrame("Twitter Authorisation"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridLayout(5, 1)); JTextField textField = new JTextField(10); textField.setText(requestToken.getAuthorizationURL()); JLabel l1 = new JLabel("Open the following URL and grant access to your account:"); l1.setLabelFor(textField); frame.add(l1); frame.add(textField); JTextField textField2 = new JTextField(10); JLabel l2 = new JLabel("Enter the PIN here and press RETURN:"); l2.setLabelFor(textField2); frame.add(l2); frame.add(textField2); textField2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Twitter4JTools.setPin(e.getActionCommand()); } }); // Display the window. frame.pack(); frame.setVisible(true); while (pin == null) { // wait ... Thread.sleep(1); } try { if (pin.length() > 0) { at = tw.getOAuthAccessToken(requestToken, pin); } else { at = tw.getOAuthAccessToken(); } } catch (TwitterException te) { if (401 == te.getStatusCode()) { System.out.println("Unable to get the access token."); } else { te.printStackTrace(); } } } /* // write to file BufferedWriter bw = new BufferedWriter(new FileWriter(tokenFile)); bw.write(at.getToken() + "\n"); bw.write(at.getTokenSecret() + "\n"); bw.close();*/ } catch (Exception e) { // couldn't write file? die e.printStackTrace(); System.exit(0); } } return at; }
31f4c6f0-0e1c-42f4-baab-91e29088478c
7
public void deleteUser(User user) { System.out.println(users); System.out.println(user); System.out.println("Started delete user"); if(users.contains(user)) { int i = 0; System.out.println("delete user: " + user); while(i<categories.size()) { Category c = categories.get(i); System.out.println("Checking Category: " + c); int j = 0; if(c.getUser().equals(user)) { removeCategory(c); System.out.println("called RemoveCategory"); } else { while(j<c.getMessages().size()) { int k = 0; Message m = c.getMessages().get(j); System.out.println("Checking messages: " + m); System.out.println(""); if(m.getUser().equals(user)) { c.removeMessage(m); System.out.println("called RemoveCategory"); } else { while(k<m.getComments().size()) { Comment cc = m.getComments().get(k); System.out.println("Checking comment: " + cc); if(cc.getUser().equals(user)) { m.removeComment(cc); System.out.println("Removing comment"); } k++; } j++; } } } i++; } } }
1a07ff47-a710-460d-ad77-5d037f15f941
1
private void notifyListeners() { for (ScoreListener listener : listeners) listener.onScoreChanged(); }
beb90d9d-991a-45a7-9b05-bf885c4eade3
8
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = in.readLine(); int n = Integer.parseInt(line); int arr[] = atoi(in.readLine()); int i = 0; int res = 0; ArrayList<Integer> lista = new ArrayList<Integer>(); for (int j = 0; j < arr.length; j++) { if (arr[j] == 1) for (int k = j + 1; k < arr.length; k++) { if (arr[k] == 1) { lista.add(k - j); break; } } } if (lista.size() > 0) { res++; } for (int j = 0; j < lista.size(); j++) { if (lista.get(j) == 1) res++; else if (lista.get(j) == 2) { res += 2; } else { res += 2; } } System.out.println(res); }
e1e985c0-b403-426e-b31e-987196e489a5
7
public boolean concatenateAligned(BitOutputStream src) { int bitsToAdd = src.totalBits - src.totalConsumedBits; if (bitsToAdd == 0) return true; if (outBits != src.consumedBits) return false; if (!ensureSize(bitsToAdd)) return false; if (outBits == 0) { System.arraycopy(src.buffer, src.consumedBlurbs, buffer, outBlurbs, (src.outBlurbs - src.consumedBlurbs + ((src.outBits != 0) ? 1 : 0))); } else if (outBits + bitsToAdd > BITS_PER_BLURB) { buffer[outBlurbs] <<= (BITS_PER_BLURB - outBits); buffer[outBlurbs] |= (src.buffer[src.consumedBlurbs] & ((1 << (BITS_PER_BLURB - outBits)) - 1)); System.arraycopy(src.buffer, src.consumedBlurbs + 1, buffer, outBlurbs + 11, (src.outBlurbs - src.consumedBlurbs - 1 + ((src.outBits != 0) ? 1 : 0))); } else { buffer[outBlurbs] <<= bitsToAdd; buffer[outBlurbs] |= (src.buffer[src.consumedBlurbs] & ((1 << bitsToAdd) - 1)); } outBits = src.outBits; totalBits += bitsToAdd; outBlurbs = totalBits / BITS_PER_BLURB; return true; }
e4aef1d4-21bc-4a8d-bfb2-1e94c819c19c
9
public static void main(String... args) throws IOException { MyScanner sc = new MyScanner(); int n = sc.nextInt(); int m = sc.nextInt(); PriorityQueue<Integer>[] p = new PriorityQueue[n]; for (int i = 0; i < n; i++) { p[i] = new PriorityQueue<>(); } int prev = -1; long globalSum = 0; for (int i = 0; i < m; i++) { int v = sc.nextInt()-1; if (prev != -1 && v - prev != 0) { p[v].add(prev - v); p[prev].add(v - prev); globalSum += Math.abs(prev - v); } prev = v; } long min = globalSum; for (int i = 0; i < n; i++) { long negativesum = 0; long positivesum = 0; long negativeCount = 0; long positiveCount = 0; for (int v : p[i]) { if (v < 0) { negativesum += -v; negativeCount++; } else { positivesum += v; positiveCount++; } } long localSum = negativesum + positivesum; PriorityQueue<Integer> q = p[i]; long lessSum = 0; long moreSum = 0; long lessCount = 0; long moreCount = 0; while (!q.isEmpty()) { long newSum = 0; int v = q.poll(); if (v < 0) { v = -v; lessCount++; lessSum += v; newSum += lessSum - lessCount * v; newSum += (negativeCount - lessCount) * v - (negativesum - lessSum); newSum += positivesum + positiveCount * v; } else { moreSum += v; moreCount++; newSum += negativesum + negativeCount * v; newSum += 1L * (moreCount * v) - moreSum; newSum += (positivesum - moreSum) - (positiveCount - moreCount) * v; } min = Math.min(globalSum - localSum + newSum, min); } } System.out.println(min); }
69719c7f-732f-4776-ae1d-f30cfc1ebc20
8
private void computePositions() { // Determine time for rendering if (fConf.getInt("fixedTime") == 0) { // No fixed time. // final long lTimePassed = System.currentTimeMillis() - fsStartTime; // fCurrentTime = fsStartTime + (long) (fConf.getDouble("timeWarpFactor") * lTimePassed); fCurrentTime = System.currentTimeMillis(); } else { // Fixed time. fCurrentTime = fConf.getInt("fixedTime") * 1000L; } if (fConf.getBoolean("sunMovesP")) { fConf.setSunPos(SunPositionCalculator.getSunPositionOnEarth(fCurrentTime)); } // Determine viewing position if (fConf.is("viewPositionType", "Fixed")) { fViewPos = fConf.getViewPos(); } else if (fConf.is("viewPositionType", "Sun-relative")) { fViewPos = getSunRelativePosition(); } else if (fConf.is("viewPositionType", "Orbit")) { fViewPos = getOrbitPosition(fCurrentTime); } else if (fConf.is("viewPositionType", "Random")) { fViewPos = getRandomPosition(); } else if (fConf.is("viewPositionType", "Moon")) { fViewPos = SunPositionCalculator.getMoonPositionOnEarth(fCurrentTime); } // for ViewRotGalactic, compute appropriate viewing rotation if (fConf.is("viewRotationType", "Galactic")) { fViewRotation = (Toolkit.degsToRads(fConf.getSunPos().getLat() * Math.sin((fViewPos.getLong() - fConf.getSunPos().getLong())))); } else { fViewRotation = fConf.getDouble("viewRotation"); } }
54f7fa41-297d-4db8-9b1f-73deeaff7f44
5
public final SymbolraetselASTNormalizer.num_return num() throws RecognitionException { SymbolraetselASTNormalizer.num_return retval = new SymbolraetselASTNormalizer.num_return(); retval.start = input.LT(1); CommonTree root_0 = null; CommonTree _first_0 = null; CommonTree _last = null; CommonTree BLOCK7=null; CommonTree SYMBOL8=null; CommonTree BLOCK7_tree=null; CommonTree SYMBOL8_tree=null; try { // C:\\Users\\Florian\\Dropbox\\Git\\CI_WiSe2013-2014\\CI_Aufgabe4\\src\\symbolraetsel_AST_Solver\\grammar\\SymbolraetselASTNormalizer.g:27:5: ( ^( BLOCK ( SYMBOL )+ ) ) // C:\\Users\\Florian\\Dropbox\\Git\\CI_WiSe2013-2014\\CI_Aufgabe4\\src\\symbolraetsel_AST_Solver\\grammar\\SymbolraetselASTNormalizer.g:27:7: ^( BLOCK ( SYMBOL )+ ) { root_0 = (CommonTree)adaptor.nil(); _last = (CommonTree)input.LT(1); { CommonTree _save_last_1 = _last; CommonTree _first_1 = null; CommonTree root_1 = (CommonTree)adaptor.nil();_last = (CommonTree)input.LT(1); BLOCK7=(CommonTree)match(input,BLOCK,FOLLOW_BLOCK_in_num174); BLOCK7_tree = (CommonTree)adaptor.dupNode(BLOCK7); root_1 = (CommonTree)adaptor.becomeRoot(BLOCK7_tree, root_1); match(input, Token.DOWN, null); // C:\\Users\\Florian\\Dropbox\\Git\\CI_WiSe2013-2014\\CI_Aufgabe4\\src\\symbolraetsel_AST_Solver\\grammar\\SymbolraetselASTNormalizer.g:27:15: ( SYMBOL )+ int cnt3=0; loop3: do { int alt3=2; int LA3_0 = input.LA(1); if ( (LA3_0==SYMBOL) ) { alt3=1; } switch (alt3) { case 1 : // C:\\Users\\Florian\\Dropbox\\Git\\CI_WiSe2013-2014\\CI_Aufgabe4\\src\\symbolraetsel_AST_Solver\\grammar\\SymbolraetselASTNormalizer.g:27:15: SYMBOL { _last = (CommonTree)input.LT(1); SYMBOL8=(CommonTree)match(input,SYMBOL,FOLLOW_SYMBOL_in_num176); SYMBOL8_tree = (CommonTree)adaptor.dupNode(SYMBOL8); adaptor.addChild(root_1, SYMBOL8_tree); } break; default : if ( cnt3 >= 1 ) break loop3; EarlyExitException eee = new EarlyExitException(3, input); throw eee; } cnt3++; } while (true); match(input, Token.UP, null); adaptor.addChild(root_0, root_1);_last = _save_last_1; } } retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { } return retval; }
bb8d10ed-f947-46c5-ad09-0282fc926cae
3
protected void cellsAdded(Object[] cells) { if (cells != null) { mxIGraphModel model = getGraph().getModel(); model.beginUpdate(); try { for (int i = 0; i < cells.length; i++) { if (!isSwimlaneIgnored(cells[i])) { swimlaneAdded(cells[i]); } } } finally { model.endUpdate(); } } }
ccaa64d2-3b42-438d-bd74-da53e82bc0a3
9
@Override public void reduce(Text key, Iterator<Node> values, OutputCollector<Text, Node> output, Reporter reporter) throws IOException { int min = Integer.MAX_VALUE; Node node = null; while (values.hasNext()) { Node distance = values.next(); if(LOGGER.isDebugEnabled()) { LOGGER.debug("Reduce1 " + key + "\t" + distance.toString()); } min = Math.min(distance.getDistance(), min); if (distance.getFriends() != null) { if (node != null) { throw new IOException("Node " + node.toString() + " already found for " + key.toString() + ": " + distance.toString()); } node = new Node(distance.getDistance(), distance.getFriends()); if(LOGGER.isDebugEnabled()) { LOGGER.debug("Reduce2 " + key + "\t" + node.toString()); } } } if (min < 0) { throw new IOException("min " + min + " less than zero " + key.toString()); } if (node == null) { throw new IOException("Did not find structure for " + key.toString()); } if (min != node.getDistance()) { reporter.incrCounter(Counters.NUMBER_OF_SHORTER_PATHS_FOUND, 1); node.setDistance(min); } if(LOGGER.isDebugEnabled()) { LOGGER.debug("Reduce3 " + key + "\t" + node.toString()); } output.collect(key, node); }
36a1ed32-aae1-432a-b0f3-d9bb4209a21e
3
public SignatureVisitor visitSuperclass() { if (type != CLASS_SIGNATURE || (state & (EMPTY | FORMAL | BOUND)) == 0) { throw new IllegalArgumentException(); } state = SUPER; SignatureVisitor v = sv == null ? null : sv.visitSuperclass(); return new CheckSignatureAdapter(TYPE_SIGNATURE, v); }
98c2c220-21fe-4a10-bc0f-b8eab370260a
8
public void addControlLogic() { Action run = new AbstractAction() { public void actionPerformed(ActionEvent e) { run(); } }; runButton.addActionListener(run); Action clear = new AbstractAction() { public void actionPerformed(ActionEvent e) { clear(); } }; clearButton.addActionListener(clear); Action delete = new AbstractAction() { public void actionPerformed(ActionEvent e) { delete(); } }; deleteButton.addActionListener(delete); commandCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (autoRunCheckBox.isSelected() && autoRunEnabled) { run(); } } }); enableDestinationCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { destinationPanel.setEnabled( enableDestinationCheckBox.isSelected()); } }); KeyAdapter adapter = new KeyAdapter() { public void keyReleased(KeyEvent e) { int code = e.getKeyCode(); if (code == KeyEvent.VK_ENTER) { if (!autoRunCheckBox.isSelected()) { run(); } } else if (code == KeyEvent.VK_UP) { autoRunEnabled = false; } else if (code == KeyEvent.VK_DOWN) { autoRunEnabled = false; } }}; Component editor = commandCombo.getEditor().getEditorComponent(); editor.addKeyListener(adapter); sourcePanel.addEditorKeyListener(adapter); sourcePanel.addComboBoxActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (autoRunCheckBox.isSelected() && autoRunEnabled) { run(); } } }); }
21a9bccd-e5b1-4fb4-81fa-fc4e91b52bfd
8
public void seguridadMenus() { @SuppressWarnings("static-access") String mcodusr = mcod_usr; try { rs = sql.executeQuery("SELECT permission FROM perfil INNER JOIN admg02 ON admg02.id_perfil = perfil.id_perfil WHERE admg02.cod_usr = '" + mcod_usr + "'"); if (rs.next()) { int value = rs.getInt("permission"); if ((perfiles.PERFIL.SOPORTE.value & value) != 0) { SMSOPORTE.setEnabled(true); } else { SMSOPORTE.setEnabled(false); } if ((perfiles.PERFIL.SERVICIO.value & value) != 0) { SMSERVI.setEnabled(true); } else { SMSERVI.setEnabled(false); } if ((perfiles.PERFIL.EQUIPO.value & value) != 0) { SMEQUIPO.setEnabled(true); } else { SMEQUIPO.setEnabled(false); } if ((perfiles.PERFIL.USER.value & value) != 0) { SMUSUARIO.setEnabled(true); } else { SMUSUARIO.setEnabled(false); } if ((perfiles.PERFIL.PERFIL.value & value) != 0) { SMEMPRE.setEnabled(true); } else { SMEMPRE.setEnabled(false); } if ((perfiles.PERFIL.REPORTE.value & value) != 0) { SMLISTA.setEnabled(true); } else { SMLISTA.setEnabled(false); } } /* rs = sql.executeQuery("select * from admg03 Where edo_reg = 'A' and cod_usr = '" + mcodusr + "'"); while (rs.next()) { String mind_rap = rs.getString("ind_rap"); String mcod_prg = rs.getString("cod_prg"); if (mcod_prg.compareTo("FSOPORTE") == 0) { if (mind_rap.compareTo("T") == 0) { SMSOPORTE.setEnabled(true); } else { SMSOPORTE.setEnabled(false); } } if (mcod_prg.compareTo("SERVICIOS") == 0) { if (mind_rap.compareTo("T") == 0) { SMSERVI.setEnabled(true); } else { SMSERVI.setEnabled(false); } } if (mcod_prg.compareTo("AUSUARIO") == 0) { if (mind_rap.compareTo("T") == 0) { SMUSUARIO.setEnabled(true); } else { SMUSUARIO.setEnabled(false); } } if (mcod_prg.compareTo("FEMPRESA") == 0) { if (mind_rap.compareTo("T") == 0) { SMEMPRE.setEnabled(true); } else { SMEMPRE.setEnabled(false); } } if (mcod_prg.compareTo("REPORTE") == 0) { if (mind_rap.compareTo("T") == 0) { SMLISTA.setEnabled(true); } else { SMLISTA.setEnabled(false); } } if (mcod_prg.compareTo("INVENTARIO") == 0) { if (mind_rap.compareTo("T") == 0) { SMEQUIPO.setEnabled(true); } else { SMEQUIPO.setEnabled(false); } } //// }*/ } catch (Exception e) { } }
084335c1-c0a5-4de9-a334-5ec682b8b9fb
8
private WriteConcern buildWriteConcern(final Boolean safe, final String w, final int wTimeout, final boolean fsync, final boolean journal) { if (w != null || wTimeout != 0 || fsync || journal) { if (w == null) { return new WriteConcern(1, wTimeout, fsync, journal); } else { try { return new WriteConcern(Integer.parseInt(w), wTimeout, fsync, journal); } catch (NumberFormatException e) { return new WriteConcern(w, wTimeout, fsync, journal); } } } else if (safe != null) { if (safe) { return WriteConcern.ACKNOWLEDGED; } else { return WriteConcern.UNACKNOWLEDGED; } } return null; }
02a2a751-0f48-4b6a-b9c5-b449e5f93682
5
private final void pop(char c) throws JSONException { if (this.top <= 0) { throw new JSONException("Nesting error."); } char m = this.stack[this.top - 1] == null ? 'a' : 'k'; if (m != c) { throw new JSONException("Nesting error."); } this.top -= 1; this.mode = this.top == 0 ? 'd' : this.stack[this.top - 1] == null ? 'a' : 'k'; }
06447c3d-e79d-4f1b-8daa-3f29baa04376
2
public void dailyBonus(Player player) { //for (List<WorldMapObject> s: p2o.objects()) { for (WorldMapObject o: p2o.objects()) { o.dailyBonus(player); } for (WorldMapObject o: p2h.objects()) { o.dailyBonus(player); } //} }
cc79bddf-41a4-4077-9874-97a2e61ad487
3
@Override public void deserialize(Buffer buf) { id = buf.readShort(); if (id < 0) throw new RuntimeException("Forbidden value on id = " + id + ", it doesn't respect the following condition : id < 0"); finishedlevel = buf.readShort(); if (finishedlevel < 0 || finishedlevel > 200) throw new RuntimeException("Forbidden value on finishedlevel = " + finishedlevel + ", it doesn't respect the following condition : finishedlevel < 0 || finishedlevel > 200"); }
60e76761-1f6f-4be4-bdcb-f6e42ce12c5b
0
public boolean isCellEditable(int row, int column) { return false; }
bc9bc01f-1cc8-44d5-b36a-064ad6979ea9
5
private void doConversion(int startPosition, int stepAlgorithm) { int block[] = new int[BLOCK]; int col = 0; int row; int x = 0; int y = 0; int position = startPosition; for (int i = 0; i < HEIGHT; i += SIZE_BLOCK) { row = i + STEP; for (int j = 0; j < HEIGHT; j += SIZE_BLOCK) { col += STEP; int index = 0; for (int k = position; k < position + BLOCK; k++) { block[index++] = arrayForHuffman[k]; } position += BLOCK; arrayAfterZigZag = deZigZag.getIntegerArray(block); arrayAfterQuant = runQuant(arrayAfterZigZag); for (int k = i; k < row; k++) { for (int s = j; s < col; s++) { yCbCr[k][s][stepAlgorithm] = arrayAfterQuant[x][y]; y++; } y = 0; ++x; } x = 0; y = 0; } col = 0; } }
7213422d-d89e-4308-8e3b-c9c653f88044
3
public void Download10KbyCIKList(String filename) { try { FileReader fr = new FileReader(filename); BufferedReader br = new BufferedReader(fr); String str = br.readLine(); while (str != null) { Download10KbyCIK(str, false); str = br.readLine(); } br.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
73225b38-a173-4e6d-916c-149df4f17b06
9
private void findChromosomeRegionItems(RPTreeNode thisNode, RPChromosomeRegion selectionRegion, ArrayList<RPTreeLeafNodeItem> leafHitItems) { int hitValue; // check for valid selection region - ignore request if null if (selectionRegion == null) return; // check if node is disjoint hitValue = thisNode.compareRegions(selectionRegion); if (Math.abs(hitValue) >= 2) return; // search down the tree recursively starting with the root node if (thisNode.isLeaf()) { int nLeaves = thisNode.getItemCount(); for (int index = 0; index < nLeaves; ++index) { RPTreeLeafNodeItem leafItem = (RPTreeLeafNodeItem) thisNode.getItem(index); // compute the region hit value hitValue = leafItem.compareRegions(selectionRegion); // select contained or intersected leaf regions - item selection is by iterator if (Math.abs(hitValue) < 2) { leafHitItems.add(leafItem); } // ascending regions will continue to be disjoint so terminate nodal search else if (hitValue > 1) break; // check next leaf } } else { // check all child nodes int nNodes = thisNode.getItemCount(); for (int index = 0; index < nNodes; ++index) { RPTreeChildNodeItem childItem = (RPTreeChildNodeItem) thisNode.getItem(index); // check for region intersection at the node level hitValue = childItem.compareRegions(selectionRegion); // test this node and get any leaf hits; intersections and containing if (Math.abs(hitValue) < 2) { RPTreeNode childNode = childItem.getChildNode(); findChromosomeRegionItems(childNode, selectionRegion, leafHitItems); } // ascending regions will continue to be disjoint so terminate nodal search else if (hitValue > 1) break; } } }
a70c56f0-33c8-465c-acfa-701f82d97eb3
0
public Bomb getBomb() { return bomb; }
66dfba71-79c2-4740-af79-da2c3a67c513
7
@Override public boolean onCommand(CommandSender commandSender, Command command, String strLabel, String[] vArgs) { if (commandSender instanceof Player) { KaramPlayer player = m_plugin.playerManager.addOrGetPlayer((Player)commandSender); if (vArgs.length == 1) { if (vArgs[0].equalsIgnoreCase(Commands.SELECT)) { if (player != null) { if (!player.isSelecting()) { player.setSelecting(true); player.sendMessage("Select the first block."); player.setSelectMode(SelectMode.FirstBlock); } else { } } else { } } else if (vArgs[0].equalsIgnoreCase(Commands.DISABLE)) { if (vArgs[1].equalsIgnoreCase(Commands.SELECT)) { player.setSelecting(false); player.sendMessage("Disabled select mode"); } else { } } } else { } } else { } return false; }
7a9f2c6c-105d-43d5-9a81-24b39a8378bc
5
public int removeElement(int[] A, int elem) { // if (A.length==0) return 0; int n = -1; for (int i = 0; i < A.length; i++) { while (i < A.length && A[i] == elem) { i++; } if (i < A.length && A[i] != elem) { n = n + 1; A[n] = A[i]; } } return n + 1; }
ec2e213e-9f22-4d28-aa97-87077e0297d2
1
public boolean shouldDeconstruct() { if (dist > Asteroids.getScreenDims()[0]) return true; return false; }