method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
e763dd08-deef-452c-a0a8-9b98d0064ca7
4
public void run() { // we don't expect this program to run on heavy load // everything runs in ONE thread! byte buffer[] = new byte[1024]; while (true) { try { DatagramPacket p = new DatagramPacket(buffer, buffer.length); listenSocket.receive(p); if (p.getLength() == 0) { System.out.println...
e829348e-381f-4919-9d39-feedf2fa5f52
7
public void bulletAction (Coords screenOffset) { Graphics2D g = (Graphics2D) strategy.getDrawGraphics(); if (bullets.size() > 0) { for (int i = 0; i < bullets.size(); i++) { BulletEntity bullet = bullets.get(i); bullet.moveBullet(); if (middleLay...
a763d80d-bb34-4c4f-a09d-62928013bbc6
5
public float[] computeBackwardError(float[] input,float []error) { // проверки if (input == null || input.length != size || error == null || error.length != size) throw new IllegalArgumentException(); // расчитываем ошибку float[] backwardError = new float[size]; ...
b4ae4ad0-f296-4d46-b2d2-c1dcaf2db66c
6
public void assignFitnessRank() //assumes 10 fit teams left out of 20 { for (int i = 0; i< 10; i++) { if (i>=0 && i<=3) { population.get(i).modifyFitnessRank(1); } if (i>3 || i<=7) { population.g...
896091c7-7152-41de-b144-768251710e46
6
public void loadCreatureSprites() { Image[][] images = new Image[10][]; // load left-facing images images[0] = new Image[] { loadImage("Pomf/PomfW1.png"), loadImage("Pomf/PomfW2.png"), loadImage("Pomf/PomfW3.png"), loadImage("Enemigo2/Enemigo2W1.p...
300c6cf2-7bb5-45f3-8e42-be970509f7d5
6
private void set(byte p, boolean intersectable, int k) { if(p < MIN_P) { throw new IllegalArgumentException("HLLCounter precisions cannot be less than MIN_P = " + Byte.toString(MIN_P)); } if(p > MAX_P) { throw new IllegalArgumentException("HLLCounter prec...
9cffc733-1a8a-41ee-a243-a04e146043c7
2
public void registerNode(final CloudNode cloudNode) { Objects.requireNonNull(cloudNode, "The given cloud node must not be null."); final String nodeName = cloudNode.getName(); final NodeRecord record = new NodeRecord(nodeName, Holder.INSTANCE.getMemberId()); HazelcastHelper.getMap(ACTIV...
6bd2b545-edae-4743-8b2e-d238f2ba30c0
8
public void shuffle(int numberOfPlayer) { //Have the game tell what turn it is //Code if(numberOfPlayer == 1) { for(int i = 0; i < player1Deck.size();) //While the deck size still have things left in it. { randomCard = generator.nextInt((player1Deck.size()+1)); temp.add(player1Deck.get(randomCar...
93c68308-553e-4865-ae34-b4225236bf83
5
public boolean checkNotEmpty() { if (this.schemaName.isEmpty() || this.schemaPassword.isEmpty() || this.baseName.isEmpty() || this.basePort.toString().isEmpty() || this.baseHost.isEmpty() ) { return false; } return true; }
ccc6d269-a7e7-4199-bd62-640472917573
0
public double getError() { return sqError; }
de9d9f0c-9006-4ec1-a362-ceb09492267b
5
@Override public boolean equals(Object o) { if (o instanceof Collision) { Collision c = (Collision) o; if (c.s1 == s1 || c.s2 == s1 || c.s1 == s2 || c.s2 == s2) return true; } return false; }
5bc90179-9e64-4eb9-8b90-49852d4f47d6
1
public String getProperty(String s){ try{ PersistentEntry persistentEntry = (PersistentEntry) em.createNamedQuery(PersistentEntry.FIND_BY_CATEGORY_AND_KEY). setParameter("category", getPropertiesFilename()). setParameter("ke...
4422b478-d34d-4d1c-b430-547ddcb3a0cd
5
@Override public int move(State state) { //Return the move with the best score int bestMove = -1; char color = state.getColorToPlay(); int bestScore = color == 'X' ? -101 : 101; //initialize best score as impossibly low/high depending on player for comparison for(int child : state.legalMoves()){ State co...
64b56cdc-6fa4-469c-b55e-a33e2b4961bb
7
@Override public double predict(int userID, int movieID) { double rating = 0; ArrayList<Double> sim = new ArrayList<Double>(); ArrayList<Double> rat = new ArrayList<Double>(); ArrayList<Double> avg = new ArrayList<Double>(); HashMap<Integer, Double> tempHashMap = similarities.get(movieID); if (tempHashMa...
11f8d594-e7b1-4950-bc00-838d0e21e1ba
7
private double surfacePotentialBisection(double pLow, double pHigh, double sigma, int n){ double surPot = 0.0D; // temporary values of the surface potential // Bisection method converging on sigma calculated = true sigma boolean testC = true; int testCiter = 0; int testCmax = ...
e0c6f11a-5bef-4f4e-b208-ac8736e70cfb
4
public int getGridHeight(){ boolean test = false; if (test || m_test) { System.out.println("Grid :: getGridHeight() BEGIN"); } if (test || m_test) { System.out.println("Grid :: getGridHeight() END"); } return m_Grid[0].length; }
10b6d56f-7dcc-4005-a64f-8681c7bbf602
7
public void forceMove() { if (currentPiece == null) { currentPiece = nextPiece; nextPiece = randomShape(); if (!placeShape(currentPiece)) { gameOver = true; } } else if (currentPiece.getY() + currentPiece.getHeight() == ROWS) { ...
d6f4b9ec-9977-4984-b710-0271b6c6ffda
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...
fa276f05-2aec-4622-8e70-ce9ec40750a2
8
public static boolean checkPVO(PickVO pvo, BNUPtnFilter filter) { int[] rr = pvo.getArray(); int sum = ArrayUtil.sumArray(rr); int[] ff = ArrayUtil.fourFloorPtn(rr); if(filter.filtered(rr, 1)==true || sum<90 || sum>150 || ff[0] > 2 || ff[1] > 3 || ff[2] > 3 ...
c572f282-5cba-4fb0-bbde-2c658ed23f59
1
public static boolean isInteger(String str) { try { Integer.parseInt(str); } catch (NumberFormatException e) { return false; } return true; }
d34318c7-780c-4ecb-8051-2bbf867b7282
7
protected void getOuput(HashMap<String, Double> incoming, double[] preds) throws Exception { if (preds.length != m_outputNeurons.length) { throw new Exception("[NeuralOutputs] Incorrect number of predictions requested: " + preds.length + "requested, " + m_outputNeurons.length + " expect...
096b4144-b81f-4267-9445-8977c122fc4a
0
public List<VPosFuncionarios> getVPosFuncionarios(int posID){ return getHibernateTemplate().find("from VPosFuncionarios where fesIdPos = ? and fesEstado <> 'A' and fesEstado <> 'X' ", posID); }
5b18550c-2fd7-43c5-a3b6-32564548fee4
9
public static void main(String[] args) throws Throwable{ BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); for(StringTokenizer st;(st=new StringTokenizer(in.readLine()))!=null;){ int N=parseInt(st.nextToken()),M=parseInt(st.nextToken()),R=parseInt(st....
1a0ff751-ba06-4bfb-b4cc-493c5bf72f59
1
void printList(ListNode head){ for(;head != null; head = head.next){ System.out.println(head.val); } }
c0ec2d86-11f5-42f3-8434-8ddef5949274
8
public DMemeGrid getStandardData() { DMemeGrid dmg = new DMemeGrid(); dmg.setLabel("Standards: English Grade 2"); //dmg.setColDescriptor("This the column descriptor here"); //dmg.setRowDescriptor("This is the row descriptor here"); dmg.setColDescriptor(...
d323e731-81c3-4ae3-92ba-51d022e0eb58
2
public boolean estaEmWait(String transacao) { boolean res = false; for (String s:waitList) { if (s.equals(transacao)) { res = true; } } return res; }
96841b08-002d-434f-83ce-0cbd03fae37b
7
private T advance() { boolean use_next = true; while (true) { if (!left.hasNext() && use_next || !right.hasNext()) return null; T x; if (use_next) { x = left.next(); } else { x = left.current(); use_next = true; } // System.out.println("at " + x); switch (right.goTo(x...
a2f8c810-9a2e-4615-8105-e84dee8dd433
0
public void setDrawOutput(Output output) { _drawOutput = output; }
c6d0d71d-047e-40fd-8251-0296a8ea80f4
4
public void dispose() { for (Field f : this.bagFields) { try { Object value = f.get(this); if (value != null && value instanceof Disposable) { Disposable.class.cast(value).dispose(); } } catch (IllegalAccessException e) ...
1bea792b-e7e5-45b0-833e-89d97add087c
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof UserOrganisationRole)) { return false; } UserOrganisationRole other = (UserOrganisationRole) object; if ((this....
c62ccc22-38c0-49eb-884b-3393bf7d1e6a
4
@Override public boolean isReadyForGetTotal() { boolean res = true; this.getLastErrors().clear(); Set<Character> orderChars = this.getOrderChars().keySet(); Iterator<Character> iterator = orderChars.iterator(); Character ch = null; Product p = null; while (iterator.hasNext()) { ch = iterator.next(...
b66605dc-a60f-4bb0-9409-0c7013279781
8
protected synchronized void unPackNatives() { //first check to see if we have already unpack any native libs if (natives_unpacked_flag) return; if (execDesc == null) { return; } NativeLibDesc nativeLibs[] = execDesc.getNativeLibs(); //download all native libs boolea...
70405cbb-5413-4478-8709-7643209d5943
7
private String getPrincipalProperty(Object principal, String property) throws IOException { String strValue = null; try { BeanInfo bi = Introspector.getBeanInfo(principal.getClass()); // Loop through the properties to get the string value of the specified property b...
dbedf709-e6fd-4353-b344-9e8a82fc4e48
2
public static String getNonEmptyInput(String query) { String response = ConsoleTools.getInput(query); while (response == null || response.equals("")) { response = ConsoleTools.getInput(query); } return response; }
9e1c094d-46bc-4503-842b-03c4e4b256b0
6
public static int getMedianOfSortedArrays(int[] arr1, int[] arr2, int n) { if (n <= 0) { return -1; } if (n == 1) { return (arr1[0] + arr2[0]) / 2; } if (n == 2) { return ((Math.max(arr1[0],...
a1929065-11f2-4129-aca5-fefe3232772d
6
public Pathing doSearch() { if (verbose) I.say( "Searching for path between "+init+" and "+destination+ ", search limit: "+searchLimit(init, destination) ) ; super.doSearch() ; if (verbose) { if (success()) I.say("\n Success!") ; else { I.say("\n Failed.") ; if ...
1dfb246b-34fb-4a4f-8f10-f0f088a4ca1b
4
private void placeAnthill(String colour, int x, int y) { int SP, len, parityAdjuster; for (int h = 0; h < 13; h++) { if (((y % 2) == 1) && ((h % 2) == 1)) { parityAdjuster = 1; } else { parityAdjuster = 0; } SP = (Math.abs...
d124774c-03b5-41f6-a6ed-cebd113b3d4c
5
void testRandom() { long i; long x; char ok = 0; selectStream(0); /* select the default stream */ putSeed(1); /* and set the state to 1 */ for(i = 0; i < 10000; i++) { random(); } x = getSeed()...
587b3a56-c856-47d8-8440-4d4d1147cc26
8
@Override protected IToken doEvaluate(ICharacterScanner scanner, boolean resume) { if (resume) { return fToken; } else { int c= scanner.read(); if ((char)c == fStartSequence[0]) { scanner.unread(); int check = scanner.getColumn(); if ( check != 0 ){ scanner.unread(); c = scanner.r...
9a66da62-c333-4c4f-ab4a-c8d44d572af0
2
private void startGame() { KiesOnderwerp kiesOnderwerp = new KiesOnderwerp(spel); String naamNo = txtVulHierJe.getText(); if (naamNo.equals(TXT_PLACEH_NAAM_INPUT) || naamNo.isEmpty()) { txtVulHierJe.setBackground(Color.red); txtVulHierJe.selectAll(); } else { spel.setSpelerNaam(naamNo); openPanel(k...
7da44458-29a0-4937-bc8c-d7f365c3f053
3
public boolean consider(Actor actor) { // FUTURE Fuzzier logic; shouldn't be so binary for (Condition condition : conditions) { if (!condition.consider()) return false; } EventDriver driver = EventDriver.getInstance(); // CONSIDER Can we use an iterator here instead? Might be cleaner. // F...
c826f4bc-83e4-4fb9-860d-a2176a9aaf30
8
public static Boolean createExcel(OutputStream os, String[] name, String[][] datas) { try { // 创建工作薄 WritableWorkbook workbook = Workbook.createWorkbook(os); // 创建新的一页 WritableSheet sheet = workbook.createSheet("Sheet1", 0); // 创建要显示的列名 WritableFont color = new WritableFont(WritableFont.ARIAL);//...
d7788b23-1039-484c-930b-397f3854463d
7
public static List<User> getNsimilarUsers(int userId, String theDay) throws SQLException { List<User> result = new LinkedList<User>(); List<User> zeUsers = users; if (zeUsers == null) zeUsers = getUsers(); List<UserAndWeight> usrwgh = new LinkedList<UserAndWeight>(); MoviesAndRatings mar1 = getVotedItem...
99d8232f-16cb-40e7-9d97-cb9fb1d1bb88
0
public void setFileFilterInclude(String fileFilterInclude) { this.fileFilterInclude = fileFilterInclude; }
3a976dfa-930e-41a1-8582-35a70da2629f
7
private final void method361(int i, ByteBuffer class348_sub49, int i_2_) { if (i != -6617) method363(95); anInt497++; if (i_2_ == 1) ((Class38) this).anInt501 = class348_sub49.getShort(); else if (i_2_ == 2) ((Class38) this).aBoolean507 = true; else if (i_2_ == 3) { ((Class38) this).anInt4...
1ad9f5b5-50ae-4120-ad5c-173e4df967bc
0
public static void _deleteArray(String tableName, long id) throws SQLException { PreparedStatement query = connect.prepareStatement("delete from `" + tableName + "` where `key` = ?"); query.setLong(1, id); query.executeUpdate(); }
60136e92-4ffc-496b-af5c-f017073d9128
0
@Before public void init() { this.manager = new ParkManager(); this.manager.handlePark(new Park(8)); ParkBoy boyA = new ParkBoy(); boyA.handlePark(new Park(5)); boyA.handlePark(new Park(9)); this.manager.handleBoy(boyA); ParkBoy boyB = new ParkBoy(); boyB.handlePark(new Park(4)); boyB.handlePark(new ...
eb29f613-c95a-47ab-a0c3-1db224366a97
6
private static Vector<Color> getKeyColors(Vector<Color> src, int cnt, int threshold) { Vector<Color> groups = new Vector<Color>(); groups.add(src.get(0)); boolean add; for (int i = 0; i < src.size(); i++) { Color c = src.get(i); add = true; for (Color col: groups) { if (getDist(c, co...
614bcd43-615e-409c-b8cb-2062669565b0
9
int insideTriangle(double x, double y) { int j = 2, k; boolean inside = false; for (k = lastTriangle(); k >= 0; k--) { Triangle t = Global.mainTriangles[k]; for (int i = 0; i <= 2; i++) { if ((((t.y[i] <= y) && (y < t.y[j])) || ((t.y[j] <= y) && (y < t.y[i]))) && (x < (t.x[j] - t.x[i]) * (y - t.y...
6e9e1b23-2974-4092-86d1-51a6877f0dec
3
public static boolean checkTryg(MathElement m) { if (m instanceof Trygonometric) { if (((Trygonometric) m).arg instanceof MathVar) { if (!((MathVar) ((Trygonometric) m).arg).preserve()) { return true; } } } return false; }
43b8f6ab-b2f4-4ee4-ab73-9372cae22274
3
public static String trimTrailingWhitespace(String str) { if (!hasLength(str)) { return str; } StringBuilder sb = new StringBuilder(str); while (sb.length() > 0 && Character.isWhitespace(sb.charAt(sb.length() - 1))) { sb.deleteCharAt(sb.length() - 1); } return sb.toString(); }
d45ea9d1-d068-46eb-825a-7c434d3887c1
3
private void readPLTE() throws IOException { int paletteEntries = chunkLength / 3; if(paletteEntries < 1 || paletteEntries > 256 || (chunkLength % 3) != 0) { throw new IOException("PLTE chunk has wrong length"); } palette = new byte[paletteEntries*3]; readChunk(palett...
3fa5a6d4-2991-4fd2-acf7-d3d4672348fe
2
public void printGraph() { for (int i = 0; i < this.vertices.size(); i++) { UndirectedNode vertex = this.vertices.get(i); String edges = ""; for (int j = 0; j < vertex.edgeNodes.size(); j++) { edges += vertex.edgeNodes.get(j).data + ", "; } ...
7663a824-d877-4964-a566-59e799d0c4a6
6
public void getCompleteGraph(mxAnalysisGraph aGraph, int numVertices) { if (numVertices < 0) { throw new IllegalArgumentException(); } mxGraph graph = aGraph.getGraph(); Object parent = graph.getDefaultParent(); Object[] vertices = new Object[numVertices]; for (int i = 0; i < numVertices; i++) {...
eb1ca972-57f4-4494-91ef-b815010152b9
8
public boolean equivalentWasDerivedFroms (WasDerivedFrom description1, WasDerivedFrom description2) { return bothNull (description1, description2) || (neitherNull (description1, description2) && equivalentIdentifiers (description1, description2) && equivalent...
1129f6a7-a57e-451f-ab54-be9753c254dd
7
private FeatureExtractor readExtractorRule(String ns, String line, int nGram) { int relPos; int componentIndex; List<FeatureExtractorPart> parts = new ArrayList<FeatureExtractorPart>(); StringBuffer sb = new StringBuffer(); while (!line.isEmpty()) { if...
30d1c8b5-9d83-4ad2-b781-11565a5bbe3e
4
public void grabAudio(Collection currentCollection) { sounds.clear(); noPreload.clear(); Iterator it = currentCollection.getMedia().entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry) it.next(); String fileName = (String) (pairs.getValue()); if (fileIsAudiofileName(fileNam...
ecd605d0-a462-447c-8364-e13cb9c36c08
9
private void spamCheck(Player player, String message, AsyncPlayerChatEvent event) { if (!message.equalsIgnoreCase(spamcheck)) { spamcheck = event.getMessage(); spamCount = 0; } else { event.setCancelled(true); spamCount++; } String result =...
76eaa9dc-445b-469f-8f91-af17d641573d
0
public int getSize() { return size; }
35035873-71c2-4239-9294-52ff2dc62ade
2
public void persistGenerator(double minSupportLevel, double minConfidenceLevel) { String sqlStatement; dao.connect(); sqlStatement = generateInsertStmt(minSupportLevel, minConfidenceLevel); if(dao.getErrorLogs().getErrorMsgs().size() == 0){ dao.executeUpdate(sqlStatement); } if(dao.getErrorLogs().getError...
1274834b-98c9-4c68-adb9-cd91c6651dac
6
public static boolean getURLforClass(String s, int JDK) { HashMap<Integer, String> JDKversions = new HashMap<>(); JDKversions.put(7, "http://docs.oracle.com/javase/7/docs/api/allclasses-frame.html"); JDKversions.put(8, "http://download.java.net/jdk8/docs/api/allclasses-frame.html"); URL u = null; Input...
fdd0a923-185d-4500-b082-e0a9b10f42d1
7
public static Calendar convertStringToCalendar( String dateStr ) { if( !isDatePattern( dateStr ) ) { return null; } int m; int d; int y; StringTokenizer st = new StringTokenizer( dateStr, "/" ); try { m = Integer.valueOf( st.nextToken() ) - 1; d = Integer.valueOf( st.nextToken() ); String...
a335ad03-b9cc-4d29-813e-fbfa3feb96c6
2
public ReSampleMapRank(HashMap<String, Double> scoresByName, int sampleSize) { super(null, sampleSize); scoreByName = scoresByName; // Create a list ordered by score ArrayList<String> names = new ArrayList<String>(); names.addAll(scoresByName.keySet()); Collections.sort(names, new Comparator<String>() { ...
56a5047e-a889-43cb-aa4f-eb17b6abb5bd
6
private void scannLog() { try { // When mysql is shutdown normally, a stop event will appears in the log file, // then should handle this situation. LogFileScanStatus status = LogFileScanStatus.SUCCESS; File logFile = new File(findCurrentLogFile()); bo...
16869804-00aa-4044-b75d-439c7cd39ec4
8
public List<SIREventWithRate> generateEvents() { List<SIREventWithRate> events = new ArrayList<>(); for ( SIREventType etype : rates.getEventTypes() ) { // EXPOSURE, BECOME_INFECTIOUS, INFECTION, RECOVERY, IMMUNITY, SUSCEPTIBILITY; IndividualStateTy...
e2bccf1e-6a6b-4417-85d7-75a32dc977bc
4
public static ArrayList<Integer> ordenaParesEImpares(ArrayList<Integer> lista) { boolean ordenado = false; while(ordenado == false) { ordenado = true; for(int i = 0; i < lista.size() -1; i++) { if(lista.get(i) % 2 == 0 && lista.get(i + 1) % 2 != 0) { int aux = lista.get(i); lista.set(i...
942d6315-95f6-47e8-ac0e-26faa5cd8a62
1
protected Integer calcBPB_BytsPerSec() throws UnsupportedEncodingException { byte[] bTemp = new byte[2]; for (int i = 11;i < 13; i++) { bTemp[i-11] = imageBytes[i]; } BPB_BytsPerSec = byteArrayToInt(bTemp); System.out.println("BPB_BytsPerSec = " + BPB_BytsPerSec); ...
3bc65c30-e31e-4684-b22e-700d38fd5e3c
5
private void listClose(Statement[] statements, ResultSet[] resultSets) { try { for (int i = 0; i < statements.length; i++) if (null != statements[i]) statements[i].close(); for (int i = 0; i < resultSets.length; i++) if (null != resultSets[i]) resultSets[i].close(); } catch (SQLException e) ...
2b8a4851-9ff7-42ef-9d81-4e3e7dc8da05
5
@Override public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { Input input = container.getInput(); int mouseX = Mouse.getX(); int mouseY = HEIGHT - Mouse.getY(); if((mouseX > exitButtonX1 && mouseX < exitButtonX2) && (mouseY > exitButtonY1 && mouseY < e...
24143adf-a0a2-4ca0-8de3-f05fc47572f0
4
public boolean getConversation( Conversation cvs ){ if( !handler_cvs.initialize() || !handler_msg.initialize() || !handler_person.initialize() || !handler_group.initialize() ){ System.out.println( "ConversationServer : failed to initialize!" ); return false; } boolean flag = getConversationInfo( cvs );...
f97739a9-6dfa-4e83-b778-364ea45c562d
1
@GET @Path("/v2.0/subnets") @Produces({MediaType.APPLICATION_JSON, OpenstackNetProxyConstants.TYPE_RDF}) public Response listSubnet(@HeaderParam("Accept") String accept) throws MalformedURLException, IOException{ if (accept.equals(OpenstackNetProxyConstants.TYPE_RDF)){ System.out.println(accept); String data...
994663ec-cd53-4d0f-b11d-abd195532568
7
public void push(Object object) throws ConfigurationException, DataNotSubscribedException { ResultData[] results = (ResultData[])object; List resultsToSendList = new LinkedList(); ResultData[] resultsToSend; synchronized(registeredObjects) { for(int i = 0; i < results.length; i++) { if(hasDataReq...
8f4efabe-76cc-40af-88de-f2b9a8465ca5
9
private String createMessage(String ACTION, String fakulty, String group, String studentName, String studentLastname, String enrolledDate,Integer studentID) { if (log.isDebugEnabled()){ log.debug("Creating SOAP message called"); } StringBuilder message = new StringBuilde...
adf837ba-a5e7-4e97-9246-eed62ad46358
4
public double[] melFilter(double bin[], int cbin[]){ double temp[] = new double[numMelFilters + 2]; for (int k = 1; k <= numMelFilters; k++){ double num1 = 0, num2 = 0; for (int i = cbin[k - 1]; i <= cbin[k]; i++){ num1 += ((i - cbin[k - 1] + 1) / (cbin[k] - cbi...
10569dfb-4610-43eb-b563-dd16e901218f
2
@Override public long getEncodedLength () { long childLength = 0; for (final Map.Entry<String,Value<?>> me : value.entrySet()) { final byte[] bytes = me.getKey().getBytes(Bencode.UTF8); childLength += bytes.length + 2 + (long) Math.log10(bytes.length); childLengt...
adb07f58-9ab6-4d90-9b7c-69c3b86be585
6
static long permutation(int [] A, int n, int k, int v){ long count = 0; // Let count be the number of all possible permutations in P(n,k) int current = 0; // Let current be the index where a swapping has just occurred do{ // visit A[1...k] ONLY IF a distinct permutation is generated (a swapping occurs...
a21c6c91-d033-4441-9269-f695709d2b70
8
public static Iterator allocateDbtableSpecialistIterator(ControlFrame frame) { if (((Iterator)(KeyValueList.dynamicSlotValue(frame.dynamicSlots, RDBMS.SYM_STELLA_ITERATOR, null))) == null) { { Proposition proposition = frame.proposition; Surrogate relationref = ((Surrogate)(proposition.operator)); ...
9198b489-321e-421e-b392-3785543a037a
6
public void run() { try { OutputStreamWriter os = new OutputStreamWriter(out); InputStreamReader ir = new InputStreamReader(System.in); char[] c = new char[4096]; while ((ir.read(c)) != -1 && !Thread.interrupted()) { //for(int i=0; i<...
034c8099-b89d-465f-a62a-b109599b9909
9
private int maxMove(Board prev, int depth, int alpha, int beta) { moves++; if(depth >= maxDepth) return prev.getScore(); // exceeded maximum depth int maxScore = MIN_SCORE; Board b = new Board(prev); for(int j = 0; j < size; j++) { for(int i = 0; i < size; i++) { if(b.move(i, j)...
3c949933-f22c-4c98-ae83-26e15491b98f
4
public static void QueryLogs(Socket s) { JSONObject query; //sent to server JSONObject reply; //recieved from server Scanner sc = new Scanner(System.in); //submenu System.out.println("Query logs:"); System.out.println("1: Get last 20 logs"); System.out.println("2...
ca50e1a0-3590-4718-8877-33649ef36e88
3
private void handleMouseMotion(MouseEvent arg0) { dx = arg0.getX() - mousex; dy = arg0.getY() - mousey; if (letMouseMove) { mousex = arg0.getX(); mousey = arg0.getY(); sx = arg0.getXOnScreen(); sy = arg0.getYOnScreen(); } else { ...
c93ee211-966b-40d3-bcd5-b5ccdfbcef27
9
public void GerarRodadas(Campeonato campeonato) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException, Exception{ try (Connection dbConecta = new ConexaoOracle().getConnection(); Statement select = dbConecta.createStatement()) { Campeonat...
9ad1b187-5542-4c76-a248-ea13feeaae16
3
private void afficherPageRepertoire(String rep) { String nomRep = rep;//nomRep est utilisé pour l'affichage sur une page web seulement if (rep.equals("/")) { nomRep = ""; } writer.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://w...
164367f6-e141-4460-a3f7-9db0df3262e7
9
public int cancel( Task task ) throws InterruptedException { m_lock.lock(); try { for (;;) { final TimerInfo timerInfo = m_timers.get( task ); if (timerInfo == null) { /* Timer already canceled or was...
955327e9-a022-4ccb-8134-29fac32f3ae9
7
public static boolean isAlNumUS(char c) { if (c >= 'a' && c <= 'z') { return true; } if (c >= 'A' && c <= 'Z') { return true; } if (c >= '0' && c <= '9') { return true; } if (c == '_') { return true; } ...
00b24073-fc91-4e1b-abd8-8c24f9433782
1
public static String reverse2(String s) { StringBuilder rev = new StringBuilder(); int n = s.length(); for (int i = 0; i < n; i++) rev.append(s.charAt(n - i - 1)); return rev.toString(); }
6f661192-8c44-45c0-9fe5-40fdf44a9b12
0
private static byte[] toUTF8Bytes(final String text) throws Exception { return text.getBytes(UTF_8_ENCODING); }
c179a7c0-f8af-44d5-9143-a1b0f27e1df7
7
public Object nextValue() throws JSONException { char c = this.nextClean(); String string; switch (c) { case '"': case '\'': return this.nextString(c); case '{': this.back(); return new JSONObject(this); ...
22292682-bf20-4b3b-a67d-48fba6d79018
4
private void experiment() { // wait for all entities to register super.gridSimHold(50.0); int location = 0; // create three new files and add them as master files to resource Res_2 try { ArrayList fList = new ArrayList(); for (int i = 0; i < 3; i++) { ...
b619d581-1a46-4104-a093-661b433b6a92
0
private Set<Card> quadsJacksWithTenKicker() { return convertToCardSet("JH,4S,JC,3S,JD,TS,JS"); }
840048c9-4ff8-44e5-89f7-07e0e7df2ab0
5
public static void rbbstTest() { for (int i = 0; i < 100; i++) { RBBST tree = new RBBST(); Make make = new Make(); ArrayList<Integer> list = make.list(); for (int n = 0; n < list.size(); n++) { tree.insert(list.get(n)); if (n % 10...
b419dcc7-f4c1-47de-8938-5df9e26fc83e
6
public Object receive() throws IOException, ClassNotFoundException { int lastAck = 0; while (true) { /** receive the datagrams and check checksum first **/ Datagram gram = datagramService.receiveDatagram(); if (verbose > 0) { System.out.println("received datagram, sequenceNum: " + String.valueOf(...
1500b3fc-bdac-4c58-bb29-8dece5137b2a
7
public TipWindow(Window owner, FocusableTip ft, String msg) { super(owner); this.ft = ft; // Render plain text tool tips correctly. if (msg!=null && msg.length()>=6 && !msg.substring(0,6).toLowerCase().equals("<html>")) { msg = "<html>" + RSyntaxUtilities.escapeForHtml(msg, "<br>", false); } this.te...
0a8ba4b7-db14-403c-8714-6187fba73f8c
9
boolean statement() { switch (_input.peek()) { case "create": createStatement(); break; case "load": loadStatement(); break; case "exit": case "quit": exitStatement(); return false; case "*EOF*": ...
808a8659-be57-4769-a568-767f5ef9f166
9
public String outputFreeSlots(String[] users, Calendar cal) throws FileNotFoundException, IOException{ String output = ""; DBManager db = new DBManager(); cal.set(cal.get(cal.YEAR),cal.get(cal.MONTH),1); cal.setFirstDayOfWeek(Calendar.MONDAY); int lastMonthCount = cal.get(cal...
bb0a6a39-0a7b-4ea8-a907-ac860fefc71b
7
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Adresse adresse = (Adresse) o; if (!land.equals(adresse.land)) return false; if (!ort.equals(adresse.ort)) return false; if (!plz.equal...
ab5f2c92-ba29-4873-a6aa-3571b1e3486a
3
private void EditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EditActionPerformed if(LOST == true) { Narra.append("You have died!"); ActionListener[] al = Edit.getActionListeners(); Edit.removeActionListener(al[0]); return; }...
799bb6b6-2214-47a8-8d96-b3f2617fe29c
0
@Override public void removeAttachment(PermissionAttachment pa){ throw new UnsupportedOperationException("Not supported yet."); }
91c8d11a-5ba1-4005-88f8-6de45a3e0d54
9
public int method304(int i, int j, int k, int l) { Ground class30_sub3 = groundArray[i][j][k]; if(class30_sub3 == null) return -1; if(class30_sub3.obj1 != null && class30_sub3.obj1.uid == l) return class30_sub3.obj1.aByte281 & 0xff; if(class30_sub3.obj2 != null && class30_sub3.obj2.uid == l) return cl...
ff7d47d2-9238-4333-ba6c-608cc39d4bb1
7
@Override public void caseAIfStmt(AIfStmt node) { inAIfStmt(node); if(node.getIffalse() != null) { node.getIffalse().apply(this); } if(node.getElse() != null) { node.getElse().apply(this); } if(node.getIftrue() != null) ...