text stringlengths 14 410k | label int32 0 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 |
public void keyTyped(KeyEvent e) {
} | 0 |
public static void doMultiThreadTest(String host, int txn, int threads) {
int eachUnitCount = txn/threads;
final LoadTest ltu[] = new LoadTest[threads];
for(int i=0;i<threads;i++) {
ltu[i] = new LoadTest("Test-"+i, host, eachUnitCount, threads);
ltu[i].setUp();
}
Thread threadPool[] = new Thread[thr... | 7 |
private void searchPropietarioTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_searchPropietarioTextKeyPressed
cList = taller.searchClientes(searchPropietarioText.getText());
clientsModel.clear();
for(int i=0; i<cList.size(); ++i){
clientsModel.addElement(cList.get(i).g... | 1 |
private float buscar(String nombreAntecedente, String etiquetaRegla,File archivo) throws FileNotFoundException, IOException
{
RandomAccessFile raf = new RandomAccessFile(archivo, "rw");
char temp[] = new char[15];
String variable = null;
String etiqueta = null;
... | 5 |
private void actionOk( )
{
int m = acceptanceList.length;
for ( int i = 0; i < m; ++i )
acceptanceList[i] = eigenValueCB[i].isSelected();
state = State.OKAY;
setVisible(false);
} | 1 |
public synchronized String invoke( String endpoint, Serializable request ) throws IOException {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpPost post = new HttpPost(endpoint);
post.setHeader("Content-Type", "application/json");
Gson gson = new Gso... | 2 |
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!(obj instanceof Node<?>))
return false;
Node<?> other = (Node<?>) obj;
return this.getElem() == other.getElem()
&& this.getNext() == other.getNext();
} | 6 |
@Test
public void testPerformanceEdgeCount() throws FileNotFoundException
{
final OrdinaryCluster cl = new OrdinaryCluster(null, 0.5);
cl.setGroundTruthIndex(0);
final Random random = new Random();
final int numRuns = 1;
final int numQueries = 1000000;
final int maxSize = (int) 1e4;
final int stepsPerDe... | 6 |
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
if (firstname != null ? !firstname.equals(user.firstname) : user.firstname != null) return false;
if (lastname != null ? !lastname.equals(user.... | 7 |
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Card other = (Card) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;... | 6 |
synchronized public static org.omg.CORBA.TypeCode type ()
{
if (__typeCode == null)
{
__typeCode = pgrid.service.corba.PeerReferenceHelper.type ();
__typeCode = org.omg.CORBA.ORB.init ().create_sequence_tc (0, __typeCode);
__typeCode = org.omg.CORBA.ORB.init ().create_alias_tc (pgrid.service... | 1 |
public void check() {
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
if (check1(i, j) || check2(i, j) || check3(i, j)
|| check4(i, j)) {
int tmp = getMatrix(i, j);
System.out.println("Player " + tmp + " wins.");
return;
}
}
}
System.out.println("No player wins... | 6 |
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
GenericTreeNode<?> other = (GenericTreeNode<?>) obj;
... | 8 |
@Override
public void confirm(String mail, Integer... workshopIds) {
File tempFile = new File(file.getAbsolutePath() + ".tmp");
try (BufferedReader br = new BufferedReader(new FileReader(file)); PrintWriter pw = new PrintWriter(new FileWriter(tempFile), true)) {
String line;
... | 9 |
public IautosSellerInfo getSeller() {
return seller;
} | 0 |
public static NearbyPlace toNearbyPlace(RequestBean request, PFPAd ad)
throws CitysearchException {
NearbyPlace nearbyPlace = new NearbyPlace();
String adUnitIdentifier = request.getAdUnitIdentifier();
StringBuilder nameLengthProp = new StringBuilder(adUnitIdentifier);
name... | 7 |
public void showdown(int currentPlayer, ArrayList<Card> holeCards, ArrayList<Card> sharedCards) throws Exception {
for (OpponentEntry entry : histories.get(currentPlayer).getHistory()) {
double handStrength;
if(entry.getStage() == STAGE.PREFLOP) {
handStrength = preFlops.get(entry.getNumberOfPlayers() - 2).... | 2 |
public boolean containsValue(Object value)
{
if (value == null) return containsNullValue();
Entry[] tab = this.table;
for (int i = 0; i < tab.length; i++)
for (Entry e = tab[i]; e != null; e = e.next)
if (value.equals(e.value)) return true;
return false;
} | 4 |
public PeerManager(int portNumber, Tracker tracker, String flag){
port = portNumber;
this.tracker = tracker;
this.flag = flag;
downloading = false;
peerList = new ArrayList<Peer>(MAX_PEERS);
th = this.tracker.getTorrentHandler();
th.setPeerManager(this);
if(flag.equals("")){
peerCheck = new Thread... | 5 |
@Override
public void destroy () {
assert (pipe == null);
// If there's still a pending linger timer, remove it.
if (has_linger_timer) {
io_object.cancel_timer (linger_timer_id);
has_linger_timer = false;
}
// Close the engine.
if (engine !... | 2 |
public static void printDifferentElements(int[] arr1, int[] arr2) {
int[] biggerArray;
int[] smallerArray;
int n;
if(arr1.length > arr2.length) {
biggerArray = arr1;
smallerArray = arr2;
n = arr2.length;
}
else {
biggerArray = arr2;
smallerArray = arr1;
n = arr1.length;
}
int count = 0... | 6 |
public void connect(String connection_id, Properties prop)
throws Exception {
if (connection_id == null || connection_id.trim().equals(""))
throw new Exception("Cannot connect to empty database identifier.");
String dump = prop.getProperty(connection_id);
if (dump == null) throw new Exception("Database ide... | 5 |
public static Node hasCycle(Node head) {
Node slow = head;
Node fast = head;
while (slow != null && slow.next != null && fast != null
&& fast.next != null && fast.next.next != null) {
slow = slow.next;
fast = fast.next.next;
if (slow == fast) ... | 9 |
public void UpdateGame(long gameTime, Point mousePosition) {
// Move the car
playerCar.Update();
movingBg.Update();
enemyCar.Update(playerCar.getSpeedY(), passedPoint[2]);
for (int i = 0; i < courseList.size(); i++) {
courseList.get(i).Update(playerCar.getSpeedY(), p... | 2 |
public void sendTo(CommandSender target, int pageNumber) throws InvalidMenuException, NoPageException, InvalidPageException{
validate();
Page page = getPage(pageNumber);
page.validate();
StringBuilder header = new StringBuilder();
if(usePrefix){
header.append(prefix);
if(!prefix.endsWith(" ")){
head... | 4 |
@Override
void update() {
countDown--;
if (countDown < 0) remove = true;
int index = ImageManager.EXPLOSION_SPRITES - 1 - (int) (countDown / LENGTH_MULTIPLIER);
if (SCALE == 1) painter.drawImage(ImageManager.EXPLOSION[index], (int) x, (int) y, null);
else {
... | 2 |
public DynFactory(Class<? extends Sprite> cl) {
this.cl = cl;
} | 1 |
private void viewTabStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_viewTabStateChanged
String agcoopLoan = "maininterface.ViewLoan";
String agcoopMember = "maininterface.ViewMember";
String agcoopCompany = "maininterface.ViewCompany";
String agcoopSupplier = "maininterfa... | 6 |
public boolean delete(Usuarios u){
PreparedStatement ps;
try {
ps = mycon.prepareStatement("DELETE FROM Usuarios WHERE codigo=?");
ps.setString(1, u.getCodigo());
return (ps.executeUpdate()>0);
} catch (SQLException ex) {
Logger.getLogger(UsuariosC... | 1 |
void readBlock() throws IOException {
if (_streamEndWasReached) {
return;
}
while (true) {
int size = (0 - _bufferOffset) + _blockSize - _streamPos;
if (size == 0) {
return;
}
int numReadBytes = _stream.read(_bufferBase,... | 6 |
public boolean checkBox (int row, int col) {
int i = 0, j = 0, k = 0, count = 0;
/* Uses nested for loops to check the entries */
for (k = 1; k < 10; k++) {
for (i = row; i < row+3; i++) {
for (j = col; j < col+3; j++) {
count = 0;
if (k == Integer.parseInt(entries[i][j].getText())) {
... | 5 |
public void sort(T[] a, int lo, int hi)
{ // Sort a[lo..hi].
if (hi <= lo)
return;
int mid = lo + (hi - lo) / 2;
sort(a, lo, mid); // Sort left half.
sort(a, mid + 1, hi); // Sort right half.
merge(a, lo, mid, hi); // Merge results (code on page 271).
} | 1 |
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
for (int i = 0; i < n; i++) {
start.add(new Node(i));
finish.add(new Node(i));
}
int m = s.nextInt(); //количество рёбер
if (m == 0) {
System.out.println(n);
return;
}
while (m-- > 0) {
in... | 8 |
public void render(){
glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
switch(page){
case 0:
renderMainPage();
break;
case 1:
renderHowToPage();
break;
}
} | 2 |
@Test
public void resolve() {
long MAX=Long.MAX_VALUE;
int max=0;
for(long i=1, s=1;s<MAX; s=sum(++i)){
//print(i, s);
Set<Integer> divisors=new HashSet<Integer>();
for(int j=1;j<Math.sqrt(s)+1; j++){
if(s%j==0){
divisors.add(j);
divisors.add((int) (s/j));
}
}
max=Math.max(max, d... | 4 |
public <S> S getService(Bundle bundle, ServiceReference<S> ref)
{
UsageCount usage = null;
Object svcObj = null;
// Get the service registration.
ServiceRegistrationImpl<S> reg =
((ServiceRegistrationImpl.ServiceReferenceImpl) ref).getRegistration();
synchronize... | 9 |
public static void readFile(Map<Integer, UserPreferences> mapUP ,Map<Integer, ItemPreferences> mapIT ) throws FileNotFoundException{
File file = new File("u.data");
Scanner sc = new Scanner(file);
while(sc.hasNextLine()){
StringTokenizer st = new StringTokenizer(sc.nextLine(), "\t");
int userId = Integer.p... | 3 |
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MyRectangle rectangle = (MyRectangle) o;
return Double.compare(rectangle.h, h) == 0
&& Double.compare(rectangle.r, r) == 0
... | 7 |
public CollisionSolverThread(ActorSet actors, int start, int stride){
if(stride <= 0 || start < 0)
throw new IllegalArgumentException("CollisionSolverThread: Stride must be positive");
this.actors = actors;
this.stride = stride;
this.start = start;
} | 2 |
public static int[] add(int[] number1, int[] number2) {
int num1Len = number1.length;
int num2Len = number2.length;
int[] result = (num1Len>num2Len)?new int[num1Len+1]:new int[num2Len+1];
int carry = 0;
int i=1;
for(;i<=num1Len&&i<=num2Len;i++) {
int currIdx1 = num1Len-i;
int currIdx2 = num2Len-i;
... | 9 |
public JSONObject toJSONObject(JSONArray names) throws JSONException {
if (names == null || names.length() == 0 || this.length() == 0) {
return null;
}
JSONObject jo = new JSONObject();
for (int i = 0; i < names.length(); i += 1) {
jo.put(names.getString(i), this.... | 4 |
public Circle2D(Point2D _center, double _radius) {
center = _center;
radius = _radius;
} | 0 |
public String getContentType() {
return contentType;
} | 0 |
void getFetInfo(String arr[], String n) {
arr[0] = ((pnp == -1) ? "p-" : "n-") + n;
arr[0] += " (Vt = " + getVoltageText(pnp * vt) + ")";
arr[1] = ((pnp == 1) ? "Ids = " : "Isd = ") + getCurrentText(ids);
arr[2] = "Vgs = " + getVoltageText(volts[0] - volts[pnp == -1 ? 2 : 1]);
ar... | 6 |
public int getSize() {
// the size is in byte 0 of 'off' for primitive types (buf == null)
return buf == null ? (off & 0xFF) : 1;
} | 1 |
public void onKeyPressed(KeyEvent e) {
switch (e.getKeyCode()) {
case VK_UP:
case VK_W:
// Arrow up key: move direction = forward (infinitely)
moveDirection = 1;
moveAmount = Double.POSITIVE_INFINITY;
break;
case VK_DOWN:
case VK_S:
// Arrow down key: move direction = backward (infinitely)
... | 8 |
public String getAlgorithm() {
return algorithm;
} | 0 |
public void restoreOps(Object s) {
Stack state = (Stack) s;
while (!state.isEmpty()) {
int penalty = ((Integer) state.pop()).intValue();
startOp(DONT_BREAK, penalty);
}
} | 1 |
@Override
public int hashCode() {
int prime = 31;
int prime1 = 37;
int prime2 = 41;
int prime3 = 43;
int rId = recordId;
int nIId = imageId;
int tFId = fieldId;
int tRNum = rowNumber;
int tVal;
if (rId == 0) {
rId =... | 5 |
*/
public void destroyInferenceProblemStoreByName(final String name) throws IOException, CycApiException {
//// Preconditions
if (name == null) {
throw new NullPointerException("name must not be null");
}
if (name.length() == 0) {
throw new IllegalArgumentException("name must not be an emp... | 2 |
public int hashCode() {
return (int)(5 *((milky == null) ? 0 : milky.hashCode()));
} | 1 |
private void createWindow (JFrame f){
final JComboBox categoryList= new JComboBox(categoryStrings); //initiate drop down lists
final JComboBox ratingList= new JComboBox(ratings);
final JComboBox yearList= new JComboBox(years);
final JComboBox pageList= new JComboBox(pages);
fin... | 9 |
public static <V> Set<Rectangle> drawSector(Node<V> node, BufferedImage image, int w, int h, int s, int d)
{
Set<Rectangle> result = new HashSet<Rectangle>();
Graphics2D graphics = image.createGraphics();
Rectangle rect = node.nodeRect;
if (node.color) {
gra... | 3 |
public static List<SystemObject> getObjects(String objectSpecString, DataModel dataModel) throws IllegalArgumentException {
List<SystemObject> allObjects = new LinkedList<SystemObject>();
String[] objectSpecs = objectSpecString.split(",");
for(int specIndex = 0; specIndex < objectSpecs.length; ++specIndex) {
L... | 9 |
@Override
public List<ValidateException> validate(String parameter) {
final int maxFirstNameLength = 30;
List<ValidateException> validateExceptionList = new LinkedList<>();
if (!ValidateUtils.stringMaxLengthValidation(parameter, maxFirstNameLength)) {
String exMsg = "entered qui... | 1 |
final public void Elif_statement() throws ParseException {
/*@bgen(jjtree) Elif_statement */
SimpleNode jjtn000 = new SimpleNode(JJTELIF_STATEMENT);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
jjtn000.jjtSetFirstToken(getToken(1));
try {
jj_consume_token(ELIF);
... | 8 |
protected boolean setArmorModel(EntityPlayer var1, int var2, float var3) {
ItemStack var4 = var1.inventory.armorItemInSlot(3 - var2);
if(var4 != null) {
Item var5 = var4.getItem();
if(var5 instanceof ItemArmor) {
ItemArmor var6 = (ItemArmor)var5;
this.loadTexture("/... | 7 |
public Number addNumbers(Number a, Number b)
throws NumberClassNotFoundException {
Number sum = null;
if (a instanceof Double && b instanceof Double) {
sum = new Double(roundDouble(a.doubleValue() + b.doubleValue()));
// trimNumber(sum);
} else if (a instanceof Integer && b ... | 8 |
public static Object decodeToObject( String encodedObject )
{
// Decode and gunzip if necessary
byte[] objBytes = decode( encodedObject );
java.io.ByteArrayInputStream bais = null;
java.io.ObjectInputStream ois = null;
Object obj = null;
try
... | 4 |
public int getNumberOfPoints(){
return numberOfPoints;
} | 0 |
public void initOccupy(Scene s){
if(main.dayTime>=Main.NIGHT_TIME && spawnType==SpawnType.CIVILIAN)
spawnType = SpawnType.NIGHTER;
else if(main.dayTime<Main.NIGHT_TIME && spawnType==SpawnType.NIGHTER)
spawnType = SpawnType.CIVILIAN;
int toSpawn = (int)(Math.random()*(3) +1);
for(int i = 0; i<toSpawn; i... | 7 |
static void configure() throws NumberFormatException, IOException {
textArea.append("In order to analyze your keystroke, you will be required to " +
"enter you password a certain amount of times to gather data.\n");
delay(1000);
textArea.append("You must enter you password at least five times.\n");
delay(15... | 9 |
private void buildVerticalRoads() {
_verticalRoads = new VehicleAcceptor[_gridDimensions.getColumn()][_gridDimensions.getRow()+1];
//[column][row]
for (int j=0; j<_gridDimensions.getColumn(); j++) {
for (int i=0; i<=_gridDimensions.getRow(); i++) {
VehicleAcceptor l = VehicleAcceptorFactory.newR... | 2 |
public void TempPlayers(){
File PLog = new File(getDataFolder() + ("tempPlayers.yml"));
if(!(PLog.exists())){
try {
PLog.createNewFile();
getLogger().info("TempPlayer File made!");
} catch (IOException e) {
e.printStackTrace();
}
}
getLogger().info("TempPlayer File Already exists not making... | 2 |
private int CharacterCollapse(int inTarget){ // computes and returns role code of the freshly deceased.
double[] CumulProbs = new double[4 + (2*NumWolves)];
CumulProbs[0] = Probabilities[inTarget - 1][0];
for(int i = 1; i < (4 + (2*NumWolves)); i++){
CumulProbs[i] = Probabilities[inTarget - 1][i] + CumulProbs[... | 9 |
public GUI(){
c = new Counter();
mr = new MindReader();
s = new Score();
r = new Random();
show();
} | 0 |
public static void playSound(int id) {
Float[] floats = new Float[10];
floats[0] = 0.0f;
floats[1] = 0.1f;
floats[2] = 0.2f;
floats[3] = 0.3f;
floats[4] = 0.4f;
floats[5] = 0.5f;
floats[6] = 0.6f;
floats[7] = 0.7f;
floats[8] = 0.8f;
floats[9] = 0.9f;
if (Main.isSoundOn) {
if (id == 0) {
M... | 5 |
public char[] stringCompresssion(char[] s) {
StringBuffer ss = new StringBuffer();
ss.append(s[0]);
int count = 1;
for (int i = 1; i < s.length; i++) {
if (s[i] == s[i - 1]) {
count++;
} else {
ss.append(count);
ss.append(s[i]);
count = 1;
}
}
ss.append(count);
if(ss.length()>=s.l... | 3 |
public static void main(String[] args) {
double[] fs = { 0 * Math.PI / 180, 1 * Math.PI / 180,
2 * Math.PI / 180, 3 * Math.PI / 180, 4 * Math.PI / 180,
5 * Math.PI / 180, 6 * Math.PI / 180, 7 * Math.PI / 180, };
System.out.println(Arrays.toString(fs));
// frequency,magnitude,phase
double[] timeData = ge... | 3 |
public void calcTable()
{
int countCalc = table.size();
int prevCount = 0;
while(countCalc != prevCount)
{
prevCount = countCalc;
countCalc = 0;
for (Map.Entry<String, TableCell> entry : table.entrySet())
{
// System.out.println("Key : " + entr... | 5 |
public Drive put (Object key, Drive drive) throws IllegalArgumentException
{
if(containsKey(key) || containsValue(drive) || (key == null && drive != null && drive.getID() != null) ||
(key != null && drive != null && !key.equals(drive.getID())))
throw new IllegalArgumentException ("The specified drive is alre... | 8 |
public static void main(String[] args) {
try {
g();
} catch (Exception e) {
System.out.println("main: printStackTrace()");
e.printStackTrace(System.out);
}
try {
h();
} catch (Exception e) {
System.out.println("main: printStackTrace()");
e.printStackTrace(System.out);
}
} | 2 |
public void forward(double amount)
{
double dx = amount * Math.cos(heading * Math.PI / 180);
double dy = amount * Math.sin(heading * Math.PI / 180);
double temp1 = xPos + dx;
double temp2 = yPos - dy;
((Graphics2D)graphics1).setStroke(new BasicStroke(thi... | 6 |
@Override
public void populateVals()
{
byte[] temp1 = new byte[7]; // PtgRef3d is 7 bytes
byte[] temp2 = new byte[7];
// Encoded Cell Range Address:
// 0-2= first row
// 2-4= last row
// 4-6= first col
// 6-8= last col
// Encoded Cell Address:
// 0-2= row index
// 2-4= col index + relative flag... | 4 |
public static void main(String[] args){
if(args.length < 1){
System.out.println("TCPServer port number not specified.");
System.exit(1);
}
ServerSocket parentSocket = null;
try{
int portNo = Integer.valueOf(args[0]).intValue();
parentSocket = new ServerSocket(portNo);
while(true){
Socket ch... | 3 |
public void nextPermutation(int[] num) {
int i,j,k,t;
for(i = num.length - 2; i>=0; i--){
if(num[i]>=num[i+1])continue;
else break;
}
if(i==-1) {
sort(num,0,num.length-1);
return;
}
k = Integer.MAX_VALUE;
t = -1;
for(... | 6 |
public SignatureVisitor visitParameterType() {
if (type != METHOD_SIGNATURE
|| (state & (EMPTY | FORMAL | BOUND | PARAM)) == 0)
{
throw new IllegalArgumentException();
}
state = PARAM;
SignatureVisitor v = sv == null ? null : sv.visitParameterType();
... | 3 |
private static void solve(String[] input) {
for (String str:input){
recordChanges(str);
}
} | 1 |
public void updateBoard()
{
// Iterate through entire gameBoard, deleting position of currentBlock
for (int i = 0; i < NUM_ROWS; i++) // Loop through rows
{
for (int j = 0; j < NUM_COLUMNS; j++) // Loop through columns
{
if(gameBoard[i][j] == ACTIVE_BLOCK)
{
gameBoard[i][j] = EMPTY;
}
... | 7 |
@Override
public GameState[] allActions(GameState state, Card card, int time) {
GameState[] states = new GameState[1];
states[0] = state;
if(time == Time.DAY)
{
states = new GameState[]{bruteDay(state, card, false)};
}
else if(time == Time.DUSK)
{
PickTreasure temp = new PickTreasure();
state... | 3 |
public void setEncode(ENCODE encode) {
this.encode = encode;
} | 0 |
public MeterDatos(Principal init) {
initComponents();
this.setLocationRelativeTo(null);
this.setVisible(true);
lblInfo.setVisible(false);
this.inicio = init;
if (inicio.principal != null) {
txtAntiguedad.setText("" + inicio.principal.datos.getAntiguedad());
... | 7 |
public void checkCbolOriginalDirV3() {
Path dir = Paths.get(CBOL_HOME);
List<String> list = new ArrayList<>();
//
//http://docs.oracle.com/javase/tutorial/essential/io/dirs.html
String str;
String str2;
String str3;
try (DirectoryStream<Path> stream = F... | 4 |
public boolean printDistance(BSTNode<T> root, BSTNode<T> node1, BSTNode<T> node2, LinkedList<BSTNode<T>> queue) {
if(root != null) {
//if either of the nodes match with root
if(root == node1 || root == node2) {
// do the counting down logic
BSTNode<T> targ... | 8 |
public static void main(String[] args) {
String temp = "abcd";
byte[] b = temp.getBytes();
ByteArrayInputStream in = new ByteArrayInputStream(b);
for(int i = 0 ; i < 2; i ++)
{
int c;
while(-1 != (c = in.read()))
{
if(0 == i)
{
System.out.println((char)c);
}
e... | 3 |
public static void main(String[] args)
{
for (int i = 1; i <= 100; i++)
{
if (i % 3 == 0 && i % 5 == 0)
{
System.out.println(i+"-"+"FizzBuzz");
}
else if (i % 3 == 0)
{
System.out.println(i+"-"+"Fizz");
... | 5 |
@Test
public void testGetAllDeployments() throws IOException {
List<Deployment> remoteDeployments = dexmaRestFacade.getAllDeployments();
assertEquals(1,remoteDeployments.size());
Iterator<Deployment> itRemote = remoteDeployments.iterator();
while (itRemote.hasNext()) {
Deployment dep = ... | 3 |
@Override
public Group createGroup(Group group) {
Connection cn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
cn = ConnectionHelper.getConnection();
ps = cn.prepareStatement(QTPL_INSERT_GROUP, new String[] { "group_id" });
ps.set... | 5 |
private static void initializeLists() {
try{
readCubes();
}
catch(ParserConfigurationException | SAXException | IOException e){
System.out.println(e.getMessage());
createRandomCubes();
}
try{
readLines();
}
catch(Par... | 6 |
@Override
public void execute(CommandSender sender, String gateName, List<String> args) {
this.sender = sender;
if (gateName == null) {
error("No gate given.");
reply("Usage: /gate setdenysilent <gatename> <true|false>");
} else if (!gateExists(gateName)) {
reply("Gate not found: " + gateName);
} e... | 5 |
private String buildDirectoryListing(String path, File[] files) {
// Sort all files: first directories, then files
Arrays.sort(files, (f1, f2) -> {
if (f1.isDirectory() && !f2.isDirectory()) {
return -1;
} else if (!f1.isDirectory() && f2.isDirectory()) {
return 1;
} else {
return f1.toString()... | 9 |
private int getIndexToWrite() { //returns the first empty particle array index, and if none exist returns the location of the "oldest" particle instead
int oldestParticleAge = 0;
int oldestParticleIndex = 0;
for (int particleIndex = 0; particleIndex < particleArray.length; particleIndex... | 3 |
*/
@Override
public boolean equals(Object arg0) {
for (int i = 1; i < transitions.length; i++) {
for (int j = 1; j < transitions[0].length; j++) {
// Lazy!
try {
if (transitions[i][j] != ((Automata<Integer>)arg0).getTransitions()[i][j]) {
return false;
}
... | 4 |
private void leftComp(float a, int vel) {
for (float i = 0; i < a; i++) {
if (!this.touchRobotRotate()) {
this.rotateRobot(-1);
if (this.checkTouchBullet()) {
this.onHitByBullet();
return;
}
... | 4 |
@Override
public String calculate(VcfEntry vcfEntry) {
if (vcfEntry == null) return null;
try {
// We set the master (and VcfFileIterator) 'parseNow=false', so the VcfEntry should be 'unparsed' at this moment.
// The idea is that the workers can do this, relieving the master from this task.
vcfEntry.pars... | 6 |
private int classifyFitness(char[][] board) {
float[] input = new float[48];
int i = 0;
for (int r = 0; r < board.length; r++) {
for (int t = 0; t < board[0].length; t++) {
switch(board[r][t]) {
case PLAYER1:
input[i++] = 1;
break;
case PLAYER2:
input[i++] = -1;
break;
case ... | 8 |
@Override
public String getName() {
return "dump";
} | 0 |
public BodyArmorSlots getBodyArmorSlots(){
return bodyArmorSlot;
} | 0 |
public static ArrayList<Planet> forGR(PlanetWars pw){
// Tested
ArrayList<Planet> asw = new ArrayList<Planet>(2);
asw.add(null);
asw.add(null);
// Find the biggest fleet to attack with
int maxShips = 0;
for (Planet p : pw.MyPlanets()){
if (p.NumShips() > maxShips){
maxShips = p.NumShips();
asw.... | 5 |
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.