method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
258ba997-4938-4dd3-ba2d-dea50de6d9de
7
public void setValue(E aValue) { // Only take action when the new value is different from the old value. // If nothing changes nobody should be asked or notified about the change. if(((aValue == null) && (aValue != value)) || ((aValue != null) && (!aValue.equals(value)))) ...
94edd426-3a48-4abd-9df3-6f77da4a042a
3
public void dispatchDownloadTask(final List<File> tasks) { executorService.execute(new Runnable() { @Override public void run() { try { for (File task : tasks) { List<String> urls = getZipFileUrls(task); for (String url : urls) { GutenbergCrawlerHelper.downloadFile(url); } ...
ee8f8325-bd51-4c34-a9b3-2de8a384618b
0
public String toString() { return "[" + buffer.toString() + "]" + " TAPE HEAD AT " + tapeHead; }
7a0c2035-d875-4951-803f-13282c06d1d8
2
private static boolean isValueAnArmstrongNumber(int input) { // convert user int value to a String object in order to use the charAt() method StringBuffer valueAsStr = new StringBuffer(String.valueOf(input)); int combinedTotal = 0; // determine the number of digits in the users input ...
a54406b3-2dcb-410e-989f-bcfec84647a2
6
public WordArranger(String[] words, WordSearch wordSearch) { this.wordSearch = wordSearch; wordPositions = new ArrayList<>(); for (String word : words) { Direction direction = Direction.getRandomDirection(); Point point = getRandomPoint(); wordPositions.add(new Word(word, direction, point)); } L...
906a9cc4-98d6-4279-96d0-230ee2afe894
1
@Override protected void compute() { if (((hii - loi) * (hij - loj)) < t) { sequentiallyUpdate(array, hij, loj, hii, loi); } else { divideTask(array, hij, loj, hii, loi, t, irregular); } }
4816b3c6-08ac-4cbb-9fd0-f3e00e54a038
0
private void initStatusBar(){ statusBar = new JPanel(); statusBar.setBorder(new BevelBorder(BevelBorder.LOWERED)); statusBar.setSize(frame.getWidth() - 10, STATUS_HEIGHT); subject = new JLabel(nameCurrentSubject); subject.setMaximumSize(new Dimension(50, 25)); action = ...
3c78f95e-e78c-43b2-ba08-f46afe5cb541
5
public void move() { // ... Move the ball at the given velocity. m_x += m_velocityX; m_y += m_velocityY; // ... Bounce the ball off the walls if necessary. if (m_x < 0) { // If at or beyond left side m_x = 0; // Place against edge and m_velocityX = -m_velocityX; // reverse direction. } else if (m_x > ...
d896e170-4874-403b-87e5-c1574522f701
7
public static int[] merge(int[] a, int[] b){ int[] result = new int[a.length + b.length]; int aIndex = 0, bIndex = 0, resIndex = 0; while(aIndex < a.length && bIndex < b.length){ if(a[aIndex] == b[bIndex]){ result[resIndex++] = a[aIndex++]; result[resIndex++] = b[bIndex++]; } if(a[aIndex] < b[bI...
78097db3-09f6-40ac-9e37-340cf061b4dd
7
public void nextCity() { if (!finished) { if (!cityPool.isEmpty()) { City bestCity = null; City currentCity = getRoute().getLastCity(); double bestProbability = 0; double alpha = Main.data.getPheromon(); double beta = Ma...
a41287c6-a0be-47c3-a069-1790bffe0d7d
1
public URL createRapport() { try { tempFile = File.createTempFile("rapport", ".html"); tempDir = Utilities.addressFichier(tempFile.getPath(), tempFile .getName()); PrintStream out = new PrintStream(new FileOutputStream(tempFile)); out.pri...
25042f48-f045-41b2-93b9-f5a065e6f4d6
1
@Test public void angleTest() { for (int i = 0; i < TESTS; i++) { double x1 = rand.nextInt(); double y1 = rand.nextInt(); Vector v1 = new Vector(x1, y1); Vector v2 = new Vector(-x1, -y1); assertEquals(v1.angle(), v2.angle().add(new Angle(180.0))); } }
47363d8b-4088-4297-8a4f-f918819fbf4e
1
public String toString(){ String str=this.name + " : " + this.mode + " " + this.data_type.name; if(this.data_type instanceof ArrayType){ ArrayType at = (ArrayType) this.data_type; str +=" RANGE ( "+ at.starting_index + " "+ at.indexing_scheme + " "+ at.ending_index + " );"; } return str; }
44f67bce-ecdf-422d-b64b-208bc16ee7f8
8
void print() { System.out.println("@RELATION Untitled"); for(int i = 0; i < m_attr_name.size(); i++) { System.out.print("@ATTRIBUTE " + m_attr_name.get(i)); int vals = valueCount(i); if(vals == 0) System.out.println(" CONTINUOUS"); else { System.out.print(" {"); for(int j = 0; j < vals; j...
a6491503-ad06-4590-b5d6-dff515e485fb
7
@EventHandler public void punchWool(PlayerInteractEvent event) { CTFTeam team = null; TeamPlayer player = null; for (CTFTeam t: Teams){ for (TeamPlayer p: t.getTeamPlayers()){ if (p.getPlayer().equals(event.getPlayer())){ player = p; team = t; } } } if (player == null){ ...
32e28cdf-6c97-423d-81d8-735321554c89
3
public Tour tourCalc(Double[] currCity, LinkedList<Double[]> unusedCities, Double[] origin) { Tour t1 = new Tour(); //Base case if(unusedCities.size() == 0){ t1.cost = distanceFormula(currCity, origin); t1.tour = ((Integer) origin[0].intValue()).toString(); return t1; } //Set comparison point for...
0f411c85-85ac-4045-88d2-2998ccae2503
0
public Usuario getUsuarioidUsuario() { return usuarioidUsuario; }
b72ebfb2-cee5-4c24-acdf-b278d4e652ba
9
public void SizeOfContribution(AbstractApi api, String outputPath) { List<ClassDocumentation> docs = DeserializeModel(api); Hashtable<Integer,Integer> Askers = new Hashtable<Integer,Integer>(); Hashtable<Integer,Integer> Advisors = new Hashtable<Integer,Integer>(); Hashtable<Integer,Integer> SelfAdvisors = ne...
062cd32e-423d-4895-9879-bb4c08cfa112
4
@Override public List<Action> getActions() throws BadResponseException { List<Action> actions = new ArrayList<Action>(); JsonRepresentation representation = null; // R�cup�ration de la liste des messages Representation repr = serv.getResource("intervention/" + interId + "/action", null); try { represent...
072ee087-dc90-45f3-9173-cb1df3eef188
1
Node reverseCopy() { int len = this.length(); int count = 1; int value = this.kthToLastNode(count); Node copy = new Node(value); count++; while(count <= len) { value = this.kthToLastNode(count); copy.appendToTail(value); ...
5a0bcba0-aef2-496f-97cc-7a8a555fcef5
6
public SliceTaskXmlDriver(String xmlStr) throws DocumentException, XmlTypeErrorException { super(); if (!isSliceTaskXml(xmlStr)) { throw new XmlTypeErrorException("not a valid sliceTask Xml"); } document = DocumentHelper.parseText(xmlStr); timestamp = docu...
17c0c1ca-bef7-41f2-bb14-aeda18c46abe
2
public String createSubForum(User invoker, User moderator, String subForumName, String forumId) { for (int i = 0; i < forums.size(); i++) { if (forums.get(i).getId().equals(forumId)) return forums.get(i).createSubForum(invoker, moderator, subForumName); } return null; }
9411866a-b2a0-4ced-9dc3-f9073052f75a
7
* @return MethodSlot */ public static MethodSlot lookupFunction(Symbol functionsymbol) { functionsymbol = functionsymbol.softPermanentify(); { StandardObject function = ((StandardObject)(Stella.$FUNCTION_LOOKUP_TABLE$.lookup(functionsymbol))); if ((function != null) && (function.primaryTyp...
6159c3fe-a139-4dba-b24e-29978ba0030a
8
public List<Entity> getEntities(Entity ee) { hits.clear(); int x0 = ee.xSpot - 1; int y0 = ee.ySpot - 1; int x1 = ee.xSpot + 1; int y1 = ee.ySpot + 1; for (int x = x0; x <= x1; x++) for (int y = y0; y <= y1; y++) { if (x >= 0 && y >= 0 && x < width && y < height) { List<Entity> es = entityMap[x...
ce9e28be-f704-4459-9407-63b0b30b6c59
8
public boolean loadCustomListeners() { killstreakListeners.clear(); victoryListeners.clear(); boolean errors = false; File listenerDir = new File(OITG.instance.getDataFolder() + File.separator + "listeners"); listenerDir.mkdirs(); ClassLoader cl; try { ...
a50ede88-5cb4-4b23-9535-71697a19bf7b
7
public boolean isGameOver() { String symbolOne = String.valueOf(players.get(0).getSymbol()); String symbolTwo = String.valueOf(players.get(1).getSymbol()); if (checkForDiagonalStrike(symbolOne) || checkForDiagonalStrike(symbolTwo) || checkForHorizontalStrike(symbolOne) || checkForHorizontalStri...
27107091-010d-4d91-a9e8-5e17265abfd5
3
public void Update(double speedY, int y) { //if (y <= 350) { if (speedY <= -5) { speed = speedY; this.y -= -45; } else if (speedY <= -3) { speed = speedY; this.y -= -30; } else if (speedY < 0) { s...
6b873e6a-02f0-4bb1-b47b-857e450f8fd1
1
int getMergedType(final int type1, final int type2) { key2.type = TYPE_MERGED; key2.longVal = type1 | (((long) type2) << 32); key2.hashCode = 0x7FFFFFFF & (TYPE_MERGED + type1 + type2); Item result = get(key2); if (result == null) { String t = typeTable[type1].strVal1; String u = typeTable[type2].strVal...
d96bb4af-af34-4f59-91dc-20aabeb53fbd
8
@EventHandler public void onTeleportToWorld(PlayerTeleportEvent event) { Player p = event.getPlayer(); String tow = event.getTo().getWorld().getName(); if (plugin.getConfig().getBoolean("worlds." + tow + ".enabled") && plugin.getConfig().getInt("worlds." + tow + ".players") != -1) { ...
48d8533b-2650-427b-a124-77e93dade005
3
public String validate(){ for (AbstractUnit unit : units) { if(unit instanceof IInstructionUnit){ String error = ((IInstructionUnit)unit).validateIntruction(); if (error != null){ unit.color = Color.YELLOW; return unit.unitNumbe...
b03de6dd-6d04-4803-8b40-d76f56d86786
9
public void Sprint(Rachel r){ if(seePlayer(r)){ follow++; } if(beganSprinting()){ started++; } if(follow > 0){ if(facingUp){ setUp(true); }else if(facingRight){ setRight(true); }else if(facingDown){ setDown(true); }else { setLeft(true); } if(sta...
a9f69795-0f8c-4966-a920-fa986c729753
9
public String printInstructions() { List<Integer> pinList; PinController pinC = new PinController(); StringBuilder ret = new StringBuilder(); for (Component c : getComponents()) { String name = c.getName(); pinList = pinC.getComponentPins(name); if (c instanceof LedComponent || c instanc...
ee91f6b6-1abd-4306-b8f1-fbff1ab30346
2
double testPredicting(NHL nhl) { double profit = 0; count = 0; for (int i = 0; i < nhl.getAmountMatches(); i++) { double current = nhl.tryGetProfit(nhl.getMatch(i)); profit += current; if (current != 0) { count++; // out.printl...
84896837-85ad-476b-959d-dd574bc6f0e2
1
private DCPackage receiveDCPackage() throws IOException { byte[] buffer = new byte[DCPackage.PACKAGE_SIZE]; for(int i = 0; i < DCPackage.PACKAGE_SIZE; i++) { buffer[i] = (byte) is.read(); } return DCPackage.getPackage(buffer); // String s = Arrays.toString(buffer); // Debugger.println(2, "[Connection] re...
a20b1e02-612e-4a9b-b198-01b7ef87b2aa
0
public Object[] getArenas() { return arenas.entrySet().toArray(); }
b5c5517a-f8a8-43cf-9830-05ac2f25aad6
6
@Override public void caseAMethodCallExp(AMethodCallExp node) { inAMethodCallExp(node); if(node.getRPar() != null) { node.getRPar().apply(this); } if(node.getExplist() != null) { node.getExplist().apply(this); } if(node.getL...
58c2412d-02b9-455b-a4f5-d7e0aab89bd6
7
public static int calcDiff(String word1, String word2){ int diff = 0; int j=0; for(int i=0; i<word1.length(); i++){ char ch1 = word1.charAt( i ); if(word2.length()<=j){ diff++; continue; } char ch2 = word2.charAt( j+...
cf16e867-8384-4796-b18f-4f27425a4f28
9
public static void main(String[] args) { int N = Integer.parseInt(args[0]); // add elements 1, ..., N System.out.println(N + " random integers between 0 and 99"); DoublyLinkedList<Integer> list = new DoublyLinkedList<Integer>(); for (int i = 0; i < N; i++) list.add((int) (100 * Math.random())); System.o...
64770b97-24ab-4d27-9356-26bc44b03c72
5
private static final ZLibResult compress(byte[] text) throws IOException { if (text.length == 0) { return new ZLibResult(text, false); } int length = text.length; byte[] bin = null; if (length < 44) { /* NOP */ } // DCI: required for Java...
fbbe8153-ac08-43ce-a947-2bdd6ffedc85
9
@Override public synchronized T borrowObject() throws Exception { assertOpen(); T obj = null; boolean newlyCreated = false; while(null == obj) { if(_pool.isEmpty()) { if(null == _factory) { throw new NoSuchElementException(); ...
800d7420-4e0f-4643-9d47-17e995918ec4
6
public void engineNextBytes (byte[] bytes) { int index = 0; int todo; byte[] output = this.remainder; // First use remainder from last time int rC = this.remCount; if (rC > 0) { todo = (bytes.length - index) < (4 - rC) ? (bytes.length - index) : (4 - rC); for (int i = 0; i < todo; i++, rC++) ...
54eb8ff0-09db-4bad-89b3-005cc480be7b
7
private String[] getOutputHelper(String hide) { String rowBar = " "; String[] retval = new String[1 + (4*height) + 1]; String bar = "-"; for(int i=0; i<width; i++) { bar = bar + "-----"; rowBar = rowBar + " " + (i%10) + " "; } retva...
29a8bdfc-0a03-4f37-8fb3-26bf25e78ac6
6
private static String getAnnotations(BotState state) { List<Region> relevantRegions = new ArrayList<>(); for (Region region : state.getVisibleMap().getRegions()) { if (region.getPlayerName().equals(state.getMyPlayerName()) || region.getPlayerName().equals(state.getOpponentPlayerName()) || region.getPla...
abb6fe0b-b5cb-491e-9b06-c2d3f8372c53
2
private Vector3D getAccelerationForCraft(Craft craft) { // Uses mass of all bodies Vector3D aTotal = new Vector3D(); for (int i = 0; i < bodies.size(); i++) { Body body = bodies.get(i); if (body.mass == 0) { break; } Vector3D diff = body.position.clone().subtract(craft.position); double mag =...
6ca90999-0e06-464f-88f0-265cdaadf1c3
0
@Test @Ignore // not supported yet, would require condition evaluation public void runTestExceptions3() throws IOException { InfoflowResults res = analyzeAPKFile("GeneralJava_Exceptions3.apk"); Assert.assertEquals(0, res.size()); }
74ce35af-00b2-41f7-8109-f105cb0d6fe6
6
@Override public void init() { super.init(); int vertShader = 0, fragShader = 0; try { vertShader = createShader("shaders/screen.vert", ARBVertexShader.GL_VERTEX_SHADER_ARB); fragShader = createShader("shaders/screen.frag", ARBFragmentShader.GL_FRAGMENT_SHADER_ARB); ...
7971e985-65f2-4852-b128-f5d6eb630812
4
@Override public void mouseMoved(MouseEvent me) { //System.out.println("Length="+a.getPanel().lineList.size()); boolean wasOver=false; for (int i=0;i<a.getDataModel().getCurveList2().size();i++) { for (int j=0;j<a.getDataModel().getCurveList2().get(i).getLineList().size();j++) { if (a.getDataModel().getCu...
a4147067-25db-4144-93a3-b886ca576d21
0
public Person2(String name, int age) { this.name = name; this.age = age; }
e8e0e23b-981f-42f8-9cf6-31b0ebdced2b
9
public Coordinates createShifted(Action.action a) { Coordinates dest = null; switch (a) { case WAIT: dest = new Coordinates(this); break; case NORTH: dest = new Coordinates( this.getX() - 1 < 0 ? Util.DIM - 1 : this.getX() - 1, this.getY() ); break; case SOUTH: ...
687fb294-ce2e-48c9-be4f-a7ad56735644
9
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { super.executeMsg(myHost,msg); if(!(affected instanceof MOB)) return; final MOB mob=(MOB)affected; if((msg.amISource(mob)) &&(msg.targetMinor()==CMMsg.TYP_WEAPONATTACK) &&(mob.isInCombat()) &&(!mob.amDead()) &&(msg.ta...
31f4ab40-927f-465b-9a1e-1691b63f9f0c
4
@Test public void addsStuff() { list.add("Hello"); list.add("world"); list.add("whaz"); list.add("good?"); assertTrue(list.getNext().equals("Hello") && list.getNext().equals("world") && list.getNext().equals("whaz") && list....
0870b615-53f3-4d58-982e-2e4378f8b602
9
private GenericTreeNode<LayoutParserTreeElement> parseXMLRow( Match currentMatch) { GenericTreeNode<LayoutParserTreeElement> parentTreeNode = null; int i; int top = -1; int bottom; int right; int left; // Parsam atributele ca sa nu dea eroare if (currentMatch.attr("top") != null) { top = Integer....
7f546043-a51d-473d-bc08-b77086f55744
9
public void uimsg(String msg, Object... args) { if (msg == "set") { synchronized (ui) { int i = 0, o = 0; while (i < equed.size()) { if (equed.get(i) != null) equed.get(i).unlink(); int res = (Integer) ar...
a9a22ad9-2c46-4b70-b066-9fdee7b933bf
2
public void associate(int roomNumber, String type) { //got error TypeEntity tempType = new TypeEntity(); Query q = em.createQuery("SELECT t from TypeEntity t"); for (Object o : q.getResultList()) { TypeEntity p = (TypeEntity) o; if (p.getName().equals(type)) { ...
c0d24415-f0dc-4a8e-97be-d5db70f9dc71
2
public static List<Commercial> selectCommercial() throws SQLException { String query = null; List<Commercial> util = new ArrayList<Commercial>(); ResultSet resultat; try { query = "SELECT * from COMMERCIAL "; PreparedStatement pStatement = (PreparedStatement) Co...
6f047a3c-a682-41ef-8cea-b6fe41590acc
7
private void updateLocatorValues() { boolean locatorFound=false; try{ Map<String, List<TestcaseStep>> testcaseSteps = this.getTestcaseQue(); for(String tcID : testcaseSteps.keySet()){ for(TestcaseStep tcStep: testcaseSteps.get(tcID)){ String fieldName =tcStep.getFieldName(); if(fieldName.equals...
a8e0f7a1-5b32-489d-ad66-2986683ad0d8
4
private static void listFiles() { try { Registry nameNodeRegistry = LocateRegistry.getRegistry(Hdfs.Core.NAME_NODE_IP, Hdfs.Core.NAME_NODE_REGISTRY_PORT); NameNodeRemoteInterface nameNodeStub = (NameNodeRemoteInterface) nameNodeRegistry.lookup(Hdfs.Core.NAME_NODE_SERVICE_NAME); PriorityQueue<String> rst = na...
197ffbf5-aa41-45de-afb5-92cf02e81b0f
3
public void paintComponent(Graphics g){ // Draw the background image on the panel if(firstPage){ g.drawImage(background, 0, 0, this.getWidth(), this.getHeight(), this); } else if(secondPage){ g.drawImage(background2, 0, 0, this.getWidth(), this.getHeight(), this);...
08c9c80a-be96-448c-8c13-183828a25a88
5
public void execute(InetAddress addr, int port, JSONObject arguments) { try { // Récupération des arguments UUID clientUUID = UUID.fromString(arguments.getString("uuid")); JSONArray jsonMessages = arguments.getJSONArray("messages"); List<Message> messages = new Vector<Message>(); for (int i = 0;...
1ce7b4f7-a27c-47cc-92f9-592786ae83ac
9
@Override public void remove(T toDelete) { if(head == null){ throw new IndexOutOfBoundsException(); } else { Node<T> temp = head; while (temp.right != null) { if (temp.data.equals(toDelete)) { if (temp.left != null && temp.right...
b0774957-b970-4af9-a0ec-03f377dbdbb9
3
private int getAndMoveToFrontDecode0(final int groupNo) throws IOException { final InputStream inShadow = this.in; final Data dataShadow = this.data; final int zt = dataShadow.selector[groupNo] & 0xff; final int[] limit_zt = dataShadow.limit[zt]; int zn = dataShadow.minLens[zt]; ...
b21f9b15-9775-4b33-a712-b20e3182e687
6
private void cribaEratostenes2(long n) { long k, pos; long numMaxPrimos = (n - 3) / 2; long numPrimos = 0; long[] primos = new long[(int)numMaxPrimos + 1]; boolean[] esPrimo = new boolean[(int)numMaxPrimos + 1]; for(long i=0; i < numMaxPrimos; i++) ...
234a8f30-f925-4c6c-bb9e-c533c5dd7957
2
public static double atanh(double a){ double sgn = 1.0D; if(a<0.0D){ sgn = -1.0D; a = -a; } if(a>1.0D) throw new IllegalArgumentException("atanh real number argument (" + sgn*a + ") must be >= -1 and <= 1"); return 0.5D*sgn*(Mat...
d3a896c6-b5c1-4d77-be07-f4daa8ce92ae
3
public static void main(String[] args) throws IOException { // TODO Auto-generated method stub out.println("Please enter the maze you would like to run:"); String input = "src/MazeReadIn/trickySearch";//console().readLine(); String output = input+"Solution"; Maze myMaze = ReadMaze.parseMaze(input); // classNa...
9f2b9c7a-9cb5-4ee0-9f33-34621af6cecc
3
private static double[] getProbabilitiesOfColorLevel(Image img, ChannelType c) { double[] probabilities = new double[Image.MAX_VAL + 1]; for (int x = 0; x < img.getWidth(); x++) { for (int y = 0; y < img.getHeight(); y++) { int aColorPixel = (int) img.getPixel(x, y, c); probabilities[aColorPixel]++; ...
880be476-cb41-48cd-b262-148db37996cb
5
protected int getNeighbours(int row, int column) { int neighbours = 0; for (int i = -1; i <= 1; i++) { if (isLive(row - 1, column + i)) { neighbours += 1; } if (isLive(row + 1, column + i)) { neighbours += 1; } } if (isLive(row, column - 1)) { neighbours += 1; } if (isLive(row,...
ff830112-c721-494b-810a-dd09dce041fe
2
@Override public void update(LineEvent event) { LineEvent.Type type = event.getType(); if (type == LineEvent.Type.START) { System.out.println("Playback started."); } else if (type == LineEvent.Type.STOP) { playCompleted = true; Syst...
fac4161f-a33f-4618-a6a2-4ffa58580001
3
public void setPositionEntity(boolean cartesien, int XOrAngle, int YOrRadius) { if(cartesien){ this.setPosition(XOrAngle, YOrRadius); this.radius = (int) Math.sqrt(Math.pow(XOrAngle, 2) + Math.pow(YOrRadius, 2)); if(radius>0){ angle = (int) Math.atan(YOrRadius/XOrAngle); }else if...
42ab2089-60cb-4ba3-9ea3-cf62f290f711
4
@Override public void timeHasChanged() { Config.ZeitAbschnitt[] a = Config.getAbschnitte(); AZeit gesamtZeit=new Zeit(0); AZeit restProduktivZeit = minProduktivForPlus; AZeit restAbwesenheit = abwesenheit; for(int i=0;i<a.length;i++) { if (a[i].arbeit) { if (restProduktivZeit.getMinutes() > a[...
f834017e-23b8-40ce-9d10-1b353b6d9396
4
private void mergeWithoutCopy(T[] src, T[] dst, int lo, int mid, int hi) {// Though 'mid' can be calculated in the body, it is sent as a parameter as // one may always not want to merge 2 equal subarrays. Look at bottem up // merge sort // i and j is used to point to the currently processing element ...
2ba131de-823d-410c-a017-56c70af733d8
1
public static Vector multiply(Vector op1, Double op2) { Vector result = new Vector(op1.getDimension()); for (int i = 0; i < result.getDimension(); i++){ result.setComponent(i, op1.getComponent(i)*op2); } return result; }
20d5b841-94af-4d30-ba8e-a7954c021592
8
private static List findClasses(File directory, String packageName) throws Exception { List classes = new ArrayList(); if (!directory.exists()) { if (bDebug) System.out.println("目录不存在:" + directory.getAbsoluteFile()); return classes; } File[] files = directory.lis...
c0d279f8-2413-4ddd-9f5b-6481f0b29069
5
private PriorityQueue<KeyValue<Object, Object>> sortReducerInput(){ FileInputStream fileStream; try { System.out.println(mapperOutputPath+"/"+ReducerInputFileName); fileStream = new FileInputStream(mapperOutputPath+"/"+ReducerInputFileName); try { ObjectInputStream input...
63c7fb8d-aeb7-4654-b3de-ccb1b598aff4
0
public void addColleague(Colleague colleague) { colleague.setMediator(this); colleagues.put(colleague.getName(), colleague); }
208b9e65-a1eb-404e-b1f4-d32abbabd7b5
3
public void entityProcessComplete(CAS aCas, EntityProcessStatus aStatus) { if (aStatus.isException()) { List<Exception> exceptions = aStatus.getExceptions(); for (int i = 0; i < exceptions.size(); i++) { ((Throwable) exceptions.get(i)).printStackTrace(); } return; }...
90035fad-2166-43ab-a51a-c9427ffcf809
3
public static void exportDatabase(List<String> tableName, String zipName) throws ClassNotFoundException, SQLException { String driverName = "org.apache.derby.jdbc.EmbeddedDriver"; String clientDriverName = "org.apache.derby.jdbc.ClientDriver"; String databaseConnectionName = "jdbc:derby:WinchCom...
89f31666-c78d-4740-9cf3-0821fbaf36af
3
public static byte[] booleanArray2ByteArray(boolean[] input) { byte[] result = new byte[input.length / 8]; for(int i = 0;i < input.length;i += 8) { //result[i / 8] = 0; for(int j = 0; j < 8; j++) { if(input[i+j]) result[i / 8] |= (1 << Math.abs(j-7)); else result[i / 8] &= ...
b01bfbaa-1996-44aa-876e-a7a291016f41
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...
e226e178-2325-47bc-835c-8f1bd4a64bc0
9
public void aggiornaCorsie(List<Integer> corsie, List<Colore> colori) { outStream.print("|"); int j = 0; for(Integer posizioneScuderia : corsie){ String abbrScud = colori.get(j).name().substring(0,3); outStream.print("="+abbrScud+"="); j++; }; outStream.print("|"); outStream.println(); for(int i...
e58df117-982f-4524-9dc9-198b89fb5275
5
public String readCommand() throws Throwable { String result; StringBuilder buffer; String line; String prompt; prompt = "> "; buffer = new StringBuilder(); do { System.out.printf(prompt); line = reader.readLine(); line = StringUtils.trim(line); buffer.append(line); buffer.append(' '); ...
01d607cd-a9e6-459f-929e-6273ed406368
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...
1340486c-2475-4351-a636-63d9d5f3d7b4
6
private void cmdMOVED(ArrayList<String> args) { if (status == INGAME) { if (args.size() == 4) { try { if (autoCrapTalk) { if (myTurn) { sendMessage(util.CrapTalker .insult(util.CrapTalker.INSULTS_ME_MOVE)); } else { sendMessage(util.CrapTalker .insult(util.CrapT...
1e563356-c88e-49a3-bdd9-163bfeafd522
6
public static double determinant(double[][] m) { double res = 1.0; /* Row reduce. */ for (int i = 0; i < m.length; i++) { /* Find a row with a nonzero entry and swap. */ for (int j = i; j < m.length; j++) { if (Math.abs(m[j][i]) > ...
64be9b04-0823-4c07-8729-dbf6168a6f30
4
public void markIO (Circuit c, int[] tsize) { tsize[0] = 0; tsize[1] = 0; // scan through all format object for input objects for (int i = 0; i < FMT.size(); i++) { IO io = FMT.elementAt(i); // mark all input/output wires for (int j = 0; j < io.getN...
274422d3-5963-41c6-8792-0bfee5f21239
1
public void setStatus(Boolean b){ if(b){ lblTrue.setText("Evet"); lblTrue.setForeground(Color.GREEN); }else{ lblTrue.setText("Hayır"); lblTrue.setForeground(Color.RED); } }
c9b6d7d6-e270-4310-9a0f-d464be20cf98
2
public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SPACE) { spacePressed = false; if (activeMode == defaultMode) { setCursor(defaultCursor); } } }
4cec9633-1195-42e5-a8f7-97c7574a16c6
7
public static void removeEmployee() { File f = new File("Employee.txt"); String choice = "y"; try { PrintWriter pw = new PrintWriter(new FileOutputStream(f, false)); while (choice.equalsIgnoreCase("y")) { System.out.print("Please enter the username you would like to remove: "); String user...
774c4a33-e90c-44d2-8af3-618b466d0b57
9
@Override protected CommandExecutionResult executeArg(Map<String, RegexPartialMatch> arg) { final String ent1 = arg.get("ENT1").get(1); final String ent2 = arg.get("ENT2").get(1); final IEntity cl1; final IEntity cl2; final IEntity normalEntity; final String suffix = "lol" + UniqueSequence.getValue(); ...
c886af74-32a7-41f4-be72-e1c4e0256c6b
0
public void removePawn(final Pawn pawn) { pawns.remove(pawn); }
c2c6cb3f-5621-4e69-bbf0-d79e675eb520
6
public static ListNode reverseKGroup(ListNode head, int k) { if (head == null || k < 2) { return head; } int[] temp = new int[k]; int step = 0; ListNode p = head; ListNode q = head; while (p != null) { int i = step++ % k; temp[...
c7ea3127-52a4-4140-8108-200c7f1e7bdb
7
public static int selectKth(int[] arr, int k) { if (arr == null || arr.length <= k) throw new Error(); int from = 0, to = arr.length - 1; // if from == to we reached the kth element while (from < to) { int r = from, w = to; int mid = arr[(r + w) / 2]; // stop if the reader and writer meets whi...
5a834daf-ca90-4809-a4d6-bae9dbd1c02a
2
@Override public int compareTo(Vertex o) { if (distToMST > o.distToMST) return 1; else if (distToMST < o.distToMST) return -1; return 0; }
0dda2e57-5ec3-4cc6-8da4-e1f9d3ffde17
2
public void destruct() { for(int i = 0; i < maxPlayers; i++) { if(players[i] == null) continue; players[i].destruct(); players[i] = null; } }
7a28944d-981f-42d1-818d-447caef35f4b
5
public void moveForItems(Person p, ITask task, SimulationMap map){ LOG.info(p.name + " is fetching item:"); for(String str: task.getRequiredItemsSet()){ if(!p.hasItem(str, task.getRequiredItems().get(str)) && map.hasItem(str, task.getRequiredItems().get(str))){ p.setTargetIte...
e76baacc-61ca-4467-b12c-6cc88ae5c36f
4
public void setDeclaracao(List<?> list) { for(PDeclaracao e : this._declaracao_) { e.parent(null); } this._declaracao_.clear(); for(Object obj_e : list) { PDeclaracao e = (PDeclaracao) obj_e; if(e.parent() != null) { ...
4f731ba6-9617-491c-8c59-d8b9ecf361dc
1
private Void directDownload() { BufferedImage newImage; try { newImage = ImageIO.read(directURL); } catch (IOException e) { return null; } BufferedImage image = transform(newImage); button.setImage(image); return null; }
96b5457b-53e3-4d43-97c1-26a755a69f03
1
private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked this.jPanel1.setVisible(false); this.jPanel3.setVisible(false); if (this.jPanel2.isVisible()) this.jPanel2.setVisible(false); else { this.jPanel2.setVi...
2fea300d-0ae7-497b-b7db-c32751e31331
9
public ControllerWrapper(Controller controller, String groupName, String groupAddress, String pName, double cpuThreshold) throws ClientConstructorException { try { this.controller = controller; //bound to controller this.groupName = groupName; this.groupAddress = groupAddress; this.pName = pNam...
5885377d-5b05-4886-acc9-3ddb9afda098
8
public boolean canCastleLeft(Board board) { if (!this.canCastle) { return false; } if (this.inCheck(board)) { return false; } PossibleTile space1 = new PossibleTile(this.getX() - 1, this.getY(), this); PossibleTile space2 = new PossibleTile(this.getX() - 2, this.getY(), this); PossibleTile space3 = ...
5eecda7c-2657-4c37-b64f-737df17dd3c4
6
private boolean isPlayerNameOk(ArrayList<String> joueurs) { ArrayList<String> copiListeJoueur = new ArrayList<String>(joueurs); //quelques vérifications de base for (String nomJoueur: joueurs) { if (nomJoueur.isEmpty() || nomJoueur==null || nomJoueur.length()>30) { JOptionPane.showMessageDialog(new Fra...