method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
a9a9bd8c-1c80-446a-922d-8e340413847d | 1 | public static int raceToId(String race) {
HashMap<String, Integer> races = new HashMap<String, Integer>();
races.put("baden-württemberg", 1);
races.put("bayern", 2);
races.put("berlin", 3);
races.put("brandenburg", 4);
races.put("bremen", 5);
races.put("hamburg", 6);
races.put("hessen", 7);
races.put("mecklenburg-vorpommern", 8);
races.put("niedersachsen", 9);
races.put("nordrhein-westfalen", 10);
races.put("rheinland-pfalz", 11);
races.put("saarland", 12);
races.put("sachsen", 13);
races.put("sachsen-anhalt", 14);
races.put("schleswig-holstein", 15);
races.put("thüringen", 16);
if (races.get(race.toLowerCase()) == null) {
return 0;
} else {
return races.get(race.toLowerCase());
}
} |
1776cd25-fb1b-448f-8a7e-08b85cbb2f79 | 9 | @Override
public String toString() {
if (this.type == NUM) {
return "NUM: " + this.value;
} else if (this.type == CMD) {
return "CMD: " + this.name;
} else if (this.type == UNK) {
return "UNK";
} else if (this.type == EOF) {
return "EOF";
} else if (this.type == NAME) {
return "NAME: " + this.name;
} else if (this.type == CMD) {
return "CMD: " + this.name;
} else if (this.type == STR) {
return "STR: (" + this.name;
} else if (this.type == ARYB) {
return "ARY [";
} else if (this.type == ARYE) {
return "ARY ]";
} else {
return "some kind of brace (" + this.type + ")";
}
} |
2c3356d5-1510-4186-9dca-535c63be2b48 | 9 | static final public ValueExpression value_spec() throws ParseException {
Token tok; TupleExpression tup; VariableExpression var; ActorIdentifier actId;
if (jj_2_12(4)) {
tok = jj_consume_token(TUPLETAG);
tup = new TupleExpression(tok.image);
jj_consume_token(LPAREN);
if (jj_2_11(4)) {
value_spec_list(tup.getElements());
} else {
;
}
jj_consume_token(RPAREN);
{if (true) return tup;}
} else if (jj_2_13(4)) {
tok = jj_consume_token(VARIABLEIDENT);
{if (true) return new VariableExpression(tok.image);}
} else if (jj_2_14(4)) {
tok = jj_consume_token(ACTORIDENT);
{if (true) return new ActorIdentifier(tok.image);}
} else if (jj_2_15(4)) {
tok = jj_consume_token(NUMBER);
{if (true) return ValueExpression.intToTuple(Integer.parseInt(tok.image));}
} else {
jj_consume_token(-1);
throw new ParseException();
}
throw new Error("Missing return statement in function");
} |
add70a49-e5f3-4383-bcc4-938ff46dd48b | 9 | public static Circle reconstructCircle( final String[] elements ) {
if( elements == null ) {
throw new IllegalArgumentException( "The parameter 'elements' must not be 'null'." );
}
final Map< String, Object > attributesP = new HashMap< String, Object >();
final Map< String, Object > attributesR = new HashMap< String, Object >();
IColumnVector< Float > p = null;
float radius = 0f;
final List< Float > digitBuffer = new ArrayList< Float >();
int i = 1;
do {
if( elements[i].equals( "p" ) ) {
++i;
digitBuffer.clear();
while( (Character.isDigit( elements[i].charAt( 0 ) ) || (elements[i].charAt( 0 ) == '-') ) ) {
digitBuffer.add( Float.parseFloat( elements[i++] ) );
}
p = new ColumnVector( digitBuffer );
if( elements[i].equals( "color" ) ) {
++i;
final int r = Integer.parseInt( elements[i++] );
final int g = Integer.parseInt( elements[i++] );
final int b = Integer.parseInt( elements[i++] );
attributesP.put( "color", new Color( r, g, b ) );
}
} else if( elements[i].equals( "r" ) ) {
++i;
radius = Float.parseFloat( elements[ i++ ] );
if( i < elements.length && elements[i].equals( "color" ) ) {
++i;
final int r = Integer.parseInt( elements[i++] );
final int g = Integer.parseInt( elements[i++] );
final int b = Integer.parseInt( elements[i++] );
attributesR.put( "color", new Color( r, g, b ) );
}
}
} while( i < elements.length );
return new Circle( p, attributesP, radius, attributesR );
} |
efb72acc-460c-43b6-9d52-bf33a040530c | 6 | public static int[][] getTiles(int dx, int dy, int width, int blockAdd, int tilesetAdd, int tilesetBankOffset) {
int[] rom = curGb.getROM();
int[][] tmp = new int[24][20];
int add = blockAdd;
for (int y=0;y<5;y++) {
for (int x=0;x<6;x++) {
int block = getBlockVal(tilesetBankOffset, rom, add);
for (int yy=0;yy<4;yy++)
for (int xx=0;xx<4;xx++)
tmp[x*4 + xx][y*4 + yy] = getTileVal(tilesetAdd, rom, 16*block + 4*yy + xx);
add++;
}
add += (width + 6) - 6;
}
int[][] ret = new int[20][18];
for (int y=0;y<18;y++)
for (int x=0;x<20;x++)
ret[x][y] = tmp[x + 2*(dx&1)][y + 2*(dy&1)];
return ret;
} |
aee7f939-4c02-4de6-8aa5-131a574bb09f | 5 | public static void main(String[] args){
HybridTrie hbt = new HybridTrie();
String[] arr = {"abc", "abcd", "abcde", "bcde", "bce", "eofl", "cctv"};
for(int i = 0; i < arr.length; i++){
String s = arr[i];
hbt.put(s, i + 1);
}
Integer result = hbt.get("cctv");
LinkedList<String> resultList = (LinkedList<String>) hbt.keys();
for(int i = 0; i< resultList.size(); i++){
System.out.println(resultList.get(i));
}
System.out.println("--------|||||||||||-------------");
LinkedList<String> resultList2 = (LinkedList<String>) hbt.keysWithPrefix("abc");
for(int i = 0; i< resultList2.size(); i++){
System.out.println(resultList2.get(i));
}
System.out.println("--------MARKER---------");
String res = hbt.longestPrefixOf("abcdef");
System.out.println(res);
System.out.println("---------------SUFFIX TREE DEMO----------");
SuffixTree sft = new SuffixTree();
String data = "abcbcabcdab";
for(int i=0 ; i < data.length(); i++){
String s = data.substring(i);
sft.put(s, i);
}
ArrayList<Integer> resultIndex = sft.get("bc");
for(int i = 0 ; i < resultIndex.size(); i++){
System.out.println(resultIndex.get(i));
}
} |
6a969f9c-4030-41d9-a606-acd2d40ebb58 | 7 | @Override
public void run() {
String s;
while(true) {
if (!csConnection.m_incomingMsgQueue.isEmpty()) {
s = csConnection.m_incomingMsgQueue.remove();
//System.out.println("PIM:" + s);
try {
JSONObject j = new JSONObject(s);
if (j.has("Message")) {
System.out.println(j.get("Message"));
if (j.has("UpdateCharacter")) {
gc.updateCharacterFlag = true;
}
} else if (j.has("PlayerID")) {
//System.out.println("playerId geting set " + j.getString("PlayerID"));
gc.playerID = j.getString("PlayerID");
}
} catch (JSONException e) {
System.err.println("Error in PIM - converting string to JSON");
}
//System.out.println(csConnection.m_initcomingMsgQueue.remove());
}
try {
Thread.sleep(1);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} |
d4c1049d-b0d1-4ab0-9703-07de5ac28486 | 7 | public static void makeCompactGrid(Container parent,
int rows, int cols,
int initialX, int initialY,
int xPad, int yPad) {
SpringLayout layout;
try {
layout = (SpringLayout)parent.getLayout();
} catch (ClassCastException exc) {
System.err.println("The first argument to makeCompactGrid must use SpringLayout.");
return;
}
//Align all cells in each column and make them the same width.
Spring x = Spring.constant(initialX);
for (int c = 0; c < cols; c++) {
Spring width = Spring.constant(0);
for (int r = 0; r < rows; r++) {
width = Spring.max(width,
getConstraintsForCell(r, c, parent, cols).
getWidth());
}
for (int r = 0; r < rows; r++) {
SpringLayout.Constraints constraints =
getConstraintsForCell(r, c, parent, cols);
constraints.setX(x);
constraints.setWidth(width);
}
x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
}
//Align all cells in each row and make them the same height.
Spring y = Spring.constant(initialY);
for (int r = 0; r < rows; r++) {
Spring height = Spring.constant(0);
for (int c = 0; c < cols; c++) {
height = Spring.max(height,
getConstraintsForCell(r, c, parent, cols).
getHeight());
}
for (int c = 0; c < cols; c++) {
SpringLayout.Constraints constraints =
getConstraintsForCell(r, c, parent, cols);
constraints.setY(y);
constraints.setHeight(height);
}
y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
}
//Set the parent's size.
SpringLayout.Constraints pCons = layout.getConstraints(parent);
pCons.setConstraint(SpringLayout.SOUTH, y);
pCons.setConstraint(SpringLayout.EAST, x);
} |
0a4714ee-90c6-496b-80ea-e85b96c9c705 | 8 | public void addSeries(float[] values,
int seriesNumber, Comparable seriesKey) {
invalidateRangeInfo();
int i;
if (values == null) {
throw new IllegalArgumentException("TimeSeriesDataset.addSeries(): "
+ "cannot add null array of values.");
}
if (seriesNumber >= this.valueHistory.length) {
throw new IllegalArgumentException("TimeSeriesDataset.addSeries(): "
+ "cannot add more series than specified in c'tor");
}
if (this.valueHistory[seriesNumber] == null) {
this.valueHistory[seriesNumber]
= new ValueSequence(this.historyCount);
this.seriesCount++;
}
// But if that series array already exists, just overwrite its contents
// Avoid IndexOutOfBoundsException:
int srcLength = values.length;
int copyLength = this.historyCount;
boolean fillNeeded = false;
if (srcLength < this.historyCount) {
fillNeeded = true;
copyLength = srcLength;
}
//{
for (i = 0; i < copyLength; i++) { // deep copy from values[], caller
// can safely discard that array
this.valueHistory[seriesNumber].enterData(i, values[i]);
}
if (fillNeeded) {
for (i = copyLength; i < this.historyCount; i++) {
this.valueHistory[seriesNumber].enterData(i, 0.0f);
}
}
//}
if (seriesKey != null) {
this.seriesKeys[seriesNumber] = seriesKey;
}
fireSeriesChanged();
} |
de7a4d43-0fcc-480f-89af-323cd8103b5d | 8 | public void evalGarbledGate(boolean alice_interpret, boolean bob_interpret) {
int i;
int permuted_index;
byte[] dec_key;
byte[] cipher;
byte perm_dec_key;
// Do something only if gate hasn't been evaluated yet
if (garbled_value == null) {
// Construct permuted_index
for (i = permuted_index = 0; i < n_inputs; i++)
permuted_index |= (in_gates[i].garbled_perm << i);
// Calculate decryption keys
dec_key = genKey(-1, permuted_index);
perm_dec_key = dec_key[PPOS];
// Decrypt
cipher = encrypted_truth_table.get(permuted_index);
garbled_value = MyUtil.decArrays(cipher, dec_key);
garbled_perm = (byte) (encrypted_perm[permuted_index] ^ perm_dec_key);
// Sanity check
if ((garbled_perm != 0) && (garbled_perm != 1)) {
logger.warn("evalGarbledGate: garbled_perm isn't a bit! garbled_perm = " + garbled_perm);
garbled_perm = 0;
value = 0;
return;
}
// Interpret the output only for relevant output gates
if ((alice_interpret && isAliceOutput()) ||
(bob_interpret && isBobOutput())) {
value = interpretCode();
}
}
logger.debug("evalGarbledGate: output value is " + value);
} |
626904c1-f502-4e95-97cb-947a3df33978 | 1 | public int getLevel() {
int level = 0;
if (item != null) {
level = item.getLevel();
}
return level;
} |
9d0abb5b-6cd7-454c-8587-bf41d31ec8b9 | 8 | private void drawLoginScreen(boolean originalLoginScreen) {
setupLoginScreen();
loginBoxLeftBackgroundTile.initDrawingArea();
titleBoxImage.drawImage(0, 0);
int x = 360;
int y = 200;
if (loginScreenState == 0) {
int _y = y / 2 + 80;
fontSmall.drawCentredTextWithPotentialShadow(onDemandFetcher.statusString, x / 2,
_y, 0x75a9a9, true);
_y = y / 2 - 20;
fontBold.drawCentredTextWithPotentialShadow("Welcome to RuneScape", x / 2,
_y, 0xffff00, true);
_y += 30;
int _x = x / 2 - 80;
int __y = y / 2 + 20;
titleButtonImage.drawImage(_x - 73, __y - 20);
fontBold.drawCentredTextWithPotentialShadow("New User", _x, __y + 5,
0xffffff, true);
_x = x / 2 + 80;
titleButtonImage.drawImage(_x - 73, __y - 20);
fontBold.drawCentredTextWithPotentialShadow("Existing User", _x, __y + 5,
0xffffff, true);
}
if (loginScreenState == 2) {
int _y = y / 2 - 40;
if (loginMessage1.length() > 0) {
fontBold.drawCentredTextWithPotentialShadow(loginMessage1, x / 2,
_y - 15, 0xffff00, true);
fontBold.drawCentredTextWithPotentialShadow(loginMessage2, x / 2,
_y, 0xffff00, true);
_y += 30;
} else {
fontBold.drawCentredTextWithPotentialShadow(loginMessage2, x / 2,
_y - 7, 0xffff00, true);
_y += 30;
}
fontBold.drawTextWithPotentialShadow("Username: "
+ enteredUsername
+ ((loginScreenFocus == 0) & (tick % 40 < 20) ? "@yel@|"
: ""), x / 2 - 90, _y, 0xffffff, true);
_y += 15;
fontBold.drawTextWithPotentialShadow(
"Password: "
+ TextClass.asterisksForString(enteredPassword)
+ ((loginScreenFocus == 1) & (tick % 40 < 20) ? "@yel@|"
: ""), x / 2 - 88, _y, 0xffffff, true);
_y += 15;
if (!originalLoginScreen) {
int _x = x / 2 - 80;
int __y = y / 2 + 50;
titleButtonImage.drawImage(_x - 73, __y - 20);
fontBold.drawCentredTextWithPotentialShadow("Login", _x, __y + 5,
0xffffff, true);
_x = x / 2 + 80;
titleButtonImage.drawImage(_x - 73, __y - 20);
fontBold.drawCentredTextWithPotentialShadow("Cancel", _x, __y + 5,
0xffffff, true);
}
}
if (loginScreenState == 3) {
fontBold.drawCentredTextWithPotentialShadow("Create a free account", x / 2,
y / 2 - 60, 0xffff00, true);
int _y = y / 2 - 35;
fontBold.drawCentredTextWithPotentialShadow("To create a new account you need to", x / 2,
_y, 0xffffff, true);
_y += 15;
fontBold.drawCentredTextWithPotentialShadow("go back to the main RuneScape webpage", x / 2,
_y, 0xffffff, true);
_y += 15;
fontBold.drawCentredTextWithPotentialShadow("and choose the red 'create account'", x / 2,
_y, 0xffffff, true);
_y += 15;
fontBold.drawCentredTextWithPotentialShadow("button at the top right of that page.", x / 2,
_y, 0xffffff, true);
_y += 15;
int _x = x / 2;
int __y = y / 2 + 50;
titleButtonImage.drawImage(_x - 73, __y - 20);
fontBold.drawCentredTextWithPotentialShadow("Cancel", _x, __y + 5, 0xffffff,
true);
}
loginBoxLeftBackgroundTile.drawGraphics(171, super.gameGraphics, 202);
if (welcomeScreenRaised) {
welcomeScreenRaised = false;
topLeft1BackgroundTile.drawGraphics(0, super.gameGraphics, 128);
bottomLeft1BackgroundTile
.drawGraphics(371, super.gameGraphics, 202);
bottomLeft0BackgroundTile.drawGraphics(265, super.gameGraphics, 0);
aRSImageProducer_1113.drawGraphics(265, super.gameGraphics, 562);
middleLeft1BackgroundTile
.drawGraphics(171, super.gameGraphics, 128);
aRSImageProducer_1115.drawGraphics(171, super.gameGraphics, 562);
}
} |
980b7a6a-7eb4-4d45-a4f0-b169e496001b | 8 | public static WidgetChild getCompass() {
final Record record = get();
update(record);
if (record.index_widget == -1) {
return null;
}
final Widget widget = Widgets.get(record.index_widget);
if (widget != null) {
if (record.index_compass == -1) {
for (final WidgetChild widgetChild : widget.getChildren()) {
final String[] actions = widgetChild.getActions();
if (actions != null && actions.length == 1 && actions[0].equalsIgnoreCase("Face North")) {
record.index_compass = widgetChild.getIndex();
break;
}
}
}
if (record.index_compass != -1) {
return Widgets.get(record.index_widget, record.index_compass);
}
}
return null;
} |
1b57b39b-5682-4144-933a-79e1352ecd49 | 8 | public void run(String arg) {
ImagePlus image = IJ.getImage();
int currentChannel = image.getChannel();
int currentSlice = image.getSlice();
int currentFrame = image.getFrame();
ImageStack stack = image.getStack();
HashMap<Integer, Integer> histogram = new HashMap<Integer, Integer>();
int totalPixels = 0;
// Count how many pixels there are of each intensity
for (int sx = 1; sx <= image.getNSlices(); ++sx) {
// IJ.log("Processing slice number " + sx);
int stackIx = image.getStackIndex(currentChannel, sx, currentFrame);
ImageProcessor ip = stack.getProcessor(stackIx);
for (int x = 0; x < ip.getWidth(); ++x) {
for (int y = 0; y < ip.getHeight(); ++y) {
int val = ip.getPixel(x, y);
totalPixels++;
if (histogram.containsKey(val)) {
histogram.put(val, histogram.get(val) + 1);
} else {
histogram.put(val, 1);
}
}
}
IJ.showProgress(sx, image.getNSlices());
}
// Convert counts to probabilities and compute Shannon entropy
double totalProbability = 0.0;
double entropy = 0.0;
int minIntensity = 1000000;
int maxIntensity = -1;
Integer modeIntensity = null;
int modeCount = -1;
for (Integer intensity : histogram.keySet()) {
int count = histogram.get(intensity);
// While we're here, store the mode statistic too
if (count > modeCount) {
modeCount = count;
modeIntensity = intensity;
}
// And min and max
if (minIntensity > intensity) {
minIntensity = intensity;
}
if (maxIntensity < intensity) {
maxIntensity = intensity;
}
double p = (double)count / (double)totalPixels;
totalProbability += p;
entropy -= p * Math.log(p) / Math.log(2.0); // bits
}
DecimalFormat entFmt = new DecimalFormat("0.00");
DecimalFormat countFmt = new DecimalFormat("#,###,###,###,##0");
String msg = "Shannon entropy = " + entFmt.format(entropy) + " bits per pixel";
msg += "\nNumber of slices = " + image.getNSlices();
msg += "\nNumber of voxels = " + countFmt.format(totalPixels);
msg += "\nMost common intensity (mode) = " + modeIntensity + " (" + countFmt.format(modeCount) + " times)";
msg += "\nMaximum intensity = " + maxIntensity;
msg += "\nMinimum intensity = " + minIntensity;
IJ.showMessage("Shannon Entropy", msg);
} |
df49043b-4b93-48fc-8e06-3631c84a383e | 8 | private boolean r_postlude() {
int among_var;
int v_1;
// repeat, line 56
replab0: while(true)
{
v_1 = cursor;
lab1: do {
// (, line 56
// [, line 58
bra = cursor;
// substring, line 58
among_var = find_among(a_0, 3);
if (among_var == 0)
{
break lab1;
}
// ], line 58
ket = cursor;
switch(among_var) {
case 0:
break lab1;
case 1:
// (, line 59
// <-, line 59
slice_from("i");
break;
case 2:
// (, line 60
// <-, line 60
slice_from("u");
break;
case 3:
// (, line 61
// next, line 61
if (cursor >= limit)
{
break lab1;
}
cursor++;
break;
}
continue replab0;
} while (false);
cursor = v_1;
break replab0;
}
return true;
} |
74d99c69-9b80-4ea6-a763-d20243895567 | 2 | private void moveUp() {
int[] rows = table.getSelectedRows();
DefaultTableModel model = (DefaultTableModel) table.getModel();
try {
if (model.getRowCount() >= 2) {
model.moveRow(rows[0], rows[rows.length - 1], rows[0] - 1);
table.setRowSelectionInterval(rows[0] - 1,
rows[rows.length - 1] - 1);
}
} catch (Exception ArrayIndexOutOfBoundsException) {
}
} |
f4c7051a-cb92-4037-9a84-03c80e8880ed | 0 | public Long getId() {
return id;
} |
2c2fb9d6-8dfc-4dc3-9da8-7fd496793c2a | 5 | private void initGui()
{
this.setPreferredSize(new Dimension(640, 480));
this.setSize(new Dimension(640, 480));
this.setResizable(false);
this.setBackground(Color.WHITE);
this.setLayout(new BorderLayout());
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
chatWindow = new JPanel();
chatWindow.setLayout(new BorderLayout());
chatPane = new JTextPane();
chatPane.setEditable(false);
StyleContext sc = StyleContext.getDefaultStyleContext();
AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, Color.BLACK);
aset = sc.addAttribute(aset, StyleConstants.FontFamily, "Lucida Console");
aset = sc.addAttribute(aset, StyleConstants.Alignment, StyleConstants.ALIGN_JUSTIFIED);
chatPane.setCharacterAttributes(aset, false);
scrollPane = new JScrollPane(chatPane);
scrollPane.setAutoscrolls(true);
chatWindow.add(scrollPane, BorderLayout.CENTER);
chatField = new JTextField();
chatField.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER)
{
String message = chatField.getText();
//interprets message as command if begins with '/'
if (message.charAt(0) == '/')
{
serverCommand(message);
}
//else prints sends message to all users
else if (!message.equals(""))
{
printMessage("Server", message);
for (int i = 0; i < MAX_USERS; i++) {
if (user[i] != null) {
user[i].chatQueue.add(new String("Server: "+message));
}
}
}
//resets chat field
chatField.setText("");
}
}
@Override
public void keyReleased(KeyEvent e) {
}
@Override
public void keyTyped(KeyEvent e) {
}
});
chatWindow.add(chatField, BorderLayout.SOUTH);
this.add(chatWindow, BorderLayout.CENTER);
this.setVisible(true);
} |
6d37603e-3743-4148-a7d8-716b821d5d9a | 1 | public Match getCurrentMatch(int userID){
if(alstNewMatchRequests.contains(userID)){
return this.upcomingMatches.peek();
}
return this.runningMatch;
} |
a0cdbd67-adb2-4000-9c76-efefded44227 | 4 | private void p_searchPage(){
p_searchPane = new JPanel();
p_searchPane.setBackground(SystemColor.activeCaption);
p_searchPane.setLayout(null);
JLabel lbl_searchPatient = new JLabel("Search Patient");
lbl_searchPatient.setFont(new Font("Arial", Font.BOLD, 30));
lbl_searchPatient.setBounds(376, 20, 221, 41);
p_searchPane.add(lbl_searchPatient);
JLabel lbl_HKID = new JLabel("HKID:");
lbl_HKID.setFont(new Font("Arial", Font.PLAIN, 25));
lbl_HKID.setBounds(343, 253, 80, 41);
p_searchPane.add(lbl_HKID);
JButton B_clear = new JButton("Clear");
B_clear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
SPT_HKID.setValue(null);
}
});
B_clear.setFont(new Font("Arial", Font.PLAIN, 25));
B_clear.setBounds(416, 366, 142, 70);
p_searchPane.add(B_clear);
JButton B_search = new JButton("Search");
B_search.setBackground(new Color(245, 222, 179));
B_search.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int index = Patient.patientSearch(db, (String) SPT_HKID.getValue());
if (index > -1){
patient = db.getPatient(index);
if (patient.getAge()>50)
elderly = true;
else
elderly = false;
SPT_HKID.setValue(null);
PB_save.setEnabled(false);
PB_update.setEnabled(true);
cardLayout.show(contentPane, "Patient");
try {
patientPage();
} catch (ParseException e1) {
e1.printStackTrace();
}
} else if (index == -1){
JOptionPane.showMessageDialog(null, "Patient cannot be found.","Search", JOptionPane.ERROR_MESSAGE);
}
}
});
B_search.setFont(new Font("Arial", Font.PLAIN, 25));
B_search.setBounds(230, 366, 142, 70);
p_searchPane.add(B_search);
JButton B_menu = new JButton("Menu");
B_menu.setBackground(new Color(255, 192, 203));
B_menu.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SPT_HKID.setValue(null);
cardLayout.show(contentPane, "Menu");
}
});
B_menu.setFont(new Font("Arial", Font.PLAIN, 25));
B_menu.setBounds(602, 366, 142, 70);
p_searchPane.add(B_menu);
} |
2ce04791-d511-403e-9886-f239457be63c | 0 | public temp (String text)
{
this.text = text;
} |
12433c32-6b74-4f67-84b4-16f6deb6f9aa | 5 | public GraphicInterface(final TaskManager tManager) {
super("Running Task Program");
setBounds(500,100,570,520);
setLayout(null);
this.tManager = tManager;
name = "gg";
laTitle.setBounds(120,10,100,15);
add(laTitle);
laActiveTasks.setBounds(400,10,100,15);
add(laActiveTasks);
tTasks.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
tActiveTasks.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
spTasks.setBounds(15,35,280,250);
spTasks.setVisible(true);
spTasks.setAutoscrolls(true);
add(spTasks);
spActiveTasks.setBounds(310,35,230,250);
spActiveTasks.setVisible(true);
spActiveTasks.setAutoscrolls(true);
add(spActiveTasks);
tableModel.setColumnIdentifiers(new Object[] {"Name",
"Delay",
"Time",
"Number Of Starts"});
tableModel2.setColumnIdentifiers(new Object[] {"Name",
"Start Time"});
tTasks.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
tTasks.getColumnModel().getColumn(0).setPreferredWidth(65);
tTasks.getColumnModel().getColumn(1).setPreferredWidth(45);
tTasks.getColumnModel().getColumn(2).setPreferredWidth(40);
tTasks.getColumnModel().getColumn(3).setPreferredWidth(130);
btStart.setBounds(100,295,95,25);
add(btStart);
btStop.setBounds(320,295,95,25);
add(btStop);
btUpdate.setBounds(420,295,110,25);
add(btUpdate);
laAddTask.setBounds(120,330,110,15);
add(laAddTask);
laTaskName.setBounds(15,360,100,15);
add(laTaskName);
tfTaskName.setBounds(125,355,120,25);
tfTaskName.setFont(new Font("Courier", 0, 12));
add(tfTaskName);
laTaskDelay.setBounds(15,390,100,15);
add(laTaskDelay);
tfTaskDelay.setBounds(125,385,120,25);
tfTaskDelay.setFont(new Font("Courier", 0, 12));
add(tfTaskDelay);
laTaskTime.setBounds(15,420,100,15);
add(laTaskTime);
tfTaskTime.setBounds(125,415,120,25);
tfTaskTime.setFont(new Font("Courier", 0, 12));
add(tfTaskTime);
laTaskNumber.setBounds(15,450,100, 15);
add(laTaskNumber);
tfTaskNumber.setBounds(125,445,120,25);
tfTaskNumber.setFont(new Font("Courier", 0, 12));
add(tfTaskNumber);
btAdd.setBounds(260,385,95,25);
add(btAdd);
btClear.setBounds(260,415,95,25);
add(btClear);
btClear.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent ae) {
tfTaskName.setText("");
tfTaskDelay.setText("");
tfTaskNumber.setText("");
tfTaskTime.setText("");
}
});
btStart.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent ae) {
tManager.startTask();
}
});
btAdd.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent ae) {
if (!tfTaskName.getText().isEmpty() && !tfTaskTime.getText().isEmpty() && !tfTaskDelay.getText().isEmpty() && !tfTaskNumber.getText().isEmpty() ) {
try {
tManager.addTask(tfTaskName.getText(), Integer.parseInt(tfTaskDelay.getText()), Integer.parseInt(tfTaskTime.getText()), Integer.parseInt(tfTaskNumber.getText()));
} catch (NumberFormatException e) {
logger.error("", e);
}
}
}
});
btStop.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent ae) {
tManager.stopTask();
}
});
btUpdate.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent ae) {
tManager.updateActiveTable();
}
});
} |
bf7e6ebe-1e41-4718-b454-3195810c393f | 9 | protected Collection getCells(Collection cells, boolean edges,
boolean ordered) {
Set result = null;
if (ordered && order != null) {
result = new TreeSet(order);
} else {
result = new LinkedHashSet();
}
Iterator it = cells.iterator();
while (it.hasNext()) {
Object cell = it.next();
if ((edges && isEdge(cell)) && (getSource(cell) != null)
&& (getTarget(cell) != null))
result.add(cell);
if (!edges && isVertex(cell)) {
result.add(cell);
}
}
return result;
} |
37181d7d-34ae-47ed-9143-74df1e4a3e1a | 6 | public int firstMissingPositive(int[] A) {
if (A.length == 0)
return 1;
boolean[] f = new boolean[A.length+1];
for (int i=0;i<=A.length; i++) f[i] = false;
for (int i = 0 ;i< A.length ;i++)
{
if (A[i] > 0 && A[i] <= A.length + 1)
{
f[A[i] -1] =true;
}
}
int j = 0;
while ( f[j] )
{
j++;
}
return j + 1 ;
} |
ee8e1d34-4921-41d1-adc4-7f13d3265621 | 4 | public void turnLeft() {
if(speedX > 0) {
this.speedX = 0;
this.speedY = speedOfSnake;
} else if(speedX < 0){
this.speedX = 0;
this.speedY = -speedOfSnake;
} else if(speedY > 0) {
this.speedY = 0;
this.speedX = -speedOfSnake;
} else if(speedY < 0) {
this.speedY = 0;
this.speedX = speedOfSnake;
}
} |
d6cab760-37d3-4efd-815b-c5893c3f493d | 7 | private int checkCross(GameBoardMark playerMark) {
int k, l, x;
for (k = 1; k < 7; k++) {
for (l = 1; l < 7; l++) {
x = k + 10 * l;
if (gameBoard.mainBoard()[x] == playerMark.index && gameBoard.mainBoard()[x + 2] == playerMark.index && gameBoard.mainBoard()[x + 20] == playerMark.index && gameBoard.mainBoard()[x + 22] == playerMark.index && gameBoard.mainBoard()[x + 11] == 0) return (x + 11);
}
}
return GameBoard.oneMoreThanLastPositionOnBoard;
} |
312a9097-baf5-4fa3-85a0-4e836167df59 | 8 | private void OkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OkButtonActionPerformed
String user = UsernameText.getText();
String pass = new String(PasswordText.getPassword());
if (!user.equals("") && !pass.equals("")) {
String q = "select contrasenna from usuario where nombre_usuario = '" + user + "';";
try {
ResultSet ejecutarConsulta = connection.ejecutarConsulta(q);
if (ejecutarConsulta.next()) {
if (ejecutarConsulta.getString(1).equals(pass)) {
this.correct = true;
this.username = user;
java.io.File userfile = new File("user");
if (checkRememberUsername.isSelected()) {
java.io.FileWriter fw = new FileWriter(userfile);
fw.write(user);
fw.close();
java.io.File passfile = new File("pass");
if (checkRememberPassword.isEnabled()) {
fw = new FileWriter(passfile);
fw.write(pass);
fw.close();
} else {
passfile.delete();
}
} else {
userfile.delete();
}
this.setVisible(false);
this.dispose();
} else {
ShowError("Contraseña incorrecta");
}
} else {
ShowError("El usuario no existe");
}
} catch (SQLException sqlEX) {
ShowError("Imposible establecer la conexión con la base de datos");
System.out.println(q);
} catch (IOException ioex) {
}
} else {
ShowError("El nombre de usuario o contraseña está vacío");
}
}//GEN-LAST:event_OkButtonActionPerformed |
80027fbb-ded2-4dc2-a62a-bb075e22224b | 1 | public void doGet(HttpServletRequest req,
HttpServletResponse res)
throws IOException, ServletException {
//first goal is to be able to receive and process
//a well formatted XML moveTwo piggybacked on a POST
//this gives me a raw stream to payload of Post request
Scanner in = new Scanner(req.getInputStream());
StringBuffer input = new StringBuffer();
//peel off XML message a line at a time
while (in.hasNext())
input.append(in.next());
//convert to String for convenience
String inputAsString = input.toString();
//parse the XML and marshal the java Move_Two object
Move_Two moveTwo = processInput(inputAsString);
//now create the response
PrintWriter out = res.getWriter();
//at this pont we want to return an XML document
//that represents the moveTwo "response" to one or both
//clients
/*
<moveResponse>
<status>confimed</status>
<mover> player ID here </mover>
<loc> loc value here </loc>
</moveResponse>
*/
//A good first test is to just veryify that you can
//successfully send back any XML string. From there
//building up simple response is trivial and can be
//done at the level of String building or, if you prefer,
//DOM objects converted to Strings
//test xml just to show that we can do it.
//no significance to this moveTwo definition. just mechanics.
out.println("<moveTwo> <location> " + moveTwo.getLocation() +
"</location> </moveTwo>");
out.flush();
out.close();
} |
c0893b5f-6b9d-4d84-baa7-9dea22d49e5b | 3 | public void flush()
{
BufferedWriter saveWriter = null;
try
{
saveWriter = new BufferedWriter(new FileWriter(saveFile));
saveWriter.write("# Automatically generated file; DO NOT EDIT\n");
saveWriter.write("#Contacts\n");
for(Contact contact : contactList)
{
saveWriter.write(((ContactImpl)contact).toCSV() + "\n");
}
saveWriter.write("#\n");
saveWriter.write("#Meetings\n");
for(Meeting meeting : meetingList)
{
saveWriter.write(((MeetingImpl)meeting).toCSV() + "\n");
}
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
finally
{
closeWriter(saveWriter);
}
} |
a4798f43-7a75-4509-8787-e7cfcf707209 | 1 | public JSONObject getJSONObject(int index) throws JSONException {
Object object = get(index);
if (object instanceof JSONObject) {
return (JSONObject)object;
}
throw new JSONException("JSONArray[" + index +
"] is not a JSONObject.");
} |
9f6c2cd8-e27b-4d2a-9002-08b6ff794857 | 1 | public static void msg(String msg, boolean debugging_on)
{
if(debugging_on)
System.err.println("DEBUG ("+System.currentTimeMillis()+"): "+msg);
} |
417cb90c-5b74-462f-af85-52ea7b338112 | 4 | private boolean checkFieldColumnWinn(int columnNumber, char cellValue){
boolean checkColumn = true;
for (int i = 0; i <= fieldSize - WIN_NUMBER_OF_CELLS ; i++){
checkColumn = true;
for(int j = i; j < i + WIN_NUMBER_OF_CELLS; j++){
if( field[columnNumber][j] != cellValue) checkColumn = false;
}
if(checkColumn){
return true;
}
}
return false;
} |
e94eaf5f-e4d8-46a6-8f5e-8a6ebd7d1cb9 | 6 | public static void main(String[] args){
int[] p = new int[(int)1e6];
for(int i=2;i<1e6;i++) p[i]=1;
sieve(p);
int count=0;
for(int i=2;i<1e6;i++){
if (p[i]==1){
List<Integer> rotations = rotate(i);
boolean circular = true;
for(Integer k:rotations){
if(p[k] == 0) circular = false;
}
if (circular == true) count++;
}
}
System.out.println(count);
} |
e18610f4-6464-4f03-822b-45f8525bacda | 9 | private void cftbsub(int n, float[] a, int offa, int[] ip, int nw, float[] w) {
if (n > 8) {
if (n > 32) {
cftb1st(n, a, offa, w, nw - (n >> 2));
if ((ConcurrencyUtils.getNumberOfThreads() > 1) && (n > ConcurrencyUtils.getThreadsBeginN_1D_FFT_2Threads())) {
cftrec4_th(n, a, offa, nw, w);
} else if (n > 512) {
cftrec4(n, a, offa, nw, w);
} else if (n > 128) {
cftleaf(n, 1, a, offa, nw, w);
} else {
cftfx41(n, a, offa, nw, w);
}
bitrv2conj(n, ip, a, offa);
} else if (n == 32) {
cftf161(a, offa, w, nw - 8);
bitrv216neg(a, offa);
} else {
cftf081(a, offa, w, 0);
bitrv208neg(a, offa);
}
} else if (n == 8) {
cftb040(a, offa);
} else if (n == 4) {
cftxb020(a, offa);
}
} |
cf073d05-b50a-48ec-9fbe-f449bf9b1f4e | 1 | public void resetSyntax() {
for (int i = ctype.length; --i >= 0;)
ctype[i] = 0;
} |
9e41da5e-84cc-4abe-8f0c-86517f5faa5e | 1 | public boolean is(Object key) {
Boolean b = get(key);
if (b == null) {
return false;
}
return b;
} |
9ea82f39-bfe3-4d66-b2ce-7a8b237883ab | 2 | @Override
public double escapeTime(Complex point, Complex seed) {
// Keep iterating until either n is reached or divergence is found
int i = 0;
while (point.modulusSquared() < escapeSquared && i < iterations) {
// Z(i+1) = (Z(i) * Z(i)) + c
point = point.square().add(seed);
i++;
}
return normalise(point, i);
} |
3ffab664-0d3e-4551-8464-880142c2c6e4 | 1 | private void deepLearn(){
DL_layers++;
//Add another layer
if (DL_layers < DL_maxlayers){
int dl = drawNet.layers.get(1).length - DL_layers*DL_drawdelta,
pl = playNet.layers.get(1).length - DL_layers*DL_playdelta;
//if (Game.verbose)
System.out.println("Casandra: Adding DEEP LEARNING layer #"+DL_layers+" ("+dl+", "+pl+" nodes)");
drawNet.addHiddenLayer(dl);
playNet.addHiddenLayer(pl);
drawNet.freeze(DL_layers);
playNet.freeze(DL_layers);
}
//Unfreeze all layers (refinement stage)
else{
drawNet.freeze(0);
playNet.freeze(0);
//if (Game.verbose)
System.out.println("Casandra: Beginning DEEP LEARNING refinement stage");
}
} |
4e87006f-a73b-49eb-abb5-c86cd0e8304d | 7 | private Giocatore[] getBestAtt(Formazione f){
Giocatore[] att=new Giocatore[3];
Giocatore[] squad=f.getGiocatori();
Giocatore tmp=squad[0];
int st=0, nd=0, temp=0;
for(int j=0;j<3;j++){
for(int i=1;i<11;i++){
if(squad[i].getAttacco()>=tmp.getAttacco() && (i!=st || i!=nd) ){
tmp=squad[i];
temp=i;
}
}
att[j]=tmp;
switch(j){
case 0: st=temp;break;
case 1: nd=temp;break;
}
}
return att;
} |
0d883f80-781d-485e-9e69-230267c15998 | 7 | @Override
public void mouseReleased(MouseEvent me) {
if (me.getSource() instanceof JMenuItem) {
JMenuItem menuItem = (JMenuItem) me.getSource();
if (menuItem.getActionCommand().compareTo("FILE->INSERT") == 0) {
StudentsInformation.StudentsName(stdname.getText());
StudentsInformation.StudentsSurname(stdsur.getText());
StudentsInformation.StudentsAEM(stdaem.getText());
StudentsInformation.Subject(subject.getText());
StudentsInformation.Grades(grade.getText());
try {
SaveToFile.WriteFile(stdname.getText(), stdsur.getText(), stdaem.getText(), subject.getText(), grade.getText());
} catch (FileNotFoundException ex) {
Logger.getLogger(MouseInputStudents.class.getName()).log(Level.SEVERE, null, ex);
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(MouseInputStudents.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(MouseInputStudents.class.getName()).log(Level.SEVERE, null, ex);
}
ClearFields.Clearing(stdname, stdsur, stdaem, subject, grade);
} else if (menuItem.getActionCommand().compareTo("FILE->LOGOUT") == 0) {
System.exit(0);
} else if (menuItem.getActionCommand().compareTo("HELP->ABOUT") == 0) {
JOptionPane.showMessageDialog(null, "This project is created with the teamwork of Kostas Korosidis,Thomas Liakos,Giwrgos,Dimitris Bakalis.\n IT's created with NetBeans IDE and the use of Git Hub.", "About Window", JOptionPane.INFORMATION_MESSAGE);
}
}
} |
63808824-65eb-409f-bd5b-5477f13deec6 | 5 | public static void mergePropertiesIntoMap(Properties props,
Map<String, Object> map) {
if (map == null) {
throw new IllegalArgumentException("Map must not be null");
}
if (props != null) {
for (Enumeration<?> en = props.propertyNames(); en
.hasMoreElements();) {
String key = (String) en.nextElement();
Object value = props.getProperty(key);
if (value == null) {
// Potentially a non-String value...
value = props.get(key);
}
map.put(key, value);
}
}
} |
e6be7c64-b7ed-4118-8c00-d452b11f4dab | 8 | public static int findMaximumPathSum(){
String linestr;
String[] tokens;
int lines = 0, i = 0;
int j,temp;
try{
BufferedReader br = new BufferedReader(new FileReader("triangle"));
LineNumberReader reader = new LineNumberReader(new BufferedReader(new FileReader("triangle")));
while((reader.readLine()) != null){
lines++;
}
triangle = new int[lines][lines];
while(((linestr = br.readLine())) != null){
tokens = linestr.split(" ");
for(j = 0; j < tokens.length; j++){
temp = Integer.parseInt(tokens[j]);
triangle[i][j] = temp;
}
i++;
}
for(i = lines-1; i > 0; i--){
for(j = 0; j < lines - 1; j++){
triangle[i-1][j] += (triangle[i][j] > triangle[i][j+1]) ? triangle[i][j]: triangle[i][j+1];
}
}
return triangle[0][0];
} catch (FileNotFoundException e){
System.out.println(e);
} catch (IOException e){
System.out.println(e);
}
return 0;
} |
41a8a8fb-c7fb-4961-b404-0941a4d68af6 | 4 | public int read(BitReader bitreader) throws JSONException {
try {
this.width = 0;
Symbol symbol = this.table;
while (symbol.integer == none) {
this.width += 1;
symbol = bitreader.bit() ? symbol.one : symbol.zero;
}
tick(symbol.integer);
if (JSONzip.probe) {
JSONzip.logchar(symbol.integer, this.width);
}
return symbol.integer;
} catch (Throwable e) {
throw new JSONException(e);
}
} |
47dbe88e-e1d6-49c3-85aa-40dea88ba6da | 8 | @Override
@SuppressWarnings({ "nls", "boxing" })
protected void initialize(Class<?> type, Object oldInstance,
Object newInstance, Encoder enc) {
super.initialize(type, oldInstance, newInstance, enc);
if (type != oldInstance.getClass()) {
return;
}
MenuBar bar = (MenuBar) oldInstance;
int count = bar.getMenuCount();
Expression getterExp = null;
for (int i = 0; i < count; i++) {
getterExp = new Expression(bar.getMenu(i), "getLabel", null);
try {
// Calculate the old value of the property
Object oldVal = getterExp.getValue();
// Write the getter expression to the encoder
enc.writeExpression(getterExp);
// Get the target value that exists in the new environment
Object targetVal = enc.get(oldVal);
// Get the current property value in the new environment
Object newVal = null;
try {
newVal = new Expression(((MenuBar) newInstance).getMenu(i),
"getLabel", null).getValue();
} catch (IndexOutOfBoundsException ex) {
// The newInstance has no elements, so current property
// value remains null
}
/*
* Make the target value and current property value equivalent
* in the new environment
*/
if (null == targetVal) {
if (null != newVal) {
// Set to null
Statement setterStm = new Statement(oldInstance, "insert",
new Object[] { null, i });
enc.writeStatement(setterStm);
}
} else {
PersistenceDelegate pd = enc
.getPersistenceDelegate(targetVal.getClass());
if (!pd.mutatesTo(targetVal, newVal)) {
Menu menu = new Menu((String) oldVal);
menu.setName(bar.getMenu(i).getName());
Statement setterStm = new Statement(oldInstance,
"add", new Object[] { menu });
enc.writeStatement(setterStm);
}
}
} catch (Exception ex) {
enc.getExceptionListener().exceptionThrown(ex);
}
}
} |
b3a42f7b-2783-40a4-a219-9f097b067277 | 5 | public void run() {
try {
/*
* A server socket is opened with a connectivity queue of a size specified in int floodProtection. Concurrent login handling under normal
* circumstances should be handled properly, but denial of service attacks via massive parallel program logins should be prevented with this.
*/
m_ServerSocket = new ServerSocket(m_Port, m_FloodProtection);
// log entry
Object[] args = {new Integer(m_Port), new Integer(m_FloodProtection)};
log.info(MessageFormat.format(logmsg, args));
do {
try {
Socket s = m_ServerSocket.accept();
if (m_Available) {
connectionManager.makeConnection(s);
} else {
// just shut down the socket
s.close();
}
} catch (SocketException ex) {
if (m_Stopping) {
// server socket was closed blocked in accept
log.debug("run(): ServerSocket closed by stop()");
} else {
log.error("run()", ex);
}
}
} while (!m_Stopping);
} catch (IOException e) {
log.error("run()", e);
}
log.debug("run(): returning.");
}// run |
32b7d16b-6490-4c01-bb85-17d7051ca85e | 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(Boolean.TRUE)
|| (object instanceof String && ((String) object)
.equalsIgnoreCase("true"))) {
return true;
}
throw new JSONException("JSONObject[" + quote(key)
+ "] is not a Boolean.");
} |
65d52684-88b9-4572-a321-53216d057e26 | 2 | public void writeTo(String outname)
throws IOException {
if(!assembled) {
throw new IllegalStateException("assemble method must be called before writeTo");
}
WordWriter out;
if(outname.equals("-")) {
out = new WordWriter(System.out, littleEndian);
} else {
out = new WordWriter(new FileOutputStream(outname, false), littleEndian);
}
try {
resolvables.writeTo(out);
} finally {
out.close();
}
} |
362f4ce1-a042-4465-a1ea-2ca66a6cb9d0 | 1 | private Combination<Colors> generateCombination(Answer lastAnswer) {
// / to be completed !!!
String combi = "RRRRR";
List<Token<Colors>> colors = new ArrayList<Token<Colors>>();
for (int i = 0; i < combi.length(); i++) {
colors.add(new Token<Colors>(Colors.valueOf(combi.substring(i, i + 1))));
}
return new Combination<Colors>(colors);
} |
f109dd3e-04b6-475a-8052-c58ab54555fa | 4 | @Override
public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
if (!sender.hasPermission("VanishCommand.isVanish")) {
sender.sendMessage(ChatColor.RED + "No permission!");
return true;
}
if (args.length != 1)
return false;
Player p = Bukkit.getPlayer(args[0]);
if (p == null) {
sender.sendMessage(ChatColor.RED + "The player " + ChatColor.GRAY + args[0] + ChatColor.RED + " isn't online!");
return true;
}
sender.sendMessage(ChatColor.AQUA + "The player " + p.getName() + " is " + ChatColor.GRAY + ((this.plugin.isHided(p)) ? "vanish" : "visible") + ChatColor.AQUA + "!");
return true;
} |
20618bf4-f7ed-4379-9095-0bc6f974a542 | 7 | private <T extends NeuralNetwork> ArrayList<T> merge(ArrayList<T> one,ArrayList<T> two){
ArrayList<T> merged=new ArrayList<>();
while(!one.isEmpty()&&!two.isEmpty()){
if(one.get(0).getFitness()>two.get(0).getFitness())
merged.add(one.remove(0));
else if(one.get(0).getFitness()<two.get(0).getFitness())
merged.add(two.remove(0));
else{
double random=(new Random()).nextDouble();
if(random>.5)
merged.add(one.remove(0));
else
merged.add(two.remove(0));
}
}
while(!one.isEmpty())
merged.add(one.remove(0));
while(!two.isEmpty())
merged.add(two.remove(0));
return merged;
} |
eb1d0670-db4f-426f-8113-35173b103e6d | 1 | public static void main(String[] args){
TreeNode root = new TreeNode(1);
TreeNode node1 = new TreeNode(2);
TreeNode node2 = new TreeNode(3);
TreeNode node3 = new TreeNode(4);
root.left = node1;
root.right = node2;
node2.left = node3;
List<List<Integer>> result = new Binary_Tree_Level_Order_Traversal().levelOrder(null);
for(int i = 0 ; i < result.size();i++){
System.out.println(Arrays.toString(result.get(i).toArray()));
}
System.out.println("Hello World!");
} |
5e051ffb-c726-4cf1-b1cd-fcb9a8ab1da7 | 2 | public static void compareFiles(File f1, File f2) throws IOException {
assertEquals(f1.length(), f2.length());
try (BufferedInputStream b1 = new BufferedInputStream(new FileInputStream(f1));
BufferedInputStream b2 = new BufferedInputStream(new FileInputStream(f2))) {
byte[] buf1 = new byte[1024 * 16], buf2 = new byte[1024 * 16];
while (true) {
boolean eof = readFully(b1, buf1);
if (eof) {
break;
}
readFully(b2, buf2);
assertArrayEquals(buf1, buf2);
}
}
} |
a0d6481f-3fff-43c2-9879-c98e783c3724 | 2 | public static void main(String[] args) {
try {
Socket socket = new Socket("localhost", 3300);
new ObjectOutputStream(socket.getOutputStream()).writeObject(new SimpleMessage("pera", "marko", 1));
System.out.println(new ObjectInputStream(socket.getInputStream()).readUTF());
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} |
09ed9d7b-141c-48f9-a4af-7245398c6b24 | 4 | public void destroy(BitacoraId id) throws NonexistentEntityException, RollbackFailureException, Exception {
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
Bitacora bitacora;
try {
bitacora = em.getReference(Bitacora.class, id);
bitacora.getId();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The bitacora with id " + id + " no longer exists.", enfe);
}
em.remove(bitacora);
utx.commit();
} catch (Exception ex) {
try {
utx.rollback();
} catch (Exception re) {
throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
} |
429e0b30-dd9d-452a-808e-bf231d3ebe63 | 3 | public char nextClean() throws JSONException {
for (; ; ) {
char c = next();
if (c == 0 || c > ' ') {
return c;
}
}
} |
54362574-7cec-4ac1-bbe2-398c81ece075 | 6 | @Override
public void paint(Graphics jframeg) {
//super.paint(g);
Graphics g = bi.getGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, 500, 500);
for (int i = 0; i < points.size(); i++) {
GeoRef p = points.get(i);
if (p == selected) {
g.setColor(Color.red);
} else {
g.setColor(Color.black);
}
if (i==0){
g.setColor(Color.blue);
}
int radius = 10;
g.fillArc((int) p.getX() - radius / 2, (int) p.getY() - radius / 2, radius, radius, 0, 360);
}
g.setColor(Color.green);
if (points.size() >= 3) {
algorithm.loadData(points);
algorithm.run();
for (int i = 0; i < algorithm.conjunct.size(); i++) {
GeoRef p = algorithm.conjunct.get(i);
GeoRef q = algorithm.conjunct.get((i + 1) % algorithm.conjunct.size());
if (i == 0) {
g.setColor(Color.blue);
g.drawLine((int) p.getX(), (int) p.getY(), (int) q.getX(), (int) q.getY());
g.setColor(Color.green);
} else {
g.drawLine((int) p.getX(), (int) p.getY(), (int) q.getX(), (int) q.getY());
}
//char[] ar = ("L:"+p.distance(q)).toCharArray();
char[] ar = ("["+p+"]").toCharArray();
g.drawChars(ar,0,ar.length,(int) p.getX(), (int) p.getY());
}
}
jframeg.drawImage(bi, 0, 0, null);
} |
98f6fad1-5105-4808-9f36-0d93d07fcef4 | 5 | protected int getRowofvalue(int a) {
int lngRow = 0;
if(lisCol.get(0).contains(a)) {
lngRow = 0;
}else if(lisCol.get(1).contains(a)) {
lngRow = 1;
} else if(lisCol.get(2).contains(a)) {
lngRow = 2;
} else if(lisCol.get(3).contains(a)) {
lngRow = 3;
} else if(lisCol.get(4).contains(a)) {
lngRow = 4;
}
return lngRow;
} |
9b991423-93aa-4d1d-9a29-4ad814a142b3 | 3 | public void setGraphComponent(mxGraphComponent graphComponent)
{
mxGraphComponent oldValue = this.graphComponent;
if (this.graphComponent != null)
{
this.graphComponent.getGraph().removeListener(repaintHandler);
this.graphComponent.getGraphControl().removeComponentListener(
componentHandler);
this.graphComponent.getHorizontalScrollBar()
.removeAdjustmentListener(adjustmentHandler);
this.graphComponent.getVerticalScrollBar()
.removeAdjustmentListener(adjustmentHandler);
}
this.graphComponent = graphComponent;
if (this.graphComponent != null)
{
this.graphComponent.getGraph().addListener(mxEvent.REPAINT,
repaintHandler);
this.graphComponent.getGraphControl().addComponentListener(
componentHandler);
this.graphComponent.getHorizontalScrollBar().addAdjustmentListener(
adjustmentHandler);
this.graphComponent.getVerticalScrollBar().addAdjustmentListener(
adjustmentHandler);
}
if (updateScaleAndTranslate())
{
repaintBuffer = true;
repaint();
}
firePropertyChange("graphComponent", oldValue, graphComponent);
} |
0e7de618-9274-42b3-bb13-da7caf4dcac0 | 5 | private static void test(Mat src, Mat tpl)
{
//Imshow.show(src);
//Imshow.show(tpl);
// generate log polar images
Mat srcPolar = new Mat(src.rows(), src.cols(), src.type());
Mat tplPolar = new Mat(tpl.rows(), tpl.cols(), tpl.type());
Mat srcCart = new Mat(src.rows(), src.cols(), src.type());
Mat tplCart = new Mat(tpl.rows(), tpl.cols(), tpl.type());
Imgproc.logPolar(src, srcPolar, new Point(src.cols() * .5, src.rows() * .5),
30, Imgproc.INTER_LINEAR + Imgproc.CV_WARP_FILL_OUTLIERS);
Imgproc.logPolar(tpl, tplPolar, new Point(tpl.cols() * .5, tpl.rows() * .5),
30, Imgproc.INTER_LINEAR + Imgproc.CV_WARP_FILL_OUTLIERS);
//Imshow.show(srcPolar);
//Imshow.show(tplPolar);
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
/*
FeatureDetector surf = FeatureDetector.create(FeatureDetector.FAST);
DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.ORB);
DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE);
MatOfKeyPoint keyPointsSource = new MatOfKeyPoint();
MatOfKeyPoint keyPointsTemplate = new MatOfKeyPoint();
Mat descriptorSource = new Mat();
Mat descriptorTemplate = new Mat();
MatOfDMatch matchesSourceTemplate = new MatOfDMatch();
surf.detect(srcPolar, keyPointsSource);
surf.detect(tplPolar, keyPointsTemplate);
extractor.compute(srcPolar, keyPointsSource, descriptorSource);
extractor.compute(tplPolar, keyPointsTemplate, descriptorTemplate);
matcher.match(descriptorSource, descriptorTemplate, matchesSourceTemplate);
// reduce points...
int minDistance = 100;
int maxDistance = 0;
List<DMatch> dMatches = matchesSourceTemplate.toList();
for( int i = 0; i < dMatches.size(); i++)
{
float distance = dMatches.get(i).distance;
if( distance < minDistance )
{
minDistance = (int)distance;
}
if( distance > maxDistance )
{
maxDistance = (int)distance;
}
}
System.out.println("Max distance: " + maxDistance);
System.out.println("Min distance: " + minDistance);
List<DMatch> goodMatchesList = new ArrayList<DMatch>();
double upperBound = 4.5 * minDistance;
for (int i = 0; i < dMatches.size(); i++)
{
if (dMatches.get(i).distance < upperBound)
{
goodMatchesList.add(dMatches.get(i));
}
}
MatOfDMatch goodMatches = new MatOfDMatch();
goodMatches.fromList(goodMatchesList);
Mat output = new Mat();
Features2d.drawMatches(srcPolar, keyPointsSource, tplPolar, keyPointsTemplate, goodMatches, output,
Scalar.all(-1), Scalar.all(-1), new MatOfByte(), Features2d.NOT_DRAW_SINGLE_POINTS);
System.out.println(keyPointsSource.size());
System.out.println(keyPointsTemplate.size());
//System.out.println(goodMatches.dump());
System.out.println(goodMatches.size());
//next step...
//List<Ma> object = new ArrayList<Point>();
//List<Point> scene = new ArrayList<Point>();
/*MatOfPoint2f object = new MatOfPoint2f();
MatOfPoint2f scene = new MatOfPoint2f();
List<KeyPoint> kpsL = keyPointsSource.toList();
List<KeyPoint> kptL = keyPointsTemplate.toList();
for( int i = 0; i < goodMatchesList.size(); i++ )
{
//-- Get the keypoints from the good matches
object.push_back(kpsL.get(goodMatchesList.get(i).queryIdx).pt);
scene.push_back(kptL.get(goodMatchesList.get(i).trainIdx).pt);
}
Mat h = Calib3d.findHomography(object, scene);
/*Features2d.drawKeypoints(source, keyPointsSource, output, Scalar.all(-1),
Features2d.NOT_DRAW_SINGLE_POINTS);*
Imshow.show(output);
*/
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
Imgproc.logPolar(srcPolar, srcCart, new Point(src.cols() * .5, src.rows() * .5),
30, Imgproc.INTER_LINEAR + Imgproc.CV_WARP_INVERSE_MAP);
Imgproc.logPolar(tplPolar, tplCart, new Point(tpl.cols() * .5, tpl.rows() * .5),
30, Imgproc.INTER_LINEAR + Imgproc.CV_WARP_INVERSE_MAP);
//Imshow.show(srcPolar);
//Imshow.show(tplPolar);
//Imshow.show(srcCart);
//Imshow.show(tplCart);
// check for template matching
Mat matchResult = new Mat();
Mat matchResultCart = new Mat();
Imgproc.matchTemplate(srcPolar, tplPolar, matchResult, Imgproc.TM_SQDIFF_NORMED);
//Core.normalize(matchResult, matchResult, 0, 1, Core.NORM_MINMAX, -1, new Mat());
/*
Imgproc.logPolar(matchResult, matchResultCart, new Point(matchResult.cols() * .5, matchResult.rows() * .5),
30, Imgproc.INTER_LINEAR + Imgproc.CV_WARP_INVERSE_MAP);
Core.normalize(matchResultCart, matchResultCart, 0, 255, Core.NORM_MINMAX, -1, new Mat());
Mat matchResultCartShow = new Mat();
matchResultCart.convertTo(matchResultCartShow, src.type());
//Imshow.show(matchResultCartShow);
MinMaxLocResult minMaxLocation = Core.minMaxLoc(matchResultCartShow);
Point location = minMaxLocation.maxLoc;
Imgproc.rectangle(matchResultCartShow, location, new Point(location.x + tpl.cols(),
location.y + tpl.rows()), new Scalar(255, 255, 255));
Imshow.show(matchResultCartShow);
Imgproc.rectangle(src, location, new Point(location.x + tpl.cols(),
location.y + tpl.rows()), new Scalar(255, 255, 255));
Imshow.show(src);*/
//generate binary view
Mat threshold = new Mat();
Mat thresholdShow = new Mat();
// classify and rate the result
MinMaxLocResult minMaxLocation = Core.minMaxLoc(matchResult);
Imgproc.threshold(matchResult, threshold, (minMaxLocation.minVal + minMaxLocation.maxVal) / 2, 255, 0);
threshold.convertTo(thresholdShow, src.type());
//System.out.println(thresholdShow);
//Imshow.show(thresholdShow);
//System.out.printf("%f \n", minMaxLocation.minVal);
System.out.printf("%15.2f \n", minMaxLocation.minVal);
System.out.printf("%15.2f \n", minMaxLocation.maxVal);
System.out.printf("%15.2f \n", (double)(matchResult.rows() * matchResult.cols()));
Point location = minMaxLocation.maxLoc;
//System.out.println(minMaxLocation.maxLoc);
Imgproc.rectangle(thresholdShow, location, new Point(location.x + tpl.cols(),
location.y + tpl.rows()), new Scalar(0, 255, 0));
//Imshow.show(thresholdShow);
Mat cut = new Mat(tpl.rows(), tpl.cols(), thresholdShow.type());
// calculate safe width and height
int width = ((int)location.x + tpl.cols() > thresholdShow.cols() ? thresholdShow.cols() - (int)location.x : tpl.cols());
int height = ((int)location.y + tpl.rows() > thresholdShow.rows() ? thresholdShow.rows() - (int)location.y : tpl.rows());
Rect rect = new Rect((int)location.x, (int)location.y, width, height);
cut = thresholdShow.submat(rect);
//Imshow.show(cut);
int white = 0;
double percentWhite = 100;
for (int i = 0; i < cut.cols(); i++)
{
for (int j = 0; j < cut.rows(); j++)
{
if((int)cut.get(j, i)[0] == 255)
{
white++;
}
}
}
percentWhite = (100.0 / ((double)cut.cols() * (double)cut.rows())) * (double)white;
//System.out.println(percentWhite);
//System.out.println();
} |
f4ada3d8-d4e6-4c9e-b3ff-9e19eb630f8d | 0 | public void addResponseHeader(String name, String value)
{
response.add(name+": "+value+"\n");
} |
83229013-8c01-4fe1-9c9a-51c9b92bf431 | 4 | int divide(int dividend, int divisor) {
long a = Math.abs(( long)dividend);
long b = Math.abs(( long)divisor);
int ans = 0, i = 0;
while (a > b){
i++;
b = b << 1;
}
while (i >= 0){
if (a >= b){
a -= b;
ans += (1 << i);
}
b = b >> 1;
i--;
}
//通过最高位(符号位)亦或来判断最后结果的符号位。^ 亦或 不同为1,相同为0;
return (((dividend >> 31)^(divisor >> 31))==0) ? ans : -ans;
} |
85f941ed-cf83-47bd-8b69-ca860b3f6d0a | 6 | public void init(Map attributes)
throws InvalidKeyException, IllegalStateException {
synchronized(lock) {
if (state != -1) {
throw new IllegalStateException();
}
Integer want = (Integer) attributes.get(STATE);
if (want != null) {
switch (want.intValue()) {
case ENCRYPTION: state = ENCRYPTION; break;
case DECRYPTION: state = DECRYPTION; break;
default: throw new IllegalArgumentException();
}
}
Integer bs = (Integer) attributes.get(MODE_BLOCK_SIZE);
modeBlockSize = (bs == null ? cipherBlockSize : bs.intValue());
byte[] iv = (byte[]) attributes.get(IV);
if (iv != null) {
this.iv = (byte[]) iv.clone();
} else {
this.iv = new byte[modeBlockSize];
}
cipher.init(attributes);
setup();
}
} |
762f7a49-b9ce-41fc-b801-98350873bcb0 | 4 | @Override
public void processPacket(Packet p) {
String username = "";
String message = "";
ChannelBuffer data = p.getData();
int updateFlags = data.readByte();
if ((updateFlags & 0x1) == 0x1) {
int messagesToRead = p.getData().readByte();
for (int i = 0; i < messagesToRead; i++) {
byte usernameLength = data.readByte();
for (int j = 0; j < usernameLength; j++)
username += (char) data.readByte();
int messageLength = data.readInt();
for (int j = 0; j < messageLength; j++)
message += (char) data.readByte();
int type = data.readByte();
Chat.messageReceived(new Message(username, message, type));
}
}
} |
10dcb413-97d3-4d2c-8346-dccc6a76cbed | 3 | void rightRotate(RedBlackNode y)
{
RedBlackNode x = y.left; // set x
y.left = x.right; // turn x's right subtree into y's left subtree
if(x.right != nil)
x.right.parent = y;
x.parent = y.parent; // link y's parent to x
if(y.parent == nil)
root = x;
else if (y == y.parent.left)
y.parent.left = x;
else
y.parent.right = x;
x.right = y; // put y on x's right
y.parent = x;
} |
a9499d1b-0e1b-462f-b02a-9fe00aa55247 | 8 | public static String createHref(String contextPath, String actionPath, String action) {
StringBuffer sb = new StringBuffer();
if (contextPath != null) {
sb.append(contextPath);
}
if (actionPath != null) {
sb.append(actionPath);
if (sb.charAt(sb.length()-1) != '/') {
sb.append('/');
}
}
String[] splitString = null;
if (action != null) {
splitString = action.split("\\.");
}
if (splitString != null && splitString.length > 0) {
sb.append(splitString[0]);
}
if (splitString != null && splitString.length > 1) {
sb.append("/" + splitString[1]);
}
return sb.toString();
} |
1e249a4c-1fe0-4209-990d-ee42d662af14 | 5 | @Test
public void testServerGetQueueTimeoutDisconnectIndividualHashEx() {
LOGGER.log(Level.INFO, "----- STARTING TEST testServerGetQueueTimeoutDisconnectIndividualHashEx -----");
boolean exception_other = false;
String client_hash = "";
try {
server2.setUseMessageQueues(true);
} catch (TimeoutException e) {
exception_other = true;
}
try {
server1.startThread();
} catch (IOException | ServerSocketCloseException | FeatureNotUsedException e) {
exception_other = true;
}
waitListenThreadStart(server1);
try {
client_hash = server2.addSocket("127.0.0.1", port);
} catch (IOException | TimeoutException e) {
exception_other = true;
}
waitSocketThreadAddNotEmpty(server2);
waitSocketThreadState(server2, client_hash, SocketThread.CONFIRMED);
waitMessageQueueAddNotEmpty(server2);
waitMessageQueueState(server2, client_hash, MessageQueue.RUNNING);
try {
server2.getQueueTimeoutDisconnectIndividual("TEST");
} catch (HashNotFoundException e) {
exception = true;
} catch (FeatureNotUsedException | NullException | InvalidArgumentException e) {
exception_other = true;
}
Assert.assertFalse(exception_other, "Caught an unexpected exception");
Assert.assertTrue(exception, "Successfully ran getQueueTimeoutDisconnectIndividual on server, should have received an exception");
LOGGER.log(Level.INFO, "----- TEST testServerGetQueueTimeoutDisconnectIndividualHashEx COMPLETED -----");
} |
2a7fd3b9-9839-40b5-89b4-e54bbd1d0451 | 0 | public T[] getFooArray()
{
return fooArray;
} |
b29495ce-4e6f-4e9d-b016-79b59f7396ca | 0 | public int getBumonCode() {
return bumonCode;
} |
53024ad6-e398-4468-b6f9-c6eb48074d66 | 3 | public void bindThumbnailTexture(Minecraft var1) {
if(this.texturePackThumbnail != null && this.texturePackName < 0) {
this.texturePackName = var1.renderEngine.allocateAndSetupTexture(this.texturePackThumbnail);
}
if(this.texturePackThumbnail != null) {
var1.renderEngine.bindTexture(this.texturePackName);
} else {
GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, var1.renderEngine.getTexture("/assets/gui/unknown_pack.png"));
}
} |
8a3ebf84-bc14-404c-ada2-8bc9680c9f75 | 1 | public boolean insertar(BeanProducto bean) {
boolean estado = false;
try {
PreparedStatement ps = MySQL_Connection.getConection().
prepareStatement(insertar);
ps.setString(1, bean.getNombre());
estado = ps.executeUpdate() != 0;
ps.close();
} catch (SQLException ex) {
System.out.println("productoControl/insertar: "
+ ex.getMessage());
}
return estado;
} |
f57a94d3-b9a3-436c-b040-2678dc5c79c7 | 1 | @Test
public void testPlayGame()
{
Player winPlayer = _underTest.playGame(_player1, _player2);
if (winPlayer != null) // it was no tie
{
assertEquals(1, winPlayer.getNumberOfWins());
// use knowledge about Player to verify behaviour.
}
} |
537ebe70-6621-41e4-8272-56101c15d06c | 5 | public void render(GameContainer gc, Graphics g) throws SlickException {
if (state != STATE.INVISIBLE) {
if (state == STATE.ON || state == STATE.REFRESH) CustomRender(gc, g);
if (state == STATE.FREEZE_NEXT) {
sence.getGraphics().clear();
CustomRender(gc, sence.getGraphics());
state = STATE.FREEZE;
}
if (state == STATE.FREEZE) g.drawImage(sence, 0, 0);
}
} |
58ee65b3-8842-4003-bc2e-209bc15d7339 | 9 | public void update(int wx, int wy, int wz, int r) {
depth = wz;
visible = new boolean[world.width()][world.height()];
for (int x = -r; x < r; x++) {
for (int y = -r; y < r; y++) {
if (x*x + y*y > r*r)
continue;
if (wx + x < 0 || wx + x >= world.width() || wy + y < 0 || wy + y >= world.height())
continue;
for (Point p : new Line(wx, wy, wx+x, wy+y)) {
Tile tile = world.tile(p.x, p.y, wz);
visible[p.x][p.y] = true;
tiles[p.x][p.y][wz] = tile;
if (!tile.isGround()) break;
}
} // for
} // for
} |
dc86cf20-2b36-4883-9689-d3831163884e | 3 | private void getModsPath(){
String OS = System.getProperty("os.name").toLowerCase();
OS = OS.substring(0,3);
if(OS.equals("win")){
modsPath = System.getProperty("user.home")+ "/AppData/Roaming/.minecraft/mods";
}
else if(OS.equals("mac")){
modsPath =System.getProperty("user.home")+"/Library/Application Support/minecraft/mods";
}
else if(OS.equals("lin")){
modsPath = System.getProperty("user.home")+"/.minecraft/mods";
}
else{
System.out.println("UNSUPORTED OS");
//unsuported OS (for now), add more
}
} |
c9283241-df3b-4086-afe4-e381ff4a124c | 7 | public void parseXML() throws FileNotFoundException {
try {
if (file != null) {
DocumentBuilderFactory newDocumentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder newBuilder = newDocumentBuilderFactory.newDocumentBuilder();
Document doc = newBuilder.parse(file);
doc.getDocumentElement().normalize();
NodeList nodeList = doc.getElementsByTagName("loc");
fullPaths = new String[nodeList.getLength()];
for (int i = 0; i < nodeList.getLength(); i++) {
Node newNode = nodeList.item(i);
fullPaths[i] = newNode.getTextContent().toLowerCase();
}
//Initialize ArrayList objects
urls = new ArrayList<>();
for(String fullPath : fullPaths) {
boolean stored = false; // Flag to see if we've matched an extension
// Check for query string in path
if (fullPath.contains("?")) {
fullPath = getBaseURL(fullPath); // Strip off query string
// Check for a duplicate of the base url
stored = isDuplicateURL(fullPath);
}
if (!stored) {
boolean matched = matchPath(urlExtensions, fullPath);
if (!matched) {
urls.add(new URL(fullPath, "other", URLType.Page));
}
}
}
}
} catch (ParserConfigurationException | SAXException | IOException | DOMException e) {
System.out.println(e);
}
Collections.sort(urls);
} |
448864b7-8ec1-4efe-8f64-bafdcaa8644e | 4 | public static JSONObject getJSON(HttpResponse response) throws IOException {
final String json = getString(response);
if (json == null || json.length() == 0) throw new IOException("JSON response is empty");
try {
return new JSONObject(json);
} catch (JSONException e) {
throw new IOException("could not parse JSON document: "+e.getMessage()+" "+
(json.length() > 80 ? (json.substring(0, 79) + "..." ) : json));
}
} |
046becf1-3898-49b8-9846-bc034b623c16 | 1 | public static void printList(ListNode list){
while(list!= null){
System.out.print(list.val+" ");
list = list.next;
}
} |
610130f1-557a-4696-85d5-83b34de204e5 | 9 | public List<Usuario> listarProfessor(Professor professor){
ArrayList<Usuario> listaRetorno = new ArrayList<Usuario>();
if (professor.recuperarSiape().isEmpty()
|| professor.recuperarSiape() == null){
for (Usuario usuario : this.usuarios) {
if(usuario instanceof Professor &&
usuario.recuperarStatus() != Status.DESABILITADO.valor())
listaRetorno.add(usuario);
}
}
else {
for (Usuario usuario : this.usuarios) {
if (usuario instanceof Professor) {
if (professor.recuperarSiape().indexOf(usuario.recuperarSiape()) > -1 &&
usuario.recuperarStatus() != Status.DESABILITADO.valor())
listaRetorno.add(usuario);
}
}
}
return listaRetorno;
} |
b8b1d58b-7c48-4d17-916d-c113a4742b3a | 4 | public static void initializeWeights(){
//input to hidden weights
for(int i = 0; i < inHid.length; i++){
for(int j = 0; j < inHid[i].length; j++){
inHid[i][j] = (Math.random()/10) - 0.5;
}
}
//set the bias to one
// for(int j = 0; j < inHid[0].length -1; j++){
// inHid[numInputs - 1][j] = 1;
// }
//hidden to output weights
for(int i = 0; i < hidOut.length; i++){
for(int j = 0; j < hidOut[i].length; j++){
hidOut[i][j] =(Math.random()*10) - 5;
}
}
} |
1918c8c5-fff1-4b38-8297-b3b893918876 | 9 | private void postPlugin(final boolean isPing) throws IOException {
// The plugin's description file contain all of the plugin data such as
// name, version, author, etc
final PluginDescriptionFile description = plugin.getDescription();
// Construct the post data
final StringBuilder data = new StringBuilder();
data.append(encode("guid")).append('=').append(encode(guid));
encodeDataPair(data, "version", description.getVersion());
encodeDataPair(data, "server", Bukkit.getVersion());
encodeDataPair(data, "players",
Integer.toString(Bukkit.getServer().getOnlinePlayers().length));
encodeDataPair(data, "revision", String.valueOf(REVISION));
// If we're pinging, append it
if (isPing) {
encodeDataPair(data, "ping", "true");
}
// Acquire a lock on the graphs, which lets us make the assumption we
// also lock everything
// inside of the graph (e.g plotters)
synchronized (graphs) {
final Iterator<Graph> iter = graphs.iterator();
while (iter.hasNext()) {
final Graph graph = iter.next();
for (Plotter plotter : graph.getPlotters()) {
// The key name to send to the metrics server
// The format is C-GRAPHNAME-PLOTTERNAME where separator -
// is defined at the top
// Legacy (R4) submitters use the format Custom%s, or
// CustomPLOTTERNAME
final String key = String.format("C%s%s%s%s",
CUSTOM_DATA_SEPARATOR, graph.getName(),
CUSTOM_DATA_SEPARATOR, plotter.getColumnName());
// The value to send, which for the foreseeable future is
// just the string
// value of plotter.getValue()
final String value = Integer.toString(plotter.getValue());
// Add it to the http post data :)
encodeDataPair(data, key, value);
}
}
}
// Create the URL
URL url = new URL(BASE_URL
+ String.format(REPORT_URL, encode(plugin.getDescription()
.getName())));
// Connect to the website
URLConnection connection;
// Mineshafter creates a socks proxy, so we can safely bypass it
// It does not reroute POST requests so we need to go around it
if (isMineshafterPresent()) {
connection = url.openConnection(Proxy.NO_PROXY);
} else {
connection = url.openConnection();
}
connection.setDoOutput(true);
// Write the data
final OutputStreamWriter writer = new OutputStreamWriter(
connection.getOutputStream());
writer.write(data.toString());
writer.flush();
// Now read the response
final BufferedReader reader = new BufferedReader(new InputStreamReader(
connection.getInputStream()));
final String response = reader.readLine();
// close resources
writer.close();
reader.close();
if (response == null || response.startsWith("ERR")) {
throw new IOException(response); // Throw the exception
} else {
// Is this the first update this hour?
if (response.contains("OK This is your first update this hour")) {
synchronized (graphs) {
final Iterator<Graph> iter = graphs.iterator();
while (iter.hasNext()) {
final Graph graph = iter.next();
for (Plotter plotter : graph.getPlotters()) {
plotter.reset();
}
}
}
}
}
} |
2049de0a-38c8-47c8-978a-baaf0f079f93 | 3 | public void atira() {
for (int i = 0; i < 10; i++) {
double angulo = 0.2 * i * Math.PI;
int cos = (int) (Math.cos(angulo));
int sen = (int) (Math.sin(angulo));
int x = pos.x + (int) (10 * cos);
int y = pos.y + (int) (10 * sen);
int sinalx, sinaly;
if (cos != 0) {
sinalx = cos / cos;
}else{
sinalx = 0;
}
if (sen != 0) {
sinaly = sen / sen;
}else{
sinaly = 0;
}
this.municao.add(new Municao(x, y, sinalx,sinaly));
municao.get(i).getTile().setReferencia(new ImageIcon(getClass().getResource("/res/enemyBullet.png")));
}
} |
61746ee2-df15-4f8a-825d-e1f83d1c2968 | 6 | * @param terminalP
* @param frame
* @return Keyword
*/
public static Keyword selectTestResult(boolean successP, boolean terminalP, ControlFrame frame) {
if (successP == ((Boolean)(Logic.$REVERSEPOLARITYp$.get())).booleanValue()) {
ControlFrame.setFrameTruthValue(frame, Logic.FALSE_TRUTH_VALUE);
if ((((QueryIterator)(Logic.$QUERYITERATOR$.get())) != null) &&
(((QueryIterator)(Logic.$QUERYITERATOR$.get())).partialMatchStrategy != null)) {
((QueryIterator)(Logic.$QUERYITERATOR$.get())).partialMatchStrategy.setBasePartialMatchTruth(frame.proposition, Logic.KWD_FAIL);
}
return ((terminalP ? Logic.KWD_TERMINAL_FAILURE : Logic.KWD_FAILURE));
}
else {
ControlFrame.setFrameTruthValue(frame, Logic.TRUE_TRUTH_VALUE);
if ((((QueryIterator)(Logic.$QUERYITERATOR$.get())) != null) &&
(((QueryIterator)(Logic.$QUERYITERATOR$.get())).partialMatchStrategy != null)) {
((QueryIterator)(Logic.$QUERYITERATOR$.get())).partialMatchStrategy.setBasePartialMatchTruth(frame.proposition, Logic.KWD_TRUE);
}
return (Logic.KWD_FINAL_SUCCESS);
}
} |
0cafd873-86e0-4dc4-8e7f-3af25383cd35 | 3 | public void setDead(int number){
if (beings.get(number).isHuman() || beings.get(number).isZombie()) {
turnToDeadMan(number);
} else if (beings.get(number).isDead()){
turnIntoHuman(number);
}
} |
dc3049cb-abc7-44c7-8d93-030102e0f79a | 0 | public String getSearchAuthArg()
{
_read.lock();
try
{
return _searchAuthArg;
}
finally
{
_read.unlock();
}
} |
e3940ac4-e68a-43f4-8279-9d88180de0ad | 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://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(MusteriPencereV.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(MusteriPencereV.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MusteriPencereV.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MusteriPencereV.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MusteriPencereV().setVisible(true);
}
});
} |
85293839-ce03-4046-b0d5-49796d62e9f8 | 9 | public static boolean bringOnScreen(final boolean move, final Entity e) {
final Tile nearLoc = e instanceof Locatable ? getReachable((Locatable) e) : null;
if (e instanceof Locatable && nearLoc == null) {
return false;
}
if (turnTo(e)) {
return true;
} else if (e instanceof Locatable && move) {
final Locatable l = (Locatable) e;
final FastPath fast = new FastPath(l.getLocation());
if (new TimedCondition(10000) {
@Override
public boolean isDone() {
fast.traverse();
return turnTo(e) && !fast.validate();
}
}.waitStop(500) && turnTo(e)) {
return true;
}
}
return false;
} |
2e370543-d01a-4fc1-a282-ade10b43ab8d | 8 | private void resolution() {
if (width == 800 && height == 600) {
} else {
if (width == 1024 && height == 768) {
} else {
if (width == 1152 && height == 864) {
} else {
if (width == 1280 && height == 720) {
yIcon = 630;
yText = 680;
xText_score = 1070;
xIcon_score = 1000;
xText_life = 107;
xTime = 600;
xBar_life = 70;
yBar_life = 610;
}
}
}
}
} |
be69c1f2-df8c-4d15-b18d-ce2bf06f6f98 | 8 | public static void shogwarr_mcu_run()
{
int mcu_command;
if ( shogwarr_mcu_status != (1|2|4|8) ) return;
mcu_command = mcu_ram.READ_WORD(shogwarr_mcu_command_offset);
if (mcu_command==0) return;
if (errorlog!=null) fprintf(errorlog,
"CPU #0 PC %06X : MCU executed command at %04X: %04X\n",
cpu_get_pc(),shogwarr_mcu_command_offset,mcu_command);
switch (mcu_command)
{
case 0x00ff:
{
int param1 = mcu_ram.READ_WORD(shogwarr_mcu_command_offset + 0x0002);
int param2 = mcu_ram.READ_WORD(shogwarr_mcu_command_offset + 0x0004);
int param3 = mcu_ram.READ_WORD(shogwarr_mcu_command_offset + 0x0006);
// int param4 = READ_WORD(&mcu_ram[shogwarr_mcu_command_offset + 0x0008]);
int param5 = mcu_ram.READ_WORD(shogwarr_mcu_command_offset + 0x000a);
// int param6 = READ_WORD(&mcu_ram[shogwarr_mcu_command_offset + 0x000c]);
// int param7 = READ_WORD(&mcu_ram[shogwarr_mcu_command_offset + 0x000e]);
// clear old command (handshake to main cpu)
mcu_ram.WRITE_WORD(shogwarr_mcu_command_offset, 0x0000);
// execute the command:
COMBINE_WORD_MEM(mcu_ram,param1 & (~1),
(param1 & 1)!=0 ?
(0xff000000 | (~readinputport(4)<<0) ) :
(0x00ff0000 | (~readinputport(4)<<8) ) ); // DSW
COMBINE_WORD_MEM(mcu_ram,param2 & (~1),
(param2 & 1)!=0 ?
(0xff000000 | (0xff<<0) ) :
(0x00ff0000 | (0xff<<8) ) ); // ? -1 / anything else
shogwarr_mcu_command_offset = param3; // where next command will be written?
// param 4?
mcu_ram.WRITE_WORD(param5, 0x8ee4); // MCU Rom Checksum
// param 6&7 = address.l
}
break;
case 0x0001:
{
// int param1 = READ_WORD(&mcu_ram[shogwarr_mcu_command_offset + 0x0002]);
int param2 = mcu_ram.READ_WORD(shogwarr_mcu_command_offset + 0x0004);
// clear old command (handshake to main cpu)
mcu_ram.WRITE_WORD(shogwarr_mcu_command_offset, 0x0000);
// execute the command:
// param1 ?
mcu_ram.WRITE_WORD(param2+0x0000, 0x0000 ); // ?
mcu_ram.WRITE_WORD(param2+0x0002, 0x0000 ); // ?
mcu_ram.WRITE_WORD(param2+0x0004, 0x0000 ); // ?
mcu_ram.WRITE_WORD(param2+0x0006, 0x0000 ); // ? addr.l
mcu_ram.WRITE_WORD(param2+0x0008, 0x00e0 ); // 0000e0: 4e73 rte
}
break;
case 0x0002:
{
// int param1 = READ_WORD(&mcu_ram[shogwarr_mcu_command_offset + 0x0002]);
// int param2 = READ_WORD(&mcu_ram[shogwarr_mcu_command_offset + 0x0004]);
// int param3 = READ_WORD(&mcu_ram[shogwarr_mcu_command_offset + 0x0006]);
// int param4 = READ_WORD(&mcu_ram[shogwarr_mcu_command_offset + 0x0008]);
// int param5 = READ_WORD(&mcu_ram[shogwarr_mcu_command_offset + 0x000a]);
// int param6 = READ_WORD(&mcu_ram[shogwarr_mcu_command_offset + 0x000c]);
// int param7 = READ_WORD(&mcu_ram[shogwarr_mcu_command_offset + 0x000e]);
// clear old command (handshake to main cpu)
mcu_ram.WRITE_WORD(shogwarr_mcu_command_offset, 0x0000);
// execute the command:
}
break;
}
} |
c72a096d-577b-48a0-b8e8-f8633f670be1 | 0 | public final String getVersion() {
return version;
} |
b5d59611-2b00-4561-a23e-4dd78794a134 | 9 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
if((mob.getWorshipCharID().length()==0)
||(CMLib.map().getDeity(mob.getWorshipCharID())==null))
{
mob.tell(L("You must worship a god to use this prayer."));
return false;
}
final Deity target=CMLib.map().getDeity(mob.getWorshipCharID());
final Room newRoom=target.location();
if(!super.invoke(mob,commands,givenTarget,auto,asLevel))
return false;
final boolean success=proficiencyCheck(mob,0,auto);
if(success)
{
mobName=target.Name();
final CMMsg msg=CMClass.getMsg(mob,target,this,verbalCastCode(mob,target,auto),auto?"":L("^S<S-NAME> invoke(s) the holy perspective of '@x1'.^?",mobName));
final CMMsg msg2=CMClass.getMsg(mob,target,this,verbalCastCode(mob,target,auto),null);
if((mob.location().okMessage(mob,msg))&&((newRoom==mob.location())||(newRoom.okMessage(mob,msg2))))
{
mob.location().send(mob,msg);
if(newRoom!=mob.location())
newRoom.send(target,msg2);
beneficialAffect(mob,target,asLevel,10);
}
}
else
beneficialVisualFizzle(mob,null,L("<S-NAME> attempt(s) to invoke the holy perspective of @x1, but fail(s).",target.Name()));
// return whether it worked
return success;
} |
834150bc-7932-49eb-aee1-f7911dd4ca10 | 5 | protected void action(){
if(!dead){
if(wallExistsRight()){
if(game.getCurrentLevel().blockAtPixelExists(x+(width)-1,y+(height/4))){
Block bl = game.getCurrentLevel().getBlockAtPixel(x+(width)-1,y+(height/4));
activateDoor(bl);
} else {
Block bl = game.getCurrentLevel().getBlockAtPixel(x+(width)-1,y-(height/4));
activateDoor(bl);
}
} else if(wallExistsLeft()){
if(game.getCurrentLevel().blockAtPixelExists(x+(width)-1,y+(height/4))){
Block bl = game.getCurrentLevel().getBlockAtPixel(x+(width)-1,y+(height/4));
activateDoor(bl);
} else {
Block bl = game.getCurrentLevel().getBlockAtPixel(x-(width),y+(height/4));
activateDoor(bl);
}
}
}
} |
49fc80a5-1b1f-42d7-a108-d29f2af063bb | 5 | @Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof RecordingEntity)) {
return false;
}
RecordingEntity other = (RecordingEntity) object;
if ((this.recordedName == null && other.recordedName != null) || (this.recordedName != null && !this.recordedName.equals(other.recordedName))) {
return false;
}
return true;
} |
0fab1084-f85e-4017-88ae-0493e9897a70 | 0 | public void setUitleenDatum(GregorianCalendar UitleenDatum) {
this.UitleenDatum = UitleenDatum;
} |
c1865341-98be-4808-91cd-9de27ed46e3b | 3 | private int boardValue(Board board) {
//Take the next checker.
Checker curChecker = board.pop();
//Exception case: there is no board!
if (curChecker == null)
return 0;
//Every piece has an initial value of 2 points.
int value = 2;
//Having a king is worth another 3 points.
if (curChecker.getType() == "King")
value += 3;
//Pieces on the sides have a slight advantage, they cannot be jumped, lets give them another point.
//if (curChecker.getX() == 0 || curChecker.getX() == Board.SIZE)
//value++;
//If the piece we've examined up until now is not hours lets negate since it is our opponent's.
if (!isMyColor(curChecker))
value = -value;
//Sum up our value and add the checker to our board.
value += boardValue(board);
board.push(curChecker);
return value;
} |
fe423a8d-8d4d-4498-b437-b273bad0f7f7 | 9 | public File createSSTableFiles(String csvFile, String keyspace, String columnFamily, MutableInt lineCounter, MutableBoolean lastLineRead, BufferedReader reader) throws IOException {
File directory = new File(keyspace+columnFamily);
if (directory.exists()) {
FileUtils.deleteDirectory(directory);
}
directory.mkdir();
// random partitioner is created, u can give the partitioner as u want
IPartitioner partitioner = new Murmur3Partitioner();
List<AbstractType<?>> types = new ArrayList<AbstractType<?>>();
types.add(AsciiType.instance);
types.add(AsciiType.instance);
CompositeType cmpType = CompositeType.getInstance(types);
SSTableSimpleUnsortedWriter usersWriter = new SSTableSimpleUnsortedWriter(
directory, partitioner, keyspace, columnFamily, cmpType, null, 64);
String line;
CsvEntry entry = new CsvEntry(csvFile);
// There is no reason not to use the same timestamp for every column in that example.
long timestamp = System.currentTimeMillis() * 1000;
int currentCounter = 0;
int ttl = daily_ttl;
if(columnFamily.contains("hour"))
ttl = hourly_ttl;
while ((line = reader.readLine()) != null && currentCounter < LINES_IN_BATCH) {
currentCounter++;
if (entry.parse(line, lineCounter.intValue()+currentCounter)) {
usersWriter.newRow(bytes(entry.partner_filter_gb1_gb2));
usersWriter.addExpiringColumn(cmpType.builder().add(ByteBufferUtil.bytes(entry.dt_gb1_gb2)).add(ByteBufferUtil.bytes("dim_gb1")).build(), ByteBufferUtil.bytes(entry.dim_gb1), timestamp, ttl, (timestamp/1000) + ttl * 1000);
usersWriter.addExpiringColumn(cmpType.builder().add(ByteBufferUtil.bytes(entry.dt_gb1_gb2)).add(ByteBufferUtil.bytes("dim_gb2")).build(), ByteBufferUtil.bytes(entry.dim_gb2), timestamp, ttl, (timestamp/1000) + ttl * 1000);
usersWriter.addExpiringColumn(cmpType.builder().add(ByteBufferUtil.bytes(entry.dt_gb1_gb2)).add(ByteBufferUtil.bytes("f")).build(), ByteBufferUtil.bytes(entry.f), timestamp, ttl, (timestamp/1000) + ttl * 1000);
for(int i=1; i < CsvEntry.max_allowed_measures;i++)
{
usersWriter.addExpiringColumn(cmpType.builder().add(ByteBufferUtil.bytes(entry.dt_gb1_gb2)).add(ByteBufferUtil.bytes("m" + i)).build(), ByteBufferUtil.bytes(entry.getMeasures()[i]), timestamp, ttl, (timestamp/1000) + ttl * 1000);
}
}
}
lineCounter.add(currentCounter);
if (reader.readLine()==null) // last line
lastLineRead.setValue(true);
// Don't forget to close!
usersWriter.close();
return directory;
} |
9e98f59b-730a-432b-9556-05504291b695 | 5 | @Override
public void deserialize(Buffer buf) {
super.deserialize(buf);
playerId = buf.readInt();
if (playerId < 0)
throw new RuntimeException("Forbidden value on playerId = " + playerId + ", it doesn't respect the following condition : playerId < 0");
playerName = buf.readString();
level = buf.readShort();
if (level < 0 || level > 200)
throw new RuntimeException("Forbidden value on level = " + level + ", it doesn't respect the following condition : level < 0 || level > 200");
alignmentSide = buf.readByte();
breed = buf.readByte();
if (breed < PlayableBreedEnum.Feca.value() || breed > PlayableBreedEnum.Steamer.value())
throw new RuntimeException("Forbidden value on breed = " + breed + ", it doesn't respect the following condition : breed < PlayableBreedEnum.Feca.value() || breed > PlayableBreedEnum.Steamer.value()");
sex = buf.readBoolean();
guildInfo = new BasicGuildInformations();
guildInfo.deserialize(buf);
moodSmileyId = buf.readByte();
status = ProtocolTypeManager.getInstance().build(buf.readShort());
status.deserialize(buf);
} |
1cf36a8f-a9f8-4d87-97cc-8f3b52a784b8 | 3 | @Override
public void handle(HttpExchange he) throws IOException {
String requestedFile = he.getRequestURI().getPath().substring(1);
File file;
if (requestedFile.equals("")) {
file = new File(contentFolder + "index.html");
contentType = "text/html";
} else if (requestedFile.equals("/")) {
file = new File(contentFolder + "index.html");
contentType = "text/html";
} else {
file = new File(contentFolder + requestedFile);
contentType = getExtension(requestedFile.substring(requestedFile.lastIndexOf(".")));
}
if (!file.exists()) {
response.error(he, 404, response.FILE_NOT_FOUND);
return;
}
byte[] bytesToSend = new byte[(int) file.length()];
try (FileInputStream input = new FileInputStream(file);) {
input.read(bytesToSend, 0, bytesToSend.length);
}
Headers h = he.getResponseHeaders();
h.add("Content-Type", contentType);
h.add("charset", "UTF-8");
response.send(he, 200, bytesToSend);
} |
04d69e1f-8d5b-4822-9ae3-3b36bc92ee16 | 4 | public static Movimientos getInstance(int tipo){
switch(tipo){
case 1: return movimientos1;
case 2: return movimientos2;
case 3: return movimientos3;
case 4: return movimientos4;
}
return null;
} |
f1a7f2e9-9819-49d2-8037-eda3a0256708 | 1 | public int compareTo(StatView o) {
int r = getName().compareTo(o.getName());
if (r == 0) {
r = -stat.getWhen().compareTo(o.stat.getWhen());
}
return r;
} |
bf98828f-820e-461a-8b5d-1650fcd7d04b | 9 | @Override
public double calculateJuliaWithPeriodicity(Complex pixel) {
iterations = 0;
check = 3;
check_counter = 0;
update = 10;
update_counter = 0;
period = new Complex();
Complex tempz2 = new Complex(init_val2.getPixel(pixel));
Complex[] complex = new Complex[3];
complex[0] = new Complex(pixel);//z
complex[1] = new Complex(seed);//c
complex[2] = tempz2;//z2
Complex zold = new Complex();
if(parser.foundS()) {
parser.setSvalue(new Complex(complex[0]));
}
if(parser2.foundS()) {
parser2.setSvalue(new Complex(complex[0]));
}
if(parser.foundP()) {
parser.setPvalue(new Complex());
}
if(parser2.foundP()) {
parser2.setPvalue(new Complex());
}
for(; iterations < max_iterations; iterations++) {
if(bailout_algorithm.escaped(complex[0], zold)) {
Object[] object = {iterations, complex[0], zold};
return out_color_algorithm.getResult(object);
}
zold.assign(complex[0]);
function(complex);
if(parser.foundP()) {
parser.setPvalue(new Complex(zold));
}
if(parser2.foundP()) {
parser2.setPvalue(new Complex(zold));
}
if(periodicityCheck(complex[0])) {
return max_iterations;
}
}
return max_iterations;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.