text stringlengths 14 410k | label int32 0 9 |
|---|---|
public Path optimizePath(Path path, int[][] distances) {
// int[][] distances = distanceHolder.distances;
Node[] nodes = path.nodes;
Path newPath = null;
int skipped = 0;
double bestDistance = 10000000; //path.distance;
double newDistance = Integer.MAX_VALUE;
double diff = 10000;
// outerloop: do {
... | 9 |
protected int getVersionIndex(String romId) {
switch (romId) {
case "B4WJ0":
return 0;
case "B4BJ0":
return 1;
case "B4WE0":
return 2;
case "B4WP0":
return 3;
case "B4BE0":
return 4;
case "B4BP0":
return 5;
case "B4WJ1":
return 6;
//case "B4BJ1":
// return 7;
... | 7 |
private synchronized void pulse(){
for(int i = 0; i < peerList.size();i++){
Peer p = peerList.get(i);
if(!checkPulse(p)){//if it has no pulse, it's dead
disconnect(p);
}
}
} | 2 |
public boolean checkcheck(Board b){
aiarr=b.getBoardArray();
for(int x=0;x<8;x++){
for(int y=0;y<8;y++){
if(aiarr[x][y].toString().charAt(0)==color && aiarr[x][y].toString().charAt(1)=='K' && isThreatened(new Point(x,y))){
System.out.println("CHECK");
//checkCheckmate(b,x,y);
return true;
... | 5 |
private final String getChunk(String s, int slength, int marker)
{
StringBuilder chunk = new StringBuilder();
char c = s.charAt(marker);
chunk.append(c);
marker++;
if (isDigit(c))
{
while (marker < slength)
{
c = s.charAt(marker... | 5 |
private void playSound(){
if (cSound.getModel().isSelected()) {
if(status.getChangedServerList().size() > 0)
alarm.play();
}
} | 2 |
public static void main(String[] args) {
if (args.length < 3) {
System.out.println("Simple Web Crawler");
System.out.println("Usage:");
System.out.println("First argument: page URL e.g. http://example.com");
System.out.println("Second argument: number of pages to ... | 7 |
private boolean validateInput(Move theMove, Board board)
{
if (theMove == null || board == null) {
throw new IllegalArgumentException("Move or Board were null");
}
if (!(theMove instanceof ConnectFourMove))
{
throw new IllegalArgumentException("Wrong move type");
}
if (boardColumns != board.getColumn... | 8 |
synchronized public void quitterVoie(Train train){
train.setVenteOuverte(false);
if(train.listeVoyageurIsEmpty()){
listeTrainQuai.remove(train);
System.out.println( train.getNomTrain() +" quitte gare");
}
voiesDispo++;
// Pour les trains en attente d'un qu... | 1 |
public static void main(String[] args) {
WrapCheckedException wce = new WrapCheckedException();
for(int i = 0; i < 3; i++) {
try {
if(i < 3) {
wce.throwRuntimeException(i);
} else {
throw new RuntimeException();
... | 6 |
public static String checkSum(String f) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
DigestInputStream ds = new DigestInputStream(
new FileInputStream(f), md);
byte[] b = new byte[512];
while (ds.read(b) != -1)
;
String computed = "";
for(byte v : md.digest())
computed... | 5 |
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof AttributeStorageLevel)) {
return false;
}
AttributeStorageLevel other = (AttributeStorageLevel) object;
if ((th... | 5 |
public void paint(Graphics g) {
super.paint(g);
if (ingame) {
Graphics2D g2d = (Graphics2D)g;
if (craft.isVisible())
g2d.drawImage(craft.getImage(), craft.getX(), craft.getY(),
this);
ArrayList ms = craft.getMissiles()... | 5 |
public Double compute(User u) {
Integer correct = u.get("correct");
Integer questions = u.get("questions");
if(questions == 0)
return 1.0;
else
return correct / (double) questions;
} | 1 |
public boolean addNewSportsBooking(ArrayList<SportsBooking> sb1, Connection conn) throws SQLException {
int rowsInserted = 0;
try {
String SQLString = "insert into sportsBooking values (?,?,?,to_timestamp(?),?)";
PreparedStatement statement = null;
statement = conn.pr... | 3 |
public void eseguiSimulazioneDoppiaCPU() {
/* Inizializzazione vettore. */
ArrayList<Double> tempiUscitaMedi = new ArrayList<Double>();
/* Cicla sui job. */
for (int i = passo ; i <= jobTotali ; i += passo) {
/* Cicla sui run. */
for (int j = 1 ; j <= run ; j++... | 4 |
@Override
public void putAll( MultiMap< ? extends K, ? extends V > map )
{
// Get iterator to map's entry set
Iterator< ? extends Map.Entry< ? extends K, ? extends V > > it = null;
try
{
it = map.entrySet().iterator();
}
catch( Throwa... | 9 |
private ArrayList<NonDuplicateArrayList<String>> getKSubset(NonDuplicateArrayList<String> set, int k){
/*
// recursive approach
// ref: http://stackoverflow.com/questions/4504974/how-to-iteratively-generate-k-elements-subsets-from-a-set-of-size-n-in-java
ArrayList<NonDuplicateArrayList<Integer>> subsets = new A... | 8 |
@Override
public void mutate(){
TspPopulation offspring = new TspPopulation();
for (int i = 0; i < population.getSize(); ++i){
double r;
synchronized (rng){
r = rng.nextDouble();
}
if (r < PROBABILITY){
TspIndividual mut... | 8 |
private void writeTag(ByteQueue queue, int tagNumber, boolean classTag, long length) {
int classValue = classTag ? 8 : 0;
if (length < 0 || length > 0x100000000l)
throw new IllegalArgumentException("Invalid length: " + length);
boolean extendedTag = tagNumber > 14;
if (len... | 8 |
private void actionInterested (String key, OutputStream out) throws IOException {
Object o = _hash.get(key);
if (o != null){
Fichier f = (Fichier)o;
if (_estMisAssertion)
System.out.println("On me demande mon fichier " + key);
String reponse = "have " + key + " ";
int i;
boolean[] masque =... | 5 |
public void setValueAt(int numSample, int numChannel, Object value)
{
boolean channelAdded = false;
boolean valueAdded = false;
if (numSample < 0 || numChannel < 0) return;
//Locate the channel
while (numChannel >= channelsValues.size()){
//Add empty vectors until the desired channel
channelsValues.... | 7 |
public ProxyDynamicSubject(Object obj)
{
this.obj = obj;
} | 0 |
void showdetail() {
int max =0;
ArrayList<Integer[]> scorelist0 = new ArrayList<Integer[]>();
ArrayList<Integer[]> scorelist1 = new ArrayList<Integer[]>();
for (int i=0; i<size*size-1; i++) {
if (grid[i].value>max) {
max = grid[i].value;
... | 9 |
public static int columnIndex(CSTable table, String name) {
for (int i = 1; i <= table.getColumnCount(); i++) {
if (table.getColumnName(i).equals(name)) {
return i;
}
}
return -1;
} | 2 |
void run(){
Scanner sc = new Scanner(System.in);
for(boolean h = true;;h=false){
n = sc.nextInt(); m = sc.nextInt();
if((n|m)==0)break;
if(!h)System.out.println();
Map<String, Integer> ref = new HashMap<String, Integer>();
String[] s = new String[n];
for(int i=0;i<n;i++){
s[i] = sc.next();
... | 9 |
private void init(int numRowsOfPieces) {
for (int i = 0; i < SIZE; i++) {
//Adds red checkers.
for (int j = 0; j < numRowsOfPieces; j++)
if ((i + j) % 2 == 1)
pieces.add(new RedChecker(i, j));
//Adds blue checkers
for (int j = SIZE - numRowsOfPieces; j < SIZE; j++)
if ((i + j) % 2 =... | 5 |
public boolean taskExists(Task task){
for (Task t : tasks){
if (t.equals(task)){
return true;
}
}
return false;
} | 2 |
public void checkDeclaration(Set declareSet) {
if (instr instanceof StoreInstruction
&& (((StoreInstruction) instr).getLValue() instanceof LocalStoreOperator)) {
StoreInstruction storeOp = (StoreInstruction) instr;
LocalInfo local = ((LocalStoreOperator) storeOp.getLValue())
.getLocalInfo();
if (dec... | 3 |
public void sendMessage(Message m, String url)
{
try {
IMessageReceivedHandler stub = (IMessageReceivedHandler) java.rmi.Naming.lookup("rmi://"+registry+":1099/"+url);
stub.onMessageReceived(m);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace()... | 3 |
public static void setLongLE(final byte[] array, final int index, final long value, final int size) {
switch (size) {
case 0:
return;
case 1:
Bytes.setInt1(array, index, (int)value);
break;
case 2:
Bytes.setInt2LE(array, index, (int)value);
break;
case 3:
Bytes.setInt3LE(array, index... | 9 |
float getMeasurement(int[] countPlusIndices) {
float value = Float.NaN;
if (countPlusIndices == null)
return value;
int count = countPlusIndices[0];
if (count < 2)
return value;
for (int i = count; --i >= 0;)
if (countPlusIndices[i + 1] < 0) {
return value;
}
switch (count) {
case 2:
va... | 7 |
private static double slowCos(final double x, final double result[]) {
final double xs[] = new double[2];
final double ys[] = new double[2];
final double facts[] = new double[2];
final double as[] = new double[2];
split(x, xs);
ys[0] = ys[1] = 0.0;
for (int i = ... | 4 |
public static void main(String[] args) {
EntityManagerFactory entityManagerFactory= Persistence.createEntityManagerFactory("introducaojpa_pu");
EntityManager entityManager = entityManagerFactory.createEntityManager();
Scanner scanner = new Scanner(System.in);
Banda banda;
for(int i = 0;i<2;i++ ){
b... | 1 |
public void destroy() {
removeAll();
removeNotify();
setIcon(null);
renderer = null;
} | 0 |
public StringTemplate getAbandonEducationMessage(boolean checkStudent) {
if (!(getLocation() instanceof WorkLocation)) return null;
boolean teacher = getStudent() != null;
boolean student = checkStudent && getTeacher() != null;
if (!teacher && !student) return null;
Building sch... | 6 |
public final String encode(final K[] plain) {
String crypt = "";
for (K symbol : plain) {
crypt += this.symbols.get(symbol);
}
return crypt;
} | 1 |
public void set(int symbol, int freq) {
checkSymbolInRange(symbol);
if (freq < 0)
throw new IllegalArgumentException("Negative symbol frequency");
freqTable.set(symbol, freq);
} | 1 |
public Object success(NullParamFn<? extends Object> fn) {
return this.suc ? fn.fn() : null;
} | 2 |
public void run()
{
while (true)
{
try
{
sleep(delay);
}
catch (InterruptedException e)
{
}
objectPool.reapObjects();
}
} | 2 |
private static void parseTraces(final JsonNode rootNode, final TraceRelationshipBuilder<Integer> builder) throws IOException
{
for (JsonNode traceNode : getField(rootNode, JsonTraceCodec.TRACES))
{
final int traceId = getIntField(traceNode, JsonTraceCodec.TRACE_ID);
final String name = getTextFiel... | 9 |
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof PieDataset)) {
return false;
}
PieDataset that = (PieDataset) obj;
int count = getItemCount();
if (that.getItemCount() != count) {
retur... | 8 |
public static boolean getAutoConnect(){ return AutoConnect; } | 0 |
private static boolean isOnlyDoubleByteKanji(String content) {
byte[] bytes;
try {
bytes = content.getBytes("Shift_JIS");
} catch (UnsupportedEncodingException uee) {
return false;
}
int length = bytes.length;
if (length % 2 != 0) {
return false;
}
for (int i = 0; i < l... | 7 |
@RequestMapping(value = {"/CuentaBancaria/{idCuentaBancaria}/MovimientosBancarios"}, method = RequestMethod.GET)
public void readMovimientosPorCuenta(HttpServletRequest httpRequest, HttpServletResponse httpServletResponse, @PathVariable("idCuentaBancaria") String idCuentaBancaria) {
try {
Object... | 2 |
public KeyboardListener() {
keyMapper = new KeyMapper();
keyStates = new boolean[MAX_KEY];
} | 0 |
public static void main(String[] args) {
// TODO Auto-generated method stub
String sr_ip;
int sr_port;
if (args.length < 3)
{
System.out.println("Wrong arguments, Format: java examples/TestServer <ip of S_Registry> <port of S_Registry> <port of this Server>");
return;
}
sr_ip = args[0];
try
{
... | 6 |
public void run() {
// Adjust sleeping time to avoid too small times
double sampleInterval = DESIRED_INTERVAL;
double execInterval = sampleInterval / mySpeed;
if (execInterval < MINIMUM_INTERVAL) {
execInterval = MINIMUM_INTERVAL;
sampleInterval = MINIMUM_INTERVAL * mySpeed;
}
try {
long t = 0... | 4 |
public boolean chocaElPardalet(float px, float py, float pw, float ph) {
//System.out.println(py+" "+yEspacio);
if(px>x+getW()){
System.out.println("estem a lesquerra");
}
if(px+pw<x) System.out.println("estem a la dreta");
if(px+pw>x) System.out.println("Dreta: "+px+" "+pw+", "+x);
if(py>yEspacio+yEs... | 6 |
public static void reset()
{
step = 0;
actors.clear();
populate();
if(CUSTOM_DEPTH>0 && CUSTOM_WIDTH>0 && CUSTOM_DEPTH <=100 && CUSTOM_WIDTH <=100) {
field.setField(CUSTOM_DEPTH, CUSTOM_WIDTH);
view.getSim().getView().changeView(CUSTOM_DEPTH,CUSTOM_WIDTH);
... | 4 |
public void convert(String input, String output, Formats inputFileformat, int lineCount) throws IOException {
// we save the parameter in the class fields
this.input = input;
this.output = output;
this.lineCount = lineCount;
// we create an object fro writing the output file
writer = new BufferedWrite... | 5 |
public void loadLibrary() {
try {
BufferedReader br = new BufferedReader(new FileReader("./ivJava.ini"));
String line = "";
while ((line = br.readLine()) != null) {
if (line.length() > 0) {
int index = line.indexOf("LoadLibrary=");
if (index >= 0) {
String Library = line.substring(index +... | 5 |
public static int[] lcp(int[] sa) {
int n = sa.length;
int[] rank = new int[n];
for (int i = 0; i < n; i++)
rank[sa[i]] = i;
int[] lcp = new int[n - 1];
for (int i = 0, h = 0; i < n; i++) {
if (rank[i] < n - 1) {
for (int j = sa[rank[i] + 1]; Math.max(i, j) + h < cad.length
&& cad[i + h] == ca... | 6 |
private void initializeWithABC() {
l.insert(c);
l.insert(b);
l.insert(a);
} | 0 |
public static void main(String[] args) {
if (args.length != 1 || args[0].charAt(0) != '-') {
usage();
return;
}
try {
// Create the modeler/solver object
IloCplex cplex = new IloCplex();
IloNumVar[][] var = new IloNumVar[1][];
IloRange[][] rng = new IloRange[1][];
// Evaluate command line ... | 9 |
public void update() {
time++;
if (time >= 7400) time = 0;
if (time > life) remove();
za -= 0.1;
if (zz < 0) {
zz = 0;
za *= -0.55;
xa *= 0.4;
ya *= 0.4;
}
move(xx + xa, (yy + ya) + (zz + za));
} | 3 |
private void postPlugin(final boolean isPing) throws IOException
{
// The plugin's description file containg all of the plugin data such as
// name, version, author, etc
final PluginDescriptionFile description = plugin.getDescription();
// Construct the post data
final StringBuilder data = new StringBuilde... | 9 |
private String buildBar() {
// Collecting information about the bar length
int every = 100 / BAR_DEPTH;
int bars = approx_progress / every;
int subDepth = BAR_DEPTH / 2;
// Creating the array of character corresponding to the percentage of
// completion
char a[] = new char[BAR_DEPTH];
if (bars > BAR_DE... | 3 |
private void jTextField9KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField9KeyPressed
if (evt.getKeyCode() == 38) {
jTextField7.grabFocus();
} else if (evt.getKeyCode() == 40) {
jTextField8.grabFocus();
} else if (evt.getKeyCode() == 39) {
jRadioButton1.grabFocus... | 3 |
public final void interfaces() throws RecognitionException {
try {
// fontes/g/CanecaSemantico.g:216:2: ( ^( INTERFACE_ modificadorDeAcessoFeminino IDENTIFICADOR listaDeTiposGenericos listaDeInterfaces corpoDaInterface ) )
// fontes/g/CanecaSemantico.g:216:4: ^( INTERFACE_ modificadorDeA... | 9 |
private int checkRegEx(String result) {
if(result == null || result.isEmpty()) return 0;
result = result.toLowerCase();
String regEx1 = "[2-9][p-z][a-h][2-9][a-z]*[p-z][2-9][p-z][2-9][p-z]";
String regEx2 = "[2-9][p-z][p-z][a-h][2-9][a-z]*[p-z][2-9][2-9][2-9][p-z]";
if(result.mat... | 4 |
public String getName(){
return name;
} | 0 |
public void keyPressed(KeyEvent arg0)
{
int keyCode = arg0.getKeyCode();
if(keyCode == KeyEvent.VK_ENTER)
{
name = inputName.getText();
for(int i = 0; i < name.length(); i++)
{
if(name.charAt(i) == ' ' && i < name.length() - 1)
{
name = name.sub... | 9 |
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://down... | 6 |
private void connectLocal(DcServer server, DCStation station) {
DummyChannel chA = new DummyChannel(), chB = new DummyChannel();
Connection c1 = new DummyConnection(chA.getInputStream(), chB.getOutputStream(), station);
Connection c2 = new DummyConnection(chB.getInputStream(), chA.getOutputStream(), server);
st... | 0 |
public static void conversationthread() throws Exception {
while (worker1) {
java.sql.Connection conn = DbController.dbconnect();
conv = DbController.getconversation(conn, m_loggedas);
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
... | 7 |
public int Execute(PolishProgram program) throws Exception
{
// execute the command.
// returns -10 - standard running
// returns label in goto - in case the command was goto
// returns -1 - in case there is a runtime error
int expressionVal = -1;
switch (m_Type)
{
case Assignment:
{
expressio... | 9 |
public static World initWorld( ResourceContext rc ) throws IOException {
final DemoBlocks blocks = DemoBlocks.load(rc);
final GenericPhysicalNonTileInternals crateInternals = getCrateInternals(rc);
final SubstanceContainerInternals fuelCanInternals = getFuelCanInternals(rc);
int worldSizePower = 24;
int... | 5 |
@Override
public Clock deepCopy() {
VectorClock newClock = new VectorClock();
newClock.hostName = this.hostName;
for (String key : this.clock.keySet()) {
newClock.clock.put(key, this.clock.get(key));
}
return newClock;
} | 1 |
public static Stella_Object accessTruthValueSlotValue(TruthValue self, Symbol slotname, Stella_Object value, boolean setvalueP) {
if (slotname == Logic.SYM_LOGIC_POLARITY) {
if (setvalueP) {
self.polarity = ((Keyword)(value));
}
else {
value = self.polarity;
}
}
else ... | 7 |
public HomeScreen(Market m, User u) {
setPreferredSize(new Dimension(1000, 650)); // set it to the same size as the container
setLayout(null); // it will be a card in the main deck
setBackground(Color.black);
// From MainFrame
market = m;
user = u;
// Set up the home label
homeLabel = new JLabel("<html> <h1> ... | 3 |
private static void hasRole() throws Exception {
UserDAO ud = new UserDAO();
RoleDAO rd = new RoleDAO();
Role role = (Role) rd.findById(2);
User user = (User) ud.findById(2);
boolean itHasRole = ud.hasRole(role, user);
if (itHasRole == true) {
System.out.print... | 1 |
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
try {
commands.execute(cmd.getName(), args, sender, sender);
} catch (CommandPermissionsException e) {
sender.sendMessage(ChatColor.RED + "You don't have permission.");
} catch (Mis... | 6 |
@Override
public Object filter(PropertyContainer container, Object value) {
return value;
} | 0 |
@Override
public void handle(HttpExchange exchange) throws IOException {
System.out.println("In rob player handler");
String responseMessage = "";
if(exchange.getRequestMethod().toLowerCase().equals("post")) {
try {
//TODO verify cookie method
String unvalidatedCookie = exchange.getRequestHeade... | 5 |
public UIForm toUIForm(String heading) {
if (null == heading)
throw new IllegalArgumentException();
if (_menu.size() < 1)
throw new IllegalStateException();
UIForm.Pair[] array = new UIForm.Pair[_menu.size()];
for (int i = 0; i < _menu.size(); i++)
array[i] = _menu.get(i);
return n... | 3 |
@Override
public Map<UUID, String> call() throws Exception {
Map<UUID, String> uuidStringMap = new HashMap<UUID, String>();
for (UUID uuid : uuids) {
HttpURLConnection
connection =
(HttpURLConnection) new URL(PROFILE_URL + uuid.toString().replace("-", ""))
.openConnecti... | 4 |
public static void main(String[] args) throws InvalidFormatException, IOException, ClassNotFoundException, InterruptedException {
InputStream is = new FileInputStream( "en-pos-maxent.bin" );
setModel( new POSModel( is ) );
//use sockets?
System.out.print("USE SOCKETS? ");
boolean useSockets = scan.next... | 5 |
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
fcSkin = new javax.swing.JFileChooser();
grbLogin = new javax.swing.JPanel();
lblUsername = new javax.swing.JLabel();
txtUsern... | 3 |
public void addClassAnalyzer(ClassAnalyzer clazzAna) {
if (innerAnalyzers == null)
innerAnalyzers = new Vector();
innerAnalyzers.addElement(clazzAna);
getParent().addClassAnalyzer(clazzAna);
} | 1 |
@Override
public void run() {
while (true) {
repaint();
try {
Thread.sleep(10);
} catch (InterruptedException e) {
}
frame++;
}
} | 2 |
@Override
protected boolean doDelete(final String key) {
boolean ok = client.delete(key);
if (!ok) {
CacheErrorHandler.handleError(new Exception("Memcached:删除缓存Key[" + key + "]对应的对象失败"));
}
return ok;
} | 1 |
public void askActionType(List<String> actions) {
System.out.println(this.texts.get("actionType"));
String result = "";
for (int i = 0; i < actions.size(); i++) {
result += "\t[" + (i + 1) + "]\t" + actions.get(i) + "\n";
}
System.out.println(result);
String rep = "";
int indexRep = -1;
boolean e... | 5 |
@Override
public int processMessage(String msg) {
System.out.println(msg);
String[] action = msg.trim().split(":");
if(!action[0].equals(tabPlayer[currentPlayer].getId()))
return -2;
if (action[1].equals("MOVEB")) {
if(moveB(tabPlayer[currentPlayer].getColor(), action[2], action[3]))
return 0;
els... | 6 |
public static boolean chooseSave() {
JFileChooser cho = new JFileChooser(file);
cho.setFileSelectionMode(JFileChooser.FILES_ONLY);
FileFilter emu = new FileFilter(){{}
@Override
public boolean accept(File f) {
if (f.isDirectory())
return true;
String ext = getExtension(f);
if (ext != null) {
... | 6 |
public boolean isOptOut() {
synchronized (optOutLock) {
try {
// Reload the metrics file
configuration.load(getConfigFile());
} catch (IOException ex) {
if (debug) {
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.g... | 4 |
public String getTrainNumber() {
return this._trainNumber;
} | 0 |
@Override
public Object solve() {
int max = 0;
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 20; j++) {
for (Direction d : Direction.values()) {
if (isAValidDirection(d, i, j)) {
int val = calculateProduct(d, i, j);
... | 5 |
public boolean isPrime(long num) {
if (num%2 == 0) {
return false;
}
for (int i = 3; i*i <= num; i+=2) {
if (num % i == 0) {
return false;
}
}
return true;
} | 3 |
public void pause() {
for (ConnectionProcessor pipe : pipes) {
pipe.pause();
}
} | 1 |
public static ArrayList<Excel> rotateX(int angle, ArrayList<Excel> toScale)
{
ArrayList<Excel> result = new ArrayList<Excel>();
double matrix[][] = { {1, 0,0,0},
{0, Math.cos(angle * Math.PI/180), Math.sin(angle* Math.PI/180), 0},
{0,(-Math.sin(angle* Math.PI/180)), Math.cos(angle* Math.... | 1 |
public void broadcast(String broadcastMessage){
Iterator<DCBroadcastReceiver> it = dCBroadcasterSubscribers.iterator();
while(it.hasNext()) {
DCBroadcastReceiver subscriber = it.next();
if (subscriber==null) {
it.remove();
} else {
subs... | 2 |
static void checkMethodSignature(final String signature) {
// MethodTypeSignature:
// FormalTypeParameters? ( TypeSignature* ) ( TypeSignature | V ) (
// ^ClassTypeSignature | ^TypeVariableSignature )*
int pos = 0;
if (getChar(signature, 0) == '<') {
pos = checkFormalTypeParameters(signature, pos);
}
... | 6 |
public void addHability(Ability ability) {
if(!this.abilitiesListed.contains(ability.getName())) {
buttons[cur].setAbility(ability);
buttons[cur].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
selectedAbility = ((AbilityButton)e.getSource()).getAbility();
own... | 1 |
private void setOutputFormatNumeric() {
if (m_Indices == null) {
setOutputFormat(null);
return;
}
FastVector newAtts;
int newClassIndex;
StringBuffer attributeName;
Instances outputFormat;
FastVector vals;
// Compute new attributes
newClassIndex = getInputFormat().clas... | 9 |
private Object genRandom(Class<?> clazz) {
Object rand = null;
if (clazz == Boolean.class) {
rand = random.nextBoolean();
} else if (clazz == Integer.class) {
rand = random.nextInt();
} else if (clazz == Long.class) {
rand = random.nextLong();
} else if (clazz == Double.class) {
rand = random.ne... | 8 |
static boolean isThereAStraight(Hand hand){
//first check for ace low straight
if (hand.get(0).getValue() == 2 && hand.get(1).getValue() == 3 && hand.get(2).getValue() == 4 && hand.get(3).getValue() == 5 && hand.get(4).getValue() == 14)
return true;
for(int x = 0; x < hand.size()-1 ; x++) // look for... | 7 |
MainWindow() {
this.setLayout(new BorderLayout());
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(WINDOW_DEFAULT_WIDTH, WINDOW_DEFAULT_HEIGTH);
this.setTitle(WINDOW_TITLE);
this.setMinimumSize(new Dimension(WINDOW_MIN_WIDTH, WINDOW_MIN_HEIGTH));
fram... | 3 |
public String getCountry() {
return super.getCountry();
} | 0 |
public int check() {
if (columns < 3 || rows < 3) {
return 1;
} else if (timesteps < 1) {
return 2;
} else if (constantK <= 0 || constantK > 1) {
return 3;
} else if (timesteps > 100) {
return 4;
} else if (rows * columns > 3600) {
... | 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.