method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
cbece763-5df6-461a-8695-5720992a6d43
4
public int compare(Object arg1, Object arg2) { Point p1 = (Point) arg1; Point p2 = (Point) arg2; if (p1.x > p2.x) return 1; else if(p1.x == p2.x) { if (p1.y > p2.y) return 1; else if (p1.y == p2.y) return 0; } return -1; }
8b1908e7-4779-479c-9cff-67ab821931c2
1
private void halveArraySize() { Person[] smallerArray = new Person[(personArray.length/2)]; for (int i = 0; i < (personArray.length/2); i++) { smallerArray[i] = this.personArray[i]; } this.personArray = smallerArray; }
7e269938-c481-43a7-b885-eb45577d0a38
2
@Override public boolean canAttack(Board board, Field currentField, Field occupiedField) { return this.validSetupForAttack(currentField, occupiedField) && occupiedField.distanceBetweenRank(currentField) == this.forwardDistance(1) && Math.abs(occupiedField.distanceBetweenFile(currentField)) == 1; }
9059ee8c-9c02-484e-a318-3cf9191b2eb7
6
public void exec() { List<Double> annOut = network.run(); if (annOut.get(0) > .5 && annOut.get(1) <= .5) { headingDelta = 5; movement = 0; hunger += .0009; } else if (annOut.get(0) > .5 && annOut.get(1) > .5) { headingDelta = 0; movement = 3; hunger += .0009; } else if (annOut.get(0) <= .5 && ...
5258075f-35e8-4fd4-a9c7-daa994f0b051
5
public boolean configureFor(int stage) { if (stage == STAGE_GET_SEED) { toPlant = findPlantTile(actor, nursery) ; if (toPlant == null) { abortBehaviour() ; return false ; } if (nursery.stocks.amountOf(seedMatch()) > 0) { this.stage = STAGE_GET_SEED ; } else this.stage = STAGE_P...
b45fa651-07b1-4323-9f79-e0050237e4db
8
public void feedCitiesProcessDisasters() { players.get(currentplayer).feedCities(); players.get(currentplayer).processDisasters(); int numSkulls = players.get(currentplayer).getSkulls(); if (numSkulls == 3) { for (int i = 0; i < players.size(); i++) { if (i != currentplayer || players.size() == 1) { ...
1daa48a2-5ece-4abb-abb2-ff27984cb34e
0
@Override public String toString() { return "{id=" + id +"}"; }
017dc84b-7302-47d0-9743-07ee7c90e655
2
public void testPropertySetMinute() { Partial test = new Partial(TYPES, VALUES); Partial copy = test.property(DateTimeFieldType.minuteOfHour()).setCopy(12); check(test, 10, 20, 30, 40); check(copy, 10, 12, 30, 40); try { test.property(DateTimeFieldType.minute...
53000c29-977a-4de1-9220-60f14f898254
9
protected void load() { boolean loaded = false; try { load(file); loaded = true; } catch (final FileNotFoundException e) {} catch (final IOException e) { plugin.logException(e, "cannot load " + file); } catch (final InvalidConfigurationException e) { if (e.getCause() instanceof YAMLException) ...
ad9d47f2-eee7-4c2a-861d-e2f96983f513
0
public Integer getQuantity() { return quantity; }
67d79284-787a-41aa-b370-b9c602a712fe
0
public Timestamp getModifyDateGmt() { return this.modifyDateGmt; }
3148d5a5-b6cf-4b2f-a971-4d97a56a28d9
9
protected void verifySignature(RandomAccessFile randomaccessfile) throws IOException, InvalidLodFileException { randomaccessfile.seek(0L); boolean matchedSignature = true; for (int i = 0; i < SIGNATURE_NEW_MM7.length; i++) { int aByte = randomaccessfile.read(); ...
93e1fedb-ff2f-49cb-a151-dcf89aad3170
8
protected String getGlobalLinkerFlags() { final StringBuilder builder = new StringBuilder(); if (globalOverrideLinkerFlags == null || globalOverrideLinkerFlags.isEmpty()) { if (parent != null) builder.append(parent.getGlobalLinkerFlags()); else builder.append(config.ldflags()); } else { build...
85262bab-99e3-4e4f-9eac-eb6ff6555d6b
3
public FieldMetadata getNamedField(final String fieldName) { if (StringUtils.isBlank(fieldName)) return null; for (FieldMetadata field : fields) { if (field.getName().equals(fieldName)) return field; } return null; }
6e29c99c-91d2-4078-8faf-af46bf62a700
1
private String startTimeToString() { long start = this.videoSection.getStart(); if (videoSection.getTimeUnit() == TimeUnit.SECONDS) { start *= 1000; } int millisecond = (int) (start % 1000); start /= 1000; int second = (int) (start % 60); s...
42be4855-05c2-4c37-ade1-2c4577a93a88
7
public int dijkstra(int s, int t) { for (int i = 0; i < cost.length; i++) { dis[i] = INF; vis[i] = false; } PriorityQueue<Edge> q = new PriorityQueue<Edge>(); q.add(new Edge(s, 0, -1)); dis[s] = 0; while (!q.isEmpty()) { Edge u = q.poll(); if (u.id == t) return u.w; for (int j...
3b16ecd3-e4d3-4453-92b1-a33b6a6d32ba
7
@Override public Clip getSoundClip(EnActionResult actionResult) { if (moveClip == null) { moveClip = openClip(SoundPlayerWav.SOUND_MOVE); } if (treasureClip == null) { treasureClip = openClip(SoundPlayerWav.SOUND_TREASURE); } if (winClip == null) { ...
2bfba43f-67e3-424d-8f9a-75bb284f89ef
3
public int aroonOscLookback( int optInTimePeriod ) { if( (int)optInTimePeriod == ( Integer.MIN_VALUE ) ) optInTimePeriod = 14; else if( ((int)optInTimePeriod < 2) || ((int)optInTimePeriod > 100000) ) return -1; return optInTimePeriod; }
74535bdc-d43e-4ebe-a565-233ea5cdf739
7
public String getGameStateName(){ String stateName; switch(gameState){ case 0: stateName = "New hand"; break; case 1: stateName = "Fold"; break; case 2: stateName = "Bet"; ...
6b11a1e3-5635-400b-be3e-366f8c14dee4
3
public Word getAnswer(String s){ Iterator<Word> iterator = list.iterator(); Word w = null; boolean flag = false; while (iterator.hasNext()){ w = iterator.next(); if (w.getEWord().equals(s)){ System.out.println(w); flag = true; ...
f9392fa2-c8ca-47e1-8be4-b2da51b5c190
0
public void setIautosSellerInfo(IautosSellerInfo iautosSellerInfo) { this.iautosSellerInfo = iautosSellerInfo; }
4be696f2-3082-47c2-bf19-42c0351859f8
1
private void fetchAttributes() { int len = GL20.glGetProgrami(program, GL20.GL_ACTIVE_ATTRIBUTES); // max length of all uniforms stored in program int strLen = GL20.glGetProgrami(program, GL20.GL_ACTIVE_ATTRIBUTE_MAX_LENGTH); attributes = new Attrib[len]; for (int i = 0; i < len...
b54a3e12-cca8-41a5-86fd-ae1b521cc7fd
4
private static boolean formQueryHotel(Criteria crit, List params, StringBuilder sb, StringBuilder sbw, Boolean f2345, Boolean f5) { List list = new ArrayList<>(); StringBuilder str = new StringBuilder(" ( "); String qu = new QueryMapper() { @Override public String mapQuer...
031539f9-990b-4538-a27e-b39e58bd179a
8
Level(GameEngine eng, String file_prefix) { priority = -1; engine = eng; try { layout = ImageIO.read(new File(file_prefix + ".layout.png")); visual = ImageIO.read(new File(file_prefix + ".visual.png")); LevelGeometry g = new LevelGeometry(engine, layout, visua...
d09fc437-b341-436e-bb39-d8799cb74a94
5
public static ArrayList<Media> getAllRentedMedia() { try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ArrayList<Media> mediaList = new ArrayLis...
5a62d612-83ba-4253-b04f-440b2abff7ee
8
public String getAccessString() { StringBuffer sb = new StringBuffer(); if (AccessFlags.isPublic(this.accessFlags)) sb.append("public "); if (AccessFlags.isPrivate(this.accessFlags)) sb.append("private "); if (AccessFlags.isProtected(this.accessFlags)) ...
1a76e16d-a5c3-46b8-98ce-2180ef7a8a81
8
public void attackClosestUnit() { ArrayList<Cell> attackableCells = getAttackableCells(map); if (attackableCells.size() == 0) { map.resetPreviousCells(); Queue<Cell> queue = new LinkedList<Cell>(); queue.add(this.getCell()); ArrayList<Cell> expandedNode...
f342eb56-dea4-4097-9746-9d27080eb7a4
3
public static void dfsCat() { Stack<Integer> s = new Stack<Integer>(); s.push(hcat); vcat[hcat] = true; while (!s.isEmpty()) { int cur = s.pop(); for (int i = 0; i < gcat[cur].size(); i++) { int neigh = gcat[cur].get(i); if (!vcat[neigh]) { vcat[neigh] = true; s.push(neigh); } } ...
b44cfc9e-62b1-4304-9456-2145ec6d810f
9
public String encrypt (String input) { //Below checks whether the string contains any digit characters if(input.matches(".*\\d.*")) throw new IllegalArgumentException(); //Below the replaceAll is used to ignore non-characters until first appearance of a character String formatted = input.toUpperCase().replaceAll("[...
84ee0c9f-72c9-42ba-aeab-6a2937a1d81d
9
private static void intersectFrom(Scope scope1, Scope scope2, Set<String> matchedNames, Collection<Variable> vars) { Set<Variable> privates1 = scope1.mPrivateVars; Variable[] vars1 = scope1.getLocallyDeclaredVariables(); ...
9463cc27-4104-4073-9cd7-4b4a9fa50aa2
1
public void playGame() { while (!isOver()) { showTrack(); move(); } showTrack(); showWinners(); }
7c6741ee-dc4c-4e8b-ac29-c7992b6a4c68
1
public int hashCode() { int code = 0; for (final E item : this) { code = code ^ item.hashCode(); } return code; }
baf8448e-fd64-4459-a3fc-278e5803da7b
0
public List<String> getNameCombinations() { List<String> nameComb = new ArrayList<String>(); nameComb.add(getLastName() + ", " + getFirstName() + " " + getMiddleName()); nameComb.add(getFirstName() + " " + getMiddleName() + " " + getLastName() + " " + getSuffix()); return nameComb; }
fd306349-bfc0-404f-b55b-bf6a9e9de02b
7
private static void Transform(int i, int[] buffer, int messageLenBytes, byte[] message, byte[] paddingBytes, int[] state) { int index = i << 6; for (int j = 0; j < 64; j++, index++) { buffer[j >>> 2] = ((int) ((index < messageLenBytes) ? message[index] : paddingBytes[index - messageLenBytes]...
2b48656f-c2bd-4eeb-afaa-65034c7f7590
8
public static StandardObject lookupVariableType(Symbol variablename) { { StandardObject entry = ((((KeyValueList)(Stella.$LOCALVARIABLETYPETABLE$.get())) != null) ? ((StandardObject)(KeyValueList.lookupVariableTable(((KeyValueList)(Stella.$LOCALVARIABLETYPETABLE$.get())), variablename))) : ((StandardObject)(null)))...
77a23884-e332-4fba-99ea-11d7a5817bf4
8
public static void choldc_f77(int n, double a[][], double diagmx, double tol, double addmax[]) { /* Here is a copy of the choldc FORTRAN documentation: SUBROUTINE CHOLDC(NR,N,A,DIAGMX,TOL,ADDMAX) C C PURPOSE C ------- C FIND THE PERTURBED L(L-TRANSPOSE) [WRITTEN LL+] DECOMPOSIT...
330b0d93-1b70-496d-81d5-95a3448f50d7
7
@Override public boolean tick(Tickable ticking, int tickID) { if((affected!=null)&&(affected instanceof MOB)&&(tickID==Tickable.TICKID_MOB)) { final MOB mob=(MOB)affected; if(tickUp==1) { if(success==false) { final StringBuffer str=new StringBuffer(L("You get distracted from your search.\n\r...
81ed043b-d817-4657-b6e7-2a1fe4ef8e7b
3
public static void main(String[] args) throws IOException { byte[] b = new byte[16]; for(int i = 0 ; i < b.length;i ++) { b[i] = (byte)i; } MyOwnStream1 mosrm = new MyOwnStream1(b); //指定下次读取的位置 mosrm.mark(3); //需要用reset方法来重置下次读取的位置为mark指定的位置 mosrm.reset(); while(true) { int c =...
bc703c5d-fccd-4dd7-afb1-fcbc5ca2ba19
9
public IDassign(String type) { this.nextIDchar = new Character[type.length()]; Pattern patrn = Pattern.compile("[...a-z_]"); Matcher match = patrn.matcher(type); for (int i = 0; i < 3; i++) { if (i == 1) { patrn = Pattern.compile("[...A-Z_]"); match = patrn.matcher(type); } else if (i == 2) ...
ad253476-dab4-47d2-9f28-93c7a8af84ee
2
public void build(AssemblyType type) { Mass one; Mass two; double restLength; double constant; NodeList nodes = myDoc.getElementsByTagName(SPRING); for (int i = 0; i < nodes.getLength(); i++) { restLength = -1; constant = 1; Node springItem = nodes.item(i); NamedNodeMap nodeMap = springItem.getA...
4367cde6-222a-42d8-baf7-0c9fec6e4163
5
public Component getEditorComponent(final PropertyEditor editor) { String[] tags = editor.getTags(); String text = editor.getAsText(); if (editor.supportsCustomEditor()) { return editor.getCustomEditor(); } else if (tags != null) { // m...
c3f1e2e8-5378-434a-b735-52a7a36de464
3
private static void printGridletList(GridletList list, String name, boolean detail) { int size = list.size(); Gridlet gridlet = null; String indent = " "; System.out.println(); System.out.println("============= OUTPUT for " + name ...
e455157d-dddf-420e-869b-720295fe3e5c
1
JobFuturePair(PageJob job, Future<?> future) { this.job = job; this.future = future; }
d9002397-ea77-4825-b68c-48ee022e8571
3
public void onJoin(String channel, String sender, String login, String hostname) { if (!sender.equals(bot.getNick())) { if (status == GameStatus.PRE) sendNotice(sender, getFromFile("GAME-STARTED", NOTICE)); else if (status != GameStatus.IDLE) sendNotice(sender, getFromFile("GAME-PLAYING", NOTICE)); } ...
828e9df5-6166-418c-8f6d-81579e1abb1b
3
public static void main(String[] args) { // 只能在List下面的类型 GenericTestExtends<? extends List> ge = null; //引用指向不同类 ge = new GenericTestExtends<ArrayList>(); ge = new GenericTestExtends<LinkedList>(); // ge = new GenericTestExtends<HashMap>(); // 只能在List上面的类型 GenericTestExtends<? super List> ge2 = n...
c63641ed-a1a5-4e90-b2cb-ed7039dff9ed
5
@Override public void mousePressed(final MouseEvent e) { // if handler is clicked don't do anything for (final Element el : getGraphicPanel().getSelectionManager().getSelectedElements()) { if (el.getComponent().getHandlers().isHandlerAt(e.getPoint())) { System.out.println...
373d406e-e655-4f5b-8042-fb80ba4a3b2b
3
public boolean isBlockTile(Block block) { Set<Integer> tilesKeys = tilesLocations.keySet(); SerializableLocation blockLocation = new SerializableLocation(block.getLocation()); for(Integer key : tilesKeys) { for(int i = 0; i < tilesLocations.get(key).size(); ++i) { SerializableLocation keyBlockLocation = ti...
ac6d1d64-d5fd-4bc1-b4e9-488ae4380709
1
public boolean checkhit(Coord c) { init(); if (spr != null) return (spr.checkhit(c)); return (false); }
fc487c0f-0ca7-40da-913b-b1e967b82ab4
9
@Override public void keyReleased(KeyEvent arg0) { if (arg0.getKeyCode() == KeyEvent.VK_W || arg0.getKeyCode() == KeyEvent.VK_A || arg0.getKeyCode() == KeyEvent.VK_S || arg0.getKeyCode() == KeyEvent.VK_D) { if (arg0.getKeyCode() == KeyEvent.VK_W) { playerAction("halt", "U"); } if (arg0.g...
7752a0c6-a02b-420d-a378-0dc5754a05f1
4
public void update(GameContainer gc, Player player, int deltaT) { float rotateSpeed = 0.06f; Input input = gc.getInput(); if (input.isKeyDown(Input.KEY_Q) && angle < 90) { angle += rotateSpeed * deltaT; } else if (input.isKeyDown(Input.KEY_E) && angle > 2) { angle -= rotateSpeed * deltaT; } x = Ma...
9f25c173-a2e2-4983-814b-6c18e4cdc98d
2
public boolean equals(Vector3f r) { return x == r.getX() && y == r.getY() && z == r.getZ(); }
63dfb3d9-90c4-44b4-b6e8-00c00c0c1845
0
public Entradas getEntradasIdEntrada() { return entradasIdEntrada; }
dc1ab0c0-757d-4e62-91c4-bef66a9bd0a9
3
public synchronized void actualiza(long tiempoTranscurrido) { if (cuadros.size() > 1) { tiempoDeAnimacion += tiempoTranscurrido; if (tiempoDeAnimacion >= duracionTotal) { tiempoDeAnimacion = tiempoDeAnimacion % duracionTotal; indiceCuadroActual = 0; ...
fb517b42-8fb9-4535-8865-a7de09b5a176
2
@Override public void pop() { if (amount != 0) { for (int i = 0; i < amount + 1; i++) { stack[i] = stack[i + 1]; } amount--; } }
9b7f03b4-62a8-4534-bf56-d2dcbe71da5f
5
private static List<URL> getJarUrls(String jarString, Shell shell) { String[] jars = jarString.split(";"); List<URL> urls = new ArrayList<URL>(); if (jars != null) { for (int i = 0; i < jars.length; i++) { String jar = jars[i]; if (jar != null && !"".equals(jar.trim())) { try { URL url = new...
9135c46a-5f41-497c-84c0-b4efe571e8d5
8
public static void main(String[] args) throws IOException { // TODO Auto-generated method stub GUI.init(); System.out.println("...SOS..."); String in = GUI.askString("Connection setup", "To join a game, type an ip address. To host one, type \"host\""); Render.loadStep = "Loading resources..."; new Thread(ne...
086bd2e6-40d7-4a66-8265-52f093a0ef75
3
public static Borne getBorneById(int id_borne) { Borne borne = null; Statement stat; try { stat = ConnexionDB.getConnection().createStatement(); stat.executeUpdate("use nemovelo"); ResultSet res = stat.executeQuery("select * from borne where id_borne="+ id_bo...
c1273731-8490-4386-8696-55ef81bd3105
4
@Override public String toString() { StringBuilder movieString = new StringBuilder(); Iterator<String> it = keywords.iterator(); Iterator<String> actorIterator = actorList.iterator(); movieString.append("-Movie- \n").append("director: ").append(director).append('\n'); movieS...
82477033-6988-4524-8610-97a3e1b7dd11
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; PingMessage other = (PingMessage) obj; if (correlationId == null) { if (other.correlationId != null) return false; } else if (!correlati...
b57c03b4-617b-4837-b7c3-0869f74691a5
4
public void insertWord(String word) { //Start at root TrieNode curNode = root; //loop through each char in the string for (char c : word.toCharArray()) { //get the index of where the string should be stored in the children array int index = getIndex(c); //if -1 then the char is invalid if (index != ...
8af424ca-2a5b-4d8c-89cb-a5a86126b879
9
private void gameKeyPressed(int key){ switch(key){ case KeyEvent.VK_W: //UP break; case KeyEvent.VK_S: //DOWN break; case KeyEvent.VK_A: //LEFT mainModel.wilbert.moveLeft(); break; case KeyEvent.VK_D: //RIGHT mainModel.wilbert.getBody().applyLinearImpulse(new Vec2(0.01f, 0.0f),main...
c97a1b52-fc16-4818-8d9b-fb2bc9071b6c
9
@Override public boolean equals(Object o) { if (o == null) { return false; } if (!(o instanceof Pair)) { return false; } else { Pair<?, ?> oP = (Pair<?, ?>) o; return (key == null ? oP.getKey() == null : ...
9b07492f-438b-4aba-97f2-e28783541d78
2
public final Hashtable<Integer,Integer> distributionOff() { final Hashtable<Integer,Integer> offd = new Hashtable<Integer,Integer>(); for (int m=0; m<this.m; m++) { final Integer key = off[m].size(); Integer value = offd.get(key); if (value==null) offd.put(key, value); else value++; } return offd; ...
b1d82cc6-e067-4135-8abc-42886f805939
7
* @param row * The row of the bracket to match. * @param col * The column of the bracket to match. * @param match * The BracketMatch instance for this match attempt. */ private void findMatchForward(int row, int col, BracketMatch match) { int y = row; i...
4a11271f-f840-4cf3-92b2-b272bbe68d48
8
public static void hm_main(String args[]){ int map_type = Integer.parseInt(args[0]); int NUM_THREADS = Integer.parseInt(args[1]); int init_capacity = Integer.parseInt(args[2]); int load = Integer.parseInt(args[3]); System.out.println("Running with " + NUM_THREADS + " threads."); System.out.println("Runni...
6142784d-7277-46dd-bffe-eaacf2c5325f
4
@Test public void test_insertions() { int m = 3; int n = 5; Matrix m1 = new MatrixArrayList(m, n); for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) m1.insert(i, j, (double) (i * j)); } for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) assertEquals(m1.get(i, j), (double)...
e24d7c62-3d30-4c70-82c2-ae148397d466
0
public boolean GetHasMemory() { return hasMemory; }
3585be8b-b01f-4bc1-8acf-2b07141f4dd5
3
public static void generateNewPopulation( Individual[] pop ) { sumFitness = 0; for( int i=0; i<POPULATION_SIZE; i++ ) sumFitness += pop[i].fitness; generation[ currentGeneration++ ] = sumFitness / POPULATION_SIZE; Individual[] tempGen = new Individual[POPULATION_SIZE]; for( int i=0; i<POPULATION...
6256cdcd-1b5f-4104-9719-6bc802a509b3
4
public void keyPressed(final KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_LEFT) moveXcoord = -game.speed; if (e.getKeyCode() == KeyEvent.VK_RIGHT) moveXcoord = game.speed; if (e.getKeyCode() == KeyEvent.VK_UP) moveYcoord = -game.speed; if (e.getKeyC...
8402f628-3291-4096-b944-4903b4fa00fe
2
private void strize(){ for(int i=0; i<m;i++) { stolbiki[i] = new Stolbec(n); for(int j=0; j<n; j++){ stolbiki[i].setone(j, stroki[j].get(i) ); } } }
66819e3e-10e5-444b-a5f9-a3a1b4f7e4c0
9
public int countSquares(String[] field){ n = field.length; m = field[0].length(); map = field; int result = 0; for(int i=0; i<n; i++){ for(int j=0; j<m; j++){ for(int u=i; u<n; u++){ for(int v=j+1; v<m; v++){ ...
fae3279a-3433-4391-815e-4bf555041702
5
public static Polynomial getIrreducible(final int degree, final int start) { int test = start; Polynomial polynomial = new Polynomial(test); while(polynomial.getWeight() % 2 == 0 || !polynomial.isMonomial() || polynomial.getDegree() < degree || !polynomial.isIrreducible()) { test++; ...
4ae9d186-c9cf-4c8b-b484-50ce6683cd10
8
private void helpPressed() { if (getTray() == null || fHelpButton != null && fHelpButton.getSelection()) { // help button was not selected before if (getShell() != null) { Control c = getShell().getDisplay().getFocusControl(); while (c != null) { if (c.isListening(SWT.Help)) { c.notifyListen...
d9a2bbc5-48c3-427c-b995-d45c71ea9071
1
@Override public boolean hasNext() { return Math.abs( x - line.getX2()) > 0.9 || ( Math.abs(y - line.getY2()) > 0.9); }
e7b8efc1-d9e9-4320-a7db-4357535f7278
7
public static boolean isVersionLessThan(String isThis, String lessThanThis){ int A[] = parseVersion(isThis); int B[] = parseVersion(lessThanThis); if(A[0] < B[0]){ return true; } if(A[0] == B[0]){ if(A[1] < B[1]){ return true; } if(A[1] == B[1]){ if(A[2] < B[2]){ return true; } ...
5fd33cd7-94d8-4bcd-bbc2-73603ade7381
8
public static PartitionMetadata findLeader(Collection<BrokerReference> replicaBrokers, Collection<BrokerReference> seedBrokers, String topicId, int partitionId) { PartitionMetadata returnMetaData = null; loop: for (BrokerReference seed : seedBrokers) { SimpleConsumer consumer = null; try { consumer ...
436e9414-2bb6-4aea-bbe7-289e4c2d7484
6
static Object redirect(Object proxy, InvocationHandler handler, Method m, Object... args) throws Throwable { try { return handler.invoke(proxy, m, args); } catch(Throwable t) { if(t == null) { throw new Exception("An excepti...
89a68f91-df44-46dd-a916-c8643ae7d57d
8
public void move(int Direction , int Delta) { if(y < Game.HEIGHT - 32) { if(Direction == 3) { dir = 3; y += pace; currentLengthD += pace; } } if(x > 0) { if(Direction == 1) { dir = 1; x -= pace; currentLengthL += pace; } } if(x < Game.WIDTH - 32) { if(Dire...
9c8c081c-7434-49bd-997d-1b8717b050ff
7
public FillResult tryFillCanvas(TextMetaInfo textInfo, StyleConfig styleConfig) { FillResult result = new FillResult(); int maxCanvasHeight = styleConfig.getCanvasHeight(); // 所有textLine取出来,算出最高的 // 在这里用set过滤掉指向相同文本的textLine,相同文字的图片块在画布上只绘制一次 Set<TextLine> textLineList = new HashSet<TextLine>(); int maxL...
433285ff-c2bc-4e7b-b72b-65a87f455c0f
0
public void configureAndShow(JoeTree tree) { configure(tree); super.show(); }
a3589fc2-c960-4c2a-9694-cd05481df2e8
3
private void btn_eliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_eliminarActionPerformed final int row = this.table_ticket.getSelectedRow(); if (row >= 0) { final Ticket tic = this.tableTicketModel.getTicket(row); int i = JOptionPane.showConfirmDial...
19e30beb-a8ca-45bf-909c-eca6056bfae3
5
public static void testDictionary(String apiKey) throws NetworkException, AnalysisException { DictionaryManager dictionaryManager = new DictionaryManager(apiKey); // Delete all dictionaries in our account. { for (Dictionary dict : dictionaryManager.allDictionaries()) { System.out.println("Deleting curren...
b6316408-ff71-421d-88fa-e3b80b316bf9
1
public void delLines(int[] indexRows) { // modif bellier.l - merci pour le code //la fonction remove d'une arraylist effectue également un rétractage //indiceRow contient des indices "erronés" d'où l'intéret de delay for (int i = indexRows.length - 1; i >=0 ; i--) { ob...
8e46b9df-9661-4d72-badd-5eb6815a8177
0
@Override public BeerReadOnly getBeer(String beerId) { return persistenceService.get(beerId); }
ef355334-1a8d-40c3-b848-58102e248ee4
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 Mitglied)) { return false; } Mitglied other = (Mitglied) object; if ((this.id == null && other.id != null) || (...
b2169070-0679-41f0-9ca0-ea5b19840ff6
0
public static void main(String[]args){ FabrykaKomputerow fabrykaKomputerow = new FabrykaKomputerow(); System.out.println("PC"); Komputer pc = fabrykaKomputerow.wydajKomputer("PC"); System.out.println("\n\nLaptop"); Komputer laptop = fabrykaKomputerow.wydajKomputer("Laptop"); }
18acc22c-2657-4153-8bdb-3bd1bb3cbb0c
0
public void addEvent(Event e) { events.add(e); }
e726ddfe-a061-4833-9df9-943d76e1adcd
9
public static Map<String, String> simpleCommandLineParser(String[] args) { Map<String, String> map = new HashMap<String, String>(); for (int i = 0; i <= args.length; i++) { String key = (i > 0 ? args[i - 1] : null); String value = (i < args.length ? args[i] : null); if (key == null || key.star...
cab180f9-8797-4a78-b9a4-959bfc86a45f
3
public static boolean wordBreak(String s, Set<String> dict) { if(dict.size() <=0) return false; Pattern pattern; Matcher matcher; Iterator<String> iterator=dict.iterator(); while(iterator.hasNext()){ pattern=Pattern.compile(iterator.next()); matcher= pattern.matcher(s); s=matcher.replaceAll(""); } ...
ea48b48b-99ce-4d9e-adc8-26cc7ef3af74
1
public final void setUnitPrice(double unitPrice) { if(unitPrice < 0) { throw new IllegalArgumentException(); } this.unitPrice = unitPrice; }
5f950ead-7c29-49a6-a85d-e601bcae1445
0
@Basic @Column(name = "CSA_CANTIDAD") public int getCsaCantidad() { return csaCantidad; }
aac53679-c45a-43f5-a4e0-83dff56e67f4
0
public void validate(final Object object, final Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "Cannot be empty", "Cannot be empty"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description", "Cannot be empty", "Cannot be empty"); }
3fb51d12-5448-48aa-b192-acf3486eb713
3
@Override public Dimension getPreferredContentSize() { int width = 0; int height = 0; int dividerHeight = getRowDividerHeight(); for (TreeRow row : new TreeRowViewIterator(this, mRoot.getChildren())) { height += getRowHeight(row) + dividerHeight; } for (TreeColumn column : mColumns) { width += column...
1f1a3c62-a9df-418f-b633-cc341dcf828a
0
public Productos() { initComponents(); mostrarProductosTabla(); }
33c2f4ae-c811-4470-862a-16b7df64aa1a
1
public Production[] getAnswer() { /* Collections.sort(myAnswer, new Comparator<Production>(){ public int compare(Production o1, Production o2) { return (o2.getRHS().length()-o1.getRHS().length()); } }); */ Production[] answer=new Production[myAnswer.size()]; for (i...
fe515b76-c102-48aa-a308-a29bcdeeb1ef
5
public void connect() { MongoClientOptions.Builder builder = new MongoClientOptions.Builder(); //builder.socketTimeout(0); builder.socketKeepAlive(true); boolean notConnected = true; while (notConnected && !shutdown) { try { Utils.printWithDate("Connect to MongoDB at " + hostname + " (Port " + p...
d516a910-4235-4ea0-b7ee-3de3677100ed
3
@Test public void testSphereColliding(){ // spheres at an arbitrary location and is obviously not colliding Sphere s4441 = new Sphere(new Vector3f(4.0f,4.0f,4.0f),1.0f); Sphere s8881 = new Sphere(new Vector3f(8.0f,8.0f,8.0f),1.0f); Sphere s0004 = new Sphere(new Ve...
35863264-bdbc-40b2-b05d-00e56b1516f7
7
public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_P) { //Presiono letra P pausa = !pausa; //cambio valor de pausa } if (e.getKeyCode() == KeyEvent.VK_LEFT) { //Presiono flecha izquierda barra.setDireccion(1); } if (e.getKeyCode() =...
bf66dafe-7d15-4796-a422-df96fe19edb3
0
private int readUInt8(byte[] uint16, int offset) throws IOException { int b0 = uint16[0 + offset] & 0x000000FF; return b0; }
1675f7c1-0c4f-4e07-9824-3db07a701e2e
6
public static Tree decisionTreeLearning( ArrayList<HashMap<String, String>> examples, ArrayList<String> attributes, String goalAttribute, HashMap<String, String[]> attributeValues, ArrayList<HashMap<String, String>> parentExamples) { print("Attributes: " + attributes); print("Examples: " + examples); ...