method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
a0901c1d-6e7a-4cbc-b8a2-ea6de4d6c54d | 0 | public static short byte2tinyint(byte b[], int offset)
{
return (short)(b[offset] & 0xff );
} |
28cbd8b4-a9c5-4880-9739-25d889b027ec | 7 | @Override public boolean getControls(String control){
if(control == "Age"){ return true;}
if(control == "Fade"){ return true;}
if(control == "Mat"){return true;}
if(control == "Born"){ return true;}
if(control == "Survives"){ return true;}
if(control == "Mirror"){ return true;}
if(control == "Xfac... |
bb66a511-c5c0-4d80-bf20-1ea8a2ca6357 | 9 | private void initialize() {
students = new Vector<Student>();
teachers = new Vector<Teacher>();
frame = new JFrame();
frame.getContentPane().setBackground(Color.WHITE);
frame.setBounds(100, 100, 769, 563);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
J... |
bf7fed83-2aa6-447b-8342-0734fdcaf18e | 2 | public static void main(String[] args){
StringBuilder sb = new StringBuilder();
int n = (int) 1e6 - 1;
int digits = 9;
List<Integer> avai = new ArrayList<Integer>();
for(int i=0;i<10;i++) avai.add(i);
while(digits>=0){
int numPer = fac(digits);
sb.append(""+findNthAndRemove(avai, n/numPer));
digits... |
f1d56392-d7a0-4494-a9bc-96f7030e7b60 | 5 | private void moveZombies() {
// roll a random value
int value = getDie();
// Place a Zombie on top of a player if possible
if (value >= ZOMBIE_PLACE_COST) {
for (IPlayer player : getPlayers()) {
IField field = getMap().getField(player.getCoordinates());
... |
41189d70-978c-4f4d-88cf-802f2b8fbad9 | 2 | public static void main(String[] args) {
String str = "-a \"Two Against One.mp3\" \"my file here\"";
System.out.println("String in testing: " + str);
try {
String[] filenames = parseString(str);
for(String s: filenames) {
System.out.println("Returned filenames: <" + s + ">");
}
} catch (Ille... |
9213ab64-0a42-4306-a6e4-a6009eff6625 | 4 | public MenuPanel(final Handler handler, int random) {
super();
this.handler = handler;
this.random = random;
if(random == 0) color = "_green";
else if(random == 1) color = "_blue";
else color = "_orange";
Border panelBorder = new LineBorder(GUI3.guiColor);
... |
8962d690-9e66-4f5e-bde3-dce08fa17449 | 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 fe... |
64e004aa-6c39-4620-9f08-3301cc8dc285 | 1 | public synchronized boolean connect(InetAddress ipadr) {
ishost = false;
try {
clientSocket = new Socket(ipadr, port);
isClient = true;
} catch (IOException ex) {
System.out.println(ex.getMessage());
return false;
}
System.out.print... |
b17e48fb-8bcd-4b10-9a3d-2f48d6db014d | 2 | public boolean merge(List<String> other) {
if (other == null) {
return true;
}
if (result == null) {
result = new ArrayList<String>();
}
result.addAll(other);
return true;
} |
8e3f95bf-a145-48a4-b515-153f9f97516f | 6 | public int getCostSavings(int numberOfEmployees){
int counter = 0;
int savings=0;
while(counter<numberOfEmployees){
if(ratingEmployeeMap.size()>0) {
TreeSet<Integer> treeset = (TreeSet) ratingEmployeeMap.remove(ratingEmployeeMap.firstKey()).descendingSet();
... |
699d67cb-8e85-4213-bce1-69c729c621ae | 9 | public void addPiece(int col, int row, int currentPlayer)
{
++ithMove;
//Update the parity
if(oldPlayer == currentPlayer)
hasAPlayerPassed = !hasAPlayerPassed;
oldPlayer = currentPlayer;
board[col][row] = currentPlayer;
updateCornerCloseness(col, row);//Change the cornercloseness if the piece is pla... |
0f68a665-3943-4e84-bf14-6e8cf0a07afe | 2 | public void animate(boolean relocate) {
if(relocate){
relocate();
}
calculateSpeed();
this.animationCounter++;
if(this.animationCounter >= this.animationCounterMax){
this.animationCounter = 0;
}
} |
3eb5c525-e6a3-40b5-b474-15e1f4c736eb | 9 | public void makeDirectory(String name, Path currentDirectory) {
Path path = null;
boolean succeeded = false;
try {
path = Paths.get(name);
if (path.isAbsolute()) {
Files.createDirectories(path);
succeeded = true;
}
} catch (IOException ioException) {
if (Constants.DEBUG)
System.out.fo... |
e01dc363-a3b3-49f3-94fa-e1a287906d2a | 0 | public JCheckBox getjCheckBoxQuit() {
return jCheckBoxQuit;
} |
817d9e76-848d-440b-aaf6-7150d134e5f8 | 2 | private List<SoftwareSystem> generateSystems() {
List<SoftwareSystem> systems = new ArrayList<>();
for (HardwareSystem hardwareSystem : project.getHardwareSystems())
for (DeploymentAlternative deploymentAlternative : project.getDeploymentAlternatives())
systems.add(new SoftwareSystem(hardwareSystem, deployme... |
4d472d21-c50f-47ae-b0de-f491d5c01dba | 1 | protected void gerarXml(){
int index = gCrlv.getTableGerenciarCrlvs().getSelectionModel().getLeadSelectionIndex();
if(index > -1){
XStream xstream = new XStream();
ModelCRLV c = gCrlv.getCrlv().get(index);
String xml = xstream.toXML(c);
ViewXM... |
792571da-7024-4e7b-b844-09959d66e696 | 8 | private void init() {
if (defaultCheckBoxBackground == null)
defaultCheckBoxBackground = getBackground();
if (defaultCheckBoxForeground == null)
defaultCheckBoxForeground = getForeground();
popupMouseListener = new PopupMouseListener(this);
addMouseListener(popupMouseListener);
setOpaque(false);
setFo... |
991ebf25-9ba9-449e-bb34-4051c566e0f8 | 7 | public void run() {
Random ran = new Random();
while (ancho < maxAncho && alto < maxAlto) {
try {
if (mascarillaAplicada == false) {
Thread.sleep(500 + ran.nextInt(3000));
ancho++;
alto++;
gs.repa... |
b286cc7d-de6a-4edf-bad6-139d1fb47d21 | 1 | public void putTime(String key, Time t)
{
try
{
byte[] ba = Utils.object2Bytes(t);
prefs.putByteArray(key, ba);
} catch (IOException ex)
{
Logger.getLogger(TimerPreferences.class.getName()).log(Level.SEVERE, null, ex);
}
} |
867f671f-c6a8-4b0c-8a99-9cec2214dd4d | 1 | @Override
public void cast(Player p) {
if (super.attemptCast(p)) {
Vector eye = p.getEyeLocation().getDirection();
Projectile proj = p.launchProjectile(Arrow.class);
ids.add(proj.getEntityId());
proj.setVelocity(eye.multiply(1.24).add(new Vector(0, 0.2, 0)));
proj.setFireTicks(200);
}
} |
59059044-6e1e-43d7-8e56-e04ea6b01fa5 | 6 | public static List<DiffField> diffObj(Object oldValue, Object newValue) {
List<DiffField> allDiffs = new ArrayList<>();
Class cOld = oldValue.getClass(), cNew = newValue.getClass();
if (cOld != cNew) {
throw new IllegalArgumentException("Objects to be compared must be of identical class");
}
Class c;
for... |
4d226005-a8a9-4250-a124-c221145d5c16 | 8 | @Override
public boolean execute(CommandSender sender, String[] args) {
if(!(sender instanceof Player)) {
return true;
}
String groupName = args[0];
Group group = groupManager.getGroupByName(groupName);
if(group == null) {
sender.sendMessage("Group doesn't exist");
return true;
}
if(gro... |
2f3055e1-e61c-4967-a1a2-109e38f73b6d | 1 | public Snake(MonsterManager mm, Registry rg, String im, String st, int x, int y, int minDist, int maxDist) {
super(mm, rg, im, st, x, y, minDist, maxDist, false);
name = "Snake";
displayName = "Snake";
monsterManager = mm;
difficultyFactor = 0.50f;
adjustHPForLevel();... |
edd11616-21f2-4de9-ad1d-326cfd56ec05 | 5 | public void doAction(String str) {
int r = 9;
for (int ox = -r; ox < r+1; ox++) {
for (int oy = -r; oy < r+1; oy++) {
if (ox*ox + oy*oy > r*r) {
continue;
}
Creature other = Game.game.world.getCreature(creature.x+ox, creature.y+oy);
if (other == null) {
continue;
} else if (other ==... |
dfb80e0e-9d39-4255-9d1e-44ba3f1f5069 | 5 | @Test
public void testMartialArts(){
World world = new World(150,150);
Game game = new Game(world, new BrainParser("C:/Users/mpp27/cleverbrain1.brain"), new BrainParser("C:/Users/mpp27/cleverbrain1.brain"));
int i = 0;
int y = 0;
int[] p = new int[2];
boolean found = false;
while(i < world.getRows() && !... |
03a33c50-5fbe-48fd-9ee9-c81abebd9e0e | 8 | private void blacklistAddActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_blacklistAddActionPerformed
String text = userlistField.getText().trim();
if (text.length() > 0) {
if (text.matches("[^\\u0023]*")) {
text = text + "#" + defaultProjectField.getText();
userlistFiel... |
ea87a926-b050-41e0-b20f-4761bb468e55 | 3 | public void checkNewTasks(){
if(incomingTasks.isEmpty()) {
return;
}
Iterator<Task> it = incomingTasks.iterator();
while(it.hasNext()){
Task task = it.next();
if(task.getDate().after(new Date(System.currentTimeMillis()))){
executoryCycl... |
c024be53-95b7-4ee7-bc54-5afb472c98d4 | 1 | @Override
public void render(float delta) {
Gdx.gl.glClearColor(1f, 1f, 1f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
if(manager.update()){
// we are done loading, let's move to another screen!
AssetLoader.getInstance().setManager(manager);
this.game.setScreen(new TitleScreen(game));
}
// displa... |
117be191-4515-407f-9319-668b1ca1a6ba | 7 | private static int naoAlcancaveis(List<Integer> vertices, int[][] arestas,
int noInicial, int ttl) {
int totalVertices = vertices.size();
List<Integer> marcados = new ArrayList<Integer>();
Queue<Integer> fila = new LinkedList<Integer>();
fila.add(noInicial);
fila.add(ttl);
marcados.add(noInicial);
... |
4745b50e-a5de-44c6-ae60-447b4999ef69 | 3 | void createColorAndFontGroup () {
super.createColorAndFontGroup();
TableItem item = new TableItem(colorAndFontTable, SWT.None);
item.setText(ControlExample.getResourceString ("Selection_Foreground_Color"));
item = new TableItem(colorAndFontTable, SWT.None);
item.setText(ControlExample.getResourceString ("S... |
195c6755-6f07-4523-b442-9b1aeeaf904e | 8 | public ParseException generateParseException() {
jj_expentries.clear();
boolean[] la1tokens = new boolean[15];
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 26; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
i... |
f95d4fef-1948-46df-b48f-74412e4ef315 | 9 | @Override
protected TilesetInfo convert(File image, TilesetInfo info) throws TilingException {
long startTime = System.currentTimeMillis();
log.info("Generating PTIF for file " + image.getName() + ": " + info.getImageWidth() + "x" + info.getImageHeight()
+ ", " + info.getZoomLevels() + " zoom levels")... |
6e5bf300-17dd-4059-b7a8-ea660c6db527 | 3 | public static void DFS(int node){
if(vis[node]){
cycle = true;
return;
}
if(cycle)
return;
vis[node] = true;
for (int i = 0; i < m[node].size(); i++) {
DFS(m[node].get(i));
}
} |
02ebd441-a929-43a5-b249-3019685e65b6 | 0 | public static String replaceBlank(String s) {
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
Matcher m = p.matcher(s);
return m.replaceAll("");
} |
0bdee6b0-7fc0-4f8a-b08d-77152f4d6ad0 | 8 | private static long solve(int matrix[][]) {
long max = 0;
// rows
for (int i = 0; i < 20; i++) {
for (int j = 0; j + 3 < 20; j++) {
max = Math.max(max, matrix[i][j] * matrix[i][j + 1] * matrix[i][j + 2] * matrix[i][j + 3]);
}
}
// cols
for (int i = 0; i < 20; i++) {
for... |
e38d6638-60d0-4097-8f3d-68442a1b2009 | 7 | public PacketAction feedEncryptedPacket(ByteBuffer b, Object passthrough) {
if(isClosed) {
throw new IllegalStateException(id+"SSLEngine is closed");
} else if(runningRunnable)
throw new IllegalStateException(id+"SSLListener was passed a Runnable object" +
" that has not completed yet and must complete b... |
dc54fe4d-4934-4bb0-b63e-b1cb4a33d325 | 9 | public BufferedImage yellowRGBFilter(){
this.yellowImage = originalImage;
Color actualPixel;
int actualRedValue;
int actualGreenValue;
int actualBlueValue;
float numberOfYellowPixels = 0f;
for (int i = 0; i < originalImage.getWidth(); i++) {
for (int j = 0; j < originalImage.getHeight(); j++) {
act... |
167acec1-085c-45cd-bf30-0e19bd543b2d | 6 | @Override
public void run() {
if (Updater.this.url != null) {
// Obtain the results of the project's file feed
if (Updater.this.read()) {
if (Updater.this.versionCheck(Updater.this.versionName)) {
if ((Updater.this.versionLink != null) && (Updater.this.type != UpdateType.NO_DOWNLOAD)) {
S... |
73e3e151-a46a-43b1-9da1-6cf906ded11e | 2 | public List<String> getFileList() {
File dir = new File(File.separator + directory);
List<String> temp = Arrays.asList(dir.list());
List<String> fileList = new ArrayList<String>();
int i = fileList.indexOf(lastScript);
if (i < 0) {
i = 0;
}
while (i ... |
f7cd4d67-d889-4f4e-837a-ffec7e8c69c6 | 6 | private Vector3 getNormal(Face face) {
switch (face) {
case LEFT:
return new Vector3(-1, 0, 0);
case BOTTOM:
return new Vector3(0, -1, 0);
case BACK:
return new Vector3(0, 0, -1);
case RIGHT:
return n... |
612f3f21-af02-4e62-8305-c9b1d319b2a1 | 1 | public T getLast() {
if(nodes.size() <= 0)
return null;
return nodes.get(nodes.size() - 1);
} |
8a2c4a7a-96f1-4109-acdf-05aa7c2e12d6 | 1 | static ShaderProgram getDefaultShader() throws LWJGLException {
if(defaultShader == null) {
return new ShaderProgram(DEFAULT_VERT_SHADER, DEFAULT_FRAG_SHADER, ATTRIBUTES);
}
else {
return defaultShader;
}
} |
e0436561-61a0-40a2-ae1a-f4cdeb8cab16 | 3 | public void setVar(PVar node)
{
if(this._var_ != null)
{
this._var_.parent(null);
}
if(node != null)
{
if(node.parent() != null)
{
node.parent().removeChild(node);
}
node.parent(this);
}
... |
79218bcb-5934-4523-bf90-32cf9f066bb1 | 7 | @Override
public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException{
res.setContentType("text/html");
Connection con = null;
String lausend = null;
ResultSet rs = null;
PreparedStatement ps = null;
Gson gson=new Gson();
ArrayList<CreateByParty> byParty=new Arr... |
4c4859cb-09ac-4b0c-bdbb-aaca0f04c8a6 | 2 | public Object get(String key) throws JSONException {
if (key == null) {
throw new JSONException("Null key.");
}
Object object = opt(key);
if (object == null) {
throw new JSONException("JSONObject[" + quote(key) +
"] not found.");
}
... |
f9fe6196-36ad-4152-88db-9a9526e6de04 | 2 | public static void main(String[] args) {
//---
// Parse command line argument
//---
if (args.length < 2) {
System.err.println("Usage: " + PromoterSequences.class.getSimpleName() + " genomeName fastaFile.fa geneId_1 geneId_2 ... geneId_N");
System.exit(1);
}
String genomeName = args[0];
String fas... |
cf9bd172-fe79-4c0f-a8cf-66bdf2e8c1ee | 1 | public String toString() {
String x = "(TREE " + block + " stack=";
for (int i = 0; i < stack.size(); i++) {
final Expr expr = stack.get(i);
x += expr.type().shortName();
}
return x + ")";
} |
3de7983e-46c6-4515-aacf-48d2339b13ac | 2 | public void buildBoard(BoardModel boardModel) {
for (int i = 0; i < boardModel.getBoardWidth(); i++) {
for (int j = 0; j < boardModel.getBoardHeight(); j++) {
boardModel.getBoard()[i][j] = new Cell(i, j);
boardModel.getBoard()[i][j].setContent("0");
}
... |
a74c82e3-4a9c-4bf2-9404-631aa269e608 | 2 | private boolean contensFornecedor(String razao) {
for (Fornecedor f : fornecedores) {
if (f.getNome().equalsIgnoreCase(razao)) {
return true;
}
}
return false;
} |
94686199-9321-419b-81c1-7542eb953d71 | 7 | public static void main(String[] arg)
{
Matadorspil spil = new Matadorspil();
Scanner keyboard = new Scanner(System.in);
System.out.println("Intast antal spilere");
int antalS = keyboard.nextInt(); // Intast tal int for antal spiller
String name;
for (int i = 0; i < antalS; ++i)// Lkke som bru... |
01cbba03-2e6f-45f7-8e19-61f4c67c7d74 | 4 | public float func_675_a(Vec3D var1, AxisAlignedBB var2) {
double var3 = 1.0D / ((var2.maxX - var2.minX) * 2.0D + 1.0D);
double var5 = 1.0D / ((var2.maxY - var2.minY) * 2.0D + 1.0D);
double var7 = 1.0D / ((var2.maxZ - var2.minZ) * 2.0D + 1.0D);
int var9 = 0;
int var10 = 0;
... |
216a7b0c-205e-41db-afe3-ad5e5263c05a | 2 | public boolean equals(Card card){
boolean retVal = true;
if (this.suit != card.suit){
retVal = false;
} else if (this.faceValue != card.faceValue){
retVal = false;
}
return retVal;
} |
4e06989a-d084-466a-8022-701757c22bd5 | 3 | public static Map map(Object... keyvals) {
if (keyvals == null) {
return new HashMap();
} else if (keyvals.length % 2 != 0) {
throw new IllegalArgumentException("Map must have an even number of elements");
} else {
Map m = new HashMap(keyvals.length / 2);
... |
61df0b44-1019-4aa3-a771-e6fb563021bc | 6 | private int bayse(String instance) {
double pp1 = 0.0;
double pp2 = 0.0;
//Scanner scanner = null;
BufferedReader scanner = null;
try {
scanner = new BufferedReader(new FileReader(new File(instance))); //new Scanner(new File(instance));
} catch (FileNotFoundE... |
d714680a-979a-4c94-854a-384c95ceaafb | 4 | @Test
public void testRecurrence()
{
int currentTaskNum = Timeflecks.getSharedApplication().getTaskList()
.getTasks().size();
Task t = new Task("taskname");
Date sun = new Date(1415572208000L); // Sunday, November 9, 2014 @ 5:30
Calendar c = new GregorianCalendar();
c.setTime(sun);
assertEquals("Test ... |
2cdc78e2-9164-4ebf-8687-9769593f8735 | 0 | public LoadNetFile() {
initLoadNetFile();
} |
de40b231-516f-4efd-a14c-ee9420399650 | 5 | public Wave45(){
super();
MobBuilder m = super.mobBuilder;
for(int i = 0; i < 3250; i++){
if(i % 8 == 0)
add(m.buildMob(MobID.ONIX));
else if(i % 7 == 0)
add(m.buildMob(MobID.MACHOP));
else if(i % 6 == 0)
add(m.buildMob(MobID.GRAVELER));
else if(i % 5 == 0)
add(m.buildMob(MobID.MAROWAK... |
68dde0c6-2f33-4d6d-afd6-fb9eae482a22 | 9 | private void addLink(Link link) {
final String assId = "ass" + UniqueSequence.getValue();
if (link.getType().getDecor1() == LinkDecor.EXTENDS || link.getType().getDecor2() == LinkDecor.EXTENDS) {
addExtension(link, assId);
return;
}
final Element association = document.createElement("UML:Association");
... |
15e6e22c-6a56-480f-938d-598b40536a4b | 0 | public double getSaldo()
{
return this.saldo;
} |
a952aa09-7465-437c-b63d-6b47243ffee0 | 7 | public void calculateAllocation() {
/* calculate processing rate of each site */
double tmp = 0;
double[] daRelativeWeightBySite = new double[iSite];
for (int i = 0; i < iSite; i++) {
tmp = 0;
for (int j = 0; j < iClass; j++) {
tmp += dmPrediction[j][i] * dmWeight[j][i] * dmDist[j][i];
}
// Syst... |
0d17bf85-76b9-4ed3-a792-123c0fb2bd9e | 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... |
3dbe67b3-9034-4f38-b4bb-13e016f5543d | 8 | public boolean load(File repoFile) {
Repository repository;
Git git = null;
try {
repository = new FileRepositoryBuilder().setGitDir(repoFile)
.setMustExist(true)
.readEnvironment()
.build();
git = new Git(repository);
branchFull = repository.getFullBranch();
branchShort = ... |
d6481802-b847-49a5-b59b-21195fe747e5 | 9 | static private int jjMoveStringLiteralDfa2_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(0, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(1, active0);
return 2;
}
switch(curChar)
{
cas... |
7a4f7aaa-f79b-4543-9b33-d9eab76c6ed7 | 7 | @Override
public void handleDFSInit() {
// rst $28
dfs.addJumpTable(0x2b0, 36);
dfs.addJumpTable(0x92e8, 29);
dfs.addJumpTable(0x934e, 3);
dfs.addJumpTable(0x93f0, 7);
dfs.addJumpTable(0x966a, 3);
dfs.addJumpTable(0x96be, 3);
dfs.addJumpTable(0x9754, 7);
dfs.addJumpTable(0x9864, 4)... |
1e1b3275-cb27-4ad0-afe7-5fa6cf6f5948 | 7 | protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
if (par1MovingObjectPosition.entityHit != null)
{
par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, thrower), 0);
}
if (!worldObj.isRemote && rand.nextInt(8) =... |
76cbe786-a522-4246-8c5d-abc1eeb9d0e0 | 6 | @Override
public void keyPressed(KeyEvent e)
{
switch(e.getKeyCode())
{
case VK_D:
isDDown = true;
break;
case VK_A:
isADown = true;
break;
case VK_SPACE:
isSpaceDown = true;
... |
8b37a433-7ee5-4dff-a2fa-09b1c5874965 | 7 | public void smash() {
InstanceBlock breakage = new InstanceBlock(Block.cracked, this.x + Game.translate_x, this.y - Game.translate_y, world);
this.broken++;
if (broken == block.hardness) {
boolean done = false;
ToolBar tb = world.getPlayer().getToolBar();
int... |
5b611735-f913-49b2-aa70-aa5786b1633d | 4 | public static synchronized void onFinish(Chunk chunk) {
finishedChunks++;
int p = (int) ((finishedChunks / totalChunks) * 100);
if (percent != p) {
percent = p;
if (prints++ == 8) {
prints = 0;
System.out.println();
}
System.out.print("\t" + p + "%");
if (finishedChunks == totalChunks... |
776d5819-8e7e-4b99-b551-dd1a4a4d6e40 | 6 | private void walkToEss() {
if (Util.inEssenceMine() && !Players.getLocal().isMoving() && Players.getLocal().getAnimation() == -1) {
if (Util.walkToAndClick("Mine", Util.essenceId)) {
int time = 0;
while (Players.getLocal().getAnimation() == -1 && time <= 4000) {
time += 50;
Time.sleep(50);
}
... |
095827f4-0fee-4346-a432-0bdb27b06206 | 4 | @Override
public boolean parseField(String name, String value){
if (super.parseField(name, value)){
return true;
}
if (name != null && value != null){
StorageFieldHandler handler = EnumUtils.lookup(StorageFieldHandler.class, name);
if (handler != null){
return handler.handle(device, value);
... |
4813f421-3aeb-43dc-8a42-56b95799ec82 | 0 | public KeyContainerType createKeyContainerType() {
return new KeyContainerType();
} |
c8b420e9-f011-44aa-b282-9d37dbda10bb | 8 | @Override
public void populate(World world, Random random, Chunk source) {
ChunkSnapshot snapshot;
for (int i = 0; i < ITERATIONS; i++) {
if (random.nextInt(100) < CHANCE) {
snapshot = source.getChunkSnapshot();
if (random.nextInt(100) < CORNER_CHANCE) {
int x, z;
switch (random.nextInt(4)) {... |
90df9a5e-86db-4adb-9035-2352dd8aac90 | 7 | public List<Instance> readData() {
ArrayList<Instance> instances = new ArrayList<Instance>();
while (this._scanner.hasNextLine()) {
String line = this._scanner.nextLine();
if (line.trim().length() == 0)
continue;
FeatureVector feature_vector = new FeatureVector();
// Divide the line int... |
525df668-20e5-40a7-9f29-b48e75e75377 | 2 | private void closeKey(Integer handle) {
if (METHOD_CLOSE_KEY == null) {
METHOD_CLOSE_KEY = getMethod(mRoot.getClass(), "WindowsRegCloseKey", int.class);
}
try {
METHOD_CLOSE_KEY.invoke(mRoot, new Object[] { handle });
} catch (Exception exception) {
Log.error(exception);
}
} |
5cd90fca-3baa-4b16-8a3b-4e1f02ee8b59 | 8 | public void format(InStream in, OutStream out, FormatOptions formatOptions) throws FormatterException {
boolean isNewString = false;
boolean isAloneSpaceButton = false;
char c;
int braceCount = 0;
int parenthesisCount = 0;
char space = ' ';
try {
whi... |
1900d4b4-2a8d-4edf-8d41-5f240a543c8a | 7 | public Instances pruneToK(Instances neighbours, double[] distances, int k) {
if(neighbours==null || distances==null || neighbours.numInstances()==0) {
return null;
}
if (k < 1) {
k = 1;
}
int currentK = 0;
double currentDist;
for(int i=0; i < neighbours.numInstances(); ... |
49adfdcf-6218-44c1-a6c8-61abd9b6aa42 | 4 | private void broadcastAction(JSONObject action, AIConnection playerWhoPerformedTheAction){
Debug.debug("Action was valid, re-broadcasting (FIXME)");
try {
action.put("from", playerWhoPerformedTheAction.username);
}
catch (JSONException e){
}
try {
graphicsContainer.get().sendMessage(action);
}
catch (... |
eea727f3-01d4-4cd6-9f8c-1729e2573d0b | 0 | public boolean isPaused() {
return paused;
} |
c9c22da0-01ea-48f6-aba5-99a4b6598959 | 8 | public void convertCsvToClass(String path) {
File infile = new File(path);
File outfile = new File(infile.getParent(), "TorresAndGuerrero.dot");
String csvToRead = infile.getAbsolutePath();
BufferedReader br = null;
String line = "";
String splitBy = ",";
List<Tasks> taskList = new ArrayLi... |
186685d7-ebbd-4af7-b488-7875c44b8dd0 | 4 | public void centerOnPlayer(int px, int py, int mWidth, int mHeight) {
x = px - (width / 2);
if (x < 0)
x = 0;
if (x >= (mWidth * this.tileSize) - width) {
x = (mWidth * this.tileSize) - width;
}
y = py - (height / 2);
if (y < 0)
y = 0;
if (y >= ((mHeight) * this.tileSize) - height) {
y = ((mHeight... |
6f8255bf-6882-421f-b0da-6d6cbbe4ad67 | 0 | public int getEmptyNum() {
return this.totalNum - this.carList.size();
} |
d6322acd-d3e2-4936-a284-6235ab730390 | 7 | public static void main(String[] args) {
Integer start = 0;
Integer end = 0;
Integer stripe = 0;
Integer sNum = 0;
ArrayList<Integer> al = new ArrayList<Integer>();
try {
ServerSocket ss = new ServerSocket(Integer.parseInt(JOptionPane.showInputDialog("port number: ")));
Socket s = ss.accept();
Obj... |
41cbf14e-eb04-4fe1-8c0f-2d37d7c0181b | 1 | private String emptyIfNull(String message) {
return message == null ? "" : message;
} |
770dd690-5dfc-40a6-aa16-3fc8964c5b75 | 4 | public static void main(String[] args) {
ExecutorService executor = Executors.newFixedThreadPool(NTHREDS);
List<Future<Long>> list = new ArrayList<Future<Long>>();
for (int i = 0; i < 20000; i++) {
Callable<Long> worker = new MyCallable();
Future<Long> submit = executor.submit(worker);
list.add(submit);... |
d5dab4d5-6711-4e14-a25f-39742e615dbc | 6 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RenderMessage that = (RenderMessage) o;
if (isError != that.isError) return false;
if (messageText != null ? !messageText.equals(that.messageTe... |
24cfb8de-6259-42c8-b1b4-42e4f81abb3c | 7 | public void game() throws MessagingException {
try {
usedTime=1000;
SZYBKOSC=Integer.parseInt(readFile("src/poziom.txt"));
initWorld();
while (isVisible() && !gameEnded)
{
while (isVisible() && !gameEnded && !pause) {
... |
e0133a0e-3174-4ecf-88da-fbeec011fccc | 6 | public Long sumSetofPrimes(){
Long count = 0L;
for (int i =0; i<sumPrimesList.size(); i++){
int primeSum = sumPrimesList.get(i);
for (int j = 2 ; j <=i && j <primes.size(); j++){
int prime2 = primes.get(j);
int sum = prime2;
for (int k = j; sum<=primeSum && k <primes.size(); k++ ) {
//if(isPri... |
7518875e-a92c-40c0-ac58-906bb0b3a037 | 4 | private static double remainder(String attribute,
ArrayList<HashMap<String, String>> examples,
HashMap<String, String[]> attributeValues, String goalAttribute) {
double out = 0;
for (String attrValue : attributeValues.get(attribute)) {
ArrayList<HashMap<String, String>> examplesWValue = new ArrayList<HashM... |
7a2f68b3-1eff-4978-bb1d-703e8b68fe75 | 6 | @Override
public void insertElement(IndexPair pair) throws IOException {
if (!bitSignatureIndex.contains(pair.getElementId())) {
throw new RuntimeException("Element not in bit signature index: "+ pair);
}
// If there is no block yet, allocate one and insert the element.
if (firstBlock == nu... |
603c8573-ce9e-4b63-9dcd-de9718c701cb | 4 | public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
try {
new MenuPrincipal().setVisible(true);
} catch (FileNotFoundException ex) {
... |
633902b1-c565-4ba9-8f47-0ef238ebaa51 | 0 | public String getInputToRead() {
return myInputToRead;
} |
07d8fe84-3a19-40d0-b732-7019211f9a80 | 8 | @Override
public void tick(InputHandler input) {
super.tick(input);
while (GameWindow.w.next());
if (GameWindow.w.isPressed())
this.accelerate(new Vector(0,0.5));
while (GameWindow.a.next());
if (GameWindow.a.isPressed())
this.accelerate(new Vector(-0.5, 0));
while (GameWindow.s.next());
if (Gam... |
ff978dca-f296-4256-b9f6-981f0cb1947b | 9 | public final TWS_SCHEDULESParser.untilDefinition_return untilDefinition() throws RecognitionException {
TWS_SCHEDULESParser.untilDefinition_return retval = new TWS_SCHEDULESParser.untilDefinition_return();
retval.start = input.LT(1);
Object root_0 = null;
Token time=null;
Token string_literal163=null;
Tok... |
e0c9bb24-7965-41f6-bd4f-890c56c499a7 | 7 | public void applyMedianFilter(int size) throws MyExceptions {
MyNotOddNumberException.test("size", size);
MyOutOfBoundException.test("size", size, 3, Math.min(row, column)-1);
int width = (size - 1) / 2;
Data clone = new Data(this);
for(int i = width; i < row - width; ++i)
for(int j = width; j < column - w... |
8a45a07a-9538-468b-a1c7-03931d30cf59 | 2 | public boolean passTurnstile(Turnstile turnstile, SkiPass card) {
if (turnstile == null) {
throw new IllegalArgumentException("Turnstile is null");
}
if (card == null) {
throw new IllegalArgumentException("Ski-pass is null");
}
return turnstile.makePass(... |
183de9bb-a342-4b35-8b32-718087a8a450 | 9 | int insertKeyRehash(char val, int index, int hash, byte state) {
// compute the double hash
final int length = _set.length;
int probe = 1 + (hash % (length - 2));
final int loopIndex = index;
int firstRemoved = -1;
/**
* Look u... |
cd6f3ce9-0b00-4439-b72b-d3b7bba596a3 | 2 | @Override public URI authorizationCodeUrl(String... options) {
final Request req = Request.to(options.length == 0 ? Endpoints.CONNECT : options[0]).with(
"redirect_uri", mRedirectUri,
"client_id", mClientId,
"response_type", "code");
if (options.length == ... |
a52915ee-6f1f-4e9b-9d22-550c2d6ff915 | 4 | private double[] calculateCPUConsumption(Component component, HardwareAlternative hardwareAlternative) {
double consumption[] = { -1, -1 };
consumption[0] = component.getUsageCPU().getEnergyPoints();
for (HardwareComponent cpu : hardwareAlternative.getHardwareComponents()) {
double temp = Utils.consumptionCPU(... |
763ad0ec-ae4e-4808-b185-e5aa579bf30b | 3 | public void mouseClick() {
if (this.getSelectedColumn() == 0)
return;
prev = curr;
curr = (String) model.getValueAt(getSelectedRow(), 1);
boolean isDir = model.getValueAt(getSelectedRow(), 0) == folder_icon;
if (curr.equals(prev)) {
if (isDir) {
updateList(path + "/"
+ curr.s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.