method_id
stringlengths 36
36
| cyclomatic_complexity
int32 0
9
| method_text
stringlengths 14
410k
|
|---|---|---|
bb55d94a-4601-40d6-87f1-acda398dacaf
| 2
|
public String getInterfaceMethodrefName(int index) {
InterfaceMethodrefInfo minfo
= (InterfaceMethodrefInfo)getItem(index);
if (minfo == null)
return null;
else {
NameAndTypeInfo n
= (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex);
if(n == null)
return null;
else
return getUtf8Info(n.memberName);
}
}
|
85e95709-a9f3-4379-9edd-73cddf777ec9
| 8
|
public Tile returnBestCityScoresMod(int settlerR, int settlerC, int capitalR, int capitalC, double distBias, int maxDist)
{
evalBefore();
int[][] cityScores = new int[rows][cols];
for (int r = 0; r < rows; r++)
{
for (int c = 0; c < cols; c++)
{
int dist = (int)Math.sqrt(Math.pow(r-settlerR,2) + Math.pow(c-settlerC,2));
int capitalDist = (int)Math.sqrt(Math.pow(r-settlerR,2) + Math.pow(c-settlerC,2));
if (dist > maxDist || getTile(r,c).owner != null || getTile(r,c).biome == -1)
cityScores[r][c] = -9999;
else
{
cityScores[r][c] = returnCityScoreNoOwner(r,c)*5 - (int)(distBias*dist)*2 - (int)(distBias*capitalDist);
/*out:
for (int rr = r - 2; rr <= r + 2; rr++)
{
for (int cc = c - 2; cc <= c + 2; cc++)
{
Tile t = getTile(rr,cc);
if (t == null) continue;
if (t.improvement != null)
{
if (t.improvement instanceof City)
{
cityScores[r][c] = 0;
break out;
}
else
cityScores[r][c]--;
}
else
{
if (t.owner == null)
cityScores[r][c] += 4;
else
cityScores[r][c] += 2;
}
}
}*/
}
}
}
Tile candidate = tiles[0][0];
for (int r = 0; r < rows; r++)
{
for (int c = 0; c < cols; c++)
{
if (cityScores[r][c] > cityScores[candidate.row][candidate.col])
candidate = getTile(r,c);
}
}
return candidate;
}
|
3b9728c8-c02f-4d4f-b230-10545abcd53f
| 9
|
private void verifierAuthentification()
{
if (loginTF.getText().equals("") && pwdTF.getText().equals(""))
errorMessageLabel.setText("Les champs login et password sont vides.");
else if (loginTF.getText().equals(""))
errorMessageLabel.setText("Le champs login est vide.");
else if (pwdTF.getText().equals(""))
errorMessageLabel.setText("Le champs password est vide.");
else
{
try {
// TODO add your handling code here:
if (authentificationMetier.verifierAccee(loginTF.getText(), pwdTF.getText()))
{
Session.getInstance().connexion(AuthentificationDAO.getInstance().getByLogin(loginTF.getText()));
if (authentificationMetier.verifierBan(Session.getInstance().getUser().getIdAuthentification()))
{
errorMessageLabel.setText(Session.getInstance().getMessage());
}
else
{
if (Session.getInstance().getUser().getType() == 's')
{
GUI.SuperAdministrateur.Accueil acc = new GUI.SuperAdministrateur.Accueil();
acc.setVisible(true);
}
else if (Session.getInstance().getUser().getType() == 'a')
{
GUI.Administrateur.Accueil acc = new GUI.Administrateur.Accueil();
acc.setVisible(true);
}
this.dispose();
}
}
else
{
pwdTF.setText("");
pwdTF.requestFocus();
errorMessageLabel.setText("Veuillez vérifier votre login et/ou mot de passe");
}
} catch (ProblemeTechniqueException ex) {
errorMessageLabel.setText(ex.getMessage());
}
}
}
|
74d5ae4d-a569-4922-9331-12ced6e1f6bd
| 8
|
private static void preRenderChunk(
short[][] sectionBlockIds, byte[][] sectionBlockData,
boolean[] usedSections, byte[] biomeIds, BlockMap blockMap,
BiomeMap biomes, int cx, int cz, int[] colors, short[] heights) {
/**
* Color of 16 air blocks stacked
*/
final int air16Color = Color.overlay(0, getColor(blockMap, biomes, 0, 0, 0), 16);
int maxSectionCount = MAX_CHUNK_SECTIONS;
for (int s = 0; s < maxSectionCount; ++s) {
if (usedSections[s]) {
//++timer.sectionCount;
}
}
//resetInterval();
for (int z = 0; z < 16; ++z) {
for (int x = 0; x < 16; ++x) {
int pixelColor = 0;
short pixelHeight = 0;
int biomeId = biomeIds[z * 16 + x] & 0xFF;
for (int s = 0; s < maxSectionCount; ++s) {
if (usedSections[s]) {
short[] blockIds = sectionBlockIds[s];
byte[] blockData = sectionBlockData[s];
for (int idx = z * 16 + x, y = 0, absY = s * 16; y < 16; ++y, idx += 256, ++absY) {
final short blockId = blockIds[idx];
final byte blockDatum = blockData[idx];
int blockColor = getColor(blockMap, biomes, blockId & 0xFFFF, blockDatum, biomeId);
pixelColor = Color.overlay(pixelColor, blockColor);
if (Color.alpha(blockColor) >= SHADE_CUTOFF) {
pixelHeight = (short) absY;
}
}
} else {
pixelColor = Color.overlay(pixelColor, air16Color);
}
}
final int dIdx = 512 * (cz * 16 + z) + 16 * cx + x;
colors[dIdx] = pixelColor;
heights[dIdx] = pixelHeight;
}
}//pixelColor = new java.awt.Color(cz/32.0f,z/16.0f,cx/32.0f,x/16.0f).getRGB();
}
|
56b00422-e896-4d48-831d-5c3960fb5657
| 5
|
public synchronized static Logger getLogger() {
if(logger == null) {
try {
logger = Logger.getLogger("RedpinLogger");
FileHandler fh = new FileHandler(Configuration.LogFile);
if(Configuration.LogFormat == LoggerFormat.PLAIN) {
fh.setFormatter(new SimpleFormatter());
} else if(Configuration.LogFormat == LoggerFormat.XML) {
fh.setFormatter(new XMLFormatter());
} else {
//default
fh.setFormatter(new SimpleFormatter());
}
logger.addHandler(fh);
logger.setLevel(Configuration.LogLevel);
} catch (SecurityException e) {
// TODO Auto-generated catch block
System.err.println(e.getMessage());
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
System.err.println(e.getMessage());
e.printStackTrace();
}
}
return logger;
}
|
c002c560-d48c-4dd1-8b4b-df7b74ad55ad
| 0
|
public String getType() {
return type;
}
|
fd6750a7-68ab-418b-be70-ae35a2be87a4
| 5
|
static final int method1908(int i, int i_1_, int i_2_, boolean bool,
int i_3_, int i_4_, int i_5_) {
i_2_ &= 0x3;
anInt3216++;
if (bool != true)
aClass21_3217 = null;
if ((i_5_ & 0x1 ^ 0xffffffff) == -2) {
int i_6_ = i_4_;
i_4_ = i_3_;
i_3_ = i_6_;
}
if ((i_2_ ^ 0xffffffff) == -1)
return i_1_;
if (i_2_ == 1)
return i;
if ((i_2_ ^ 0xffffffff) == -3)
return 7 + -i_1_ + (-i_4_ + 1);
return -i_3_ - (-1 - (7 - i));
}
|
9777122f-a24d-4c53-81b4-1acf2e92b1d6
| 6
|
public synchronized boolean removeIRCEventListener(IRCEventListener l) {
if (l == null)
return false;
int index = -1;
for (int i = 0; i < listeners.length; i++)
if (listeners[i].equals(l)) {
index = i;
break;
}
if (index == -1)
return false;
listeners[index] = null;
int len = listeners.length - 1;
IRCEventListener[] newListeners = new IRCEventListener[len];
for (int i = 0, j = 0; i < len; j++)
if (listeners[j] != null)
newListeners[i++] = listeners[j];
listeners = newListeners;
return true;
}
|
2c7b774d-7230-4f92-ad4f-b19c3f224f92
| 4
|
private Vector2 adjust(float minx, float maxx, float miny, float maxy, Vector2 v){
if(v.x > maxx - viewportWidth * zoom / 2) v.x = maxx - viewportWidth * zoom / 2;
if(v.x < minx + viewportWidth * zoom / 2) v.x = minx + viewportWidth * zoom / 2;
if(v.y > maxy - viewportHeight * zoom / 2) v.y = maxy - viewportHeight * zoom / 2;
if(v.y < miny + viewportHeight * zoom / 2) v.y = miny + viewportHeight * zoom / 2;
return v;
}
|
137b5924-6e85-4e1f-bdba-25815abbe62a
| 5
|
private static void write(Path path) throws IOException, InterruptedException {
int value;
int width;
int height;
byte rgba[] = new byte[4];
int bitmap[];
PixelGrabber pg;
BufferedImage img = null;
try {
img = ImageIO.read(image.toFile());
image = path;
} catch (IOException e) {
IllegalStateException ise = new IllegalStateException("An exception occured while converting!");
Main.handleUnhandableProblem(ise);
}
width = img.getWidth();
height = img.getHeight();
bitmap = new int[width * height];
pg = new PixelGrabber(img, 0, 0, width, height, bitmap, 0, width);
pg.grabPixels();
bfSize = ((width * height) * 4) + BITMAPFILEHEADER_SIZE + BITMAPINFOHEADER_SIZE;
biWidth = width;
biHeight = height;
if (!Files.exists(image, LinkOption.NOFOLLOW_LINKS)) {
Files.createFile(image);
assert Files.exists(image);
}
try (OutputStream fo = new FileOutputStream(image.toFile())) {
{
fo.write(AbstractBitmap.bfType);
fo.write(intToDWord(bfSize));
fo.write(intToDWord(AbstractBitmap.bfReserved));
fo.write(intToDWord(AbstractBitmap.bfOffBits));
}
{
fo.write(intToDWord(AbstractBitmap.biSize));
fo.write(intToDWord(biWidth));
fo.write(intToDWord(biHeight));
fo.write(intToWord(AbstractBitmap.biPlanes));
fo.write(intToWord(AbstractBitmap.biBitCount));
fo.write(intToDWord(AbstractBitmap.biCompression));
fo.write(intToDWord(AbstractBitmap.biSizeImage));
fo.write(intToDWord(AbstractBitmap.biXPelsPerMeter));
fo.write(intToDWord(AbstractBitmap.biYPelsPerMeter));
fo.write(intToDWord(AbstractBitmap.biClrUsed));
fo.write(intToDWord(AbstractBitmap.biClrImportant));
}
{
for (int col = biHeight - 1; col >= 0; col--) {
for (int row = 0; row < biWidth; row++) {
value = bitmap[(col * biWidth) + row];
rgba[0] = (byte) (value & 0xFF);
rgba[1] = (byte) ((value >> 8) & 0xFF);
rgba[2] = (byte) ((value >> 16) & 0xFF);
rgba[3] = (byte) ((value >> 24) & 0xFF);
fo.write(rgba);
}
}
}
fo.flush();
fo.close();
} catch (IOException e) {
throw e;
}
}
|
903a4857-7d11-41c7-977c-480a1e605e8e
| 4
|
public int[] sensedCell(int[] pos, int dir, Sense.senseDir sD) {
int[] sensedCellPos = new int[2];
switch (sD) {
case HERE:
sensedCellPos = pos;
break;
case AHEAD:
sensedCellPos = adjacentCell(dir);
break;
case LEFTAHEAD:
sensedCellPos = adjacentCell((dir + 5) % 6);
break;
case RIGHTAHEAD:
sensedCellPos = adjacentCell((dir + 1) % 6);
break;
}
return sensedCellPos;
}
|
c1545730-16b7-43ab-858d-3f9cc6e18472
| 3
|
public void tick() {
time++;
if (time >= lifeTime) {
remove();
return;
}
xx += xa;
yy += ya;
zz += za;
if (zz < 0) {
zz = 0;
za *= -0.5;
xa *= 0.6;
ya *= 0.6;
}
za -= 0.15;
int ox = x;
int oy = y;
int nx = (int) xx;
int ny = (int) yy;
int expectedx = nx - x;
int expectedy = ny - y;
move(nx - x, ny - y);
int gotx = x - ox;
int goty = y - oy;
xx += gotx - expectedx;
yy += goty - expectedy;
if (hurtTime > 0) hurtTime--;
}
|
f9ad22b5-4fd8-472f-86fa-d589f787d8ce
| 7
|
public int[] merge(int[] L1, int[] L2) {
int[] L = new int[L1.length + L2.length];
int i = 0;
while ((L1.length != 0) && (L2.length != 0)) {
if (L1[0] < L2[0]) {
L[i++] = L1[0];
L1 = eliminar(L1);
if (L1.length == 0) {
while (L2.length != 0) {
L[i++] = L2[0];
L2 = eliminar(L2);
}
}
} else {
L[i++] = L2[0];
L2 = eliminar(L2);
if (L2.length == 0) {
while (L1.length != 0) {
L[i++] = L1[0];
L1 = eliminar(L1);
}
}
}
}
return L;
}
|
1b51257f-2b09-47b2-81ff-3b54ab8aafad
| 1
|
public Car build() {
if (builtOn != null) {
throw new IllegalStateException("can't call build more than once");
}
builtOn = new Date();
delegate.setBuiltOn(builtOn);
return delegate;
}
|
5d8fe2b0-e2a3-4828-90ca-72d02ecf0cb5
| 4
|
* @return Returns whether the given column in the line with the given
* index lies within a tab character.
*/
public boolean column_in_tab(int line, int col) {
int ind = 0;
StringBuilder l = code.getsb(line);
int i;
for (i = 0; i < col && ind < l.length(); ind++) {
if (l.charAt(ind) == '\t') {
i += Settings.indentSizeInSpaces;
i /= Settings.indentSizeInSpaces;
i *= Settings.indentSizeInSpaces;
if (i > col) {
return true;
}
} else {
i++;
}
}
return false;
}
|
eedb917b-1820-4ef6-80ef-86da05c124b2
| 3
|
*@param nivel
* @return des
**/
public long cobrarMiembros(beansMiembro miembro, int nivel){
long a = 0, desc = 0, des = 0;
if(nivel <= 10){
if(condicionarPago(miembro.getListaInterna(), nivel) == true){
for(beansMiembro miembroInterno : miembro.getListaInterna()){
desc += devolverPorcentaje(miembroInterno.getEgresos(), nivel)+50;
a = cobrarMiembros(miembroInterno, nivel+1);
des = a + desc;
}
}
}
return des;
}
|
10bcf01c-992e-4b1b-a48b-da341ae90dac
| 6
|
@Override
public void caseADeclLeiaDefinicaoComando(ADeclLeiaDefinicaoComando node)
{
inADeclLeiaDefinicaoComando(node);
if(node.getLeia() != null)
{
node.getLeia().apply(this);
}
if(node.getLPar() != null)
{
node.getLPar().apply(this);
}
if(node.getMultiploId() != null)
{
node.getMultiploId().apply(this);
}
if(node.getIdentificador() != null)
{
node.getIdentificador().apply(this);
}
if(node.getRPar() != null)
{
node.getRPar().apply(this);
}
if(node.getPontoVirgula() != null)
{
node.getPontoVirgula().apply(this);
}
outADeclLeiaDefinicaoComando(node);
}
|
20168b4e-55a0-40c4-9b44-8deb025a8bea
| 5
|
public void applyMove(Operators2048 op) {
boolean moved = false;
switch (op) {
case UP:
moved = moveUp();
break;
case DOWN:
moved = moveDown();
break;
case RIGHT:
moved = moveRight();
break;
case LEFT:
moved = moveLeft();
break;
}
if (moved) {
addTile();
}
}
|
4283458c-805c-4890-9d04-a4497e8afacc
| 9
|
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AtLine atLine = (AtLine) o;
if (clazz != null ? !clazz.equals(atLine.clazz) : atLine.clazz != null) return false;
if (method != null ? !method.equals(atLine.method) : atLine.method != null) return false;
if (source != null ? !source.equals(atLine.source) : atLine.source != null) return false;
return true;
}
|
eff71b0a-e00e-42a3-8ad2-0491c88dacc4
| 5
|
@SuppressWarnings("unchecked")
public void load(String courseraUrl) throws IOException {
// Coursera has a limit of 1000 courses per query, but over 1500
// classes at the time of this writing. We will use categories as
// additional argument to split the whole thing into multiple requests.
universities.clear();
uniIdsByShortName.clear();
categories.clear();
courses.clear();
// Page size limit is 1000.
long pageSize = 100;
long start = 0;
loadWithParams(courseraUrl, pageSize, start);
long total = (Long) ((HashMap<String, Object>) json.get("paging"))
.get("total");
System.out.println("Paging says " + total + " classes");
System.out.println("The whole thing " + this);
// Now the rest of them.
start = pageSize;
while (start < total) {
long chunk = Math.min(pageSize, total-start);
System.out.println("Loading " + chunk + " starting at " + start);
loadWithParams(courseraUrl, chunk, start);
start += chunk;
}
System.out.println("Done loading 1. Got " + this);
long missing = total - courses.size();
//if (missing > 0)
// loadWithParams(courseraUrl + "&certificates=VerifiedCert&start=0", 1000, null);
//missing = total - courses.size();
//System.out.println("Done loading 2. Got " + this);
System.out.println("Still missing " + missing + " classes.");
for (HashMap<String, Object> crs : courses.values()) {
ArrayList<String> lst = (ArrayList<String>) crs.get("categories");
if (lst == null) continue;
for (String name : lst) {
if (!categories.containsKey(name)) {
categories.put(name, null);
}
}
}
}
|
0a1178d2-e2b5-43e3-98b8-8ad7de6cf53c
| 2
|
public static ArrayList<TestReaction> findTestReactionByTestId(ArrayList<TestReaction> testReactions, int id) {
ArrayList<TestReaction> outputReactions = new ArrayList<TestReaction>();
for(TestReaction tr:testReactions) {
if(tr.test==id) {
outputReactions.add(tr);
}
}
return outputReactions;
}
|
2d5e28c3-3012-4273-a29c-a875905e04fa
| 7
|
private void writeOriginsQuartiles(String originsQuartilesFilename,
Map<Byte, SpikeClassStats> stats, SpikeClassStats single33,
SpikeClassStats single66, SpikeClassStats single100, byte maxHop)
throws IOException {
// create folders if needed
if (originsQuartilesFilename.lastIndexOf("/") != -1) {
File file = new File(originsQuartilesFilename.substring(0,
originsQuartilesFilename.lastIndexOf("/")));
file.mkdirs();
}
FileWriter ofwr = new FileWriter(originsQuartilesFilename);
BufferedWriter obwr = new BufferedWriter(ofwr);
// write origins for correlated
for (byte hop = 1; hop <= maxHop; hop++) {
// write current hop
if (hop == 1) {
// start first line
obwr.write(hop + " hop");
} else {
// make new line and write "hopS"
obwr.write("\n" + hop + " hops");
}
// write xtic
obwr.write("\t" + hop * 10);
if (stats.get(hop) != null) {
Quartiles quartiles = stats.get(hop).getOriginsQuartiles();
obwr.write("\t" + quartiles.getFirstQuartile() + "\t"
+ quartiles.getMediana() + "\t"
+ quartiles.getThirdQuartile() + "\t"
+ quartiles.getMin() + "\t" + quartiles.getMax());
} else {
obwr.write("\t0\t0\t0\t0\t0");
}
}
// write origins for single
Quartiles quartiles;
// 33
quartiles = single33.getOriginsQuartiles();
if (quartiles != null) {
obwr.write("single33\t" + (maxHop + 1) * 10);
obwr.write("\t" + quartiles.getFirstQuartile() + "\t"
+ quartiles.getMediana() + "\t"
+ quartiles.getThirdQuartile() + "\t" + quartiles.getMin()
+ "\t" + quartiles.getMax());
}
// 66
quartiles = single66.getOriginsQuartiles();
if (quartiles != null) {
obwr.write("single66\t" + (maxHop + 2) * 10);
obwr.write("\t" + quartiles.getFirstQuartile() + "\t"
+ quartiles.getMediana() + "\t"
+ quartiles.getThirdQuartile() + "\t" + quartiles.getMin()
+ "\t" + quartiles.getMax());
}
// 100
quartiles = single100.getOriginsQuartiles();
if (quartiles != null) {
obwr.write("single100\t" + (maxHop + 3) * 10);
obwr.write("\t" + quartiles.getFirstQuartile() + "\t"
+ quartiles.getMediana() + "\t"
+ quartiles.getThirdQuartile() + "\t" + quartiles.getMin()
+ "\t" + quartiles.getMax());
}
obwr.close();
ofwr.close();
}
|
81a1650e-9a09-4112-9b12-59942000bf89
| 8
|
public Image scale(Image img)
{
// Offset the image by one pixel so there's a border around it.
// This lets us avoid having to check that A-I are in range of the image before samping them
sourceGraphics.drawImage(img, 1, 1, null);
int line = width + 2;
for (int y = 0; y < height; y++)
{
// Two lines of target pixel pointers
int tp0 = y * width * 4 - 1;
int tp1 = tp0 + width * 2;
// Three lines of source pixel pointers
int sp0 = (y) * line;
int sp1 = (y + 1) * line;
int sp2 = (y + 2) * line;
// Fill the initial A-I values
int A = sourcePixels[sp0];
int B = sourcePixels[++sp0];
int C = sourcePixels[++sp0];
int D = sourcePixels[sp1];
int E = sourcePixels[++sp1];
int F = sourcePixels[++sp1];
int G = sourcePixels[sp2];
int H = sourcePixels[++sp2];
int I = sourcePixels[++sp2];
for (int x = 0; x < width; x++)
{
if (B != H && D != F)
{
targetPixels[++tp0] = D == B ? D : E;
targetPixels[++tp0] = B == F ? F : E;
targetPixels[++tp1] = D == H ? D : E;
targetPixels[++tp1] = H == F ? F : E;
}
else
{
targetPixels[++tp0] = E;
targetPixels[++tp0] = E;
targetPixels[++tp1] = E;
targetPixels[++tp1] = E;
}
// Scroll A-I left
A = B;
B = C;
D = E;
E = F;
G = H;
H = I;
// Resample rightmost edge
C = sourcePixels[++sp0];
F = sourcePixels[++sp1];
I = sourcePixels[++sp2];
}
}
return targetImage;
}
|
954fecab-9d0d-4d7c-8934-d548107be0d6
| 9
|
public static Command inputEventToCommand(InputEvent e) {
if (e==null) {return NO_COMMAND;}
if (e instanceof KeyEvent) {
switch (((KeyEvent)e).getKeyChar()) {
case 'w': return MOVE_UP;
case 'a': return MOVE_LEFT;
case 's': return MOVE_DOWN;
case 'd': return MOVE_RIGHT;
case '=': return DEBUG_DUMPDISPLAYS;
default: return INVALID_KEY_COMMAND;
}
} else if (e instanceof MouseEvent) {
switch(((MouseEvent) e).getButton()) {
case MouseEvent.BUTTON1: return SPAWN_BALL;
default: return INVALID_MOUSE_COMMAND;
}
} else {
return WTF;
}
}
|
e2f84145-de9c-495b-a4e0-3657fe1223fb
| 5
|
public void extract(LauncherAPI api, int min, int max)
{
System.out.println("Extracting '" + getFileName() + "'...");
if (type == Type.NATIVE || type == Type.ADDITIONNAL)
{
File dest = this.dest;
boolean recursive = true;
if (type == Type.ADDITIONNAL)
{
dest = api.getMinecraftDirectory();
recursive = false;
}
try
{
if (FileExtractor.extract(api, this, dest, min, max,
recursive))
{
}
}
catch (final Exception e)
{
e.printStackTrace();
}
}
}
|
e607e903-b9b6-4244-88d8-7b8399996a49
| 7
|
static String toHex4ByteString(int i) {
String hex = Integer.toHexString(i);
if (hex.length() == 1)
return "0000000" + hex;
if (hex.length() == 2)
return "000000" + hex;
if (hex.length() == 3)
return "00000" + hex;
if (hex.length() == 4)
return "0000" + hex;
if (hex.length() == 5)
return "000" + hex;
if (hex.length() == 6)
return "00" + hex;
if (hex.length() == 7)
return "0" + hex;
return hex;
}
|
5e7087c5-5c58-427e-8354-efb2de571c9b
| 1
|
private String parseSettingsPath(String settingsPath) {
if (settingsPath.matches("^~.*")) {
settingsPath = settingsPath.replace("~", "");
String home = System.getProperty("user.home");
settingsPath = home + settingsPath;
}
return settingsPath;
}
|
0154a575-897f-4663-a2ca-ef9c6481bec6
| 4
|
public void calculateCycleLength(){
boolean notFound = true;
int currentState;
int threshhold = 10;
while(notFound){
for(int i=0;i<threshhold;i++){
update();
}
currentState = getState();
for(int i=0;i<threshhold;i++){
update();
if (currentState == getState()){
notFound = false;
cycleLength=i+1;
break;
}
}
threshhold *= 2;
}
}
|
330cc258-ad08-4d28-b3e5-9e85689923fd
| 9
|
public boolean renderBlockFenceGate(BlockFenceGate par1BlockFenceGate, int par2, int par3, int par4)
{
boolean flag = true;
int i = blockAccess.getBlockMetadata(par2, par3, par4);
boolean flag1 = BlockFenceGate.isFenceGateOpen(i);
int j = BlockDirectional.getDirection(i);
if (j == 3 || j == 1)
{
float f = 0.4375F;
float f4 = 0.5625F;
float f8 = 0.0F;
float f12 = 0.125F;
par1BlockFenceGate.setBlockBounds(f, 0.3125F, f8, f4, 1.0F, f12);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
f8 = 0.875F;
f12 = 1.0F;
par1BlockFenceGate.setBlockBounds(f, 0.3125F, f8, f4, 1.0F, f12);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
}
else
{
float f1 = 0.0F;
float f5 = 0.125F;
float f9 = 0.4375F;
float f13 = 0.5625F;
par1BlockFenceGate.setBlockBounds(f1, 0.3125F, f9, f5, 1.0F, f13);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
f1 = 0.875F;
f5 = 1.0F;
par1BlockFenceGate.setBlockBounds(f1, 0.3125F, f9, f5, 1.0F, f13);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
}
if (flag1)
{
if (j == 3)
{
par1BlockFenceGate.setBlockBounds(0.8125F, 0.375F, 0.0F, 0.9375F, 0.9375F, 0.125F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.8125F, 0.375F, 0.875F, 0.9375F, 0.9375F, 1.0F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.5625F, 0.375F, 0.0F, 0.8125F, 0.5625F, 0.125F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.5625F, 0.375F, 0.875F, 0.8125F, 0.5625F, 1.0F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.5625F, 0.75F, 0.0F, 0.8125F, 0.9375F, 0.125F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.5625F, 0.75F, 0.875F, 0.8125F, 0.9375F, 1.0F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
}
else if (j == 1)
{
par1BlockFenceGate.setBlockBounds(0.0625F, 0.375F, 0.0F, 0.1875F, 0.9375F, 0.125F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.0625F, 0.375F, 0.875F, 0.1875F, 0.9375F, 1.0F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.1875F, 0.375F, 0.0F, 0.4375F, 0.5625F, 0.125F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.1875F, 0.375F, 0.875F, 0.4375F, 0.5625F, 1.0F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.1875F, 0.75F, 0.0F, 0.4375F, 0.9375F, 0.125F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.1875F, 0.75F, 0.875F, 0.4375F, 0.9375F, 1.0F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
}
else if (j == 0)
{
par1BlockFenceGate.setBlockBounds(0.0F, 0.375F, 0.8125F, 0.125F, 0.9375F, 0.9375F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.875F, 0.375F, 0.8125F, 1.0F, 0.9375F, 0.9375F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.0F, 0.375F, 0.5625F, 0.125F, 0.5625F, 0.8125F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.875F, 0.375F, 0.5625F, 1.0F, 0.5625F, 0.8125F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.0F, 0.75F, 0.5625F, 0.125F, 0.9375F, 0.8125F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.875F, 0.75F, 0.5625F, 1.0F, 0.9375F, 0.8125F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
}
else if (j == 2)
{
par1BlockFenceGate.setBlockBounds(0.0F, 0.375F, 0.0625F, 0.125F, 0.9375F, 0.1875F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.875F, 0.375F, 0.0625F, 1.0F, 0.9375F, 0.1875F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.0F, 0.375F, 0.1875F, 0.125F, 0.5625F, 0.4375F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.875F, 0.375F, 0.1875F, 1.0F, 0.5625F, 0.4375F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.0F, 0.75F, 0.1875F, 0.125F, 0.9375F, 0.4375F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(0.875F, 0.75F, 0.1875F, 1.0F, 0.9375F, 0.4375F);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
}
}
else if (j == 3 || j == 1)
{
float f2 = 0.4375F;
float f6 = 0.5625F;
float f10 = 0.375F;
float f14 = 0.5F;
par1BlockFenceGate.setBlockBounds(f2, 0.375F, f10, f6, 0.9375F, f14);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
f10 = 0.5F;
f14 = 0.625F;
par1BlockFenceGate.setBlockBounds(f2, 0.375F, f10, f6, 0.9375F, f14);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
f10 = 0.625F;
f14 = 0.875F;
par1BlockFenceGate.setBlockBounds(f2, 0.375F, f10, f6, 0.5625F, f14);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(f2, 0.75F, f10, f6, 0.9375F, f14);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
f10 = 0.125F;
f14 = 0.375F;
par1BlockFenceGate.setBlockBounds(f2, 0.375F, f10, f6, 0.5625F, f14);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(f2, 0.75F, f10, f6, 0.9375F, f14);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
}
else
{
float f3 = 0.375F;
float f7 = 0.5F;
float f11 = 0.4375F;
float f15 = 0.5625F;
par1BlockFenceGate.setBlockBounds(f3, 0.375F, f11, f7, 0.9375F, f15);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
f3 = 0.5F;
f7 = 0.625F;
par1BlockFenceGate.setBlockBounds(f3, 0.375F, f11, f7, 0.9375F, f15);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
f3 = 0.625F;
f7 = 0.875F;
par1BlockFenceGate.setBlockBounds(f3, 0.375F, f11, f7, 0.5625F, f15);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(f3, 0.75F, f11, f7, 0.9375F, f15);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
f3 = 0.125F;
f7 = 0.375F;
par1BlockFenceGate.setBlockBounds(f3, 0.375F, f11, f7, 0.5625F, f15);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
par1BlockFenceGate.setBlockBounds(f3, 0.75F, f11, f7, 0.9375F, f15);
renderStandardBlock(par1BlockFenceGate, par2, par3, par4);
}
par1BlockFenceGate.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
return flag;
}
|
fbdfccf5-2f7c-4f47-b487-83ab839a9efa
| 5
|
public boolean existeRelacion( String nombreClaseA, String nombreClaseB, int tipoRelacion ){
for ( int i=0 ; i<listaFigura.size() ; i++ ) {
if ( listaFigura.get(i) instanceof RelacionGrafica ){
RelacionGrafica r = (RelacionGrafica)listaFigura.get(i);
String nrA=r.getRelacion().getClaseOrigen().getNombre();
String nrB=r.getRelacion().getClaseDestino().getNombre();
if ( nrA.equals(nombreClaseA) && nrB.equals(nombreClaseB) &&
r.getRelacion().getTipo()==tipoRelacion )
return true;
}
}
return false;
}
|
f8af59a1-3dfe-4b7c-a157-5696f3906649
| 3
|
public void visitLdcInsn(final Object cst) {
buf.setLength(0);
buf.append(tab2).append("LDC ");
if (cst instanceof String) {
appendString(buf, (String) cst);
} else if (cst instanceof Type) {
buf.append(((Type) cst).getDescriptor()).append(".class");
} else {
buf.append(cst);
}
buf.append('\n');
text.add(buf.toString());
if (mv != null) {
mv.visitLdcInsn(cst);
}
}
|
b92bc23b-aeb1-40f1-9592-b2e534d4f6fd
| 7
|
boolean isDynamicTypePersistenceModeDifferent(SystemObjectTypeProperties property, DynamicObjectType.PersistenceMode persistenceMode) {
// Liste der erweiterten Typen (SuperTypen)
final List<SystemObjectType> superTypes = new ArrayList<SystemObjectType>();
superTypes.addAll(createSuperTypes(property.getExtendedPids()));
switch(property.getPersistenceMode()) {
case TRANSIENT_OBJECTS:
if(persistenceMode != DynamicObjectType.PersistenceMode.TRANSIENT_OBJECTS) return true;
break;
case PERSISTENT_OBJECTS:
if(persistenceMode != DynamicObjectType.PersistenceMode.PERSISTENT_OBJECTS) return true;
break;
case PERSISTENT_AND_INVALID_ON_RESTART:
if(persistenceMode != DynamicObjectType.PersistenceMode.PERSISTENT_AND_INVALID_ON_RESTART) return true;
break;
default: // es wurde kein PersistenceMode angegeben
if(_configurationImport.getSuperTypePersistenceMode(superTypes) != persistenceMode) return true;
}
return false;
}
|
9dd82d2f-45cc-45d4-8c1a-5a02425cf2d8
| 8
|
public boolean similar(Object other) {
if (!(other instanceof JSONArray)) {
return false;
}
int len = this.length();
if (len != ((JSONArray)other).length()) {
return false;
}
for (int i = 0; i < len; i += 1) {
Object valueThis = this.get(i);
Object valueOther = ((JSONArray)other).get(i);
if (valueThis instanceof JSONObject) {
if (!((JSONObject)valueThis).similar(valueOther)) {
return false;
}
} else if (valueThis instanceof JSONArray) {
if (!((JSONArray)valueThis).similar(valueOther)) {
return false;
}
} else if (!valueThis.equals(valueOther)) {
return false;
}
}
return true;
}
|
3626701e-4741-447b-b524-2b646aa17bfa
| 3
|
static String getFingerPrint(HASH hash, byte[] data){
try{
hash.init();
hash.update(data, 0, data.length);
byte[] foo=hash.digest();
StringBuffer sb=new StringBuffer();
int bar;
for(int i=0; i<foo.length;i++){
bar=foo[i]&0xff;
sb.append(chars[(bar>>>4)&0xf]);
sb.append(chars[(bar)&0xf]);
if(i+1<foo.length)
sb.append(":");
}
return sb.toString();
}
catch(Exception e){
return "???";
}
}
|
3da4dfb2-09c5-4163-bfb3-1cee4ee61a08
| 5
|
public final void method43(AbstractToolkit var_ha, int i) {
if (i != -14218)
aBoolean10019 = false;
anInt10016++;
Object object = null;
r var_r;
if (aR10036 == null && aBoolean10003) {
Class2 class2 = method2417(i + 14218, var_ha, 262144, true);
var_r = class2 != null ? ((Class2) class2).aR118 : null;
} else {
var_r = aR10036;
aR10036 = null;
}
if (var_r != null)
Class169.method1301(var_r, ((Class318_Sub1) this).mapHeightLevel,
((Class318_Sub1) this).xHash,
((Class318_Sub1) this).anInt6388, null);
}
|
4b554903-8959-49ed-904d-3582eef34120
| 3
|
public Move chooseMove(State s) {
// remember who we are so we can correctly evaluate states
me = s.whoseTurn();
// The rest of this function looks a lot like evalMove, except
// that it doesn't just track the minimaxvalue, but also the
// best move itself.
// get a list of possible moves
MyList moves = s.findMoves();
Collections.shuffle(moves);
// shuffle so we don't always take the same maximum
// return if there are no moves
if (moves.size() == 0)
return null;
// Iterate over all moves
Iterator it = moves.iterator();
// We already know there is at least one move, so use it to
// initialize minimaxvalue
Move bestMove = (Move) it.next();
int minimaxvalue = evalMove(bestMove, s, maxdepth);
// now the rest of the moves
while (it.hasNext()) {
Move move = (Move) it.next();
int eval = evalMove(move, s, maxdepth);
// if we found a better move, remember it
if (eval > minimaxvalue) {
minimaxvalue = eval;
bestMove = move;
}
}
return bestMove;
}
|
4ac30848-f8aa-4abd-9983-1dea0113fa57
| 7
|
@Override
public Column parse() {
if(!this.prepared) {
this.prepared = true;
StringBuilder sB = new StringBuilder();
sB.append(this.name);
String type = this.t.getTextual();
if(this.t == DataType.RAW) {
sB.append(type.replace("%1", this.data));
}else if(null != this.length) {
sB.append(type.replace("%1", String.valueOf(this.length.intValue())));
}else{
sB.append(type);
}
if(this.n) {
sB.append(" DEFAULT NULL ");
}else{
sB.append(" NOT NULL ");
if(this.rawDef) {
sB.append(" DEFAULT ");
sB.append(this.def);
sB.append(" ");
}else{
if(null != this.def) {
sB.append(" DEFAULT '");
sB.append(this.def);
sB.append("' ");
}
}
}
if(this.A_INCR) {
sB.append(" AUTO_INCREMENT ");
}
this.field = sB.toString();
}
return this;
}
|
c07522b9-125c-45a5-8088-14ab3a3964cd
| 4
|
@SuppressWarnings("deprecation")
@EventHandler
public void onTeamChatKick(PlayerKickEvent event){
if(functions.isPlayerInTC(event.getPlayer())){
if(config.getBoolean("tc.general.kick-offline-players")){
TeamChat2.remove(event.getPlayer().getName());
for(Player p : Bukkit.getServer().getOnlinePlayers()){
if(functions.isPlayerInTC111(p)){
p.sendMessage(Tag + lang.TeamChatLeave(event.getPlayer(), "chat"));
}
}
}
}
}
|
450a7842-a759-49b7-8920-1ba9ce0263e5
| 5
|
void searchFiu(String ID)
{
//read text file
String line = "";
//traverses the whole file line by line
try
{
BufferedReader reader = new BufferedReader(
new FileReader("FiuDB.txt"));
while((line = reader.readLine()) != null)
{
String[] tokens = line.split(" ");
if(tokens[0].equalsIgnoreCase(userID))
{
userType = tokens[1];
for(int i = 2; i < tokens.length; i++)
{
userName += tokens[i];
if(i + 1 != tokens.length)
userName += " ";
}
reader.close();
return;
}
}
userType = "Invalid";
reader.close();
}
//handles any exception caused by reading the file
catch(IOException e)
{
System.out.println("There was an error while reading the file");
}
}
|
93c42c16-30db-4603-9393-31e5b174d776
| 4
|
private void displayCompResults(List<SplitMapperCompJvmCost> cMapperJvmCostList, List<SplitReducerCompJvmCost> cReducerJvmCostList,
String mapperFile, String reducerFile, String jobName) throws IOException {
File mFile = new File(mapperFile);
File rFile = new File(reducerFile);
if(!mFile.getParentFile().exists())
mFile.getParentFile().mkdirs();
if(!rFile.getParentFile().exists())
rFile.getParentFile().mkdirs();
PrintWriter cMapperWriter = new PrintWriter(new FileWriter(mFile));
PrintWriter cReducerWriter = new PrintWriter(new FileWriter(rFile));
//cMapperWriter.println("--------------------------------Mapper Comparison--------------------------------");
cMapperWriter.println("split" + "\t" + "xmx" + "\t" + "xms" + "\t" + "ismb" + "\t" + "RN" + "\t" + "Bytes" + "\t"
+ "rxOU" + "\t" + "exOU" + "\t" + "diff" + "\t"
+ "rmNGU" + "\t" + "rxNGU" + "\t" + "exNGU" + "\t" + "mDiff" + "\t" + "rDiff" + "\t"
+ "rnOU" + "\t" + "enOU" + "\t" + "diff" + "\t"
+ "rnNGU" + "\t" + "enNGU" + "\t" + "diff" + "\t"
+ "rnHeapU" + "\t" + "enHeapU" + "\t" + "diff" + "\t"
+ "rxHeapU" + "\t" + "exHeapU" + "\t" + "diff" + "\t"
+ "rnRSS" + "\t" + "rxRSS" + "\t" + "HRDiff" + "\t"
+ "rnEdenU" + "\t" + "rxEdenU" + "\t"
+ "rxS0U" + "\t" + "rxS1U" + "\t"
+ "enTempObj" + "\t" + "exTempObj" + "\t" + "enFix" + "\t" + "exFix" + "\t"
+ "OGC" + "\t" + "OGCMX" + "\t" + "NGC" + "\t" + "NGCMX" + "\t" + "EdenC" + "\t" + "S0C" + "\t"
+ "mYGC" + "\t" + "mFGC" + "\t" + "mTime" + "\t" + "reason");
for(SplitMapperCompJvmCost cJvmCost : cMapperJvmCostList)
cMapperWriter.println(cJvmCost);
//cReducerWriter.println("--------------------------------Redcucer Comparison-------------------------------");
cReducerWriter.println("split" + "\t" + "xmx" + "\t" + "xms" + "\t" + "ismb" + "\t" + "RN" + "\t"
+ "rmOU" + "\t" + "rxOU" + "\t" + "exOU" + "\t" + "mDiff" + "\t" + "xDiff" + "\t"
+ "rmNGU" + "\t" + "rxNGU" + "\t" + "exNGU" + "\t" + "mDiff" + "\t" + "xDiff" + "\t"
+ "rnOU" + "\t" + "enOU" + "\t" + "diff" + "\t"
+ "rnNGU" + "\t" + "enNGU" + "\t" + "diff" + "\t"
+ "rnHeapU" + "\t" + "enHeapU" + "\t" + "diff" + "\t"
+ "rxHeapU" + "\t" + "exHeapU" + "\t" + "diff" + "\t"
+ "rnRSS" + "\t" + "rxRSS" + "\t" + "HRDiff" + "\t"
+ "IMSB" + "\t" + "MergB" + "\t" + "ShufMB" + "\t"
+ "nRedIn" + "\t" + "xRedIn" + "\t"
+ "rnEdenU" + "\t" + "rxEdenU" + "\t"
+ "rnS0U" + "\t" + "rxS0U" + "\t" + "rnS1U" + "\t" + "rxS1U" + "\t"
+ "enSSTObj" + "\t" + "exSSTObj" + "\t" + "enRTObj" + "\t" + "exRTObj" + "\t"
+ "enFix" + "\t" + "exFix" + "\t"
+ "OGC" + "\t" + "OGCMX" + "\t" + "NGC" + "\t" + "NGCMX" + "\t" + "EdenC" + "\t" + "S0C" + "\t"
+ "rnRecords" + "\t" + "rxRecords" + "\t" + "nYGC" + "\t" + "nFGC" + "\t" + "mTime" + "\t" + "reason");
for(SplitReducerCompJvmCost cJvmCost : cReducerJvmCostList)
cReducerWriter.println(cJvmCost);
cMapperWriter.close();
cReducerWriter.close();
System.out.println("[" + jobName + "] JvmCost comparison finished");
}
|
4d4e74af-d745-4102-9960-cb194355ec3a
| 8
|
@Override
public void executeMsg(Environmental host, CMMsg msg)
{
if(affected instanceof MOB)
{
final MOB M = (MOB)affected;
if((msg.target()==M)
&&((msg.targetMinor()==CMMsg.TYP_LOOK)||(msg.targetMinor()==CMMsg.TYP_EXAMINE))
&&(CMLib.flags().canBeSeenBy(M,msg.source())))
{
final String s=CMLib.utensils().niceCommaList(affectedLimbNameSet(),true);
if(s.length()>0)
{
msg.addTrailerMsg(CMClass.getMsg(msg.source(),null,null,
CMMsg.MSG_OK_VISUAL,L("\n\r@x1 is missing @x2 @x3.\n\r",M.name(msg.source()),M.charStats().hisher(),s),
CMMsg.NO_EFFECT,null,
CMMsg.NO_EFFECT,null));
}
}
if((msg.sourceMinor()==CMMsg.TYP_DEATH)&&(msg.amISource(M)))
{
M.delEffect(this);
M.recoverCharStats();
M.recoverPhyStats();
M.recoverMaxState();
}
}
super.executeMsg(host,msg);
}
|
f8d9cda6-17e1-47af-92f2-5cd96c479fc4
| 2
|
@Override
public void keyPressed(KeyEvent e) {
// TODO Auto-generated method stub
if(e.getKeyCode() == KeyEvent.VK_ENTER) {
String message = txtBox.getText();
String showMessageForMe = "me: " + message + "\n";
message = message.replace("<", "<");
message = message.replace(">", ">");
String messageToSend = Tags.CHAT_MSG_S + message + Tags.CHAT_MSG_E;
try {
write.writeUTF(messageToSend);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
updateTxtBoard(showMessageForMe);
txtBox.setText("");
txtBox.setCaretPosition(-1);
txtBoard.setCaretPosition(txtBoard.getDocument().getLength());
}
}
|
148de5e0-b6cc-4676-a439-801798d87b2c
| 1
|
@RequestMapping(value = "/saveProject", method = RequestMethod.POST)
public String saveProject(@ModelAttribute("project") Project project, BindingResult result) {
System.out.println("project id:" + project.getProjectId() + "name" + project.getName());
if (project.getProjectId() == null) {
getProjectsDAO().create(project);
} else {
Project projectObject = getProjectsDAO().getById(project.getProjectId());
projectObject.setName(project.getName());
getProjectsDAO().update(projectObject);
}
return "redirect:projects.htm";
}
|
0d282c35-2eb1-47d8-b571-12f06bd0fce6
| 3
|
public Socket findServer(){
String IP = getIP();
String[] nodes = IP.split ("\\D");
String newIP = "";
for (int i = 0 ; i < nodes.length - 1 ; i++)
{
newIP = newIP.concat (nodes [i] + ".");
}
//Declares an array used for searching for a server
Socket[] sktarr = new Socket [255];
//Search variable
int i = 0;
//Search loop
for (; i < 254 ;)
{
sktarr [i] = new Socket ();
try
{
sktarr [i].connect (new InetSocketAddress (newIP + i, PORT), 10);
return sktarr[i];
}
catch (IOException ex)
{
i++;
}
}
return null;
}
|
5dd70152-9591-4134-b1af-77bf0f62382a
| 0
|
public int getSourceLinesSize() {
return sourceLines.size();
}
|
c4c6f983-0e41-464b-b060-a62529775fea
| 2
|
public void interact(ThePlayer p)
{
for (Item k : getKeys(p))
{
Key K = (Key) k;
if (K.getName().equals(keyName))
{
System.out.println("Thou use-ith thine key to open ye door.");
p.moveTo(getLocation());
return;
}
}
System.out.println("Thou needidst a key");
}
|
15d7cecd-cdbe-44f6-9953-28f7f1ac48fc
| 3
|
protected static boolean getBoolean(String key, JSONObject json) throws JSONException {
String str = json.getString(key);
if(null == str || "".equals(str)||"null".equals(str)){
return false;
}
return Boolean.valueOf(str);
}
|
1d9f648a-1c75-43a6-951c-3e1e83c83e50
| 4
|
private void init() {
Scanner reader = null;
try {
reader = new Scanner(new File(Constants.IMAGE_LIST_PATH));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
while(reader.hasNext()){
String row = reader.nextLine();
if(row.isEmpty()) { //Ignore empty rows.
continue;
}
String[] parts = row.split("\\s+"); //Split the row into a key and a path to an image at one or more whitespace characters.
String key = parts[0];
String imagePath = parts[1];
Image image = null;
try {
image = new Image(imagePath);
} catch (SlickException e) {
e.printStackTrace();
}
images.put(key, image);
}
reader.close();
}
|
82859210-d0df-463f-abf2-73d942c961c0
| 5
|
public static void act(Unit unit) {
MapPoint goTo = null;
MapPoint unitPlace = getNearestInfantryPreferablyOutsideBunker(unit);
if (unitPlace != null) {
goTo = unitPlace;
}
// If there's someone to protect, go there
if (goTo != null) {
double distance = goTo.distanceTo(unit);
// If distance is big, just go
if (distance > 3) {
UnitActions.moveTo(unit, goTo);
} else {
UnitActions.moveTo(unit, goTo);
}
}
// ==============================
// Manually check for units to heal
ArrayList<Unit> possibleToHeal = xvr.getUnitsInRadius(unit, 50,
xvr.getUnitsPossibleToHeal());
for (Unit otherUnit : possibleToHeal) {
if (otherUnit.isWounded()) {
xvr.getBwapi().rightClick(unit, otherUnit);
return;
}
}
}
|
2b0dd51f-f7ed-4d7a-8f40-5b14b1b2ad37
| 5
|
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null) return false;
if(getClass() == o.getClass()) {
Controlsystem s = (Controlsystem) o;
return (inQueue.equals(s.inQueue) &&
outQueue.equals(s.outQueue) &&
tlc.constructionRoad.equals(s.tlc.constructionRoad));
}
return false;
}
|
db3626b0-931e-4311-92a2-964025d67db7
| 9
|
public void HuffmanBlockEncoder(BufferedOutputStream outStream, int zigzag[], int prec, int DCcode, int ACcode)
{
int temp, temp2, nbits, k, r, i;
NumOfDCTables = 2;
NumOfACTables = 2;
// The DC portion
temp = temp2 = zigzag[0] - prec;
if(temp < 0) {
temp = -temp;
temp2--;
}
nbits = 0;
while (temp != 0) {
nbits++;
temp >>= 1;
}
// if (nbits > 11) nbits = 11;
bufferIt(outStream, ((int[][])DC_matrix[DCcode])[nbits][0], ((int[][])DC_matrix[DCcode])[nbits][1]);
// The arguments in bufferIt are code and size.
if (nbits != 0) {
bufferIt(outStream, temp2, nbits);
}
// The AC portion
r = 0;
for (k = 1; k < 64; k++) {
if ((temp = zigzag[jpegNaturalOrder[k]]) == 0) {
r++;
}
else {
while (r > 15) {
bufferIt(outStream, ((int[][])AC_matrix[ACcode])[0xF0][0], ((int[][])AC_matrix[ACcode])[0xF0][1]);
r -= 16;
}
temp2 = temp;
if (temp < 0) {
temp = -temp;
temp2--;
}
nbits = 1;
while ((temp >>= 1) != 0) {
nbits++;
}
i = (r << 4) + nbits;
bufferIt(outStream, ((int[][])AC_matrix[ACcode])[i][0], ((int[][])AC_matrix[ACcode])[i][1]);
bufferIt(outStream, temp2, nbits);
r = 0;
}
}
if (r > 0) {
bufferIt(outStream, ((int[][])AC_matrix[ACcode])[0][0], ((int[][])AC_matrix[ACcode])[0][1]);
}
}
|
da90f130-ac4e-4bd8-bfae-979305a51334
| 7
|
protected void wrapBuffer()
throws IOException
{
// Handle chunking
int size=size();
if (_chunking && size()>0)
{
prewrite(__CRLF,0,__CRLF.length);
while (size>0)
{
int d=size%16;
if (d<=9)
prewrite('0'+d);
else
prewrite('a'-10+d);
size=size/16;
}
postwrite(__CRLF,0,__CRLF.length);
}
// Complete it if we must.
if (_complete && !_completed)
{
_completed=true;
if (_chunking)
postwrite(__CHUNK_EOF,0,__CHUNK_EOF.length);
}
}
|
cbc7b5b0-834a-4827-9723-6057bd8b38f5
| 4
|
public boolean daysAreChecked() {
return (chckbxLun.isSelected() || chckbxMar.isSelected()
|| chckbxMie.isSelected() || chckbxJue.isSelected() || chckbxVie
.isSelected());
}
|
a2fca8e2-1486-4a18-87c0-6209bf746b46
| 8
|
@Override
public void run() {
try (DatagramSocket socket = new DatagramSocket(Constants.SYSTEM_PORT)) {
byte[] buf = new byte[512];
DatagramPacket packet = new DatagramPacket(buf, buf.length);
// infinite listening
for (;;) {
socket.receive(packet);
if (packet.getAddress().equals(InetAddress.getLocalHost())) {
continue;
}
synchronized (Chat.usersLoaded) {
try {
Chat.usersLoaded.wait();
} catch (InterruptedException ex) {
java.util.logging.Logger.getLogger(UsersListener.class.getName()).log(Level.SEVERE, null, ex);
}
}
byte[] request = packet.getData();
InetAddress userAddress = packet.getAddress();
switch (request[0]) {
case (Constants.USERS_LIST_COMMAND):
// new user info
byte[] byteUsername = new byte[buf.length - 1];
System.arraycopy(request, 1, byteUsername, 0, buf.length - 1);
String username = new String(byteUsername).trim();
// send response (if needed)
if (ifShouldIAnswer()) {
log.info("Sending information to " + username + " from " + userAddress.getHostAddress());
try (Socket tcpSocket = new Socket(userAddress, Constants.SYSTEM_PORT);
ObjectOutputStream oos = new ObjectOutputStream(tcpSocket.getOutputStream())) {
oos.writeObject(Chat.users.getAll());
}
log.info("Information sent");
}
// save new user
Chat.users.addUser(new User(username, userAddress));
break;
case (Constants.BYE_COMMAND):
Chat.users.removeUser(Chat.users.findByAddress(userAddress));
break;
}
}
} catch (SocketException ex) {
log.error(ex);
} catch (IOException ex) {
log.error("Error while listening new connections: " + ex.getLocalizedMessage());
}
}
|
b5718fa5-af9c-44ba-8c25-2660ae2051ec
| 2
|
public User findUserByLogin(String login){
User user = new User();
String requete = "select * from User where Login=?";
try {
PreparedStatement ps = MyConnection.getInstance().prepareStatement(requete);
ps.setString(1, login);
ResultSet resultat = ps.executeQuery();
while (resultat.next())
{
user.setId(resultat.getInt(1));
user.setLogin(resultat.getString(2));
user.setPassword(resultat.getString(3));
user.setLastName(resultat.getString(4));
user.setFirstName(resultat.getString(5));
user.setSexe(resultat.getString(6));
user.setAddress(resultat.getString(7));
user.setEmail(resultat.getString(8));
user.setDateB(resultat.getDate(9));
user.setCity(resultat.getString(10));
user.setImg(resultat.getString(11));
user.setRank(resultat.getInt(12));
user.setDateI(resultat.getDate(13));
user.setBlocked(resultat.getBoolean(14));
}
return user;
} catch (SQLException ex) {
//Logger.getLogger(PersonneDao.class.getName()).log(Level.SEVERE, null, ex);
System.out.println("Error : "+ex.getMessage());
return null;
}
}
|
320b4cd3-7e5d-4314-b46c-3fe3a233a993
| 5
|
@Test
public void testInfixToPostfix1() throws DAIllegalArgumentException,
DAIndexOutOfBoundsException, ShouldNotBeHereException,
BadNextValueException, UnmatchingParenthesisException {
try {
QueueInterface<String> postFix = calc.infixToPostfix(infix);
String result = "24+";
assertEquals(result, calc.stringTrans(postFix));
} catch (DAIllegalArgumentException e) {
throw new DAIllegalArgumentException();
} catch (DAIndexOutOfBoundsException e) {
throw new DAIndexOutOfBoundsException();
} catch (ShouldNotBeHereException e) {
throw new ShouldNotBeHereException();
} catch (BadNextValueException e) {
throw new BadNextValueException();
} catch (UnmatchingParenthesisException e) {
throw new UnmatchingParenthesisException();
}
}
|
481a2c5a-a412-4051-8dde-2556c4b0ad7b
| 7
|
static int CacheCorrespondenciaDirecta(int i) {
int Etiqueta = Integer.parseInt(Integer.toBinaryString(0x1000 | i).substring(1).substring(0, 3));
int Palabra = Integer.parseInt(Integer.toBinaryString(0x1000 | i).substring(1).substring(9, 12), 2);
int Linea = Integer.parseInt(Integer.toBinaryString(0x1000 | i).substring(1).substring(3, 9), 2);
if (CacheMemoryD[Linea].isValid()) {
if (Etiqueta == CacheMemoryD[Linea].getEtiqueta()) {
Time += 0.01;
return CacheMemoryD[Linea].recoverWord(Palabra);
} else {
if (CacheMemoryD[Linea].isModify()) {
int Bloque = i / 8;
int firstLine = Bloque * 8;
int count = 0;
int BloqueC = Integer.parseInt(Integer.toBinaryString(0x1000 | CacheMemoryD[Linea].getEtiqueta()).substring(1).substring(9, 12).concat(Integer.toBinaryString(0x1000 | Linea).substring(1).substring(6, 12)), 2);
int firstLineM = BloqueC * 8;
for (int j = firstLineM; j < firstLineM + 8; j++) {
RAM[j] = CacheMemoryD[Linea].getPalabra()[count];
count++;
}
count = 0;
for (int j = firstLine; j < firstLine + 8; j++) {
CacheMemoryD[Linea].getPalabra()[count] = RAM[j];
count++;
}
CacheMemoryD[Linea].setValid(true);
CacheMemoryD[Linea].setModify(false);
Time += 0.66 + 0.66 + 0.01;
return CacheMemoryD[Linea].recoverWord(Palabra);
} else {
int Bloque = i / 8;
int firstLine = Bloque * 8;
int count = 0;
CacheMemoryD[Linea].setValid(true);
CacheMemoryD[Linea].setModify(false);
for (int j = firstLine; j < firstLine + 8; j++) {
CacheMemoryD[Linea].getPalabra()[count] = RAM[j];
count++;
}
}
CacheMemoryD[Linea].setEtiqueta(Etiqueta);
Time += 0.1 + 0.01;
return CacheMemoryD[Linea].recoverWord(Palabra);
}
} else {
int Bloque = i / 8;
int firstLine = Bloque * 8;
int count = 0;
CacheMemoryD[Linea].setEtiqueta(Etiqueta);
CacheMemoryD[Linea].setValid(true);
CacheMemoryD[Linea].setModify(false);
for (int j = firstLine; j < firstLine + 8; j++) {
CacheMemoryD[Linea].getPalabra()[count] = RAM[j];
count++;
}
Time += 0.1 + 0.01;
return CacheMemoryD[Linea].recoverWord(Palabra);
}
}
|
bd8d8f8d-d3f4-4bdd-b39b-a90f7a214d52
| 5
|
private void networkStartup()
{
String load = "n";
while (!(load.equals("y") || load.equals("n")))
{
System.out.print(" Load network (y/n) : ");
try
{
load = bufReader.readLine();
load = load.toLowerCase();
}
catch (IOException ioe)
{
System.out.println("Input error");
}
}
if (load.equals("y"))
{
try
{
FileInputStream fis = null;
DataInputStream dis = null;
fis = new FileInputStream(nodeCounter);
dis = new DataInputStream(fis);
maxIdIndex = dis.readInt();
fis.close();
dis.close();
}
catch (IOException ioe)
{
System.out.println("Error while loading shell settings " + ioe);
System.exit(-1);
}
initialPort = choose(" Start UDP port (>1024) : ", 1024, 65000);
env.loadNetwork();
}
else
{
nodeNumber = 15;//choose(" Number of nodes: ",1,MAXNODES);
maxIdIndex = nodeNumber - 1;
initialPort = 3000;//choose(" Start UDP port (>1024) : ", 1024,65000);
env.registerNodes(nodeNumber, "User", initialPort);
}
env.startupAll();
env.bootstrapAll();
}
|
4357474c-893b-4fc7-825a-37ba1938741d
| 8
|
@Override
public void actionPerformed(ActionEvent e)
{
Reference.lastActionMinute = new DateTime().getMinuteOfDay();
if (e.getSource() == overviewButton)
{
Reference.overPanel = new OverPanel();
Reference.saveAndChangePanel(Reference.overPanel, Reference.billAccountPanel, Reference.BILL_ACCOUNT);
}
else if (e.getSource() == debtButton)
Reference.saveAndChangePanel(Reference.debtAccountPanel, Reference.billAccountPanel, Reference.BILL_ACCOUNT);
else if (e.getSource() == bankButton)
Reference.saveAndChangePanel(Reference.bankAccountPanel, Reference.billAccountPanel, Reference.BILL_ACCOUNT);
else if (e.getSource() == logoutButton)
{
Reference.loginPanel = new LoginPanel();
Reference.ex.shutdownNow();
Reference.saveAndChangePanel(Reference.loginPanel, Reference.billAccountPanel, Reference.BILL_ACCOUNT);
}
else if (e.getSource() == saveButton)
Reference.saveAccounts(Reference.BILLACCOUNT_DATABASE_FILE.toString(), Reference.BILL_ACCOUNT);
else if (e.getSource() == newButton)
accountTableModel.addNewAccount();
else if (e.getSource() == delButton)
{
if ( Reference.billAccountTable.getSelectedRow() == -1)
{
JOptionPane
.showMessageDialog(
getRootPane(),
"No account selected: Please click on an account to highlight it and then click the Remove account button.",
"No account selected",
JOptionPane.INFORMATION_MESSAGE);
}
else
accountTableModel.removeAccount(Reference.billAccountTable.getSelectedRow());
}
}
|
bf7a5e45-50ad-4eb2-a3a2-359db84310bb
| 6
|
private static int hexToInt(char ch) {
if ('a' <= ch && ch <= 'f') { return ch - 'a' + 10; }
if ('A' <= ch && ch <= 'F') { return ch - 'A' + 10; }
if ('0' <= ch && ch <= '9') { return ch - '0'; }
throw new IllegalArgumentException(String.valueOf(ch));
}
|
f878699f-5cce-4121-ac2e-4ac89b8ca9c2
| 4
|
public void setSuperstrateRefractiveIndex(double index){
if(this.calcEffectiveDone)this.clearData();
this.superstrateRI = index;
super.superstrateRefractiveIndex = index;
this.setSuperstrateRI = true;
if(this.setMeasurementsGrating && this.setGratingPitch && super.setWavelength)this.calcEffectiveRefractiveIndices();
}
|
a0af1250-f638-4aaa-bc67-0b9fdd55755e
| 0
|
public UpdateChecker() {
}
|
bff8e9bc-2cd1-447c-a9d2-e3ab555cff4b
| 7
|
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BigFraction that = (BigFraction) o;
if (denominator != null ? !denominator.equals(that.denominator) : that.denominator != null) return false;
if (numerator != null ? !numerator.equals(that.numerator) : that.numerator != null) return false;
return true;
}
|
981b7500-f604-48ab-bc1e-ea73132d2a34
| 2
|
private static void parseStyles(Map<String, String> styles, String inlinedStyles) {
String[] keyValues = inlinedStyles.split(",");
for (String keyValue : keyValues) {
String[] kv = keyValue.split(":");
if (kv.length > 1) {
styles.put(kv[0].trim(), kv[1].trim());
}
else {
styles.put(keyValue.trim(), "");
}
}
}
|
b2c275dd-67a2-4b53-9acc-2e25eb9509e4
| 3
|
public ArrayList<MatchScheduling> schedule(ArrayList<Team> teams) throws SQLException
{
ArrayList<MatchScheduling> matches = new ArrayList();
int i = 1;
while (getGroup(i, teams) != null)
{
ArrayList<Team> group = getGroup(i, teams);
ArrayList<Team> group2 = getGroup(i + 1, teams);
ArrayList<MatchScheduling> groupMatches = new ArrayList();
if (group.size() == 4)
{
/*
* Round 1
*/
groupMatches.add(new MatchScheduling(1, group.get(0), group.get(1)));
groupMatches.add(new MatchScheduling(1, group.get(2), group.get(3)));
/*
* Round 2
*/
groupMatches.add(new MatchScheduling(2, group.get(0), group.get(2)));
groupMatches.add(new MatchScheduling(2, group.get(1), group.get(3)));
/*
* Round 3
*/
groupMatches.add(new MatchScheduling(3, group.get(0), group.get(3)));
groupMatches.add(new MatchScheduling(3, group.get(1), group.get(2)));
/*
* Round 4
*/
groupMatches.add(new MatchScheduling(4, group.get(1), group.get(0)));
groupMatches.add(new MatchScheduling(4, group.get(3), group.get(2)));
/*
* Round 5
*/
groupMatches.add(new MatchScheduling(5, group.get(2), group.get(0)));
groupMatches.add(new MatchScheduling(5, group.get(3), group.get(1)));
/*
* Round 6
*/
groupMatches.add(new MatchScheduling(6, group.get(3), group.get(0)));
groupMatches.add(new MatchScheduling(6, group.get(2), group.get(1)));
}
else
{
/*
* Round 1
*/
groupMatches.add(new MatchScheduling(1, group.get(0), group.get(1)));
/*
* Round 2
*/
groupMatches.add(new MatchScheduling(2, group.get(2), group.get(1)));
/*
* Round 3
*/
groupMatches.add(new MatchScheduling(3, group.get(0), group.get(2)));
/*
* Round 4
*/
groupMatches.add(new MatchScheduling(4, group.get(1), group.get(2)));
/*
* Round 5
*/
groupMatches.add(new MatchScheduling(5, group.get(1), group.get(0)));
/*
* Round 6
*/
groupMatches.add(new MatchScheduling(6, group.get(2), group.get(0)));
}
matches.addAll(groupMatches);
i++;
for (MatchScheduling matchScheduling : groupMatches)
{
db.addMatches(matchScheduling);
}
}
return null;
}
|
ac93e880-ca54-4142-a80b-65ecdea0b72f
| 1
|
public static void print(ListNode root){
ListNode step = root;
while(step != null){
System.out.print( +step.val);
step = step.next;
}
System.out.println();
}
|
53743bfa-e7b9-463f-8db0-adc48c3189d3
| 9
|
Page readPageData(RandomAccessFile raf) throws IOException {
PageId pid;
Page newPage = null;
String pageClassName = raf.readUTF();
String idClassName = raf.readUTF();
try {
Class<?> idClass = Class.forName(idClassName);
Class<?> pageClass = Class.forName(pageClassName);
Constructor<?>[] idConsts = idClass.getDeclaredConstructors();
int numIdArgs = raf.readInt();
Object idArgs[] = new Object[numIdArgs];
for (int i = 0; i<numIdArgs;i++) {
idArgs[i] = new Integer(raf.readInt());
}
pid = (PageId)idConsts[0].newInstance(idArgs);
Constructor<?>[] pageConsts = pageClass.getDeclaredConstructors();
int pageSize = raf.readInt();
byte[] pageData = new byte[pageSize];
raf.read(pageData); //read before image
Object[] pageArgs = new Object[2];
pageArgs[0] = pid;
pageArgs[1] = pageData;
newPage = (Page)pageConsts[0].newInstance(pageArgs);
// Debug.log("READ PAGE OF TYPE " + pageClassName + ", table = " + newPage.getId().getTableId() + ", page = " + newPage.getId().pageno());
} catch (ClassNotFoundException e){
e.printStackTrace();
throw new IOException();
} catch (InstantiationException e) {
e.printStackTrace();
throw new IOException();
} catch (IllegalAccessException e) {
e.printStackTrace();
throw new IOException();
} catch (InvocationTargetException e) {
e.printStackTrace();
throw new IOException();
}
return newPage;
}
|
e320a82b-25af-499f-8931-0fac5199d891
| 7
|
public boolean scrollTo(int line, int offset)
{
// visibleLines == 0 before the component is realized
// we can't do any proper scrolling then, so we have
// this hack...
if(visibleLines == 0)
{
setFirstLine(Math.max(0,line - electricScroll));
return true;
}
int newFirstLine = firstLine;
int newHorizontalOffset = horizontalOffset;
if(line < firstLine + electricScroll)
{
newFirstLine = Math.max(0,line - electricScroll);
}
else if(line + electricScroll >= firstLine + visibleLines)
{
newFirstLine = (line - visibleLines) + electricScroll + 1;
if(newFirstLine + visibleLines >= getLineCount())
newFirstLine = getLineCount() - visibleLines;
if(newFirstLine < 0)
newFirstLine = 0;
}
int x = _offsetToX(line,offset);
int width = painter.getFontMetrics().charWidth('w');
if(x < 0)
{
newHorizontalOffset = Math.min(0,horizontalOffset
- x + width + 5);
}
else if(x + width >= painter.getWidth())
{
newHorizontalOffset = horizontalOffset +
(painter.getWidth() - x) - width - 5;
}
return setOrigin(newFirstLine,newHorizontalOffset);
}
|
a8c80a51-b1ef-4402-ab2a-e123833c2722
| 6
|
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
ArrayList<Event> eventsPerHall = schedulesMap.get(columnNames[columnIndex]);
if (eventsPerHall != null) {
for (int i = 0; i <= this.daysInMonth; i++) {
if(rowIndex == i){
for (Event event : eventsPerHall) {
Date eventStartDate = event.getStartDate();
Date eventEndDate = event.getEndDate();
Date currentCalendarDate = DateUtils.getDateByDayMonthYear((rowIndex + 1), currentMonth, currentYear);
int dateMarginStart = DateUtils.returnDateWithoutTime(eventStartDate).compareTo(DateUtils.returnDateWithoutTime(currentCalendarDate));
int dateMarginEnd = DateUtils.returnDateWithoutTime(eventEndDate).compareTo(DateUtils.returnDateWithoutTime(currentCalendarDate));
if (dateMarginStart <= 0 && dateMarginEnd >= 0) {
return event.getName();
}
}
}
}
}
return null;
}
|
4f2b5a8e-6458-4713-ba44-0f4bcf2929d8
| 9
|
public String nextToken() throws JSONException {
char c;
char q;
StringBuilder sb = new StringBuilder();
do {
c = next();
} while (Character.isWhitespace(c));
if (c == '"' || c == '\'') {
q = c;
for (; ; ) {
c = next();
if (c < ' ') {
throw syntaxError("Unterminated string.");
}
if (c == q) {
return sb.toString();
}
sb.append(c);
}
}
for (; ; ) {
if (c == 0 || Character.isWhitespace(c)) {
return sb.toString();
}
sb.append(c);
c = next();
}
}
|
f9613e1b-4469-4702-b3e8-90cfc067c33e
| 5
|
public static Double calculate(Component c1, Component oper, Component c2, MathGame game) {
NumberCard card1 = null;
NumberCard card2 = null;
OperationCard operation = null;
try {
card1 = (NumberCard) c1;
card2 = (NumberCard) c2;
operation = (OperationCard) oper;
} catch(Exception e) {
System.out.println("Invalid: Not in the number, operation, number order");
return null;
}
double num1 = NumberCard.parseNumFromText(card1.getValue());
double num2 = NumberCard.parseNumFromText(card2.getValue());
System.out.println("num1 final : " + card1.getValue());
System.out.println("num2 final : " + num2);
System.out.println("op final: " + operation.getOperation());
String op = operation.getOperation();
double answer;
if(op == "add") {
answer = num1 + num2;
} else if(op == "subtract") {
answer = num1 - num2;
} else if(op == "multiply") {
answer = num1 * num2;
} else if(op == "divide") {
answer = num1 / num2;
} else {
answer = -1;
}
return answer;
}
|
98b2f15c-0a2e-4985-8685-2304abe4519a
| 3
|
public void listen()
{
try
{
while (!this.open)
{
Thread.sleep(SLEEPTIME);
}
while (this.open)
{
String text = this.client.receive().toString();
enteredText.insert(text + "\n", enteredText.getText().length());
enteredText.setCaretPosition(enteredText.getText().length());
Thread.sleep(SLEEPTIME);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
|
eda62854-f483-4613-991a-64e80ca695bf
| 6
|
public synchronized void drop (DropTargetDropEvent dropTargetDropEvent)
{
try
{
Transferable tr = dropTargetDropEvent.getTransferable();
if (tr.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
dropTargetDropEvent.acceptDrop (DnDConstants.ACTION_COPY_OR_MOVE);
java.util.List fileList = (java.util.List)
tr.getTransferData(DataFlavor.javaFileListFlavor);
Iterator iterator = fileList.iterator();
while (iterator.hasNext()) {
File file = (File)iterator.next();
System.out.println(file.getName()+"\n"+file.toURL().toString()+"\n"+file.getAbsolutePath());
String fname=file.getName().toLowerCase();
if (fname.endsWith(".html") || fname.endsWith(".htm")) {
main.parseJsonImageMapFile(file);
} else { // Alles andere versuchen als Bild zu laden
main.readImageFile(file.getAbsolutePath());
}
break; // nur die erste Datei
}
dropTargetDropEvent.getDropTargetContext().dropComplete(true);
} else {
System.err.println ("Rejected");
dropTargetDropEvent.rejectDrop();
}
} catch (IOException io) {
io.printStackTrace();
dropTargetDropEvent.rejectDrop();
} catch (UnsupportedFlavorException ufe) {
ufe.printStackTrace();
dropTargetDropEvent.rejectDrop();
}
}
|
51a278e1-d388-4c56-ba78-83fb64899365
| 7
|
public final void method78(int i, boolean bool, Component component,
int i_11_) throws Exception {
if (anInt5158 == 0) {
if (i < 8000 || (i ^ 0xffffffff) < -48001)
throw new IllegalArgumentException();
anInt5157 = !bool ? 1 : 2;
if (i_11_ != 27929)
aDirectSound5162 = null;
anInt5161 = bool ? 4 : 2;
anIntArray5154 = new int[anInt5157 * 256];
aDirectSound5162.initialize(null);
aDirectSound5162.setCooperativeLevel(component, 2);
for (int i_12_ = 0; (i_12_ ^ 0xffffffff) > -3; i_12_++)
aDSBufferDescArray5152[i_12_].flags = 16384;
aWaveFormatEx5163.avgBytesPerSec = anInt5161 * i;
aWaveFormatEx5163.formatTag = 1;
aWaveFormatEx5163.bitsPerSample = 16;
aWaveFormatEx5163.blockAlign = anInt5161;
aWaveFormatEx5163.channels = anInt5157;
anInt5158 = i;
aWaveFormatEx5163.samplesPerSec = i;
}
}
|
376ea822-24bf-4483-bd50-17c49bd7b04c
| 9
|
public boolean hasEmbeddedMovie() {
if (isEmpty() || getTapePointer() <= 0)
return false;
if (numberOfAtoms > 0) {
if (atom[0].rQ == null || atom[0].rQ.isEmpty())
return false;
}
if (obstacles != null && !obstacles.isEmpty()) {
RectangularObstacle o = obstacles.get(0);
if (o.rxryQ == null || o.rxryQ.isEmpty())
return false;
}
return true;
}
|
a49a2d8e-1edf-49d7-acc7-415f72af44cf
| 2
|
public PublishedSwarmDetails getSwarmDetails( final long swarmid ) {
return (new SQLStatementProcessor<PublishedSwarmDetails>( "SELECT * FROM swarm_extras WHERE swarmid = ?" ){
PublishedSwarmDetails process(PreparedStatement s) throws SQLException {
s.setLong(1, swarmid);
ResultSet rs = s.executeQuery();
if( rs.next() ) {
Blob blob = rs.getBlob("previewpng");
return new PublishedSwarmDetails(
rs.getLong("swarmid"),
rs.getString("description"),
rs.getInt("downloads"),
rs.getString("language"),
rs.getInt("upvotes"),
rs.getInt("downvotes"),
blob != null ? blob.getBytes(1, (int)blob.length()) : null);
} else {
return null;
}
}}).doit();
}
|
17f4ee20-3279-49d0-8cef-287af91eac12
| 7
|
private static void getSongLibrary(ArrayList<Song> songs, ArrayList<String> dates, ArrayList<String> names, ArrayList<String> artists)
{
TimeCalculator calc= new TimeCalculator();
for(int i=(names.size()-1); i>=0; i--){
boolean contains=false;
for(Song song: songs){
if (song.getTitle().toLowerCase()
.contains(names.get(i).toLowerCase())
|| names.get(i).toLowerCase()
.contains(song.getTitle().toLowerCase())) {
if (song.getArtist().toLowerCase()
.contains(artists.get(i).toLowerCase())
|| artists.get(i).toLowerCase()
.contains(song.getArtist().toLowerCase())) {
contains=true;
song.updateSong(calc.calculte(dates.get(i)));
break;
}
}
}
if(!contains){
songs.add(new Song(names.get(i),artists.get(i),calc.calculte(dates.get(i))));
}
}
}
|
f4a778a8-3e46-4301-9e61-a38db8abb802
| 3
|
public static Bank narrow (org.omg.CORBA.Object obj)
{
if (obj == null)
return null;
else if (obj instanceof Bank)
return (Bank)obj;
else if (!obj._is_a (id ()))
throw new org.omg.CORBA.BAD_PARAM ();
else
{
org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
_BankStub stub = new _BankStub ();
stub._set_delegate(delegate);
return stub;
}
}
|
3daa3465-1a7c-44bf-8c3d-eccacf68329b
| 4
|
private short try_open_comport()
{
// the next line is for Raspberry Pi and gets us into the while loop and was suggested here was suggested http://www.raspberrypi.org/phpBB3/viewtopic.php?f=81&t=32186
System.setProperty("gnu.io.rxtx.SerialPorts", COM_PORT_NAME);
Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();
//First, Find an instance of serial port as set in PORT_NAMES.
while (portEnum.hasMoreElements())
{
CommPortIdentifier cur_port_id = (CommPortIdentifier) portEnum.nextElement();
if (cur_port_id.getName().equals(COM_PORT_NAME))
{
port_id = cur_port_id;
break;
}
}
if (port_id == null)
{
MsgDumperCmnDef.WriteErrorFormatSyslog(__FILE__(), __LINE__(), "Fail to find the COM port: %s", COM_PORT_NAME);
return MsgDumperCmnDef.MSG_DUMPER_FAILURE_COM_PORT;
}
// Open the serial port
short ret = open_serial_port();
if (!MsgDumperCmnDef.CheckMsgDumperFailure(ret))
close_serial_port();
return ret;
}
|
16ccb425-c235-41a9-98be-8488d458a0f3
| 3
|
boolean alreadyInFile(String name) {
File file = new File("Users.txt");
Scanner scanner;
try {
scanner = new Scanner(file);
while (scanner.hasNextLine()) {
String lineFromFile = scanner.nextLine();
if(lineFromFile.contains(name)) {
JOptionPane.showMessageDialog(null, "Username has already been chosen. Pick another.", "Error", JOptionPane.ERROR_MESSAGE);
scanner.close();
return true;
}
}
scanner.close();
return false;
}
catch (FileNotFoundException e) {
JOptionPane.showMessageDialog(null, "System Error: Contact administrator.", "Error", JOptionPane.ERROR_MESSAGE);
return false;
}
}
|
84bd03d8-73ad-4d47-8bfb-858fd7d25330
| 4
|
public boolean accept(File f) {
if (f != null) {
if (f.isDirectory()) {
return true;
}
String extension = getExtension(f);
if (extension != null && filters.get(getExtension(f)) != null) {
return true;
};
}
return false;
}
|
eed37658-0838-484d-a888-8e34d5953226
| 0
|
public Encoder correspondingEncoder() {
// return this;
return xmlcodec;
}
|
0325cfa7-ba46-42d1-b08b-fad57c3cd13d
| 6
|
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
int a, b, c, max;
System.out.print("整数aを入力 >");
a = scan.nextInt();
System.out.print("整数bを入力 >");
b = scan.nextInt();
System.out.print("整数cを入力 >");
c = scan.nextInt();
if(a > b && a > c){
max = a;
System.out.println("最大値maxは" + max + "です。");
} else if(b > a && b > c){
max = b;
System.out.println("最大値maxは" + max + "です。");
}else if(c > a && c >b){
max = c;
System.out.println("最大値maxは" + max + "です。");
}
}
|
03fd7a52-d018-4e33-a701-eef56e7c2af4
| 4
|
private Direction getDirection()
{
if (id.length() == 1) return Direction.None;
else if (id.substring(id.length()-1).equals("0")) return Direction.NW;
else if (id.substring(id.length()-1).equals("1")) return Direction.NE;
else if (id.substring(id.length()-1).equals("2")) return Direction.SW;
else return Direction.SE;
}
|
3a590356-7f7d-4b28-9694-a3f99c6bb7a8
| 5
|
public void addCells(Object[] cells)
{
if (cells != null)
{
Collection<Object> remove = null;
if (singleSelection)
{
remove = this.cells;
cells = new Object[] { getFirstSelectableCell(cells) };
}
List<Object> tmp = new ArrayList<Object>(cells.length);
for (int i = 0; i < cells.length; i++)
{
if (!isSelected(cells[i]) && graph.isCellSelectable(cells[i]))
{
tmp.add(cells[i]);
}
}
changeSelection(tmp, remove);
}
}
|
0b75a520-51bd-4bde-a0fa-ef4f6d13bbfd
| 7
|
public ArrayList<Move> getPossibleMoves()
{
ArrayList<Move> possibleMoves = new ArrayList<Move>();
for(int i = -1; i <= 1; i += 2)
{
for(int j = -1; j <= 1; j += 2)
{
boolean openSpace = true;
int count = 1;
while(openSpace)
{
Location currentLoc = new Location(getLoc().getRow() + i*count, getLoc().getCol() + j*count);
if(!getBoard().isValid(currentLoc) || getBoard().getNode(currentLoc).getPiece() != null)
{
openSpace = false;
if(getBoard().isValid(currentLoc) && getBoard().getNode(currentLoc).getPiece().getLoyalty() != this.getLoyalty())
{
ArrayList<Node> move = new ArrayList<Node>();
move.add(getNode());
move.add(getBoard().getNode(currentLoc));
possibleMoves.add(new ChessMove(move, getBoard(), getLoyalty()));
}
}
else
{
ArrayList<Node> move = new ArrayList<Node>();
move.add(getNode());
move.add(getBoard().getNode(currentLoc));
possibleMoves.add(new ChessMove(move, getBoard(), getLoyalty()));
}
count ++;
}
}
}
return possibleMoves;
}
|
e5b15a11-7b60-420d-b64d-ce42b5cea1f5
| 7
|
public void testValueCollectionRemoveAllTCollection() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongHashMap();
for ( int i = 0; i < keys.length; i++ ) {
vals[i] = keys[i] * 2;
map.put( keys[i], vals[i] );
}
TLongCollection values = map.valueCollection();
assertEquals( map.size(), values.size() );
assertFalse( values.isEmpty() );
assertTrue( values.removeAll( values ) );
assertTrue( values.isEmpty() );
// repopulate the set.
map = new TIntLongHashMap();
for ( int i = 0; i < keys.length; i++ ) {
vals[i] = keys[i] * 2;
map.put( keys[i], vals[i] );
}
values = map.valueCollection();
// With empty set
TLongSet tlongset = new TLongHashSet();
assertFalse( "values: " + values + ", collection: " + tlongset,
values.removeAll( tlongset ) );
// With partial set
tlongset = new TLongHashSet( vals );
tlongset.remove( 42 * 2 );
assertTrue( "values: " + values + ", collection: " + tlongset,
values.removeAll( tlongset ) );
assertEquals( "set: " + values, 1, values.size() );
assertEquals( "set: " + values, 1, map.size() );
for ( int i = 0; i < keys.length; i++ ) {
if ( keys[i] == 42 ) {
assertTrue( values.contains( vals[i] ) );
assertTrue( map.containsValue( vals[i] ) );
} else {
assertFalse( values.contains( vals[i] ) );
assertFalse( map.containsValue( vals[i] ) );
}
}
// repopulate the set.
map = new TIntLongHashMap();
for ( int i = 0; i < keys.length; i++ ) {
vals[i] = keys[i] * 2;
map.put( keys[i], vals[i] );
}
values = map.valueCollection();
// Empty list
TLongCollection collection = new TLongArrayList();
assertFalse( "values: " + values + ", collection: " + collection,
values.removeAll( collection ) );
// partial list
collection = new TLongArrayList( vals );
collection.remove( 42 * 2 );
assertTrue( "values: " + values + ", collection: " + collection,
values.removeAll( collection ) );
assertEquals( "values: " + values, 1, values.size() );
assertEquals( "values: " + values, 1, map.size() );
for ( int i = 0; i < keys.length; i++ ) {
if ( vals[i] == 42 * 2 ) {
assertTrue( values.contains( vals[i] ) );
assertTrue( map.containsValue( vals[i] ) );
} else {
assertFalse( values.contains( vals[i] ) );
assertFalse( map.containsValue( vals[i] ) );
}
}
}
|
02f16274-22ab-44ab-9f29-58cfca730cbf
| 8
|
public final SymbolraetselASTParser.sym_return sym() throws RecognitionException {
SymbolraetselASTParser.sym_return retval = new SymbolraetselASTParser.sym_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
Token SYMBOL2=null;
CommonTree SYMBOL2_tree=null;
RewriteRuleTokenStream stream_SYMBOL=new RewriteRuleTokenStream(adaptor,"token SYMBOL");
try {
// C:\\Users\\Florian\\Dropbox\\Git\\CI_WiSe2013-2014\\CI_Aufgabe4\\src\\symbolraetsel_AST_Solver\\grammar\\SymbolraetselAST.g:42:2: ( ( SYMBOL )+ -> ^( BLOCK ( SYMBOL )+ ) )
// C:\\Users\\Florian\\Dropbox\\Git\\CI_WiSe2013-2014\\CI_Aufgabe4\\src\\symbolraetsel_AST_Solver\\grammar\\SymbolraetselAST.g:42:4: ( SYMBOL )+
{
// C:\\Users\\Florian\\Dropbox\\Git\\CI_WiSe2013-2014\\CI_Aufgabe4\\src\\symbolraetsel_AST_Solver\\grammar\\SymbolraetselAST.g:42:4: ( SYMBOL )+
int cnt1=0;
loop1:
do {
int alt1=2;
int LA1_0 = input.LA(1);
if ( (LA1_0==SYMBOL) ) {
alt1=1;
}
switch (alt1) {
case 1 :
// C:\\Users\\Florian\\Dropbox\\Git\\CI_WiSe2013-2014\\CI_Aufgabe4\\src\\symbolraetsel_AST_Solver\\grammar\\SymbolraetselAST.g:42:4: SYMBOL
{
SYMBOL2=(Token)match(input,SYMBOL,FOLLOW_SYMBOL_in_sym321);
stream_SYMBOL.add(SYMBOL2);
}
break;
default :
if ( cnt1 >= 1 ) break loop1;
EarlyExitException eee =
new EarlyExitException(1, input);
throw eee;
}
cnt1++;
} while (true);
// AST REWRITE
// elements: SYMBOL
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
root_0 = (CommonTree)adaptor.nil();
// 42:12: -> ^( BLOCK ( SYMBOL )+ )
{
// C:\\Users\\Florian\\Dropbox\\Git\\CI_WiSe2013-2014\\CI_Aufgabe4\\src\\symbolraetsel_AST_Solver\\grammar\\SymbolraetselAST.g:42:15: ^( BLOCK ( SYMBOL )+ )
{
CommonTree root_1 = (CommonTree)adaptor.nil();
root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(BLOCK, "BLOCK"), root_1);
if ( !(stream_SYMBOL.hasNext()) ) {
throw new RewriteEarlyExitException();
}
while ( stream_SYMBOL.hasNext() ) {
adaptor.addChild(root_1, stream_SYMBOL.nextNode());
}
stream_SYMBOL.reset();
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
retval.stop = input.LT(-1);
retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);
}
finally {
}
return retval;
}
|
6eb225a7-0749-425c-8102-493a090eb71a
| 1
|
public void addFreq(String word)
{
mFreq++;
if (Character.isUpperCase(word.charAt(0)))
mCapitalFreq++;
}
|
69aacd06-6ad9-41c2-bf37-e4d845136c16
| 7
|
public ArrayList<ArrayList<Integer>> fourSum(int[] num, int target) {
ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
int size = num.length;
ValueIndexPair[] twoSums = new ValueIndexPair[(size - 1) * size / 2];
int twoSumsSize = 0;
for (int i = 0; i < size; i++) {
for (int j = i + 1; j < size; j++) {
twoSums[twoSumsSize] = new ValueIndexPair();
twoSums[twoSumsSize].sum = num[i] + num[j];
twoSums[twoSumsSize].index1 = i;
twoSums[twoSumsSize].index2 = j;
twoSumsSize++;
}
}
Set set = new HashSet();
for (int i = 0; i < twoSumsSize; i++) {
for (int j = i + 1; j < twoSumsSize; j++) {
if (twoSums[i].sum + twoSums[j].sum == target && !twoSums[i].conflict(twoSums[j])) {
ArrayList<Integer> tmp = addFour(num[twoSums[i].index1],
num[twoSums[i].index2], num[twoSums[j].index1], num[twoSums[j].index2]);
if (set.add(tmp))
result.add(tmp);
}
}
}
return result;
}
|
8c813124-d4d2-466b-b70a-5a3e54ada221
| 9
|
public void genNewIndividual(int parent)
{
Genome child;
Genome tmp;
Genome tmp2;
RNG die = RNG.getInstance();
a1 = die.nextInt(individual.size());
a2 = die.nextInt(individual.size());
a3 = die.nextInt(individual.size());
a4 = parent;
/* child = a1 + Xover(a2 - a3) */
child = individual.get(a1).copy();
tmp = individual.get(a2);
tmp2 = individual.get(a3);
// FIXME: cludge to prevent negative weight values.
// this messes with the relative weights :-/
double baseline = 0;
for (int i = 0; i < child.index.length; i++)
{
child.weight[i] += DE_K*(tmp.weight[i] - tmp2.weight[i]);
child.index[i] = child.index[i] || tmp.index[i] || tmp2.index[i];
if (child.weight[i] < baseline)
baseline = child.weight[i];
}
// FIXME: cludge to prevent negative weight values.
// this messes with the relative weigths
if (baseline < 0)
for (int i = 0; i < child.index.length; i++)
child.weight[i] -= baseline;
// exchange with a4
for (int i = 0; i < child.index.length; i++)
if (die.nextDouble() < DE_C)
{
child.weight[i] = individual.get(a4).weight[i];
child.index[i] = individual.get(a4).index[i];
}
child.eval(T);
if (child.fitness > individual.get(a4).fitness)
{
individual.remove(a4);
individual.add(child);
}
}
|
3544c673-0fed-4575-a6b7-ac798207365b
| 2
|
public BoundedGrid(int rows, int cols)
{
if (rows <= 0)
throw new IllegalArgumentException("rows <= 0");
if (cols <= 0)
throw new IllegalArgumentException("cols <= 0");
occupantArray = new Object[rows][cols];
}
|
dae266e7-cad9-41a6-9548-bc9b845c171b
| 4
|
public Simulator() {
for (int i=0; i<6; i++)
{
if (i<2)
{
employees[i]=new TastebudStylist(500);
}
else if (i<4)
{
employees[i]=new Moover(200);
}
else if (i<6)
{
employees[i]=new Shaker(100);
}
}
week=0;
}
|
d05b5352-253e-4211-9d3f-7c1f8b9ad0ff
| 7
|
@Override
protected boolean handleEvent(Event evt) {
if(evt.isMouseEventNoWheel()) {
if(dragActive) {
if(evt.isMouseDragEnd()) {
if(listener != null) {
listener.dragStopped(this, evt);
}
dragActive = false;
getAnimationState().setAnimationState(STATE_DRAG_ACTIVE, false);
} else if(listener != null) {
listener.dragging(this, evt);
}
} else if(evt.isMouseDragEvent()) {
dragActive = true;
getAnimationState().setAnimationState(STATE_DRAG_ACTIVE, true);
if(listener != null) {
listener.dragStarted(this, evt);
}
}
return true;
}
return super.handleEvent(evt);
}
|
3716e4be-db59-406d-8d3e-cf0e70a7c42e
| 5
|
public static void main(String[] args) {
int sum = 0;
HashSet<Integer> prods = new HashSet<Integer>();
for(int i = 2; i < 10_000; i++) {
for(int j = i+1; j < 10_000; j++) {
int k = i*j;
if( isPan(i, j, k) ) {
boolean added = prods.add(k);
System.out.printf("%6d%6d%6d", i, j, i*j);
if(!added)
System.out.print(" *");
System.out.println();
if( added )
sum += k;
}
}
}
System.out.println(sum);
}
|
03ca1d9c-535b-44bd-ae20-9b3d6a2f90ed
| 3
|
public boolean hasReturnTypeMethod(String name, Class<?> returnType, Class<?>... argTypes) {
Preconditions.hasText(name);
Preconditions.notNull(returnType);
try {
return null != returnTypeMethod(name, returnType, argTypes);
} catch (Exception e) {
return false;
}
}
|
070eddb4-4d71-4654-86f1-0cb4c05f0118
| 8
|
public void drawCell(mxICanvas canvas, Object cell)
{
mxCellState state = graph.getView().getState(cell);
if (state != null
&& isCellDisplayable(state.getCell())
&& (!(canvas instanceof mxGraphics2DCanvas) || hitClip(
(mxGraphics2DCanvas) canvas, state)))
{
graph.drawState(canvas, state,
cell != cellEditor.getEditingCell());
}
// Handles special ordering for edges (all in foreground
// or background) or draws all children in order
boolean edgesFirst = graph.isKeepEdgesInBackground();
boolean edgesLast = graph.isKeepEdgesInForeground();
if (edgesFirst)
{
drawChildren(cell, true, false);
}
drawChildren(cell, !edgesFirst && !edgesLast, true);
if (edgesLast)
{
drawChildren(cell, true, false);
}
if (state != null)
{
cellDrawn(canvas, state);
}
}
|
466fb387-8c80-4318-b542-682cd4fc574f
| 1
|
public boolean isWorldLoaded(String world) {
if (world.equalsIgnoreCase(loadedWorld)) {
return true;
} else {
return false;
}
}
|
123c9269-492e-471e-8d58-8e5d3a2c17bb
| 4
|
private void findFromPoint(Point p, List<Point> curPath) {
curPath.add(p);
if(isFinalPoint(p)){ //recursive stop point
pathes.add(curPath);
return;
}
if(MAZE.isRoad(p.X + 1, p.Y)){
findFromPoint(new Point(p.X + 1, p.Y), new ArrayList<Point>(curPath));
}
if(MAZE.isRoad(p.X, p.Y + 1)){
findFromPoint(new Point(p.X, p.Y + 1), new ArrayList<Point>(curPath));
}
if(MAZE.isRoad(p.X + 1, p.Y + 1)){
findFromPoint(new Point(p.X + 1, p.Y + 1), new ArrayList<Point>(curPath));
}
}
|
10c2a84c-8db8-4557-8167-2ee1624dc988
| 7
|
public ArrayList<ArrayList<Integer>> permute(int[] num) {
ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
int n = num.length;
if (n == 0){
return result;
}
if (n == 1){
ArrayList<Integer> t = new ArrayList<Integer>();
t.add(num[0]);
result.add(t);
return result;
}
for (int i=0;i<num.length;i++){
int []temp = new int[num.length-1];
for (int j=0;j<num.length;j++){
if (j<i){
temp[j]= num[j];
}
else if (j>i){
temp[j-1]=num[j];
}
}
ArrayList<ArrayList<Integer>> subResult = permute(temp);
for (int k=0;k<subResult.size();k++){
ArrayList<Integer> row = new ArrayList<Integer>();
row.add(num[i]);
row.addAll(subResult.get(k));
result.add(row);
}
}
return result;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.