method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
86dfdbe3-37a8-4471-a150-82d44fc39805
2
public void addFirst(E element) { LinkedElement<E> elem = new LinkedElement<E>(element); elem.setPrev(null); elem.setNext(first); if (total == 0) { last = elem; } if (total > 0) { first.setPrev(elem); } first = elem; total++; // System.out.println(elem.toInfoString()); // System.out.println(...
6564cd94-109f-4e4e-846f-0da363c8c0c6
8
private static List<Point[]> translateAlphaToPoints(boolean[][] imageInformation, int width, int height) { int[][] label = new int[width][height]; Map<Integer, Integer> mergeLabels = new HashMap<Integer, Integer>(); List<List<Point>> unstructuredPolygonPointList = new ArrayList<List<Point>>(); unstructuredPo...
c596363c-348c-4305-bb1d-17838be37cd8
8
private void jButton27ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton27ActionPerformed // Create Order and refresh order and market list String serverID = "ALL"; String nymID = "ALL"; try { if (serverMap != null && serverMap.size() > 0 && jComboBox5...
d698146b-1d88-4fcc-870a-eac4c5d3d7b1
0
public void setCountry(String country) { Address.setCountry(country); }
ced1fd26-6785-4ae7-8d11-8dfc6bfd213f
2
@Override public void update(Observable obs, Object arg) { if (!game.isInterrupted()) { Display.getDefault().syncExec(new Runnable() { public void run() { if (!shell.isDisposed()) { updateView(); ...
58b99319-940b-4db5-b561-4caf74500a76
7
@Override public void run() { if (input_stream == null) return; int count; try { if (buffer == null) buffer = new byte[BuildConfig.BUFFER_SIZE]; // if (stream_processor != null) // stream_processor.reset(); while ((count = input_stream.read(buffer)) != -1) { if (stream_processor != null) ...
07b3976f-d0eb-4628-ac03-d467baa36c0b
3
public void run() { for (Sensor sensor : this.sensors) { sensor.start(); } for (Sensor sensor : this.sensors) { System.out.print(sensor.report()); } for (Sensor sensor : this.sensors) { sensor.stop(); } }
29fcf882-7627-4409-8fee-5d8d81bfa7ba
9
public void parseXmlFile(String file){ //get the factory DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { //Using factory get an instance of document builder dbf.setValidating(true); dbf.setIgnoringElementContentWhitespace(true); dbf.setCoalescing(true); DocumentBuilder d...
33c4690f-e488-4727-95ec-e20796672207
3
public void update(Game game) { lastMovementType = Types.MOVEMENT.MOVE; //Get the input from the player. requestPlayerInput(game); //Map from the action mask to a Vector2D action. Direction action2D = Utils.processMovementActionKeys(getKeyHandler().getMask(), getPlayerID())...
a28be08e-9f29-4c24-963f-2e96a9f38209
6
public HugeArrayList<T> create() { normaliseArgs(); try { if (arrayListClass == null) arrayListClass = classLoader().loadClass(typeModel.type().getName() + "ArrayList"); } catch (ClassNotFoundException e) { acquireImplClass(); defineClass(GenerateHugeArrays.dumpElement(typeModel)...
fe988aa1-6585-4697-82bf-d4973f3b728d
3
@Test public void testReserve() throws Exception{ ThreadDriver thread = new ThreadDriver(); thread.start(); SpotStub stub = new SpotStub("312",3738); String ans = ""; int x = 0; while(x != -1 && x < 100){ //if no response is received in 10 seconds, test is deemed failed. x++; ...
b4010c0e-3364-4214-a90b-64392ef6538b
2
public static void sendMessageToPlayer( String player, String message ) { if ( player.equals( "CONSOLE" ) ) { ProxyServer.getInstance().getConsole().sendMessage( message ); } else { for ( String line : message.split( "\n" ) ) { getPlayer( player ).sendMessage( lin...
20902d5a-9158-4cca-b760-68f57b17be44
2
public static int getStringWidthWithFont(Font font, String value) { if (font == null || value == null) { return 0; } FontMetrics fm = getFontMetrics(font); return fm.stringWidth(value); }
ace10b1e-be29-4f66-997b-280f22439d5c
3
public int insert(Funcionario f) { Connection conn = null; PreparedStatement pstm = null; int retorno = -1; try { conn = ConnectionFactory.getConnection(); pstm = conn.prepareStatement(INSERT, Statement.RETURN_GENERATED_KEYS); pstm.setString(1, f.get...
0cbb7cdb-5926-4f34-b0bd-e9af8c41fc50
2
public static void saveTransactions(SWDataClass swDataClass) { FileOutputStream saveFile; ObjectOutputStream save; try { // Open a file to write to saveFile = new FileOutputStream(SAVE_FILE_DIRECTORY + "\\" + SAVE_FILE_NAME); save = new ObjectOutputStream(saveFile); // Save the whole class save....
8e877308-4ab2-4f17-9e90-285cd15553e5
6
private static int partition(Comparable[] a, int lo, int hi) { int i = lo; int j = hi + 1; while (true) { while (less(a[++i], a[lo])) if (i == hi) break; while (less(a[lo], a[--j])) if (j == lo) break...
2e5e74a3-1759-4ac1-8adf-e2323d601764
0
public void setEntityList(List<ValidableEntity> entityList) { this.entityList = entityList; }
bb222873-4723-4ada-8e4d-f86c0fed0e21
0
public LRParseTable getParseTable() { return table; }
b6552d27-a13b-4125-b695-2e3b20e1249a
6
static public void adjustBeginLineColumn(int newLine, int newCol) { int start = tokenBegin; int len; if (bufpos >= tokenBegin) { len = bufpos - tokenBegin + inBuf + 1; } else { len = bufsize - tokenBegin + bufpos + 1 + inBuf; } int i = 0, j = 0, k = 0; ...
e3db00d1-19b6-4e24-b878-52b15c4ff433
1
public char getNextChar() { thisChar = ++position < json.length() ? json.charAt(position) : 0; return thisChar; }
ea954fc1-d876-485e-85a9-b6203874d4eb
9
private String updateAccountBalance(String residentId, double amount, Session session, boolean isCredit) { Double cashBackPercentage = Double.parseDouble(env.getProperty("cashback_percentage")); Transaction tx = session.getTransaction(); String hql = HibernateQueries.getAccountsQueryBasedonResid...
25ec7695-3d3e-4f9d-9c37-0abee17e93b0
5
public void createFromXML(NodeList shop) { Node n = shop.item(0); while(n != null) { if(n.getNodeType() == Node.ELEMENT_NODE) { if(n.getNodeName().equalsIgnoreCase("ShopItem")) { createShopItem(n); } else if(n.getNodeName()....
13f0474a-5a1d-44fb-bce1-5061bf54616a
0
public static boolean isApplicable(Object object) { return object instanceof Serializable; }
cdb6a899-feb7-4588-94f7-1ac4e075efe9
9
public Stats() throws FileNotFoundException { String slvl = new String(); String sName = new String(); Scanner sin = new Scanner(System.in); int atk = 1; int lvl = 0; int hp = 0; int currXp = 0; int Xpgoal = 0; try { File level = new F...
ff6f1194-45ec-4fec-8123-89dba676a0a7
6
public Toolbar(CConn cc_) { super(); cc = cc_; BufferedImage bi = new BufferedImage(176, 16, BufferedImage.TYPE_INT_ARGB); Graphics2D g = bi.createGraphics(); g.drawImage(toolbarImage, 0, 0, 176, 16, null); setAlignmentX(java.awt.Component.LEFT_ALIGNMENT); setAlignmentY(java.awt.Compon...
4257c543-3d93-42ee-95a6-732e65d71884
6
@Override public final boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) { try { commands.execute(cmd.getName(), args, sender, sender); } catch (CommandPermissionsException e) { sender.sendMessage(ChatColor.RED + message...
1e6beffb-ee3b-4fc3-b7ed-e67bf66593e9
4
public void propertyChange(PropertyChangeEvent e) { boolean update = false; String prop = e.getPropertyName(); //If the directory changed, don't show an image. if (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(prop)) { file = null; update = true; //If...
48e7345e-f967-41cc-acf9-b755585551b1
1
public static User getUserByUserID(int userID) { try { String statement = new String("SELECT * FROM " + DBTable + " WHERE userid = ?"); PreparedStatement stmt = DBConnection.con.prepareStatement(statement); stmt.setInt(1, userID); ResultSet rs = stmt.executeQuery(); rs.next(); User user = new User(r...
83b747fa-02d8-4d27-a2f4-018117a8c95e
4
public void carregarTurmasDeDisciplinasEmArquivo(String nomeArquivo) throws IOException, DisciplinaInexistenteException, TurmaJaExisteException { BufferedReader leitor = null; try { leitor = new BufferedReader(new FileReader(nomeArquivo)); String CodDis = leitor.readLine(); do { if (CodDis != ...
7a5538e4-ab95-45db-ad9e-d0e8c4a2f25b
7
private final void buildNotifications() { // any function that calls this should be wrapped in synchronized(notifications) to make sure that it doesn't change before that function finishes with the updated notifications if (!bDirty) { return; } final Set<Integer> chs = WorldRegistryImpl.getInstance().getChanne...
928b11e2-c456-4a41-9d7b-8a02c254920b
4
public boolean matches(Inventory inv) { for (int i = 0; i <= 3 - recipeWidth; i++) { for (int j = 0; j <= 3 - recipeHeight; j++) { if (checkMatch(inv, i, j, true)) { return true; } if (checkM...
46748683-aed1-4614-bb23-5ea3c1b68834
4
@Override public int hashCode() { int result = firstName != null ? firstName.hashCode() : 0; result = 31 * result + (secondName != null ? secondName.hashCode() : 0); result = 31 * result + (email != null ? email.hashCode() : 0); result = 31 * result + (phone != null ? phone.hashCode(...
2443696d-46f7-4cda-9605-6ee501d2c437
4
boolean obviousBlockExists() { // проверка на то что доска имеет участок который никогда не будет заполнен изза // количества квадратов в нем blockCheckCt++; int forcedEmptyCt = 0; for (int r = 0; r < rows; r++) for (int c = 0; c < cols; c++) { int blockSi...
3a3d833b-1e25-476c-b649-3377ba9a7622
9
public Updater(Plugin plugin, int id, File file, UpdateType type, boolean announce) { this.plugin = plugin; this.type = type; this.announce = announce; this.file = file; this.id = id; this.updateFolder = plugin.getServer().getUpdateFolder(); final File pluginFile...
189cf396-056c-4592-af96-74f58b0188e9
2
public void setQuickLaunchFile(File f, int index){ if(index < 0 || index >= QUICK_SLOTS) return; quick_launch_files[index] = f; //sendQuickLaunchFiles(); sendQuickLaunchFile(index); changedQLFiles(); }
00c7b7be-38bf-4377-aeae-89a0c3560430
1
protected void setPrecio(double precio)throws Exception { if(precio<1){ throw new Exception("El precio tiene que ser superior a 0."); }else{ this.precio = precio; } }
6cd24dab-efa9-4201-be27-c08c112cfbed
5
public static void copyEdge(XSSFWorkbook wb, XSSFSheet sheet, int size) throws IOException { FileInputStream fis = null; try { fis = new FileInputStream(new File("data/excel/template.xlsx")); XSSFWorkbook template = new XSSFWorkbook(fis); XSSFSheet tempSheet = template.getSheet(Integer.toString(size)); ...
1729579e-7fa2-48e6-9bc8-cdf4502fdbc6
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Fornecedor)) { return false; } Fornecedor other = (Fornecedor) object; if ((this.cpf == null && other.cpf != nu...
f2cd6c1a-da4e-4d95-a838-c38b66598905
0
public TabStripperFileContentsHandler(int numOfTabs, String lineEnding) { super(lineEnding, false); setNumOfTabs(numOfTabs); }
7200020b-9ee0-487e-beee-094cb2960fef
1
public void visit_pop2(final Instruction inst) { stackHeight -= 2; if (stackHeight < minStackHeight) { minStackHeight = stackHeight; } }
574b1d50-72d1-49db-8fa1-da8b878c11ca
7
public boolean isInsideRectangle( int x, int y, int width, int height ) { boolean upper_left_corner = ( ( x < this.x && this.x < x + width ) && ( y < this.y && this.y < y + height ) ); boolean lower_right_corner = ( ( x < this.x + this.width && this.x + this.width < x + width ...
e54c3cbc-a6d6-41ab-bbfc-5efa33b216bb
6
@EventHandler public void movedOreGin(InventoryClickEvent event) { ItemStack cursorItem = event.getCursor(); ItemStack slotItem = event.getCurrentItem(); if (cursorItem.getType() == Material.DISPENSER) { if (slotItem.getType() == Material.DISPENSER) { if (oreGinMan.isOreGin(cursorItem) || oreGin...
40e5d7a8-0f17-4e40-8505-4e4d6b5c357e
4
public String getCurrentPuzzle() { String currentPuzzle = ""; int i = 0, j = 0; for(i = 0; i < 9; i++) { for(j = 0; j < 9; j++) { if(entries[i][j].isEditable()) { currentPuzzle = currentPuzzle +"E "; } else { currentPuzzle = currentPuzzle +"N "; } if(entries[i][j].ge...
48154619-48e4-4e93-825a-383b81a47fe7
9
public static void openURL(final String url) { try { //attempt to use Desktop library from JDK 1.6+ Class<?> d = Class.forName("java.awt.Desktop"); d.getDeclaredMethod("browse", new Class[]{java.net.URI.class}).invoke( d.getDeclaredMethod("getDesktop").invoke(null), ...
3230efe6-7d81-4f09-882c-9b275993b6bc
8
Matrix QRsolve(Matrix B, Matrix X, Transpose trans) { int nrhs = B.numColumns(); // Allocate temporary solution matrix DenseMatrix Xtmp = new DenseMatrix(Math.max(numRows, numColumns), nrhs); int M = trans == Transpose.NoTranspose ? numRows : numColumns; for (int j = 0; j < nrhs...
e4800dde-c393-4cec-8263-05fff6f7703a
2
private void swim(int i) { int t = pq[i]; // Save for later restoring while (i > 1 && greater(items[pq[i / 2]], items[t])) { pq[i] = pq[i / 2]; // half exchanges qp[pq[i / 2]] = i; // reverse index i /= 2; } pq[i] = t; // restore in the correct position qp[t] = i; // reverse index }
322df050-4fa8-421a-ab41-c0379094b94b
1
@Override public int hashCode() { int result = name.hashCode(); result = 31 * result + (elements != null ? elements.hashCode() : 0); return result; }
ab0517b8-1163-49c5-92e6-145ec13ab198
9
final int[][] method3047(int i, int i_2_) { if (i_2_ != -1564599039) method3150(true); anInt9468++; int[][] is = ((Class348_Sub40) this).aClass322_7033.method2557(-117, i); if (((Class322) ((Class348_Sub40) this).aClass322_7033).aBoolean4035) { int[][] is_3_ = this.method3039((byte) -88, i, 0); ...
e8ff3a0a-7a14-4446-9f70-2021ee2b9333
4
private void downloadAttachmentButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_downloadAttachmentButtonActionPerformed if (attachmentsComboBox.getSelectedItem() != null){ JFileChooser filechooser = new JFileChooser(); filechooser.setFileSelectionMode(JFileCho...
14778413-9834-404e-8917-c0a58507e64c
8
private void UpdateUI() { double monthlyCost = 0.00; double planCost = 0.00; double phoneCost = 0.00; double addOnCost = 0.00; double taxes = 0.00; double phoneCostFinal = 0.00; /* * look to see which radio buttons in each group are selected, then * check to see which/if any add-ons selected */ ...
f5296293-07ab-45ed-9bbd-c54df3f06bb3
0
public String getFood(){ return food; }
1643e3d7-5e32-467b-93e3-5705573ef00e
9
protected Node<T> getReplacementNode(Node<T> nodeToRemoved) { Node<T> replacement = null; if (nodeToRemoved.lesser != null && nodeToRemoved.greater == null) { // Using the less subtree replacement = nodeToRemoved.lesser; } else if (nodeToRemoved.greater != null && nodeToRemoved.lesser == null) { ...
202181e8-1cdc-459b-a96b-615d706098f6
9
public static void main(String[] args) { /* * input parameters: * 1.) algorithm type: which implementation * 2.) inputFile number * 3.) boundary: boundary for the generation (optional) * 4.) show result (optional) */ if (args.length < 1) { System.err.println("Missing Argument(s)! [algorithm-...
247a7f9c-18fa-48bc-bfb5-dd5217ad8290
8
public static Cons javaTranslateMethodCall(Cons tree) { { Symbol methodname = ((Symbol)(tree.rest.rest.value)); Surrogate classtype = ((Surrogate)(tree.rest.value)); Cons allargs = tree.rest.rest.rest; Stella_Object renamed_Object = tree.fourth(); if (methodname == Stella.SYM_STELLA_DEFINED...
7f5306f1-284a-4621-90a1-17847f11ca65
2
public static byte stringToByte(String str){ byte b = 0; if(str!=null){ try{ b = Byte.parseByte(str); }catch(Exception e){ } } return b; }
5468ebf9-ea3b-4207-a3fe-2c0b2160ba99
3
public static String createStateNameFromStatesList(List<String> states){ if(states.isEmpty()) return ""; String result = states.get(0); if(states.size() >= 2){ for(int i=1; i< states.size(); i++){ result += "|" + states.get(i); } } ...
36e89f79-eee1-4337-bd05-04ddb087cde1
7
@Override public MapConnector<String, Double> putAll(Map<? extends String, ? extends Double> map) throws Exception { String stm; try (Connection con = getConnectorInfo().getConnection()) { stm = getCreateTableTmp(getConnectorInfo().getTableName()); try (PreparedStatement prep...
e4129aad-1dea-4a15-9130-90c265f71342
7
public c.ty.Type refine(TypeDef typeCtx, MethodDef methodCtx) { if (genericArgs.length == 0) { if (methodCtx != null) { int index = methodCtx.genericParamIndex(rawType); if (index != -1) return new c.ty.MethodGenericType(index); } ...
b9af774e-3a5a-4823-a481-cdaaf73fdc07
5
protected SecretKey engineGenerateSecret(KeySpec spec) throws InvalidKeySpecException { if (!(spec instanceof PBEKeySpec)) { throw new InvalidKeySpecException("not a PBEKeySpec"); } IRandom kdf = PRNGFactory.getInstance("PBKDF2-"+macName); HashMap attr = new HashMap(); at...
379e5b7a-6269-443f-aefc-1941a0556820
3
private void init(){ m_cross = new ImageIcon(getClass().getResource( "Cross.png")); m_nought = new ImageIcon(getClass().getResource( "Nought.png")); m_crossWin = new ImageIcon(getClass().getResource( "CrossWin.png")); m_noughtWin = new ImageIcon(getClass().getResource( "NoughtWin.png")); m_bg...
a7c7c182-fbc2-4c16-aee9-7fa8c21f6e7a
5
public void create(TObject TObject) { if (TObject.getObjectFieldsList() == null) { TObject.setObjectFieldsList(new ArrayList<ObjectFields>()); } EntityManager em = null; try { em = getEntityManager(); em.getTransaction().begin(); List<Objec...
f0b22867-018d-43a5-b6c6-21d0b46127d3
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Delta other = (Delta) obj; if (original == null) { if (other.original != ...
2f4f40b3-cc47-4c66-b175-653089df6604
9
public String MenMan (){ if(elementos[0]<elementos[1]&&elementos[1]<elementos[2]&& elementos[2]<elementos[3]&&elementos[3]<elementos[4]&& elementos[4]<elementos[5]&&elementos[5]<elementos[6]&& elementos[6]<elementos[7]&&elementos[7]<elementos[8]&& elementos[8]<elem...
5179f201-aaac-4558-8ca9-1ddd4134b61c
9
private void writeValue(Object value) throws JSONException { if (value instanceof Number) { String string = JSONObject.numberToString((Number) value); int integer = this.values.find(string); if (integer != none) { write(2, 2); writeAndTick(inte...
b5e6436a-d9a0-490f-9e87-ef6ada2d47fb
7
public static DataSectionable constructDataSectionableForNonListObject(Class dataSectionableClass, Object object) { if (null == dataSectionableClass) throw new RuntimeException("dataSectionableClass is null."); if (object instanceof List) throw new RuntimeException("object is List."); ...
59141f50-b991-4a4c-9c09-d3e4a263be4b
4
public static void main(String[] args) throws IOException { if (args.length > 3) { System.err.println(USAGE_MESSAGE); System.exit(1); } FileInputStream in = new FileInputStream(args[1]); Test.copyStream(new ArithCodeInputStream(args.length < 2 ? System.in : new java.io.FileInputStream(args[1]), new...
46629c3d-8bcf-4c0a-b091-e21054dcc4b8
3
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String accessToken = (String) request.getSession().getAttribute( ACCESS_TOKEN); if (accessToken == null) { String instanceUrl = null; if (request.getRequestURI().endsWith("oauth")) { ...
4b37d966-2a53-4c61-90ca-c6e6ec6ea200
8
public void layPath(Node[][] map, int pathWidth) { Point pointer = new Point(start); int wanderCounter=20; while (pointer.x != end.x || pointer.y != end.y) { for (int px=0; px<pathWidth; px++) { for (int py=0; py<pathWidth; py++) { // if (!map[pointer.x+px][pointer.y+py].isRoom()) map[pointer.x+p...
410ec489-2129-41a7-9d3c-c706f1c1051b
2
public void run() { try { InputStream in = s.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line; while ((line = reader.readLine()) != null) { // at this point send out to all clients messages.add(line); // all threads use same List of messages }...
ebf91f6e-1ae8-4144-84c5-95801cde0b68
1
public String[] getKtivMale() { String[] arr = this.ktivMale.split(" או |,"); for (int i = 0; i < arr.length; i++) { arr[i] = arr[i].trim(); } return arr; }
c184915c-b039-402e-b73a-13774685627f
5
public void setName(String name) { Connection conn = null; PreparedStatement ps = null; try { conn = iConomy.getiCoDatabase().getConnection(); ps = conn.prepareStatement("UPDATE " + Constants.SQLTable + "_Banks SET name = ? WHERE id = ?"); ps.setString(1, name); ps.setInt(2, thi...
582bf015-329c-4449-be08-55c983789c58
7
private final void step6() { j = k; if (b[k] == 'e') { int a = m(); if (a > 1 || a == 1 && !cvc(k-1)) k--; } if (b[k] == 'l' && doublec(k) && m() > 1) k--; }
d9f3ce91-7e53-42ce-be6a-ec233ac65b62
2
public void act() { ArrayList<Actor> neighbors = new ArrayList<Actor>(getGrid().getNeighbors(getLocation())); for(Actor neighbor : neighbors) { if(neighbor instanceof Apple) { new ApplePie().putSelfInGrid(getGrid(), neighbor.getLocation()); } } move(); }
84b5f8cd-1fde-46f1-aeaf-c097eac94329
5
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(false); List<ReservatieMandjeItem> gelukteReservaties = new ArrayList<>(); List<ReservatieMandjeItem> mislukteReservaties = new ArrayList<>(); if (sessio...
98010083-ad89-411a-9753-5fb6fd12a618
9
@Override protected Class<? extends Attribute>[] computeValue(Class<?> clazz) { final Set<Class<? extends Attribute>> intfSet = new LinkedHashSet<>(); // find all interfaces that this attribute instance implements // and that extend the Attribute interface do { for (Class<?> curInter...
fb0c3110-ffbe-4dff-9ccb-f39c75d48661
7
public PluginDescriptionFile getPluginDescription(File file) throws InvalidDescriptionException { Validate.notNull(file, "File cannot be null"); JarFile jar = null; InputStream stream = null; try { jar = new JarFile(file); JarEntry entry = jar.getJarEntry(...
19f09f0d-3e5c-43c0-885e-748009c36602
5
public static int ntz3(long x) { // another implementation taken from Hackers Delight, extended to 64 bits // and converted to Java. // Many 32 bit ntz algorithms are at http://www.hackersdelight.org/HDcode/ntz.cc int n = 1; // do the first step as a long, all others as ints. int y = (int) x; if( y == 0 ...
2c9a4379-9964-4d0a-8f24-68ad92506a99
0
public void stop() { clip.stop(); }
850c5436-93c4-434c-9c01-338d9eda2685
8
public static <E extends Comparable<E>> int positionOfRotated(E[] array, E element) { if (array == null) return -1; int leftIndex = 0; int rightIndex = array.length - 1; int pivot; while (leftIndex <= rightIndex) { pivot = (rightIndex + leftIndex) / 2; if (element.compareTo(array[pivot]) ==...
fbe9fbaa-d761-4490-9211-33794b17ad8f
5
public void start() throws InterruptedException { Grid clone = initialGrid.clone(); clone.setOriginal(); stack.add(clone); for (int i = 0; i < threadsCount; i++) { threads[i] = new GridWorker(this, i); threadStates[i] = false; threads[i].start(); } while (!stopCalled) { boolean waiting = true;...
66a2fb0e-aa4b-4a21-b3f6-2b25627047e7
8
protected double[] svmlightToArray(String row) throws Exception { double[] result; StringTokenizer tok; int index; int max; String col; double value; // actual data try { // determine max index max = 0; tok = new StringTokenizer(row, " \t"); tok.nextToken(...
6f998712-3fdf-48a0-a799-86493d3f9735
9
private Object newBuffer(Object template) { if(template instanceof Object[]) return new Object [((Object[]) template).length] ; if(template instanceof byte[]) return new byte [((byte[]) template).length] ; if(template instanceof char[]) return new char [((char[]) template).length] ; ...
c261c1b9-810c-47aa-8629-cbf3f1e54b2e
4
public static HandRank omaha(Cards hand, Cards board) { // In Omaha we must use 2 cards from our hand HandRank best = null; List<Cards> boardSubsets = choose3(board); List<Cards> handSubsets = choose2(hand); for (Cards boardCards : boardSubsets) { for (Cards handCards...
e1402074-e058-43d3-af8c-9854e3524fbb
0
public void setEncoding(String value) { this.encoding = value; }
3afd1ce0-d227-4146-a0a7-1919e57e785f
3
@Override public void updateLong() { super.updateLong(); if(generationTimerEnd == 0) { resetGenerationTimer(); } if(generationTimerEnd <= System.currentTimeMillis() && this.isActivated()) { placeableManager.playerAddItem("Silver", 1); ...
aa1989a9-2033-4bab-8419-83d77edb5709
4
public double strategySpeed(double time) { double speed = 0.0; switch(carStatus){ case ACCELERATE: speed = tempSpeed + (acceleration*time); break; case DECELERATE: speed = tempSpeed - (acceleration*time); break; case STOP: speed = 0.0; break; case CONSTANT: speed = tempSpeed; break; ...
6aba9748-491f-4ba7-aa3e-3c7d42a47814
0
@Override public final boolean setDebug(boolean d) { return (debug = d); }
c08d7e35-81c8-4e1f-b488-ead3bb8173cc
2
public void goToFrame(int frameNum) { if (frameNum < 0 || frameNum >= frames.size()) { throw new IndexOutOfBoundsException(); } this.frameNum = frameNum; }
cd9d4230-7b3b-4562-8fb1-165a2c507742
3
public void addRow(List<Double> row) { if (row.size() != getNumCols()) { throw new MLException(String.format( "Cannot add a row with mismatching number of columns to matrix. Expected: %d, Got: %d", getNumCols(), row.size())); } for (Double valu...
72d90716-de4f-4d2c-9ad3-84bc837cdbd8
8
private static void addMod(ClassLoader var0, String var1) { try { String var2 = var1.split("\\.")[0]; if (var2.contains("$")) { return; } if (props.containsKey(var2) && (props.getProperty(var2).equalsIgnoreCase("no") || pr...
8d84fb83-1dfa-47da-b584-4545c940f29c
0
@Override public void startSetup(Attributes atts) { super.startSetup(atts); addActionListener(this); }
74ea51fa-8bc3-4bc3-a0b1-7c9fd03fbf88
4
public static String getColorDescription(int type) { String desc = ""; switch (type) { case HONG_TAO: desc = "r"; break; case FANG_PIAN: desc = "r"; break; case MEI_HUA: desc = "b"; break; case HEI_TAO: desc = "b"; break; } return desc; }
e4952e48-1f36-45e8-8979-56a8e40d816c
5
public String read(String chunk_uuid) { Socket client = null; try { client = new Socket(InetAddress.getLocalHost(), port);// 򱾻port˿ڷͻ }catch (IOException e) { // TODO Auto-generated catch block return "-1"; } ObjectOutputStream out = null; try {out = new ObjectOutputStream(client.getOutputStream(...
30aee89e-3016-4393-82b5-0a5315d795f3
6
@Override public void run () { try { while (true) { String s = In.readLine(); if (s == null || s.equals("@@@@end")) throw new IOException(); Dump.println("From Partner: " + s); if (s.startsWith("@@busy")) { T.append(Global.resourceString("____Server_is_busy____")); return; ...
659a92f3-c37b-4e15-ae89-f22a3bdda03a
0
public MapEditor() { }
be165638-f8d5-4fd0-90dd-6c6b7e5592ef
6
public void getBipartiteGraph(mxAnalysisGraph aGraph, int numVerticesGroup1, int numVerticesGroup2) { if (numVerticesGroup1 < 0 || numVerticesGroup2 < 0) { throw new IllegalArgumentException(); } int numVertices = numVerticesGroup1 + numVerticesGroup2; mxGraph graph = aGraph.getGraph(); Object parent =...
110e93b1-3e74-420d-b618-f75b9cfabaf1
1
public Production[] getNewProductions(String variable, Production[] oldProductions) { ArrayList list = new ArrayList(); for (int k = 0; k < oldProductions.length; k++) { list.add(new Production(variable, oldProductions[k].getRHS())); } return (Production[]) list.toArray(new Production[0]); }
37601266-639d-4892-af8a-b06728895d09
3
@Override public boolean isMine(String command) { Iterable<String> ans = Splitter.on(' ').omitEmptyStrings().split(command); arguments.clear(); CollectionUtils.addAll(arguments, ans.iterator()); if (arguments.get(0).equals(commandName)) { if (argumentNumber != 0 && argume...
dcc98ea3-eb38-4a77-a357-356c1028d8c2
3
public static void pointsSpent(String prestige, int ap){ pointsSpent += ap; //update the trees points spent for(ClassTree ct : takenPrestigeTrees){ if(ct.getPrestige().equalsIgnoreCase(prestige)) ct.spendAp(ap); } if(prestige.equalsIgnoreCase(characterRace)) racialTree.spendAp(ap); }
c4cbf78b-f5b0-4775-87d0-dff7fe7dfc64
5
private double rowAdd(Double[][] mat, int rowTo, int rowFrom, double scaleFactor) { List<Future> futures = new ArrayList<Future>(col); if (rowTo == rowFrom) return rowScale(mat[rowTo], scaleFactor + 1) + 0.0; for (int i = 0; i < mat[0].length; i++) { // mat[rowTo][i] = mat[rowTo][i] + mat[rowFrom][i] *...