method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
f2aef448-0d33-4e18-b026-41b69a34cf49
4
@Override public void doJob() { try { //TODO wait till queue is empty and keep adding ISBN to array. System.out.println("Waiting for messages from " + queueName + "..."); String body =""; Message msg; OrderBook book = new OrderBook(); boolean isBookLost = false; while((msg = consumer....
82475664-6a00-41b1-a1f4-5880dbdac57f
4
public static Session getSession() throws HibernateException{ Session session = (Session)threadLocal.get(); if(session == null || !session.isOpen()){ if(sessionFactory == null){ rebuildSessionFactory(); } session = (sessionFactory!=null) ?sessionFactory.openSession() : null; threadLocal.set(sess...
2bc6565a-afd4-49d1-a8fe-fabe6941e22c
4
@Override public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) { logInfo("UngeradeAnnotationProcessorJDK6 entry to process"); for (final TypeElement annotation : annotations) { final Set<? extends Element> elements = roundEnv...
1d80e1d7-cd04-42b5-8548-ab80f034d95f
8
public static int log2(int x) throws ArithmeticException { if (x <= 0) throw new ArithmeticException("Cannot calculate log of a negative or null value"); if (x < 256) return LOG2_4096[x] >> 2; if (x < 512) return 1024 + (LOG2_4096[x>>1] >> 2); int log = ...
02ef4ff8-6369-41e9-8086-8dc41bd1e5c2
8
public void addCar(int x, int y, int type, int code){ switch(type){ case Car.GO_UP: if(code==9) carsBottom.add(new Tank(x, y, type, code)); else carsBottom.add(new Car(x, y, type, code)); break; case Car.GO_DOWN: if(code==9) carsTop.add(new Tank(x, y, type, code)); else carsTop.add(...
6e5a7824-df74-40b7-a2d6-92636f400e8f
6
private float[][] generateRandomCenters() { Random random = new Random(); float[][] centers = new float[K][dimension]; for(int j = 0; j < dimension; ++j) { float min = values[0][0][j]; float max = values[0][0][j]; for(int a = 0; a < height; ++a) for(int b = 0; b < width; ++b) { if(values[a][b][j...
3436c3ba-8e98-46d8-89cd-0e533ae87f46
9
public boolean skipPast(String to) throws JSONException { boolean b; char c; int i; int j; int offset = 0; int length = to.length(); char[] circle = new char[length]; /* * First fill the circle buffer with as many characters as are in the ...
f3c0f2c9-8fc8-4b85-8f0a-1380173e8b01
3
public void doGeneralCheck(String romanNr) { if (!checkValidLetters(romanNr)) { System.out.println("invalid"); System.exit(0); } if (!checkThreeConsecLetters(romanNr) || !checkRomanNr(romanNr)) { System.out.println("invalid"); System.exit(0); ...
fc1d4c82-ceb0-4f22-b6c3-bd1c012bbde0
5
@Override public boolean accept(File f) { return f.isDirectory() || f.getName().toLowerCase().endsWith(".jpeg") || f.getName().toLowerCase().endsWith(".jpg") || f.getName().toLowerCase().endsWith(".png") || f.getName().toLowerCase().endsWith(".gif") || f.getName().toLowerCase().endsWith(".bmp"); }
2261ec6b-f6f1-416d-a89a-ed1ead7ad38e
8
public int getMemberCount() { Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; int cnt = 0; try { conn = getConnection(); pstmt = conn.prepareStatement("select count(*) from member"); rs = pstmt.executeQuery(); if (rs.next()) { cnt = rs.getInt(1); } } catch (...
64539e27-3359-454a-8734-841aac08cb5d
3
public static void main(String[] args) { Space space; Board new_game = new Board(); new_game.setup(); Chess game = new Chess(); try { game.play(new_game); } catch (IOException e) { System.err.println("Fatal Error with input"); e.printStackTrace(); } if(game.white_victory) { Syste...
2597970e-2cbe-44c4-acf3-eba227f963a2
7
private boolean r_postlude() { int v_1; int v_2; // (, line 203 // Boolean test Y_found, line 203 if (!(B_Y_found)) { return false; } // repeat, line 20...
9ca07069-e91f-4d53-85ed-e3efb0485008
9
private String checkValidKey(String key) { String message = ""; boolean valid = false; if(key == null || key.equals("") || !ModPack.isValidKey(key)) { message = "Key is not valid, pick a new key"; } else if(Globals.getInstance().listsPacks.codeExists(key, shortNameField.getTe...
240b7e70-67a0-4493-82a6-8e88fa2b54ec
3
public int getTextWidth(Component component, String str) { int width = 50; Font font = component.getFont(); if (font != null) { FontMetrics metrics = Main.getInstance().getMetrics(font); if (str != null && metrics != null) { width = metrics.stringWidth(str); } } width += 16; return width; }
08af4c88-2a0b-4529-9ba4-da2e5a751d7b
3
@Test public void canGetProductsByName() { ProductModel addedProduct1 = ProductModel.builder("Night Visions", 1) .description("Imagine Dragons").cost(149).rrp(400).build(); ProductModel addedProduct2 = ProductModel.builder("Night Visions", 1) .description("Imagine Dragons").cost(149).rrp(400).build(); Li...
7bb38de4-4ff8-4d75-bbea-13456aa938ec
9
private void processLine(String line) throws NotesFormatException, MalformedNumberException { LOGGER.info(String.format("Reading line: %s", line)); // tries to match a string pattern NotesLine[] linePatterns = NotesLine.values(); for (NotesLine lp : linePatterns) { Matcher m = lp.getPattern().matcher(lin...
fcd9cdc3-652e-4359-b78a-66a33f530c40
6
public Object getValue(ELContext context, Object base, Object property) { if ((base == null) || (property == null)) { return null; } context.setPropertyResolved(true); FacesContext fcontext = (FacesContext) context.getContext(FacesContext.class); ELContext elContext...
a6bb9a97-3c1d-4be2-9bf7-5709f7c8c0b8
5
public boolean peutConsulter(Utilisateur utilisateur) { return ( utilisateur != null && ( utilisateur.getRole().getValeur() >= getConsultationRoleMinimum().getValeur() || (getJeuAssocie() != null && ( getJeuAssoc...
db0dff4c-4fa2-4900-b108-9be6a1d80d19
1
private void launch(){ // variables String input = ""; Fraction value = new Fraction(1,1); // create Scanner Scanner scan = new Scanner(System.in); // welcome message System.out.println("Welcome to James Hills' Fraction Calculator."); ...
988c7997-ca98-4379-9b51-3f6bb986d558
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...
1c08d45f-9145-4442-94fb-362eb67cccff
3
public void agregarUsuario(String nom, String apel, String direc, String usuar, String pass, String correo, int tel) { boolean clienteExistente = false; for (int x = 0; x < clientes.size(); x++) { if (clientes.get(x).getUsuario() == usuar) { clien...
5c1e3df7-0552-408d-97fc-dc75517a73c0
3
@Override public void run() { while (run) { try { final ClientInfo client = new ClientInfo(serverSocket.accept()); client.addObserver(AnalyzerCalcul.getInstance()); Log.d("Server", "run()"); clients.add(client); } catch (final IOException ioe) { ioe.printStackTrace(); } } ...
4d4c4c47-827b-43be-a735-c8c0cbc0f3c6
4
public void fireSubLWorkerTerminatedEvent(SubLWorkerEvent event) { if (event.getEventType() != SubLWorkerEvent.TERMINATION_EVENT_TYPE) { throw new RuntimeException("Got bad event type; " + event.getEventType().getName()); } setStatus(event.getStatus()); synchronized(listeners) { Object...
e2ce7c09-1f3a-4f46-a4fe-fb87ab68a13c
7
@Override public boolean equals(Object obj) { if (!(obj instanceof Message)) { return false; } Message comp = (Message) obj; if (this.code != comp.getCode()) { return false; } if (this.key != comp.getKey()) { return false; }...
855a84fe-728c-48c6-a8c5-ee37dab94bf0
7
private List register(List subscriptionInfos) throws Exception { List allObjects = new LinkedList(); Iterator infoIterator = subscriptionInfos.iterator(); while(infoIterator.hasNext()) { SubscriptionInfo subscriptionInfo = (SubscriptionInfo)infoIterator.next(); List<SystemObject> objects = new LinkedList<Sy...
066dfd96-1885-4f0e-a78a-c1524d264a02
3
public void update(long deltaMs) { if(enabled) { // don't update disabled actors for(BaseComponent b : components.values()) { if(enabledComponents.get(b.getName().toLowerCase())) { b.update(deltaMs); } } } }
2f4804a9-7d0e-49ca-b113-10134a7f1b3f
9
public static byte getArchiveCode(String code) { byte result = 0; if (code.equals("1700TL")) { result = 0x63; } if (code.equals("2100TL")) { result = 0x63; } if (code.equals("3000TL")) { result = 0x71; } if (code.equals(...
547386cd-a14c-4f0f-91f4-e104e250ac36
6
@Override public Class<?> getColumnClass(int columnIndex) { switch (COLUMNS.values()[columnIndex]) { case ID: return Integer.class; case FIRSTNAME: case LASTNAME: case EMAIL: return String.class; case BIRTH: return Date.class; default: throw new IllegalArgumentException("colum...
8e455579-8ed4-4b2f-8e86-96ec85894948
3
public int getMostWest() { for (int c = 0; c < matrix.length; c++) { for (int r = 0; r < matrix.length; r++) { if (checkSlot(r, c)) return c; } } return -1; }
1b29602c-7440-40e8-9404-4f98216efd67
0
public void SetX(int x) { this.x = x; }
4489886f-db9a-4af0-8caa-2c8bd394269a
0
public void operation() { System.out.println("concrete ImplementorB operation!"); }
bbae2793-4672-4a39-925a-788a32131b2d
0
public String getName() { return name; }
d737e1d3-b07b-4693-8dec-72c19200710b
7
public static void deriveDeferredContrapositiveSatelliteRules(Description self) { if (Logic.$LAZY_SATELLITE_RULESp$) { if (BooleanWrapper.coerceWrappedBooleanToBoolean(self.deferredContrapositivesP())) { { Proposition masterproposition = null; List queuedrules = List.newList(); { ...
1886b3a2-ba07-409d-9b29-b81327b2d092
9
public int bestCell(int row, int pos){ //Find the number of conflicts int[] colConflicts = colConflicts(row); int[] diagConflicts = diagConflicts(row); int[] totalConflicts = new int[colConflicts.length]; for (int i = 0; i<colConflicts.length;i++){ totalConflicts[i] = colConflicts[i] + diagConflicts[i]; ...
fbc82512-0add-454d-811f-005087a99bbd
7
private Map<Integer,Integer> readOrder() { Map<Integer,Integer> order = new HashMap<Integer,Integer>() ; try { int i = 0; in.nextToken() ; while(in.ttype != StreamTokenizer.TT_EOF) { in.nextToken(); if (in.sval != null && in.sval.equals("c")) { break; } in.nextToken(); if (in.sva...
99ac0054-33ab-42d7-9570-278c71eecfd0
8
protected PartitionKeyTrace getPartitionKeyTrace(Object target, MethodSignature signature) { // inspect cached traces first PartitionKeyTrace trace = traces.get(signature.getMethod().toString()); if (trace == null) { Method method = getTargetMethod(target, signature); if (method != null) { Annot...
2986e829-4681-4206-adcf-34801c699443
3
protected Duration restSplit() { Duration restLong = intervals.findGap(period, Rest.SPLIT_LONG.getValue()); Duration restShort = intervals.findGap(period, Rest.SPLIT_SHORT.getValue()); if (restLong == null) { if (restShort == null) { return null; } else {...
16349b9b-4f10-4261-ae15-b100ebbdc625
2
private boolean isValidEndEffectEvent(Event event) { if (event.getOriginator() instanceof PrimaryPowerFailure) { PrimaryPowerFailure powerFailure = (PrimaryPowerFailure) event.getOriginator(); if (powerFailure.equals(parentPowerFailure.parentPowerFailure)) return true; } return false; }
503387da-3ac4-4f0f-b8b8-2059b5e9db39
3
public boolean verificaTroca(Movimento mov1,Movimento mov2) { return mov1.getX1()==mov2.getX2() && mov1.getY1()==mov2.getY2() && mov1.getX2()== mov2.getX1() && mov1.getY2()==mov2.getY1(); }
395d15a7-151f-4c97-a73c-aad567c586ab
0
@Override public String toString() { return "action\t:" + this.action + "\n" + "src\t:" + this.source + "\n" + "dst\t:" + this.dest + "\n" + "kind\t:" + this.kind + "\n" + "seqNum\t:" + this.seqNum + "\n" + "duplicate\t:" + this.duplicate + "\n"; }
402a7068-b9d2-4c9f-afec-ed75f7949f29
0
public void setInitialGrid(Grid grid) { this.initialGrid = grid; }
c4d6ca32-6cb8-4050-81a0-1f70d0e9d566
2
public void connect() { try{ // Register JDBC driver Class.forName(jdbcDriver); // Open a connection connection = DriverManager.getConnection(url, name, password); statement = connection.createStatement(); }catch(...
8b66a7ff-f317-451b-9956-f6e39d6c83c5
0
public List<String> getComments() { return comments; }
4091f44c-1f69-44a7-8f53-12f2cc9213f1
1
public void updateStatusPanel(java.awt.Component component) { File f = new File(filePath); if (f.isFile()) { progressBar.setMaximum((int) (f.length())); statusPanel.removeAll(); statusPanel.add(component); statusPanel.revalidate(); statusPanel.repaint(); } }
3faa673e-ddb7-4c3b-ab7e-cb0209b23c91
3
@Override public String getText() { if (isLeaf()) { return text; } else { String ret = ""; for (int i = 0; i < getChildCount(); i++) { if (ret.trim().length() > 0) ret += " "; ...
c71f5238-863b-4c04-9d39-0efac79f3b41
7
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Trends)) return false; Trends trends1 = (Trends) o; if (asOf != null ? !asOf.equals(trends1.asOf) : trends1.asOf != null) return false; if (trendAt != null ? !trendAt.equals(trends1.trendAt) : trends1.tr...
66f6feaf-69db-45d0-8187-625a06aa1b51
9
public boolean blockingIdle(Piece piece, int destX, int destY){ if(!piece.validMove(destX, destY)){ return true; } //need to have this part first, b/c the other ifs might pass if it wants to do an angle move. if(destX != piece.getX() && destY != piece.getY()){ //lazy, just checking every direction inst...
35f09edd-d8d6-489f-83bf-215eafc4b952
3
public static int findNumDays(String fileName) { int lineNumber = 0; String line; try { BufferedReader br = new BufferedReader( new FileReader(fileName)); while( (line = br.readLine()) != null) { lineNumber++; ...
16f0b0d4-5132-4559-8b31-11c2b93dd691
4
public void updatePictures(Attraction[] name){ attractionPanel.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), recomControl.getCurrentTag())); if (name[0] != null){ leftLabel.setText(name[0].getName()); } else if (name[0] == null){ leftLabel.setText("NO picture found"); } if (n...
c2a4ded4-92e4-48e5-acb6-5541c5b77ee2
4
public void createClient(String hostName, int portNumber) { if(hostName == null){ hostName = DEFAULT_HOST; } if(portNumber <= 0){ portNumber = DEFAULT_PORT; } try { socket = new Socket(hostName, portNumber); } catch (UnknownHostExcept...
0947bdde-e8c8-4dbd-972b-6e7bb7e449b4
0
public int[][] getPlateau() { return plateau; }
e1a72e3d-bfdb-4e07-88e6-d55f64670963
3
public static void queens(int col) { if (col == 9) System.arraycopy(board, 1, allSol[nsol++], 1, 8); else for (int row = 1; row <= 8; row++) if (check(row, col)) { board[col] = row; queens(col + 1); } }
5fa5a618-edc6-48b4-8f42-aae8b184fd0f
7
public static UserSimilarity userSimilarity(SIMILARITY type, DataModel m) throws TasteException { switch (type) { case PEARSON: return new PearsonCorrelationSimilarity(m); case COSINE: return new UncenteredCosineSimilarity(m); case TANIMOTO: return new...
f7fedb32-8007-4157-82c5-cc61376248c6
3
public LogicLargeArray xor(LogicLargeArray array) { if (array == null || array.length() != length) { throw new IllegalArgumentException("array == null || array.length() != length"); } LogicLargeArray out = new LogicLargeArray(array.length(), false); for (long i = 0; i < ...
2f54df88-39c6-46b7-a1d0-cf389d0fa579
6
protected Clickable getTextLink(Vec2D mousePos, Box2D textArea) { if (myHUD.selected() != this) return null ; final float mX = mousePos.x + textArea.xpos() - xpos(), mY = mousePos.y + textArea.ypos() - ypos() ; if (! textArea.contains(mX, mY)) return null ; Box2D box = new Box2D() ; for ...
8edb2a93-d15b-43ae-a481-7441be638b62
4
private void percolatingDown(int k) { T tmp = heapArray[k]; int child; while (2 * k <= size) { child = 2 * k; if (child != size && heapArray[child].compareTo(heapArray[child + 1]) > 0) { child++; } if (tmp.compareTo(heapArray[child]) > 0) { heapArray[k] = heapArray[child]; } else { br...
effb2d57-79a7-464c-a8ee-e0cfca7574a1
4
public void setValueAt(Object value, int row, int col) { // Fermentable m = (Fermentable) data.get(row); try { switch (col) { case 0 : add[row] = Boolean.valueOf(value.toString()).booleanValue(); break; case 1 : // data.setMaltPppg(row, Double.parseDouble(value.toString())); ...
6725a8cd-3506-4210-b013-01cd1992eaa7
2
public String toString() { String s = "["; int count = 0; for(E e : this) { count++; s += e.toString() + ((count < size) ? ", " : ""); } return s + "]"; }
4507d032-cabc-4cff-b5d9-b42bb9461900
1
public void simplify() { block.simplify(); if (nextByAddr != null) nextByAddr.simplify(); }
5944a539-6834-42a5-a81a-f406fa1d3236
4
public boolean simulateInput(String input) { /** clear the configurations to begin new simulation. */ //System.out.println("In Simulate Input"); myConfigurations.clear(); Configuration[] initialConfigs = getInitialConfigurations(input); for (int k = 0; k < initialConfigs.length; k++) { TMConfiguratio...
c480afec-103a-4064-ae07-2b73b3afe840
1
public ClientHandler(Socket client) { this.client = client; try { reader = new BufferedReader(new InputStreamReader(client.getInputStream())); writer = new BufferedWriter(new OutputStreamWriter(client.getOutputStream())); } catch (IOException e) { e.printStackTrace(); } start(); }
e2a578ff-9e59-44c8-a95f-576246fdae18
8
public ArrayList<Car> findCarsById(int id) { ArrayList<Car> cars = new ArrayList<Car>(); for (Racing temp:racing1) { if (temp.getId()==id) cars.add(temp); } for (Racing temp:racing2) { if (temp.getId()==id) cars.add(temp); } for...
d3f21405-0449-4cfd-b7a9-5a97a7417b37
8
public void method344(int i, int j, int k) { for(int i1 = 0; i1 < myPixels.length; i1++) { int j1 = myPixels[i1]; if(j1 != 0) { int k1 = j1 >> 16 & 0xff; k1 += i; if(k1 < 1) k1 = 1; else if(k1 > 255) k1 = 255; int l1 = j1 >> 8 & 0xff; l1 += j; if(l1 < 1) l1 =...
69f00d45-a92c-4f4c-877e-dbd1637916c3
0
protected AnnotatedHandlerBuilder<Method> handleMethod() { return wrapped.handleMethod(); }
d458860b-2304-4a67-8fab-f14a99d4d26b
5
public void applyChanges() { // HIDE THE WINDOW TO APPLY CHANGES setVisible(false); // PRINT THE GRAPHICAL CONFIG // MAKE THE WINDOW FULLSCREEN IF REQUIRED if (config.isFullscreen() && gd.isFullScreenSupported()) { setSize(tk.getScreenSize().width, tk.getScreenSize()...
67f80c6c-bc96-45b7-bb93-97c82e5ef8e5
3
@SuppressWarnings("unchecked") @Override public String displayQuestionWithAnswer(int position, Object userAnswer) { ArrayList<String> questionList = (ArrayList<String>) question; String questionStr = questionList.get(0); String answerStr = (String) answer; String userAnswerStr = (String) userAnswer; boolean...
019225a8-ff5c-4570-9ce9-1e24e973ed2c
9
void mergesort(Vector a, Vector b, int l, int r, XPathContext support) throws TransformerException { if ((r - l) > 0) { int m = (r + l) / 2; mergesort(a, b, l, m, support); mergesort(a, b, m + 1, r, support); int i, j, k; for (i = m; i >= l; i--) { //...
b5de5876-f0da-4087-b9a0-9e1095930a11
2
public static boolean insideAngle(Point v, Point u, Point P, Point A) { Point w = makeVector(P, A); double uw = Math.signum(crossProd(u, w)); double uv = Math.signum(crossProd(u, v)); double vw = Math.signum(crossProd(v, w)); double vu = Math.signum(crossProd(v, u)); if(Double.compare(uw, uv) == 0 && D...
d35d857f-c8a4-4db7-9aab-5d1ba1995bfc
3
static public byte[] read(File file) throws IOException, FileNotFoundException { byte []buffer = new byte[(int) file.length()]; InputStream ios = null; try { ios = new FileInputStream(file); if ( ios.read(buffer) == -1 ) { throw new IOException("end of file"); } ...
663d2f30-4556-4c80-9100-5d8629f29701
0
@Basic @Column(name = "CSA_POS_ID") public int getCsaPosId() { return csaPosId; }
cfee2046-8890-4b4e-b6df-b445ee215202
0
@Override public String getDescription() { return description; }
442fff8c-0c7a-4c36-bd80-6e4cdd8be966
5
public JSONObject increment(String key) throws JSONException { Object value = this.opt(key); if (value == null) { this.put(key, 1); } else if (value instanceof Integer) { this.put(key, ((Integer) value).intValue() + 1); } else if (value instanceof Long) { ...
a174b8bb-7396-4da0-a8ac-4c2b56a27ce2
6
public static void main(String[] args) { if ( args.length != 5 ) { System.err.println("Uso: ncons nprod tambuf niterp niterc"); return ; } // leer parametros, crear vectores y buffer intermedio Consumidor[] cons = new Consumidor[Integer.parseInt(args[0])] ; Pr...
eef3e09c-a839-4800-900c-c2d684d7f533
3
public HashMap broach(int type, int count) throws Exception { char[] params = new char[]{(char)type, (char)count}; ArrayList<Integer> answer = this.device.send(0x29, 3, params); if (answer.size() == 0) throw new Exception("Пустой ответ"); HashMap<String, Integer> result...
7eece237-723c-44c0-a3e7-9536d4564c15
0
@Override public String toString() { return "GOTO " + label; }
96db3488-5fe8-4892-80c1-ee8ba302bd4e
3
public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case WHAT: return isSetWhat(); case WHY: return isSetWhy(); } throw new IllegalStateException(); }
e72eda3b-1112-48de-be9d-793c7300e4ae
2
private void checkCollision(){ for(Moveable e : enemies){ if(player.contains(e)){ gameover = true; } } }
c6c2aae2-39ec-4b15-851b-31517443b99b
0
public String getInput() { return myInput; }
7c2f8279-46a6-4fa0-b884-aa32e17c9a5d
6
public boolean esPotAfegir(CjtRestriccioAula cjtRestAula, CjtRestGrupoAula cjtRestGrupoAula, CjtRestGrupSessio cjtRestGrupSesio) { boolean es_pot = true; //Solo sera false cuando se produzca alguna incoherencia! //Si un grupo esta obligado a estar en una aula que es la que esta prohibida usarse un dia/h...
10137da1-a06c-4d32-81e8-9b490c4ebdb9
1
@Override public void deleteSelection() { if (mDeletableProxy != null) { mDeletableProxy.deleteSelection(); } }
7757e2d7-0ee6-41cb-a51b-a0bc405ab588
6
public static void main(String[] args) { RedBlackTree t = new RedBlackTree(new MyInteger(Integer.MIN_VALUE)); final int NUMS = 40000; final int GAP = 307; System.out.println("Checking... (no more output means success)"); for (int i = GAP; i != 0; i = (i + GAP) % NUMS) t.insert(new MyInteger(i)); if (N...
45cb70de-05d4-482d-a4d9-9110a59896a5
6
private void computeMoments() { if (valid) throw new IllegalStateException(); centralMoments = new double[6]; centralMoments[0] = 1.0; centralMoments[1] = 0.0; int n = isInt ? iArray.length : dArray.length; for (int i = 0; i < n; i++) { double x = isInt ? iArray[i] : dArray[i]; x -= mean; double m ...
89415888-ca82-4e9e-b3e2-89eb548ab5cb
6
public void compiler_start() throws Exception{ File f = new File("src"+File.separator+"input"+File.separator+"program.lsp"); // прописываем путь где будет храниттся файл File f1 = new File(System.getProperty("user.dir")+"/src/output/program.java"); File f2 = new File(System.getProperty("u...
8e5b4d27-3e57-4b35-bf97-0dfba7bf3108
1
public void vacuum() { if (currentCell.dirt() > 0) { currentCell.dirt( currentCell.dirt() - 1); } }
0d324564-9057-4220-b397-d5c767d10839
0
public String getUserName() { return mUserName; }
c9dcf4a0-b2d9-4e72-885f-c5eb810bb5b2
9
public static int getCategoryIndex(String... category) { final WidgetChild catlist = Widgets.get(SELECT_WIDGET, CATEGORY_DROP_DOWN); if (catlist == null) return -1; WidgetChild[] children = catlist.getChildren(); String[] strs = new String[children.length]; int loc = 0; for (WidgetChild sub : children) {...
2b75e3ec-b78c-4320-ad13-9ceef1423cbf
3
public boolean isCloseTo(GameObject go, int offset) { return (this.getX() + this.size.width + offset) >= (go.getX()) && (this.getX() - offset <= (go.getX() + go.getSize().width)) && (this.getY() + this.size.height + offset) >= (go.getY()) && (this.getY() - offset) <= (go.getY() + go.getSize().height); }
528d9514-66fb-4eeb-b283-20592925efa0
5
@Test public void annotations() { for (final Method method : Command.class.getDeclaredMethods()) { final SubCommand sub = method.getAnnotation(SubCommand.class); if (sub == null) { continue; } final String n = method.getName() + ": "; ...
b83347a3-b7cd-449d-9539-b1c2aeeaeddd
6
public void tableChanged(TableModelEvent e) { // If we're not sorting by anything, just pass the event along. if (!isSorting()) { clearSortingState(); fireTableChanged(e); return; } // If the table structure has changed, cancel the sorting; the // sorting columns may have been either mo...
a1dac6e9-b435-43a6-97e5-3a172241f4ad
2
public static boolean getClientIsAcceptChat(String inString) throws TagFormatException, JDOMException, IOException { SAXBuilder mSAXBuilder = new SAXBuilder(); Document mDocument = mSAXBuilder.build(new StringReader(inString)); Element rootNode = mDocument.getRootElement(); String protType = rootNode.getNam...
e7322894-d197-4ef7-b19a-44111961dbda
6
private void unionAround(int index) { if (topBlock(index)) { union(index, tvBlock); } if (bottomBlock(index)) { union(index, bvBlock); } if (hasOpenedUpBlock(index)) { union(index, getUpBlock(index)); } ...
275ef4b6-9121-4462-bf4d-2fe4e5ae981a
9
@Override public void run() { try { OutputStream responseStream = client.socket().getOutputStream(); while(running){ lock.lock(); if(responseQueue.isEmpty()){ //System.err.println("sender: empty queue waiting!"); has_data.await(); //System.err.println("sender: got data")...
75a91410-d9e9-4b7c-a107-0c8ea38af69f
9
@java.lang.Override public boolean isValidMove(int MoveToX,int MoveToY,int MoveFromX,int MoveFromY) { if ((((MoveFromX-MoveToX)==1)||((MoveFromX-MoveToX)==0)||((MoveFromX-MoveToX)==-1))&&(((MoveFromY-MoveToY)==1)||((MoveFromY-MoveToY)==0)||((MoveFromY-MoveToY)==-1))){ return true; } ...
8d2d19f0-19b4-4534-848d-751c36a7d67e
6
public void setState(int pin, boolean state) { if (pin >= 0 && pin <= this.pins) { this.states[pin] = state; if (!state) { if (this.connections[pin] != null) { this.connections[pin].delete(); this.connections[pin] = null; this.circuit.getSimulation().addEvent(this.topnode[pin], 0); this....
d28e9d4d-1c60-4e36-ae89-6acb6d909688
8
public void Build(DMemeGrid grid) { Double tickSpacing = 50d; int rows = grid.Rows(); Double cellMaxWidth = 100d; Double X1 = horzOffset; Double Y1 = vertOffset; Double len = (double)(rows * tickSpacing); ...
5aa0b170-bfa9-4ca4-8391-eacb0fd64d22
2
public String getValue(String configName){ for (int i=0;i<configs.length;i++){ if (configs[i].contains(configName)){ return configs[i].substring(configName.length()+1); } } return null; }
9e882540-e9f1-43a1-9494-b3c87b705777
3
public synchronized int getAmount() { int retVal = amount; if (retVal != 0) { if (state == STATE_RELEASED) { amount = 0; } else if (behavior == DETECT_INITAL_PRESS_ONLY) { state = STATE_WAITING_FOR_RELEASE; amount = 0; ...
b70c1b72-0f8a-4c25-a775-f319b1dc3767
4
@Override public void deserialize(Buffer buf) { areaId = buf.readInt(); atLeastNbRoom = buf.readByte(); if (atLeastNbRoom < 0) throw new RuntimeException("Forbidden value on atLeastNbRoom = " + atLeastNbRoom + ", it doesn't respect the following condition : atLeastNbRoom < 0"); ...
ebd08790-a5ef-45dd-bbac-4c0c45fa7d10
2
@Override public boolean hasNext() { //return history.size() > 1 || // (history.firstElement().lastOctent < 8 && history.firstElement().subTree.internal_node); try { if (next == null) next = next(); return true; ...
4c3c45e6-ef9e-4f2b-ac0d-ea61b7576acd
2
public CellModel(Statistics statistics, BoardModel model){ this.model = model; cells = new CellContext[model.getHeight()][model.getWidth()]; for (int i = 0; i < model.getHeight(); i++) { for (int j = 0; j < model.getWidth(); j++) { cells[i][j] = new CellCo...