method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
9cfb8850-4c6a-4bb9-b514-f5cf901994df | 3 | public double correlationZeroTime(double[] sign1, double[] sign2){
double sum = 0.0;
if(sign1.length == sign2.length)
for(int i=0; i < sign1.length; i++)
sum += (sign1[i] * sign2[i]);
else System.out.println("The length of sign1 and sign2 is not the same.");
return (sum<0.00001)?0:sum;
} |
8d3ec67f-a3cd-40a7-a049-e3ea34f70ec3 | 4 | @Override
public void actualiza(long tiempoTranscurrido) {
if(pausa) { //si esta pausado, no se actualiza
return;
}
checaColision();
//actualiza las animaciones
bola.getAnimacion().actualiza(tiempoTranscurrido);
barra.getAnimacion().actua... |
e30203ac-f0b1-44eb-9b0e-060c5d206a5b | 1 | public void printRoute(int[] route){
for(int i = 0;i<route.length;i++){
System.out.print(route[i]+" ");
}
} |
e8fae65f-1a8d-4f9d-b337-f25cd748b8eb | 9 | public String find(String word) {
String likes = "Likes";
String dislikes = "Dislikes";
if (word.toUpperCase() != word) {
return dislikes;
}
char previousC = 0;
for (char c : word.toCharArray()) {
if (c == previousC) {
return dislikes;
}
previousC = c;
}
for (int i = 0; i < word.lengt... |
f7663874-9b6f-4123-9cf3-ced7ee559be3 | 4 | private org.apache.commons.httpclient.HttpClient getHttpClient(){
org.apache.commons.httpclient.HttpClient client = new org.apache.commons.httpclient.HttpClient();
if (proxyHost != null && !proxyHost.equals("")) {
client.getHostConfiguration().setProxy(proxyHost, proxyPort);
client.getParams().setAuth... |
cfc005f7-e9e3-43b4-a4a5-06e381e2a506 | 4 | @Override
public void load(Map<String, Object> map) throws DataLoadFailedException {
super.load(map);
Object obj = map.get("groups");
if (obj instanceof List) {
List list = (List) obj;
for (Object o : list) {
if (o instanceof String) {
... |
6426659b-b3cc-4798-9b9d-173643f7af1c | 6 | private void arrivalInit(double[] aarr, double[] barr,
double[] anum, double[] bnum, int start_hour, double weights[][]) {
int idx, moveto = CYCLIC_DAY_START;
double[] mean = new double[] {0,0};
for(int i=0; i<weights.length; i++) {
for(int j=0; j<weights[i].length; j++) {
weig... |
69bb6319-4f03-4577-b444-d92b9bdb75f8 | 4 | public boolean smaller(double tmp) {
boolean flag = true;
for (int i = 0; i < p.length - 1; i++) {
if (Math.abs(p[i]) > epsilon) {
flag = false;
}
}
if (flag == true && p[p.length - 1] < tmp)
return true;
else
return false;
} |
8f285053-57db-4114-9d54-b60647f5b50b | 6 | private int getFirstArgEndIndex() {
int l = arg.length();
// An empty string can't have any arguments
if(l == 0) {
return -1;
}
int i;
for(i = 0; i < l; i++) {
char c = arg.charAt(i);
if(c == '\"') {
i = getSectionEndIndex(i, '\"');
} else if (c == '[') {
i = getSectionEndIndex(i, ']');
... |
ed868295-eeb5-41a6-9bbb-42fb3e4a6e3f | 7 | */
public void visit_ldc(final Instruction inst) {
final Object value = inst.operand();
Type type;
if (value == null) {
type = Type.NULL;
} else if (value instanceof Integer) {
type = Type.INTEGER;
} else if (value instanceof Long) {
type = Type.LONG;
} else if (value instanceof Float) {
type ... |
27cadc87-79a5-4632-b879-7d2d3e7051dd | 3 | public int numOf2s(int n) {
// Ending condition:
if (n == 0) {
return 0;
}
// get the top digit
int top = new Integer(n).toString().toCharArray()[0] - '0';
int numOfDigits = new Integer(n).toString().length();// String.getLength()???
int next = n - top * (int) Math.pow(10, numOfDigits - 1);
int nines... |
99437d73-cc3c-429e-94ec-ef83d9026176 | 8 | final private boolean jj_3R_37() {
Token xsp;
xsp = jj_scanpos;
if (jj_3R_64()) {
jj_scanpos = xsp;
if (jj_3R_65()) {
jj_scanpos = xsp;
if (jj_3R_66()) {
jj_scanpos = xsp;
if (jj_3R_67()) {
jj_scanpos = xsp;
if (jj_3R_68()) {
jj_scanpos = xsp;
if (jj_3R_69()) {
jj... |
8e1b5ce6-8efa-4906-ba8c-4d83acd340d7 | 3 | public static void replyToPlayer( String sender, String message ) {
BSPlayer p = PlayerManager.getPlayer( sender );
String reply = p.getReplyPlayer();
if ( p.isMuted() && ChatConfig.mutePrivateMessages ) {
p.sendMessage( Messages.MUTED );
return;
}
if ( re... |
cce51d0a-7fa8-40e6-8739-8124dbdcf890 | 5 | private void shootFirework(Location loc) {
Firework fw = (Firework) loc.getWorld().spawnEntity(loc, EntityType.FIREWORK);
FireworkMeta fwm = fw.getFireworkMeta();
Random r = new Random();
int rt = r.nextInt(5) + 1;
FireworkEffect.Type type = FireworkEffect.Type.BALL;
if... |
ffd1e876-b7a2-403e-a5af-c62c30ff5ff0 | 8 | HashSet getAllspTempOutliers() throws SQLException {
ArrayList<ArrayList<String>> results= new ArrayList<ArrayList<String>>();
RegionIdData rid=new RegionIdData();
ArrayList<String> smallList=rid.getCentralCoordinate(region);
results.add(smallList);
String months="JAN FEB MAR APR M... |
8263db0b-c1b7-4e39-9145-9b6d2a783c5c | 4 | static public OutputChannels fromInt(int code)
{
switch (code)
{
case LEFT_CHANNEL:
return LEFT;
case RIGHT_CHANNEL:
return RIGHT;
case BOTH_CHANNELS:
return BOTH;
case DOWNMIX_CHANNELS:
return DOWNMIX;
default:
throw new IllegalArgumentException("Invalid channel code: "+code);
}
} |
4d71616d-150d-400f-ade2-450ad32fe29b | 8 | public static double [][] loadBandwidth()
{
double[][] ret = new double[4][2001];
File file = new File("bandwidth.txt");
FileReader fr;
StringTokenizer tokenizer;
int cnt = 0;
try {
fr = new FileReader(file);
BufferedReader inFile = new BufferedReader(fr);
String line = inFile.readLine();
int d... |
dc37234d-6dda-4171-96a2-9303a4358529 | 7 | public static void main(String[] args) {
Scanner input = new Scanner(System.in);
boolean first = true;
while (input.hasNext()) {
// extra line between input cases
if (!first) System.out.println();
first = false;
int numPpl = input.nextInt();
// store the people in order
HashMap<String, Integ... |
4af6ec19-8d1a-4870-a01c-ba24ccc0a23e | 6 | public static void main(String args[]) throws UnsupportedLookAndFeelException {
/* 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.... |
b73d0677-1e31-4d7e-b634-cb9f36680efd | 9 | public final Boolean validate(final Integer newYear, final Integer newMonth, final Integer newDay) {
//some rough testing
if (newDay.equals(null)
|| newDay <= 0
|| newDay > MAX_DAYS_IN_MONTH
|| newMonth.equals(null)
|| newMonth <= 0
|| newMonth > MAX_MONTH_IN_YEAR
|| newYear.equals(nul... |
2d4c0617-b797-4a2c-a0aa-1ff449fb6241 | 6 | public boolean getBoolean(String key) throws JSONException {
Object object = this.get(key);
if (object.equals(Boolean.FALSE)
|| (object instanceof String && ((String) object)
.equalsIgnoreCase("false"))) {
return false;
} else if (object.equals... |
87174c69-a5d3-4b4d-94df-221405e5f609 | 5 | public static void load(final List<ScriptInfo> scripts, final File file) throws ClassNotFoundException, IOException, IllegalAccessException, InstantiationException {
final JarFile jar = new JarFile(file);
final Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
... |
20e799b5-4370-42e5-9f02-bab04a94524b | 5 | private void writeBitmap() throws Exception {
int size;
int value;
int j;
int i;
int rowCount;
int rowIndex;
int lastRowIndex;
int pad;
int padCount;
byte rgb[] = new byte[3];
size = (biWidth * biHeight) - 1;
pad = 4 - ((biWidth * 3) % 4);
// The following bug correction will cause the bitmap to be unrea... |
70ca3c1d-8109-4c64-81e2-514797066ade | 0 | public boolean isCanceled() {
return canceled;
} |
17127e65-a5ab-494f-8daa-07c2c52e52bd | 5 | @Override
public void update() {
super.update();
if(isActivated()) {
if(canFire)
{
//target the closest mob
Monster m = registry.getMonsterManager().getClosestWithinMax(getCenterPoint(), MAX_RANGE);
if(m != null) {
... |
b35e4fa5-e7b5-4534-9e9a-deed442465be | 0 | public Engine getEngine() {
return engine;
} |
e98c23b8-6714-4ace-9184-2b70f4ddcbff | 5 | public static Result calcResult(int truePositives, int falsePositives,
int falseNegatives, int trueNegatives) {
double precision = truePositives / (float) (truePositives + falsePositives);
double recall = truePositives / (float) (truePositives + falseNegatives);
double fScore = 2 * ((precision * recall) / (pre... |
3155deb9-2107-4f28-b2b1-63530c7c8c65 | 2 | public final synchronized Character readCharacter(){
int ich = -1;
char ch = '\u0000';
Character wch = null;
try{
ich = input.read();
}catch(java.io.IOException e){
System.out.println(e);
... |
22320e43-1b6d-45ee-a6b8-782e38e96395 | 0 | private static int findMidpoint(int hi, int lo) {
return lo + ((hi - lo) / 2);
} |
bbae68fc-48e3-44e1-a459-5b6c57b4e785 | 5 | public Instruction findMatchingPop() {
int poppush[] = new int[2];
getStackPopPush(poppush);
int count = poppush[1];
Instruction instr = this;
while (true) {
if (instr.succs != null || instr.doesAlwaysJump())
return null;
instr = instr.nextByAddr;
if (instr.preds != null)
return null;
in... |
d677d803-8120-40d9-b023-e2d833b9aa9d | 6 | private ArrayList<OneMealData> findMatchedMeals(ArrayList<Canteen> canteens) {
ArrayList<OneMealData> matchedMeals = new ArrayList<OneMealData>();
//Not pretty at all!!
for (Canteen canteen : canteens) {
for (LineData lineData : canteen.getCanteenData().getLines()) {
if (!lineData.getLineName().equals("... |
33a33b0a-6b52-429d-99a0-3c737ccd7f96 | 3 | public static byte menuAbrirCuentaClienteNuevo(){
byte op=0;
do{
try{
System.out.println("Cliente nuevo");
System.out.println("1. Abrir Cuenta Corriente");
System.out.println("2. Abrir Cuenta de Ahorro");
System.out.print("OP => ");
BufferedReader stdin=new BufferedReader(new InputStreamReader(Syst... |
6b2327fb-32ec-4223-b93c-30ec1504a398 | 8 | public void putAll( Map<? extends Integer, ? extends Long> map ) {
Iterator<? extends Entry<? extends Integer,? extends Long>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Integer,? extends Long> e = it.next();
this.put( e.get... |
e65ed01c-ce75-4342-9e3e-d85e6352adff | 1 | public static String showString() {
StringBuilder builder = new StringBuilder();
for (Argument arg : arguments.values()) {
builder.append(arg.toString());
builder.append("\n");
}
return builder.toString();
} |
b8f6ced6-bdf5-42c2-952a-70b29a930e0e | 2 | static void input(double[][] matrix){
for(int i = 0; i < matrix.length; i++){
for(int j = 0; j < matrix[i].length; j++){
matrix[i][j] = scan.nextDouble();
}
}
} |
15950aff-c6b7-487c-9e73-8de8ac83475f | 3 | @Override
public void deletePosition(Position position) throws SQLException {
Connection dbConnection = null;
PreparedStatement preparedStatement = null;
String deletePosition = "DELETE FROM position WHERE id_position = '"
+ position.getId() + "'";
try {
dbConnection = PSQL.getConnection();
prepared... |
8d52d712-b373-489e-b9a7-52ea2dde99bc | 8 | public void player1move(){
if (leftPressed)
{
if(!player1.offscreenleft)
{
player1.setX(player1.getX() - player1Speed);
}
} else if (rightPressed)
{
if(!playe... |
41a53f81-681b-48bd-b3a1-0f2136325bc5 | 8 | private void setupButtons() {
// Air button
String airText = VirusStatistics.isAirTransmission() ? "Air" : "Air ("
+ VirusStatistics.getAirTransmissionCost() + ")";
Color airColor = VirusStatistics.isAirTransmission() ? BUTTON_BUY_COLOR : BUTTON_COLOR;
airButton = new Button(20, 50, BUTTON_WIDTH, BUTTON_HEI... |
9e693c8d-16c8-49b7-ac61-95cec540744e | 5 | private void edgeCheck() {
Vector2D pos = gameObject.getPos();
switch(gameObject.getMoveDir()){
case MOVE_UP:
blockedCheck(pos.x, pos.y-delta*speed);
break;
case MOVE_DOWN:
blockedCheck(pos.x, pos.y+delta*speed);
break;
case MOVE_LEFT:
blockedCheck(pos.x - delta*speed, pos.y);
break;
case ... |
6038cad6-f02a-4da6-a936-3fb9d2efbe75 | 8 | private static int ssIsqrt(int x)
{
if (x >= (SS_BLOCKSIZE * SS_BLOCKSIZE))
return SS_BLOCKSIZE;
final int e = ((x & 0xFFFF0000) != 0) ? (((x & 0xFF000000) != 0) ? 24 + LOG_TABLE[(x>>24) & 0xFF]
: 16 + LOG_TABLE[(x>>16) & 0xFF])
: (((x & 0x0000FF00) != 0) ? 8 + L... |
cda7e8d4-876d-4bd7-b11b-350fc3ea9f05 | 1 | public synchronized void editar(int i)
{
try
{
new InstituicaoCooperadoraView(this, list.get(i));
}
catch (Exception e)
{
}
} |
e740c166-c576-46e5-8b6a-af3ca990584a | 6 | public void handleInput(InputManager input)
{
// Move to the previous menu entry?
if (input.getMenuUp())
{
_SelectedEntry--;
if (_SelectedEntry < 0)
{
_SelectedEntry = _MenuEntries.size() - 1;
}
}
// Move to the next menu entry?
if (input.getMenuDown())
{
_SelectedEntry++;
if (_S... |
76f24846-59c1-4334-9102-14bacdf7ac91 | 4 | @Override
public String codonsOld() {
int numCodons = 1;
// Get CDS
String cdsStr = transcript.cds();
int cdsLen = cdsStr.length();
// Calculate minBase (first codon base in the CDS)
int minBase = codonNum * CodonChange.CODON_SIZE;
if (minBase < 0) minBase = 0;
// Calculate maxBase (last codon base ... |
cba4e00d-e6ce-4fd6-9769-67f39aae09f0 | 8 | public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String line = "";
StringBuilder out = new StringBuilder();
int times = 0;
int[] ids = new int[100001];
while ((line = in.readLine()) != null) {
if (times++ != 0)
line ... |
3d8771fe-f284-4cd5-b525-261250264676 | 0 | protected Point getCenterIntersection(State state1, State state2) {
return pointOnState(state1, angle(state1, state2));
} |
18182e66-52d0-4eb1-b874-aa166fbfc744 | 2 | private void wczytajPaczke() {
//this.campaign = new Campaign();
String tempStr=getXML();
if(tempStr.equals(""))
return;
this.campaign.clearCampaign();
if(campaign.loadXml(tempStr))
{
NewQuizView.setCampaign(campaign);
} //projectTabPane.setCampaign(campaign);
projectTabPane.initiateGameFields();... |
8998fb2f-65ba-45de-970a-744a332f0f35 | 9 | public void renderElement(int pos, Graphics g) {
Polygon p = new Polygon();
switch (pos) {
case 0:
p.addPoint(0.5F, -0.5F);
p.addPoint(0.5F, 0);
p.addPoint(0.25F, 0);
p.addPoint(0.25F, -0.25F);
break;
... |
b046b5ed-26bb-44f6-a021-6fb9cbb2c1b6 | 2 | public void testGetField() {
MonthDay test = new MonthDay(COPTIC_PARIS);
assertSame(COPTIC_UTC.monthOfYear(), test.getField(0));
assertSame(COPTIC_UTC.dayOfMonth(), test.getField(1));
try {
test.getField(-1);
} catch (IndexOutOfBoundsException ex) {}
try {
... |
45e57d51-d0d1-404c-af94-a5ada528c073 | 2 | private String getAttributeValue(AXmlResourceParser parser, String attributeName) {
for (int i = 0; i < parser.getAttributeCount(); i++)
if (parser.getAttributeName(i).equals(attributeName))
return AXMLPrinter.getAttributeValue(parser, i);
return "";
} |
0a1507db-530a-4c24-95b5-fd295ad1ff02 | 0 | public Journal getByName(String name) {
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Journal.class);
criteria.add(Restrictions.eq("name", name));
return (Journal) criteria.uniqueResult();
} |
c42957ec-98e0-4f48-9c81-b3c4a69ebf72 | 9 | private Node firstIntersectionNode( Node node, K key ) {
if( node == null ) {
return null;
}
Node ret = null;
while( true ) {
if( mComp.compareMinToMax( key, node.mKey ) < 0 && mComp.compareMinToMax( node.mKey, key ) < 0 ) {
ret = node;
... |
368dba66-47ac-4c42-b28e-c839491f6c6d | 0 | public void setId(Integer id) {
this.id = id;
} |
769ea4a7-d9e4-4fee-a27a-ffd34e0805eb | 2 | public static Image applyMaskAndZeroCross(Image original, Mask mask,
int threshold) {
Image masked = applyMask(original, mask);
Image image = original.shallowClone();
if (original.isRgb()) {
zeroCross(masked, image, threshold, RED);
zeroCross(masked, image, threshold, GREEN);
zeroCross(masked, image, ... |
e4a0fd14-8b55-4ace-822d-f52b899026a1 | 5 | @Override
public void execute(CommandSender sender, String worldName, List<String> args) {
this.sender = sender;
if (worldName == null) {
error("No world given.");
reply("Usage: /gworld suppresshunger <worldname> <true|false>");
} else if (!hasWorld(worldName)) {
reply("World not found: " + worldName... |
26bb6282-7715-4022-8260-aafd30750d8b | 0 | public static PriceManager getInstance()
{
return instance;
} |
b7e87524-45a9-47c6-bfe7-018c94cc01ee | 7 | public synchronized void saveDataHeader(HashMap<String,String> metaInfo, Integer count){
//Hibernate Session creation.
Session session = HibernateUtil.getMetaSessionFactory().openSession();
Transaction txn = null;
//session.beginTransaction();
if(session != null){
... |
2141a7b5-9367-43d2-aeab-7e7a7a60a730 | 7 | public void showText(Screen screen) {
if(option == OPTION.NONE) font.render(170, 35, -2, 0, "The Judgement", screen);
if(option == OPTION.ITEMS) font.render(215, 35, -4, 0, "Items", screen);
if(option == OPTION.EQUIPMENT) font.render(200, 35, -4, 0, "Equipment", screen);
if(option == OPTION.MAGIC) font.render(2... |
9c7c058b-95a4-4305-aacd-8cacb51554f9 | 5 | public void uzyskanieOdpNaPytanie_oRewanz()
{
boolean b_odpowiedz = false;
Object[] opcje = {"Tak","Nie"};
int odpowiedz = JOptionPane.showOptionDialog(widokWynikow, "Przeciwnik proponuje rewanż. Zgadzasz się?",
"Statki", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
null, opcje, opcje[0]);
... |
e993fde8-1228-4e4d-9489-09c6904fc9a1 | 2 | public void getRandom() {
//generate a temp value for the random;
int temp = 0;
if (!isVisible()) {
setVisible(true);
}
temp = getBpm() + r.nextInt(tolerance);
if (temp > max) {
BPM = getBpm() - r.nextInt(tolerance);
} else {
BP... |
3ab79ac9-d3f7-4df1-a200-9ce58aa8ba6e | 5 | public static int updateUserInfo(String uid, String u_name, String u_qq, String u_Email, String u_favourite,
String u_dis) {
int result = 0;
Connection con = DBUtil.getConnection();
PreparedStatement pstmt = null;
try {
pstmt = con.prepareStatement("update mstx_user set u_name=?, u_qq=?, u_Email=?, u_hobb... |
e90781fa-13b2-41e3-a81a-1a0596c6f65e | 8 | private int[] image2pixels(Image image)
{
int ai[] = new int[picsize];
PixelGrabber pixelgrabber =
new PixelGrabber(image, 0, 0, width, height, ai, 0, width);
try
{
pixelgrabber.grabPixels();
}
catch (InterruptedException interruptedexception)
{
... |
31099ef5-b515-42fa-ae50-23e3c82af160 | 9 | public void endGame(boolean plateauRempli) {
JLabel gagnantLabel = new JLabel("");
String text = null;
Couleur gagnant = jeu.getGagnant();
System.out.println("gagnant : "+gagnant.toString());
if (!plateauRempli) {
int pointsRestants=0;
for (int i=0;i<Plateau.PLATEAU_HEIGHT;i++) {
f... |
f0972dfc-5c7b-4caf-b135-13fbcc035e39 | 7 | public boolean handleMainMenuInput(){
String userChoice;
boolean safeChoice = false;
boolean endGame = false;
while(!safeChoice){
System.out.print("Command: ");
userChoice = input.next();
if(userChoice.compareTo("Shop") == 0 || userChoice.compareTo("shop") == 0){
event = new Shop();
even... |
63a68ca2-aeb3-42cd-b366-6504ba127475 | 8 | private Component cycle(Component currentComponent, int delta) {
int index = -1;
loop : for (int i = 0; i < m_Components.length; i++) {
Component component = m_Components[i];
for (Component c = currentComponent; c != null; c = c.getParent()) {
if (component == c) {
index = i;
break loop;
}
... |
70c1b2e0-6c01-426a-9b91-c305c4af6ba1 | 5 | public int getUnsignedInt(int start, int offset) {
if (start < 0 || stringData.length() < (start + offset))
return stringData.charAt(0);
if (offset == 1) {
return stringData.charAt(start);
}
if (offset == 2) {
return ((stringData.charAt(start) & 0xFF)... |
de5fbc54-1181-4b42-bb3f-55f9d9ed032a | 5 | protected synchronized void parserNode(Node node, WebPage wp) throws Exception {
if (node instanceof TextNode) {// 判斷是否是文本結點
// srb.addText(((TextNode) node).getText());
} else if (node instanceof Tag) {// 判斷是否是標籤庫結點
Tag atag = (Tag) node;
if (atag instanceof LinkTag) {// 判斷是否是標LINK結點
LinkTag linkatag =... |
d6190678-8719-488e-a5ea-e3834fbbeb5f | 7 | public void drawItem(Graphics2D g2,
CategoryItemRendererState state,
Rectangle2D dataArea,
CategoryPlot plot,
CategoryAxis domainAxis,
ValueAxis rangeAxis,
CategoryDatase... |
45dcdbdb-baaa-40b2-b279-ec06c896fe8c | 1 | public boolean createChannel(Player p, String channelName) {
if(ChannelsConfig.getChannels().getConfigurationSection("channels").contains(channelName)) {
Messenger.tell(p, Msg.CUSTOM_CHANNELS_EXISTS);
return false;
}
ChannelsConfig.getChannels().createSection("channels." + channelName);
ChannelsConfig.g... |
c9841c5c-4113-452b-8882-7b1cd16d9b27 | 8 | public void updateModel()
{
//We don't allow reverse moves for the snake
boolean lateral = (lastDir == Direction.RIGHT && direction == Direction.LEFT)
|| (direction == Direction.RIGHT && lastDir == Direction.LEFT) ;
boolean vertical = (lastDir == Direction.UP && direction == Direction.DOWN)
|| (direction... |
36647971-752e-4330-99ac-3a833b1695fd | 3 | @Override
public boolean addUser(User user)
{
/*
* we add a new unique user to UserDB
* if User name exist this function will return false
*/
{
Session session = null;
boolean succses = true;
try {
session = factory.openSession();
session.beginTransaction();
session.save(user);
s... |
c85d3722-2328-4625-bb7b-20b35f223307 | 3 | public void setFullScreen(DisplayMode dm) {
JFrame f = new JFrame();
f.setUndecorated(true);
f.setIgnoreRepaint(true);
f.setResizable(false);
vc.setFullScreenWindow(f);
if (dm != null && vc.isDisplayChangeSupported()){
try {
vc.setDisplayMode(... |
0c9d93e1-896c-462a-bd88-b432aa68f3f5 | 6 | private static Double castDouble(Object o) {
if (o == null) {
return null;
} else if (o instanceof Float) {
return (double) (Float) o;
} else if (o instanceof Double) {
return (Double) o;
} else if (o instanceof Byte) {
return (double) (Byt... |
1d7bbf80-c4c6-4911-a13e-f19b1f2a0409 | 5 | @Test
public void TestaaTyhjaVasenAlanurkkaOikeaYlanurkka() {
rakentaja = new Kartanrakentaja(10, 6);
char[][] kartta = rakentaja.getKartta();
Solmu aloitus = new Solmu(kartta.length-1, 0);
Solmu maali = new Solmu(0, kartta[0].length-1);
Reitinhaku haku = new Reitinhaku(kartt... |
3af5608d-146a-451e-9a94-64ebf04e3b1a | 9 | public void close() {
if(fos != null)
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
if(file != null)
file.delete();
if(initReq != null) {
String fileUID = initReq.getFileUID();
FileTransferClientCallBack cb = initReq.getGetFileCallBack();
printMessage("Signal ... |
40a1fcf4-3cf5-4250-a3df-9f5aa18c764f | 9 | public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
if ((this.PFPanel.getSelectedIndex() == 0 || this.PFPanel.getSelectedIndex() == 1) &&
patientList.getSelectedIndex() >= 0 &&
e.getSource() == patientList) {
... |
fb0d1400-b30d-4a06-a2dd-cff4a3dbeab3 | 8 | private void createGUI() {
JPanel mainPanel = new JPanel(new BorderLayout());
JPanel dataPanel = new JPanel(new MigLayout("fill, nogrid"));
receptionCodeLabel = new JLabel();
byRecordLabel = new JLabel();
serviceNameLabel = new JLabel();
serviceNameLabel.setBorder(BorderFactory.createEtchedBorder());
... |
61b23694-3e9d-417c-9a65-9927bcd8aa57 | 8 | @Override
public synchronized boolean delete(SyndicateFSPath path) throws FileNotFoundException, IOException {
if(path == null) {
LOG.error("path is null");
throw new IllegalArgumentException("path is null");
}
SyndicateFSPath absPath = getAbsolutePath(path);... |
860fbaf9-2964-4d0a-9a40-34aba28578ce | 5 | private static String getName(int playerNum, String prevName){
String name;
while(true){
System.out.print("Player " + playerNum + " please enter your name.\n>> ");
name = scanner.nextLine().trim();
//if there is no spaces and it is not empty and names are not the same
if(!name.isEmpty() && !(nam... |
b4cdd99e-60da-43d5-8d88-eb91993b7ae7 | 7 | @Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
this.buttonPressed = true;
this.dragInitiated = true;
boolean anySelected = false;
Vector2 touchPos = new Vector2(screenX, 640 - screenY);
for(Character character : this.characters)
{
Vector2 characterCenterPos = new Ve... |
1edc028d-b345-4ef0-bddb-2e99c8e849bc | 6 | private Value search(Node x, Key key, int ht) {
Entry[] children = x.children;
// external node
if (ht == 0) {
for (int j = 0; j < x.m; j++) {
if (eq(key, children[j].key)) return (Value) children[j].value;
}
}
// internal node
el... |
4a95bb4e-94d6-46c1-9e93-598669fab349 | 3 | public void DFS(int v) {
boolean[] visited = new boolean[vertice];
for (int i = 0; i < visited.length; i++) {
visited[i] = false;
}
for (int i = 0; i < vertice; i++) {
if (!visited[i])
DFSUtils(i, visited);
}
} |
689f78a9-2e86-498f-bb1f-7166abeb921f | 8 | public void timeCounter(){
try{
String strline;
while((strline=timeBr.readLine())!=null){
String[] s = strline.split("[-: ]+");
// s[0]:年, s[1]:月, s[6]:题号;
String time = s[0] + s[1];
if(timemap.containsKey(time))
timemap.put(time, timemap.get(time)+1);
else
timemap.put(time, 1);
... |
61c4da2b-5b43-459f-8e54-c652af99ad96 | 1 | private void mettreAJourLePlateau(Position unePosition)
throws AucunPionARetournerExeption
{
ArrayList<Position> positionsDesCasesDesPionsAInverser = this
.obtenirPositionsDesCasesDesPionsAInverser(unePosition);
for (Position positionCourante : positionsDesCasesDesPionsAInverser)
{
this.plateau.obteni... |
0d83e639-6cbe-41d2-b9af-52cc4058e36f | 2 | public PolyLinje findKortasteGulaPolylinje(PolyLinje[] randomPolylinje)
{
// Går igenom array:en och kollar av varje
// polylinje om den är gul; om ja - kolla dess distans
// om inte fortsätt, gå igenom helt & behåll lägsta sträckan samt
// index till polylinjen och skriv ut dess info.
PolyLinje[] gulaPolyl... |
4d29b585-67e5-4850-a033-eed29059f3aa | 3 | private boolean initFile(String filename) {
try {
File f = new File(filename);
if (!f.exists()) {
f.createNewFile();
}
File f2 = new File(filename);
if (f2.exists()) {
return true;
}
} catch (Exception e) {
log.severe(e.getMessage());
}
return false;
} |
b3fc024a-b1df-4777-b65b-0ca7f550c9f9 | 4 | @EventHandler(priority = EventPriority.LOWEST)
public void onPlayerJoin(PlayerJoinEvent event) throws VanishNotLoadedException {
Player player = event.getPlayer();
String newJoinMessage = "";
newJoinMessage += this.plugin.getConfig().getString("server.joinmessage");
newJoinMessage =... |
74fc0369-1b9f-46e4-81ac-6e3765578de1 | 1 | public static GameConnection getInstance(){
if(instance == null){
instance = new GameConnection();
}
return instance;
} |
1f5e233e-c275-4347-9863-aca358fd2427 | 7 | protected DataTable addRows(Worksheet worksheet) {
DataTable dataTable = worksheet.getDatatable();
int width = dataTable.getColumnHeaders().size();
String[][] data = worksheet.getData();
//start on 6th line
for (int y = 5; y < data.length; y++) {
if(Helper.isNotBlank(data[y][0]) && data[y][0].matches... |
98cff975-82a5-4cdc-a337-a2a6cdbf7b47 | 8 | protected Instances process(Instances instances) throws Exception {
Instances result;
int i;
int n;
double[] values;
String value;
Instance inst;
Instance newInst;
// we need the complete input data!
if (!isFirstBatchDone())
setOutputFormat(determineOutputFormat(getInput... |
6b8eafaa-08f7-4d89-8fcd-d5b3246a5e26 | 2 | public String getListaCodigosDisciplinas(List<Disciplina> lista) {
String listaCodigo = "";
for (int k = 0; k < lista.size(); k++) {
listaCodigo += lista.get(k).getCodigo();
if (k != lista.size() - 1) {
listaCodigo += ",";
}
}
return listaCodigo;
} |
dbba1f9b-dc13-4610-aecb-1e864766679b | 7 | @Override
public String getListOfRecommendations() {
String sql = SELECT_PROJECTS_FOR_TRAINING;
List<Position> positions = new ArrayList<Position>();
ResultSet resultSet = null;
Statement statement = null;
Connection connection = new DbConnection().getConnection();
try {
statement = connection.createSta... |
dc6ca0ff-d106-4adc-8a76-960741d07877 | 8 | private void computeOneOverlap(Overlappable overlappable,
Vector<Overlap> overlaps) {
Area overlappableArea, targetArea;
Rectangle boundingBoxTarget, boundingBoxOverlappable;
Shape intersectShape = intersectionComputation(overlappable);
overlappableArea = new Area(intersectShape);
boundingBoxOverlappable... |
9fc256c0-6862-4f42-80ad-135c47126144 | 0 | protected void input(String string) {
controller.initialize(string);
} |
fde2b4a5-6a9a-4d5e-97f8-9e00779ba878 | 8 | @Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
{
Player player = null;
if (sender instanceof Player)
{
player = (Player) sender;
}
if(ModGod.debug){ModGod.log.info("onCommand");}
if (cmd.getName().equalsIgnoreCase("... |
c7ead725-3363-4d16-9e82-e3946d18f9e2 | 9 | private boolean interfaceIsSelected(RSInterface rsInterface) {
if (rsInterface.conditionType == null)
return false;
for (int c = 0; c < rsInterface.conditionType.length; c++) {
int opcode = parseInterfaceOpcode(rsInterface, c);
int value = rsInterface.conditionValue[c];
if (rsInterface.conditionType[c] ... |
c28fec1c-9464-4e82-b8f4-a0c51342a53f | 5 | public Object setStateParameterValue(String key, Object value) {
int index = -1;
for (int i = 0; i < parameterKeys.length; i++) {
if (key.equals(parameterKeys[i])) {
index = i;
break; // exit loop
}
}
// Check if card could be found
if (index < 0) {
return null;
} // else return the found ... |
f215abc4-8174-4a05-ba48-6ae37f6afb2a | 4 | public void deregister() throws ClientDeregisterFailureException, ClientDoesNotExistException {
try {
_out.writeInt(8); //Size
_out.writeInt(Response.MSG_CLIENT_DEREGISTER);
_out.writeInt(_clientId);
_out.flush();
int messageType = _in.readInt();
... |
8c38eb27-7381-437b-b3ba-f02c1b3fada9 | 8 | public static int[] getDirection(int x1, int y1, int x2, int y2) {
int[] returnvalue = new int[2];
int UP = calulateUpDistance(x1, y1, x2, y2);
int RIGHT = calulateRightDistance(x1, y1, x2, y2);
int DOWN = calulateDownDistance(x1, y1, x2, y2);
int LEFT = calulateLeftDistance(x1, y1, x2, y2);
int X = Math.... |
dcdd20a7-74d7-4dd5-87fa-cecab31606c2 | 8 | public void fetchAll() throws Exception {
running = true;
lastRequestStart = new AtomicLong(System.currentTimeMillis());
activeThreads = new AtomicInteger(0);
spinWaiting = new AtomicInteger(0);
fetchQueue = new FetchQueue();
configQueue = new ConfigQueue();
Ar... |
3ba79fb2-62ab-4d3c-9617-ed423c854fad | 7 | static public Point[] find2CirclesIntersections(final Point c1, final double r1,
final Point c2, final double r2) {
if (r1 < 0 || r2 < 0)
return null;
Point[] result = null;
if (r1 == 0 || r2 == 0){
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.