method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
16f29c18-ecd9-4c96-989f-b80f35c095d1 | 3 | public void getLocalNetworkCardInfo(InetAddress net) {
/* NetworkInterface를 이용하여 현재 로컬 서버에 대한 하드웨어 어드레스를 가져오기,리모트 정보는 못가져온다. */
//네트워크 카드에 대한 정보를 가져온다.
NetworkInterface ni;
try {
ni = NetworkInterface.getByInetAddress(net);
byte[] mac = ni.getHardwareAddress();
String macAddr = "";
for (... |
e18fcfa6-8896-45a5-bc8a-25ad13b30be3 | 1 | private void closeOrder() throws JFException {
if (this.order.getState() == IOrder.State.FILLED) {
this.order.close();
this.order = null;
}
} |
144e3598-6202-4852-b399-7826e3a640fb | 3 | private double getSeekTime(int fileSize) {
double result = 0;
if (gen_ != null) {
result += gen_.sample();
}
if (fileSize > 0 && capacity_ != 0) {
result += ((double) fileSize / capacity_);
}
return result;
} |
e10c88b3-6531-43b7-bfa9-a39a6a1c15bc | 5 | public void move()
{
//If you cant move return
if (!canMove()) {
return;
}
//If you can move then move
switch(direction) {
case SOUTH :
setLocation(getX(), getY() + 1);
break;
case EAST :
setL... |
29eb6e29-a84c-40b8-a3ca-79ae72517d8a | 0 | @Override
public void die() {
this.tile.getBombers().remove(this);
this.tile = null;
this.cooldown = match.dyingCooldown;
this.points -= match.pointsLostForDying;
} |
c664696e-68a5-424f-9aee-f97ebee060bc | 7 | @EventHandler
public void onInventoryOpen(InventoryOpenEvent event){
//We don't care about players other than the owner
if(!event.getPlayer().equals(owner))
return;
//We don't care about non-chest interactions
if(!event.getInventory().getType().equals(InventoryType.CHEST))
return;
if(event.getInventory... |
4d984ea5-40b7-4462-a1de-7669ae6caa43 | 1 | @Override
public boolean[] getSetupPattern() {
boolean[] setupPattern = new boolean[periods.length];
for (int i = 0; i < setupPattern.length; i++){
setupPattern[i] = periods[i].setup;
}
return setupPattern;
} |
1d4bd47a-689b-41b4-a959-551f0cab4506 | 7 | public static void main (String [] args) throws Exception {
try {
System.out.println(System.getProperty("user.dir"));
CatalogReader foo = new CatalogReader ("Catalog.xml");
Map <String, TableData> res = foo.getCatalog ();
System.out.println (foo.printCatalog (res));
InputSt... |
18a6543b-c322-4898-8a46-6be81db1119b | 3 | public void catchPowerUp(int type) {
switch (type) {
case 1:
length += FRAME_HEIGHT / 10;
break;
case 2:
if (length > FRAME_HEIGHT / 10 + FRAME_HEIGHT / 50) {
length -= FRAME_HEIGHT / 10;
}
... |
f5e6891a-015a-484c-a09d-a3f976a5ae7a | 5 | public static void main(String args[]) throws Exception {
String clientMSG[];
String capitalizedSentence;
ServerSocket welcomeSocket = new ServerSocket(7000);
int state = 0; // 0 = waiting for call
// 1 = waiting for ACK
int timeOut = 1;// how long to wai... |
b03c771a-8990-4e4f-a46d-f18f5fcc2801 | 5 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final TipoEndereco other = (TipoEndereco) obj;
if (this.idTipoEndereco != other.idTipoEndereco && (this.idTipoE... |
b5158242-50f9-48b5-aa96-d7cef42115b7 | 7 | private void loadConnection() {
Properties properties = new Properties();
File connectionsDir = new File(settingsDir+fileSeparator+"connections");
if(!connectionsDir.exists()){
System.out.println("making new connecitons directory");
connectionsDir.mkdir();
}
File[] files = new File(connectionsDir... |
4e31150f-675a-4fd3-8602-db9b0cc2d12c | 2 | public static void printlnPattern(boolean[] pattern){
System.out.print("|");
for (int i = 0; i < pattern.length; i++){
if (pattern[i]) System.out.print(""+1);
else System.out.print(""+0);
System.out.print("|");
}
System.out.println("");
} |
e2e493c2-2c32-45a4-8a71-b4baa3fdca5c | 5 | boolean promoteLifeLocals(LocalInfo[] newLife, InstrInfo nextInfo) {
if (nextInfo.lifeLocals == null) {
nextInfo.lifeLocals = (LocalInfo[]) newLife.clone();
return true;
}
boolean changed = false;
for (int i = 0; i < maxlocals; i++) {
LocalInfo local = nextInfo.lifeLocals[i];
if (local == null)
... |
977714c0-8a5b-4b3e-946c-420fc8a2b0ff | 6 | public int[] getInts(int par1, int par2, int par3, int par4)
{
int[] var5 = this.field_35512_b.getInts(par1, par2, par3, par4);
int[] var6 = this.field_35513_c.getInts(par1, par2, par3, par4);
int[] var7 = IntCache.getIntCache(par3 * par4);
for (int var8 = 0; var8 < par3 * par4; ++v... |
7c554846-4625-4bb7-8646-673a121a77f7 | 3 | private void calculateTextState(Document doc) {
if (doc != null && doc instanceof OutlinerDocument) {
if (((OutlinerDocument) doc).isShowingAttributes()) {
setText(HIDE_ATTRIBUTES);
} else {
setText(SHOW_ATTRIBUTES);
}
}
} |
02f38490-35a7-4b3b-969e-a9be5286757e | 7 | @Override
public Graph simplify(Graph g) {
Graph ret = new Graph(g);
if (g.size() < 2) {
return ret;
}
Triple<List<Node>, List<Node>, List<Node>> triple = split(g);
List<Node> positiveNodeList = triple.first;
List<Node> negativeNodeList = triple.second;... |
beecfbe0-8679-48b1-9f95-5657d939e47f | 0 | protected double returnPIDInput() {
return _angleToTarget;
} |
9995bacd-24a1-44f4-875d-8cd22cb2baa9 | 4 | public void destroyFleet()
{
if(fleet.size() == 0)
return;
for(int y = 0; y < sea[0].length; y++)
for(int x = 0; x < sea.length; x++)
if(sea[x][y] == SHIP)
bombTile(x, y);
} |
18127aa2-2fd0-475a-8fd5-8e3b70c48a1d | 5 | public ArrayList<Player> getPlayer(CategoryType kat){
if(kat == CategoryType.BASS)
return bassPlayer;
else if(kat == CategoryType.BEATS)
return beatsPlayer;
else if(kat == CategoryType.HARMONY)
return harmonyPlayer;
else if(kat == CategoryType.MELODY)
return melodyPlayer;
else if(kat == CategoryTy... |
3c82ceaa-76a7-4924-9747-d689cdf2142c | 1 | public Key max()
{
if (N == 0)
throw new RuntimeException("Priority Queue Underflow");
return heap[1];
} |
e0180320-80cf-47b9-a8df-0035898bfe0c | 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... |
1b311afd-401d-4df0-b6c7-0f4571754171 | 7 | private void getChallengeList() {
titleDLM.removeAllElements();
challengeList = challenge.getChallengeList(fileName, publicFileName, counterTeamType);
if (challengeList.size() != 0) {
for (int i = 0; i < challengeList.size(); i++) {
titleDLM.addElement(challengeList.get(i).getTitle());
}
titleJlst.se... |
eba3fb11-9795-4d24-a8ea-8a79436ddf04 | 7 | public StatusContext playDrinkingGame(List<Player> players) {
try {
// play with random roll or not
if (Constants.randomPlay) {
Collections.shuffle(players);
}
context.setPlayers(players);
context.setMaxDrinkingCnt(maxDrinkingCnt);
context.setPausetime(pausetime);
int nSecond = 0; // time b... |
61f2049a-190a-4533-8643-404a19167553 | 6 | public JSWindow jsFunction_waitNewWindow(String name, int timeout) {
deprecated();
int curr = 0;
if (timeout == 0) timeout = 10000;
while (curr < timeout) {
if (JSBotUtils.lastCreatedWindow != null &&
JSBotUtils.lastCreatedWindow.ca... |
c2a3354b-bc53-4be0-b168-fb55c3351b11 | 5 | public void tick() {
spawner.tick();
for (int y = 0; y < height; y++) {
for (int x = 0; x < height; x++) {
getTile(x, y).tick();
}
}
List<Player> players = new ArrayList<Player>();
for (int i = 0; i < entities.size(); i++) {
Entity e = getEntities().get(i);
if (!(e.tag.contains("player"))) e... |
d0b0ada9-c3c8-49bb-bc4d-5bc15f9493b0 | 3 | @Override
public double getClientWaitTime(Client client) {
for(int i = 0; i < cashiers; i++){
int totalWaitTime = 0;
for(int j = 0; j < lines[i].size(); j++){
totalWaitTime = lines[i].get(j).getExpectedServiceTime();
if(lines[i].get(j) == client){
return totalWaitTime;
}
}
}
return 0;
... |
863e5c6c-d4dd-4521-ae55-e74e0ec13628 | 9 | public boolean readJPEGChannel(InputStream in, int c, int chanW, int chanH) throws java.io.IOException {
int len=readInt(in);
newjpegLen=len;
//System.out.println("len="+len);
if(!_isConnected) return false;
if(len>=_newjpeg.length) {
System.out.println("Not enough tmp room");
return false;
}
readBy... |
7bde3474-100e-4de6-929a-91bb68b5f70e | 1 | public boolean isCellEditable(int row, int column) {
if (frozen)
return false;
return column != 0;
} |
4843e698-3cc1-4a60-a60e-f02ea81ed8d2 | 2 | public void testForFields_weekBased_YD() {
DateTimeFieldType[] fields = new DateTimeFieldType[] {
DateTimeFieldType.weekyear(),
DateTimeFieldType.dayOfWeek(),
};
int[] values = new int[] {2005, 5};
List types = new ArrayList(Arrays.asList(fields));
... |
afe3ad67-9f4d-4f87-88cd-b90c9ba9620b | 6 | public void go() {
//System.out.println("how many times does go get entered?");
new Thread(new Runnable() {
public void run() {
try {
for (SimonButton button : buttons) {
button.setEnabled(false);
/// button.rem... |
795917f2-85fd-47d5-832b-6cbf1ed2c9ff | 4 | private void addBlockToBlue() {
debug("Adding block to blue");
if (bLoc1.getBlock().getType() == Material.AIR) {
bLoc1.getBlock().setType(Material.GOLD_BLOCK);
} else if (bLoc2.getBlock().getType() == Material.AIR) {
bLoc2.getBlock().setType(Material.GOLD_BLOCK);
... |
49eef8d5-d919-4dae-9091-892b1f9c4ee2 | 9 | public void reproduccirPlayList() {
if ((jListListaCancionesPlaylist.getModel().getSize()) > 0 && jListListaCancionesPlaylist.getSelectedIndex() >= 0) {
Object nombreCancionActual = jListListaCancionesPlaylist.getSelectedValue();
Cancion cancionObtenida = (Cancion) listaCanciones.getCan... |
851582da-bc90-4638-b3ea-750db1c40b2b | 7 | public static final Component getChildAtLine(Container container, Point p, boolean horizontal) {
if (horizontal) {
for (int i = 0; i < container.getComponentCount(); i++) {
Component c = container.getComponent(i);
if (p.x >= c.getX() && p.x < c.getX() + c.getWidth())
return c;
... |
7f5dbae8-b510-4786-94e2-05b76052ebed | 6 | public static void main(String[] args) {
// key = word, value = set of files containing that word
ST<String, SET<File>> st = new ST<String, SET<File>>();
// create inverted index of all files
StdOut.println("Indexing files");
for (String filename : args) {
StdOut.pr... |
78e464a4-0f23-4578-ad60-23c5c99e3d26 | 8 | public void invokeMethod() {
try {
Class<?> clazz = Class.forName("com.rock.reflect.User");
User u = (User) clazz.newInstance();
Method m = clazz.getMethod("setUserName", String.class);
m.invoke(u, "rock");
System.out.println(u.getUserName());
} catch (ClassNotFoundException e) {
e.printSt... |
489fe0fc-fe97-4880-afc0-cde8d97d70fd | 8 | public void move (){
if (movArriba && movDerecha){
this.setPosX(this.getPosX()+angulo);
this.setPosY(this.getPosY()-10);
}
if (movArriba && !movDerecha){
this.setPosX(this.getPosX()-angulo);
this.setPosY(this.getPosY()-10);
}
... |
95b11a92-ec09-439f-b113-d3fc692d131b | 8 | public static int getDepartmentIdByName(String departmentName)
{
ResultSet rs=null;
Connection con=null;
PreparedStatement ps=null;
int result=0;
try{
String sql="SELECT DEPTID FROM DEPARTMENT WHERE DEPTNAME=?";
con=ConnectionPool.getConnectionFromPool();
ps=con.prepareStatement(sql);
ps.setStrin... |
27265b02-5eee-41aa-8aac-c4bab02e799d | 8 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
final MOB target=this.getTarget(mob,commands,givenTarget);
if(target==null)
return false;
if((!auto)&&(target.charStats().getBodyPart(Race.BODY_EYE)==0))
{
mob.tell(L("@x1 has no eyes, and... |
d27f7c84-197d-4718-8474-5076923f6e5e | 7 | @Override
public Object getValueAt(int row, int col) {
if ( data == null )
return null;
ColorPatch patch = data.get(row);
Color color = patch.getColor();
switch (col) {
case 1: return patch.getSize();
case 2: return color.toRGBString();
case 3: return color.toHSVString();
case 4: return co... |
08888741-e8c1-4d45-8a64-9b57b3bc6ecf | 6 | public jpvmTaskStatus pvm_tasks(jpvmConfiguration conf, int which) {
jpvmTaskStatus ret = null;
if(conf==null || which<0 || which>=conf.numHosts)
return null;
try {
jpvmBuffer buf = new jpvmBuffer();
pvm_send(buf,conf.hostDaemonTids[which],
jpvmDaemonMessageTag.jpvmdTaskStatus);
jpvmMessage m... |
d5c71772-0905-402f-be44-9eebeb84b686 | 9 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
final MOB target=this.getTarget(mob,commands,givenTarget);
if(target==null)
return false;
if((!auto)
&&(target.location()!=null)
&&(target.location().getArea().getClimateObj().canSeeTheSun(... |
379a8222-56ad-435f-9df9-01ba83af9e36 | 0 | public int numberOfPawns() {
return pawns.size();
} |
01d66fd7-bfd9-4099-9010-4b09ae463fcd | 3 | protected synchronized Class loadClass(String name, boolean resolve)
throws ClassNotFoundException
{
Class c = findLoadedClass(name);
if (c == null)
c = findClass(name);
if (c == null)
throw new ClassNotFoundException(name);
if (resolve)
... |
a555de9a-b483-44e6-bef7-9e0c1dc5f423 | 1 | public void enqueue(Item item) {
if (isFull())
q = resize(N * 2);
q[(front + size()) % N] = item;
nItems++;
} |
5e14d3fd-68a4-4428-9c71-1dbe8e9342bb | 7 | public static S2Point getIntersection(S2Point a0, S2Point a1, S2Point b0, S2Point b1) {
Preconditions.checkArgument(robustCrossing(a0, a1, b0, b1) > 0,
"Input edges a0a1 and b0b1 muct have a true robustCrossing.");
// We use robustCrossProd() to get accurate results even when two endpoints
// are c... |
a46cf057-aab2-4057-8c52-961a6033ebf6 | 2 | public boolean verificaBancoCriado() {
if (!verificaInstalacaoCouchDB()) {
JOptionPane
.showMessageDialog(null,
"O CouchDB não está instalado em seu sistema",
"Erro na execução do aplicativo",
JOptionPane.ERROR_MESSAGE);
System.exit(0);
}
setNomeBanco("agenda");
String url = getH... |
2aae86b8-b159-4765-a122-dabeb3fd95dc | 6 | private boolean supported(int i) {
switch (i) {
case SUPGA:
case ECHO:
case NAWS:
case TTYPE:
case NEWENV:
return true;
case LINEMODE:
return m_ConnectionData.isLineMode();... |
317a337b-b7f8-4155-804c-947d386fffbf | 0 | public SimRepFileConHandler(String match, String replacement, String lineEnding) {
super(lineEnding);
setMatch(match);
setReplacement(replacement);
} |
de72e32b-5bea-4c2b-884e-fd1c2bebfce3 | 8 | public boolean ld_play( int i, int j, int val ){
int nval = -val;
int i1 = i+1;
int j1=j-1;
while( i1<values.length && j1>=0 && values[i1][j1] == nval ){
i1++;
j1--;
}
if( i1<values.length && j1>=0 && i+1 < i1 && values[i1][j1] == val ){
... |
37566b08-03c7-4bcb-bcae-fc617e36daca | 0 | public void setAddress(int address) {
this.address = address;
} |
f7104e4d-c0b1-4107-add2-d4db10fdbea5 | 6 | static public void adjustBeginLineColumn(int newLine, int newCol)
{
int start = tokenBegin;
int len;
if (bufpos >= tokenBegin)
{
len = bufpos - tokenBegin + inBuf + 1;
}
else
{
len = bufsize - tokenBegin + bufpos + 1 + inBuf;
}
int i = 0, j = 0, k = 0;
int nextCol... |
3ebb5752-f23a-4fe6-a7d3-b17bb3638d17 | 7 | private static boolean handleLadder(Player player, WorldObject object,
int optionId) {
String option = object.getDefinitions().getOption(optionId);
if (option.equalsIgnoreCase("Climb-up")) {
if (player.getPlane() == 3)
return false;
player.useStairs(828, new WorldTile(player.getX(), player.getY(),
... |
22a90c10-acb0-4ab7-96ba-a5baf7b4cde9 | 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... |
bdce9e45-f343-4e88-9f9e-5bd4b83992b8 | 0 | private static long getTime() {
return System.currentTimeMillis();
} |
b99e44e3-f4fc-45f8-b065-2ca7febc10ad | 0 | public static void main(String [] args) {
Field field = new Field();
field.eraseField();
field.showField();
//field.setFieldSize(10);
//field.showField();
} |
1b5fa9be-8c54-4c2a-814f-00733839382f | 2 | public Synthesizer() {
for (int i = 0; i < voices.length; i++) {
voices[i] = new Voice();
voices[i].setSourceShape(WaveShapes.SINE, 0.5f);
}
//32khz samplerate, 8 bit depth, 1 channel, signed, big endian
AudioFormat format = new AudioFormat(SAMPLE_RATE, 8, 1, tru... |
fae6c2cf-b684-4303-9a78-ca30675a5555 | 5 | public int checkQuantity(String recipeName, Date fromDate, Date toDate) {
String sql =
"Select count(*) "+
"from Pallets "+
"where recipeName like ? and creationDateAndTime between ? and ? ";
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(sql);
ps.setString(1, recipeName);
ps... |
aef444a0-a64b-428e-9575-bdab1f1c9c49 | 4 | public boolean winCheck() {
if (wincheck1()) {
return true;
}
if (wincheck2()) {
return true;
}
if (wincheck3()) {
return true;
}
if (wincheck4()) {
return true;
}
return false;
} |
61397aaf-9d88-4109-b77e-36bb38efe28e | 2 | public CalendarDrawArea (Year year, int X, int Y)
{
boxes = new ArrayList <Box>();
Calendar currentDate = Calendar.getInstance();
int m = currentDate.get(Calendar.MONTH);
int d = currentDate.get(Calendar.DATE);
currentYear = year;
currentMonth = year.getMonths().get(m);
currentDay = currentMonth.getDay... |
0662d678-6171-42c7-9b8b-8c11053a9403 | 0 | public int getpY() {
return pY;
} |
00ca6119-c6de-4279-b7cc-b0f77fe86473 | 2 | @Override
public void tick(InputHandler input, GameComponent gc)
{
if (input.keys[KeyEvent.VK_ENTER] || input.keys[KeyEvent.VK_SPACE])
{
input.keys[KeyEvent.VK_SPACE] = false;
input.keys[KeyEvent.VK_ENTER] = false;
gc.setMenu(new MainMenu());
}
} |
e6be70a2-12ed-4202-b8e6-b95d971b0f0e | 8 | public void loadFromFile(File file, String separator, boolean skipFirst) {
try {
BufferedReader in = new BufferedReader(new FileReader(file));
String line;
int irow = -1;
Pattern pattern = Pattern.compile(separator, Pattern.LITERAL);
while ((line = in.readLine()) != null) {
++irow;
if (irow == ... |
027106af-2565-4450-a535-40351d9ee529 | 0 | public int getCount() {
return balls.size();
} |
41d068c9-dc25-4770-a8b1-7860f5f897a1 | 2 | @Test
public void testGetNeighbourhoodBestMinimum(){
boolean result = true;
double testFitness = 0;
for(int i = 0; i < 20; i++){
if(testSolutions.get(classUnderTest.neighbourhoodBest(i)) < testFitness){
result = false;
}
}
assertTrue(result);
} |
e83464dd-2d72-4e83-84a6-d4606abbef31 | 4 | public void run() {
Frame frame;
try {
while(!consumerError & ((frame = frameReader.readFrame()) != null && transceiver.isConsuming())) {
frameBuffer.enbuf(frame);
}
}
catch(InterruptedException e) {
// shutdown in progress
Fluid.error("ReadingEngine: Interrupted", 2);
}
catch(IOException e)... |
92d33c3b-2767-4f0b-a87a-e0c1a5d8471f | 0 | @Test
public void testDivision(){
calculator.pushOperand(10);
calculator.pushOperand(2.0);
calculator.pushDivideByOperator();
calculator.evaluateStack();
assertEquals(5.0, calculator.popOperand(), 0);
} |
2dfa477d-59dd-43a5-b4f0-e56fc258dd66 | 7 | public void insert(T item, int afterIndex) {
assert -1 <= afterIndex && afterIndex < length;
if (afterIndex == -1) {
if (front != null)
front.previous = front;
front = new DNode(item, null, front);
if (back == null)
back = front;
} else {
DNode previousNode = getNode(afterIndex);
DNod... |
ed3336d7-f9bd-4fe4-8c0f-b1719c1661a9 | 5 | public void nextPhrase()
{
if(exPanel != null)
remove(exPanel);
btnCheck.setEnabled(false);
Phrase phr = coach.getRandomPhrase();
LinkedList<Component> tabOrder = new LinkedList<Component>();
if (phr == null)
{
exPanel = new EmptyPanel(null);
btnCheck.setText("Next Phrase");
btnCheck.setMne... |
7b8a5601-c006-463d-aebf-35d8a0558926 | 5 | private int [] combinar(int []left, int right[], int[] lista){
int nleft=left.length;
int nright=right.length;
int l=0,r=0,li=0;
while(l<nleft && r<nright){
if(left[l]<=right[r]){
lista[li]=left[l];
l++;
}
else{
lista[li]=right[r];
r++;
}
li++;
}
while(l<nleft){
lista[li]=l... |
65fefcdb-3b91-46bb-9ca4-267ce674904a | 4 | private byte[] readBytesFromFie(File file) throws IOException {
InputStream is = new FileInputStream(file);
// Get the size of the file
long length = file.length();
// You cannot create an array using a long type.
// It needs to be an int type.
// Before converting to an int type, check
... |
b54c0685-233f-432c-8463-dda9d45b4317 | 1 | private static void drawHorizontalGripper(Graphics gc, DockLayoutNode secondary) {
int x = secondary.getX() - DIVIDER_SIZE + (DIVIDER_SIZE - GRIP_WIDTH) / 2;
int y = secondary.getY() + (secondary.getHeight() - GRIP_LENGTH) / 2;
int top = GRIP_HEIGHT / 2;
int bottom = GRIP_HEIGHT - top;
for (int yy = y; yy < y... |
0f05e81f-9883-47de-af00-a69c822a4646 | 8 | public String treeToString(int level) {
int i;
StringBuffer text = new StringBuffer();
if (!m_isLeaf) {
text.append("\n");
for (i = 1; i <= level; i++) {
text.append("| ");
}
if (m_instances.attribute(m_splitAtt).name().charAt(0) != '[') {
text.append(m_instances.attribute(... |
e9a828e6-23b1-440a-8663-82c6d3b077f9 | 5 | public void nextPermutation(int[] num) {
int current = num.length - 1;
//when find the first descending order element (from end to begin order), reverse these elements
while (current > 0 && num[current - 1] >= num[current]) {
current--;
}
reverse(num, current, num.le... |
b44c13db-75fb-4f62-93fb-5f0e52c288db | 4 | @Override
public void handle(HttpExchange exchange) throws IOException {
System.out.println("In buy dev card handler");
String responseMessage = "";
if(exchange.getRequestMethod().toLowerCase().equals("post")) {
try {
//TODO verify cookie method
String unvalidatedCookie = exchange.getRequestHea... |
4d708136-c9e4-4656-b12a-759d1a6c2ff6 | 2 | @Override
public void spawnEnemy(String enemyData) {
if(!free()) {
return;
}
int r = Application.get().getRNG().nextInt(6);
GameActor a = Application.get().getLogic().createActor(enemyData);
PhysicsComponent pc = (PhysicsComponent)a.getComponent("PhysicsComponent"... |
e207bc17-87dd-417f-8dc4-11e9a414182d | 0 | public IOException getException() {
throw new RuntimeException("not implemented");
} |
5c00c93f-9b4d-47bb-9204-5f8f5c8f56d1 | 7 | public static boolean computeCell(boolean[][] world, int col, int row) {
boolean liveCell = getCell(world, col, row);
int neighbours = countNeighbours(world, col, row);
boolean nextCell = false;
if (neighbours < 2) nextCell = false;
if (liveCell && (neighbours == 2 || neighbours == 3)) nextCell = tru... |
0384292d-9f74-4898-9418-a0f558826917 | 9 | public Object[] mover(int y, int x, int[][] matriz){
recorrido[n][0]=y;
recorrido[n][1]=x;n++;
Object[] resultado ={false,100,100};
try{
if(!isIn(y+1,x,recorrido)&&matriz[y+1][x]==1){
resultado[0]=true;
resultado[1]=y+1;
resultado[2]=x... |
3f7edb09-e929-4f44-971b-21bc035406d4 | 3 | private void createCycle(int n, boolean edges) {
double d = canvas.getHeight() / 3 * Math.sqrt(n) / 5;
for (int i = 0; i < n; ++i) {
createVertex(d * Math.sin(i * 2 * Math.PI / n), -d * Math.cos(i * 2 * Math.PI / n),
getNewVertexID());
}
if (edges) {
... |
8e5b7f92-33c3-4445-9a98-784691dbb4c7 | 5 | private void constructDenseGraph(ArrayList<_Doc> collection) {
m_N = collection.size();
//we need to make this very sparse!
m_transition = new DenseDoubleMatrix2D(m_N, m_N);
double sim;
//construct the connection
for(int i=0; i<collection.size(); i++) {
_Doc di = collection.get(i);
// transit... |
c4d58e0f-506a-41e9-a49e-7aeee3ab3b89 | 8 | private static boolean a1 (int i, int j, BufferedImage image) {
boolean above = ((image.getRGB(i-1, j+1) == BLACK) ||
(image.getRGB(i , j+1) == BLACK) ||
(image.getRGB(i+1, j+1) == BLACK));
boolean with = ((image.getRGB(i-1, j) == WHITE) &&
... |
477fd612-cc8f-4032-a73f-50e606fdc016 | 6 | public static String escape(String string) {
char c;
String s = string.trim();
StringBuffer sb = new StringBuffer();
int length = s.length();
for (int i = 0; i < length; i += 1) {
c = s.charAt(i);
if (c < ' ' || c == '+' || c == '%' ... |
93684d2a-b879-4c95-aa88-b0ee534e0a0b | 5 | public static void main(String[] args) throws IOException{
String city = args[0];
String folder = Settings.getInstance().getFolder();
/**
* This parameter controls the size of the grid that we will create
* around the city.
* WARNING: if the city is either small or very large, you might want
* to change t... |
1177d5cd-991e-41d1-a09a-7c53ca968d0d | 8 | public void updateAudioPanel()
{
System.out.println("updation of audio panel required : ");
audioPanel.removeAll();
studentPanel.removeAll();
studentPanel=new JPanel();
if(Integer.parseInt(studentNumberComboBox.getSelectedItem().toString())<5 || Student.studentListAudio.size()<=5)
studentPanel.setLayout(n... |
8d2bc38c-4307-4c08-a57b-35ffc8e9ff38 | 1 | @Override
public void setSolutionFitness(HashMap<Integer, Double> fitness) {
assert(fitness.size() >= 16 && fitness.size() % 4 == 0);
this.fitness = fitness;
} |
05cc2d21-9e3d-4539-ade6-16988397c1b7 | 6 | static void extractFromZip(String szZipFilePath, String szExtractPath, String szName, ZipFile zf, ZipEntry ze)
{
if (ze.isDirectory()) return;
String szDstName = slash2sep(szName);
String szEntryDir;
if (szDstName.lastIndexOf(File.separator) != -1) szEntryDir = szDstName.substring(0, szDstName.lastIn... |
2f63c70b-3a85-47ea-81f7-acebd11f5563 | 2 | public String[] getSessionInfo() {
String profileID = "";
String accessToken = "";
try {
HttpClient hClient = new DefaultHttpClient();
HttpPost hPost = new HttpPost("https://authserver.mojang.com/authenticate");
String jsonData = ""
+ "{... |
3b18c8a9-fd3a-4c9b-be7b-79bb6f2078bf | 8 | public static boolean Check(String User, String Command) {
boolean Grant = false;
if (Command.equals(new String("\\setspawn"))) {
if (User.equals(new String("F1shb0ne"))) {
Grant = true;
}
}
if (Command == "\\spawn") {
Grant = true;
... |
ebae0807-c1c2-4a62-849c-51f2867d3a38 | 9 | public static void invert(double src[][], double dst[][]) {
gaussian(src, a);
for (int i = 0 ; i < 4 ; i++)
for (int j = 0 ; j < 4 ; j++)
b[i][i] = i == j ? 1 : 0;
for (int i = 0 ; i < 3 ; i++)
for (int j = i + 1 ; j < 4 ; j++)
for (int k = 0 ; k < 4 ; k++)
... |
fbb6e0ed-f1e2-4f27-88d0-bdbbe8fb7fec | 4 | @Override
public StringBuffer getOOXML( String catAxisId, String valAxisId, String serAxisId )
{
StringBuffer cooxml = new StringBuffer();
// chart type: contains chart options and series data
cooxml.append( "<c:lineChart>" );
cooxml.append( "\r\n" );
cooxml.append( "<c:grouping val=\"" );
if( is100Perc... |
759b7382-3204-4b58-94c3-623742e86e48 | 6 | public void setPixel(int x, int y, double r, double g, double b) {
if (r < 0)
r = 0;
if (r > 1)
r = 1;
if (g < 0)
g = 0;
if (g > 1)
g = 1;
if (b < 0)
b = 0;
if (b > 1)
b = 1;
Color col = new Color((int) Math.round(r * 255.),
(int) Math.round(g * 255.), (int) Math.round(b * 255.));
... |
f7484226-74cc-4d3a-b39e-03679f8b5630 | 3 | public GedcomObjectFactory findFactoryForTag(String tag) {
if (tag.equalsIgnoreCase("SOUR"))
return sourceFactory;
else if (tag.equalsIgnoreCase("NOTE"))
return noteFactory;
GedcomObjectFactory factory = (GedcomObjectFactory)eventHash.get(tag);
if (factory != null)
return factory;
return null;
... |
18a2c9c0-fe52-4cfd-9697-24aada7c9549 | 5 | public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
Graphics2D g2d = (Graphics2D)graphics;
ImageIcon icon;
Shape clip = g2d.getClip();
AffineTransform savedTransform = g2d.getTransform();
try {
double width = pa... |
28ed3bfe-1d11-4a89-998a-2fbc8f4af277 | 2 | public static String getFilename(String path) {
if (path == null) {
return null;
}
int separatorIndex = path.lastIndexOf(FOLDER_SEPARATOR);
return (separatorIndex != -1 ? path.substring(separatorIndex + 1) : path);
} |
c49e57b7-b0e9-4b15-87a2-3b847dce2aaa | 3 | public void setScene(Scene paramScene)
{
unregisterAll();
if (this.shroud != null) {
this.shroud.removeShroudListener(this);
}
this.Surface.unregisterAll();
this.Layers.clear();
this.CurrentScene = paramScene;
this.map = paramScene.getMap();
this.MapSize = this.map.getSize();
... |
ef5a2fb5-c50c-4934-a53e-ab354ba08be0 | 3 | void appendInstruction(Instruction newInstr, BytecodeInfo codeinfo) {
newInstr.addr = nextByAddr.addr;
newInstr.nextByAddr = nextByAddr;
nextByAddr.prevByAddr = newInstr;
newInstr.prevByAddr = this;
nextByAddr = newInstr;
/* adjust exception handlers end */
Handler[] handlers = codeinfo.getExceptionHand... |
6b2b2d66-54a6-4f5c-87e1-70de8b031285 | 5 | public static void main(String[] args) {
System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
Map<Integer, TrackedFile> trackedFileMap = TorrentSimUtils.initializeTrackedFiles();
Map<Integer, Peer> mapOfPeers = TorrentSimUtils.createPeerMap();
TorrentSimUtils.distributeFile... |
7207fa0c-4fc1-40ad-86f2-a57d57db5fe3 | 0 | public Dealer cDealer(){
Dealer dealer = new Dealer(17);
return dealer;
} |
955bb357-c899-449c-9574-da402470c679 | 7 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (dao == null) {
Map<String, String> env = System.getenv();
String services = env.get("VCAP_SERVICES");
ObjectMapper mapper = new ObjectMapper();
Map svcsMap = mapper.readValue(services... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.