method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
96059023-bc21-4ec1-987d-55bdf8932ff5 | 3 | public static void createUser(int totalUser, int totalGridlet,
int[] glLength, double[] baudRate, int testNum)
{
try
{
double bandwidth = 0;
double delay = 0.0;
for (int i = 0; i < totalUser; i++)
{
String name = "User_" + i;
if (i % 2 == 0) {
bandwidth = baudRate[0];
delay = 5.0;
}
else {
bandwidth = baudRate[1];
}
// creates a Grid user
createTestCase(name, bandwidth, delay, totalGridlet, glLength,
testNum);
}
}
catch (Exception e) {
// ... ignore
}
} |
83d98953-5f9b-4fc3-b4a3-16bc38c3eea6 | 4 | public void keyPressed(KeyEvent e)
{
int i = targetList.getSelectedIndex();
switch (e.getKeyCode())
{
case KeyEvent.VK_UP:
i = targetList.getSelectedIndex() - 1;
if (i < 0)
{
i = 0;
}
targetList.setSelectedIndex(i);
break;
case KeyEvent.VK_DOWN:
int listSize = targetList.getModel().getSize();
i = targetList.getSelectedIndex() + 1;
if (i >= listSize)
{
i = listSize - 1;
}
targetList.setSelectedIndex(i);
break;
default:
break;
}
} |
07cfe283-0290-49d2-bf91-e9c678b35e8b | 6 | public void removeCourse(Course course)
{
if (DEBUG) log("Find the courseWidget that contains the desired course");
CourseWidget target = null;
for (CourseWidget cw : courseWidgets)
{
if (cw.getCourse() == course)
{
target = cw;
}
}
if (target == null)
{
if (DEBUG) log("Failed to find desired courseWidget");
}
else
{
if (DEBUG) log("Found the desired courseWidget...now just remove it");
courseWidgets.remove(target);
leftContent.remove(target);
}
} |
5336295b-bfa1-4a76-8d54-2ae77c863417 | 0 | public static byte[] sha(byte[] data) throws NoSuchAlgorithmException {
MessageDigest digest = MessageDigest.getInstance(SHA);
digest.update(data);
return digest.digest();
} |
922a599d-a6f5-4024-a105-968120340fc7 | 6 | public static float detectCollision(Collidable a,Collidable b) {
if (a == b)
return -1F;
float velMag1 = Vector.mag(a.getVelocity());
float velMag2 = Vector.mag(b.getVelocity());
float sampleFreq1 = velMag1 / a.getLargestDim();
float sampleFreq2 = velMag2 / b.getLargestDim();
float timeInterval = (sampleFreq1 < sampleFreq2)?1F/sampleFreq2:1F/sampleFreq1;
for (float percent = 0F; percent <= 1F; percent = (percent >= 1F)?(percent + timeInterval):(((percent += timeInterval) > 1F)?1F:percent)) {
if (compare(a,b,percent)) {
return percent;
}
}
return -1F;
} |
663e839f-dbb6-4ad2-bd59-7313de59bf60 | 1 | public static void declare(PrintStream w, Object... comps) {
w.println("// Declarartions");
for (Object c : comps) {
ComponentAccess cp = new ComponentAccess(c);
w.println(" " + c.getClass().getName() + " " + objName(cp) + " = new " + c.getClass().getName() + "();");
}
w.println();
} |
527a4018-1ad3-41b6-b534-d77f6128ceb2 | 6 | int numConnected(Piece p, int x, int y, boolean[][] board){
if(x<0 || x>=board.length || y<0 || y>=board[0].length || !board[x][y])
return 0;
board[x][y] = false;
int[] nums = {
numConnected(p,x+1,y,board),
numConnected(p,x-1,y,board),
numConnected(p,x,y+1,board),
numConnected(p,x,y-1,board),
numConnected(p,x-1,y-1,board),
numConnected(p,x+1,y+1,board),
numConnected(p,x+1,y-1,board),
numConnected(p,x-1,y+1,board)
};
int sum = 1;
for(int i : nums)
sum+=i;
return sum;
} |
d05fcf18-bd4c-4c47-937a-2c552a0dc7fa | 9 | public boolean isCollideingWithBlock(Point pt1, Point pt2) {
for (int x = (int) (this.x / Tile.tileSize); x < (int) (this.x / Tile.tileSize) + 3; x++) {
for (int y = (int) (this.y / Tile.tileSize); y < (int) (this.y / Tile.tileSize) + 3; y++) {
if (x >= 0 && y >= 0 && x < Component.level.block.length
&& y < Component.level.block[0].length) {
if (Component.level.block[x][y].id != Tile.air) {
if (Component.level.block[x][y].contains(pt1)
|| Component.level.block[x][y].contains(pt2)) {
return true;
}
}
}
}
}
return false;
} |
299f7764-e6ed-4c29-9f05-961a40448348 | 1 | @Override
public void printAnswer(Object answer) {
if (!(answer instanceof Boolean)) return;
System.out.print((Boolean) answer);
} |
1f66ec12-d885-4cd8-90b4-37260eaafe85 | 2 | @Override
public void mouseMoved(MouseEvent e) {
if(!isMouseGrabbed)
return;
Controls.c.setMousePoition((Test3DMain.frame.getX()+Test3DCanvas.WIDTH/2 - e.getPoint().x-3),(Test3DMain.frame.getY()+Test3DCanvas.HEIGHT/2 - e.getPoint().y-25));
//Grabs mouse back to Center of Window
try {
Robot robot = new Robot();
robot.mouseMove(Test3DMain.frame.getX()+Test3DCanvas.WIDTH/2, Test3DMain.frame.getY()+Test3DCanvas.HEIGHT/2);
} catch (AWTException ex) {
ex.printStackTrace();
}
} |
e4d60fdc-7328-4041-92c2-0f774d69e4bc | 0 | public double getDexterity() {
return dexterity;
} |
b7261663-8342-4c78-b404-1ede59eff87d | 5 | final void method3782(Interface11 interface11, int i) {
try {
anInt7640++;
if (anInt7738 >= 3)
throw new RuntimeException();
if (i != 327685)
method3688(-94, -9, -90, -108, 41, -52, 70);
if (anInt7738 >= 0)
anInterface11Array7741[anInt7738].method45((byte) -47);
anInterface11_7745 = anInterface11Array7741[++anInt7738]
= interface11;
anInterface11_7745.method49(-27141);
} catch (RuntimeException runtimeexception) {
throw Class348_Sub17.method2929(runtimeexception,
("qo.HD("
+ (interface11 != null ? "{...}"
: "null")
+ ',' + i + ')'));
}
} |
9215999d-e3eb-4f1b-baa5-1f4267e22f44 | 0 | @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jSplitPane1 = new javax.swing.JSplitPane();
jPanelTitre = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabelPraticien = new javax.swing.JLabel();
jLabelMotifVisite = new javax.swing.JLabel();
jLabelBilan = new javax.swing.JLabel();
jTextFieldDateRapport = new javax.swing.JTextField();
jTextFieldMotifVis = new javax.swing.JTextField();
jButtonPrevious = new javax.swing.JButton();
jButtonNext = new javax.swing.JButton();
jButtonClose = new javax.swing.JButton();
jLabelDateRapport = new javax.swing.JLabel();
jTextFieldNumRapport = new javax.swing.JTextField();
jLabelNumeroRapport = new javax.swing.JLabel();
jComboBoxPracticien = new javax.swing.JComboBox();
jScrollPane1 = new javax.swing.JScrollPane();
jTextAreaBilan = new javax.swing.JTextArea();
jButtonNew = new javax.swing.JButton();
jButtonDetails = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
jTableOffre = new javax.swing.JTable();
jButtonSauvegarder = new javax.swing.JButton();
jLabelOffreEchantillons = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanelTitre.setBorder(new javax.swing.border.MatteBorder(null));
jLabel1.setText("Rapports de Visites");
javax.swing.GroupLayout jPanelTitreLayout = new javax.swing.GroupLayout(jPanelTitre);
jPanelTitre.setLayout(jPanelTitreLayout);
jPanelTitreLayout.setHorizontalGroup(
jPanelTitreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelTitreLayout.createSequentialGroup()
.addGap(208, 208, 208)
.addComponent(jLabel1)
.addContainerGap(230, Short.MAX_VALUE))
);
jPanelTitreLayout.setVerticalGroup(
jPanelTitreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE)
);
jLabelPraticien.setText("Practicien");
jLabelMotifVisite.setText("Motif Visite");
jLabelBilan.setText("Bilan");
jTextFieldDateRapport.setEditable(false);
jTextFieldMotifVis.setEditable(false);
jButtonPrevious.setText("Précédent");
jButtonPrevious.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonPreviousActionPerformed(evt);
}
});
jButtonNext.setText("Suivant");
jButtonNext.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonNextActionPerformed(evt);
}
});
jButtonClose.setText("Fermer");
jButtonClose.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonCloseActionPerformed(evt);
}
});
jLabelDateRapport.setText("Date Rapport");
jTextFieldNumRapport.setEnabled(false);
jLabelNumeroRapport.setText("Numéro Rapport");
jComboBoxPracticien.setEditable(true);
jComboBoxPracticien.setEnabled(false);
jTextAreaBilan.setEditable(false);
jTextAreaBilan.setColumns(20);
jTextAreaBilan.setRows(5);
jScrollPane1.setViewportView(jTextAreaBilan);
jButtonNew.setText("Nouveau");
jButtonNew.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonNewActionPerformed(evt);
}
});
jButtonDetails.setText("Détails");
jButtonDetails.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonDetailsActionPerformed(evt);
}
});
jTableOffre.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Médicament", "Nb. Echantillons"
}
));
jScrollPane2.setViewportView(jTableOffre);
jButtonSauvegarder.setText("Sauvegarder");
jButtonSauvegarder.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonSauvegarderActionPerformed(evt);
}
});
jLabelOffreEchantillons.setText("Offre d'échantillons");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(100, 100, 100)
.addComponent(jPanelTitre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(100, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelDateRapport)
.addComponent(jLabelMotifVisite)
.addComponent(jLabelPraticien)
.addComponent(jLabelNumeroRapport)
.addComponent(jLabelBilan))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jComboBoxPracticien, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jTextFieldDateRapport, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextFieldMotifVis, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextFieldNumRapport, javax.swing.GroupLayout.PREFERRED_SIZE, 262, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButtonPrevious)
.addGap(18, 18, 18)
.addComponent(jButtonNext, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButtonNew)))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButtonDetails)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(jButtonSauvegarder)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButtonClose))
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabelOffreEchantillons))
.addGap(24, 24, 24))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanelTitre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(31, 31, 31)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jTextFieldNumRapport, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jComboBoxPracticien, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonDetails)
.addComponent(jLabelPraticien))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextFieldDateRapport, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelDateRapport))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextFieldMotifVis, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelMotifVisite)))
.addComponent(jLabelNumeroRapport))
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelBilan)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabelOffreEchantillons)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonPrevious)
.addComponent(jButtonNext)
.addComponent(jButtonNew)
.addComponent(jButtonSauvegarder)
.addComponent(jButtonClose))
.addGap(12, 12, 12))
);
pack();
}// </editor-fold>//GEN-END:initComponents |
76e4ab13-3b6c-400e-92fa-c935c38cb29e | 8 | public boolean checkWin(GameState g)
{
if(townAlive.check())
{
if(!g.townAlive(townAlive.getRelational(), townAlive.getNum()))
return false;
}
if(townDead.check())
{
if(!g.townDead(townDead.getRelational(), townDead.getNum()))
return false;
}
if(mafiaAlive.check())
{
if(!g.mafiaAlive(mafiaAlive.getRelational(), mafiaAlive.getNum()))
return false;
}
if(mafiaDead.check())
{
if(!g.mafiaDead(mafiaDead.getRelational(), mafiaDead.getNum()))
return false;
}
return true;
} |
374f8a11-6cb7-4875-89fd-a3b8b1680f1f | 1 | public ParticleRenderer(String name, int number, int maxLife, Texture texture) {
super("particleRenderer:"+name);
this.particles = new ArrayList<Particle>(number);
Random r = new Random();
for (int i = 0; i<number;i++){
particles.add(new Particle(new Vector2f(10,10),1 + r.nextInt(maxLife),texture));
}
} |
f4ac6c2f-723b-4e1a-8f66-e4c75adba5af | 8 | public Edge[] getEdges() {
Edge[] ret = new Edge[(n*deg) / 2];
int t = 0;
if(deg%2 == 0) {
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < i+(deg / 2) + 1; j++) {
if(i != j) {
ret[t++] = new Edge(v[i], v[j % n]);
}
}
}
} else {
for (int i = 0; i < n; i=i+2) {
for (int j = i + 1; j < i + ((deg - 1) / 2) + 1; j++) {
Edge e = new Edge(v[i], v[j % n]);
ret[t++] = e;
}
for (int j = i - 1; j > i - ((deg - 1) / 2) - 1; j--) {
Edge e = new Edge(v[i], v[(j + n) % n]);
ret[t++] = e;
}
}
for (int i = 0; i < n/2; i++) {
ret[t++] = new Edge(v[i], v[(i+(n/2))%n]);
}
}
return ret;
} |
2eed22fb-7006-41f6-92f3-2418eb7838b7 | 9 | private String useTriangleVariables(String s) {
int n = view.getNumberOfInstances(TriangleComponent.class);
if (n <= 0)
return s;
int lb = s.indexOf("%triangle[");
int rb = s.indexOf("].", lb);
int lb0 = -1;
String v;
int i;
TriangleComponent triangle;
while (lb != -1 && rb != -1) {
v = s.substring(lb + 10, rb);
double x = parseMathExpression(v);
if (Double.isNaN(x))
break;
i = (int) Math.round(x);
if (i < 0 || i >= n) {
out(ScriptEvent.FAILED, "Triangle " + i + " does not exist.");
break;
}
v = escapeMetaCharacters(v);
triangle = view.getTriangle(i);
s = replaceAll(s, "%triangle\\[" + v + "\\]\\.x1", triangle.getVertex(0).x * R_CONVERTER);
s = replaceAll(s, "%triangle\\[" + v + "\\]\\.y1", triangle.getVertex(0).y * R_CONVERTER);
s = replaceAll(s, "%triangle\\[" + v + "\\]\\.x2", triangle.getVertex(1).x * R_CONVERTER);
s = replaceAll(s, "%triangle\\[" + v + "\\]\\.y2", triangle.getVertex(1).y * R_CONVERTER);
s = replaceAll(s, "%triangle\\[" + v + "\\]\\.x3", triangle.getVertex(2).x * R_CONVERTER);
s = replaceAll(s, "%triangle\\[" + v + "\\]\\.y3", triangle.getVertex(2).y * R_CONVERTER);
s = replaceAll(s, "%triangle\\[" + v + "\\]\\.particlecount", triangle.getParticleCount());
VectorField vf = triangle.getVectorField();
if (vf instanceof ElectricField)
s = replaceAll(s, "%triangle\\[" + v + "\\]\\.efield", vf.getIntensity());
else if (vf instanceof MagneticField)
s = replaceAll(s, "%triangle\\[" + v + "\\]\\.bfield", vf.getIntensity());
else {
s = replaceAll(s, "%triangle\\[" + v + "\\]\\.efield", 0);
s = replaceAll(s, "%triangle\\[" + v + "\\]\\.bfield", 0);
}
lb0 = lb;
lb = s.indexOf("%triangle[");
if (lb0 == lb) // infinite loop
break;
rb = s.indexOf("].", lb);
}
return s;
} |
9c4d5263-4790-4a09-9510-5a8ca4370ea4 | 9 | public boolean buyItem(int itemID, int fromSlot, int amount) {
if (amount > 0 && itemID == (server.shopHandler.ShopItems[MyShopID][fromSlot] - 1)) {
if (amount > server.shopHandler.ShopItemsN[MyShopID][fromSlot]) {
amount = server.shopHandler.ShopItemsN[MyShopID][fromSlot];
}
double ShopValue;
double TotPrice;
int TotPrice2;
int Overstock;
int Slot = 0;
for (int i = amount; i > 0; i--) {
TotPrice2 = (int)Math.floor(GetItemShopValue(itemID, 0, fromSlot));
Slot = GetItemSlot(995);
if (Slot == -1) {
sendMessage("You don't have enough coins.");
break;
}
if(TotPrice2 <= 1)
{
TotPrice2 = (int)Math.floor(GetItemShopValue(itemID, 0, fromSlot));
}
if (playerItemsN[Slot] >= TotPrice2) {
if (freeSlots() > 0) {
deleteItem(995, GetItemSlot(995), TotPrice2);
addItem(itemID, 1);
server.shopHandler.ShopItemsN[MyShopID][fromSlot] -= 1;
server.shopHandler.ShopItemsDelay[MyShopID][fromSlot] = 0;
if ((fromSlot + 1) > server.shopHandler.ShopItemsStandard[MyShopID]) {
server.shopHandler.ShopItems[MyShopID][fromSlot] = 0;
}
} else {
sendMessage("Not enough space in your inventory.");
break;
}
} else {
sendMessage("You don't have enough coins.");
break;
}
}
resetItems(3823);
resetShop(MyShopID);
UpdatePlayerShop();
return true;
}
return false;
} |
c015944d-b38f-4cb5-9ee6-4f9b11b2d839 | 1 | public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
AnnotationVisitor av = mv.visitAnnotation(remapper.mapDesc(desc), visible);
return av == null ? av : new RemappingAnnotationAdapter(av, remapper);
} |
8379dca1-ea98-4f3b-9499-9b383d844e45 | 1 | public synchronized boolean addGameLawEnforcer(
GameLawEnforcer gameLawEnforcer) {
if (gameEnforcerCount < gameEnforcers.length) {
gameEnforcers[gameEnforcerCount++] = gameLawEnforcer;
gameLawEnforcer.setGameRoom(this);
// gameLawEnforcer.start();
return true;
} else
return false;
} |
1d6cf03e-d4bd-4c79-ad5a-1d254c9efe69 | 8 | private void dibujaPaint(Graphics2D g2){
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.clip(new Rectangle2D.Float(0, 0, getWidth(), getHeight()));
switch (tipo){
case NONE:{
float x1=0,x2=0,y1=0,y2=getHeight();
if(!vertical){
x1=0;
y1=0;
x2=getWidth();
y2=0;
}
Paint paint = new GradientPaint(x1,y1,getBackground(), x2, y2, getBackground().darker());
g2.setPaint(paint);
g2.fill(getForma(g2));
break;
}
case CENTRAL:{
float x1=0,x2=0,y1=0,y2=getHeight();
if(!vertical){
x1=0;
y1=0;
x2=getWidth();
y2=0;
}
Paint paint = new LinearGradientPaint(x1, y1, x2, y2, new float[]{0f, 0.30f, 0.5f, 0.70f, 1f},
new Color[]{getBackground().darker().darker(),
getBackground(),
getBackground().brighter(),
getBackground(),
getBackground().darker()});
g2.setPaint(paint);
g2.fill(getForma(g2));
break;
}
case CURVE:{
double bulletWidth = getWidth();
double bulletHeight = getHeight();
Ellipse2D curve = new Ellipse2D.Double(-20, bulletHeight / 2.0,
bulletWidth+20*2, bulletHeight);
Color startColor = getBackground().darker();
Color endColor = getBackground().brighter();
Paint paint = g2.getPaint();
g2.setPaint(new GradientPaint(0.0f, 0.0f, startColor,
0.0f, (float) bulletHeight/2, endColor));
g2.fill(getForma(g2));
startColor =getBackground().darker().darker();
endColor = getBackground().brighter();
g2.setPaint(new GradientPaint(0.0f,(float)getHeight()/2 , startColor,
0.0f, (float) bulletHeight, endColor));
Area area = new Area(getForma(g2));
area.intersect(new Area(curve));
g2.fill(area);
g2.setPaint(paint);
break;
}
case CURVE_2:{
Ellipse2D curve = new Ellipse2D.Double( -getWidth()/2, 0,
getWidth(), getHeight()*2);
Color startColor = getBackground().darker();
Color endColor = getBackground().brighter();
Paint paint = g2.getPaint();
g2.setPaint(new GradientPaint(0.0f, 0.0f, startColor,
0.0f, (float) getHeight()/2, endColor));
g2.fill(getForma(g2));
startColor =getBackground().darker().darker();
endColor = getBackground().brighter();
g2.setPaint(new GradientPaint(0.0f,(float)getHeight()/2 , startColor,
0.0f, (float) getHeight(), endColor));
Area area = new Area(getForma(g2));
area.intersect(new Area(curve));
g2.fill(area);
g2.setPaint(paint);
break;
}
case CURVE_3:{
Ellipse2D curve = new Ellipse2D.Double(-20, -getHeight()/ 2.0,
getWidth()+20*2, getHeight());
Color startColor = getBackground().darker();
Color endColor = getBackground().brighter();
Paint paint = g2.getPaint();
g2.setPaint(new GradientPaint(0.0f, 0.0f, startColor,
0.0f, (float) getHeight()/2, endColor));
g2.fill(getForma(g2));
startColor =getBackground().darker().darker();
endColor = getBackground().brighter();
g2.setPaint(new GradientPaint(0.0f,0f, startColor,
0.0f, (float) getHeight()/2, endColor));
Area area = new Area(getForma(g2));
area.intersect(new Area(curve));
g2.fill(area);
g2.setPaint(paint);
break;
}
case CURVE_4:{
Ellipse2D curve = new Ellipse2D.Double( getWidth()/2, 0,
getWidth()*2, getHeight()*2);
Color startColor = getBackground().darker();
Color endColor = getBackground().brighter();
Paint paint = g2.getPaint();
g2.setPaint(new GradientPaint(0.0f, 0.0f, startColor,
0.0f, (float) getHeight()/2, endColor));
g2.fill(getForma(g2));
startColor =getBackground().darker().darker();
endColor = getBackground().brighter();
g2.setPaint(new GradientPaint(0.0f,(float)getHeight()/2 , startColor,
0.0f, (float) getHeight(), endColor));
Area area = new Area(getForma(g2));
area.intersect(new Area(curve));
g2.fill(area);
g2.setPaint(paint);
break;
}
}
} |
4737eb47-68d3-4ec3-973d-d14c8008e785 | 6 | public void update() {
// update of the player. No, why so serious ?
this.player.update(this);
// test
this.updateTime();
// update of the monsters
// But, with a lot of monster, there will be too much operations ? oO
// So, let's check only for nearest only
for (int i=0; i<this.level.getMobs().length;i++) {
if (this.player.distanceTo(this.level.getMobs()[i]) < MainPanel.GAME_WIDTH)
this.level.getMobs()[i].update(this);
}
// we update position if the player is too far from the center
if (this.player.getPosX()+this.posX <= MainPanel.GAME_WIDTH/3)
this.posX += Player.RUNSPEED;
else if (this.player.getPosX()+this.posX >= MainPanel.GAME_WIDTH*2/3.0)
this.posX -= Player.RUNSPEED;
// idem with the Y-axis
if (this.player.getPosY()+this.posY <= MainPanel.GAME_HEIGHT/3)
this.posY += Player.GRAVITY;
else if (this.player.getPosY()+this.player.getHeight()+this.posY >= MainPanel.GAME_HEIGHT*2/3.0)
this.posY -= Player.GRAVITY;
} |
b5cafad2-a224-4249-a136-6a60dbd1ee33 | 3 | public void call(String type, Object... params) {
if (!methods.containsKey(type)) {
throw new IllegalArgumentException("Not enough type");
}
Map<Method, Object> methods = this.methods.get(type);
for (Map.Entry<Method, Object> entry : methods.entrySet()) {
try {
entry.getKey().invoke(entry.getValue(), params);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
} |
9d7d09c0-07fc-4b28-adb5-0167dfccaac9 | 7 | @Override
public void insertNames(UUID uuid, String... names) {
if (names == null || names.length == 0) {
throw new IllegalArgumentException("names must have at least one entry");
}
Integer playerId = null;
String query;
if (names.length == 1) {
query = "INSERT INTO `" + playerNamesTable + "` (`player_id`, `name`) " +
"SELECT `p`.`player_id`, ? FROM `" + playersTable + "` AS `p` WHERE `p`.`uuid` = ? " +
"ON DUPLICATE KEY UPDATE `player_id` = `p`.`player_id`";
} else {
playerId = selectPlayerId(uuid);
if (playerId == null) {
playerId = insertUUID(uuid);
}
query = "INSERT INTO `" + playerNamesTable + "` (`player_id`, `name`)";
query += Strings.repeat(" VALUES(?,?)", names.length);
query += " ON DUPLICATE KEY UPDATE `player_id` = ?";
}
try (PreparedStatement insertStmt = this.connection.prepareStatement(query)) {
if (names.length == 1) {
insertStmt.setString(1, names[0]);
insertStmt.setString(2, uuid.toString());
insertStmt.executeUpdate();
} else {
for (String name : names) {
insertStmt.setInt(1, playerId);
insertStmt.setString(2, name);
insertStmt.setInt(3, playerId);
insertStmt.addBatch();
}
insertStmt.executeBatch();
}
} catch (SQLException e) {
e.printStackTrace();
}
} |
ead1d5a0-2b9f-49a8-bb8e-a674a4c7bc37 | 3 | public void execute() throws MojoExecutionException {
appDb = new AppInitializer();
BdbTerminologyStore store = appDb.getDB();
ViewCoordinate vc = appDb.getVC();
ConceptVersionBI con = appDb.getBloodPressureConcept();
ConceptVersionBI newCon = null;
try {
createNewDescription(con);
ConceptChronicleBI newConChron = createNewConcept(con);
newCon = newConChron.getVersion(appDb.getVC());
createNewRelationship(con, newCon);
appDb.getDB().commit();
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidCAB e) {
e.printStackTrace();
} catch (ContradictionException e) {
e.printStackTrace();
}
ConceptPrinter printer = new ConceptPrinter(store, vc);
printer.printConcept(con);
System.out.println("\n\n\n******** NEW CONCEPT **********");
printer.printConcept(newCon);
} |
71b4ccd9-4203-4907-906c-485393b6ec41 | 9 | protected void clearWordsBySpot(char[] guesses) {
ArrayList<Integer> letSpots = new ArrayList<Integer>(14);
for (int i = 0; i < guesses.length; i += 1) {
if (guesses[i] != '_') {
letSpots.add(i);
}
}
ArrayList<String> wordsToRemove = new ArrayList<String>();
for (String wrd : this.words) {
wordLoop:
for (Integer in : letSpots) {
if (wrd.charAt(in) != guesses[in]) {
wordsToRemove.add(wrd);
break;
} else {
for (int k = 0; k < wrd.length(); k += 1) {
if (k != in && wrd.charAt(k) == guesses[in]) {
wordsToRemove.add(wrd);
break wordLoop;
}
}
}
}
}
for (String wrdR : wordsToRemove) {
this.words.remove(wrdR);
}
} |
a00f6d72-2a9f-421d-b08e-1e30e021f824 | 0 | public void showProgress( int current ) {
jLabel2.setText("已完成 " + current + " bytes / " + filesize + " bytes");
progress.setValue( current*100/filesize );
} |
3c406500-ebf8-4645-88b6-79bfdd67033f | 4 | @SuppressWarnings("deprecation")
public void leaveGame(Player player, boolean normalLeave) {
player.setGameMode(GameMode.CREATIVE);
//player.setAllowFlight(true);
player.setHealth(20.0);
player.setFoodLevel(20);
player.setLevel(0);
for (PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType());
}
//Session session = HyperPVP.getSession(player);
//session.setInterruptThread(true);
if (normalLeave) {
player.sendMessage(ChatColor.AQUA + "You are now spectating!");
HyperPVP.setListName(ChatColor.AQUA, player);
player.getInventory().clear();
player.updateInventory();
}
CycleUtil.addSpectator(player, normalLeave);
HyperPVP.getGameSessions().remove(player.getName());
CycleUtil.hidePlayerWhereAppropriate(player, false);
player.getInventory().setHelmet(null);
player.getInventory().setBoots(null);
player.getInventory().setChestplate(null);
player.getInventory().setLeggings(null);
try {
HyperPVP.getStorage().executeQuery("UPDATE servers SET team_one = '" + this.getTeamMembers(this.teams.get(0).getColor()).size() + "' WHERE bungee_name = '" + HyperPVP.getConfiguration().getConfig().getString("Server").toLowerCase() + "'");
if (this.type != GameType.FFA) {
HyperPVP.getStorage().executeQuery("UPDATE servers SET team_two = '" + this.getTeamMembers(this.teams.get(1).getColor()).size() + "' WHERE bungee_name = '" + HyperPVP.getConfiguration().getConfig().getString("Server").toLowerCase() + "'");
}
} catch (SQLException e) {
e.printStackTrace();
}
} |
b214428d-aab9-4c31-a356-46b21239d759 | 6 | protected Response getReply() {
try {
if (read == null) {
read = new BufferedReader(new InputStreamReader(socket.getInputStream()));
}
String line;
int code = -1;
ArrayList<String> responses = new ArrayList<String>();
while ((line = read.readLine()) != null) {
if (line.length() < 4)
throw new SMTPDisconnectedException("Not enough data read.");
if (debug) {
java.lang.System.out.print('<');
java.lang.System.out.println(line);
}
code = Integer.parseInt(line.substring(0, 3));
responses.add(line.substring(4));
if (line.charAt(3) != '-')
break;
}
return new Response(code, join("\n", responses));
} catch (IOException e) {
throw new SMTPException(e);
}
} |
6e4d8e21-0f0d-4280-9fcd-40334cf028cb | 5 | @Override
public void keyReleased(KeyEvent e) {
int keyCode = e.getKeyCode();
if(keyCode == KeyEvent.VK_LEFT){
mainPlayer.setLeft(false);
}
if(keyCode == KeyEvent.VK_RIGHT){
mainPlayer.setRight(false);
}
if(keyCode == KeyEvent.VK_UP){
mainPlayer.setUp(false);
}
if(keyCode == KeyEvent.VK_DOWN){
mainPlayer.setDown(false);
}
if(keyCode == KeyEvent.VK_SHIFT){
mainPlayer.setSpeedUp(false);
}
} |
3759d9c9-e618-44b7-9008-417d33039d26 | 9 | @SuppressWarnings("unchecked")
public boolean equals(Object otherViewObject) {
if (otherViewObject != null && otherViewObject instanceof View) {
View<T> otherView = (View<T>) otherViewObject;
if (size() == otherView.size()) {
for (int i = 0; i < size(); i++) {
if ((get(i) != null || otherView.get(i) != null) && (get(i) == null || otherView.get(i) == null || !get(i).equals(otherView.get(i)))) {
return false;
}
}
return true;
}
}
return false;
} |
02b5c14e-ac83-4d92-936e-9ae433fa710c | 4 | private SignFilter(final String text1, final String text2, final String text3, final String text4) throws PatternSyntaxException {
this.text[0] = (text1 != null ? Pattern.compile(text1) : null);
this.text[1] = (text2 != null ? Pattern.compile(text2) : null);
this.text[2] = (text3 != null ? Pattern.compile(text3) : null);
this.text[3] = (text4 != null ? Pattern.compile(text4) : null);
} |
806ee1d9-bef7-4979-ad71-3c1f2e0bfcf8 | 7 | public Set<Map.Entry<Double,V>> entrySet() {
return new AbstractSet<Map.Entry<Double,V>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TDoubleObjectMapDecorator.this.isEmpty();
}
public boolean contains( Object o ) {
if ( o instanceof Map.Entry ) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TDoubleObjectMapDecorator.this.containsKey( k ) &&
TDoubleObjectMapDecorator.this.get( k ).equals( v );
} else {
return false;
}
}
public Iterator<Map.Entry<Double,V>> iterator() {
return new Iterator<Map.Entry<Double,V>>() {
private final TDoubleObjectIterator<V> it = _map.iterator();
public Map.Entry<Double,V> next() {
it.advance();
double k = it.key();
final Double key = (k == _map.getNoEntryKey()) ? null : wrapKey( k );
final V v = it.value();
return new Map.Entry<Double,V>() {
private V val = v;
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals( key )
&& ( ( Map.Entry ) o ).getValue().equals( val );
}
public Double getKey() {
return key;
}
public V getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public V setValue( V value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Double,V> o ) {
throw new UnsupportedOperationException();
}
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Double key = ( ( Map.Entry<Double,V> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Double,V>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TDoubleObjectMapDecorator.this.clear();
}
};
} |
3640faf4-926e-4044-9eac-1033852829d7 | 0 | public static Font getFont() throws FontFormatException, IOException{
URL urlFont = ResourceManager.class.getResource("/fonts/8bit.ttf");
Font font = Font.createFont(Font.TRUETYPE_FONT, urlFont.openStream());
return font;
} |
cc1af325-9602-43f0-bc1d-f1353be32131 | 5 | private void goDirection(MouseEvent e) {
// handle direction
Direction direction = view.directionContaining(e.getPoint());
if(direction != null) {
switch (direction)
{
case NORTH:
{
kdtCC.execGo(Direction.NORTH);
break;
}
case SOUTH:
{
kdtCC.execGo(Direction.SOUTH);
break;
}
case WEST:
{
kdtCC.execGo(Direction.WEST);
break;
}
case EAST:
{
kdtCC.execGo(Direction.EAST);
break;
}
}
}
} |
a438dfaf-8da5-42f4-b3ef-843e8efd1e5c | 7 | public int Run(RenderWindow App) {
boolean Running = true;
Text numberChickenKillLabel = new Text();
Text scoreLabel = new Text();
Text numberChickenKill = new Text();
Text score = new Text();
Text scoreLoseLabel = new Text();
Text scoreLose = new Text();
Text bottomText = new Text();
Font font = new Font();
try {
font.loadFromFile(Paths.get("rsc/font/Frank Knows.ttf"));
} catch (IOException e) {
e.printStackTrace();
return -1;
}
numberChickenKillLabel.setFont(font);
numberChickenKillLabel.setCharacterSize(50);
numberChickenKillLabel.setString("Number of chicken killed: ");
numberChickenKillLabel.setPosition(App.getSize().x / 2 - numberChickenKillLabel.getLocalBounds().width / 2, (App.getSize().y / 4)-100);
numberChickenKill.setFont(font);
numberChickenKill.setCharacterSize(50);
numberChickenKill.setString(""+Score.getChickenKill());
numberChickenKill.setPosition(App.getSize().x / 2 - numberChickenKill.getLocalBounds().width / 2, App.getSize().y / 4 -50);
scoreLoseLabel.setFont(font);
scoreLoseLabel.setCharacterSize(50);
scoreLoseLabel.setString("Lost points: ");
scoreLoseLabel.setPosition(App.getSize().x/2-scoreLoseLabel.getLocalBounds().width/2, ((App.getSize().y/4)*2)-100);
scoreLose.setFont(font);
scoreLose.setCharacterSize(50);
scoreLose.setString("-"+Score.getLostPoints());
scoreLose.setPosition(App.getSize().x/2-scoreLose.getLocalBounds().width/2, (App.getSize().y/4)*2-50);
scoreLabel.setFont(font);
scoreLabel.setCharacterSize(50);
scoreLabel.setString("Score: ");
scoreLabel.setPosition( App.getSize().x/2-scoreLabel.getLocalBounds().width/2, ((App.getSize().y/4)*3)-100);
score.setFont(font);
score.setCharacterSize(50);
score.setString(""+Score.getScore());
score.setPosition(App.getSize().x/2-score.getLocalBounds().width/2, (App.getSize().y/4)*3-50);
bottomText.setFont(font);
bottomText.setCharacterSize((int)(0.50*50));
bottomText.setString("Appuyez sur une touche");
bottomText.setPosition( App.getSize().x/2-bottomText.getLocalBounds().width/2, App.getSize().y-bottomText.getLocalBounds().height-20);
Score.reset();
while (Running) {
//Verifying events
for (Event event : App.pollEvents()) {
{
// Window closed
if (event.type == event.type.CLOSED) {
return (-1);
}
//Key pressed
if (event.type == Event.Type.KEY_PRESSED) {
event.asKeyEvent();
if (Keyboard.isKeyPressed(Keyboard.Key.ESCAPE))
return (1);
else {
return 1;
}
}
if(event.type == Event.Type.MOUSE_BUTTON_RELEASED) {
return 1;
}
}
}
App.draw(scoreLabel);
App.draw(numberChickenKillLabel);
App.draw(score);
App.draw(numberChickenKill);
App.draw(scoreLoseLabel);
App.draw(scoreLose);
App.draw(bottomText);
App.display();
//Clearing screen
App.clear();
}
//Never reaching this point normally, but just in case, exit the application
System.out.println("game over finit");
return (1);
} |
82b2ca30-9c53-4d9d-af9e-db53f787a580 | 8 | public Node findItem(int key) {
if (isEmpty())
return null;
else {
Node current = this.root;
while (true)
if (current.getKey() > key && current.getLeft() != null)
current = current.getLeft();
else if (current.getKey() < key && current.getRight() != null)
current = current.getRight();
else if (current != null && current.getKey() == key)
return current;
else
return null;
}
} |
a619d198-48ce-48c2-98d8-1476e1648b31 | 9 | @Override
public Session findPlayerSessionOnline(String srchStr, boolean exactOnly)
{
// then look for players
for(final Session S : localOnlineIterable())
{
if(S.mob().Name().equalsIgnoreCase(srchStr))
return S;
}
for(final Session S : localOnlineIterable())
{
if(S.mob().name().equalsIgnoreCase(srchStr))
return S;
}
// keep looking for players
if(!exactOnly)
{
for(final Session S : localOnlineIterable())
{
if(CMLib.english().containsString(S.mob().Name(),srchStr))
return S;
}
for(final Session S : localOnlineIterable())
if(CMLib.english().containsString(S.mob().name(),srchStr))
return S;
}
return null;
} |
dd86a5ac-c1e4-4dd2-9909-902cd9798eb1 | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ArraySelectorNode other = (ArraySelectorNode) obj;
if (selector == null) {
if (other.selector != null)
return false;
} else if (!selector.equals(other.selector))
return false;
if (subject == null) {
if (other.subject != null)
return false;
} else if (!subject.equals(other.subject))
return false;
return true;
} |
7afedf3d-8377-468f-a41f-4bc44894bdbf | 4 | private boolean osuukoKarkiVarteen(double karkix, double karkiy,
double[] juuriKarkiXYXY){
double varsijuurix = juuriKarkiXYXY[0];
double varsijuuriy = juuriKarkiXYXY[1];
double varsikarkix = juuriKarkiXYXY[2];
double varsikarkiy = juuriKarkiXYXY[3];
boolean karkiOnVarrenXpisteidenValissa = karkix > Math.min(varsikarkix, varsijuurix)
&& karkix < Math.max(varsikarkix, varsijuurix);
boolean karkiOnVarrenYpisteidenValissa = karkiy > Math.min(varsikarkiy, varsijuuriy)
&& karkiy < Math.max(varsikarkiy, varsijuuriy);
boolean onkoKarkiVarrella = false;
if (karkiOnVarrenXpisteidenValissa && karkiOnVarrenYpisteidenValissa){
//lasketaan onko kulmakerroin sama suhteessa varren juuren
onkoKarkiVarrella = Math.abs(Math.abs((karkix-varsijuurix)/(karkiy-varsijuuriy))
-Math.abs((varsikarkix-varsijuurix)/(varsikarkiy-varsijuuriy)))<0.1;
}
return onkoKarkiVarrella;
} |
ddd90ca7-b108-4572-a843-be9e0d1dc2ff | 6 | private synchronized void savePasswd() throws IOException {
if (passwdFile != null) {
FileOutputStream fos = new FileOutputStream(passwdFile);
PrintWriter pw = null;
try {
pw = new PrintWriter(fos);
String key;
String[] fields;
StringBuffer sb;
Enumeration keys = entries.keys();
while (keys.hasMoreElements()) {
key = (String) keys.nextElement();
fields = (String[]) entries.get(key);
sb = new StringBuffer(fields[0]);
for (int i = 1; i < fields.length; i++) {
sb.append(":"+fields[i]);
}
pw.println(sb.toString());
}
} finally {
if (pw != null) {
try {
pw.flush();
} finally {
pw.close();
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException ignored) {
}
}
lastmod = passwdFile.lastModified();
}
}
} |
3c945c2f-0455-447c-82f5-5829916cdf77 | 5 | private ArrayList<Time_Sheet> getAllConflicts(Time_Sheet ts) throws SQLException{
ArrayList<Time_Sheet> conflicts = new ArrayList();
int oldConflictsSize = 0;
conflicts.add(ts);
for(int i = 0; i < conflicts.size(); i++){
for(Time_Sheet tempTs : timeSheetAccess.getConflictingTimeSheets(conflicts.get(i))){
boolean alreadyIncluded = false;
for(Time_Sheet temporaryTs : conflicts){
if(tempTs.getId() == temporaryTs.getId())
alreadyIncluded = true;
}
if(!alreadyIncluded)
conflicts.add(tempTs);
}
}
return conflicts;
} |
577589fb-df97-4bf2-ad2f-f8dd9efd26e8 | 4 | public void setComplete() {
double temp = 0.0;
// Check the IBU
if (ibuHigh < ibuLow) {
temp = ibuHigh;
ibuHigh = ibuLow;
ibuLow = temp;
}
// check the SRM
if (srmHigh < srmLow) {
temp = srmHigh;
srmHigh = srmLow;
srmLow = temp;
}
// check the OG
if (ogHigh < ogLow) {
temp = ogHigh;
ogHigh = ogLow;
ogLow = temp;
}
// check the ALC
if (alcHigh < alcLow) {
temp = alcHigh;
alcHigh = alcLow;
alcLow = temp;
}
} |
bb767e41-7364-4732-a8a8-cdf01224c48b | 7 | public int compare(TradeOrder order1, TradeOrder order2)
{
if (order1.isMarket() && order2.isMarket())
{
return 0;
}
if (order1.isMarket() && order2.isLimit())
{
return -1;
}
if (order1.isLimit() && order2.isMarket())
{
return 1;
}
double cents1 = 100 * order1.getPrice();
double cents2 = 100 * order2.getPrice();
if (asc)
{
return (int) (Math.round(cents1 - cents2));
} else
{
return (int) (Math.round(cents2 - cents1));
}
} |
0962d866-2d5b-4952-b0cf-faf145cd2212 | 6 | Class310_Sub3(DirectxToolkit class378, Class304 class304, int i, int i_0_,
int i_1_, byte[] is) {
super(class378, class304, Class68.aClass68_1183, false,
i_1_ * i_0_ * i);
anInt6338 = i;
anInt6337 = i_1_;
anInt6339 = i_0_;
anIDirect3DVolumeTexture6336
= (((DirectxToolkit) ((Class310_Sub3) this).aClass378_3893)
.anIDirect3DDevice9810.a
(i, i_0_, i_1_, 1, 0,
DirectxToolkit.method3958(22, ((Class310_Sub3) this).aClass68_3895,
class304),
1));
PixelBuffer pixelbuffer
= (((DirectxToolkit) ((Class310_Sub3) this).aClass378_3893)
.aPixelBuffer9803);
int i_2_ = anIDirect3DVolumeTexture6336.LockBox(0, 0, 0, 0, i, i_0_,
i_1_, 0, pixelbuffer);
if (ue.a(i_2_, false)) {
int i_3_
= (((Class304) ((Class310_Sub3) this).aClass304_3896).anInt3850
* anInt6338);
int i_4_ = i_3_ * anInt6339;
int i_5_ = pixelbuffer.getSlicePitch();
if (i_5_ == i_4_)
pixelbuffer.a(is, 0, 0, anInt6337 * (i_3_ * anInt6339));
else {
int i_6_ = pixelbuffer.getRowPitch();
if (i_3_ != i_6_) {
for (int i_7_ = 0; i_7_ < anInt6337; i_7_++) {
for (int i_8_ = 0;
(i_8_ ^ 0xffffffff) > (anInt6339 ^ 0xffffffff);
i_8_++)
pixelbuffer.a(is, i_3_ * i_8_ + i_4_ * i_7_,
i_8_ * i_6_ + i_7_ * i_5_, i_3_);
}
} else {
for (int i_9_ = 0;
(i_9_ ^ 0xffffffff) > (anInt6337 ^ 0xffffffff);
i_9_++)
pixelbuffer.a(is, i_4_ * i_9_, i_9_ * i_5_, i_4_);
}
}
anIDirect3DVolumeTexture6336.UnlockBox(0);
}
} |
971b331c-2d1b-4d9f-ae54-d77a0426f3db | 0 | public void method2()
{
System.out.println("执行方法!");
} |
1e7aa7c8-773c-4620-b7ce-ee45a03a1028 | 6 | static public void adjustBeginLineColumn(int newLine, int newCol)
{
int start = tokenBegin;
int len;
if (bufpos >= tokenBegin)
{
len = bufpos - tokenBegin + inBuf + 1;
}
else
{
len = bufsize - tokenBegin + bufpos + 1 + inBuf;
}
int i = 0, j = 0, k = 0;
int nextColDiff = 0, columnDiff = 0;
while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
{
bufline[j] = newLine;
nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
bufcolumn[j] = newCol + columnDiff;
columnDiff = nextColDiff;
i++;
}
if (i < len)
{
bufline[j] = newLine++;
bufcolumn[j] = newCol + columnDiff;
while (i++ < len)
{
if (bufline[j = start % bufsize] != bufline[++start % bufsize])
bufline[j] = newLine++;
else
bufline[j] = newLine;
}
}
line = bufline[j];
column = bufcolumn[j];
} |
989b4de9-25d2-4982-bfdd-c970baffab70 | 2 | public static Pays selectPaysById(int id) throws SQLException {
String query = null;
Pays pays1 = new Pays();
ResultSet resultat;
try {
query = "SELECT * from PAYS where ID_PAYS=? ";
PreparedStatement pStatement = ConnectionBDD.getInstance().getPreparedStatement(query);
pStatement.setInt(1, id);
resultat = pStatement.executeQuery();
while (resultat.next()) {
//System.out.println(resultat.getString("PAYS"));
pays1 = new Pays(resultat.getInt("ID_PAYS"), resultat.getString("PAYS"));
}
} catch (SQLException ex) {
Logger.getLogger(RequetesPays.class.getName()).log(Level.SEVERE, null, ex);
}
return pays1;
} |
51cb7afa-bc21-464d-b500-a10d1da0c421 | 7 | public boolean handleEvent(Event e) {
switch (e.id) {
case Event.KEY_PRESS:
case Event.KEY_ACTION:
// key pressed
break;
case Event.KEY_RELEASE:
// key released
break;
case Event.MOUSE_DOWN:
// mouse button pressed
break;
case Event.MOUSE_UP:
// mouse button released
controller.onClick(e.x, e.y);
break;
case Event.MOUSE_MOVE:
// mouse is being moved
break;
case Event.MOUSE_DRAG:
// mouse is being dragged (button pressed)
break;
}
return false;
} |
902b5d45-d455-4802-ac53-0451b10988b4 | 8 | public Iterator<SecFlag> flags()
{
return new Iterator<SecFlag>()
{
Iterator<SecFlag> p=null;
Iterator<SecGroup> g=null;
private boolean doNext()
{
if(p==null)
p=flags.iterator();
if(p.hasNext())
return true;
if(g==null)
g=groups.iterator();
while(!p.hasNext())
{
if(!g.hasNext())
return false;
p=g.next().flags();
}
return true;
}
@Override
public boolean hasNext()
{
if((p==null)||(!p.hasNext()))
return doNext();
return p.hasNext();
}
@Override
public SecFlag next()
{
if(hasNext())
return p.next();
throw new java.util.NoSuchElementException();
}
@Override public void remove() {}
};
} |
10c1890c-46cf-4f1b-b2e2-479f1f9d7498 | 7 | private void putResize (int key, V value) {
if (key == 0) {
zeroValue = value;
hasZeroValue = true;
return;
}
// Check for empty buckets.
int index1 = key & mask;
int key1 = keyTable[index1];
if (key1 == EMPTY) {
keyTable[index1] = key;
valueTable[index1] = value;
if (size++ >= threshold) resize(capacity << 1);
return;
}
int index2 = hash2(key);
int key2 = keyTable[index2];
if (key2 == EMPTY) {
keyTable[index2] = key;
valueTable[index2] = value;
if (size++ >= threshold) resize(capacity << 1);
return;
}
int index3 = hash3(key);
int key3 = keyTable[index3];
if (key3 == EMPTY) {
keyTable[index3] = key;
valueTable[index3] = value;
if (size++ >= threshold) resize(capacity << 1);
return;
}
push(key, value, index1, key1, index2, key2, index3, key3);
} |
5d505491-8f71-4fe9-b661-76e940d5e1ad | 6 | public static void test()
{
Gson gson = new Gson();
String json;
try {
json = getJSON("http://dev.mhsnews.org/json_db/updates.php");
char[] cson = json.toCharArray();
System.out.println(json.toCharArray().length);
System.out.println();
//LOOP:
//While there is a line in JSON up to a certain line (test:4)
int a = 0, j=0;
for (int i=1; i<cson.length; i++)
{
if (cson[i] == '{' && a==0)
{
j=i;
}
if (cson[i] == '}')
{
a++;
String sson = "";
for(int k=j; k<=i; k++)
sson+= cson[k];
post = gson.fromJson(sson,Post.class);
postList.add(post);
j=i+1;
//2/1/13 - This works fine. GSON_Tester parses all of the json into individual Posts.
// Next Step: add Posts to Post ArrayList
}
}
// post = gson.fromJson(json, Post.class);
} catch (IOException e) {e.printStackTrace();}
} |
b2943794-52c2-4446-952a-2be59ab454a0 | 4 | static boolean containsOrigin(List<Vector3f> simplex) {
// If we don't have 4 points, then we can't enclose the origin in R3
if(simplex.size() < 4)
return false;
Vector3f a = simplex.get(3);
Vector3f b = simplex.get(2);
Vector3f c = simplex.get(1);
Vector3f d = simplex.get(0);
// Compute all the edges we will use first, to avoid computing the same edge twice.
Vector3f ac = c.minus(a);
Vector3f ab = b.minus(a);
Vector3f bc = c.minus(b);
Vector3f bd = d.minus(b);
Vector3f ad = d.minus(a);
Vector3f ba = ab.negate();
Vector3f ao = a.negate();
Vector3f bo = b.negate();
/* We need to find the normals of all the faces
* of a tetrahedron
*
* Tetrahedron net (unfolded)
* A-----------------B-----------------A
* \ / \ /
* \ / \ /
* \ AC x AB / \ AB x AD /
* \ / \ /
* \ / \ /
* \ / BC x BD \ /
* \ / \ /
* \ / \ /
* C-----------------D
* \ /
* \ /
* \ AD x AC /
* \ /
* \ /
* \ /
* \ /
* \ /
* A
*/
Vector3f abc = ac.cross(ab);
Vector3f bcd = bc.cross(bd);
Vector3f adb = ab.cross(ad);
Vector3f acd = ad.cross(ac);
/*
* We don't know which way our sides are described, so we could have an inside out
* tetrahedron.
*
* So we multiple two dot products, the first tells us which way the normal is facing
* and the second tells us which way the origin is from that face, if they are the same
* sign then the origin and the vertex opposite that face are in the same direction.
*
* Since we just want to know if they are the same sign we multiple the two dot products
* together and see if the product is positive.
*
* For the origin to be within the tetrahedron, it must be on the inside of all four faces.
*/
return
(abc.dotProduct(ad) * abc.dotProduct(ao) >= 0.0f) &&
(bcd.dotProduct(ba) * bcd.dotProduct(bo) >= 0.0f) &&
(adb.dotProduct(ac) * adb.dotProduct(ao) >= 0.0f) &&
(acd.dotProduct(ab) * acd.dotProduct(ao) >= 0.0f);
} |
4fa3791c-a9cc-45ed-a805-26f2979d735f | 3 | @Test
public void getterTest() {
for (int i = 0; i < TESTS; i++) {
double value = rand.nextDouble() * rand.nextInt();
Angle angle = new Angle(value);
double truevalue = value % 360;
if (truevalue < 0) truevalue += 360;
assertEquals(truevalue, angle.getAngle(), 0.00001);
assertTrue(angle.getAngle() >= 0 && angle.getAngle() < 360);
}
} |
96c839e5-b25e-48ef-98a5-e9cfcac76a38 | 3 | private void AddComponentsToGamePanel() {
ArtAssets art = ArtAssets.getInstance();
this.setLayout(null);
switch (gameState.getDifficultyLevel()) {
case GameState.DIFFICULTY_EASY:
this.loadTargetPins(new Dimension(4, 3), 60, new Dimension(70, 70), 60, 80);
break;
case GameState.DIFFICULTY_MEDIUM:
this.loadTargetPins(new Dimension(5, 4), 30, new Dimension(70, 70), 40, 70);
break;
case GameState.DIFFICULTY_HARD:
this.loadTargetPins(new Dimension(7, 5), 5, new Dimension(70, 70), 60, 55);
break;
}
BackgroundPanel menuBar = new BackgroundPanel(art.getAsset(ArtAssets.MENU_BAR_TOP));
menuBar.setBounds(0, 0, 640, 28);
this.add(menuBar);
this.setComponentZOrder(menuBar, 5);
scoreLabel = new ScoreLabel();
scoreLabel.setBounds(100, 0, 175, 28);
this.add(scoreLabel);
this.setComponentZOrder(scoreLabel, 5);
timeRemainingLabel = new TimeLabel();
timeRemainingLabel.setBounds(250, 0, 100, 28);
this.add(timeRemainingLabel);
this.setComponentZOrder(timeRemainingLabel, 5);
MenuButton menuButton = new MenuButton("Main Menu", art.getAsset(ArtAssets.MENU_BAR_BUTTON), this);
menuButton.setBounds(0, 0, 79, 28);
menuButton.addText(12);
menuButton.addMouseListener(new MouseAdapter() { //In case of click:
public void mouseClicked(MouseEvent e) { //Remove everything and load the Main Menu
gameTimer.stop();
GameState.resetInstance();
ParticleManagerWrapper.resetInstance();
mainJFrame.removeAll();
MenuPresets.loadPreset_MainMenu(mainJFrame);
mainJFrame.validate();
mainJFrame.repaint();
}
});
this.add(menuButton);
this.setComponentZOrder(menuButton, 6);
comboLabel = new ComboLabel();
comboLabel.setBounds(10, 420, 150, 50);
this.add(comboLabel);
this.setComponentZOrder(comboLabel, 6);
ParticlePanel particlePanel = new ParticlePanel(this);
particlePanel.setBounds(0, 0, ScrapBlaster.SCREEN_WIDTH, ScrapBlaster.SCREEN_HEIGHT);
particlePanel.setOpaque(false);
this.add(particlePanel);
this.setComponentZOrder(particlePanel, 7);
} |
0c0e7aea-9d2f-447c-a054-e86c1021f468 | 5 | public static void createSolution() {
try {
switch (solution) {
case 1:
s = new FkSolution(depth);
break;
case 2:
s = new F2kSolution(depth);
break;
case 3:
s = new F3kSolution(depth);
break;
case 4:
s = new F4kSolution(depth);
}
} catch (NullPointerException e) {
System.err
.println("Invalid use of Test.createSolution, solution or depth or both is/are unselected.");
e.printStackTrace();
}
} |
5baac544-276f-4ff3-80fe-51c2f70d87ed | 5 | public void algoritmi(int iAlku, int jAlku){
int[] sij;
Verkkosolmu vuorossa;
initialiseSingleSource(iAlku, jAlku);
int kaydytsolmut = 0;
keko.heapInsert(kaytavaverkko[iAlku][jAlku]);
while(!keko.empty()){
kaydytsolmut++;
vuorossa = keko.heapDelMin();
sij = vuorossa.getSijainti();
if(tarkistin(sij[0], sij[1]+1)){
relax(sij[0], sij[1], sij[0], sij[1]+1);
}
if(tarkistin(sij[0], sij[1]-1)){
relax(sij[0], sij[1], sij[0], sij[1]-1);
}
if(tarkistin(sij[0]+1, sij[1])){
relax(sij[0], sij[1], sij[0]+1, sij[1]);
}
if(tarkistin(sij[0]-1, sij[1])){
relax(sij[0], sij[1], sij[0]-1, sij[1]);
}
}
System.out.println("Dijkstran käytyjen solmujen lkm: "+kaydytsolmut);
} |
f651cb86-c82f-4bf9-b9c9-b558d1493cc8 | 0 | public static String getValidationString() {
String random = RandomStringUtils.randomAlphanumeric(20);
return random;
} |
f4a67613-524e-445c-a9d9-a7f573cb66d6 | 8 | final public void EqualityExpression() throws ParseException {
Token t = null;
InstanceOfExpression();
label_12:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case EQ:
case NE:
;
break;
default:
break label_12;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case EQ:
t = jj_consume_token(EQ);
break;
case NE:
t = jj_consume_token(NE);
break;
default:
jj_consume_token(-1);
throw new ParseException();
}
InstanceOfExpression();
BSHBinaryExpression jjtn001 = new BSHBinaryExpression(JJTBINARYEXPRESSION);
boolean jjtc001 = true;
jjtree.openNodeScope(jjtn001);
jjtreeOpenNodeScope(jjtn001);
try {
jjtree.closeNodeScope(jjtn001, 2);
jjtc001 = false;
jjtreeCloseNodeScope(jjtn001);
jjtn001.kind = t.kind;
} finally {
if (jjtc001) {
jjtree.closeNodeScope(jjtn001, 2);
jjtreeCloseNodeScope(jjtn001);
}
}
}
} |
413f9ec8-65e5-4ab8-be67-537936cb248a | 1 | * The expression whose value we are storing.
*/
private void addStore(final MemExpr target, final Expr expr) {
if (saveValue) {
stack.push(new StoreExpr(target, expr, expr.type()));
} else {
addStmt(new ExprStmt(new StoreExpr(target, expr, expr.type())));
}
} |
e7e1952c-1856-4c6e-9141-10524c40a516 | 1 | public static boolean isWindows() {
String osName = System.getProperty("os.name");
if (osName.toLowerCase().startsWith("win")) {
return true;
} else {
return false;
}
} |
8536876a-a187-411f-a7f8-255db6a4d329 | 3 | @Override
public float calculateCost() {
float cost = getPrice();
cost = (float) (cost + (0.125 * cost) + (.1 * cost));
if (cost > 0) {
if (cost <= 100) {
cost += 5;
} else if (cost <= 200) {
cost += 10;
} else {
cost = (float) (cost + (0.05 * cost));
}
}
return cost;
} |
3b01a9b1-cc2c-447d-b2b3-3ba27b71475f | 1 | public void fillObject(Users user, ResultSet result) {
//Заполняем информацией из базы
try {
user.setId(result.getInt("ID"));
user.setUserName(result.getString("USERNAME"));
user.setUserPsw(result.getString("USERPSW"));
user.setUserState(result.getInt("USERSTATE"));
user.setUserTypeId(result.getInt("USERTYPEID"));
} catch (SQLException exc) {
JOptionPane.showMessageDialog(null, "Ошибка при извлечении обьекта из базы");
}
} |
7548fd46-a08a-44eb-952d-6ef0f97efd24 | 4 | int bestScore() {
alignmentScore = Integer.MIN_VALUE;
int maxj = b.length, maxi = a.length;
for (int i = 1; i <= a.length; i++) {
if (alignmentScore < score[i][maxj]) {
alignmentScore = score[i][maxj];
besti = i;
bestj = maxj;
}
}
for (int j = 1; j <= b.length; j++) {
if (alignmentScore < score[maxi][j]) {
alignmentScore = score[maxi][j];
bestj = j;
besti = maxi;
}
}
return alignmentScore;
} |
5340d1e1-87f7-4df5-8dd2-6d30745f0299 | 8 | @Override
public void tick() {
if (fuelSlider.isActive()) {
fuelSlider.tick();
}
if (massSlider.isActive()) {
massSlider.tick();
if (rocket.getY() < 0.001) {
mass = massSlider.getValue();
rocket = new Rectangle(210, 0, (int) (mass * 8), 60);
}
}
if (running) {
if (fuel > 0) {
ay = -EXHAUST_VELOCITY / mass();
fuel--;
} else {
ay = 0;
}
if (rocket.getY() > 0) {
ay -= (9.8 / 60); // gravity
}
vy += ay;
rocket.setBounds((int) rocket.getX(), (int) (rocket.getY() + vy), (int) rocket.getWidth(), (int) rocket.getHeight());
if (rocket.getY() < 0.001) {
rocket.setBounds((int) rocket.getX(), 0, (int) rocket.getWidth(), (int) rocket.getHeight());
}
if (rocket.getY() + rocket.getHeight() > maxHeight) {
maxHeight = (int) (rocket.getY() + rocket.getHeight());
}
}
} |
036c3555-cd47-4ed3-892a-c2739cc64d09 | 5 | @Override
public void initialize(InputSplit split, TaskAttemptContext context)
throws IOException, InterruptedException {
this.conf = context.getConfiguration();
sequenceFileRecordReader.initialize(split, context);
// get dimensionLengths from hadoop conf
try {
initDimensionLengthsFromHadoopConf();
} catch (DimensionLengthsNotSetException e) {
e.printStackTrace();
// TODO exit is not a good way
System.exit(-1);
}
// get start&end from conf
try {
initStartAndEndFromHadoopConf();
} catch (StartOrEndNotSetException e) {
e.printStackTrace();
// TODO exit is not a good way
System.exit(-1);
}
// check whether any problem with the process of getting the start&end
if (startPointForElement == null || endPointForElement == null) {
// TODO it's good to Debug but definitely not nice codes
try {
throw new CubeException(
"problem with the process of getting start&end from conf");
} catch (CubeException e) {
e.printStackTrace();
// TODO exit is not a good way
System.exit(-1);
}
}
} |
0c8d6c11-09b5-4f1f-b6d5-6fc715ff899a | 2 | private void initComponents() {
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
selectFileLbl = new JLabel();
backBtn = new JButton();
statusLbl = new JLabel();
sectionScrollPane = new JScrollPane();
sectionListTable = new JTable();
addFileBtn = new JButton();
//======== this ========
setTitle("Learning words - Import words");
setResizable(false);
Container contentPane = getContentPane();
contentPane.setLayout(null);
//---- selectFileLbl ----
selectFileLbl.setText("Select file:");
selectFileLbl.setFont(new Font("Segoe UI", Font.BOLD, 14));
contentPane.add(selectFileLbl);
selectFileLbl.setBounds(new Rectangle(new Point(15, 15), selectFileLbl.getPreferredSize()));
//---- backBtn ----
backBtn.setText("Back");
contentPane.add(backBtn);
backBtn.setBounds(95, 45, 75, 30);
backBtn.addActionListener(new BackButtonListener(this, user));
//---- statusLbl ----
statusLbl.setText("Select section and choose excel file to import words. Duplicate words won't be imported!");
statusLbl.setFont(new Font("Segoe UI", Font.BOLD, 12));
contentPane.add(statusLbl);
statusLbl.setBounds(new Rectangle(new Point(15, 295), statusLbl.getPreferredSize()));
//======== sectionScrollPane ========
{
sectionScrollPane.setViewportView(sectionListTable);
}
contentPane.add(sectionScrollPane);
final SelectSectionTableModel model = new SelectSectionTableModel();
sectionListTable.setModel(model);
sectionListTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
sectionListTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
try {
int row = sectionListTable.getSelectedRow();
selectedSection = (model.getValueAt(row, 0)).toString();
selectedSectionId = (Integer)(model.getId(selectedSection));
System.out.println(selectedSectionId);
if (!addFileBtn.isEnabled()) {
addFileBtn.setEnabled(true);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
sectionScrollPane.setBounds(15, 85, 595, 185);
//---- addFileBtn ----
addFileBtn.setText("Add file");
contentPane.add(addFileBtn);
addFileBtn.setBounds(15, 45, 75, 30);
addFileBtn.setEnabled(false);
addFileBtn.addActionListener(new AddFileButtonListener(statusLbl));
contentPane.setPreferredSize(new Dimension(640, 360));
pack();
setLocationRelativeTo(getOwner());
} |
9dbd231a-32ac-4c31-bd6a-b95c8f2c883b | 2 | private Connection getConn() {
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
try {
conn = (Connection) DriverManager.getConnection(this.url, this.usuario, this.senha);
} catch (SQLException ex) {
Logger.getLogger(ConectorMySql.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (ClassNotFoundException |
InstantiationException |
IllegalAccessException ex) {
Logger.getLogger(ConectorMySql.class.getName()).log(Level.SEVERE, null, ex);
}
return conn;
} |
63c3abde-166e-41e4-a19d-9ea7dfea795a | 1 | public static boolean isFloat(String string) {
try {
Float.parseFloat(string);
return true;
} catch (Exception ex) {
return false;
}
} |
7b090b21-68a2-4dd1-9359-7b73e9aba46f | 9 | @Override
public void keyReleased(KeyEvent e) {
if (isWaitingForKeyPress() || consoleInputField != null) {
return;
}
/* Movement controls */
if (e.getKeyCode() == KeyEvent.VK_LEFT) {
leftPressed = false;
leftPressedMs = 0;
nextSprite = 0;
}
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
rightPressed = false;
rightPressedMs = 0;
nextSprite = 0;
}
if (e.getKeyCode() == KeyEvent.VK_UP) {
upPressed = false;
}
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
downPressed = false;
}
if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
shiftPressed = false;
}
if (e.getKeyCode() == KeyEvent.VK_Z) {
zPressed = false;
}
if (e.getKeyCode() == KeyEvent.VK_X) {
xPressed = false;
}
} //end method keyReleased |
007ff092-1a17-4fea-8d3b-82761c507652 | 9 | private void updateGrid() {
// Draw the shadow (previous should already have been removed)
if (displayShadow) {
shadowDistance = 0;
boolean canMoveDown = true;
// Drop the shadow to calculate new distance
while (true) {
for (int[] relLoc : relLocs) {
if (relLoc[1] + row - shadowDistance <= 0
|| grid.isOccupied(relLoc[0] + col, relLoc[1] + row
- shadowDistance - 1)
&& !isSelfOccupied(relLoc[0] + col, relLoc[1] + row
- shadowDistance - 1)) {
canMoveDown = false;
break;
}
}
if (!canMoveDown) {
break;
}
++shadowDistance;
}
for (int[] relLoc : relLocs) {
grid.set(relLoc[0] + col, relLoc[1] + row - shadowDistance,
SquareType.SHADOW);
}
}
// Place this tetromino in the grid (overlaps shadow)
for (int[] relLoc : relLocs) {
grid.set(relLoc[0] + col, relLoc[1] + row, type);
}
} |
ccf658f4-d0a2-4c8d-8d53-7b3f17a5552b | 9 | private void decodeHeader(BufferedReader in, Properties pre, Properties parms, Properties header)
{
try {
// Read the request line
String inLine = in.readLine();
if (inLine == null) return;
inLine = URLDecoder.decode(inLine, "UTF-8");
StringTokenizer st = new StringTokenizer( inLine );
if ( !st.hasMoreTokens())
System.out.println("BAD REQUEST: Syntax error. Usage: GET /example/file.html" );
String method = st.nextToken();
pre.put("method", method);
if ( !st.hasMoreTokens())
System.out.println("BAD REQUEST: Missing URI. Usage: GET /example/file.html" );
String uri = st.nextToken();
// Decode parameters from the URI
int qmi = uri.indexOf( '?' );
if ( qmi >= 0 )
{
decodeParms( uri.substring( qmi+1 ), parms );
uri = decodePercent( uri.substring( 0, qmi ));
}
else uri = decodePercent(uri);
// If there's another token, it's protocol version,
// followed by HTTP headers. Ignore version but parse headers.
// NOTE: this now forces header names lowercase since they are
// case insensitive and vary by client.
if ( st.hasMoreTokens())
{
String line = in.readLine();
while ( line != null && line.trim().length() > 0 )
{
int p = line.indexOf( ':' );
if ( p >= 0 )
header.put( line.substring(0,p).trim().toLowerCase(), line.substring(p+1).trim());
line = in.readLine();
}
}
pre.put("uri", uri);
}
catch ( IOException ioe )
{
System.out.println("SERVER INTERNAL ERROR: IOException: " + ioe.getMessage());
}
} |
403671bd-51d6-4ec3-815d-9cbed7136d75 | 6 | static public Vector3f findTriangleSimplex(List<Vector3f> simplex){
Vector3f newDirection;
//A is the point added last to the simplex
Vector3f a = simplex.get(2);
Vector3f b = simplex.get(1);
Vector3f c = simplex.get(0);
Vector3f ao = Vector3f.ORIGIN.minus(a);
// The AB edge
Vector3f ab = b.minus(a);
// the AC edge
Vector3f ac = c.minus(a);
// The normal to the triangle
Vector3f abc = ab.cross(ac);
if (abc.cross(ac).sameDirection(ao)) {
// The origin is above
if (ac.sameDirection(ao)) {
simplex.clear();
simplex.add(a);
simplex.add(c);
newDirection = ac.cross(ao).cross(ac);
}
else
if (ab.sameDirection(ao)) {
simplex.clear();
simplex.add(a);
simplex.add(b);
newDirection = ab.cross(ao).cross(ab);
}
else {
simplex.clear();
simplex.add(a);
newDirection = ao;
}
}
else {
// The origin is below
if (ab.cross(abc).sameDirection(ao)) {
if (ab.sameDirection(ao)) {
simplex.clear();
simplex.add(a);
simplex.add(b);
newDirection = ab.cross(ao).cross(ab);
}
else {
simplex.clear();
simplex.add(a);
newDirection = ao;
}
}
else {
if (abc.sameDirection(ao)) {
//the simplex stays A, B, C
newDirection = abc;
}
else {
simplex.clear();
simplex.add(a);
simplex.add(c);
simplex.add(b);
newDirection = abc.negate();
}
}
}
return newDirection;
} |
17d6ac84-d993-4253-a651-bec36de09c25 | 2 | @Override
public void sorted(OutlineModel model, boolean restoring) {
if (!restoring && isFocusOwner()) {
scrollSelectionIntoView();
}
repaintView();
} |
2e10b055-8af7-41e4-abed-1dfba64b208c | 9 | public boolean create(String username, String albumname){
PreparedStatement stmt = null;
Connection conn = null;
ResultSet rs = null;
try {
conn = DbConnection.getConnection();
stmt = conn.prepareStatement(GET_UID_OWNER);
stmt.setString(1, username);
rs = stmt.executeQuery();
if (!rs.next()) {
return false;
}
int uid = rs.getInt(1);
try { stmt.close(); }
catch (Exception e) { }
Date date = new Date();
stmt = conn.prepareStatement(NEW_ALBUM_STMT);
stmt.setString(1, albumname);
stmt.setInt(2, uid);
stmt.setDate(3,new java.sql.Date(date.getTime()));
stmt.executeUpdate();
return true;
} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException(e);
} finally {
if (rs != null) {
try { rs.close(); }
catch (SQLException e) { ; }
rs = null;
}
if (stmt != null) {
try { stmt.close(); }
catch (SQLException e) { ; }
stmt = null;
}
if (conn != null) {
try { conn.close(); }
catch (SQLException e) { ; }
conn = null;
}
}
} |
858bade7-aa47-4f81-aadc-87a103f4febb | 5 | public void displaySet() {
System.out.println("");
String disSet = "";
int i = 0;
for (Case c : this.set.getCases()) {
disSet += "[";
for (Player p : this.players) {
if (p.getPosition() == c.getPosition()) disSet += "(" + p.getTurn() + ")";
}
disSet += c.getDisplay() + "]";
if ( i%20 == 17 ) {
disSet += "\n";
}
i++;
}
System.out.println(disSet);
System.out.println("");
try {
Thread.sleep(800);
} catch (InterruptedException e) {
e.printStackTrace();
}
} |
ab567775-6ae1-4ebb-a2b3-6d28accddaf6 | 5 | public static void putData(int data, int port) {
ENABLE_BIT.high();
switch (port) {
case 1:
GPIO_PORT_PINS.get(0).low();
GPIO_PORT_PINS.get(1).low();
break;
case 2:
GPIO_PORT_PINS.get(0).low();
GPIO_PORT_PINS.get(1).high();
break;
case 3:
GPIO_PORT_PINS.get(0).high();
GPIO_PORT_PINS.get(1).high();
break;
default:
}
resetPins(GPIO_DATA_PINS);
HunLogger.logger.debug("Data: {} on port: {}", data, port);
for (int i = 0; i < DATA_BITS_COUNT; i++) {
if (BigInteger.valueOf(data).testBit(i)) {
GPIO_DATA_PINS.get(i).high();
HunLogger.logger.debug("{} bit is high", i);
} else {
GPIO_DATA_PINS.get(i).low();
HunLogger.logger.debug("{} bit is low", i);
}
}
ENABLE_BIT.low();
} |
79799125-5407-4355-93b3-c4488f32e687 | 5 | Rectangle getHitBounds () {
int[] columnOrder = parent.getColumnOrder ();
int contentX = 0;
if ((parent.getStyle () & SWT.FULL_SELECTION) != 0) {
int col0index = columnOrder.length == 0 ? 0 : columnOrder [0];
if (col0index == 0) {
contentX = getContentX (0);
} else {
contentX = 0;
}
} else {
contentX = getContentX (0);
}
int width = 0;
CTableColumn[] columns = parent.columns;
if (columns.length == 0) {
width = getContentWidth (0);
} else {
/*
* If there are columns then this spans from the beginning of the receiver's column 0
* image or text to the end of either column 0 or the last column (FULL_SELECTION).
*/
CTableColumn column;
if ((parent.getStyle () & SWT.FULL_SELECTION) != 0) {
column = columns [columnOrder [columnOrder.length - 1]];
} else {
column = columns [0];
}
width = column.getX () + column.width - contentX;
}
return new Rectangle (contentX, parent.getItemY (this), width, parent.itemHeight);
} |
a2634a1b-1ea6-4fff-b34d-8453903242ef | 6 | public ListNode reverseBetween(ListNode head, int m, int n) {
if(m == n)
return head;
Stack<ListNode> stack = new Stack<ListNode>();
ListNode headNew = new ListNode(-1);
ListNode step = headNew;
ListNode index = head;
ListNode left = null;
for(int i=1;index != null && i <= n;i++){
if(i<= n && i>=m){
stack.add(index);
}else{
step.next = index;
step = step.next;
}
index = index.next;
}
left = stack.peek().next;
while(!stack.empty()){
step.next = stack.pop();
step = step.next;
}
step.next = left;
return headNew.next;
} |
4516a03f-d0b5-48c7-a24f-1a36d4db7170 | 5 | public static boolean cobreTodasTwoFlip(Coluna col1, Coluna col2, Solucao sol){
ArrayList<Integer> cobertura1 = col1.getCobertura();
ArrayList<Integer> cobertura2 = col2.getCobertura();
for(Integer entradateste1 : cobertura1){
if(!(sol.getLinhasCobertas().contains(entradateste1))){
sol.getLinhasCobertas().add(entradateste1);
}
}
for(Integer entradateste2 : cobertura2){
if(!(sol.getLinhasCobertas().contains(entradateste2))){
sol.getLinhasCobertas().add(entradateste2);
}
}
if(sol.getLinhasCobertas().size()==sol.getQtdeLinhas()){
//System.out.println("Cobertura de linhas: " + linhasCobertas.size());
return true;
}
else{
return false;
}
} |
7bad6520-76a9-4141-9334-a1d15957bc65 | 8 | public static void processLines(ArrayList<String> listaFiles, String folder) {
String[] XMLS=new String[listaFiles.size()];
int counter=1;
int iterador = 0;
for (String linea2 : listaFiles) {
System.out.println("Record "+counter+"..."+listaFiles.size());
counter++;
try {
URL url = new URL("http://catalog.hathitrust.org/Record/"+linea2+".xml");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/json");
if (conn.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ conn.getResponseCode());
}
BufferedReader br2 = new BufferedReader(new InputStreamReader(
(conn.getInputStream())));
StringBuffer output=new StringBuffer();
String LineaT=null;
while ((LineaT = br2.readLine()) != null) {
System.out.println(LineaT);
output.append(LineaT);
}
String Result=output.toString();
FileWriter fichero = null;
PrintWriter pw = null;
try
{
File D=new File("Result/"+folder+"/");
D.mkdirs();
fichero = new FileWriter("Result/"+folder+"/"+linea2+".xml");
pw = new PrintWriter(fichero);
pw.println(Result);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != fichero)
fichero.close();
} catch (Exception e2) {
e2.printStackTrace();
}
}
XMLS[iterador]=Result;
iterador++;
conn.disconnect();
} catch (Exception e3) {
System.err.println("Error en Elemento " + linea2 );
e3.printStackTrace();
}
}
try {
mainMerge(XMLS, folder);
} catch (Exception e) {
e.printStackTrace();
}
} |
d4ed6919-80f3-4bad-8e09-3f82a09bdb4b | 3 | @Override
public void mousePressed(MouseEvent evt) {
int mouseX = evt.getX();
int mouseY = evt.getY();
lastTilePressed = CheckTiles(mouseX, mouseY, evt.getButton());
if(lastTilePressed.x != -1 && lastTilePressed.y != -1)
{
if(evt.getButton() == MouseEvent.BUTTON3)
{
System.out.println("got in the if statment");
tileMenu.show(evt.getComponent(), evt.getX(), evt.getY());
}
repaint();
}
} |
be38708f-769b-47a1-bec7-fdffa2f82358 | 7 | public Map<String, List<Entry<String, List<?>>>> getValue() {
Map<String, List<Entry<String, List<?>>>> ret = new HashMap<>();
for(ICommandParser<Entry<String, List<?>>> t : parserList) {
List<Entry<String, List<?>>> valList = new ArrayList<>();
for(Entry<String,List<?>> entry : t.getValue()) {
valList.add(entry);
}
ret.put(t.getCommand(), valList);
}
return ret;
} |
ade04def-c97e-479a-86ad-f828156e74ef | 3 | public double[] subtractMean_as_double() {
double[] arrayminus = new double[length];
switch (type) {
case 1:
double meand = this.mean_as_double();
ArrayMaths amd = this.minus(meand);
arrayminus = amd.getArray_as_double();
break;
case 12:
BigDecimal meanb = this.mean_as_BigDecimal();
ArrayMaths amb = this.minus(meanb);
arrayminus = amb.getArray_as_double();
meanb = null;
break;
case 14:
throw new IllegalArgumentException("Complex cannot be converted to double");
default:
throw new IllegalArgumentException("This type number, " + type + ", should not be possible here!!!!");
}
return arrayminus;
} |
0a7b8586-bc84-4c88-915a-1168f5d340bc | 7 | public void paintComponent (Graphics g)
{
super.paintComponent (g);
// Background.
Dimension D = this.getSize ();
g.setColor (Color.white);
g.fillRect (0,0, D.width, D.height);
g.setColor (Color.black);
// Axes, bounding box.
g.drawLine (inset,D.height-inset, D.width-inset, D.height-inset);
g.drawLine (inset,inset, inset,D.height-inset);
g.drawLine (D.width-inset,inset, D.width-inset,D.height-inset);
g.drawLine (inset,inset, D.width-inset, inset);
// X-ticks and labels.
int modVal = numIntervals / 5;
for (int i=1; i<=numIntervals; i++) {
double xTickd = i*delta;
int xTick = (int) ( xTickd/(right-left) * (D.width-2*inset));
g.drawLine (inset+xTick,D.height-inset-5, inset+xTick,D.height-inset+5);
double x = left + i*delta;
if (numIntervals <= 10) {
g.drawString (df.format(x), xTick+inset-5, D.height-inset+20);
}
else if (i % modVal == 0) {
// If there are too many values, write out only 5.
g.drawString (df.format(x), xTick+inset-5, D.height-inset+20);
}
}
// Y-ticks
// First, find max.
double maxY = Double.MIN_VALUE;
for (int i=0; i<numIntervals; i++) {
if (heights[i] > maxY) {
maxY = heights[i];
}
}
// We'll make only 10 ticks.
int numYTicks = 10;
double yDelta = maxY / numYTicks;
for (int i=0; i<numYTicks; i++) {
int yTick = (i+1) * (int) ((D.height-2*inset) / (double)numYTicks);
g.drawLine (inset-5, D.height-yTick-inset, inset+5, D.height-yTick-inset);
double yValue = (i+1) * yDelta;
g.drawString (df.format(yValue), 1, D.height-yTick-inset);
}
// Finally, draw the histogram.
g.setColor (Color.blue);
for (int i=0; i<numIntervals; i++) {
int topLeftY = (int) ((heights[i] / maxY) * (D.height-2.0*inset));
double x1 = i*delta;
int topLeftX = (int) ( x1/(right-left) * (D.width-2*inset));
double x2 = (i+1)*delta;
int endX = (int) ( x2/(right-left) * (D.width-2*inset));
int barWidth = endX - topLeftX - 10;
g.fillRect (inset+topLeftX+5, D.height-topLeftY-inset, barWidth + 5, topLeftY + 5);
}
} |
8b3c53c7-52f5-460a-ba99-3ca3d95d19a1 | 0 | public void setSourceText(String sourceText)
{
_sourceText = sourceText.trim();
} |
5abf91f2-d8b2-42bb-a728-8246ede926e9 | 3 | private static void bubbleSort(int[] аrray) {
for (int i = 0; i < аrray.length; i++) {
for (int j = 1; j < аrray.length - i; j++) {
if (аrray[j - 1] > аrray[j]) {
int help = аrray[j - 1];
аrray[j - 1] = аrray[j];
аrray[j] = help;
}
}
}
} |
8198daa2-9ee3-4981-ac85-b923d7e7e799 | 5 | private void imprimirCheques() {
try{
Scanner lea = new Scanner(System.in);
System.out.print("Numero de Cuenta: ");
int nc = lea.nextInt();
if( buscarCuenta(nc) ){
if( rCuentas.readUTF().equals("CHEQUE")){
String archivo = nc + "_cheques.bac";
RandomAccessFile rCheque = new RandomAccessFile(archivo,"rw");
while(rCheque.getFilePointer() < rCheque.length() ){
int n = rCheque.readInt();
double m = rCheque.readDouble();
long f = rCheque.readLong();
boolean ca = rCheque.readBoolean();
System.out.println(n + "- Lps." + m +
(ca ? " CAMBIADO EN " : " REBOTADO EN ") +
new Date(f));
}
}
else
System.out.println("CUENTA NO ES DE CHEQUES");
}
else
System.out.println("CUENTA NO EXISTE");
}catch(IOException e){
}
} |
f0ca1290-f2eb-4975-baab-4e8c20bcf672 | 7 | private void updateComponents() {
int selectedCount = 0;
for (int i = 0; i < goodsList.getModel().getSize(); i++) {
GoodsItem gi = (GoodsItem) goodsList.getModel().getElementAt(i);
if (gi.isSelected()) selectedCount++;
}
if (selectedCount >= maxCargo) {
allButton.setEnabled(false);
for (int i = 0; i < goodsList.getModel().getSize(); i++) {
GoodsItem gi = (GoodsItem) goodsList.getModel().getElementAt(i);
if (!gi.isSelected()) gi.setEnabled(false);
}
} else {
allButton.setEnabled(true);
for (int i = 0; i < goodsList.getModel().getSize(); i++) {
GoodsItem gi = (GoodsItem) goodsList.getModel().getElementAt(i);
if (!gi.isSelected()) gi.setEnabled(true);
}
}
goodsList.repaint();
} |
86e00527-0801-4e89-8d1f-ef83d7809102 | 8 | private void destroyToolBar() {
getToolBar().removeAll();
Object o;
AbstractButton b;
for (Enumeration e = toolBarButtonGroup.getElements(); e.hasMoreElements();) {
o = e.nextElement();
if (o instanceof AbstractButton) {
b = (AbstractButton) o;
b.setAction(null);
ActionListener[] al = b.getActionListeners();
if (al != null) {
for (ActionListener l : al)
b.removeActionListener(l);
}
ItemListener[] il = b.getItemListeners();
if (il != null) {
for (ItemListener l : il)
b.removeItemListener(l);
}
MouseListener[] ml = b.getMouseListeners();
if (ml != null) {
for (MouseListener l : ml)
b.removeMouseListener(l);
}
}
}
} |
011e979b-aea0-441f-b8b1-396618c08242 | 8 | public void initFrame() {
GridBagLayout frame_layout = new GridBagLayout();
drawing = new DrawingPanel(640, 480, WORLD_WIDTH, WORLD_HEIGHT, this);
addKeyListener(this);
getContentPane().add(drawing);
side_panel = new JPanel();
side_hud_panel = new JPanel();
score_label = new JLabel("Score: " + score);
mode_label = new JLabel("Mode: " + mode);
farmed_label = new JLabel("Food: " + resources[ResourceGrid.FOOD]);
mined_label = new JLabel("Minerals: "
+ resources[ResourceGrid.MINERALS]);
side_panel.add(score_label);
side_panel.add(mode_label);
side_panel.add(farmed_label);
side_panel.add(mined_label);
side_panel.add(side_hud_panel);
side_debug_panel = new JPanel();
side_debug_panel.setLayout(new MigLayout("fill, flowY"));
side_panel.add(side_debug_panel);
side_panel.setLayout(new MigLayout("fill, flowY"));
side_hud_panel.setLayout(new MigLayout("fill, flowY"));
side_debug_panel.setLayout(new MigLayout("fill, flowY"));
final JRadioButton attract_tower_b = new JRadioButton("Attract tower");
final JRadioButton avoid_tower_b = new JRadioButton("Avoid tower");
final JRadioButton resource_grid_b = new JRadioButton("Resource grid");
final JRadioButton avoid_resources_b = new JRadioButton(
"Avoid resource");
ButtonGroup button_group = new ButtonGroup();
button_group.add(attract_tower_b);
button_group.add(avoid_tower_b);
button_group.add(resource_grid_b);
button_group.add(avoid_resources_b);
ActionListener button_listener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == attract_tower_b) {
voxels_to_draw.clear();
voxels_to_draw.add(attract_tower);
}
if (e.getSource() == avoid_tower_b) {
voxels_to_draw.clear();
voxels_to_draw.add(avoid_tower);
}
if (e.getSource() == resource_grid_b) {
voxels_to_draw.clear();
voxels_to_draw.add(resource_grid);
}
if (e.getSource() == avoid_resources_b) {
voxels_to_draw.clear();
voxels_to_draw.add(resource_grid.avoid_resources);
}
}
};
attract_tower_b.addActionListener(button_listener);
avoid_tower_b.addActionListener(button_listener);
resource_grid_b.addActionListener(button_listener);
avoid_resources_b.addActionListener(button_listener);
final JRadioButton tower_b = new JRadioButton("Spawn Tower");
final JRadioButton zombie_b = new JRadioButton("Spawn Zombie");
final JRadioButton villager_b = new JRadioButton("Spawn Villager");
button_group = new ButtonGroup();
button_group.add(tower_b);
button_group.add(zombie_b);
button_group.add(villager_b);
button_listener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == tower_b) {
addMode = ADD_TOWER;
}
if (e.getSource() == zombie_b) {
addMode = ADD_ZOMBIE;
}
if (e.getSource() == villager_b) {
addMode = ADD_VILLAGER;
}
}
};
tower_b.addActionListener(button_listener);
zombie_b.addActionListener(button_listener);
villager_b.addActionListener(button_listener);
final JCheckBox debug_b = new JCheckBox("Debug mode");
button_listener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (debug_b.isSelected()) {
mode = DEBUG_MODE;
} else
mode = NORMAL_MODE;
}
};
debug_b.addActionListener(button_listener);
side_debug_panel.add(attract_tower_b);
side_debug_panel.add(avoid_tower_b);
side_debug_panel.add(resource_grid_b);
side_debug_panel.add(avoid_resources_b);
side_debug_panel.add(debug_b);
side_debug_panel.add(tower_b);
side_debug_panel.add(zombie_b);
side_debug_panel.add(villager_b);
getContentPane().add(side_panel);
setLayout(frame_layout);
pack();
setVisible(true);
} |
30889d26-06cd-400f-996c-a8a08738ca14 | 7 | private double calcStepTemp(String stepType) {
float stepTempF = 0;
if (stepType == ACID)
stepTempF = (ACIDTMPF + GLUCANTMPF) / 2;
else if (stepType == GLUCAN)
stepTempF = (GLUCANTMPF + PROTEINTMPF) / 2;
else if (stepType == PROTEIN)
stepTempF = (PROTEINTMPF + BETATMPF) / 2;
else if (stepType == BETA)
stepTempF = (BETATMPF + ALPHATMPF) / 2;
else if (stepType == ALPHA)
stepTempF = (ALPHATMPF + MASHOUTTMPF) / 2;
else if (stepType == MASHOUT)
stepTempF = (MASHOUTTMPF + SPARGETMPF) / 2;
else if (stepType == SPARGE)
stepTempF = SPARGETMPF;
return stepTempF;
} |
6517ecbc-d47d-4743-b0fc-f535569a6ab6 | 8 | public String readLine () throws IOException {
StringBuffer buf = new StringBuffer(80);
boolean endOfLine = false;
boolean lastWasCr = false;
int bytesRead = 0;
do {
int c = read();
switch (c) {
case -1:
endOfLine = true;
break;
case '\r':
lastWasCr = true;
bytesRead++;
break;
case '\n':
bytesRead++;
if (lastWasCr) {
endOfLine = true;
} else {
buf.append((char)'\n');
}
break;
default:
bytesRead++;
if (lastWasCr) {
buf.append((char)'\r');
lastWasCr = false;
}
buf.append((char)c);
break;
}
} while (!endOfLine);
if (bytesRead == 0) {
return (null);
}
incrBytesRead(bytesRead);
String line = buf.toString();
if (line.equals(".")) {
return (null);
} else {
return (line);
}
} |
cdb4f6d3-1124-4a19-b1a5-ad3466fcb6a4 | 9 | void readProteinFileGenBank() {
FeaturesFile featuresFile = new GenBankFile(proteinFile);
for (Features features : featuresFile) {
String trIdPrev = null;
for (Feature f : features.getFeatures()) { // Find all CDS
if (f.getType() == Type.GENE) {
// Clean up trId
trIdPrev = null;
} else if (f.getType() == Type.MRNA) {
// Save trId, so that next CDS record can find it
trIdPrev = f.getTranscriptId();
} else if (f.getType() == Type.CDS) { // Add CDS 'translation' record
// Try using the transcript ID found in the previous record
String trId = trIdPrev;
if (trId == null) trId = f.getTranscriptId();
String seq = f.getAasequence();
if (debug) Gpr.debug(trId + "\t" + seq);
if ((trId != null) && (seq != null)) add(trId, seq, -1);
}
}
}
} |
97d1ca6b-dbea-474e-bf30-899f7b18fa1a | 0 | public List<PhpposSalesEntity> getMovimientosPos(){
return getHibernateTemplate().find("from PhpposSalesEntity where estadoMovimiento = 'N' ");
} |
c2b5c33b-09b0-4db3-98e5-900b28406264 | 2 | public boolean acquireLock(){
boolean success = false;
if(!isLOcked){
synchronized (this) {
if(!isLOcked){
isLOcked = true;
lockedBy = "localhost";
success = true;
String msg = "Acquire_Lock" + ":" + lockName;
manager.notifyAllRemoteListeners(new Message(msg, localhost));
}
}
}
return success;
} |
2b607389-7ab4-4de0-85f9-5581ea1c608a | 2 | @Test
public void testConcurrent()
{
final int SENDERS = 6;
final int SENDS_PER_SENDER = 100;
final int TOTAL_SENDS = SENDERS * SENDS_PER_SENDER;
final AtomicInteger sends = new AtomicInteger();
final AtomicInteger receives = new AtomicInteger();
final Signal signal = new Signal();
GroupTask.initialize(SENDERS + 1);
Runnable sender = new Runnable() {
public void run() {
for (int i = 0; i < SENDS_PER_SENDER; i++) {
signal.send();
sends.incrementAndGet();
}
}
};
Runnable reciever = new Runnable() {
public void run() {
while (receives.get() < TOTAL_SENDS) {
receives.getAndAdd(signal.receive());
}
}
};
GroupTask.add(sender, SENDERS);
GroupTask.add(reciever);
GroupTask.execute();
assertEquals( sends.get(), receives.get() );
assertEquals( TOTAL_SENDS, receives.get() );
} |
7c400721-d43c-4e28-ac0a-fbd2d4468936 | 1 | public synchronized boolean isComplete() {
return this.pieces.length > 0 &&
this.completedPieces.cardinality() == this.pieces.length;
} |
88f360ad-4cbf-4fc5-92c8-ac4e60de58b8 | 4 | private void rebalance() {
// Fictitious names for now
int leftIndex = 0;
int rightIndex = 0;
int parentIndex = getParentIndex(getParentIndex(array.getLastPosition()));
while (needRebalance()) {
leftIndex = getLeftChildIndex(parentIndex);
rightIndex = getRightChildIndex(parentIndex);
if (height(leftIndex) - height(rightIndex) > 1) {
// Left branch is two elements longer
rotateRight(parentIndex);
} else if (height(leftIndex) - height(rightIndex) < -1) {
// Right branch is two elements longer
rotateLeft(parentIndex);
}
if (parentIndex > 0) {
// If the rotation was unsuccessful, go one layer higher
parentIndex = getParentIndex(parentIndex);
} else {
rebalance();
}
}
} |
47e06a18-7e52-4541-b053-5383471fdb9b | 8 | public static OfflinePlayer requestFilePlayer(String namepart) {
OfflinePlayer requested = null;
boolean found = false;
File dir = new File("plugins/" + AdminEye.pdfFile.getName()
+ "/players/");
for (File file : dir.listFiles()) {
PlayerFile playerFile = new PlayerFile(file.getName().replaceAll(
".yml", ""));
if (namepart.equals("*")) {
requested = (Bukkit.getOfflinePlayer(playerFile.playerName) != null ? Bukkit
.getOfflinePlayer(playerFile.playerName) : null);
found = (requested != null ? true : false);
} else if (playerFile.playerName.toLowerCase().contains(
namepart.toLowerCase())) {
requested = (Bukkit.getOfflinePlayer(playerFile.playerName) != null ? Bukkit
.getOfflinePlayer(playerFile.playerName) : null);
found = (requested != null ? true : false);
}
}
return (found ? requested : null);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.