method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
a7608814-ced8-4166-9055-7219af2b8845 | 5 | public Object showInfoList(String listName, String conditions) {
String cmd = "show;" + listName + ";" + conditions;
ArrayList<String> list = null;
String[][] content = null;
try {
NetService client = initNetService();
client.sendCommand(cmd);
list = client.receiveList();
client.shutDownConnection()... |
8e965a6f-9fea-4e83-b02e-25ac08c900cc | 8 | @Override
public String toString() {
if (Left != null && Right != null)
return MessageFormat.format("{0} {1} {2}", Left, Verb, Right);
if (LeftDual != null && Right != null)
return MessageFormat.format("{0} {1} {2}", LeftDual, Verb, Right);
if (Left != null && Right... |
2552bf1e-c0fc-4569-a2a1-430d01e03cb8 | 7 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Map other = (Map) obj;
if (this.row != other.row) {
return false;
}
if (this.... |
788a4595-19b0-49c9-8cb4-06bb1f44d5bc | 0 | public void setFechaCreacion(Timestamp fechaCreacion) {
this.fechaCreacion = fechaCreacion;
} |
1299ab96-55ed-4867-b58e-31c4b358e3cf | 3 | public boolean performShot(){
Debug.game("'" + dealingPlayer.username + "' performing mortar shot at '"
+ relativeTargetVector.getString() + "'");
int range = 2;
int baseDamage = 20;
if(level == 2) {baseDamage = 20; range = 3;}
if(level == 3) {baseDamage = 25; range = 4;}
int damage = (int)Math.round(baseDa... |
f3ac8e1e-288f-40fe-bca8-b8e108037418 | 5 | protected String getEdgeId(Object edge)
{
mxGraphView view = graph.getView();
mxCellState state = view.getState(edge);
Object src = (state != null) ? state.getVisibleTerminal(true) : view
.getVisibleTerminal(edge, true);
Object trg = (state != null) ? state.getVisibleTerminal(false) : view
.getVisibleT... |
070e638e-5ef2-4ade-a550-859be0036135 | 6 | private void initUserlistImageMenu(Color bg) {
this.userlistImageMenu = new JPanel();
this.userlistImageMenu.setBackground(bg);
this.userlistImageMenu.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
// size
int[] size = new int[] { this.skin.getUserlistImageWidth(), this.... |
9dbe4c45-f672-44ce-ac3f-d30db36de261 | 6 | public ObjectDefinition child(IClientContext ctx) {
int index = 0;
if (scriptId == -1) {
index = configId != -1 ? ctx.varpbits.varpbit(configId) : -1;
} else {
final Script script = ctx.definitions.varp(scriptId);
if (script != null) {
index = ctx.varpbits.varpbit(script.configId) >> script.lowerBitI... |
2cbb0c20-b1b3-4f4f-bcbf-00e3276d62de | 9 | public boolean skipPast(String to) throws JSONException {
boolean b;
char c;
int i;
int j;
int offset = 0;
int length = to.length();
char[] circle = new char[length];
/*
* First fill the circle buffer with as many characters as are in the
... |
48a5f0c6-582c-48ea-8884-7bad7a326644 | 2 | public void update() {
if(Keyboard.isPressed(getKey())) {
setPressed(true);
setReleased(false);
} else {
if(isPressed())
setReleased(true);
else
setReleased(false);
setPressed(false);
setHeld(false);
}
} |
a6e5b616-b7e5-4d8f-98a0-ea60abcb9ae6 | 6 | public void sendPosts()
{
if (_postList == null || _postList.size() == 0)
{
System.out.println(INFO_APPNAME + "Input file not available OR No posts available");
return;
}
for (int i = 0; i < _postList.size(); i++)
{
PostInfo postInfo = (Po... |
9275c4ae-b233-4f5f-b714-c5e91b513c6f | 7 | public static void startBrowser(String url)
{
String os = System.getProperty("os.name").toLowerCase();
Runtime rt = Runtime.getRuntime();
try{
if (os.indexOf( "win" ) >= 0) {
// this doesn't support showing urls in the form of "page.html#nameLink"
rt.exec( "rundl... |
f75574cc-6082-4f00-b930-72bc825e123e | 6 | public DirectionalBulletImage(String imageURL, BulletDirection direction)
{
super(imageURL);
this.direction=direction;
//Set the south east facing bullet
if(direction==BulletDirection.SE)
{
frameNumber=0;
}
//Set the south west facing bullet
else if(direction==BulletDirection.SW)
{
fra... |
f05e911e-807f-40c5-a19d-376970d3c023 | 5 | public boolean isNeighbour(GraphPoint p1, GraphPoint p2)
{
if (p1 == p2)
return false;
for (Point point : points)
{
if (point != p1 && point != p2 &&
p1.euclideanDistance2(p2) >
p1.euclideanDistance2(point) + p2.euclideanDistance2(point))
{
return false;
}
}
return true;
} |
2d91460f-ba75-41ab-8667-32b1f71fb7a8 | 2 | public boolean DeleteFolder(String sPath) {
flag = false;
File file = new File(sPath);
// 判断目录或文件是否存在
if (!file.exists()) { // 不存在返回 false
return flag;
} else {
// 判断是否为文件
if (file.isFile()) { // 为文件时调用删除文件方法
return deleteFile... |
add51116-80cf-47f6-bb9d-38cb009f6ca3 | 6 | @Override
public boolean equals(Object obj){
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
MyString other = (MyString) obj;
if (str == null) {
if (other.str != null)
return false;
} else... |
4036479c-c207-4cfa-8e23-bb5f0985e7c7 | 0 | public void setFilename(String filename) {
this.filename = filename;
} |
96d61fcd-64b8-4633-8384-0d5d02eb30d9 | 5 | public static void loadWorld(int ID) {
if (ID < 0 || ID > 4) {
if (ChristmasCrashers.isDebugModeEnabled())
System.err.println("Failed to load world " + ID + " - invalid world ID (must be between 0 and 4, inclusive).");
return;
}
if (worlds[ID] != null) {
if (ChristmasCrashers.isDebugModeEnabled())
... |
7ff9a457-6b33-40b9-afa3-fe0cdef28d8d | 8 | void getTableAtEndOfDay(List<Team> teams) {
//get link to table
link = link.replace("results", "table");
out.println("Connecting to - " + link);
out.println("Pos P W D L F A W D L F A W D L F A GD Pt");
try {
Document doc;
doc = Jsoup.connect(link)... |
5ef24bde-d746-42b0-a7c2-f7e7e1485242 | 8 | @Test
public void testTransductionReception() {
// Partie bit emis = TRUE
Source<Boolean> src = new SourceFixe("101");
TransducteurReception tr = new TransducteurReception();
src.connecter(tr);
try {
src.emettre();
tr.emettre();
} catch (InformationNonConforme e) {
e.printStackTrace();
}
... |
fdcfdeb9-f199-43fd-919f-1e87dccc9fd4 | 6 | @Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
ServletContext sc = this.getServletConfig().getServletContext();
String localPath = sc.getInitParameter("ottzRimagePath");
HttpSession session... |
5626faf6-3608-4401-8108-af839066743f | 1 | private static void fillBuffer() {
try { buffer = in.read(); N = 8; }
catch (IOException e) { System.out.println("EOF"); buffer = EOF; N = -1; }
} |
ea99b3aa-d606-4bff-841a-13d6dbef0d30 | 0 | private int primitiveHashCode() {
return super.hashCode();
} |
8a3c3eaa-00dc-4eec-a51a-d3937eb31e1f | 8 | public int compare(NumericInterval i) {
if (lowerUndefined == i.lowerUndefined &&
lowerOpen == i.lowerOpen &&
upperUndefined == i.upperUndefined &&
upperOpen == i.upperOpen &&
lowerBound == i.lowerBound &&
upperBound == i.upperBound)
return 0;
if (this.upperBound <= i.lowerBound)
ret... |
1651fa57-c50b-45c0-93ab-17d3f374bdf1 | 2 | @Override
public void update(long deltaMs) {
sinceLastSpawn += deltaMs;
elapsed += deltaMs;
if(sinceLastSpawn >= betweenSpawns) {
int r = Application.get().getRNG().nextInt(4) + 1;
GameSector sector = Application.get().getLogic().getGame().getSector((long)r);... |
41e13262-5348-4c3a-af05-986a3c99d7ab | 0 | public City_Graph copy(){
City_Graph nextCity = new City_Graph();
nextCity.setContainers(cityList.copy(), pathList);
return nextCity;
} |
8fb685a2-44a4-4431-b6b8-59aaac35e9b1 | 6 | private void finalMerge0(int[] a, int low, int mid, int high) {
int i = low, j = mid;
int k = 0;
while (i < mid && j < high) {
if (a[i] < a[j]) {
temp[k++] = a[i];
i++;
} else {
temp[k++] = a[j];
j++;
... |
cc44afd0-64e0-4abd-b73c-62da0a1892d7 | 7 | private List<Item> retrieveItems(int minDemand, int minSupply, int minMargin) {
List<Item> items = new ArrayList<>();
CSVParser parser = new CSVParser();
int fetched = 0;
int used = 0;
try {
URL url = new URL(
"http://www.gw2spidy.com/api/v0.9/csv/all-items/all");
try (BufferedReader in = new Buffe... |
a3b71aea-4846-40e1-a756-72ca09a17775 | 1 | public void render(Graphics g) {
HUD hud = null;
for (int i = 0; i < huds.size(); i++) {
hud = huds.get(i);
hud.render(g);
}
} |
14c753f3-c211-4ef8-a595-12482b27bde2 | 1 | public void setV(int j, int []x){
assert x.length==n;
for(int i=0;i<n;i++)
setij(i,j,x[i]);
fullStrize();
} |
9bd75dc2-94ba-49fe-8aeb-b7e2eff219fd | 7 | public void positionTable(int pos) {
if (pos != TransactionPanel.TOP && pos != TransactionPanel.BOTTOM)
throw new IllegalArgumentException("Table position "+pos+" is not valid");
if (table == null || scrollPane == null || table.getRowCount() == 0)
return;
JScrollBar scr... |
13b54877-515e-4d50-92e0-8909bb782f69 | 0 | public DoNothing() {} |
d8637d5a-dc8e-4741-8a8d-c1e3d0759e08 | 5 | @Override
public boolean equals(final Object obj)
{
if (this == obj)
return true;
if (null == obj || getClass() != obj.getClass())
return false;
@SuppressWarnings("unchecked")
final Pair<T> other = (Pair<T>) obj;
if (!first.equals(other.first))
return false;
if (!second.equals(other.second))
... |
1f5d8ca3-330b-4d9e-b03d-b0108f74bbb8 | 2 | public void draw(Graphics2D g) {
g.drawImage(image, (int) x, (int) y, null);
if (x < 0) {
g.drawImage(image, (int) x + GamePanel.WIDTH, (int) y, null);
}
if (x > 0) {
g.drawImage(image, (int) x - GamePanel.WIDTH, (int) y, null);
}
} |
9dc771ec-67df-4d91-8e46-eb9c08b74d29 | 8 | public void updateTimeSpentOnTask(JTable table, JComboBox userName, JComboBox comboboxStatus, JTextField textfieldTimeSpent, JTextArea textAreaComment) throws SQLException, IOException {
DefaultTableModel tablemodel = (DefaultTableModel) table.getModel();
User user = null;
TimeSpentOnTask tsot =... |
402502ab-d581-45b4-b609-fec5b6215ed3 | 2 | private boolean stepInDirectionOfY(int yDestination) {
if (y < yDestination) {
y += Math.min(stepSize, yDestination - y);
} else if (y > yDestination) {
y -= Math.min(y - yDestination, stepSize);
}
return y == yDestination;
} |
3090b677-d197-4024-82c0-f9482b04c6c1 | 1 | public String getCommand(String prefix) {
String input = "";
System.out.print(prefix);
try {
input = in.readLine();
} catch (Exception e)
{
System.err.println(e);
}
return input;
} |
0a22c176-f8e1-4c0d-88eb-d86b66e9bb63 | 8 | public static void main( String args[] ) {
int valor[] = new int[100];
int i, j, r, total = 0, vg = 0, pk = 0;
String v, op;
op = JOptionPane.showInputDialog(null, "Ingrese Cantidad de Datos para la lista ", JOptionPane.PLAIN_MESSAGE);
pk = Integer.parseInt(op);
fo... |
36e74bf8-efe7-4ea9-a11a-16ffd722c0de | 3 | public MenuItem kiesMenuItem() {
System.out.println();
for (MenuItem m : MenuItem.values()) {
System.out.println(m.ordinal() + "\t" + m.getOmschr());
}
System.out.println();
int maxNr = MenuItem.values().length - 1;
int nr = readInt("maak een keuze uit 0 t/m "... |
20b7fe74-5857-4747-984c-0be2144e7fa4 | 0 | @Test
public void testDrawing() throws Exception {
propertyChangeSupport.firePropertyChange(DialogWindowController.CALCULATED, 0, 1);
assertEquals(view.getTextArea().getText(), "Drawing");
assertEquals(view.getProgressBar().getValue(), 0);
assertEquals(view.getButton().isEnabled(), f... |
5426dd14-1541-4e6d-bad7-6e9809351f6f | 2 | public int calculate(List<Integer> values) {
if(values.size() == 0)
return 0;
int result = values.get(0) * 2;
for (Integer value : values) {
result -= value;
}
return result;
} |
e8f87714-66d4-4574-b622-aae178d89e7e | 7 | @Override
public void act() {
//Check actors
for (Actor actor : (List<Actor>)getObjects(null)) {
if (actor == helicopter || actor == scoreCounter || actor == muteButton) continue;
actor.setLocation(actor.getX() + 40 - helicopter.getX(), actor.getY());
}
... |
e8e2ccde-e2cb-403a-9cf5-99199f90af81 | 8 | public static void main(String[] args) {
RequestsArray batch = new RequestsArray(10, 0.1f);
long clkCheck = System.currentTimeMillis();
Player user = new Player("boris",1000000);
while(true){
/*if(System.currentTimeMillis() - clkCheck >= 20000){ ... |
55270518-876c-4739-a9bb-5cd41c641745 | 3 | public int rocR100Lookback( int optInTimePeriod )
{
if( (int)optInTimePeriod == ( Integer.MIN_VALUE ) )
optInTimePeriod = 10;
else if( ((int)optInTimePeriod < 1) || ((int)optInTimePeriod > 100000) )
return -1;
return optInTimePeriod;
} |
1e43b094-7fca-4d5d-8405-2243ac4b17d3 | 5 | public void setBST(BSTNode b,String stucture)
{
root=b;
model = new DefaultTableModel();
JTable table = new JTable(model);
// Create a couple of columns
model.addColumn("ISBN No");
model.addColumn("Book Name");
model.addColumn("Book Type");
model.addColumn(... |
c3019da8-e2ba-4efd-b9da-5225279ed0bf | 2 | public static JSONObject showException(Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
JSONObject jo = new JSONObject();
try
{
jo.put("rtnCode", "500 internal server error");
String[] aSplitted = sw.toString().split("\n");
for(int... |
d3c02206-12c3-4c55-80a7-291b8345e7c0 | 4 | public void actualizarJTree() {
this.canales=new DefaultMutableTreeNode("Lista Canales");
List<Canal> canales = AudioChatService.getCanales();
for (Canal canal : canales) {
this.canal = new DefaultMutableTreeNode(canal.getName());
this.canales.add(this.canal);
List<Cliente> clientes = canal.getClientes()... |
b8d96f91-50ac-4068-9a70-9152a7c9f1fe | 0 | @Transactional
public Step getById(Integer stepId) {
return stepsDao.getById(stepId);
} |
c3db2335-104d-444d-9538-77a7c1d95a31 | 2 | public String getPastString() {
String past_string = (String) cache.get("past_string");
if (past_string != null)
return past_string;
Entity past_entity = null;
DatastoreService datastore = DatastoreServiceFactory
.getDatastoreService();
try {
past_entity = datastore.get(KeyFactory.createKey("past_st... |
c9722551-222a-4741-b9a7-f44165cd2e97 | 8 | private static void originalDefaultAction(ActionEvent e, JTextArea textArea) {
// Insert char into textArea (Code taken from javax.swing.text.DefaultEditorKit.DefaultKeyTypedAction class)
String content = e.getActionCommand();
int mod = e.getModifiers();
if ((content != null) && (content.length() > 0) && ((mod ... |
cd0ccc31-5dff-483b-b4db-43cb3e6e040c | 8 | public static String getAName(String fullName,int type) {
String [] names=fullName.split(" ");
if(type==1)
return names[0];
else if(type==2 && names.length>=2)
return names[names.length-1];
else if (type==3 && names.length>=3) {
String middleName="";
for(int i=1;i<names.leng... |
6ee3b681-d9e3-480d-a979-d22bc9b8c0ac | 7 | public Tile getTile(int x, int y) {
if (x < 0 || y < 0 || x >= width || y >= height) return Tile.voidTile;
if (tilesInt[x + y * width] == 0) return Tile.grass;
if (tilesInt[x + y * width] == 1) return Tile.flower;
if (tilesInt[x + y * width] == 2) return Tile.rock;
return Tile.voidTile;
} |
93aca3a3-f08d-4aa6-a680-3c2f4426c74c | 2 | public static Achievement getAchievementByName(String name) {
name = name.trim();
String statement = new String("SELECT * FROM " + DBTable + " WHERE name = ?");
PreparedStatement stmt;
try {
stmt = DBConnection.con.prepareStatement(statement);
stmt.setString(1, name);
ResultSet rs = stmt.executeQuery()... |
7f31a43c-9b8e-4898-b5d6-e9d07a3f14d5 | 5 | public SetGame() {
players = new HashSet<Player>();
numPlayers = 0;
numPlayersRemoved = 0;
cardsInDeck = new String[81];
pcs = new PropertyChangeSupport(this);
// Make a shuffled deck of Set cards
char[] colors = {'b', 'g', 'r'};
char[] shapes = {'d', 'o', 's'};
char[] fills = {'f', 'o', 's'};
ch... |
28c912cc-edcf-463d-8ebd-952a5f4d2501 | 7 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int quizID = Integer.parseInt(request.getParameter("quizID"));
HttpSession session = request.getSession();
int position = 0;
Quiz quiz = Quiz.getQuizByQuizID(quizID);
// TODO ERROR JACK se... |
0cb1e482-759e-4560-aacd-0611f9a09175 | 0 | public void setMostRecentDocumentTouched(Document doc) {
this.mostRecentDocumentTouched = doc;
// Fire Event
fireChangedMostRecentDocumentTouchedEvent(doc);
} |
586e91a4-c52c-46e3-9e5e-c455f73cff7d | 1 | public TileMap reloadMap() {
try {
return loadMap(
"/maps/map" + currentMap + ".txt");
}
catch (IOException ex) {
ex.printStackTrace();
return null;
}
} |
1f6db2cf-b02d-41cc-b5e9-54979fbf20fd | 1 | public void refresh() {
try {
questionDAO = new QuestionDAO();
List<SettingQuestion> questions = null;
questions = questionDAO.getAllFIBQuestion();
QuestionTableModel model = new QuestionTableModel(questions);
questionTable.setModel(model);
... |
e2eb3112-6f86-4451-a946-2738206a7532 | 0 | @Override
public int hashCode() {
return (int) this.appt.getId();
} |
c3c479a7-17d1-4524-aa3b-d08689d50864 | 4 | void setChunk(int x, int z, BiomeChunk c)
{
if (x < px || x >= px + sx)
return;
if (z < pz || z >= pz + sz)
return;
chunks[x - px][z - pz] = c;
} |
8afcc867-28cd-4218-b3d1-d2606a8a3f63 | 8 | @Override
public int compareTo (JavaInfo o)
{
if (o.major > major) return -1;
if (o.major < major) return 1;
if (o.minor > minor) return -1;
if (o.minor < minor) return 1;
if (o.revision > revision) return -1;
if (o.revision < revision) return 1;
if (o.bui... |
d8d500a9-81e5-42bd-a5c3-41e686d7cc17 | 0 | public void clearChecked() {
checked.clear();
} |
0ffcabd5-f668-48da-937a-9ec987553ec3 | 0 | @Override
public void handleEvent(Event evt) {
// TODO Auto-generated method stub
repaint();
} |
3df4a922-da9d-44e9-ab38-6a5e9e51ac78 | 0 | @Override
public void mousePressed(MouseEvent e) {
mouseKeyStatus(e, true);
} |
ef5c62e7-6d12-469d-92f5-03f0d330c7ea | 4 | public void set(CharBuffer array, int index, T value) {
Character ordinal = map.get(value);
if (ordinal == null) {
final int size = map.size();
OUTER:
do {
for (; addPosition < map.size(); addPosition++) {
if (list.get(addPosition) == null) {
ordinal = addEnumValu... |
c8eb13cf-1a4c-4cac-a1e7-e6b693cb602c | 4 | private static void QuickSrtusingfirstpivot(int l, int k) {
// TODO Auto-generated method stub
if(l==k){
return;
}
if (k>l){
int i=l+1; // startelement
int j=l+1; //
int pivot = 0;
pivot = array[l];
for(j=l+1;j<k+1;j++){
int vella = array[j];
counter++;
if(array[j]<pivot){
... |
dd9d25f6-3665-4d88-a616-4881cbea4a0a | 4 | public String read()
{
try
{
FileReader ken= new FileReader(this.fileName);
BufferedReader input= new BufferedReader(ken);
int nigmar=0;
String allTheData="";
while(nigmar!=1)
{
String line=input.readLine();
if(line==null)
nigmar=1;
else
{
allTheData=allTheData+line;
... |
cd090ae2-2012-4304-b9d3-21f11cb846a0 | 5 | public static HashSet<Integer> testAtt(ResultSet rs, double percent) throws SQLException {
int columnCount = rs.getMetaData().getColumnCount();
int[] testAtt = new int[columnCount];
int rowCount = 0;
HashSet<Integer> passAtt = new HashSet<>();
while (rs.next()) {
for ... |
83fb5b58-f83d-46be-ae16-35ec354bcd16 | 1 | public final int getListeningPort() {
return myServerSocket == null ? -1 : myServerSocket.getLocalPort();
} |
8a3326ad-fa57-4c21-a831-b4748dcfef35 | 4 | @Override
public boolean vetoContinueAfterCall(int currentAddress, int jumpAddress) {
if(jumpAddress == 0xc80d5) // messes with stack, reads return address as data
return true;
if(jumpAddress == 0xce663) // messes with stack, reads return address as data
return true;
if(jumpAddress == 0x476c) // messes wit... |
6827f63d-7d43-432e-bb65-d0dfe7d2bdce | 5 | private void populateRoles(Properties rolesMaps) {
roles.clear();
Iterator<Map.Entry<Object, Object>> e = rolesMaps.entrySet().iterator();
while (e.hasNext()) {
Map.Entry<Object, Object> entry = e.next();
String privileges = (String) entry.getValue();
if (... |
9d10cabe-c94a-4baa-ae5a-17ad73deafb7 | 4 | private void splitMessageInformaton(String actionMessage){
String[] information;
information = actionMessage.split("]");
for (int i = 0; i < information.length; i++){
information[i] = information[i].substring(1);
switch(i){
... |
8b84d3f0-945b-456d-bcd9-1a92945f804b | 3 | public boolean isCorrectTurn(int x, int y) {
if(!isOnMap(x, y)) {
return false;
}
if(map[x][y].status == ServerGameMapCell.SURROUNDED_OPT) {
return false;
}
if(map[x][y].owner != ServerGameMapCell.WITHOUT_OWNER_OPT) {
... |
b792a5fe-f4da-47a3-8a1c-f51a5179a6a0 | 8 | static ArrayList<Integer> getPosicion(int[] inicio,int cantInicio,long jugado,int cantJug) {
boolean[][] tab=new boolean[100][100];
int x=50,y=50;
tab[x][y]=true;
for(int i=0;i<cantInicio;i++) {
int p=inicio[i];
x+=jug[p][0];
y+=jug[p][1];
tab[x][y]=true;
}
for(int i=0;i<cantJug;i++) {
int p=... |
a9f4a5e9-bea5-4019-a586-33031e4cefed | 1 | public static void main(String args[])
{ // Generate an array with random elements, count the inversions. print
// them
final int MAX_NUM_ELEMENTS = 10000;
final int MULTIPLIER = 1000;
int N = Math.min(MAX_NUM_ELEMENTS,
(int) (Math.random() * MAX_NUM_ELEMENTS));
Integer[] a = new Integer[N];
for (in... |
c267c5f4-4c78-4a8f-b5d3-9ea14b94a6ac | 5 | public void save() {
adjust = "@Adjust Money:";
if(rdbtnActivator.isSelected()) {
adjust += "activator:";
} else if(rdbtnSource.isSelected()) {
adjust += "source:";
} else if(rdbtnSelect.isSelected()) {
adjust += selectCombo.getSelectedItem() + ":";
}
if(allButton.isSelected()) {
adjust += "a... |
7dd889b5-745e-4581-a3c0-e4d347f490f1 | 8 | protected boolean isRodentHere(final Room R, final MOB notM)
{
if(R==null)
return false;
for(final Enumeration<MOB> m=R.inhabitants();m.hasMoreElements();)
{
final MOB M=m.nextElement();
if((M!=null)&&(M!=notM)&&(M.isMonster()))
{
final Race mR=M.charStats().getMyRace();
if(mR.racialCategory(... |
5355ac4f-7223-47d9-ada3-e5751aed4484 | 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... |
5f3edfef-6db2-4584-be9d-c046f990f895 | 6 | public static void main(String[] args) throws InterruptedException {
DOMConfigurator.configure("log4j.xml");
LOG = Logger.getLogger(AisRecorder.class);
LOG.info("Starting AisRecorder");
// Load configuration
String propsFile = "aisrecorder.properties";
if (args.length > 0) {
propsFile = args[0];
}
t... |
ed63340d-b4ba-4a90-9d9a-50c9738f6820 | 5 | @Override
public boolean open() {
WidgetChild wc;
return superTab.open()
&& (isOpen() || (wc = Widgets.get(BOOK_WIDGET, component)) != null && wc.visible()
&& wc.click(true) && new TimedCondition(2000) {
@Override
public boolean isDone() {
return InnerAbilityTabs.this.isOpen();
... |
ab82db4a-3882-4f7e-b492-d905984a3eab | 3 | public static void main(String[] args)
{
Thread[] threads = new Thread[5];
for (int i = 0; i < threads.length; i++)
{
threads[i] = new Thread()
{
public void run()
{
}
};
threads[i].start();
}
for (int j = 0; j < threads.length; j++)
{
try
{
threads[j].join();
}
ca... |
43ae3992-c9f0-4ffd-84fe-e6d34b27f1be | 5 | private static AComposer chooseComposer(Genre genre, File f) throws IOException {
switch( genre ) {
case DRAMA:
return new MozartContraDanceOneDiceGame(f);
case KIDS_BOOK:
return new MozartContraDanceTwoDiceGame(f);
case LYRICS:
return new MozartTrioDiceGame(f);
case NONFICTION:
return n... |
3fe055fb-de36-49f4-b76d-112a5d27b4e7 | 5 | private static boolean newScope(Environment e, LList code) {
Scope outer = null;
for(int z = e.scopes.size()-1; z >= 1; z--) {
if (e.scopes.get(z).procedure && !(Primitives.prim(e.scopes.get(z).code))) {
outer = e.scopes.get(z); break;
}
}
if (canTail(outer, e, code)) {
// smash the call stack down... |
7450c9cc-91cd-4af7-8d1e-7278e110f5ee | 3 | private void testPulse() {
if (isDead) {
System.out.println(this + " is dead");
} else if (pinkEnergy <= 0 || greenEnergy <= 0) {
isDead = true;
System.out.println(this + " died");
}
} |
1c9e928f-f32d-4dc9-9f33-d225b1f00c61 | 1 | public void saveXml() throws TransformerException
{
try {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult result = new ... |
c778e810-42f9-4147-ac53-8e61bb6f2495 | 7 | private void openLevelEnclosingFolder() {
try {
Desktop desktop = Desktop.getDesktop();
String lastLevelFileName = editorSettings.getLastLevelFileName();
if(lastLevelFileName != null && lastLevelFileName.length() > 0) {
File levelFile = new File(lastLevelFileName);
if(levelFile != null && levelFile.c... |
88abab53-55be-402e-91b3-aa75fa0044f3 | 5 | @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Location other = (Location) obj;
if (Float.float... |
9d76dcc1-3183-4362-91f7-43e6fd26d598 | 5 | public DefaultAWTMonitor() {
canvas.setPreferredSize(new Dimension(160 * SCALE, 128 * SCALE));
canvas.setMinimumSize(new Dimension(160 * SCALE, 128 * SCALE));
canvas.setMaximumSize(new Dimension(160 * SCALE, 128 * SCALE));
canvas.setFocusable(true);
Thread t = new Thread() {
public void run() {
... |
0d91caaa-3102-48ea-8ddc-dfd5da573b74 | 2 | private boolean anyPiecesLeftToPlay() {
int totalPiecesLeft = 0;
Iterator<Entry<HantoPieceType, Integer>> bluePieceTotals = bluePiecesLeft.entrySet().iterator();
Iterator<Entry<HantoPieceType, Integer>> redPieceTotals = redPiecesLeft.entrySet().iterator();
while(bluePieceTotals.hasNext()) {
Entry<HantoPie... |
dd2b1944-e664-4b3d-ab42-eae848fb3111 | 9 | public String getMinimumPath() {
StringBuilder sb = new StringBuilder();
//Primeira linha
int minL = 0;
int minV = array[0][0];
for (int l = 1; l < this.rowNumber; l++ ) {
if (array[l][0] < minV) {
minV= array[l][0];
minL = l;
}
}
sb.append(minL+1);
sb.append(" ");
for ( int c = 1; c ... |
734de753-3ff7-4e25-bcde-2cd852a0f41c | 7 | protected boolean isValidDest(int x, int y) {
/* The first statements check that the x and y are inbounds. The last statement checks the map to
see if it's a valid location */
if (((x % Pacman.TILE_SIZE == 0) || (y % Pacman.TILE_SIZE == 0)) && Pacman.TILE_SIZE <= x && x < Pacman.MAX && Pacman.TILE_SI... |
b8d49c26-537f-478f-a6dd-bc10d29acce6 | 7 | public static void main(String[] args) throws FileNotFoundException, IOException {
//Aquí seteamos el archivo a ser leído
LexerCoffeeScript scanner = new LexerCoffeeScript(new FileReader("src/lexercoffeescript/fuente.txt"));
//El componente léxico a ser reconocido, perteneciente a la va... |
efeebb84-23d5-4e8d-9adc-a36ec042d4f9 | 4 | @Override
public V set(int index, V newValue) {
Preconditions.checkElementIndex(index, size);
int arrayIndex = index * gap + offset;
V old = grid.values[arrayIndex];
grid.values[arrayIndex] = newValue;
if (old == null && newValue != null) {
... |
ed721759-6aa9-4318-a5e2-58d6543b1aef | 5 | private void addStringsToFileMenu(JMenu menu, String[] labelList) {
for (int i = 0; i < labelList.length; i++) {
JMenuItem item = new JMenuItem(labelList[i]);
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
String label = ((JMenuItem)arg0.getS... |
9a98cf25-71b3-49a5-999c-c301be979972 | 6 | public List<Message> getMessagesFrom(String user, int nbMes){
List<Message> res = new ArrayList<Message>();
for(Message msg : recentMessages){
if(msg.getAuthors().contains(user)){
res.add(msg);
}
}
int logInd = 0;
while(res.size() < nbMes && logInd < logs.size()){
List<Message> tempO... |
6a08e4b2-ef74-4fe6-a788-1a8a38fce35e | 7 | public static Class loadClass(Class loadClass,String name)
throws ClassNotFoundException
{
ClassNotFoundException cnfe=null;
ClassLoader loader=Thread.currentThread().getContextClassLoader();
if (loader!=null)
{
try
{
return loader.loadC... |
66e368ec-fa2e-4a41-aa05-6e09959aaf4f | 6 | public void add(T data, String file) throws ObjectAlreadyExistsException, NoeudNonFeuilleException{
if(this.valeur.contains(data))
throw new ObjectAlreadyExistsException();
boolean trouve = false;
for(int i = 0; i < this.valeur.size(); i++){
if(this.valeur.get(i).compareTo(data) >= 0){
trouve = true;
... |
1e53f20a-f22b-422e-b9e7-034f1a87fbbd | 2 | public static boolean plays(Role role, String r) {
if (r == null) {
throw new IllegalArgumentException("null role");
}
if (role == null) {
return false;
}
return role.value().contains(r);
} |
153b3c8e-77a0-4e73-a8d8-05e58b5fe79d | 3 | public static void main(String[] args) throws IOException {
//System.out.println(args[0]);
//System.out.println(args[1]);
ProcessExonCountsCoverBed p = new ProcessExonCountsCoverBed();
//p.process("/Users/dashazhernakova/Documents/UMCG/cluster/tmp.txt");
if (args.length ... |
1a5a5d7c-9153-46f4-9eb5-483d7afc533b | 5 | @Override
public boolean equals(Object o) {
// instanceof can handle NULL values !!!
if (!(o instanceof Pojo))
return false;
Pojo pojo = (Pojo)o;
if (!this.headline.equals(pojo.headline))
return false;
if (!this.signature.equals(pojo.signature))
return false;
if (!this.volatS... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.