method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
550546fd-606e-4168-88e1-bcee0549fe21 | 1 | private void buttonBreakActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonBreakActionPerformed
//Отменить создание новой программы
if (creditProgramTable.getSelectedRow() == -1) {
creditProgramTable.setRowSelectionInterval(0, 0);
textFieldName.setText("");
... |
9c0ec206-3ed7-4f87-bdf9-61bae82e4cef | 8 | private static float rateHaven(Object t, Actor actor, Class prefClass) {
//
// TODO: Don't pick anything too close by either. That'll be in a
// dangerous area.
if (! (t instanceof Boardable)) return -1 ;
if (! (t instanceof Venue)) return 1 ;
final Venue haven = (Venue) t ;
if (! haven.... |
aeea5156-08e4-42e2-93ef-12598295936f | 9 | public static void statReceive(Packet p) {
ClientStats s = getStats(p.getSender());
if (p instanceof KeepAlivePacket) {
// nothing?
return;
}
// route
else if (p instanceof UnicastDataPacket) {
if (p.getAddress() == c.src) {
if (c.currentTest == Client.SZENARIO.CLOSE_BY) {
s.nearRouteReceiv... |
395d1aab-c49d-46b5-959a-0d18bf78ca93 | 4 | private void AIteleport() {
int difference = (ball.getY() > paddle2.getY() ? ball.getY() - paddle2.getY() : paddle2.getY() - ball.getY());
if (ball.getX() > 900 && difference > 200) {
if (player2.useTeleport()) {
createTeleport();
}
}
} |
5f78a07b-40d7-4258-acb0-72a03761babd | 6 | public int computeLevenshteinDistance(String source, String target) {
source = source.toLowerCase();
target = target.toLowerCase();
int[] costs = new int[target.length() + 1];
for (int i = 0; i <= source.length(); i++) {
int lastValue = i;
for (int j = 0; j <= target.length(); j++) {
if (i == 0)
... |
ab67c037-4933-40a1-9717-a13a8d2fbd8d | 5 | private void btnGuardarClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarClienteActionPerformed
//Primero obtenemos los datos del cliente
//y las guardamos en las siguientes variables:
//Primero obtenemos los datos del cliente
//y las guardamos en las si... |
b2727e52-f238-41d6-9dab-7260b56dfd38 | 3 | @Override
protected Void doInBackground() throws Exception {
File destDirectory = new File(ConfigManager.getInstance().pathToJar);
if (!destDirectory.exists()) {
destDirectory.mkdirs();
}
try (ZipInputStream zipIn = new ZipInputStream(new FileInputStream(pack))) {
... |
1450529a-9844-4b6a-8987-88709267d9db | 2 | public double findSupport(ItemSet itemSupport) {
Timer timer = new Timer();
timer.startTimer();
double supportCount = 0;/*keep track of the count for support of an itemSet*/
int num = this.transactionSet.size();
for (int i = 0; i < num; i++) {
if (this.transactionSet.get(i).getTransaction().containsItemSe... |
8c3d103c-884f-4ce6-8567-445e364950df | 3 | public void accept(Visitor visitor) {
if (visitor.visit(this)) {
if (_frel != null) {
_frel.accept(visitor, true);
}
if (_mrel != null) {
_mrel.accept(visitor, false);
}
super.visitContainedObjects(visitor);
visitor.endVisit(this);
... |
259ce043-8ee5-4d29-a6ca-e08f4329f8b2 | 4 | @Override
public boolean isValid()
{
boolean isValid = this.executableName != null && !this.executableName.isEmpty() && this.executableClientPath != null && !this.executableClientPath.isEmpty();
if(!isValid)
{
this.arguments.clear();
this.resultFiles.clear();
//TODO: cleanup
//Do clean up if req... |
0137812b-9221-470e-8755-80ecfb0f3275 | 5 | protected static Ptg calcLeftB( Ptg[] operands )
{
WorkBook bk = operands[0].getParentRec().getWorkBook();
if( bk.defaultLanguageIsDBCS() )
{// otherwise just returns normal string
int numchars = 1;
if( operands.length < 1 )
{
return new PtgErr( PtgErr.ERROR_VALUE );
}
if( operands.length == 2... |
0b4ef2f7-7199-496b-9a13-08c046e35984 | 4 | public File showRawSaveDialog()
{
JFileChooser fc = new JFileChooser();
if (filePath != null)
fc.setCurrentDirectory(filePath);
FileFilter filter= new FileNameExtensionFilter("Text file", "txt");
fc.addChoosableFileFilter(filter);
if (fc.showSaveDialog(this.frmOpenaltimeter) == JFileChooser.APPROVE_OPTION... |
4a40e2c4-8814-4963-ab2e-0b1dabd4f858 | 0 | @Test
public void test() throws IOException {
String cd= new File(".").getCanonicalPath();
String pkg = "/src/test/java/part2/lecture/week3/radixsort/";
String file = "M42643801.txt";
Path path = Paths.get(cd + pkg + file);
StringBuilder prime = new StringBuilder();
Stream<String> lines = Files.lines... |
2c70c3f2-388e-4f0e-afff-9bd6fcbe66e6 | 8 | private void computeAverageClassValues() {
double totalCounts, sum;
Instance instance;
double [] counts;
double [][] avgClassValues = new double[getInputFormat().numAttributes()][0];
m_Indices = new int[getInputFormat().numAttributes()][0];
for (int j = 0; j < getInputFormat().numAttributes();... |
b0e3db3d-0f92-4869-b89c-acaac46e40c1 | 0 | @Override
public void setCountry(String c) {
super.setCountry(c);
} |
7d2e82db-0209-46b0-b990-800649c08627 | 1 | public Playground(){
anzahlPlayer = 2;
//Spielfeldelemente in einer Array List (Zacken)
field = new ArrayList<LinkedList<Steinchen>>(24);
//Fuer jeden Spieler eine LinkedList
playerList = new LinkedList<Player>();
//Player zur LinkedList hinzufuegen
for(int i=0; i<2; i++){
playerList.add(ne... |
0c1d3199-8652-4601-ade1-42f78a9e0858 | 2 | private void addRowToTable(List<UserDTO> usersList) {
for (UserDTO user : usersList) {
if (user.getUserGame() != null) {
tableModel.addRow(user.toArray());
} else {
tableModel.addRow(user.toArrayOnlyUser());
}
}
} |
55463b35-a0a9-4b50-8c89-15b574ac17f3 | 0 | public void setPoints(int points) {
this.points = points;
} |
10f8a40c-d563-4839-b805-578053bd1013 | 6 | public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://down... |
6cb576d0-5da0-4220-a75b-e31d3decfce7 | 2 | public void run() {
// keep going as long as the thread is alive
while (!gameOver2) {
try {
// speed of game - larger number makes game slower
Thread.sleep(19);
} catch (InterruptedException e) {
e.printStackTrace();
}
repaint();
}
} |
ac5fe3d1-00f8-4793-b10d-d26b1599b61f | 4 | @WebMethod(operationName = "updateOrderStatus")
public void updateOrderStatus(String orderNumber,String status) throws Exception {
CompraDAOImpl dao = new CompraDAOImpl();
if("".equals(orderNumber))
throw new Exception();
if("".equals(status))
throw new Exce... |
8cf6b2b7-5148-4275-9b9b-a685f52872a7 | 6 | public void ajoutClasse()
{
JFileChooser fc = new JFileChooser("./jars/classespersonnages");
int returnVal = fc.showOpenDialog(this);
if(returnVal == JFileChooser.APPROVE_OPTION)
{
File file = fc.getSelectedFile();
try
{
IClassePers... |
0ef72437-bd58-4b95-85c3-fb0271bde677 | 8 | @Override
public char[] getBuffer() {
if (lastOverflowSize == overflowSize && buffer != null) {
return buffer;
}
if (buffer == null) {
if (reader == null) {
throw new SourceAccessException("Reader is not specified, source: " + sourceName);
... |
8964a920-74f6-415c-b96e-93b005fb58ee | 3 | public static int getEnhancementPointsSpent(String prestige, int id){
for(ClassTree ct : takenPrestigeTrees){
if(ct.getPrestige().equalsIgnoreCase(prestige))
return ct.getEnhancement(id).pointsSpent();
}
if(prestige.equalsIgnoreCase(characterRace))
return racialTree.getEnhancement(id).pointsSpent();
... |
b04c2af2-1c3c-426e-9467-387b82c048d7 | 8 | public boolean stem() {
int v_1;
int v_2;
int v_3;
int v_4;
// (, line 64
// do, line 66
v_1 = cursor;
lab0: do {
// call mark_regions, line 66
if (!r_mark_regions()) {
break lab0;
}
} while (false);
cursor = v_1;
// backwards, line 67
limit_backward = cursor;
cursor = limit;
//... |
aad24c50-8ecc-4de8-ac6e-e512c36700ba | 5 | public static void command(String command){
boolean err = false;
try{
Process process = new ProcessBuilder(command.split(" ")).start();
BufferedReader results = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String s;
ArrayList<String> res = new ArrayList<String>();
ArrayList<St... |
e8a3d093-9b95-416d-b6f5-4bd8db795107 | 0 | public String getRead(int tape) {
return (String) toRead.get(tape);
} |
0c83d70b-83e1-482d-afc6-e90cebc70a3b | 5 | public static void generateParentheses(int left, int right, String s, List<String> res) {
if (left == 0 && right == 0) {res.add(s); return;}
if (left > right) return;
if (left > 0) generateParentheses(left - 1, right, s + "(", res);
if (right > 0) generateParentheses(left, right - 1, s + ")", res);
... |
12a22847-75c6-4034-9b87-ebebca52e1c6 | 9 | private void parseCSV(CSVReader reader, int type, int level) {
String[] nextLine;
String value;
int i = 0, j;
try {
while ((nextLine = reader.readNext()) != null) {
for (j = 0; j < nextLine.length; j++) {
value = nextLine[j].replaceAll(" ", "");
switch(type) {
case LAYER:
if ... |
84b468f7-8dbe-4086-b0d0-3a4d08f11b78 | 9 | private void processFile() {
int lineNumber = 0;
log.trace("Hosts: " + this.client.getNodeNames());
long start = System.currentTimeMillis();
try{
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(this.fileName), "UTF8"));
log.debug("Reading file: " + Utils.getFileName(fi... |
d39bfd5f-7827-4eec-bb82-123dd7b8dcff | 1 | public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new Controller();
}
});
} |
6e1a753e-3cde-4d59-ade7-c0558d40f08a | 6 | Startup(boolean guion) {
IP ipp = new IP();
this.ip = ipp.getIP();
enable_gui = guion;
gui = new GUI(this,enable_gui);
config = new Config("serverConfig", "Server");
filef = new File(config.getProperty("IRCFileFolder"));
serverbots.add(new ServerBot(this,"bot"));
gui.addLogLine(... |
3bb94327-2b0e-4932-99ba-0a737627dfa1 | 4 | public Map<String, UUID> call() throws Exception {
Map<String, UUID> uuidMap = new HashMap<String, UUID>();
int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
for (int i = 0; i < requests; i++) {
HttpURLConnection connection = createConnection();
String
body =
... |
bbccf6ff-903e-4a6b-9788-9dd82414cda8 | 8 | public void map(Text key, Text value, OutputCollector<IntArray,FloatArray> output, Reporter reporter) throws IOException {
//System.out.println("Key: " + key.toString());
//System.out.println("Value: " + value.toString());
String[] vals1 = key.toString().split("\\s+");
String[] vals2 = value.toString().split("... |
3faf23b7-9284-4c10-9e1a-6e44529bc5a3 | 4 | public void mouseClick(Point p){
if(headingLbl.getBounds() == null){
return;
}
if(refreshBtn.getLabel().getBounds().contains(p)){
statue.setTitle((String) titles.randomItem());
statue.setSurname((String) surnames.randomItem());
statue.setLastname((String) lastnames.randomItem());
statue.setEndin... |
e00e9924-20c1-4a8d-96c4-90c3b15419b3 | 4 | @Override
protected void process() {
super.process();
Actor actor = ai.getActor();
Player player = registry.getPlayerManager().getPlayerById(target);
if(actor == null || player == null) {
return;
}
int actorX = actor.get... |
e1b4689f-3ce6-4f3c-97e9-4f4e354e0de4 | 0 | public void setIsGesture(boolean isGesture) {
this.isGesture = isGesture;
} |
b7b77fe0-ca28-497e-bf48-f60a29a611a9 | 3 | public static void main(String[] args){
JFrame frame = new JFrame(TITLE);
frame.pack();
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
UIController controller = new UIController(frame, MAX_PLAYERS);
//experimental stuff & easter egg
boolean sound = false, christmas = f... |
cfe14031-8650-4c59-bff6-5a54a796671c | 8 | @Override
public List<Map<String, ?>> List_Paso_Habilitado(String Proceso) {
List<Map<String, ?>> lista = new ArrayList<Map<String, ?>>();
try {
this.conn = FactoryConnectionDB.open(FactoryConnectionDB.ORACLE);
String sql = "select * from rhtc_pasos where es_pasos='1' ";
... |
0f804212-f1ee-47f6-a0a6-5268637c375f | 0 | public static void helpUser() {
System.out.println("commands:");
System.out.println("help");
System.out.println("list");
System.out.println("add [6 characters]");
System.out.println("remove [6 characters]");
System.out.println("compare [characters] [characters]");
System.out.println("retrieve [6 character... |
5c52666a-d7a5-44b5-b3b8-f949adcf337f | 0 | public static boolean isApplicable(Object object) {
return object instanceof Automaton;
} |
6dc1709c-2925-4bb4-814b-9e0426ab1956 | 2 | public void InsertFinvizData (List<String> FinvizReturn){
//construct map
Date now = new Date();
DateFormat DatePart = new SimpleDateFormat("yyyy-MM-dd");
DateFormat TimePart = new SimpleDateFormat("HH:mm:ss");
String datestr = DatePart.format(now);
String timestr = TimeP... |
e38f494c-d0d1-4188-97a6-889faf875142 | 3 | public static String lettertonumber(String code, int start) {
char[] codeline = code.toCharArray();
String result = "";
for(char element : codeline) {
if(Character.toLowerCase(element) >= 'a' && Character.toLowerCase(element) <= 'z')
result += (Character.toLowerCase(e... |
a3481ebf-a495-4e7b-9452-b1163d1dd867 | 4 | public static double[] selectionSort(double numbers[], String order) {
double temp;
for (int i = 0; i < numbers.length; i++) {
for (int j = i + 1; j < (numbers.length); j++) {
if (order.equalsIgnoreCase("asc") ? numbers[i] > numbers[j] : numbers[i] < numbers[j]) {
... |
990712fe-fca5-454e-b4ca-0e67ec78efbb | 2 | private int readIdentifier(int c, Token token) {
StringBuffer tbuf = textBuffer;
tbuf.setLength(0);
do {
tbuf.append((char)c);
c = getc();
} while (Character.isJavaIdentifierPart((char)c));
ungetc(c);
String name = tbuf.toString();
int t... |
5c30656b-5f29-4901-959f-a91fe4b9b836 | 7 | @Override
public void handlePacket(Player player, Packet packet) {
switch (packet.getOpcode()) {
case ATTACK:
handleNpcAttack(player, packet);
break;
case FIRST_CLICK:
handleFirstClick(player, packet);
break;
case SECOND_CLICK:
handleSecondClick(player, packet);
break;
case THIRD_CLICK:
... |
99cd8df3-9f84-460a-bd83-42f878dbc27a | 1 | public Object invoke(Invocation invocation) {
try {
Object bean = invocation.getBean();
Method method = invocation.getMethod();
Object[] args = invocation.getArgs();
return method.invoke(bean, args);
} catch (Exception e) {
/*
* An exce... |
e9c44e1f-b7a0-4750-b82b-b0db4007eb66 | 4 | @Override
@SuppressWarnings("unchecked")
public void distributePacket(int id, final byte[] data, IIOHandler sender) {
APacket p = IMH.getPacketRegistrie().getNewPacketOfID(id);
log.fine("Distributing Packet\nID:" + id + "\nClass:" + p.getClass());
log.fine("Incoming Packet with " + data.length + " bytes!" + S... |
2e1beab7-4c30-40b6-a89a-8178dc41c853 | 5 | private final static List<File> getFiles(File dir, List<File> files)
throws MasterException {
if(dir == null)
throw new MasterException("The directory is null");
if (files == null)
files = new LinkedList<File>();
if(dir.isDirectory() == false) {
if(dir.getName().toLowerCase... |
456aaa83-8228-4a9c-a503-35ed7ccff339 | 1 | private ArrayList<Role> getParts(String Declaration) {
// TODO Auto-generated method stub
ArrayList<Role> arrayrole = new ArrayList();
StringTokenizer st = new StringTokenizer(Declaration, ",");
while(st.hasMoreElements()){
String roleid = st.nextToken();
StringTokenizer sttemp = new StringTokenizer(rolei... |
24a4b182-1a0f-42eb-aa46-4bdaf2c7d1c1 | 8 | private PhoneId initPhoneIdParams() {
if(CUSTOMER_ID.isEmpty() || SECRET_KEY.isEmpty()) {
fail("CUSTOMER_ID and SECRET_KEY must be set to pass this test");
}
PhoneId pid;
if(!timeouts && !isHttpsProtocolSet)
pid = new PhoneId(CUSTOMER_ID, SECRET_KEY);
else if(timeouts && !isHttpsProtocolSet)
pi... |
02c0b5e1-305e-446f-a2ba-914e48bb2575 | 4 | public void mousePressed(int button,int x,int y){
if(xpos >= Button.GAME_WIDTH/2-backWidth/2 && xpos <= Button.GAME_WIDTH/2+backWidth/2 ){
if(ypos >= Button.GAME_HEIGHT-200 && ypos <= Button.GAME_HEIGHT-200+backHeight){
mousePress = true;
}
}
} |
3321b1bd-cfc0-4a80-80e2-2e627c2d46c8 | 3 | public int search(String value) {
if (reversed) {
reverse();
}
int i = 1;
Element tmp = firstElement;
while (tmp != null) {
if (tmp.getValue().equals(value)) {
return i;
}
tmp = tmp.getNextElement();
i++;... |
9df83521-0cd8-4be6-b6b2-88cf9547bd17 | 1 | public static String stripLeadingBlanks(final String string) {
//// Preconditons
if (string == null)
throw new InvalidParameterException("string cannot be null");
return stripLeading(string, ' ');
} |
26ba8bdd-c8ae-4131-86a7-5efa97b8f3bb | 6 | public Document toDOM(Serializable structure)
{
ContextFreePumpingLemma pl = (ContextFreePumpingLemma)structure;
Document doc = newEmptyDocument();
Element elem = doc.getDocumentElement();
elem.appendChild(createElement(doc, LEMMA_NAME, null, pl.getTitle()));
elem.appendChil... |
467f7b78-bf12-4872-927f-c9645dcdbd03 | 1 | @Override
public Period deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException
{
String textValue = jsonParser.getText();
try
{
return new Period(textValue);
}
catch (Throwable throwable)
... |
541de5b2-00b9-454c-b1ef-7330a3511a42 | 3 | private void setButtonsEnabled(boolean enabled) {
for(int i=0;i<3;i++)
for(int j=0;j<3;j++) {
buttons[i][j].setEnabled(enabled);
if(enabled) buttons[i][j].setText(" ");
}
} |
c9d68803-cd58-4b5c-b2c4-45e0b57e0011 | 8 | public void play(){
/*
Just play function. Play until game end. Determines who is the first player, gives him first turn.
*/
do {
if (!endGame) {
if (computerFirst) {
computer.computerTurn();
show();
... |
416326a0-112f-45e0-ab2b-2110b91c0b3b | 6 | private void printlnNodeWithNumberAndLabel(PrintWriter out, JadeNode node,
int level) {
for (int i = 0; i < level - 1; i++) {
if (umbrella[i]) {
putCharAtLevel(out, i, '|');
} else {
putCharAtLevel(out, i, ' ');
}
}
putCharAtLevel(out, level - 1, '+');
int branchNumber;
if (node.is... |
8758105b-8a72-405d-97b8-3315ea8d0ec9 | 1 | public void displayPlayer(String name, String number) {
TeamMember player = findPlayer(name, number, nullPlayer);
if (player != nullPlayer){
leagueMemberPrinter.print("", player);
} else {
leagueMemberPrinter.playerNotFound(name, number);
}
} |
32b3baaa-3fe8-49a2-92df-39cc3cb5dda5 | 5 | private void setYAxis(int type) {
switch (type) {
case BookData.TITLE:
yAxisLabel = searchMatch.getTitleAxis();
return;
case BookData.AUTHOR:
yAxisLabel = searchMatch.getAuthorAxis();
return;
case BookData.PAGES:
yAxisLabel = searchMatch.getPageAxis();
return;
case BookData.YEAR:
yAxisLab... |
e1974499-2a03-45c5-a0b2-4c4ebb0e8bb8 | 1 | public String mapFieldName(String owner, String name, String desc) {
String s = map(owner + '.' + name);
return s == null ? name : s;
} |
b8313982-7b0b-41e8-9dc8-b7bfab33d27a | 2 | public void reverseGroup(ListNode preNode, int k) {
ListNode tail = preNode.next;
ListNode previous = preNode;
ListNode current = preNode.next;
ListNode next = preNode.next.next;
for (int i = 0; i < k; i++) {
current.next = previous;
previous = current;
... |
42b7e4c8-e7d4-48b7-aef9-9b9d61aac4c9 | 5 | @Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((change == null) ? 0 : change.hashCode());
result = prime * result
+ ((includes == null) ? 0 : includes.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * r... |
86cfbc75-99c7-4a43-a6d6-487d002a2b43 | 8 | public static List<String> allTags(int imgId) {
PreparedStatement stmt = null;
Connection conn = null;
ResultSet rs = null;
List<String> tags = new ArrayList<String>();
try {
conn = DbConnection.getConnection();
stmt = conn.prepareStatement(ALL_TAGS_STMT);
stmt.setInt(1, imgId);
rs = stmt.... |
f22f47ee-a190-47ad-ab97-419e803dc978 | 5 | static private int jjMoveStringLiteralDfa5_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(3, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(4, active0);
return 5;
}
switch(curChar)
{
cas... |
9952be92-41e6-4820-bd0e-d111f3cf755d | 0 | public Grille(int longueur, int hauteur, RuleSet ruleSet) {
grid = new boolean[longueur][hauteur];
this.ruleSet = ruleSet;
} |
81c8cfe3-3ced-4820-a1de-24266d1b55ab | 6 | public static int findSmallestMultiple(int n) {
int[] gcfAll = new int[n+1];
// populate greatest common factor arrays
int[] gcfThis = null;
for (int i = 2; i <= n; i++) {
gcfThis = getPrimeExp(i);
for (int j = 2; j <= i; j++) {
if (gcfThis[j] > 0 && gcfThis[j] > gcfAll[j]) {
... |
81654eff-4923-46d4-8185-208d518d9194 | 3 | private int readStringLength(InputStream inputStream) throws IOException, InvalidFormatException {
StringBuilder stringBuilder = new StringBuilder();
int currentByte;
while ((currentByte = inputStream.read()) > -1) {
char currentChar = (char) currentByte;
if (currentChar ... |
ac0ca108-e6cd-400f-a171-65142e7fff3e | 4 | private boolean IsCollision(Map map){
int ruptile = map.getrightUptiletype(x - 9, y);
int rdowntile = map.getrightDowntiletype(x - 9, y - 9);
int luptile = map.getleftUptiletype(x, y);
int ldowntile = map.getleftDowntiletype(x, y - 9);
if(ruptile != 0 || rdowntile != 0 || luptile != 0 || ldowntile != 0)
... |
f246dc67-600a-4564-a2fa-419d61e7d300 | 1 | private void run() throws Throwable {
URL inputURL = new URL("jar:file:./input.jar!/");
if (!new File("./input.jar").exists()) {
throw new RuntimeException("Could not locate \"input.jar\"!");
}
List<Transformer> transformers = new LinkedList<Transformer>();
transformers.add(new ClassNameDeobfuscator());
... |
8334402d-77d2-447d-8976-811aab6dbb37 | 7 | private static void merge(int[] a, int[] aux, int lo, int mid, int hi)
{
// DK: add two tests to first verify "mid" and "hi" are in range
if (mid >= a.length) return;
if (hi > a.length) hi = a.length;
int i = lo, j = mid;
for (int k = lo; k < hi; k++) {
if (i == mid) a... |
fb660f11-3fa0-4d98-b7fa-8c9ecebf7377 | 6 | private static void lineMean (int radius, float[] cache, float[] pixels, int writeFrom, int writeTo,
int pixel0, int pointInc) {
double sum = 0;
double factor = 1./(1 + 2*radius);
int length = cache.length;
float first = cache[0];
float last = cache[length-1];
... |
cb0f9f83-a070-4f4e-8d6a-060551fb93f9 | 5 | public static void main(String[] args) {
// Test for Block
/*
Pixel values
49 61 69 61 78 89 100 112
68 60 51 42 62 69 80 89
90 81 58 49 69 72 68 69
100 91 79 72 69 68 59 58
111 100 101 91 82 71 59 49
131 119 120 102 90 90 81 ... |
c25dffcf-a096-41da-bde1-e3109f0a248d | 0 | public int getAge() {
return Age;
} |
39375548-cbc0-4ad2-a401-bdf8e536ecf7 | 1 | @Override
public boolean isDiagonalObstacle(Element elementPassingThrough, Element otherDiagonalElement) {
if (otherDiagonalElement instanceof ForceField)
return false;
return true;
} |
6e53b6f2-5b83-4d97-8efd-20792cf89463 | 8 | private void updateLabels() {
int size = robots.size(), first = selectedRobot == null? 0:selectedRobot.ordinal();
Robot active = null;
for(int i = first; i < first + size; i++) {
Robot r = robots.get(i % size);
if(!r.isCharging()) {
active = r;
... |
4b96f751-bd4b-4fbf-8d57-33f80e4db9eb | 3 | public boolean isAcyclicGraph() {
int size = graph.getVertices().size();
for (int i = 0; i < size; i++) {
if (visited[i] == 0 && dfs(i, i)) {
return false;
}
}
return true;
} |
652cb1b3-d68a-48e8-a57e-0609e2b0499a | 3 | public static void driver() throws InvalidFieldException {
// Instantiate a new GameData object with 6 test contestants.
GameData g = new GameData(NUM_TEST_CONTESTANTS);
// Instantiate valid tribe names for the game.
g.setTribeNames(TEST_TRIBE_ONE, TEST_TRIBE_TWO);
// Strings to be used to compose test Con... |
d4ce6b0c-d32a-4318-878a-8a8daf93205b | 8 | public int firstMissingPositive(int[] A) {
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
int N = 0;
for (int i = 0; i < A.length; ++i) {
if (A[i] > 0) {
A[N++] = A[i];
}
}
for (int i = 0; i < N; ++i) {
int trial = A[... |
57537d58-f83b-46d1-88b8-196f904fdae1 | 4 | void NewickPrintTrinaryTree( PrintStream out ) throws Exception
{
edge f;
f = root.leftEdge;
out.write('(');
if ( null != f )
{
NewickPrintSubtree( f,out );
out.write(',');
}
f = root.rightEdge;
if ( null != f )
{
NewickPrintSubtree( f, out );
out.write(',');
}
f = root.m... |
957b446e-f657-49f8-b01a-71f5abc9556a | 2 | public static AbstractItem getItem(int uniqueID){
if (uniqueID <= items.size() && items.get(uniqueID) != null){
return items.get(uniqueID);
} else {
System.out.println("Tried to access an ID not bound to an Item");
System.out.println(String.valueOf(uniqueID));
return items.get(0);
}
//return null... |
07c919b9-fa32-4376-bf95-6eee47c571c6 | 9 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
final int type=mob.location().domainType();
if(((type&Room.INDOORS)>0)
||(type==Room.DOMAIN_OUTDOORS_AIR)
||(type==Room.DOMAIN_OUTDOORS_CITY)
||(type==Room.DOMAIN_OUTDOORS_SPACEPORT)
||(... |
d44f4a42-5e2f-41a2-a6e5-2ed4d001bdf9 | 3 | public ImagePlus segment(String path){
InputImage input;
try{
input = new InputImage(path);
} catch (FileNotFoundException e){
return null;
}
ImageProcessor origImg = input.getOrig().getProcessor();
ImageProcessor adjustedImg = input.getAdjusted().getProcessor();
int width = origImg.getWidth();
in... |
7c201860-ba26-4623-9f5c-b9cf826c5245 | 0 | public static void main(String[] args) {
MemberDAO memberDAO = new MemberDAO();
Member m = memberDAO.findById(6);
//Member m = new Member("周", "1345612", "asdfj@163.com");
//memberDAO.save(m);
m.setUsername("小明");
memberDAO.attachDirty(m);
System.out.println(m.toString());
} |
3607ca1c-43a4-48c4-9188-bb6a8ca3efc6 | 9 | @SuppressWarnings("rawtypes")
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final Pair other = (Pair) obj;
if (a == null) {
if (other.a != null)
return false;
} else if (!a.equals(o... |
17d93a21-0e33-4dc2-aa17-5d8ea2c59838 | 7 | public boolean move(double newX, double newY){
if(!level.getCollisionManager().collision(newX, newY, pushBox)){
if(time % 60 == 0)previous.set(position.getX(), position.getY());
position.set(newX, newY);
time++;
if(time == 60){
//walk.play();
time = 0;
}
return true;
}else if(!level.ge... |
41477ce0-5265-46a0-bf53-704350cd4d1b | 1 | @Override
//public int getDistribution(double standardDeviation)
public int getDistribution()
{
Random rnd = new Random(SEED);
inputbuffersize = rnd.nextInt(NumberOfPackets+1);
//keeps track of packets created
int PacketCounter = 0;
... |
573ba6da-8dff-49ae-8dca-90271c9d1065 | 9 | @Override
public void sample(int maxIter, int seedSize) {
// reset sampling parameter
totalVisitCount = 0;
pogVisitCount.clear();
long time = System.currentTimeMillis();
System.out.println("Sampling: log scale + no qij");
// generate any frequent pattern
PogN... |
984324f9-068c-428c-8f90-ab7dff1b5459 | 5 | public void merge2(int[] left, int[] right, int[] arr){
int leftSize=left.length;
int rightSize=right.length;
int i=0,j=0,k=0;
while(i<leftSize && j<rightSize){
if(left[i]<=right[j]){
arr[k]=left[i];
i++;
k++;
}else{
arr[k]=right[j];
j++;
k++;
}
}
while(i<leftSize ){
... |
0fade7ab-5e71-4101-a765-7cb5d595b49b | 6 | public HashMap getValues(String query) throws SQLException
{
Connection connection = null;
Statement statement = null;
ResultSet result = null;
String val1 = "";
String val2 = "";
HashMap value = new HashMap();
try
{
Class.forName(driver);
connection = DriverManager.getConnection(url, username,... |
c483ff54-42d7-4982-97ff-4baadb61e9f5 | 1 | public String getProperty(String key) {
if (!configuration.containsKey(key))
return null;
return configuration.get(key);
} |
04432269-0288-4270-860a-19d3c3ce8f42 | 1 | public static void decrypt(int[] value, int[] key) {
final int num_rounds = 16;
int delta = 0x9E3779B9;
int sum = delta * num_rounds;
for (int i = 0; i < num_rounds; i++) {
value[1] -= (((value[0] << 4) ^ (value[0] >> 5)) + value[0]) ^ (sum + key[(sum >> 11) & 3]);
sum -= delta;
value[0] -= (((value[1]... |
59769f3a-12b3-4850-8b6d-b467e17c1ab5 | 3 | public void StartItems() {
Item gameItem1 = new Item(0);
gameItem1.setName("Map");
gameItem1.setDesc("A Map to help you through the lair");
Item gameItem2 = new Item(1);
gameItem2.setName("Broom");
gameItem2.setDesc("A really cool broom to have, this one can fly");
Item gameItem3 = new Item(2);
gameI... |
84e025ff-a123-43b0-80c4-219a292c98c4 | 1 | public void test_appendOptional_nullParser() {
try {
DateTimeFormatterBuilder bld2 = new DateTimeFormatterBuilder();
bld2.appendOptional((DateTimeParser) null);
fail();
} catch (IllegalArgumentException ex) {
// expected
}
} |
cf05bf71-74a0-4578-92c6-e40216c047de | 2 | public Id addOrComplete(State element) {
for (State actual : states) {
if (actual.isSameElementAs(element)) {
actual.completeWith(element);
return actual.getId();
}
}
// still there? one doesn't find it, so let's create it
Id id = ... |
f93b95d3-45bc-4477-b7b0-34360cf2a96f | 1 | @Override
public void main() {
cleanOutput();
final StateContext sc = new StateContext();
for (int i = 0; i < 10; i++) {
sc.writeName("Name" + i);
}
super.main("State");
} |
9ee4c497-5835-4828-bac2-699a86441e6f | 6 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
NegationNode other = (NegationNode) obj;
if (node == null) {
if (other.no... |
473ed8a5-1f3b-4d86-8e6d-11ea60270685 | 1 | public static String tankString(Tank t){
String tankString =
t.getId()+","
+t.getName()+","
+t.getX()+","
+t.getY()+","
+dirString(t.getLastDir())+","
+booleanString(t.isAlive())+","
+t.getHp()+","
+t.getCx()+","
+t.getCy()+","
+t.getCwidth()+","
... |
cd5468c6-d9ce-49a1-b8e2-eaa4af090034 | 6 | private void sortMonsters(int low, int high)
{
int i = low;
int j = high;
Monster pivot = monsters.get(low + (high-low)/2);
float pivotDistance = pivot.getTransform().getPosition().sub(Transform.getCamera().getPos()).length();
while (i <= j)
{
while (monsters.get(i).getTransform().getPosition().su... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.