method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
1c102d05-e1eb-4180-8979-7c8c2c1f4ecb
2
public synchronized void actionPerformed(ActionEvent e) { if (e.getSource() == fallTimer) { game.gameBlock.fall(); } else if (e.getSource() == resumeButton) { game.resume(); } }
18d963d5-3256-411f-b52d-f3bee87deedf
7
protected void showMenu(final RightMenu menu) { if (this.rightMenu.isHidden()) { this.rightMenu.clickHideButton(); } if (this.shown != menu) { this.rightMenu.clearContent(); String[] menustringArray = null; String info; switch (menu) ...
01d373e7-3963-4731-b80b-9abff6e9a522
2
public void readDocs(Segmenter seg, String docsPath) { BufferedReader reader; // int n = 0; try { reader = new BufferedReader(new InputStreamReader(new FileInputStream(docsPath))); String line = ""; while ((line = reader.readLine()) != null) { /*if (n == 1000) return;*/ //System.out.pri...
6bd9c299-ff8b-4ec8-82ac-5f281d8a6eea
1
public JToolBar getToolBar() { return headerPanel.getComponentCount() > 1 ? (JToolBar) headerPanel .getComponent(1) : null; }
da2cd61f-d2c3-45a2-9315-558f68ee2fdd
0
public Collection getParams() { return params; }
fa81ddd6-f45d-4500-bfcc-25bd5e708be3
8
@Override public Tile getTile(Tile source, Direction dir) { int x = source.getX(); int y = source.getY(); switch(dir) { case NORTH: y--; break; case SOUTH: y++; break; case EAST: x++; break; case WEST: x--; break; } if(x < 0) x = tiles.length - 1; else if(x > ...
1aca1c82-ce63-4747-a59d-3c4524767637
9
@Override public void update() { if (!transmitting) { super.update(); boolean resourcesUpdated = false; Resource resource = null; ArrayList dirtyResources = new ArrayList(); try { for (String key : resources.keySet()) { ...
2d5078b4-62f7-430f-acba-6f99f5612036
2
public static void main(String[] args) { if (SystemTray.isSupported()) { PopupMenu popup = new PopupMenu(); MenuItem i1 = new MenuItem("Now!"); i1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { myThread.interrupt(); ...
c387dfad-44ff-4a94-9be2-7463f07ed953
2
@Override public Converter put(String key, Converter value) { Converter v = super.put(key, value); if (v != null) { throw new IllegalArgumentException("Duplicate Converter for " + key); } return v; }
f844c02b-acdd-4dd8-bdc3-6b36a7707ad6
6
public boolean searchFor(int team){ if (blueStation1 == team) { } else if (blueStation2 == team) { } else if (blueStation3 == team) { } else if (redStation1 == team) { } else if (redStation2 == team) { } else if (redStation3 == team) { } else { return ...
b10465bc-a4e8-4738-8067-c616640b0520
6
public boolean remove(int data){ Node returnNode = null; if(head.data == data){ returnNode = head; if(tail == head){ head = null; tail = null; }else head = head.next; }else{ Node prev = head; Node n = head.next; while(n != null){ if(n.data == data){ returnNode = n; i...
8c7f79aa-59f5-43c7-8c0d-cd5d3de45dff
7
private void destroyToolBar(JToolBar tb) { if (tb == null) return; Component c; AbstractButton b; for (int i = 0, n = tb.getComponentCount(); i < n; i++) { c = tb.getComponentAtIndex(i); if (c instanceof AbstractButton) { b = (AbstractButton) c; b.setAction(null); ActionListener[] al = b.ge...
2045b285-fe60-4966-a42b-a2d2ebcb0a3b
1
public void setState(String state) { state = state.trim(); if ( state.isEmpty() ) { throw new RuntimeException( "'state' should not be empty" ); } this.state = state; }
b9b6a879-3f81-4f75-965c-2525ed141960
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...
eed1eefe-bf94-481c-930d-83dffe58be63
7
@Override public int getReps(MOB viewerM, Environmental item, List<? extends Environmental> theRest, boolean useName, boolean longLook) { final String str=itemSeenString(viewerM,item,useName,longLook,false); String str2=null; int reps=0; int here=0; Environmental item2=null; ...
b66aa95f-021c-4c3d-b028-fb32eabce9fb
4
@Override public void onDraw(Graphics G, int viewX, int viewY) { if (X>viewX&&X<viewX+300&&Y>viewY&&Y<viewY+300) { G.setColor(Color.yellow); int x = (int)X+radius-r.nextInt(radius*2)-viewX; int y = (int)Y+radius-r.nextInt(radius*2)-viewY; G.drawLine(x...
d3271cc2-653c-44b1-9519-f0fc8f22a211
6
@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof SyncConfig)) { return false; } final SyncConfig other = (SyncConfig) obj; if (configs == null) { if (other.configs != null) { return false; } ...
09cb648a-3d26-4f06-83da-bd4d3a7bf215
9
private void calPrincipalCols(int depth){ if(depth<=0 || depth>colNum) depth = colNum; ArrayList<Integer> pcs = new ArrayList<Integer>(); for(int i=0;i<principalComponentNum;i++){//for each principal component for(int j=0;j<depth;j++){ //find depth index related to the depth-th biggest elements double max ...
2f7abdb1-1b9e-4dd1-b68d-827712157db1
4
@Test public void testReplaceHashNotExist() { LOGGER.log(Level.INFO, "----- STARTING TEST testReplaceHashNotExist -----"); String client_hash = ""; String server_hash = ""; String server_hash_new = ""; try { server1.setUseMessageQueues(true); } catch (Time...
ba3cac47-66eb-4624-8165-160a1d2773f8
3
private void addItem(Production item) { if (restricted != null && !restricted.contains(item)) { JOptionPane.showMessageDialog(parent, item.toString() + " is not part of the set.", "Item not Desirable", JOptionPane.ERROR_MESSAGE); return; } if (alreadyChosen.contains(item)) { JOptionPane.showMes...
6ec4a053-c6d2-48f6-ae4d-8092fe391032
3
@Override public void actionPerformed(ActionEvent e) { if (e.getSource().equals(gestionAuditeursB)){ new AuditeurIHM(); }else if (e.getSource().equals(listeAuditeursB)){ ListeAuditeurs listeaud = gestion.getListeAuditeurs(); String message=""; for (int i=0; i< listeaud.liste.size();i++){ messag...
0014c351-eafe-4827-9fe5-1d4eb699f213
2
private void process() { refreshTable(); tblSchedule.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); model = (DefaultTableModel) tblSchedule.getModel(); model.addColumn("Nr."); model.addColumn("Naam"); model.addColumn("Contracturen"); int daysOfMonth = calendar.getActu...
6cf83469-14ef-42e5-ae12-fb3530c01ba0
4
public void handleNewgame(String part) { if(part.equals("")) { this.newGameAsk = true; this.sharedBoard.iWantNew(myPlayNum); } if(part.equals(communication.scOK)) { this.sharedBoard.answerNew(myPlayNum, true); this.newgame = true; if(this.myPlayNum == this.victor) { this.sharedBoard.setC...
48456747-cd1a-446b-a0ef-cf102839094d
8
@Override protected Value evaluate(ExecutionContext executionContext) throws InterpretationException { Color color = executionContext.ui.dw.getCurrentColor(); if(color.equals(Color.BLACK)) return new Value("BLACK"); if(color.equals(Color.BLUE)) return new Value("BLUE"); if(color.equa...
ed14e3f5-5f6d-4830-823a-88dc8d493d82
2
private boolean reqAreMet(CommandSender sender, UltimateCommand command) { for (Req req : command.reqs) { if (!req.apply(sender)) { req.message(sender); return false; } } return true; }
a27ff9ba-bc0e-45f1-8367-56dd6f1c8201
9
public void applyBoxBlur(int iterations) { for (int a = 0; a < iterations; a++) { // Blur in the direction for (int y = 0; y < size - 1; y++) { for (int x = 0; x < size - 1; x++) { if (x == 0) { setAlt(x, y, (2 * getAlt(x, y) + getAlt(x + 1, y)) / 3.0f); } else if (x == size - 1) { se...
ef707d80-b4f9-4ab3-91e6-417f3de19aab
9
protected Object cloneTemplate(Node node) { Object obj = null; try { if (template.getClass().isEnum()) { obj = template.getClass().getEnumConstants()[0]; } else { obj = template.getClass().newInstance(); } // Special case: Check if the collection // should be a map. This is if t...
157733c1-2a53-44e6-a6a1-5b518e782b6a
7
public void remove(int nr) { if(first==null) { return; } LinkedNotice show = first; for(int i = 0; i<nr; ++i) { if(show.getNext().equals(null)) { break; }else{ show = show.getNext(); } } switch(nr) { case 0: first = first.getNext(); if(first!= null) { first.setPre(null); }...
d3e75afa-9019-4155-af19-c288978f9b1e
9
@Override void addTerm(final int termID) { final FreqProxPostingsArray postings = freqProxPostingsArray; assert !hasFreq || postings.termFreqs[termID] > 0; if (!hasFreq) { assert postings.termFreqs == null; if (docState.docID != postings.lastDocIDs[termID]) { // New document; now enc...
9c47027a-3ad8-4582-a413-32b2a914cc5b
4
private HandshakeState isFlashEdgeCase( ByteBuffer request ) throws IncompleteHandshakeException { request.mark(); if( request.limit() > Draft.FLASH_POLICY_REQUEST.length ) { return HandshakeState.NOT_MATCHED; } else if( request.limit() < Draft.FLASH_POLICY_REQUEST.length ) { throw new IncompleteHandshakeEx...
86db43b5-b476-4e38-a7cb-4bb35d6801dc
6
public void printBoard( boolean[][] b, Tuple<Integer,Integer> currentLight ) { for ( int i = 0; i < 100; i++ ) { for ( int j = 0; j < 100; j++ ) { if ( currentLight != null && currentLight.y == i && currentLight.x == j ) { System.err.print( "*" ); } else { if (b[j][i]) { System.err.print( ...
fe984611-0856-4967-8a3c-28c66dc3f3f8
9
public boolean causesCheck(Location from, Location to) { Team team = from.getPiece().team; Piece p = moveCheck(from, to); for (Location[] locs : boardState.places) { for (Location l : locs) { if (l.piece != null) { if (l.piece.team != team && !deadPeople.contains(l.piece.team)) { for (Lo...
21733ac9-640a-4ab8-9f3d-ee32831e1796
1
@Override public void update(float dt) { timeElapsed += dt; if (timeElapsed > 0.3f) {//0.1 for desktop, dekstop less, like 0.05 frameNumber++; timeElapsed = 0; } }
1c210e72-6d85-44a8-9a1d-ed43057a189d
8
public FormValidation doCheckTemplateName(@QueryParameter String value) { if (value == null || value.trim().isEmpty()) { return FormValidation.error("Template is a required field."); } AbstractProject nearest = Project.findNearest(value); if(nearest == null || !value.equals(nearest.getName())) { re...
343fd5f3-e007-47fb-836c-654bfaa1ef79
3
public String getReplicaAddress() { if (slaveAddresses.isEmpty()) { return masterAddress; } else { // randomly give a slaveAdress back int size = slaveAddresses.size(); int item = new Random().nextInt(size); int i = 0; for (String obj : slaveAddresses) { if (i == item) { return obj; ...
c001ce5b-6028-47f2-82e6-9572fe875adb
8
public static void main(String[] args) { int i,j; // Initialize local variable i boolean equal = true; boolean unequal = false; Scanner input = new Scanner(System.in); System.out.println("Enter lenght of first array: "); // allow user input int SIZE = input.nextInt(); int [] array = new i...
7e4ec28d-385c-4831-9e2f-4792ae5fd045
9
private static Algebra constructAlgebra(ArrayList<AlgebraicParticle> l, Algebra old) { Boolean s /*sign*/ = null; Integer e /*exponent*/ = null; if(old instanceof AlgebraicParticle) { AlgebraicParticle a = (AlgebraicParticle) old; s = a.sign(); e = a.exponent(); } if(old instanceof Equation) r...
7208c087-74f2-4bdc-b416-fd2aa8e2910c
0
public int getI() { return id; }
5e39d733-3ee9-49b9-b70e-6828c4d17f1e
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Delta<T> other = (Delta) obj; if (original == null) { if (other.original ...
103ee7ad-527c-4981-9ee5-2233e8e8f3fe
6
public void moveDown() { if (lost) return; if (canMoveDown()) { shapeBoard.moveDown(); } else { // sets the shape in gameBoard, getting a new shape to interact // with Shape s = shapeBoard.getShape(); Point p = new Point(shapeBoard.getX(), shapeBoard.getY()); int removedRows = gameBoard.setSha...
a1a148da-158e-4e03-9abb-e99d3f59acd7
5
static void backwardsPass ( Fraction[][] matrix, coordinate[] lastLeading){ // Begin at the last pivot entry int i = leadCount-1; while ( i > 0 ){ // Don't do this for Row 1, as there is nothing above row 1. if ( lastLeading[i].x > 1 ){ for ( int k = lastLeading[i].x-1; k...
ad2c8942-4135-4255-9333-f0cc34d937e6
4
public ListNode removeNthFromEnd(ListNode head, int n) { if(n == 0) return head; int length = 0; ListNode node = head; while(node != null){ length++; node = node.next; } if(n == length) return head.next; int k = leng...
7393c31c-c0a7-49fe-a092-1cdd5560fa54
3
public boolean isInsertablePosition() { return ((row % 6 == 0 && col % 2 == 1) || (col % 6 == 0 && row % 2 == 1)); }
92dd2564-2dbd-4eed-a078-ea31c7619c4b
8
public String chompBalanced(char open, char close) { StringBuilder accum = new StringBuilder(); int depth = 0; char last = 0; do { if (isEmpty()) break; Character c = consume(); if (last == 0 || last != ESC) { if (c.equals(open)) ...
8dbecbb8-5235-4e9a-91a8-83af63161f3b
5
private boolean isSchrikkeljaar(int dag, int maand, int jaar) { if (maand == 2 && dag == 29 && (jaar % 400 == 0 || (jaar % 4 == 0 && jaar % 100 != 0))) { return true; } return false; }
a97d04eb-616e-4ea0-b829-b06cc50c0871
5
@Override public String toString() { if (this == TEXAS_HOLDEM) { return "Texas Hold'em"; } else if (this == OMAHA) { return "Omaha"; } else if (this == OMAHA_HILO) { return "Omaha Hi/Lo"; } else if (this == FOMAHA) { return "5-Card ...
0acc34e8-9bd0-4b3e-96af-3c2680c67058
5
public boolean contains(Location location) { int lX = (int) location.getX(); int lY = (int) location.getY(); int lZ = (int) location.getZ(); return lX >= this.x1 && lX <= this.x2 && lY >= this.y1 && lY <= this.y2 && lZ >= this.z1 && lZ <= this.z2; }
8b4f3912-7dbe-4437-8ffa-b0814f5c9ee4
9
public void register() { ReflectCommand command; if (this.commandLabel != null && !this.commandLabel.isEmpty()) { command = new ReflectCommand(this.commandLabel); } else { throw new CommandNotPreparedException("Command does not have a name."); } if (this....
e1982637-5b1d-446d-813b-26f0ea6a07b8
7
@Override public ResponseToProcess execute(ProcessedAPIRequest request, SDKServiceProvider serviceProvider) { Map<String, String> errParams = new HashMap<String, String>(); int responseCode = 0; String responseBody = ""; TokenType deviceTokenType; LoggerService logger = serviceProvider.getLoggerS...
9d9b8b4b-b7a7-4863-b773-aa6cf3a6316d
9
static void indexDocs(IndexWriter writer, File file) throws IOException { // do not try to index files that cannot be read if (file.canRead()) { if (file.isDirectory()) { String[] files = file.list(); // an IO error could occur if (files != null) { for (int i = 0; i < files.length; i++) { ...
663be76d-4f69-4549-b037-f020e9139184
9
@Override public Object getValueAt(int rowIndex, int columnIndex) { Summoner guy = guys.get(rowIndex); switch(columnIndex) { case 0: // rank return rowIndex + 1; case 1: // name return guy.getName(); ...
49ec8cec-cdab-4c43-810e-1fb4c670ddd1
7
private static void processSaveLine(String line) { if(line.charAt(0) == '#') { // may switch object type or be a comment if(line.startsWith("Contacts", 1)) { objectType = ObjectTypes.CONTACT_TYPE; } else if(line.startsWith("Meetings", 1)) { objectType = ObjectTypes.MEETING_TYPE; } } ...
9665db66-06b4-4362-b27f-964d72800786
2
public boolean equalsExpr(final Expr other) { if (other instanceof CatchExpr) { final CatchExpr c = (CatchExpr) other; if (catchType != null) { return catchType.equals(c.catchType); } else { return c.catchType == null; } } return false; }
720a4499-c051-41fb-8ae0-ff910b8e8d6e
6
public boolean replaceEmployee(int id, String name, Employee newEmployee) { if (name == null || newEmployee == null) throw new IllegalArgumentException(); TreeNode found = find(id, name); if(found == null){ return false; }else if(found.getEmployee().getTitle().equals(newEmployee.getTitle())){ try{ ...
24f58e89-2039-4878-90de-35b6726f9e84
4
@Override public boolean usedBy(Entity e) { if (times > 0) { if (e instanceof Player) { Player p = (Player) e; if (p.hp() < p.maxhp()) { p.heal(healpower); p.addStatus("You were fully by the healpad"); ti...
f647b51f-ba1e-4726-83be-18eb096f735b
9
private <T> List<T> merge(List<T> vetor1, List<T> vetor2, Comparator<T> comparator) { if (vetor1 == null || vetor1.isEmpty()) { return vetor2; } if (vetor2 == null || vetor2.isEmpty()) { return vetor1; } //Iterador dos vetores ...
8bebc03f-21ac-4d8a-bec1-b7f27501a268
8
@Test public void resolve() { int max=0; /*left-right*/ for(int i=0;i<N;i++){ for(int j=0;j<=N-n;j++){ int [] t=data[i]; max=Math.max(max, t[j]*t[j+1]*t[j+2]*t[j+3]); } } /*diagonally*/ for(int i=0;i<=N-n;i++){ for(int j=0;j<=N-n;j++){ max=Math.max(max, data[i][j]*data...
586c0339-19da-4c6e-8904-2ce22839a0af
0
public static void setCpf(String cpf) { OS.cpf = cpf; }
a5030695-f2c9-4a6e-9d64-7b96429e0bb6
2
public Key( Class<? extends AnnotatedElement> annotatedElementType, Class<? extends Annotation> annotationType ) { this.annotatedElementType = annotatedElementType; this.annotationType = annotationType; }
a068a168-99e1-45ba-9785-91bd40d5a981
7
public void sortArray() { this.arrayAccess = 0; this.comparisions = 0; int divisor = 10; int max = 1; boolean maxSet = false; while (max / (divisor / 10) > 0) { for (Integer temp : array) { if (!maxSet) { if (temp > max...
623a0f5f-da9f-4a3e-b51c-21ef2ac948fd
8
public ComparableNode getRightmostProperDescendant() throws MaltChainedException { NonTerminalNode node = this; ComparableNode candidate = null; while (node != null) { candidate = node.getRightChild(); if (candidate == null || candidate instanceof TokenNode) { break; } node = (NonTerminalNode)cand...
cfec0b7a-56eb-4b3c-906a-b9eb03793168
7
@Override protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { Boolean has_retweet = true; JSONObject json; try { json = (JSONObject) parser.parse(value.toString()); String time = Utility.convertDateFormat(json.get("created_at") .toString()...
a8e96168-4157-4bab-a375-9e1bc23f0f76
8
@Override protected void doReceiveMessage(Message msg) { // retrieve token option Option tokenOpt = msg.getFirstOption(OptionNumberRegistry.TOKEN); if (msg instanceof Response) { Response response = (Response) msg; Request request = null; if (tokenOpt != null) { // retrieve request...
86e6b6bb-4374-4338-b820-be4305f50cdb
0
public void setTxtPrenom(JTextField txtPrenom) { this.txtPrenom = txtPrenom; }
b7c59504-3fee-49c0-b72a-1e67afc9e404
5
private Report generateReport(String content){ String[] keyValuePairs = content.split(";"); Report report = new Report(); for (String keyValuePair : keyValuePairs) { String[] values = keyValuePair.split("="); String key = values[0]; String value = values[1]; if (key.equalsIgnoreCase(LOCATION_PR...
406e4172-8666-4f8b-a09b-6869b144b938
2
@Override public List<Person> meetCriteria(List<Person> persons) { List<Person> singlePersons = new ArrayList<>(); for (Person person : persons) { if (person.getMaritalStatus().equalsIgnoreCase("Single")) { singlePersons.add(person); } } return singlePersons; }
89f38597-5184-498c-88b8-250fbc372092
1
public static void main(String[] args) { Color myColor = Color.BULE; System.out.println(myColor); System.out.println("------------------"); for(Color c : Color.values()) { System.out.println(c); } }
664852ed-80e3-4d0d-b9a1-6e3c28422204
2
public void KillSession(Channel Channel) { Session mSession = GrabSession(Channel); try { mSession.GrabHabbo().RefreshMessenger(false); } catch (SQLException e) { } if (mSession.GrabActor().InRoom()) { mSession.LeaveRoom(); } SessionList.remove(Channel); //if (!mSession.Recie...
e002d456-9399-400c-8dd8-d9bfe7d24bb5
2
@Override public void doMapCollision() { checkCollisionMap(); if (mapCollision == Collision.NONE) { setFall(true); } if (mapCollision != Collision.NONE) { setFall(false); } }
a1aff39d-cc02-4aff-a1cc-eb2699812abf
9
static int getSizeRank(Class<?> aType) { if (aType == Double.TYPE) { return 1; } else if (aType == Float.TYPE) { return 2; } else if (aType == Long.TYPE) { return 3; } else if (aType == Integer.TYPE) { return 4; ...
0b6ee115-c5f6-4fbe-a41f-4f3f1873357a
9
private void createButtonMouseClicked(java.awt.event.MouseEvent evt) { // -- {{ What happens when the "Create Button" is pressed? }} -- String preName, preAddress, preID, prePhone, prePassword; String name, address, password; int id, phone; preName = cusName.getText(); preAddress = cu...
de420dfb-4c74-446d-8d40-c8031ed815f8
4
@Override public String print() { StringBuilder printed = new StringBuilder(); Line selectedLine = this.getSelectedLine(); // print intro TextIntro intro = this.document.getTextIntro(); for (int i = 0; i < intro.getLineNb(); i++) { if (intro.getLine(i).equals(selectedLine)) { printed.append(new String...
dc8ba14e-97ea-43ba-8b9b-572939d2d3f7
6
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(!(sender instanceof Player)) { sender.sendMessage(plugin.prefix + "You have to be a player to use this command"); return true; } Player player = (Player) sender; if(sender.hasPermission("N...
ec95ff0c-8352-44d7-b41a-2fdc0f01ac33
1
public void testWithFieldAdded3() { Partial test = createHourMinPartial(); try { test.withFieldAdded(null, 6); fail(); } catch (IllegalArgumentException ex) {} check(test, 10, 20); }
44935efc-8ca3-4091-982f-81c30089efad
3
public int getHPRegenerationBonus(Point p) { int bonus = 0; Placeable placeable = null; try { for (String key : placeables.keySet()) { placeable = (Placeable) placeables.get(key); if (placeable != null) { bonus += placeable.getHPR...
8a375435-0cc8-44ce-aaad-79b824c1c174
8
public Action getUserInput(final Set<Action> allowedActions) { System.out.println("Here"); selectedAction = null; while (selectedAction == null) { // Show the buttons for the allowed actions. SwingUtilities.invokeLater(new Runnable() { @Override ...
0897ea23-02a0-4884-b321-8206336ae9af
6
@Override public boolean take(int amnt, final boolean note, final Map<Integer, Integer> items, final Map<Integer, Integer> used) { if (note && canNote()) { for (int id : sortedIds) { ItemInformation info = this.items.get(id); int amntToUse = Math.min(amnt, get(items, info.getNotedId()) - get(used, info...
eb1d9a93-8e42-48c4-af06-76f68b10c5b6
4
int getB(String s1, String s2) { int b = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (i == j) { // this situation has handled by getA. continue; } if (s1.charAt(i) == s2.charAt(j)) { // if their digit m...
dc91398b-5413-4fd0-bee6-f97d9b6838f6
6
public static void reorderList(ListNode head) { int len = 0; ListNode node = head; if (null == node) return; while (null != node) { len = len + 1; node = node.next; } node = head; int i = 0; while (i < len / 2) { node = node.next; i = i + 1; } ListNode tmp = node.next; node.next = ...
aebccf6e-25de-4c07-85e4-704fa3a0ad76
3
@Override public List<Consulta> listByNome(String nome) { Connection con = null; PreparedStatement pstm = null; ResultSet rs = null; List<Consulta> consultas = new ArrayList<>(); try { con = ConnectionFactory.getConnection(); pstm = con.prepareStateme...
9a9cbe12-6439-4256-9578-448dcaf17077
2
@Override public boolean verifier() throws Exception { super.verifier(); if(!expression.verifier()) GestionnaireSemantique.getInstance().add(new SemantiqueException("La declaration de la variable "+((Identificateur) expression).getNom()+" a la ligne "+/*line+*/" est manquante")); ...
83585d05-f675-49a9-a851-a4b00cf1f31a
3
public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { if (str != null) { for (int index = 0; index < str.length(); index++) { char c = str.charAt(index); if (!Character.isDigit(c)) { return; } } } super.insertString(offs, str, a); }
38d94d48-f3be-4d7d-a910-f7e09e8e8987
4
private boolean jj_3R_71() { if (jj_scan_token(POINT)) return true; if (jj_3R_72()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3_55()) { jj_scanpos = xsp; break; } } return false; }
8ce3bed4-ef1f-4139-b9e4-565c2ed77af0
8
private void displayDirections() { //HashMap<String, Double> directionsMap = wGraph.getDirections(toNode); List<Edge> routeEdges = wGraph.getDirections(toNode); Collections.reverse(routeEdges); //needs reversing because the roads are apprently loaded in opposite direction (relative to to/from) directions.setT...
d6ef181b-fc39-4fe2-b5ec-a1661fd127a5
4
public PlayingCard drawTopCard() { if(cardsInDeck.length==0) { shuffle(); } if(cardsInDeck.length==0) { System.err.println("All cards are in play"); System.exit(0); } PlayingCard Return=cardsInDeck[cardsInDeck.length-1]; PlayingCard[] oldDeck=cardsInDeck; cardsInDeck=new PlayingCard[cardsInD...
a7adeca3-80ca-4be2-a27b-276c1c27141c
7
public boolean isCurrentGuessPossible() { String curGuess = getCurrentGuess(); String curWordPattern = ""; for (int i = 0; i < curGuess.length(); i++) { char c = curGuess.charAt(i); if ((c >= 'A' && c <= 'Z') || c == '_' || c == '\'') { curWordPattern += ...
78f71a1d-8a95-4148-ad3e-5b79941d8c4a
4
int getDefaultStyle () { if (ltrButton != null && ltrButton.getSelection()) { return SWT.LEFT_TO_RIGHT; } if (rtlButton != null && rtlButton.getSelection()) { return SWT.RIGHT_TO_LEFT; } return SWT.NONE; }
4659ebaa-bf82-4f60-9398-2d58d0551c2f
1
public Widget getWidget(int id) { synchronized (this) { if (widgets.containsKey(id)) { return widgets.get(id); } } return null; }
90dd7216-6fd5-438a-89f3-d02614d283e0
6
public double EV() { double ev = 0; double ev_fold; double ev_check; double ev_raise; switch(nodeType) { case SHOWDOWN : double winPossibility = gameInfo.opponentModel.winPossibility(actionHistory, knownCards.evaluate()); ev = winPossibility * opponentBetAmount - ((1 - winPossi...
39f0a237-5206-4482-be04-88c3b189e7cc
0
public String getDatetime() { return this.datetime; }
3d9114fa-3c84-4a74-b1e6-394ad8e02738
3
@Override public Vector add(Vector vector) throws IllegalArgumentException { if (this.getFieldsNumber() != vector.getFieldsNumber()) { throw new IllegalArgumentException(); } for (int i = 0; i < getFieldsNumber(); i++) { try { setElementAt(i + 1, this.getElementAt(i + 1) + vector.getElementAt(i + 1)); ...
c22d21e5-87d4-4e1d-9416-0243cabc854e
8
public static void center(Unit unit) { int lX = unit.getX() - 4; int hX = unit.getX() + 4; int lY = unit.getY() - 4; int hY = unit.getY() + 4; int tX = xOff, tY = yOff; if(lX < xOff) { tX = lX < 0 ? 0 : lX; } if(hX > field...
adc4c3b0-afbf-4a29-938e-f691f45a3a9f
0
public int getSize() { return size; }
4315126c-f7fa-46ca-aa77-dc1f05ac0ef9
5
public void getAttributes(Expression e, HashMap<String, ArrayList<String>> attrsTable) { String type=e.getType(); if(whichUnary(type)!=null) { getAttributes(e.getSubexpression(),attrsTable); } else if(whichBinary(type)!=null) { getAttributes(e.getSubexpression("left"),attrsTable); getAttri...
a2aef021-2190-4a36-a5eb-74ca2b3fcfb9
8
private boolean depthFirstSearch(int vertex, int from) { was[vertex] = from == 2 ? 1 : 2; if (robots[vertex]) if (was[vertex] == 2) evenRobots++; else unevenRobots++; for (int i = 0; i < adjacentVertices[vertex].size(); i++) { ...
c1941480-1bcf-48f2-ac8b-fc379afa37f9
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...
ab67e1ef-8075-4344-aa0f-3dc73bae3091
7
public void write(char[] cbuf, int off, int len) throws IOException { int nextOff; startProcess(); nextOff = off; for (int i = off; i < off + len; i += 1) { if (cbuf[i] == '\n') { _displayIn.write(cbuf, nextOff, i - nextOff + 1); _displayIn.flu...
5d067a3b-97db-4ad0-b13d-c92c7d6c3548
7
public InvokeOperator(MethodAnalyzer methodAnalyzer, int methodFlag, Reference reference) { super(Type.tUnknown, 0); this.ref = reference; this.methodType = Type.tMethod(reference.getType()); this.methodName = reference.getName(); this.classType = Type.tType(reference.getClazz()); this.hints = null; Ma...
ce46e937-9517-4e1c-8a9b-da689905ffcc
3
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { if(e.getMessage() instanceof WelcomeMessage) { updateListener.welcomeMessageReceived((WelcomeMessage) e.getMessage()); } else if(e.getMessage() instanceof UserSyncEvent) { Users.syncUsers((UserSyncEvent) e....
9641bcbe-4b0e-440d-b5f5-41ac85e70daa
3
public void initialize(SLConfig cfg) { currentCfg = cfg; if (getWidth() != 0 || getHeight() != 0) { cfg.placeAndRoute(); removeAll(); for (Component c : cfg.getCmps()) { SLConfig.Tile t = cfg.getTile(c); c.setBounds(t.x, t.y, t.w, t.h); c.validate(); add(c, new Integer(1)); } } }