method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
31715482-e113-4a4d-a96a-636824802ce3
5
public XmlWriter endEntity() throws IOException { if (this.stack.empty()) { throw new InvalidObjectException("Called endEntity too many times. "); } String name = this.stack.pop(); if (name != null) { if (this.empty) { writeAttributes(); this.writer.write("/>\n"); } else { if (!this.justWroteText) { for (int tabIndex = 0; tabIndex < stack.size() + indentingOffset; tabIndex++) this.writer.write(INDENT_STRING); } this.writer.write("</"); this.writer.write(name); this.writer.write(">\n"); } this.empty = false; this.closed = true; this.justWroteText = false; } return this; }
4113e661-4fea-4aab-8b7d-03a7ba61f757
2
public DaoGenerator( Table table ) { super( table ); this.table = table; daoName = table.getDomName() + "Dao"; filePath = "src/main/java/" + packageToPath() + "/dao/" + daoName + ".java"; for ( Column column : table.getColumns() ) { if ( column.isKey() ) { keyColumns.add(column); } } }
4da52790-1b31-47a0-b8ba-79c297ba2108
9
@Override public void run(){ try{ PrintWriter out=new PrintWriter( socket.getOutputStream(),true); BufferedReader in=new BufferedReader(new InputStreamReader(socket.getInputStream())); synchronized(this){ int count; FileWriter fw=new FileWriter("G:\\Dropbox\\temp.txt"); String inputLine; while((inputLine=in.readLine())!=null){ fw.write(inputLine); fw.flush(); break; } out.close(); in.close(); fw.close(); FileReader fr=new FileReader("G:\\Dropbox\\temp.txt"); char[] ch=new char[100]; fr.read(ch); inputLine=new String(ch); count=0; String folder=null, password=null; StringTokenizer st=new StringTokenizer(inputLine); while(st.hasMoreTokens()){ if(count==0) folder=st.nextToken(); else if(count==1) password=st.nextToken(); else if(count==2) break; count++; } fr.close(); File file=new File("G:\\"+folder); System.out.println(file.mkdir()); if(file.exists()){ File newFile=new File("G:\\"+folder+"\\data.txt"); if(!newFile.exists()){ if(newFile.createNewFile()){ fw=new FileWriter(newFile); fw.write(password); fw.flush(); fw.close(); } } } } }catch(IOException e){ System.out.println(e.getMessage()); System.exit(1); } }
c2aee310-58fb-42f0-b855-c24e665b4be9
5
@SuppressWarnings("unchecked") public static void main(String[] args) { int len = 10; List<Holder<Integer>> lst = new ArrayList<Holder<Integer>>(len); System.out.println("List size: " + lst.size()); Random rand = new Random(); int num; System.out.print("Adding:"); for (int i = 0; i < len; ++i) { num = rand.nextInt(5) + 1; System.out.print(" " + num); lst.add(new Holder<Integer>(num)); } System.out.println(); System.out.println("The list: " + lst); // c java.util.Collections.sort(lst); System.out.println("The list: " + lst); // d java.util.Collections.sort(lst, Collections.reverseOrder()); System.out.println("The list: " + lst); // e // Holder<Integer>[] arr = (Holder<Integer>[]) new Object[len]; Holder<?>[] arr = new Holder<?>[len]; for (int i = 0; i < len; ++i) { arr[i] = new Holder<Integer>(rand.nextInt(100)); } // List<Holder<Integer>> arrList = Arrays.asList(arr); List<Holder<?>> arrList = Arrays.asList(arr); System.out.println(arrList); }
ce712a99-e72c-42b9-96e5-23fee7a6def7
8
public int send(Map<String, String> record) { String[] emails = record.get("email").split("[|]"); String[] telnos = record.get("telno").split("[|]"); String[] pernrs = record.get("pernr").split("[|]"); // 获得并设置接收人 Map<String, String> recieversMap = service.getRecievers(emails, telnos, pernrs); telMap = new HashMap<String, String>(); for (String tel : telnos) { telMap.put(tel, tel); } for (String key : recieversMap.keySet()) { telMap.put(recieversMap.get(key), recieversMap.get(key)); } // 拼装手机群发号码 allTelno = new StringBuffer(); for (String tel : telMap.keySet()) { allTelno.append(tel); allTelno.append(UnsConsts.MARK_COMMA); } allTelno.deleteCharAt(allTelno.length() - 1); Map<String, String> smsSendInfo = service.getSmsSendInfo(record); String sn = smsSendInfo.get("sn"); String orgaddr = smsSendInfo.get("orgaddr"); String content = smsSendInfo.get("content"); String telno = allTelno.toString(); if ("".equals(telno) || telno == null) { logger.log(Level.INFO, "Telephone can not be empty, message is rejected!"); return 0; } // switch controller if ("N".equals(service.getSwitchOnFlg(record.get("sys")))) { logger.log(Level.INFO, ">>> Switch OFF!!!"); return 0; } try { sendMessageOne(sn, orgaddr, telno, content); } catch (MalformedURLException e) { return 0; } catch (IOException e) { return 0; } return 1; }
c982415e-4711-4c96-8443-3c385fc1f00b
5
public boolean check_Authors(){ boolean nameValid = false; int counter = 0; for (int i =0; i<authors.size(); i++){ if (!authors.get(i).getName().isEmpty() && authors.get(i).getName() != null){ counter ++; } } if (authors.size()==0){ nameValid = false; } else if (counter==authors.size()){ nameValid = true; } else { nameValid = false; } return nameValid; }
f319cf54-92aa-4407-b729-34f451afb4c3
3
private void leftRotate(RBNode x) { RBNode y = x.getRightChild(); x.setRightChild(y.getLeftChild()); if (y.hasLeftChild()) { y.getLeftChild().setParent(x); } y.setParent(x.getParent()); if (!x.hasParent()) { setRoot(y); } else if (x == x.getParent().getLeftChild()) { x.getParent().setLeftChild(y); } else { x.getParent().setRightChild(y); } y.setLeftChild(x); x.setParent(y); }
d5108675-6daa-4dd9-9718-60ce36b75bd5
9
static void RenderSprite(osd_bitmap bitmap, int spr_number) { int SprX, SprY, Col, Row, Height, src; int bank; UBytePtr SprReg = new UBytePtr();//unsigned char *SprReg; UBytePtr SprPalette = new UBytePtr();//unsigned short *SprPalette; short skip; /* bytes to skip before drawing each row (can be negative) */ SprReg.set(spriteram, 0x10 * spr_number);//SprReg = spriteram + 0x10 * spr_number; src = SprReg.read(SPR_GFXOFS_LO) + (SprReg.read(SPR_GFXOFS_HI) << 8); bank = 0x8000 * (((SprReg.read(SPR_X_HI) & 0x80) >> 7) + ((SprReg.read(SPR_X_HI) & 0x40) >> 5)); bank &= (memory_region_length(REGION_GFX2) - 1); /* limit to the range of available ROMs */ skip = (short) (SprReg.read(SPR_SKIP_LO) + (SprReg.read(SPR_SKIP_HI) << 8)); Height = SprReg.read(SPR_Y_BOTTOM) - SprReg.read(SPR_Y_TOP); SprPalette.set(Machine.remapped_colortable, 0x10 * spr_number);//SprPalette = Machine.remapped_colortable + 0x10 * spr_number; SprX = SprReg.read(SPR_X_LO) + ((SprReg.read(SPR_X_HI) & 0x01) << 8); SprX /= 2; /* the hardware has sub-pixel placement, it seems */ if (Machine.gamedrv == driver_wbml || Machine.gamedrv.clone_of == driver_wbml) { SprX += 7; } SprY = SprReg.read(SPR_Y_TOP) + 1; for (Row = 0; Row < Height; Row++) { src += skip; Col = 0; while (Col < 256) /* this is only a safety check, */ /* drawing is stopped by color == 15 */ { int color1, color2; if ((src & 0x8000) != 0) /* flip x */ { int offs, data; offs = ((src - Col / 2) & 0x7fff) + bank; /* memory region #2 contains the packed sprite data */ data = memory_region(REGION_GFX2).read(offs); color1 = data & 0x0f; color2 = data >> 4; } else { int offs, data; offs = ((src + Col / 2) & 0x7fff) + bank; /* memory region #2 contains the packed sprite data */ data = memory_region(REGION_GFX2).read(offs); color1 = data >> 4; color2 = data & 0x0f; } if (color1 == 15) { break; } if (color1 != 0) { Pixel(bitmap, SprX + Col, SprY + Row, spr_number, SprPalette.read(color1)); } Col++; if (color2 == 15) { break; } if (color2 != 0) { Pixel(bitmap, SprX + Col, SprY + Row, spr_number, SprPalette.read(color2)); } Col++; } } }
2b71108a-dfee-4e59-a657-d2e6b519e86f
7
private int handleStringConstant(int pos, String operand) { char c = operand.charAt(0); int num = 0; if (c == '"') { // What is the stuffing method here? for (int i = 1, n = operand.length(); i < n; i++) { c = operand.charAt(i); if (c != '"') { memory[pos] = c; pos++; num++; } } } else if (c == '\'') { boolean stuffed = false; for (int i = 1, n = operand.length(); i < n; i++) { c = operand.charAt(i); if (c != '\'' || stuffed) { memory[pos] = c; pos++; num++; stuffed = false; } else { stuffed = true; } } } return num; }
a1040bc4-f558-4b37-bd72-78b766ca8fb8
7
public boolean parse(String text) { int n = 0; lex = new CompoLexical(text); LinkedList<LinkedList<Vector<Utils.Identifier>> > Table = new LinkedList<LinkedList<Vector<Utils.Identifier>>>(); LinkedList<Vector<Utils.Identifier>> row = new LinkedList<Vector<Utils.Identifier>>(); // while(lex.nextToken() != null) { while(!lex.End()) { lex.nextToken(); // GET Gramer for input and put it in hash Vector<Identifier> vect = rules.getMultiKey(new Identifier(lex.currentToken())); row.add(vect); n++; } // Add Linked list to Table Table.add((LinkedList<Vector<Identifier>>)row.clone()); Vector<Utils.Identifier> V = new Vector<Utils.Identifier>(); for (int j=1; j<n; j++) { row.clear(); for (int i=0; i<n-j; i++) { V.clear(); for (int k=0; k<j; k++) { // GET String Gramer and put it in Set LinkedList<Vector<Utils.Identifier>> FirstList = Table.get(k); LinkedList<Vector<Utils.Identifier>> SecondList = Table.get(j-k-1); Vector<Utils.Identifier> h1 = FirstList.get(i); Vector<Utils.Identifier> h2 = SecondList.get(i+k+1); for (Utils.Identifier Identifier :getIdentifiers(h1, h2)) { if (Identifier != null) if (!V.contains(Identifier)) V.add(Identifier); } } row.add((Vector<Identifier>) V.clone()); } Table.add((LinkedList<Vector<Identifier>>)row.clone()); } return (Table.getLast().getLast().contains(rules.getStart())); }
54bec42b-4b5a-46f6-9f8f-db642d67a0e6
9
static public String purefilename (String filename) { char a[]=filename.toCharArray(); int i=a.length-1; char fs=File.separatorChar; while (i>=0) { if (a[i]==fs || a[i]=='/' || i==0) { if (i==0) i=-1; if (i<a.length-1) { int j=a.length-1; while (j>i && a[j]!='.') j--; if (j>i+1) return new String(a,i+1,j-i-1); else return ""; } else return ""; } i--; } return filename; }
8f8ec01f-5ae6-4346-833f-31d2cbe6db73
8
private void readValues(Stream stream) { do { int i = stream.readUnsignedByte(); boolean dummy; if(i == 0) return; else if(i == 1) { anInt390 = stream.read3Bytes(); method262(anInt390); } else if(i == 2) anInt391 = stream.readUnsignedByte(); else if(i == 3) dummy = true; else if(i == 5) aBoolean393 = false; else if(i == 6) stream.readString(); else if(i == 7) { int j = anInt394; int k = anInt395; int l = anInt396; int i1 = anInt397; int j1 = stream.read3Bytes(); method262(j1); anInt394 = j; anInt395 = k; anInt396 = l; anInt397 = i1; anInt398 = i1; } else { System.out.println("Error unrecognised config code: " + i); } } while(true); }
033741d7-4e3f-475b-a781-c764614263d2
6
public List<Entity> getNearestEntities(final Entity ent, double radius) { List<Entity> nearestEntities = new ArrayList<Entity>(); List<Entity> entList = core.getEntityList(); for(Entity entN : entList) { if(!entN.equals(ent) && entN.getLocation().distanceTo(ent.getLocation())<radius) { nearestEntities.add(entN); } else if(!entN.equals(ent) && radius==-1) nearestEntities.add(entN); } Collections.sort(nearestEntities, new Comparator<Entity>() { public int compare(Entity o1, Entity o2) { if(((o1.getLocation().distanceTo(ent.getLocation()) - o1.getSize()) - (o2.getLocation().distanceTo(ent.getLocation()) - o2.getSize()))>0) return 1; return -1; } }); // for(Entity ent2 : nearestEntities) { // System.out.println(ent2.getLocation().distanceTo(ent.getLocation())); // } return nearestEntities; }
fbc0ba72-c3b6-4987-aa65-afb5cb485911
1
@Override public void draw(Graphics g) { // If alive, draw the fighter jet if (Alive) { g.drawImage(img1, pos_x, pos_y, width, height, null); } // If dead, draw blood else { g.drawImage(img2, pos_x, pos_y, width, height, null); } }
d3571fa4-1a16-467b-8365-81dbdedf79b6
1
public double getDefaultVolume(String soundName) { Sound sound = sounds.get(soundName); if (sound != null) { return sound.getDefaultVolume(); } return -1.0; }
c3aebd43-40d5-450f-8e72-d2871ad689a8
3
double findTSval(String[] s){ double TSval=0; boolean find=false; int i=0; while(find ==false && i<s.length){ String tmp = s[i]; if(tmp.contains("TSval")){ find=true; TSval=Double.parseDouble(tmp.substring(6)); } i++; } return TSval; }
fe55ebcc-73c3-4747-b8b4-9d2ce332c553
5
public ListNode mergeTwoLists(ListNode l1, ListNode l2) { ListNode head = new ListNode(-1); ListNode p = head; while (l1 != null && l2 != null) { if (l1.val > l2.val) { p.next = l2; l2 = l2.next; } else { p.next = l1; l1 = l1.next; } p = p.next; } if (l1 != null) { p.next = l1; } if (l2 != null) { p.next = l2; } return head.next; }
1b8081d4-c2b4-41b6-b1c6-886bd79a9cb1
5
private boolean shouldAddInstance(RelationInstance instance) { if(filterRelations == false){ return true; } if(instance.getArguments().size() >= 1){ for(Argument arg : instance.getArguments()){ if(arg.getArgumentType().equals("SUBJ") || arg.getArgumentType().equals("DOBJ")){ return true; } } } return false; }
89eff8d4-3dcb-49b8-847b-a231af4e0706
4
private boolean testValidProtocol(Element el, Attribute attr, Set<Protocol> protocols) { // try to resolve relative urls to abs, and optionally update the attribute so output html has abs. // rels without a baseuri get removed String value = el.absUrl(attr.getKey()); if (value.length() == 0) value = attr.getValue(); // if it could not be made abs, run as-is to allow custom unknown protocols if (!preserveRelativeLinks) attr.setValue(value); for (Protocol protocol : protocols) { String prot = protocol.toString() + ":"; if (value.toLowerCase().startsWith(prot)) { return true; } } return false; }
98f250f9-5e11-4199-ae7a-fd5aeff8fd08
0
@SuppressWarnings("unchecked") public List<Osoba> getWszystkieOsoby() { return em.createNamedQuery("osoba.all").getResultList(); }
cb630724-742e-4423-b383-9dcd320152a1
9
public void mouseMoved(MouseEvent Event) { boolean needRepaint = false; if (null != this.vertexToDelete) { this.deleteVertex(this.vertexToDelete); this.selectedVertex = null; } if (null != this.movingVertex) { this.selectedVertex = null; this.position.get(this.movingVertex).setLocation(Event.getPoint()); needRepaint = true; } else { if (null != this.selectedEdge) { if (!this.underEdge(Event.getPoint(), this.selectedEdge)) { this.selectedEdge = null; needRepaint = true; } } if (null != this.selectedVertex) { if (!this.underVertex(Event.getPoint(), this.selectedVertex)) { this.selectedVertex = null; needRepaint = true; } } Vertex[] Edge = this.underEdge(Event.getPoint()); if (null != Edge) { this.selectedEdge = Edge; needRepaint = true; } else { Vertex Vertex = this.underVertex(Event.getPoint()); if (null != Vertex) { this.selectedVertex = Vertex; needRepaint = true; } } } if (needRepaint) { repaint(); } }
21364389-74f2-423d-a4e5-a3654ed9e55b
3
public void freePackets(){ activePacket = null; if(packetList != null) { Iterator<Packet> packetIter = packetList.iterator(); while(packetIter.hasNext()){ Packet.free(packetIter.next()); } packetList.clear(); } else { if(singlePacket != null) { Packet.free(singlePacket); singlePacket = null; } } }
c4c144e7-1865-4279-be1d-368c6b082a94
7
public void newGame() { InitializeRandomProblem(40); lastAction = new int[6]; lastAction[ID] = -1; lastAction[TYPE] = NO_TYPE; // NO CASE. Voting Finished. lastAction[ACTION] = NEW_GAME; lastAction[X] = -1; lastAction[Y] = -1; lastAction[VALUE] = -1; lastActionsList.add(0, lastAction); Print("Server: Initialized a New Game."); serverMode = ServerMode.graphic; instantiator = new int[sudokuSize][sudokuSize]; for (int i = 0; i < sudokuSize; i++) { for (int j = 0; j < sudokuSize; j++) { instantiator[i][j] = -1; } } for (int i = 0; i<19; i++) { memberList.add(new ArrayList<Integer>()); } committerByRowsList = new int[memberList.get(agentCommitterByRows).size()]; for(int i=0; i<memberList.get(agentCommitterByRows).size(); i++) { committerByRowsList[i] = 0; } committerByColumnsList = new int[memberList.get(agentCommitterByColumns).size()]; for(int i=0; i<memberList.get(agentCommitterByColumns).size(); i++) { committerByColumnsList[i] = 0; } committerBySquaresList = new int[memberList.get(agentCommitterBySquares).size()]; for(int i=0; i<memberList.get(agentCommitterBySquares).size(); i++) { committerBySquaresList[i] = 0; } userCommitterList = new int[memberList.get(userCommitter).size()]; for(int i=0; i<memberList.get(userCommitter).size(); i++) { userCommitterList[i] = 0; } valuesVoting = 0; valuesBugReported = 0; valuesContributed = 0; valuesCommitted = 0; valuesNotCommited = 0; valuesRejected = 0; valuesAccepted = 0; }
b3fa80fb-9a60-4ee8-a62b-17ab6f4a43a7
5
public static void main(String[] args) throws IOException { FileReaderStrategy frs = new ReadFromTextFile(6); FormatStrategy format = new PipeSeparatorFormat(frs); // Shows formatted list for (String s : format.getFormattedList()) { System.out.println(s); } System.out.println(""); // Returns as Objects for (Object o : format.getAsObjectList()) { System.out.println(o.toString()); } System.out.println(""); // Strict removes duplicates for (Object o : format.getStrictObjectList()) { System.out.println(o.toString()); } System.out.println(""); List<Contact> mailingList = new ArrayList<>(); for (String s : format.getFormattedList()) { String[] UnitInRecordArray = s.split("\\"+format.getCharacterUsed()); Contact c = new Contact(UnitInRecordArray[0], UnitInRecordArray[1], UnitInRecordArray[2], UnitInRecordArray[3], UnitInRecordArray[4], UnitInRecordArray[5]); mailingList.add(c); } for (Contact c : mailingList) { System.out.println(c.toString()); } // FileWriterStrategy fws = new WriteToTextFile("newText.txt", false); // fws.writeToFileStrict(format); // // FileWriterStrategy fws1 = new WriteToTextFile(); // fws1.writeToFile(format); // // FileWriterStrategy fws2 = new WriteToTextFile("default2.txt"); // fws2.writeToFile(format); // FileWriterStrategy fws3 = new WriteToTextFile(true); // fws3.writeToFile(format); // // FileWriterStrategy fws4 = new WriteToTextFile("C:" + File.separatorChar + "Users" // + File.separatorChar + "Kyle" + File.separatorChar + "Desktop" // + File.separatorChar + "default3.txt"); // fws4.writeToFileStrict(format); // // } }
7e947bda-57cf-4e61-b673-459030711224
5
@Override public boolean onCommand(CommandSender sender, Command command, String lable, String[] args) { Player player = null; Player toPlayer = null; if (!(sender instanceof Player)) { master.getLogManager().info( "You cannot do this from the server console."); return true; } player = (Player) sender; String invitation = ""; for (String inv : master.getInviteCmdExecutor().getInvitations()) { if (inv.substring(0, inv.indexOf(" ")).equals(player.getName())) { toPlayer = master.getServer().getPlayer( inv.substring(inv.indexOf(" "))); if (toPlayer == null) { master.getLogManager().info( "Not found player " + inv.substring(inv.indexOf(" "))); return false; } invitation = inv; player.teleport(toPlayer.getLocation()); } } if (!invitation.isEmpty()) master.getInviteCmdExecutor().getInvitations().remove(invitation); return false; }
de09c1ee-f2c5-4d31-a458-56babb903bd2
1
public void stopPlayer() { status = STOP; if (player != null) { player.close(); } player = null; }
5162bd94-39ba-4af6-93c0-0f4220e413f2
0
@Override public void mousePressed(MouseEvent e) { isMouseDown = true; mouseY = e.getY(); }
dc53aaa8-a600-4609-ac61-1e8b60f8c425
2
public boolean heeftMonteur(String kt){ boolean b = false; for (Gebruiker m: alleMonteurs){ if (m.getNaam().equals(kt)){ b = true; } } return b; }
0a746085-d925-4004-85be-03b881999e12
2
public void jsFunction_setSpeed(int speed) { deprecated(); if(speed < 0) speed = 0; else if(speed > 3) speed = 3; JSBotUtils.setSpeed(speed); }
fbb89a22-f144-4b97-bc40-369572b6c5e9
9
private JScrollPane getScrollBar(Element e) throws IOException { Element scrollPaneElt = e.getChild("ScrollPane"); if( scrollPaneElt != null ) { int horizontal = JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED; int vertical = JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED; String s = scrollPaneElt.getAttributeValue("horizontal"); if( s != null ) { if( s.equals("always") ) horizontal = JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS; else if( s.equals("never") ) horizontal = JScrollPane.HORIZONTAL_SCROLLBAR_NEVER; else if( s.equals("asNeeded") ) horizontal = JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED; else throw new IOException( "unknown horizontal attribute value: " + s ); } s = scrollPaneElt.getAttributeValue("vertical"); if( s != null ) { if( s.equals("always") ) vertical = JScrollPane.VERTICAL_SCROLLBAR_ALWAYS; else if( s.equals("never") ) vertical = JScrollPane.VERTICAL_SCROLLBAR_NEVER; else if( s.equals("asNeeded") ) vertical = JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED; else throw new IOException( "unknown vertical attribute value: " + s ); } JScrollPane jsp = new JScrollPane(vertical,horizontal); jsp.setBorder(null); return jsp; } else { return null; } }
0125e992-39e9-4a3d-a903-120d9001344d
6
public long discreteLogarithmFromExpectedRange(BigInteger value, long expectedResult, long searchRadius) { if(expectedResult - searchRadius < 0 || searchRadius == 0) { throw new IllegalArgumentException(); } long start = expectedResult - searchRadius; long end = expectedResult + searchRadius; boolean logFound = false; long power = start; BigInteger current = raiseGenerator(power); while(!logFound && power <= end) { if(current.equals(value)) { logFound = true; } else { power++; current = multiplyMod(current); } } if(logFound) { return power; } else { return discreteLogarithm(value); } }
f67a24c5-7b97-4d9b-b4ba-6e81024c2a0d
1
@Override public int attack(double agility, double luck) { if(random.nextInt(100) < luck) { System.out.println("I just did a soul strike!"); return random.nextInt((int) agility) * 2; } return 0; }
eed30a6d-3fb4-431a-936a-343caa3321a8
8
public static void main(String[] args) { int count = 0; char[] faces = { '2', '3', '4', '5', '6', '7', '8', '9', '\10', 'J', 'Q', 'K', 'A' }; char[] suits = { '♣', '♦', '♥', '♠' }; for (int i = 0; i < faces.length; i++) { for (int j = 0; j < faces.length; j++) { for (int k = 0; k < suits.length; k++) { for (int m = k + 1; m < suits.length; m++) { for (int l = m + 1; l < suits.length; l++) { for (int n = 0; n < suits.length; n++) { for (int o = n + 1; o < suits.length; o++) { if (i != j) { System.out.printf(faces[i] + "" + suits[k] + " " + faces[i] + "" + suits[m] + " " + faces[i]+ "" + suits[l] + " " + faces[j] + ""+ suits[n] + " " + faces[j] + "" + suits[o] + " "); System.out.println(); count++; } } } } } } } } System.out.println(); System.out.println(count + " full houses"); }
5e687f3e-b7f8-4133-9f48-add61d11add7
1
public ShutdownPreview(SkinPropertiesVO skin, JPanel parent) { if (skin == null) { IllegalArgumentException iae = new IllegalArgumentException("Wrong parameter!"); throw iae; } this.skin = skin; this.parent = parent; }
f3afd743-b520-4d74-a226-8046b3b5f075
5
Object[] parameterForType(String typeName, String value, Widget widget) { if (value.equals("")) return new Object[] {new TableItem[0]}; // bug in Table? if (typeName.equals("org.eclipse.swt.widgets.TableItem")) { TableItem item = findItem(value, ((Table) widget).getItems()); if (item != null) return new Object[] {item}; } if (typeName.equals("[Lorg.eclipse.swt.widgets.TableItem;")) { String[] values = split(value, ','); TableItem[] items = new TableItem[values.length]; for (int i = 0; i < values.length; i++) { items[i] = findItem(values[i], ((Table) widget).getItems()); } return new Object[] {items}; } return super.parameterForType(typeName, value, widget); }
28fd3b93-9265-48dd-aeda-dc703f125466
2
public void visitTypeInsn(final int opcode, final String type) { mv.visitTypeInsn(opcode, type); // ANEWARRAY, CHECKCAST or INSTANCEOF don't change stack if (constructor && opcode == NEW) { pushValue(OTHER); } }
587282ca-7511-464d-8f3d-983d6cee14ad
2
public List<Transition> getTransitionsByStateAndSymbol(String state, String symbol) throws Exception{ List<Transition> result = new ArrayList<Transition>(); for(Transition tran: transitions){ if(tran.matchByStateAndSymbol(state, symbol, getSymbolByAlter(tran.getSymbolRef()))) result.add(tran); } return result; }
d0f8031f-fc11-450b-b643-f55f9c039d9a
9
static boolean processWith(StringBuffer sb) { int i = find(sb, "with"); if (i < 0) { return false; } int j = find(sb, "do", i); if (j < 0) { return false; } int k = find(sb, "begin", j); if (k < 0) { return false; } int l = find(sb, "end", k); if (l < 0) { return false; } String var = sb.substring(i + 4, j).trim(); StringBuffer sblock = new StringBuffer(sb.substring(k + 5, l)); if (var.equals("Flame")) { processFields(sblock, var, JSFlame.class); } else if (var.equals("Transform")) { processFields(sblock, var, JSTransform.class); } else if (var.equals("Options")) { processFields(sblock, var, JSOptions.class); } else if (var.equals("Renderer")) { processFields(sblock, var, JSRenderer.class); } else if (var.equals("TStringList")) { processFields(sblock, var, JSStringList.class); } sb.replace(k + 5, l, sblock.toString()); sb.replace(i, j + 2, ""); return true; } // End of method processWithStatements
4f8ab429-0906-4391-8db0-4d06b774bc46
0
public void testStartSeleniumServer() throws Exception { //passing a method Print callCommand(TestSteps2(), "hello world"); }
dac4d1df-a9f4-4757-94ba-2848dd145ac7
5
public CheckResultMessage check18(int day) { int r1 = get(33, 5); int c1 = get(34, 5); int r2 = get(39, 5); int c2 = get(40, 5); BigDecimal b = new BigDecimal(0); if (checkVersion(file).equals("2003")) { try { in = new FileInputStream(file); hWorkbook = new HSSFWorkbook(in); b = getValue(r1 + 1, c1 + day, 8).add( getValue(r2 + 10, c2 + day - 1, 10)); if (0 != getValue(r1 + 1, c1 + 1 + day, 8).compareTo(b)) { return error("支付机构汇总报表<" + fileName + ">未达账项核对 J02:" + day + "日错误"); } } catch (Exception e) { } } else { try { in = new FileInputStream(file); xWorkbook = new XSSFWorkbook(in); b = getValue1(r1 + 1, c1 + day, 8).add( getValue1(r2 + 10, c2 + day - 1, 10)); if (0 != getValue1(r1 + 1, c1 + 1 + day, 8).compareTo(b)) { return error("支付机构汇总报表<" + fileName + ">未达账项核对 J02:" + day + "日错误"); } } catch (Exception e) { } } return pass("支付机构汇总报表<" + fileName + ">未达账项核对 J02:" + day + "日正确"); }
a55ae3c2-470e-44fd-b97a-105929889a56
4
public int getHeadRulePriority(String category, String edgeLabel, String childCategory) { if (!headRules.containsKey(category) || !headRules.get(category).containsKey(edgeLabel)) return Integer.MAX_VALUE; if (headRules.get(category).get(edgeLabel).containsKey("")) return headRules.get(category).get(edgeLabel).get(""); if (headRules.get(category).get(edgeLabel).containsKey(childCategory)) return headRules.get(category).get(edgeLabel).get(childCategory); return Integer.MAX_VALUE; }
71aafb89-2685-4e67-95e2-7d2bd48b88cd
4
public void addPattern(Pattern<?,?> pair) throws NNException { if (pair.inputAdapter.numberOfSignals() != network.numberOfInputs()) { throw new NNException("Incorrect number of inputs in pattern. " + "Network expected " + network.numberOfInputs() + ", but was " + pair.inputAdapter.numberOfSignals()); } if (pair.outputAdapter.numberOfSignals() != network.numberOfOutputs()) { throw new NNException("Incorrect number of outputs in pattern. " + "Network expected " + network.numberOfOutputs() + ", but was " + pair.outputAdapter.numberOfSignals()); } patterns.add(pair); }
0a230197-c409-47aa-806f-b7dd20f133a2
4
public void draw(Graphics g, Dimension d, Camera cam){ //Draw background drawBackground(g, d, cam); //Draw Player if (player != null){ player.draw(g,cam); } //Draw the world for (Tile items: map){ items.draw(g,cam); } //Draw the characters for (Entity entity: entities){ entity.draw(g,cam); } //Draw Pick Ups for (PickUpObject items: pickups){ items.draw(g,cam); } }
ede6b88c-705c-4af9-a59d-18e836fb6bb1
0
@Override public void setWatchKey(Object assignedWatchKey) { this.watchKey = (Integer) assignedWatchKey; }
4271c125-2cc5-4c4a-8278-5186e322559d
3
public String value_string(Object x) { if (x == null ) return "''"; else if(x instanceof String ) return "'" + x.toString() + "'"; else if(x instanceof java.util.Date) return sql_date((java.util.Date)x); else return x.toString(); }
fa1e03e7-22f9-4ccc-ade9-8abc38930e94
6
public static void main(String args[]) { Scanner sc = new Scanner(System.in); int T=sc.nextInt(); while(T>0) { T--; String s = sc.next(); if(s.length()>3) System.out.println(3); else { int cnt=0; if(s.charAt(0)=='o') cnt++; if(s.charAt(1)=='n') cnt++; if(s.charAt(2)=='e') cnt++; if(cnt>=2) System.out.println(1); else System.out.println(2); } } }
d82c20a7-5a8b-4f8d-abc1-27cebd8cb4cd
5
public int getBlue(int row, int col) { if (row >=0 && row < rows && col >= 0 && col < columns && grid[row][col] != null) return grid[row][col].getBlue(); else return defaultColor.getBlue(); }
755ec1fc-121e-43b3-bff8-63bf9cf70182
9
public String findSmallestWindow(String str1, String str2) { // table with counter for another string's characters int[] needsToFind = new int[256]; // variable for begin index int begin = 0; // table with counter for first string's characters int[] hasToFind = new int[256]; // variable for counting similar characters int count = 0; // variable to store minimum length of window int minWindow = Integer.MAX_VALUE; int window = 0; // variable to store minimum window starting index int minWindowIndex = 0; for (int i = 0; i < str2.length(); i++) { needsToFind[str2.charAt(i)]++; } // iterate through the first string for (int i = 0; i < str1.length(); i++) { // if characters is not in needstoFind table, skip if (needsToFind[str1.charAt(i)] == 0) { continue; } // increment counter of current character hasToFind[str1.charAt(i)]++; // increment count variable if (hasToFind[str1.charAt(i)] <= needsToFind[str1.charAt(i)]) { count++; } // if count is same as length of second string,check for window if (count == str2.length()) { // advance begin index as far right as possible, // stop when advancing breaks window constraint. while (needsToFind[str1.charAt(begin)] == 0 || hasToFind[str1.charAt(begin)] > needsToFind[str1 .charAt(begin)]) { if (hasToFind[str1.charAt(begin)] > needsToFind[str1 .charAt(begin)]) { hasToFind[str1.charAt(begin)]--; } begin++; } // update minWindow if a minimum length is met window = i - begin + 1; if (window < minWindow) { minWindow = window; minWindowIndex = begin; } } } return str1.substring(minWindowIndex, minWindowIndex + minWindow); }
5504a8e4-e4e0-48a5-93fd-1e5bf2e3b109
7
private void inject(Player player) { boolean injected = false; if (player.getClass().isAssignableFrom(this.craftPlayer)) { try { final Object entPlayer = this.getHandle.invoke(player); if (entPlayer.getClass().isAssignableFrom(this.entityPlayerClass)) { final Object playerConnection = this.playerConnectionField.get(entPlayer); if (playerConnection.getClass().isAssignableFrom(this.playerConnectionClass)) { final Object networkManager = this.networkManagerField.get(playerConnection); if (networkManager.getClass().isAssignableFrom(this.networkManagerClass)) { final Handler handler = new Handler(player); for (final Field field : this.channelFields) { final Channel channel = (Channel) field.get(networkManager); channel.pipeline().addLast(handler); injected = true; } } } } } catch (final Exception e) { this.plugin.getLogger().log(Level.WARNING, "Could not inject player " + player, e); } } if (!injected) { player.sendMessage("I could not hax ur pakkits"); } }
516f9a37-dcea-47a5-85c0-14806da5a615
3
public static void unpackConfig(Archive archive) { Stream stream = new Stream(archive.get("flo.dat")); int cacheSize = stream.getUnsignedShort(); if (Floor.cachedFloors == null) { Floor.cachedFloors = new Floor[cacheSize]; } for (int i = 0; i < cacheSize; i++) { if (Floor.cachedFloors[i] == null) { Floor.cachedFloors[i] = new Floor(); } Floor.cachedFloors[i].readValues(stream); } }
67a6c5b2-0d78-44c0-8f67-520515a0546f
5
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == hero1) { whoIsHero = "Crazy Dave"; } if (e.getSource() == hero2) { whoIsHero = "Pea Shooter"; } if (e.getSource() == hero3) { whoIsHero = "Ice Plant"; } if (e.getSource() == easy) { easy.setSelected(true); hard.setSelected(false); zombieDifficultyEasy = true; } if (e.getSource() == hard) { easy.setSelected(false); hard.setSelected(true); zombieDifficultyEasy = false; } }
9b61e025-1b58-4d9f-8f0a-4484ac7dd689
2
public static Connection getConnection() { if (connection == null) { try { Properties properties = new Properties(); properties.load(DatabaseHelper.class.getResourceAsStream("/com/dnx/multi/database/database.properties")); MysqlDataSource dataSource = new MysqlDataSource(); dataSource.setUser(properties.getProperty("username")); dataSource.setPassword(properties.getProperty("password")); dataSource.setServerName(properties.getProperty("host")); dataSource.setPort(Integer.valueOf(properties.getProperty("port"))); dataSource.setDatabaseName(properties.getProperty("database")); connection = dataSource.getConnection(); } catch (SQLException | IOException ex) { System.out.println(ex.getMessage()); } } return connection; }
9802ac06-98f0-4479-a16a-8235b7b1a7ab
7
public int moveLeft(boolean findChange) { int total = 0; for (int y = 0; y < 4; y++) { for (int x = 3; x > 0; x--) { if (next.grid[x][y] != 0 && next.grid[x][y] == next.grid[x-1][y]) { next.grid[x-1][y] *= 2; next.grid[x][y] = 0; total += weightingMerge(next.grid[x][y]); } else if (next.grid[x-1][y] == 0 && next.grid[x][y] > 0) { next.grid[x-1][y] = next.grid[x][y]; next.grid[x][y] = 0; } } } if (findChange) return total + findChange(); return total; }
a564702c-7f98-42c7-9a37-1efef3149e28
2
public void removeElement(GraphElement ge) { if (GraphLine.class.isInstance(ge)) { removeLine((GraphLine) ge); } else if (GraphPoint.class.isInstance(ge)) { removePoint((GraphPoint)ge); } }
2f4e3bb7-ae1d-4397-80ee-dc6635cde82a
4
private void btn_saveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_saveActionPerformed // TODO add your handling code here: String nomeprod, qtdprod, codprod, dataped; nomeprod = txt_nomeprod.getText(); qtdprod = txt_qtdprod.getText(); codprod = txt_codforn.getText(); dataped = txt_datapedido.getText(); if(nomeprod.isEmpty()|| qtdprod.isEmpty()|| codprod.isEmpty() || dataped.isEmpty()){ JOptionPane.showMessageDialog(rootPane, "Por favor, preencha todos os campos!!"); } }//GEN-LAST:event_btn_saveActionPerformed
57b5c8c8-0ee6-47e6-b539-ecc40647e6a1
1
private void initialize() { this.setBounds(100, 100, 800, 600); sourceImagePanel = new JPanel(); sourceImagePanel.setBounds(10, 30, 293, 447); getContentPane().add(sourceImagePanel); imageSourceLabel = new JLabel(""); sourceImagePanel.add(imageSourceLabel); imageSourceLabel.setIcon(new ImageIcon(IMAGE_SOURCE_FIST_STEP)); resultImagePanel = new JPanel(); resultImagePanel.setBounds(481, 30, 293, 447); getContentPane().add(resultImagePanel); imageResultLable = new JLabel(""); resultImagePanel.add(imageResultLable); JButton btnProcess = new JButton("Process"); btnProcess.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { BufferedImage bufferedImage = ImageUtil .getBufferedImage(IMAGE_SOURCE); BufferedImage bufferedResult = convertor .process(bufferedImage); ImageUtil.convertToImage(IMAGE_RESULT, bufferedResult); imageResultLable.setIcon(new ImageIcon(IMAGE_RESULT)); update(); } catch (IOException e1) { e1.printStackTrace(); } } }); btnProcess.setBounds(346, 79, 89, 23); getContentPane().add(btnProcess); update(); }
bb7215bf-dad5-40a5-92b2-0ea0473d6575
9
public static void main(String args[]) { List<Integer> lists = new LinkedList<Integer>(); // list store all the // left numbers, big // at first for (int i = 9; i >= 0; i--) { lists.add(i); } System.out.println(lists.get(0)); int remain = pos; // 0 as the upper digits for (int i = 0; i < nums; i++) { // count the i! if i! is bigger than remaining number int curSum = stepCross(nums - i); if (curSum >= remain) { if (i > 0) resultPos[i - 1] = lists.remove(lists.size() - 1); } else { if (i > 0) { resultPos[i - 1] = lists.remove(lists.size() - remain / curSum - (remain % curSum == 0 ? 0 : 1)); remain = remain % curSum; if (remain == 0) { setBigest(lists, i); break; } } else { System.out.println("error: exceed"); break; } } if (curSum == remain) { setBigest(lists, i); break; } } for (int i = 0; i < resultPos.length; i++) { System.out.print(resultPos[i]); } }
7c47d889-182f-4fff-b6f4-f78aed0c13fe
4
@Override public void tickClient() { super.tickClient(); if (SignalTools.effectManager != null && SignalTools.effectManager.isTuningAuraActive()) { for (WorldCoordinate coord : getPairs()) { SignalReceiver receiver = getReceiverAt(coord); if (receiver != null) { SignalTools.effectManager.tuningEffect(getTile(), receiver.getTile()); } } } }
a625af94-c272-4b1a-acf2-e7113d995e61
2
public static CtMethod setter(String methodName, CtField field) throws CannotCompileException { FieldInfo finfo = field.getFieldInfo2(); String fieldType = finfo.getDescriptor(); String desc = "(" + fieldType + ")V"; ConstPool cp = finfo.getConstPool(); MethodInfo minfo = new MethodInfo(cp, methodName, desc); minfo.setAccessFlags(AccessFlag.PUBLIC); Bytecode code = new Bytecode(cp, 3, 3); try { String fieldName = finfo.getName(); if ((finfo.getAccessFlags() & AccessFlag.STATIC) == 0) { code.addAload(0); code.addLoad(1, field.getType()); code.addPutfield(Bytecode.THIS, fieldName, fieldType); } else { code.addLoad(1, field.getType()); code.addPutstatic(Bytecode.THIS, fieldName, fieldType); } code.addReturn(null); } catch (NotFoundException e) { throw new CannotCompileException(e); } minfo.setCodeAttribute(code.toCodeAttribute()); return new CtMethod(minfo, field.getDeclaringClass()); }
3f8e6be2-e849-4dd9-ab1d-67bae083c25c
0
public synchronized void stopNotification() { this.aNotification.clear(); this.notifyAll(); }
777b2c0e-9a4c-45d0-93f7-0371e2dbad1d
0
public void setStrength(double strength) { this.strength = strength; }
11a0c9b5-d906-44af-9594-61eeb212740e
6
public static HashMap<String, HashMap<String, Integer>> getMap(String filePath) throws Exception { HashMap<String, HashMap<String, Integer>> map = new HashMap<String, HashMap<String,Integer>>(); BufferedReader reader = filePath.toLowerCase().endsWith("gz") ? new BufferedReader(new InputStreamReader( new GZIPInputStream( new FileInputStream( filePath)))) : new BufferedReader(new FileReader(new File(filePath ))); String nextLine = reader.readLine(); int numDone =0; while(nextLine != null) { StringTokenizer sToken = new StringTokenizer(nextLine, "\t"); String sample = sToken.nextToken().replace(".fastatoRDP.txt.gz", ""); String taxa= sToken.nextToken(); int count = Integer.parseInt(sToken.nextToken()); if( sToken.hasMoreTokens()) throw new Exception("No"); HashMap<String, Integer> innerMap = map.get(sample); if( innerMap == null) { innerMap = new HashMap<String, Integer>(); map.put(sample, innerMap); } if( innerMap.containsKey(taxa)) throw new Exception("parsing error " + taxa); innerMap.put(taxa, count); nextLine = reader.readLine(); numDone++; if( numDone % 1000000 == 0 ) System.out.println(numDone); } return map; }
8a95d5eb-2b28-48fc-a155-6b1bc0027f19
1
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) resp; if(request.getSession().getAttribute("USER_NAME") != null){ } System.out.println(request.getRequestURI()); chain.doFilter(request, response); }
f4d90374-3607-4e4f-a2c2-571c4bec0673
4
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(args.length == 0) { return noArgs(sender, command, label); } else { final String subcmd = args[0].toLowerCase(); // Check known handlers first and pass to them final CommandHandler handler = registeredHandlers.get(subcmd); if(handler != null) { return handler.onCommand(sender, command, label, shortenArgs(args)); } // Its our command, so handle it if its registered. final ICommand subCommand = registeredCommands.get(subcmd); if(subCommand == null) { return unknownCommand(sender, command, label, args); } // Execute command boolean value = true; try { value = subCommand.execute(plugin, sender, command, label, shortenArgs(args)); } catch(ArrayIndexOutOfBoundsException e) { sender.sendMessage(ChatColor.GRAY + WorldChannels.TAG + ChatColor.RED + " Missing parameters."); } return value; } }
f0c78ee3-1f69-45e1-b973-91edc3422c58
5
public void turnTaking(Move theMove) { Piece pieceToMove = getPiece(theMove.getSource()); String color = isLightTurn ? "light" : "dark"; if (pieceToMove.getPieceColor().equals(color) && pieceToMove != null) { makeMove(theMove); if (pieceToMove.isValid) { isLightTurn = !isLightTurn; if (isInCheck(otherColor(pieceToMove.getPieceColor()))) { System.out.println(otherColor(pieceToMove.getPieceColor()).toUpperCase() + " King is in Check"); } } } else { System.out.println("It is not your turn or the your trying to move a null position."); } }
d4135342-a9ae-4279-a8e4-b6a726f934f1
6
public Enemy(boolean side, int color, int movePattern, int bulletPattern, int bullets, double direction, int bulletSpeed) { super("sprites/fairyG_1.png"); if(color > 4 || color < 1) { color = 1; } if(color == 2) { setImage("sprites/fairyB_1.png"); } else if(color == 3) { setImage("sprites/fairyY_1.png"); } else if(color == 4) { setImage("sprites/fairyR_1.png"); } this.color = color; this.movePattern = movePattern; this.bulletPattern = bulletPattern; if(bullets < 0) { this.bullets = 0; } else { this.bullets = bullets; } this.direction = direction; this.bulletSpeed = bulletSpeed; this.side = side; this.x = fairyMove.getStartPos(true, movePattern, side); this.y = fairyMove.getStartPos(false, movePattern, side); startTime = Game.getInstance().getGameTime(); }
66e57b61-b921-465d-ab51-4c36672cdb27
9
protected final void move(byte dir) { if (distanceToTravel == 0) { if (dir == NORTH) { facing = NORTH; if (!hub.game.region.isTileOccupied(mapX, mapY - 1)) distanceToTravel = 50; } else if (dir == SOUTH) { facing = SOUTH; if (!hub.game.region.isTileOccupied(mapX, mapY + 1)) distanceToTravel = 50; } else if (dir == WEST) { facing = WEST; if (!hub.game.region.isTileOccupied(mapX - 1, mapY)) distanceToTravel = 50; } else if (dir == EAST) { facing = EAST; if (!hub.game.region.isTileOccupied(mapX + 1, mapY)) distanceToTravel = 50; } } }
8e3158c0-6457-4e32-b6e5-fd7c9a654534
9
public static double getAngleOfEllipseAtAngle(double angleFromCenter, double horizontalAxis, double verticalAxis) { if (horizontalAxis == verticalAxis) { return angleFromCenter; } //System.out.println(angleFromCenter); double axisLengths = Math.pow(horizontalAxis / 2, 2) / Math.pow(verticalAxis / 2, 2); //System.err.println(angleFromCenter + " " + axisLengths);\ angleFromCenter = Calculator.confineAngleToRange(angleFromCenter); if (angleFromCenter <= 90 && angleFromCenter >= 0) { //System.out.println(Math.toDegrees(Math.atan(axisLengths * Math.tan(Math.toRadians(angleFromCenter))))); return Math.toDegrees(Math.atan(axisLengths * Math.tan(Math.toRadians(angleFromCenter)))); } else if (angleFromCenter <= 180 && angleFromCenter > 90) { return 180 + Math.toDegrees(Math.atan(axisLengths * Math.tan(Math.toRadians(angleFromCenter)))); } else if (angleFromCenter <= 270 && angleFromCenter > 180) { return 270 - (90 - Math.toDegrees(Math.atan(axisLengths * Math.tan(Math.toRadians(angleFromCenter))))); } else if (angleFromCenter <= 360 && angleFromCenter > 270) { return 360 + Math.toDegrees(Math.atan(axisLengths * Math.tan(Math.toRadians(angleFromCenter)))); } System.err.println("ERROR"); return Double.NaN; }
c7a61f26-0b9d-49b0-855e-b6031f51704d
0
public void setDesc(String desc) { this.desc = desc; }
fff21c03-8cab-4c47-8336-4a0b052ed68e
9
public void delete(Key key) { if(key == null) { throw new NullPointerException("Key may not be null"); } if(!membershipTest(key)) { throw new IllegalArgumentException("Key is not a member"); } int[] h = hash.hash(key); hash.clear(); for(int i = 0; i < nbHash; i++) { // find the bucket int wordNum = h[i] >> 4; // div 16 int bucketShift = (h[i] & 0x0f) << 2; // (mod 16) * 4 long bucketMask = 15L << bucketShift; boolean hasUpdatedSuccess = false; // 是否更新成功 int retriedTimes = 0; // 已重试次数 while(!hasUpdatedSuccess && retriedTimes < MAX_UPDATE_RETRY_TIMES) { long oldVal = buckets.get(wordNum); long bucketValue = (oldVal & bucketMask) >>> bucketShift; // only decrement if the count in the bucket is between 0 and BUCKET_MAX_VALUE if(bucketValue >= 1 && bucketValue < BUCKET_MAX_VALUE) { // decrement by 1 hasUpdatedSuccess = buckets.compareAndSet(wordNum, oldVal, (oldVal & ~bucketMask) | ((bucketValue - 1) << bucketShift)); } retriedTimes++; } // while ends // do log if(!hasUpdatedSuccess && retriedTimes == MAX_UPDATE_RETRY_TIMES) { LOG.error("collision occurn: delete"); } } }
aff486e1-a55f-49d5-87f1-7a77a0d7d92a
3
public boolean asyncRequest(String url, String httpMethod, OauthKey key, List<QParameter> listParam, List<QParameter> listFile, QAsyncHandler asyncHandler, Object cookie) { OAuth oauth = new OAuth(); StringBuffer sbQueryString = new StringBuffer(); String oauthUrl = oauth.getOauthUrl(url, httpMethod, key.customKey, key.customSecrect, key.tokenKey, key.tokenSecrect, key.verify, key.callbackUrl, listParam, sbQueryString); String queryString = sbQueryString.toString(); QAsyncHttpClient asyncHttp = new QAsyncHttpClient(); if ("GET".equals(httpMethod)) { return asyncHttp.httpGet(oauthUrl, queryString, asyncHandler, cookie); } else if ((listFile == null) || (listFile.size() == 0)) { return asyncHttp.httpPost(oauthUrl, queryString, asyncHandler, cookie); } else { return asyncHttp.httpPostWithFile(oauthUrl, queryString, listFile, asyncHandler, cookie); } }
9509c79f-ba04-4b06-bcb2-b31072401b65
8
public int[] fix45(int[] nums) { for (int i = 0; i < nums.length; i++) { if (nums[i] == 4) { for (int j = i+1; j < nums.length; j++) { if (nums[j] == 5) { int temp = nums[i+1]; nums[i+1] = nums[j]; nums[j] = temp; } } i++; } else if (nums[i] == 5) { for (int j = i+1; j < nums.length-1; j++) { if (nums[j] == 4 && nums[j+1] != 5) { int temp = nums[j+1]; nums[j+1] = nums[i]; nums[i] = temp; } } } } return nums; }
e95b2d41-6752-40c3-a6db-2b3a6e0e6bdf
4
public static void save(String filename) { File file = new File(filename); String suffix = filename.substring(filename.lastIndexOf('.') + 1); // png files if (suffix.toLowerCase().equals("png")) { try { ImageIO.write(onscreenImage, suffix, file); } catch (IOException e) { e.printStackTrace(); } } // need to change from ARGB to RGB for jpeg // reference: http://archives.java.sun.com/cgi-bin/wa?A2=ind0404&L=java2d-interest&D=0&P=2727 else if (suffix.toLowerCase().equals("jpg")) { WritableRaster raster = onscreenImage.getRaster(); WritableRaster newRaster; newRaster = raster.createWritableChild(0, 0, width, height, 0, 0, new int[] {0, 1, 2}); DirectColorModel cm = (DirectColorModel) onscreenImage.getColorModel(); DirectColorModel newCM = new DirectColorModel(cm.getPixelSize(), cm.getRedMask(), cm.getGreenMask(), cm.getBlueMask()); BufferedImage rgbBuffer = new BufferedImage(newCM, newRaster, false, null); try { ImageIO.write(rgbBuffer, suffix, file); } catch (IOException e) { e.printStackTrace(); } } else { System.out.println("Invalid image file type: " + suffix); } }
c03fdd47-a53b-42a4-adf6-bf2aac594dc4
3
public static int parseColor(String colorString) throws IllegalArgumentException { if (colorString.charAt(0) == '#') { // Use a long to avoid rollovers on #ffXXXXXX long color = Long.parseLong(colorString.substring(1), 16); if (colorString.length() == 7) { // Set the alpha value color |= 0x00000000ff000000; } else if (colorString.length() != 9) { throw new IllegalArgumentException("Unknown color"); } return (int)color; } throw new IllegalArgumentException("Unknown color"); }
b4e0861d-8d62-449b-9995-ad5499c2b85d
4
public static boolean isAllUpperCase(String cs) { if (cs == null || StringUtil.isEmpty(cs)) { return false; } int sz = cs.length(); for (int i = 0; i < sz; i++) { if (Character.isUpperCase(cs.charAt(i)) == false) { return false; } } return true; }
647e30b9-53b4-4fec-8f56-7d38ee65c37f
9
protected void loadFields(com.sforce.ws.parser.XmlInputStream __in, com.sforce.ws.bind.TypeMapper __typeMapper) throws java.io.IOException, com.sforce.ws.ConnectionException { super.loadFields(__in, __typeMapper); __in.peekTag(); if (__typeMapper.isElement(__in, CreatedBy__typeInfo)) { setCreatedBy((com.sforce.soap.enterprise.sobject.Name)__typeMapper.readObject(__in, CreatedBy__typeInfo, com.sforce.soap.enterprise.sobject.Name.class)); } __in.peekTag(); if (__typeMapper.isElement(__in, CreatedById__typeInfo)) { setCreatedById(__typeMapper.readString(__in, CreatedById__typeInfo, java.lang.String.class)); } __in.peekTag(); if (__typeMapper.isElement(__in, CreatedDate__typeInfo)) { setCreatedDate((java.util.Calendar)__typeMapper.readObject(__in, CreatedDate__typeInfo, java.util.Calendar.class)); } __in.peekTag(); if (__typeMapper.isElement(__in, Field__typeInfo)) { setField(__typeMapper.readString(__in, Field__typeInfo, java.lang.String.class)); } __in.peekTag(); if (__typeMapper.isElement(__in, IsDeleted__typeInfo)) { setIsDeleted((java.lang.Boolean)__typeMapper.readObject(__in, IsDeleted__typeInfo, java.lang.Boolean.class)); } __in.peekTag(); if (__typeMapper.isElement(__in, NewValue__typeInfo)) { setNewValue((java.lang.Object)__typeMapper.readObject(__in, NewValue__typeInfo, java.lang.Object.class)); } __in.peekTag(); if (__typeMapper.isElement(__in, OldValue__typeInfo)) { setOldValue((java.lang.Object)__typeMapper.readObject(__in, OldValue__typeInfo, java.lang.Object.class)); } __in.peekTag(); if (__typeMapper.isElement(__in, Parent__typeInfo)) { setParent((com.sforce.soap.enterprise.sobject.Cloudswarm__Case_Swarm_Rule__c)__typeMapper.readObject(__in, Parent__typeInfo, com.sforce.soap.enterprise.sobject.Cloudswarm__Case_Swarm_Rule__c.class)); } __in.peekTag(); if (__typeMapper.isElement(__in, ParentId__typeInfo)) { setParentId(__typeMapper.readString(__in, ParentId__typeInfo, java.lang.String.class)); } }
858357da-f0b6-470e-a8d7-5e01cf5324dc
3
private MapLayer unmarshalObjectGroup(Node t) throws Exception { ObjectGroup og = null; try { og = (ObjectGroup)unmarshalClass(ObjectGroup.class, t); } catch (Exception e) { e.printStackTrace(); return og; } final int offsetX = getAttribute(t, "x", 0); final int offsetY = getAttribute(t, "y", 0); og.setOffset(offsetX, offsetY); // Add all objects from the objects group NodeList children = t.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if ("object".equalsIgnoreCase(child.getNodeName())) { og.addObject(readMapObject(child)); } } Properties props = new Properties(); readProperties(children, props); og.setProperties(props); return og; }
9ae2861c-00e6-4864-85d0-9e7061470474
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://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Menu_Opcoes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Menu_Opcoes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Menu_Opcoes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Menu_Opcoes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Menu_Opcoes().setVisible(true); JMenuBar barraMenu = new JMenuBar(); CadCliente cli = new CadCliente(); barraMenu.add(cli); CadProduto pro = new CadProduto(); barraMenu.add(pro); Vender ven = new Vender(); barraMenu.add(ven); Pesquisar pesq = new Pesquisar(); barraMenu.add(pesq); } }); }
ecbab431-e6bd-43b8-9946-6185d34d0497
4
@Override public void addComponent(Component component, LayoutParameter... parameters) { if(parameters.length == 0) { parameters = new LayoutParameter[] { CENTER }; } else if(parameters.length > 1) { throw new IllegalArgumentException("Calling BorderLayout.addComponent with more than one " + "layout parameter"); } else if(!BORDER_LAYOUT_POSITIONS.contains(parameters[0])) { throw new IllegalArgumentException("Calling BorderLayout.addComponent layout parameter " + parameters[0] + " is not allowed"); } else if(component == null) { throw new IllegalArgumentException("Calling BorderLayout.addComponent component parameter " + "set to null is not allowed"); } //Make sure we don't add the same component twice removeComponent(component); synchronized(components) { components.put(parameters[0], component); } }
62ccb663-74d9-4328-bce8-c9556ccea076
3
private static Method getMethod(Class<?> cl, String method) { for(Method m : cl.getMethods()) { if(m.getName().equals(method)) { return m; } } return null; }
a950310a-f100-4330-b81e-7621cc30056e
7
public GamesFolder(ZipFile file, String path) throws IOException { this.path = path; JsonReader reader = ZIPHelper.getJsonReader(file, path + "info.json"); reader.beginObject(); while (reader.peek() == JsonToken.NAME) { String name = reader.nextName(); if ("game_folders".equals(name)) { String[] strings = new Gson().fromJson(reader, String[].class); this.gamesFolders = new GamesFolder[strings.length]; for (int i = 0; i < strings.length; i++) { GamesFolder gamesFolder = new GamesFolder(file, path + strings[i]); gamesFolder.baseGamesFolder = this; this.gamesFolders[i] = gamesFolder; } } else if ("games".equals(name)) { String[] strings = new Gson().fromJson(reader, String[].class); this.gamePaths = new GamePath[strings.length]; for (int i = 0; i < strings.length; i++) { GamePath gamePath = new GamePath(); gamePath.path = path + strings[i]; this.gamePaths[i] = gamePath; } } } reader.endObject(); if (this.gamesFolders == null) this.gamesFolders = new GamesFolder[0]; if (this.gamePaths == null) this.gamePaths = new GamePath[0]; }
18bd9c5e-2427-42ad-8f1a-9b30d3f2ac49
9
public void compile() { errs.clear(); int n = 0; int max = links.getHighestDep(); //System.out.println("* MAX "+max); while (n<=max) { ArrayList<Import> imps = links.getLinksWithDepsOf(n); //System.out.println("* N "+n); //System.out.println("* IMPS "+imps); if (imps.isEmpty()) { n++; } else { for (Import imp : (ArrayList<Import>) imps.clone()) { SourcePackage compPkg = new SourcePackage(); if (imp.pkg!=null) { compPkg.addContents(imp.pkg); compPkg.setName(imp.pkg.getName()); HashSet<String> has = new HashSet<>(); has.add(imp.name); for (Import imp2 : imps) { if (imp2!=imp) { if (imp2.pkg!=null) { if (!has.contains(imp2.name)) { compPkg.addContents(imp2.pkg); has.add(imp2.name); } } } } addNeeded(compPkg,compPkg,has); compPkg.addContents(platform.pkgs.get("core")); errs.addAll(SourceCompiler.compile(compPkg)); } //System.out.println("* COMP "+imp); imp.compiled = true; n = 0; } } } outputPackage.setName(inputPackage.getName()); for (Import imp : links.getAllLinks()) { outputPackage.addContents(imp.pkg); } outputPackage.addContents(platform.pkgs.get("core")); }
644c5b96-b839-486e-bfc0-bb5fc67ca2e4
1
public static S3Object downloadObject(RestS3Service ss, String testBucknetName, String testObjectName) { S3Object s3objectRes = null; try { s3objectRes = ss.getObject(testBucknetName, testObjectName); } catch (S3ServiceException e) { e.printStackTrace(); } return s3objectRes; }
de598bfc-bbce-4573-84b3-0f090ae6658c
2
public static BuildingTag getName(char tag) { if (mapping == null) { mapping = new HashMap<Character, BuildingTag>(); for (BuildingTag ut : values()) { mapping.put(ut.tag, ut); } } return mapping.get(tag); }
26a3808e-c692-4714-b042-500d7939e72a
7
private int partition(int start, int end) { SortingUtils.swap(array, start, new Random().nextInt(end-start+1)+start); int i = start; int j = end; int pivotV = array[i]; while(i<j) { while(i<j && array[j]>=pivotV) {j--;} if(i<j) { array[i++] = array[j]; } while(i<j && array[i]<pivotV) {i++;} if(i<j) { array[j--] = array[i]; } } array[i] = pivotV; return i; }
9c13e47f-e502-4407-854d-9486fea0231b
1
public static <D> D getInstance(Class<D> _class) { try { return _class.newInstance(); } catch (Exception _ex) { _ex.printStackTrace(); } return null; }
211addcc-3445-4461-ad67-6ec20b24316d
7
public static int[][] multiply(int[][] f, int[][] s) { int f_rows = f.length; int s_rows = s.length; if(f_rows == 0) { return s; } if(s_rows == 0) { return f; } int f_cols = f[0].length; if (f_cols != s_rows) { String errMsg = String.format(ERRMSG_FORMAT, f_cols, s_rows); throw new IllegalArgumentException(errMsg); } int s_cols = s[0].length; if (f_rows == 1 && f_cols == 1 && s_rows == 1 && s_cols == 1) { return new int[][] { new int[] { f[0][0] * s[0][0] } }; } //looks like there is an issue in forming the sub matrix int[][] f_quad_1 = subMatrix(f, 0, f_rows / 2, 0, f_cols / 2); // A int[][] f_quad_2 = subMatrix(f, 0, f_rows / 2, f_cols / 2, f_cols); // B int[][] f_quad_3 = subMatrix(f, f_rows / 2, f_rows, 0, f_cols / 2); // C int[][] f_quad_4 = subMatrix(f, f_rows / 2, f_rows, f_cols / 2, f_cols); // D int[][] s_quad_1 = subMatrix(s, 0, s_rows / 2, 0, s_cols / 2); // E int[][] s_quad_2 = subMatrix(s, 0, s_rows / 2, s_cols / 2, s_cols); // F int[][] s_quad_3 = subMatrix(s, s_rows / 2, s_rows, 0, s_cols / 2); // G int[][] s_quad_4 = subMatrix(s, s_rows / 2, s_rows, s_cols / 2, s_cols); // H int[][] r_quad_1 = add(multiply(f_quad_1, s_quad_1), multiply(f_quad_2, s_quad_3)); int[][] r_quad_2 = add(multiply(f_quad_1, s_quad_2), multiply(f_quad_2, s_quad_4)); int[][] r_quad_3 = add(multiply(f_quad_3, s_quad_1), multiply(f_quad_4, s_quad_3)); int[][] r_quad_4 = add(multiply(f_quad_3, s_quad_2), multiply(f_quad_4, s_quad_4)); return merge(r_quad_1, r_quad_2, r_quad_3, r_quad_4); }
a3ff0379-0d83-4f51-96cb-457f7fab66c0
8
public void testDataDependance2() { try { TreeNode label = new TreeNode("label"); TreeNode result = contains(new TreeNode(label), mkChain(new TreeNode[]{ label })); assertTrue(null, "Failed to locate the only node of a leaf!", result != null && result.getData() != null && ((result.getData()) instanceof TreeNode) && result.getBranch() != null && result.getBranch().length == 0); } catch(NotFound exn) { fail(exn, "You can not locate the only node of a leaf!"); } catch(TreeException exn) { fail(exn, "An unexpected `TreeException` was thrown!"); } catch(ClassCastException exn) { fail(exn, "Your code fails to deal with tree nodes that are **not** labeled with string data structures! Make sure that: \n* You have **not** written your answer assuming that `String`'s will be the only data type used\n* You have used the `correct` type of `equal`ity."); } catch(Throwable exn) { fail(exn, "Unexpected exception thrown: " + exn.getClass().getName()); } // end of try-catch } // end of method testDataDependance2
47a3b23b-deff-47d8-8fc3-12f207eb3dd7
3
* @return Returns the style of the cell. */ public Map<String, Object> getCellStyle(Object cell) { Map<String, Object> style = (model.isEdge(cell)) ? stylesheet .getDefaultEdgeStyle() : stylesheet.getDefaultVertexStyle(); String name = model.getStyle(cell); if (name != null) { style = postProcessCellStyle(stylesheet.getCellStyle(name, style)); } if (style == null) { style = mxStylesheet.EMPTY_STYLE; } return style; }
3dcf8633-8e06-4ce4-b808-1fc22d3606cf
6
public static Long valueOf(Object o) { if (o == null) { return null; } else if (o instanceof Byte) { return (long)(Byte)o; } else if (o instanceof Integer) { return (long)(Integer)o; } else if (o instanceof Double) { return (long)(double)(Double)o; } else if (o instanceof Float) { return (long)(float)(Float)o; } else if (o instanceof Long) { return (long)(Long)o; } else { return null; } }
de82767b-55a7-48e8-a664-a88889520b37
0
public Double getAvb() { return avb; }
23daf9b2-bb3c-4d6d-9a0e-ac0ed75d753c
2
public static Matrix random(int M, int N) { Matrix A = new Matrix(M, N); for (int i = 0; i < M; i++) for (int j = 0; j < N; j++) A.data[i][j] = Math.random(); return A; }
e4f8be34-a3ec-4356-b2ea-951439ef3914
2
private boolean checkFieldInclineWinn(char cellValue){ if(checkInclineDownWinn(cellValue) || checkInclineUpWinn(cellValue)){ return true; } return false; }
02383b4f-8d5a-4972-b121-47377955dab5
9
private final static String[] buildFileForName(String filename, String contents) { String[] result = new String[contents.length()]; result[0] = null; int resultCount = 1; StringBuffer buffer = new StringBuffer(); int start = contents.indexOf("name[]"); //$NON-NLS-1$ start = contents.indexOf('\"', start); int end = contents.indexOf("};", start); //$NON-NLS-1$ contents = contents.substring(start, end); boolean addLineSeparator = false; int tokenStart = -1; StringBuffer currentToken = new StringBuffer(); for (int i = 0; i < contents.length(); i++) { char c = contents.charAt(i); if(c == '\"') { if(tokenStart == -1) { tokenStart = i + 1; } else { if(addLineSeparator) { buffer.append('\n'); result[resultCount++] = currentToken.toString(); currentToken = new StringBuffer(); } String token = contents.substring(tokenStart, i); if(token.equals(ERROR_TOKEN)){ token = INVALID_CHARACTER; } else if(token.equals(EOF_TOKEN)) { token = UNEXPECTED_EOF; } buffer.append(token); currentToken.append(token); addLineSeparator = true; tokenStart = -1; } } if(tokenStart == -1 && c == '+'){ addLineSeparator = false; } } if(currentToken.length() > 0) { result[resultCount++] = currentToken.toString(); }
a016e1a3-022e-4967-97ca-1b291b12607d
5
public int[] getOID(byte type) throws ASN1DecoderFail { if(data[offset]!=type) throw new ASN1DecoderFail("OCTET STR: "+type+" != "+data[offset]); byte[] b_value = new byte[contentLength()]; Encoder.copyBytes(b_value, 0, data, contentLength(),offset+typeLen()+lenLen()); int len=2; for(int k=1;k<b_value.length; k++) if(b_value[k]>=0) len++; int[] value = new int[len]; value[0] = get_u32(b_value[0])/40; value[1] = get_u32(b_value[0])%40; for(int k=2, crt=1; k<value.length; k++) { value[k]=0; while(b_value[crt]<0) { value[k] <<= 7; value[k] += b_value[crt++]+128;//get_u32(b_value[crt++])-128; } value[k] <<= 7; value[k] += b_value[crt++]; continue; } return value; }
72cf2496-e8d2-4be3-b3fa-343dc921e715
5
public void onBlockAdded(World var1, int var2, int var3, int var4) { super.onBlockAdded(var1, var2, var3, var4); if(!var1.multiplayerWorld) { this.updateAndPropagateCurrentStrength(var1, var2, var3, var4); var1.notifyBlocksOfNeighborChange(var2, var3 + 1, var4, this.blockID); var1.notifyBlocksOfNeighborChange(var2, var3 - 1, var4, this.blockID); this.notifyWireNeighborsOfNeighborChange(var1, var2 - 1, var3, var4); this.notifyWireNeighborsOfNeighborChange(var1, var2 + 1, var3, var4); this.notifyWireNeighborsOfNeighborChange(var1, var2, var3, var4 - 1); this.notifyWireNeighborsOfNeighborChange(var1, var2, var3, var4 + 1); if(var1.isBlockNormalCube(var2 - 1, var3, var4)) { this.notifyWireNeighborsOfNeighborChange(var1, var2 - 1, var3 + 1, var4); } else { this.notifyWireNeighborsOfNeighborChange(var1, var2 - 1, var3 - 1, var4); } if(var1.isBlockNormalCube(var2 + 1, var3, var4)) { this.notifyWireNeighborsOfNeighborChange(var1, var2 + 1, var3 + 1, var4); } else { this.notifyWireNeighborsOfNeighborChange(var1, var2 + 1, var3 - 1, var4); } if(var1.isBlockNormalCube(var2, var3, var4 - 1)) { this.notifyWireNeighborsOfNeighborChange(var1, var2, var3 + 1, var4 - 1); } else { this.notifyWireNeighborsOfNeighborChange(var1, var2, var3 - 1, var4 - 1); } if(var1.isBlockNormalCube(var2, var3, var4 + 1)) { this.notifyWireNeighborsOfNeighborChange(var1, var2, var3 + 1, var4 + 1); } else { this.notifyWireNeighborsOfNeighborChange(var1, var2, var3 - 1, var4 + 1); } } }
34156a55-b0f5-4303-a937-070f5ecc82a2
2
@Override public void mouseClicked(MouseEvent e) { //if (spawnMenuItem.isEnabled()) { int newX = (int) Math.round(e.getX() / (double) game.getPixelSize()); int newY = (int) Math.round(e.getY() / (double) game.getPixelSize()); if (game.isInBounds(newX, newY)) { if (erase) { game.removeEntity(newX, newY); } else { game.placeEntity(newX, newY, spawnID); } } repaint(); //} }
b6d6714b-7d07-4ac6-be56-494c48e23e15
3
public static void main(String[] args) { for(int i = 1; i <= (10/2+1); i++) { for (int j = i; j <= 10/2; j++) { System.out.printf(" "); } for (int j = 1; j <= (i*2-1); j++) { System.out.printf("*"); } System.out.printf("\n"); } }
f274c82e-d575-4dab-8c8f-9fad577476a1
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; TextComponent other = (TextComponent) obj; if (components == null) { if (other.components != null) return false; } else if (!components.equals(other.components)) return false; return true; }
a2cf75bb-3bc2-40ff-b02d-920f1d7e755f
4
public void setGameOption(int token){ if( token == 0){ if( gameOptionCursor < gameOption.length - 1) gameOptionCursor ++ ; else gameOptionCursor = 0 ; }else if( token == 1){ if( gameOptionCursor > 0) gameOptionCursor -- ; else gameOptionCursor = gameOption.length - 1 ; } }