text stringlengths 14 410k | label int32 0 9 |
|---|---|
public static double[] fft(double[] data, boolean useWindowFunction) {
double[] fftInput = new double[data.length];
if (useWindowFunction) {
int windowSize = data.length;
double[] windowedInput = applyWindowFunc(data, hanning(windowSize));
System.arraycopy(windowedInput, 0, fftInput, 0,
windowedInput.... | 4 |
private String getAggregationOperation(final AggregateOperation operation) {
String aggregationOperation = null;
switch (operation) {
case GEO_NEAR:
aggregationOperation = "$geoNear";
break;
case MATCH:
aggregationOperation = "$match";
brea... | 8 |
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (label.equalsIgnoreCase("get")) {
if (sender.isOp()) {
if (args.length > 0) {
if (args[0].endsWith(".sk")) {
this.plugin.getSkript(args[0]);
} else if (args[0].endsWith(".jar")) {
this.plugin.... | 5 |
private boolean clickedOnDeck(MouseEvent e) {
return e.getX() >= X_BOARD_OFFSET && e.getX() <= X_BOARD_OFFSET + CARD_WIDTH && e.getY() >= DECK_Y && e.getY() <= DECK_Y + CARD_HEIGHT;
} | 3 |
protected static String getInlineString( XmlPullParser xpp ) throws XmlPullParserException, IOException
{
int eventType = xpp.next();
String ret = "";
while( (eventType != XmlPullParser.END_DOCUMENT) &&
(eventType != XmlPullParser.END_TAG) &&
(eventType != XmlPullParser.TEXT) )
{
eventType = xpp.nex... | 5 |
private void setJPaneProjekt() {
ArrayList<HashMap<String,String>> a1 = null;
String spelProjektName = "";
String spelProjektSDate = "";
String spelProjektRDate = "";
try {
String sqlquery = "select SPELPROJEKT.BETECKNING,SPELPROJEKT.SID from SPELPROJEKT join ARBETAR... | 5 |
public static void main(String[] args) {
ExecutorService executorService = Executors.newCachedThreadPool();
for (int i = 0; i < 10000; i++) {
final int no = i;
Runnable runnable = new Runnable() {
@Override
public void run() {
... | 2 |
private void makeDropTarget(final java.io.PrintStream out,
final java.awt.Component c, boolean recursive) {
// Make drop target
final java.awt.dnd.DropTarget dt = new java.awt.dnd.DropTarget();
try {
dt.addDropTargetListener(dropListener);
} // end try
catch (java.util.TooManyListenersException e) {
... | 6 |
private boolean isInBounds(int cy, int cx) {
return cx >= 0 && cy >= 0 && cx < BOARD_SIZE && cy < BOARD_SIZE;
} | 3 |
public boolean checkHit(Rectangle2D test,BufferedImage hits ){
for(int i=(int) test.getX();i<=test.getX()+test.getWidth();i++){
for(int j=(int) test.getY();j<test.getY()+test.getHeight();j++){
if(hits.getRGB(i,j)!=0x00){
return true;
}
}
}
return false;
} | 3 |
public static void main(String[] args){
initParser(args);
System.out.println("Started");
try {
_input = new BufferedReader(new InputStreamReader(System.in));
while(emitter(_input.readLine())){}
} catch (IllegalArgumentException e) {
System.err.println(Errors.INVALID_COMMAND);
System.exit(-1);
} ca... | 5 |
private void finishRightDiagonal(int playerNumber) {
int i = 0;
int j = gameField.getFieldSize() - 1;
switch (playerNumber) {
case 1: {
while (i < gameField.getFieldSize()) {
if(!gameField.isFill(i,j)) {
gameField.putX(i,j... | 6 |
public String getCustomEvents(String username, boolean onlyCustomEvents, String fromCalendar) {
try {
if(onlyCustomEvents) {
events.events.clear();
pstmt = doQuery("SELECT * FROM events WHERE active = true AND calendar = ? AND calendar IN (SELECT calendar FROM calendars WHERE active = true AND (isPublic = ... | 6 |
public int[] generate(int nplayers, int bowlsize) {
int nfruits = nplayers * bowlsize;
dist = new int[12];
int distChoice = 2;
if(distChoice == 1)
uniform(nfruits);
else if(distChoice == 2)
halfFruits(nfruits);
return dist;
} | 2 |
public long getMin(long start, long end) {
if (this.start == start && this.end == end)
return minVal;
long mid = (this.start + this.end) / 2;
if (mid >= start && mid >= end)
return left.getMin(start, end);
if (mid < start && mid < end)
return right.getMin(start, end);
return Math
.min(le... | 6 |
public boolean contains(int X, int Y)
{
if(X > this.x && Y > this.y && X < this.x + this.width && Y < this.y + this.height)
{
return true;
}
else
{
return false;
}
} | 4 |
protected void patch_addContext(Patch patch, String text) {
if (text.length() == 0) {
return;
}
String pattern = text.substring(patch.start2, patch.start2 + patch.length1);
int padding = 0;
// Look for the first and last matches of pattern in text. If two different
// matches are found, ... | 5 |
private boolean jj_3R_23() {
if (jj_3R_78()) return true;
return false;
} | 1 |
@Override
public Collection<String> getThisPageFiles() {
Collection <String> fileset = new LinkedList<String>();
try {
fileset.add(getChildrenSaveTo());
fileset.add(getCoverSavePath());
} catch (IOException e) {
}
return fileset;
} | 1 |
public Move chooseMove(State s) {
// remember who we are so we can correctly evaluate states
me = s.whoseTurn();
// The rest of this function looks a lot like evalMove, except
// that it doesn't just track the minimaxvalue, but also the
// best move itself.
// get a list of possible moves
MyList moves = s.find... | 3 |
public void move() {
setY(getDY() + (int)getY());
setX(getDX() + (int)getX());
recalculateDY();
// Animate player by changing the image every x times, dependant on current game speed.
// Increase ticker by 1/2 of speed
double tickerIncrease = Board.getInstance().getSpeed() / 2;
... | 7 |
private void findPatterns() {
if (this.currentPredictions.isEmpty() || anyPredictionMet() || allPredictionsFailed()) {
//not monitoring any predictions, need to look for new patterns
String s;
for (int i = 2; i < this.data.length()/2; i+=1){
/*
String regex = "((\\d+\\s){"+i+"}).*\\1";
... | 7 |
private void buildInventory()
{
inventory = null;
int slots = 9;
int needed = options.size();
if (options.size() % 9 == 0)
{
slots = Math.max(9, options.size());
}
else
{
for (int x = 1; x <= 6; x++)
{
int attempt = x * 9;
if (needed < attempt)
{
slots = attempt;
... | 4 |
@Override
public String getName() {
return name;
} | 0 |
public static boolean isPalindrome(int input) {
List<Integer> intList = new ArrayList<Integer>();
int procInt = input;
// While int being processed is greater than zero,
// get last digit from the int and add to the list.
while(procInt > 0) {
intList.add(procInt%10);
procInt = procInt/10;
}
// Tak... | 5 |
public void run() {
int repeat = 1;
try {
AudioFormat af = new AudioFormat(2000f, // sampleRate
8, // sampleSizeInBits
1, // channels
true, // signed
false); // bigEndian
SourceDataLine sdl;
sdl = AudioSystem.getSourceDataLine(af);
sdl.open(af);
... | 5 |
public long [] run(Graph g,int source) {
Edge []edges=new Edge[g.getEdgeCount()];
int edgesCount=0;
for(int i=0;i<g.getVertexCount();i++) {
for(Edge e:g.getIncidentEdges(i)) {
edges[edgesCount++]=e;
}
}
long[]answer=new long[g.getVertexCount()];
... | 8 |
public void visitIfCmpStmt(final IfCmpStmt stmt) {
if (CodeGenerator.DEBUG) {
System.out.println("code for " + stmt);
}
final Block t = stmt.trueTarget();
final Block f = stmt.falseTarget();
if (f == next) {
// Fall through to the false branch.
genIfCmpStmt(stmt);
} else if (t == next) {
// F... | 3 |
public boolean makeMove(char item, int x, int y) {
if ((item == DEFAULT_X_ITEM)||(item == DEFAULT_O_ITEM)) {
if ((x >= 0)&&(y >= 0)&&(x < FIELD_SIZE)&&(y < FIELD_SIZE)) {
if (field[x][y] == DEFAULT_CELL_ITEM) {
putInCell(item, x, y);
moves[move... | 7 |
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String line = "";
StringBuilder out = new StringBuilder();
do {
line = in.readLine();
if (line == null || line.length() == 0)
break;
String[] d = line.trim().split("... | 6 |
@Override
public ElapsedTimeInterval ping(String header, String hostIP, int port, int timeout, int nTrials) throws Exception {
//TODO: implement this method
try {
Socket tcpSocket = null;
TCPMessageHandler tcpMessageHandlerSocket = null;
String msg = "";
for(int i = 0 ; i < nTrials ; i++) {
... | 8 |
public MammothRiders(boolean victory, Family family,
GameOfThronesModel model,Family[] track, PlayersChoices playerChoices) {
super(victory, family, model,playerChoices,track);
territories= new Territory[track.length];
units= new int[track.length];
if(victory && !family.getDiscardCombatantCards().isEmpty()){... | 5 |
public void addProduct(Product product) {
try {
beginTransaction();
session.save(product);
session.getTransaction().commit();
} catch (Exception e) {
e.printStackTrace();
} finally {
closeSesion();
}
} | 1 |
public static CompressedTileFlags swigToEnum(int swigValue) {
if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue) {
return swigValues[swigValue];
}
for (int i = 0; i < swigValues.length; i++) {
if (swigValues[i].swigValue =... | 5 |
public void incPlayerNofMatches(Team team) {
if (this.getG().goal1 != null) {
this.getG().goal1.incNofMatches();
}
int nofPlayers = team.getNofTeamPlayers();
for (int i = 0; i < nofPlayers; i++) {
Player player = team.getTeamPlayer(i);
if (player.getHealth().getInjury() == 0 && player != this.getG().go... | 6 |
public Object getValueAt(int row, int col) {
switch(col){
case 0: return row+1;
case 1: return data.get(row).getNbr().getId();
case 2: return data.get(row).getNbr().getAddr().getHostAddress();
case 3: return data.get(row).getCost();
... | 4 |
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
for (int y = 0; y < size; y++)
{
for (int x = 0; x < size; x++)
{
if (x > 0)
{
sb.append( " " );
}
sb.append( board[y][x] );
}
sb.append( "\n" );
}
return sb.toString();
} | 3 |
public FTLFrame( int version ) {
this.version = version;
// GUI setup
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(800, 700);
setLocationRelativeTo(null);
setTitle( "FTL Profile Editor v" + version );
try {
setIconImage( ImageIO.read( ClassLoader.getSystemResource("unlock.png") ) );
} catch... | 4 |
private void heap(){
// fill();
try{
fill();
}catch(OutOfMemoryError mem){
System.out.println("Oops I'm heaped " + count +" "+ al.size());
}
catch(Error e){
System.out.println("An Unknown Error Occurred");
}
System.out.println("Life goes on " + al.size());
} | 2 |
private String[] getFourMoves(ArrayList<Integer> sort, int i) {
String[] out = new String[4];
int mi = 0;
for (int b = 0;mi < 4; b++) {
if (i + b >= sort.size()) {
break;
}
for (int a = 0; a < list.get(sort.get(i + b)).size(); a++) {
if (mi > 3) {
break;
}
out[mi] = list.get(sort.get... | 4 |
protected boolean readYN() {
String result = "";
while (result.equals("")) {
String in = scanner.nextLine();
if (in.equalsIgnoreCase("y") || in.equalsIgnoreCase("n"))
result = in;
else System.out.println("Please type either 'y' or 'n'.");
}
... | 3 |
public void setProperties(double mass, double sigma, double epsilon) {
if (sigma <= 0.0)
throw new IllegalArgumentException("Atomic radius must be greater than zero");
if (mass <= 0.0)
throw new IllegalArgumentException("Atomic mass must be greater than zero");
if (epsilon <= 0.0) {
throw new IllegalArg... | 8 |
@Override
public String toString() {
String xMotion = xOffset < 0 ? "Left" : xOffset == 0 ? "Stop" : "Right";
String yMotion = yOffset < 0 ? "Up" : yOffset == 0 ? "Stop" : "Down";
String positionStr = String.format("(%d,%d)", position.x, position.y);
String motionStr = String.format("(%s,%s)", xMotion, yMotio... | 4 |
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 |
@Test
public void jsonTransformEquality() throws InvalidJSONException, JSONException {
Action a1 = new Action("a1", new Position(40.123,41.456), ActionType.FIRE, new Position(40.123,41.456), new Position(40.123,41.456));
Action a2;
a2 = new Action(a1.toJSON());
assertTrue((a1.getUniqueID() == a2.getUniqueID... | 2 |
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String line = "";
StringBuilder out = new StringBuilder();
while ((line = in.readLine()) != null && line.length() != 0) {
int[] a = readInts(line);
if(a[0]!=a[1] && a[0]!=a... | 8 |
public String accountTypeToString(int accountType){
String result = "";
switch (accountType){
case 0:
result += "CD";
break;
case 1:
result += "Checking";
break;
case 2:
result += "Loan";
break;
case 3:
result += "LOC";
break;
case 4:
result += "Savings";
break;
}
return ... | 5 |
public void moveToTarget(){
int px = target.getX();
int py = target.getY();
int tileSize = World.current.tileSize;
Vector2 start = new Vector2(getX() / tileSize, getY() / tileSize);
Vector2 goal = new Vector2(px / tileSize, py / tileSize);
path = World.current.findPath(start, goal);
if(path... | 6 |
protected Tank containsRelativeEnemyTank(Tank tank, int x, int y){
if(tank.isPlayer()){
for(Tank t: _enemyTanks){
if(t.getX() == x && t.getY() == y)
return t;
}
}else{
for(Tank t: _playerTanks){
if(t.getX() == x && t.getY() == y)
return t;
}
}
return null;
} | 7 |
private void initNodeNetwork() {
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
nodeNetwork[i][j] = new Node2(i, j);
}
}
} | 2 |
public void visit_if_icmpgt(final Instruction inst) {
stackHeight -= 2;
if (stackHeight < minStackHeight) {
minStackHeight = stackHeight;
}
} | 1 |
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
processRequest(request, response);
} catch (Exception ex) {
Logger.getLogger(ControlJsp.class.getName()).log(Level.SEVERE, null, ... | 1 |
public static Type addType(String name) {
Type type = null;
if(!listTypes.containsKey(name)) {
type = new Type(name);
listTypes.put(name, type);
}
return type;
} | 1 |
@Override
public void run() {
sc = new Scanner(System.in);
while(ctrl.isRunning()){
sc.reset();
if(sc.hasNext()){
String s[] = sc.nextLine().split("\\s+");
switch( s[0]){
case "list" : listCommand(s);
break;
case "shutdown" : shutdownCommand(s);
break;
cas... | 9 |
private Integer findTripsThatHaveWaysSmallerThan(City originCity, Integer wayLength) throws RouteNotFoundException{
for (Route route : originCity.getRoutesFromThisCity()) {
if(isTravelingInCircles(route)){
continue;
}
if(isLastRouteWithTheSameOrigin(route)){
actualTrip.removeLastRouteFromT... | 6 |
public void crearArtistaOCancion(char artistaOCancion){
switch (artistaOCancion) {
case 'a':
String nuevoArtista = JOptionPane.showInputDialog(null, "Ingrese El Nombre Del Nuevo Artista");
if (nuevoArtista != null && !nuevoArtista.isEmpty()) {
karaoke.agregarArtista(nuevoArtista,
(Genero) panelGuar... | 4 |
public synchronized void editar(int i)
{
try
{
new CursoView(this, list.get(i));
}
catch (Exception e)
{
}
} | 1 |
private void checkCon() throws SQLException {
if(this.con == null || this.con.isClosed())
throw new SQLException("Connection not ready.");
} | 2 |
public void SetPositions(){
for(int i = 0; i < 29; i++){
positions[0][i] = MapPointDisplayListNow.get(i).charValue();
positionsInt[0][i] = i;
}
for(int i = 1; i <= 7; i++){
positions[i][0] = MapPointDisplayListNow.get(70-i).charValue();
positionsInt[i][0] = 70 - i;
positions[i][28] =... | 5 |
protected Behaviour getNextStep() {
if (actor.mind.work() != null) {
abortBehaviour() ;
return null ;
}
if (actor.gear.credits() < BOARD_PRICE) return null ;
if (initTime == -1) {
final Action thinks = new Action(
actor, actor.aboard(),
this, "actionConsider",
A... | 7 |
public void setjTextFieldVilleCP(JTextField jTextFieldVilleCP) {
this.jTextFieldVilleCP = jTextFieldVilleCP;
} | 0 |
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Range other = (Range) obj;
if (max == null) {
if (other.max != null) {
return false;
}
} else if (!max.equals... | 9 |
public void setId(String value) {
this.id = value;
} | 0 |
public void setHindexStatus(LineAnaVO lineAnaVO) {
switch(lineAnaVO.getHindex()){
case 100:
h100a=h100a+1;
if(lineAnaVO.getNext()!=0){
h100c=h100c+1;
}
break;
case 45:
h45a=h45a+1;
if(lineAnaVO.getNext()!=0){
h45c=h45c+1;
}
break;
case 13:
h13a=h13a+1;
if(lineAnaVO.getNext(... | 8 |
public static Pokemon teachMove(Pokemon pokemon, Item tm, int number)
{
if (tm.effect1 != Item.Effect.TM && tm.effect1 != Item.Effect.HM)
{
Inventory.errorWindow.addMessage(" The Item selected is not a TM or HM! ");
return pokemon;
}
else if (canLearnMove(tm,pokemon))
{
pokemon.move[number] = tm.mo... | 3 |
private void testValues() throws IllegalArgumentException, IllegalAccessException, MalformedLayarRequestException {
if(layarRequest.version == null)
throw new MalformedLayarRequestException("version is mandatory field!");
if(!ServiceConst.LAYAR_VERSIONS.containsKey(layarRequest.version))
throw new MalformedLa... | 7 |
@Override
public void move(Excel start, Excel finish) {
if (start.getX() == begin.getX() && start.getY() == begin.getY())
{
begin = finish;
setColoredExes();
return;
}
if (start.getX() == end.getX() && start.getY() == end.getY())
{
end = finish;
setColoredExes();
return;
}
for(Excel ... | 6 |
@After
public void tearDown() {
} | 0 |
@SuppressWarnings("unchecked")
private final void registerEventHandlers() {
for (final Method method : getClass().getDeclaredMethods()) {
if (isUnannotatedMethod(method)) {
addMethodAsEventHandler((Class<? extends DomainEvent>) method.getParameterTypes()[0], method);
... | 7 |
public boolean setLocation(Location loc, boolean global) {
UUID uid = loc.getWorld().getUID();
Connection conn = plugin.getDbCtrl().getConnection();
PreparedStatement ps = null;
try {
String sql;
if (plugin.getDbCtrl().isMySQL())
sql = String.format("INSERT INTO `%s` VALUES (?, ?, ?, ?, ?, ?, ?) ON D... | 7 |
private void saveField(Object object, Class<?> clazz, Field field, Setting setting,
ConfigurationNode node) throws ConfigurationException,
IllegalArgumentException, IllegalAccessException, InstantiationException {
String path = getSettingPath(field, setting);
Object value = fiel... | 9 |
public List<Posizione> adiacenti(Posizione posizione) {
List<Posizione> adiacenti = new LinkedList<Posizione>();
int x = posizione.getX();
int y = posizione.getY();
for(int i = -1; i<2; i++) {
for(int j = -1; j<2; j++) {
adiacenti.add(new Posizione(x+i, y+j));
}
}
Iterator<Posizione> it = adi... | 8 |
public ProjectSettings(Main main, Map map) {
super(main, true);
initComponents();
// Set variables
this.map = map;
this.main = main;
// Setup choosable font properties
setupChoosableFontProperties();
// Set standard font, style and size from given proj... | 4 |
private LinkedList<String> cleanInput(String input,
LinkedList<String> result) {
LinkedList<String> output = new LinkedList<String>();
output.add(input);
//splits the sentence into parts which only contain words which were not found by phoenix
for(int i = 0; i < result.size(); i++) {
LinkedList<St... | 9 |
public void reloj(int n, char c)
{
/* PARA LA PARTE SUPERIOR DEL RELOJ DE ARENA UTILIZAMOS PRACTICAMENTE LA MISMA TECNICA
* QUE PARA EL TRIANGULO INVERTIDO; PARA LA PARTE INFERIOR UTILIZAMOS LA MISMA TECNICA QUE
* PARA EL TRIANGULO DERECHO ASCENDENTE SOLO QUE EN LA IMPRECION DE ESPACIOS EN... | 4 |
public void setChangeDate() {
setSysDate(getComboYear(), getComboMonth());
getSysRunDate();
setDateNull();
setDays(getMonthDays(getComboYear(), getComboMonth()),
getInitWeek(sysRunTime[0]), -1);
} | 0 |
private void openAudioClip(File file) throws UnsupportedAudioFileException, IOException, LineUnavailableException {
this.file = file;
audioInputStream = AudioSystem.getAudioInputStream(file);
if (isEncoded()){
AudioFormat baseFormat = audioInputStream.getFormat();
AudioFormat decodedFormat = new AudioFormat... | 1 |
SEDP(byte[] data, byte len) throws Exception {
packet_tag = (byte) SEDP_TAG;
version = 4;
key_id = (byte) TRIPLEDES_ID;
s2k = (byte) S2K_reserved;
cipher_text = data;
packet_length = (byte) (len + 1 + 1 + 1); // padded data + version + sym_alg_id + S2K
} | 0 |
public boolean jsFunction_waitCursor(String name, int timeout) {
deprecated();
int curr = 0; if(timeout == 0) timeout = 10000;
while(!JSBotUtils.getCursorName().equals(name))
{
if(curr > timeout)
return false;
Sleep(25);
curr += 25;
}
return true;
} | 3 |
private void updateAttributes() {
try {
String s = "The currently selected\nlocation has ";
RTile currentTile = WORLD.tileAt(curX, curX);
if (currentTile == null || currentTile.isEmpty())
s = s+"\nnothing... ";
else
{
if (cu... | 7 |
public String getCurrentPlayer() {
if (currentPlayer == 1) return "Player1";
else {
return "Player2";
}
} | 1 |
public User(String name, char[] password){
this.username = name;
this.password = password;
try {
this.lastLogin = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse("1970-01-01 00:00:00");
} catch (Exception e) {
System.out.println(e.getMessage());
this.lastLogin = new Date();
}
this.validLogin = fa... | 1 |
public void setLocal(final int i, final Value value)
throws IndexOutOfBoundsException
{
if (i >= locals) {
throw new IndexOutOfBoundsException("Trying to access an inexistant local variable "+i);
}
values[i] = value;
} | 1 |
public static double[] createRandomDistribution(int size, int precision, double somme_distrib) {
double[] distribution = new double[size];
if (somme_distrib > 0) {
double somme = precision;
while (precision > 0) {
// on selectionne un indice au hasard qu'on incré... | 3 |
public ResultSet QueryRes(String sql)
{
try
{
Statement stmt = con.createStatement();
ResultSet temp = stmt.executeQuery(sql);
return temp;
}
catch (Exception e)
{
System.out.println("Error running statement: " + e.toString());
return null;
}
} | 1 |
public void update(String query){
try {
this.statement.executeUpdate(query);
} catch (SQLException ex) {
Logger.getLogger(DatabaseConnection.class.getName()).log(Level.SEVERE, null, ex);
}
} | 1 |
public static String[] removeEmptyStrings(String[] data) {
ArrayList<String> result = new ArrayList<String>();
for (int i = 0; i < data.length; i++)
if (!data[i].equals(""))
result.add(data[i]);
String[] res = new String[result.size()];
result.toArray(res);
... | 2 |
public void setConnection()
{
} | 0 |
private synchronized void processNetPacket(Sim_event ev, int tag)
{
double nextTime = 0;
Packet pkt = (Packet) ev.get_data();
PacketScheduler sched = getScheduler(pkt);
// if a packet scheduler is not found, then try reschedule this packet
// in the future
if (sched ... | 6 |
public void sendMessage(String message) {
final byte[] messageBytes = message.getBytes();
sender = new Thread() {
@Override
public void run() {
DatagramPacket packet = new DatagramPacket(messageBytes, messageBytes.length, inetAddress, port);
try {
... | 1 |
private List sort(List list) {
if (list.head == list.tail) {
return list;
}
ListNode parti = list.head;
List left = null;
List right = null;
ListNode currentNode = list.head.next;
while (currentNode != null) {
if (currentNode.val <= parti.val) {
if (left == null) {
left = new List(currentNo... | 8 |
public void reset()
{
gameOver = false;
won = false;
switch (difficulty) {
case EASY:
map = new MineMap(10, 10, 6);
break;
case MEDIUM:
map = new MineMap(15, 15, 60);
break;
case HARD:
map = new MineMap(20, 20, 100);
break;
default:
break;
}
map.generate();
lastChanges... | 4 |
public static void main(String[] args){
int size = 50;
float x;
float y;
float z;
Coord3d[] points = new Coord3d[size];
for(int i=0; i<size; i++){
x = (float)Math.random() - 0.5f;
y = (float)Math.random() - 0.5f;
z = (float)Math.random() - 0.5f;
points[i] = new Coord3d(x, y, z);
}
... | 1 |
public void createReel(Player player, BlockFace face, SlotMachine slot) {
Block center = player.getTargetBlock(null, 0);
ArrayList<Block> blocks = new ArrayList<Block>();
for(int i = 0; i < 3; i++) {
blocks.add(center.getRelative(getDirection(face, "left"), 2));
blocks.add(center);
blocks.add(cente... | 2 |
private ArrayList<Cellule> cherche(){
ArrayList<Cellule> autour = curent.env.getenv(curent);
for (int i =0 ; i<autour.size() ; i++){
if(!(autour.get(i).personne.size() == 0)){
for (int j =0 ; j < autour.get(i).personne.size() ; j++){
if (!this.ennemi(autour.get(i).personne)){
a... | 4 |
protected boolean insideMatrix(int row, int col) {
return row >= 0 && row < matrix.length && col >= 0
&& col < matrix[0].length;
} | 3 |
public org.omg.CORBA.portable.OutputStream _invoke (String $method,
org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler $rh)
{
org.omg.CORBA.portable.OutputStream out = null;
java.lang.Integer __method = (java.lang.Integ... | 6 |
@Override
public void action() {
if(agente.getPasso() == 6){
Iterator<MelhorPropostaCupom> melhoresPropostas = agente.getMelhoresPropostas().iterator();
while(melhoresPropostas.hasNext()){
agente.addPropostaAceita(melhoresPropostas.next());
}
System.out.println("PASSO 6 AI");
ArrayList<M... | 5 |
private Point getPointFromRelativePositionToAnchor(RelativePosition relativePosition)
{
// Preconditions
assertNotNull("World has not been created yet.", world);
assertNotNull("Anchor molecule has not been created yet.", anchor);
assertNotNull("Position not given.", relativePosition);
assertFalse("Position u... | 8 |
private void addCallToConnection(Long connectionId, Long callId) {
conns.get(connectionId).add(callId);
} | 0 |
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.