text stringlengths 14 410k | label int32 0 9 |
|---|---|
private void checkFlush() {
for (int i = 0; i < 4; i++) {
if (getNumberOfSuits(i) == 5) {
myEvaluation[0] = 6;
myEvaluation[1] = hand[0].getValue();
myEvaluation[2] = hand[4].getValue();
myEvaluation[3] = hand[0].getValue();
break;
}
}
} | 2 |
private static void quickSort(ArrayList<PERange> array, int start, int end) {
int i = start; // index of left-to-right scan
int k = end; // index of right-to-left scan
if (end - start >= 1) {
PERange pivot = array.get(start);
while (k > i) {
while (array.get(i).getBegin() <= pivot.getBegin()
... | 9 |
public static int getGreatesProdDownRightDiagonal(int[][] arr, int maxDigits, int columns, int rows) {
int prod = 0;
for(int i = 0; i < (rows-(maxDigits - 1)); i++) {
int tmp = 0;
for(int j = 0; j < (columns-(maxDigits-1)); j++) {
int tmpprod = 1;
for(int k = 0; k < maxDigits; k++) {
tmpprod = tm... | 4 |
public static void removeLibrary(Class<?> libraryClass)
throws SoundSystemException {
if (libraries == null || libraryClass == null)
return;
libraries.remove(libraryClass);
} | 3 |
public static void main(String[] args) throws Exception {
String filename = args[0].trim().equals("") ? "A.txt"
: args[0];
Scanner inp = new Scanner(new java.io.File(filename));
System.out.println("Lecture de données :" + filename);
init(inp);
tour();
if... | 4 |
public void replaceTransition(Transition oldTrans, Transition newTrans) {
if (!getTransitionClass().isInstance(newTrans)) {
throw new IncompatibleTransitionException();
}
if (oldTrans.equals(newTrans)) {
return;
}
if (transitions.contains(newTrans)) {
removeTransition(oldTrans);
return;
}
if (... | 4 |
public void checkUp(Node node) {
this.up = -1; // reset value to -1
// Prevent out of bounds (negative coordinates)
if((node.getX()-1) >= 0) {
if(checkWall(new Node( (node.getX()-1), (node.getY()) ))) {
if(this.closedNodes.size()==0)
this.up = 1;
else {
for(int i = 0; i < this.closedNodes.siz... | 5 |
private void initializeTextFields() {
mNameHeading = new JTextField();
mNameHeading.setBounds(478, 22, 491, 14);
panel.add(mNameHeading);
mNameHeading.setEnabled(false);
mNameHeading.setForeground(new Color(0, 0, 0));
mNameHeading.setText("NAME");
mNameHeading.setToolTipText("");
mNameHeading.setEdit... | 9 |
public static void drawObjects(Graphics g){
if (left)
xs -= 1;
else if (right)
xs += 1;
if (up)
ys -= 1;
else if (down)
ys += 1;
if (drag){
checkMouse();
}
g.setColor(PlatformManager.floorColor);
// draw dynamic objects
for (Rectangle p : platforms)
g.fillRect(p.x - xs, p.y - ys,... | 8 |
@Override
protected void decode( ChannelHandlerContext ctx, ByteBuf in, List<Object> out ) throws Exception
{
int byteSize = in.readableBytes();
if(byteSize == 0 || !ctx.channel().isOpen())
return;
int id = Utils.readVarInt(in);
int conState = ctx.channel().attr(Utils.connectionState).get();
switch(c... | 6 |
public static void CDC_pairwise(CDCRelation p, boolean connected)
{
int count=0;
//int[] c = new int[511]; //counters
int i,j;
//first we calculate all the valid CDC relations, stored in valid_rel[]
List<CDCRelation> valid_rel = new ArrayList<CDCRelation>();
CDCRelation r = new CDCRelation(0);
r.connect... | 6 |
public static boolean export2FormatedJsonFiles(final String date, final String[] labels, final String[] labelsStat, final String text){
//Check if skip creating file
if( labels.length == 0 && (text == null || text.trim().length() == 0) ){
return true;
}
final String checked ... | 8 |
public static long convertToLong(String addr) throws Exception {
String[] octs = addr.split("\\.");
if( octs.length != 4 ){
throw new Exception("Invalid address format.");
}
long octA = Long.parseLong(octs[0]);
long octB = Long.parseLong(octs[1]);
long octC ... | 9 |
public void expand() {
computedIntervals++;
Interval interval = q.poll();
double a = interval.a;
double b = interval.b;
double mid = (a + b) / 2;
Interval interval1 = new Interval( a, mid, p, usedFormula );
Interval interval2 = new Interval( mid, b, p, usedFormula );
if ( (!interval1.sing... | 6 |
public int getEnemiesLasersOnField(){
int enemyLaserCount = 0;
for(Enemy enemy : munchkins){
if(enemy != null){
for(int i = 0; i < enemy.lasers.length; i++){
if(enemy.lasers[i] != null){
enemyLaserCount++;
}
}
}
}
for(Enemy enemy : ufos){
if(enemy != null){
for(int i =... | 8 |
public void limpiarBD() {
Query personas = actualizador.verificarConexion().createQuery("Select persona from Persona persona");
List<Persona> idsPersona = personas.getResultList();
for (Persona persona : idsPersona) {
actualizador.bajaDePersona(persona.getCi());
}
Que... | 4 |
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ParkBoy other = (ParkBoy) obj;
if (code == null) {
if (other.code != null)
return false;
} else if (!code.equals(other.code))
return ... | 6 |
private int jjMoveStringLiteralDfa1_0(long active0)
{
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(0, active0);
return 1;
}
switch(curChar)
{
case 32:
return jjMoveStringLiteralDfa2_0(active0, 0x40L);
case 104:
... | 6 |
public static void fillIslands() {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
Index index = new Index(i, j);
stack.push(index);
String tempPath = "";
int tempWeight = 0;
while (!stack.isEmpty()) {
index = stack.pop();
if (islands[index.getRow()][index.getCol()] > 0) ... | 8 |
private void populateCyrillicComboBoxes()
{
DefaultComboBoxModel cyrillicCapitalLetterComboBoxModel
= new DefaultComboBoxModel();
// Add the standard Cyrillic (Russian) characters to the combo
for (int i = 0x0410; i < 0x042F; i++ )
{
char a = (ch... | 3 |
TranslationFinder(Elements subSectionTitles, Document document) {
Elements transArray = document.getElementsByAttributeValueContaining("data-destinationLanguage", "אנגלית");
this.JSONTransArray = new JSONArray();
for (Element translation : transArray) {
this.JSONTransArray.put(tran... | 9 |
public float setBand(int band, float neweq)
{
float eq = 0.0f;
if ((band>=0) && (band<BANDS))
{
eq = settings[band];
settings[band] = limit(neweq);
}
return eq;
} | 2 |
private void init() {
JPanel content = new JPanel();
content.setLayout(new BorderLayout());
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BorderLayout());
JPanel spacerPanel = new JPanel();
spacerPanel.setLayout(new GridLayout());
if (m_allowAdd) {
JButton addButton = n... | 4 |
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Map other = (Map) obj;
if (this.noOfRows != other.noOfRows) {
return false;
}
... | 4 |
@Override
public QuadTree getQuadTree(){
if (QT == null) {
initDataStructure();
}
return QT;
} | 1 |
private void randomizeBackground(Background background) {
int j = 256;
for(int k = 0; k < anIntArray1190.length; k++)
anIntArray1190[k] = 0;
for(int l = 0; l < 5000; l++) {
int i1 = (int)(Math.random() * 128D * (double)j);
anIntArray1190[i1] = (int)(Math.random() * 256D);
}
for(int j1 = 0; j1 < 20; ... | 9 |
protected static Ptg calcCount( Ptg[] operands )
{
int count = 0;
for( Ptg operand : operands )
{
Ptg[] pref = operand.getComponents(); // optimized -- do it once!! -jm
if( pref != null )
{ // it is some sort of range
for( Ptg aPref : pref )
{
Object o = aPref.getValue();
if( o != null... | 7 |
public void testFilteredDocIdSet() throws Exception {
final int maxdoc=10;
final DocIdSet innerSet = new DocIdSet() {
@Override
public DocIdSetIterator iterator() {
return new DocIdSetIterator() {
int docid = -1;
@Override
public int d... | 6 |
public static Homework_database read(int value) {
Homework_database homeworkreturn = null;
{
try {
RandomAccessFile raf = new RandomAccessFile(login_area.setURL.getUrl(), "rw");
raf.seek(raf.length());
raf.seek(538*value);
Timetable_main_EDIT.delete = raf.read();
raf.seek(ra... | 3 |
private static String getArrayTableName(String tableName, String field) {
return tableName + "_" + field;
} | 0 |
public void testPropertyPlusNoWrapHour() {
LocalTime test = new LocalTime(10, 20, 30, 40);
LocalTime copy = test.hourOfDay().addNoWrapToCopy(9);
check(test, 10, 20, 30, 40);
check(copy, 19, 20, 30, 40);
copy = test.hourOfDay().addNoWrapToCopy(0);
check(copy, 10, ... | 2 |
@Override
public <T extends Comparable<? super T>> int search(T[] array, T key) {
if (array == null)
throw new NullPointerException("argument array is null");
if (key == null)
throw new NullPointerException("argument key is null");
// Make sure every element is not n... | 9 |
public void resize() {
int image[] = new int[trimWidth * trimHeight];
for (int offY = 0; offY < height; offY++) {
for (int offX = 0; offX < width; offX++) {
image[(offY + offsetY) * trimWidth + (offX + offsetX)] = pixels[offY * width + offX];
}
}
pixels = image;
width = trimWidth;
height = trimHei... | 2 |
public void save(String filename) {
File file = new File(filename);
String suffix = filename.substring(filename.lastIndexOf('.') + 1);
// png files
if (suffix.toLowerCase().equals("png")) {
try { ImageIO.write(offscreenImage, suffix, file); }
catch (IOException e... | 4 |
@Override
protected void process(List<RegistrationState> l) {
for (RegistrationState ls : l) {
if (ls.isSuccess) {
this.cp.setVisible(false);
JOptionPane.showMessageDialog(cp, "Username successfully registered", "Success", JOptionPane.INFORMATION_... | 2 |
public SwingWorker() {
final Runnable doFinished = new Runnable() {
public void run() { finished(); }
};
Runnable doConstruct = new Runnable() {
public void run() {
try {
setValue(construct());
} catch (Exception e) {
... | 1 |
public void setFloors(int value) {
if (value <= 0) {
throw new IllegalArgumentException(
"Illegal number of floors, must be positive");
} else {
floors = value;
weight = calculateTotalWeight();
}
} | 1 |
public void update(double delta) {
frameCount++;
if(frameCount >= program.framerate) {
secondFlash = !secondFlash;
frameCount = 0;
}
//Camera Zoom
canvas.camera.zoom(Input.getMouseScroll() / 10.0);
if(canvas.camera.getScale() < maxZoom) canvas.camera.setScale(maxZoom);
if(canvas.camera.getSca... | 7 |
public static void main(String[] args) {
// Exercício 03
Scanner entrada = new Scanner(System.in); // Esse é o Sacanner que captura dados do teclado. Para utilizá-lo é preciso importar a classe java.util.Scanner
System.out.println("Digite um número: "); // Perguntamos um número...o programa vai ... | 7 |
public boolean canUpdate(long isbn, Book b, Statement st, ResultSet rs) throws SQLException {
//Check if any authors will be left without a book.
ArrayList<Author> leftAuth = getAuthors(isbn, st, rs);
if(b.getAuthor() != null)
leftAuth.removeAll(b.getAuthor());
//Test if any authors that are left out are onl... | 6 |
public boolean remove_special(String s,String p,String o,String s_type,String o_type)
{ String ret;
deb_print("<remove_special>\n");
deb_print("Perform the QUERY\n");
ret = queryRDF( s.equals("*")?null:s
,p.equals("*")?null:p
,o.equals("*")?null:o
,s_type
,o_type);
deb_print("KP-CORE MESSA... | 8 |
public static LinkedList<File[]> recursiveConfigs(File folder, boolean rec) {
LinkedList<File[]> files = new LinkedList<File[]>();
if(folder.exists() && folder.isDirectory()) {
for(File f : folder.listFiles()){
if(f.isFile()){
if(f.getName().endsWith(".pc")) {
files.add(new File[]{f});
}
... | 9 |
private static int[] getNeighbours(ImageData imageData, int mx, int my, int y, int x) {
int x0 = x - 1;
int y0 = y - 1;
int x2 = x + 1;
int y2 = y + 1;
x0 = x0 < 0 ? 0 : x0;
x2 = x2 > mx ? mx : x2;
y0 = y0 < 0 ? 0 : y0;
y2 = y2 > my ? my : y2;
int[] pixels = new int[9];
pixels[0] = imageData.getPixe... | 4 |
public void simulate() throws IOException{
System.out.format("### %s ###\n",heuristic.type.toString());
boolean moreLinesToRead = true;
if (debug_f)
print_debug_header();
while (true) {
commit();
issue();
... | 6 |
protected Color getNodeColor(TreeNode node) {
return isSelected(node) ? selectedColor : deselectedColor;
// Color color = super.getNodeColor(node);
// return isSelected(node) ? color.darker() : color;
} | 1 |
@RequestMapping(value = "/sign_in")
public String custVerification(Model m,HttpServletRequest request, HttpServletResponse response,HttpSession session)
{
String username = request.getParameter("custID");
System.out.println("Customer user name : "+username);
String password = request.getParameter("password");
... | 3 |
public boolean isSolid(float x, float y) {
if (x < 0 || x / tileSize >= width || y < 0 || y / tileSize >= height)
return false;
return getTileSolid(tiles[(int) (x / tileSize) + (int) (y / tileSize)
* width]);
} | 4 |
boolean anyResultMatches(String transcriptId, Variant seqChange, ChangeEffects changeEffects, boolean useShort) {
for (ChangeEffect chEff : changeEffects) {
String resStr = chEff.toStringSimple(useShort);
Transcript tr = chEff.getTranscript();
if (tr != null) {
if ((transcriptId == null) || (transcriptI... | 6 |
public static void main (String args[]) {
Map<String, String> map = new HashMap();
fillData(map);
String[] strings = keysAsArray(map);
for (String string : strings) {
System.out.println(string);
}
System.out.println("");
List<String> list = keysAsLis... | 2 |
public void render(Graphics2D g2d) {
g2d.drawImage(image, (int) x, (int) y, null);
if (x < 0) g2d.drawImage(image, (int) x + Game.WIDTH, (int) y, null);
else if (x > 0) g2d.drawImage(image, (int) x - Game.WIDTH, (int) y, null);
} | 2 |
@Override
public void doAction(String value) {
char choice = value.toUpperCase().charAt(0);
do {
switch (choice) {
case 'M':
return;
case 'D':
System.out.println("You are not carrying any logs");
... | 5 |
public int run(){
sort(array);
return 0;
} | 0 |
public static void makeCompactGrid(Container parent,
int rows, int cols,
int initialX, int initialY,
int xPad, int yPad) {
SpringLayout layout;
try {
layout = (SpringLayout)pa... | 7 |
public static void main(String[] args) {
if(args.length >= 1) {
try {
int servers = Integer.parseInt(args[0]);
String mIP = (args.length >= 2) ? args[1] : "239.23.12.11";
InetAddress address = InetAddress.getByName(mIP);
int basePort = ... | 7 |
public ArrayList<Integer> checkCollisions() {
ArrayList<Integer> ints = new ArrayList<Integer>();
for (Rectangle r : getGame().getCollisionRecs()) {
if (new Rectangle((int) (getBounds().x + 10 - getVeloX()), getBounds().y + 14, getBounds().width - 20,
getBounds().height - 14).intersects(r))
ints.add(1);... | 4 |
public void setVar(PVar node)
{
if(this._var_ != null)
{
this._var_.parent(null);
}
if(node != null)
{
if(node.parent() != null)
{
node.parent().removeChild(node);
}
node.parent(this);
}
... | 3 |
public static long[] calculatePalette(long[] colors, int numBuckets) {
ArrayList<Bucket> buckets = new ArrayList<>();
Bucket initialBucket = new Bucket();
for (long color : colors)
initialBucket.add(color);
buckets.add(initialBucket);
while (buckets.size() < numBuckets) {
int maxI = -1;... | 6 |
public void showCards() {
playercards = GameData.CURRENT_PLAYER.getPlayerCards();
for (int i = 0; i < playercards.size(); i++) {
if (i == 0) {
cardone.setBounds(10, 10, 125, 195);
cardone.setIcon(playercards.get(i).getCardIcon());
} else if (i == 1) {
cardtwo.setBounds(135, 10, 125, 195);
... | 7 |
public void testGetCars() {
TimeServer ts = new TimeServerLinked();
VehicleAcceptor r = new VehicleAcceptorObj();
Vehicle c = VehicleFactory.newCar(ts, r);
r.accept(c);
Assert.assertTrue(r.getCars().size() == 1);
Assert.assertTrue(c.equals(r.getCars().get(0)));
for (int i=0;i<10;i++) {
r.ac... | 2 |
public int getFileCount(int idx) throws Exception{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs =null;
int result = 0;
try{
conn = getConnection();
pstmt = conn.prepareStatement("select count(*) from board where idx=?");
pstmt.setInt(1, idx);
rs = pstmt.executeQuery();
i... | 8 |
@Override
public void unInvoke()
{
if(canBeUninvoked())
{
if(affected instanceof MOB)
{
final MOB mob=(MOB)affected;
final Room room = CMLib.map().getRoom(fromRoom);
final int direction=this.direction;
if((messedUp)||(direction<0)||(fromRoom==null))
{
commonTell(mob,L("You've ruined... | 7 |
public void doCommand(String messageData, String nick) {
String[] str = messageData.split(" ");
for (int i = 0; i < commands.size(); i++) {
if (str[0].startsWith(commands.get(i).getName())) {
if (commands.get(i).userNeedsToBeOp()
&& ServerMain.uh.isOp(nick)) {
try {
ServerMain.EVENT_BUS.post... | 9 |
protected double[][] calculateAssociationMatrix() {
if( this.associationMatrix != null)
return this.associationMatrix;
if( this.clusterizedTrajectories == null)
throw new RuntimeException("Error: impossible calculates the association matrix after the final calculation call");
NodeIndexing nodeIndexing... | 7 |
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof TransformedIterator<?, ?>)) {
return false;
}
TransformedIterator<?, ?> that = (TransformedIterator<?, ?>) obj;
return function.equals(that.fun... | 9 |
private void updateGate(String A, String B, String C, String D, String E, String Y) throws InvalidPinException {
if (this.isLow(A) && this.isLow(B) && this.isLow(C) && this.isLow(D) && this.isLow(E)) {
this.setPin(Y, Pin.PinState.HIGH);
} else {
this.setPin(Y, Pin.PinState.LOW);
}
} | 5 |
@Override
public void onMouseMove(MouseMoveEvent event) {
if (supportsTouchEvents) {
return;
}
Widget sender = (Widget) event.getSource();
Element elem = sender.getElement();
// TODO optimize for the fact that elem is at (0,0)
int x = event.getRelativeX(elem);
int y = event.getRelati... | 9 |
private static Location newLocation(Player player, Location loc,
BorderData border, boolean notify) {
if (Config.Debug()) {
Config.LogWarn((notify ? "Border crossing" : "Check was run")
+ " in \"" + loc.getWorld().getName() + "\". Border "
+ border.toString());
Config.LogWarn("Player position X: "
... | 6 |
public void setTempo(int hora, int minuto, int segundo) {
setHora(hora);
setMinuto(minuto);
setSegundo(segundo);
} | 0 |
public int getArticleCount(int area) throws Exception{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs =null;
int result = 0;
try{
conn = getConnection();
pstmt = conn.prepareStatement("select count(*) from travel where area=?");
pstmt.setInt(1, area);
rs = pstmt.executeQuery(... | 8 |
private void findUser(SessionRequestContent request) throws ServletLogicException {
Criteria criteria = new Criteria();
criteria.addParam(DAO_ID_USER, request.getParameter(JSP_SELECT_ID));
User user = (User) request.getSessionAttribute(JSP_USER);
if (user != null) {
ClientTy... | 4 |
public void setStatus(SeanceStatus status) {
if (status == null) {
throw new IllegalArgumentException("Status shouldn't be NULL");
}
this.status = status;
} | 1 |
private String lireFichier(String chemin_ficher) throws FileNotFoundException, IOException {
contenu_fichier = new StringBuilder() ;
f = new File(chemin_ficher) ;
if(!f.getName().endsWith(".plic"))
throw new ArrayIndexOutOfBoundsException() ;
BufferedReader b = new BufferedRe... | 2 |
public RaiseTilter() {
requires(Robot.tilter);
} | 0 |
private void checkScoutValidity(StrategyBoard gameBoard, PlayerColor currentTurn, PieceType movePiece,
Location moveFromLocation, Location moveToLocation) throws StrategyException
{
final int distance = moveFromLocation.distanceTo(moveToLocation);
if (gameBoard.getPieceAt(moveToLocation) != null && distance... | 9 |
private void calculateLineHeight() {
lineHeight = maxAscent = 0;
// Each token style.
for (int i=0; i<syntaxScheme.getStyleCount(); i++) {
Style ss = syntaxScheme.getStyle(i);
if (ss!=null && ss.font!=null) {
FontMetrics fm = getFontMetrics(ss.font);
int height = fm.getHeight();
if (height>lin... | 7 |
public static void main(String[] args) throws Exception
{
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(
"c:\\temp\\SimulatedSpuriousCorrelationsAllGaussian.txt")));
writer.write("category\tabundant1\tlow1\tlow2\tresampledAbundnat1\tresampledLow1\tresampledLow2\tresampledRatio1\tresample... | 7 |
public void buffmsg(Message msg) {
String name = msg.string().intern();
synchronized (buffs) {
if (name == "clear") {
buffs.clear();
} else if (name == "set") {
int id = msg.int32();
Indir<Resource> res = sess.getres(msg.uint16());
... | 5 |
public void run()
{
if (player!=null)
{
try
{
player.play();
}
catch (JavaLayerException ex)
{
System.err.println("Problem playing audio: "+ex);
}
}
} | 2 |
protected void addOutsidersAndTimers(Faction F, Vector<Faction.FactionChangeEvent> outSiders, Vector<Faction.FactionChangeEvent> timers)
{
Faction.FactionChangeEvent[] CEs=null;
CEs=F.getChangeEvents("ADDOUTSIDER");
if(CEs!=null)
{
for (final FactionChangeEvent ce : CEs)
outSiders.addElement(ce);
}
... | 7 |
@Override
public void caseAMethodCallExp(AMethodCallExp node)
{
for(int i=0;i<indent;i++) System.out.print(" ");
indent++;
System.out.print("(Call [ ");
System.out.print(node.getIdentifier());
System.out.println(" ]");
inAMethodCallExp(node);
if(node.getHexp() != n... | 8 |
private void nextGeneration() {
boolean someSelected = false;
for (int i = 0; i < generators.size(); i++)
if (generators.get(i).isSelected()) {
gaPop.setIndividualFitness(i, 1);
generators.get(i).deselect();
someSelected = true;
}
if (someSelected) {
if (!goBackButton.isEnabled())
goBack... | 4 |
public static SampleSet generateSamples(final int length) {
SampleSet set = new SampleSet();
//
int size = 1 << length;
boolean[] data = new boolean[length];
//
for (int i = 0; i < size; i++) {
Sample s = new Sample(1, length, 1, 1);
//
... | 4 |
@Override
public void restoreCurrentToDefault() {cur = new Color(def.getRGB());} | 0 |
public MainFrame() {
super("Hello World");
setLayout(new BorderLayout());
lista = new ArrayList<FormEvent>();
btn = new JButton("Click me");
textPanel = new TextPanel();
formPanel = new FormPanel();
toolbar = new Toolbar();
dbl = new DatabaseLayer();
toolbar.setArrayList(lista);
toolbar.se... | 3 |
public boolean start() {
synchronized (optOutLock) {
// Did we opt out?
if (isOptOut()) {
return false;
}
// Is metrics already running?
if (task != null) {
return true;
}
// Begin hitting the s... | 6 |
public void update() {
removeAll();
HighSeas highSeas = getMyPlayer().getHighSeas();
if (highSeas != null) {
for (Unit unit : highSeas.getUnitList()) {
boolean belongs;
if (destination instanceof Europe) {
... | 8 |
public boolean Salvar(Venda obj) {
try {
if (obj.getId() == 0) {
PreparedStatement comando = bd.getConexao().prepareStatement("insert into vendas(funcionario,cliente,pagamento,data_venda,total,status) values(?,?,?,?,?,?)");
comando.setInt(1, obj.getAtendente().getId()... | 4 |
private Move getMinMove(StateTree tree) throws Exception
{
if (tree.isLeaf()) {
return new Move(
tree.getMove(),
tree.getScore());
}
Move minMove = null;
for (StateTree successor : tree.getSuccessors()) {
Move move = this.getMaxMove(successor);
if (minMove == null || move.getScore() < min... | 4 |
@EventHandler
public void PigZombiePoison(EntityDamageByEntityEvent event) {
Entity e = event.getEntity();
Entity damager = event.getDamager();
String world = e.getWorld().getName();
boolean dodged = false;
Random random = new Random();
double randomChance = plugin.getPigZombieConfig().getDouble("PigZombie... | 6 |
private double f(double b) {
double PrB=1, p=probLessThan(b);
for (int i = 0; i < futureBowls; i++) {
PrB*=p;
}
double PrA=1-PrB;
double ExA=exptGreaterThan(b);
double ExB=exptLessThan(b);
double Ex2=PrA*ExA+PrB*ExB;
return Ex2;
} | 1 |
static String getPlatformFont() {
if(SWT.getPlatform() == "win32") {
return "Arial";
} else if (SWT.getPlatform() == "motif") {
return "Helvetica";
} else if (SWT.getPlatform() == "gtk") {
return "Baekmuk Batang";
} else if (SWT.getPlatform() == "carbon") {
return "Arial";
} else { // photon, etc ...
... | 4 |
int insertKeyRehash(short val, int index, int hash, byte state) {
// compute the double hash
final int length = _set.length;
int probe = 1 + (hash % (length - 2));
final int loopIndex = index;
int firstRemoved = -1;
/**
* Look ... | 9 |
public void updateLabels(){ //sets all the new labels depending on the board configuration
int value;
int index = 0;
switch (gameMode) { //set labels differently depending on the game mode
case "normal" :
for (int r = 0; r < 4; r++) //labels will be counted left to right, up to down
for (int c = 0; c ... | 9 |
@Override
public String execute() throws Exception {
try {
session = ActionContext.getContext().getSession();
User u1 = (User) session.get("User");
if (existpass.isEmpty()) {
addActionError("Please Enter existing password");
return "error";... | 5 |
public String toQString() {
StringBuffer str = new StringBuffer();
for (int i = 0; i < FIELD_NAME.length; ++i) {
if (get(FIELD_NAME[i]) == null || get(FIELD_NAME[i]).equals(""))
continue;
if (i != 0)
str.append("&");
try {
str.append(FIELD_NAME[i] + "="
+ URLEncoder.encode(get(FIELD_NAM... | 5 |
public static CitationRecord read(InputStream is) throws IOException
{
CitationRecord rec=new CitationRecord();
String file=LabnoteUtil.readStreamToString(is);
String[] lines=file.split("\\r\\n");
LinkedList<String> nlines=new LinkedList<String>();
for(String s:lines)
nlines.add(s);
while(!nlines... | 9 |
public ClusterNode getParent() {
return this.parent;
} | 0 |
public static Document readResourceDocument(Class<?> c, String name) {
Document doc = null;
InputStream is = null;
try {
is = c.getResourceAsStream(name);
DocumentBuilder db = XMLUtils.newDocumentBuilder(false);
doc = db.parse(is);
} catch (SAXExc... | 5 |
private static int loadTexture(String fileName)
{
String[] splitArray = fileName.split("\\.");
@SuppressWarnings("unused")
String ext = splitArray[splitArray.length - 1];
try
{
BufferedImage image = ImageIO.read(new File("./res/textures/" + fileName));
boo... | 4 |
public List<String> getValidationErrors() {
List<String> errors = new ArrayList<String>();
if (customerId == null || customerId.length() == 0) errors.add("Customer ID is required");
if (username == null || username.length() == 0) errors.add("Customer username is required");
... | 7 |
Subsets and Splits
SQL Console for giganticode/java-cmpx-v1
The query retrieves a limited number of text entries within a specific length range, providing basic filtering but minimal analytical insight.