text stringlengths 14 410k | label int32 0 9 |
|---|---|
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(System.in);
StringBuilder out = new StringBuilder();
while (in.hasNext()) {
int n = in.nextInt();
int[] v = new int[n];
int[] r = new int[n];
for (int i = 0; i < n; i++)
v[i] = r[n - i - 1] = in.nextInt();
int[... | 3 |
@Override
protected int[] ParsePosition( String ToParse )
{
int Position[] = { 0, 0 };
if( ToParse.length() == 2 )
{
switch( ToParse.toUpperCase().charAt( 0 ) )
{
case('A'):
... | 9 |
private StringBuffer prepareFile(JoeTree tree, DocumentInfo docInfo) {
String lineEnding = PlatformCompatibility.platformToLineEnding(PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_LINE_ENDING));
StringBuffer buf = new StringBuffer();
buf.append("<?xml version=\"1.0\" encoding=\"").appe... | 1 |
static boolean authenticate( String username , String hashString, PassthroughConnection ptc ) {
try {
String encodedUsername = URLEncoder.encode(username, "UTF-8");
String encodedHashString = URLEncoder.encode(hashString, "UTF-8");
String authURLString = new String( "http://www.minecraft.net/game/checkse... | 7 |
@Override
public void show() {
String[][] data = ScoreIO.loadScores();
names = data[0];
scoreStrings = data[1];
int[] scores = new int[5];
for (int i = 0; i < 5; i++) {
scores[i] = Integer.parseInt(scoreStrings[i]);
}
currentScore = ScoreIO.getScore();
place = 5;
while (place > 0 && currentScore >... | 5 |
public Map<Integer, Integer> getGeneSpans(String text) {
Map<Integer, Integer> begin2end = new HashMap<Integer, Integer>();
Annotation document = new Annotation(text);
pipeline.annotate(document);
List<CoreMap> sentences = document.get(SentencesAnnotation.class);
for (CoreMap sentence : sentences) {... | 5 |
public Identifier getRepresentative() {
Identifier ptr = this;
while (ptr.left != null)
ptr = ptr.left;
return ptr;
} | 1 |
public static Vector2D getClosest(ArrayList<Vector2D> list, Vector2D vec) {
Vector2D closest = null;
double distance = 0;
for (Vector2D close : list) {
double val = close.getDistance(vec);
if (closest == null || val < distance && close != vec) {
closest =... | 4 |
private void findMax() {
if(calibrationDataSize > 0) {
int index = 0;
while(!calibrationFlag[index]) {
index++;
}
max = data[index];
index++;
for(int i=index; i<data.length; i++) {
if(calibrationFlag... | 5 |
void viewExistingCustomers() {
boolean quit = false;
while (!quit) {
System.out.println("------------");
System.out
.println("1.) Print All Registered Customer Information");
System.out.println("2.) Print Customer by ID");
System.out.printl... | 7 |
@Test
public void testQueryOrder() throws FileNotFoundException{;
int count = 0;
for (Player p : myGame.getPlayers()){
if (count == 0){
assertEquals(p.getName(), "Test name");
count++;
}
else if (count == 1){
assertEquals(p.getName(), "Elessar Telcontal");
count++;
}
else if (count == 2){
as... | 7 |
private String generateTRGFile(String csvFilename) {
// If this is the first time this step has processed data,
// mark the step as started
if (!this.running){
this.running=true;
this.logStart();
}
// Make sure filename ends in .csv
if (csvFilename.toLowerCase().endsWith(".csv")) {
// Replace .csv ... | 5 |
private void tickForwards(){
time++;
if(time % 60 == 0) second++;
if(second == 60){
minute++;
second = 0;
}
if(time == maxTime) finished = true;
} | 3 |
@Override
public String toString() {
if (currentSize == 0) {
return "[Empty Stack]";
}
StringBuffer sb = new StringBuffer();
for (int i = currentSize - 1; i >= 0; --i) {
sb.append("Stack[" + i + "] = " + array[i]);
if (i > 0) {
sb.append("\n");
}
}
return sb.toString();
} | 3 |
private void removeAnimal(int index) {
if (index < animals.size() && index >= 0) {
//System.out.println("Removing row " + index);
animals.remove(index);
animalCount --;
if (index == mother) {
mother = -1;
} else if (index < mother) {
... | 7 |
public void renderOverlay(int mx, int my, boolean[] buttons)
{
super.renderOverlay(mx, my, buttons);
float slotX = x;
float slotY = y-amountScrolled;
if(slots != null)
{
int slotIndex = 0;
for(int i = slots.length-1;i>=0;i--)
{
UISlot slot = slots[i];
if(slot == null)
continue;
if(s... | 5 |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
HttpSession session = request.getSession();
synchronized(session) {
response.setContentType("text/html");
// Get a output writer to write the respons... | 6 |
public static List<String> searchNineItems() {
String searchUrl = SearchUrl.NINE_URL;
List<String> urls = new ArrayList<>();
for (int i = 1; i <= 3; i++) {
for (Map.Entry<String, List<String>> m : cidToKeyMap.entrySet()) {
String cid = m.getKey();
List... | 7 |
public Expression simplify() {
if (subExpressions[0].getType().getCanonic()
.isOfType(Type.tSubType(castType)))
/*
* This is an unnecessary widening cast, probably that inserted by
* jikes for inner classes constructors.
*/
return subExpressions[0].simplify();
return super.simplify();
} | 1 |
public static void main(String[] args) throws Exception
{
Socket socket = new Socket("127.0.0.1",5001);
OutputStream os = socket.getOutputStream();
InputStream is = socket.getInputStream();
os.write("hi ".getBytes());
byte[] buffer = new byte[200];
int length = 0;
while(-1 != (length... | 1 |
public ReportResult getFilteredReport(String[] spielerNamen, String startString, String endeString) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.GERMAN);
Date start = sdf.parse(startString);
Date ende = null;
if (endeString == null) {
ende = new Date();
} else ... | 6 |
public synchronized BufferedImage[] getShadeOverlays( int size ) {
if( shadeOverlays == null || size != shadeOverlaySize ) {
shadeOverlays = new BufferedImage[16];
for( int i=0; i<16; ++i ) shadeOverlays[i] = Blackifier.makeShadeOverlay(
size,
(i & TileLayerData.SHADE_TL) != 0 ? 1 : 0,
(i & TileLaye... | 7 |
private prRegion createNewRegion(Player player) {
int x1,y1,z1;
try {
x1 = player.getMetadata("x1").get(0).asInt();
y1 = player.getMetadata("y1").get(0).asInt();
z1 = player.getMetadata("z1").get(0).asInt();
} catch (Exception e) {
player.sendMessage(ChatColor.RED + "Select point 1 first.");
return... | 2 |
public boolean action(Event e, Object o) {
if (e.target == ok) {
hide();
dispose();
}
return true;
} | 4 |
public void adaptToHost()
{
//Update host size to current actual value
if(inScrollPane)
hostSize = scrollPanel.getSize();
else
hostSize = slidePanel.getSize();
//Derive the number of onscreen pixels for one increment of the 800x600
//grid used for specifying size and positioning in the XML
double gr... | 8 |
public static Stella_Object generateCaseBasedAnswer(LogicObject probe, Surrogate slot, List cases) {
{ int num = cases.length();
Vector slotVector = Logic.createCaseValueVector(cases, slot);
Vector matchScores = Vector.newVector(num);
int farthest = 0;
Vector nearestNeighbors = Vector.newVec... | 9 |
public static void main(String[] args) {
Iterable collection = null;
Iterator iterator = collection.getIterator();
while (iterator.hasNext()) {
Object o = iterator.next();
}
} | 1 |
protected void onUserMode(String targetNick, String sourceNick, String sourceLogin, String sourceHostname, String mode) {} | 0 |
@GET
@Path("{path:.*}")
public Response getItem(@PathParam("path") String path, @QueryParam("download") boolean download, @QueryParam("info") boolean info) throws ContentRepositoryException, IOException {
try {
CollectionObject item = repo.getItem(path);
if (item instanceof Folder) {
return Response.o... | 6 |
private void incomingVehicleMonitor(Vehicle v) {
if (v instanceof MotorCycle) {
numMotorCycles++;
} else if (v instanceof Car && ((Car) v).isSmall() == true) {
numSmallCars++;
numCars++;
} else if (v instanceof Car && ((Car) v).isSmall() == false) {
numCars++;
}
} | 5 |
public String toString(){
String positif = "+ = ";
String negatif = ", - = ";
for(Entry<String, Boolean> entry : preferences.entrySet()){
String cle = entry.getKey();
Boolean valeur = entry.getValue();
if(valeur){
positif += cle+" ";
}
else{
negatif += cle+" ";
}
}... | 2 |
public static NymOfferDetails getNymOfferDetails(String serverID, String nymID, String transactionID) {
NymOfferDetails nymOfferDetails = new NymOfferDetails();
OfferListNym offerListNym = Helpers.getNYMOffer(serverID, nymID);
if (offerListNym == null) {
System.out.println("getNym... | 7 |
public void testObjectLargeArrayArraycopy()
{
Double[] data = new Double[]{1.12345, -1.54321, 100., -100., Double.MAX_VALUE, Double.MIN_VALUE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NaN, Double.MIN_NORMAL};
int startPos = 2;
int length = 8;
LargeArray.setMaxSizeOf... | 4 |
public static void clearTable(JTable table) {
for (int i = 0; i < table.getRowCount(); i++) {
for (int j = 0; j < table.getColumnCount(); j++) {
table.setValueAt("", i, j);
}
}
} | 2 |
public static byte[] createChecksum(String filename) throws Exception {
MessageDigest complete;
try (InputStream fis = new FileInputStream(filename)) {
byte[] buffer = new byte[1024];
complete = MessageDigest.getInstance("MD5");
int numRead;
do {
... | 2 |
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
final JTextArea txtFilePath = new JTextArea();
txtFilePath.setEditable(false);
txtFilePath.setBounds(10, 10, 290, 22);
fra... | 7 |
public boolean validCoordinates(int r, int c) {
return !(r < 0 || r >= GameConstants.HEIGHT || c < 0 || c >= GameConstants.WIDTH);
} | 3 |
public synchronized void loadCurrentResource() {
String s = getResourceAddress();
if (s == null) {
setLoadingMessagePainted(false);
return;
}
setLoadingMessagePainted(true);
if (FileUtilities.isRemote(s)) {
s = FileUtilities.httpEncode(s);
if (ConnectionManager.sharedInstance().isCachingAllowed())... | 7 |
private void calculateEnabledState(Document doc) {
if (doc == null) {
setText(TEXT);
setEnabled(false);
} else {
setText(new StringBuffer().append(TEXT).append(" ").append(doc.getUndoQueue().getRedoRangeString()).toString());
if(doc.getUndoQueue().isRedoable()) {
setEnabled(true);
} else {
se... | 2 |
private boolean consideringHierarchy(Publish p) {
boolean sent = false;
for (Entry<Class<?>, List<SubscriberParent>> e : p.mapping.entrySet()) {
if (e.getKey().isAssignableFrom(p.message.getClass())) {
for (SubscriberParent parent : e.getValue()) {
if (!predicateApplies(parent.getSubscriber(), p.message... | 5 |
@Override
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == cancelButton)
closeWindow();
else if (e.getSource() == okButton)
{
String name = (String) comboBoxUnitName.getSelectedItem();
double minPos = Utility.stringToDouble(textFieldMinPos.getText());
double maxPos = Utility.st... | 9 |
public Boss(int courtWidth, int courtHeight) {
super(INIT_VEL_X, INIT_VEL_Y, INIT_X, INIT_Y, SIZE, SIZE, courtWidth,
courtHeight);
// Set img1 to the picture of ragnaros
try {
if (img1 == null) {
img1 = ImageIO.read(new File(img_file1));
}
} catch (IOException e) {
System.out.println("Internal ... | 3 |
@SuppressWarnings("SpellCheckingInspection")
private void printMostActiveActor(final List<Movie> movies) {
// Java 7 style.
final Map<Actor, Long> actorToMovieCount = new HashMap<>();
for (final Movie movie : movies)
for (final Actor actor : movie.getActors())
act... | 6 |
private boolean parseAliceBob() throws FormatterError {
int ln = parseToken(true);
if (ln == EOF_INDICATOR) {
return false;
}
if (ln != WORD_INDICATOR) {
throw new FormatterError("parseAliceBob : Bad first word");
}
is_alice_line = s.equals("Ali... | 4 |
@Override
public boolean okMessage(final Environmental myHost, final CMMsg msg)
{
if(affected instanceof Room)
if((CMath.bset(msg.sourceMajor(),CMMsg.MASK_MALICIOUS))
||(CMath.bset(msg.targetMajor(),CMMsg.MASK_MALICIOUS))
||(CMath.bset(msg.othersMajor(),CMMsg.MASK_MALICIOUS)))
{
if((msg.target()!=null)
... | 7 |
@Override
public void run() {
isAlive = true;
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
while (isAlive) {
String readLine = bufferedReader.readLine();
parseCommand(readLine);
... | 3 |
public void visitSwitchStmt(final SwitchStmt stmt) {
if (stmt.defaultTarget() == oldDst) {
if (FlowGraph.DEBUG) {
System.out.print(" replacing " + stmt);
}
stmt.setDefaultTarget(newDst);
if (FlowGraph.DEBUG) {
System.out.println(" with " + stmt);
}
}
final Block[] targets = stmt.targe... | 7 |
private void setName(String name) {
if (name != null)
this.name = name;
} | 1 |
public void clearBoard(){
gl.clearBoard();
for(int i=0; i< game.length; i++){
game[i].setIcon(null);
}
} | 1 |
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("global")) {
return cmdGlobal(sender, args);
}
else if (cmd.getName().equalsIgnoreCase("globalrules")) {
return cmdGlobalRules(sender);
}
else if (cmd.getName().equals... | 5 |
public List<Location> adjacentLocations(Location location, int distance)
{
assert location != null : "Null location passed to adjacentLocations";
// The list of locations to be returned.
List<Location> locations = new LinkedList<Location>();
if(location != null) {
int row... | 9 |
public void saveToFile() {
try {
FileOutputStream fileOut = new FileOutputStream(FILE);
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(this);
out.close();
fileOut.close();
} catch (IOException e) {
e.printStackTrace();
}
} | 1 |
@Override
public void initialize(URL arg0, ResourceBundle arg1) {
ConnectionPool.getConnection();
colItemName.setCellValueFactory(
new PropertyValueFactory<ItemSaleModel, String>("itemName"));
colPrice.setCellValueFactory(
new PropertyValueFactory<ItemSaleMod... | 1 |
public void close() {
try {
if (resultSet != null) {
resultSet.close();
}
if (statement != null) {
statement.close();
}
if (connection != null) {
connection.close();
}
}
catch(Exception e){
e.printStackTrace();
System.out.println(e);
}
} | 4 |
private synchronized AffineTransform bufferTransform(){
AffineTransform r=new AffineTransform();
for(int i=0;i<a1.size();i++){
int s1=a1.get(i);Object s2=a2.get(i);Object s3[]=null;
if(s2 instanceof Object[])s3=(Object[])s2;
if(s1==setTransform){r=makeTransform(s2); }
... | 9 |
public void actionPerformed(ActionEvent e){
if(e.getSource() == btnRegister){
if (comboBox.getSelectedItem().equals("Patient")) {
if (textField_1.getText().equals(textField_2.getText())) {
NewPatientProfilePanel nup = new NewPatientProfilePanel(parent, textField.getText(), textField_1.getText());
... | 8 |
public long getPersonId() {
return this.personId;
} | 0 |
public void upY(){
if (jump > 0) {
// Jump case
if (jump < 15) { // Go higher
y -= moveY;
++jump;
} else if (jump < 30) { // Go higher more slowly
y -= moveY/2;
++jump;
} else if (jump == 30) { // Stand
++jump;
} else if (jump <= 45) { // Start reaching the ground
y += m... | 6 |
public static String baseToDec(String num, int base)
{
String risultato = ERRORE;
long risultato_num = 0;
num = num.toUpperCase();
if (numeroValido_privato(num, base)) // Numero valido
{
if (base==1) // Se la base è 1
{
in... | 6 |
public void mouseReleased(MouseEvent e)
{
// TODO Auto-generated method stub
} | 0 |
final public String evaluate(String expression) throws InvalidInputException, RuntimeException
{
resetStructures();
tokenizeExpression(expression);
insertImplicitMultiplication();
convertToPostfix();
int previousFunctionMode = Function.outputMode;
int previousOperatorMode = Operator.outputMode;
if (this.... | 6 |
private static void writeText(Client c, int skillType) {
c.getPA().sendFrame126(SKILLS[skillType], TITLE_LINE);
for (int j = 0; j < LEVELS[skillType].length; j++) {
c.getPA().sendFrame126(LEVELS[skillType][j], LEVEL_LINE + j);
}
for (int j = 0; j < DESCRIPTION[skillType].length; j++) {
c.getPA().sendFrame... | 4 |
public boolean addMessage(ChatMessage chatMessage){
boolean returnValue = false;
try {
Socket socket = new Socket(SERVER_ADDRESS_CHAT, CHAT_PORT);
socket.setSoTimeout(TIMEOUT);
OutputStream outputStream = socket.getOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(
... | 3 |
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TransportResponse(");
boolean first = true;
sb.append("status:");
if (this.status == null) {
sb.append("null");
} else {
sb.append(this.status);
}
first = false;
if (!first) sb.append(", ");
sb.... | 9 |
@Override
public void setValueAt(Object value, int row, int col) {
if (col != 0) {
super.setValueAt(value,row,col);
}
} | 1 |
public static void main(String[] args) {
String path = "/home/jorge/quiz.txt";
try {
Quiz quiz = QuizLoader.loadQuiz(path);
for(Question question : quiz){
System.out.println("Id: " + question.getId());
System.out.println("Enunciado: " + question.getEnunciado());
System.out.println("Puntuación: " ... | 5 |
public static URL getURL(String resourceLocation) throws FileNotFoundException {
Assert.notNull(resourceLocation, "Resource location must not be null");
if (resourceLocation.startsWith(CLASSPATH_URL_PREFIX)) {
String path = resourceLocation.substring(CLASSPATH_URL_PREFIX.length());
URL url = SpringClassUtils.... | 4 |
public final void append(final File fileToAppendTo, final File content,
int bytesToDiscard) {
OutputStream out = null;
InputStream in = null;
if (!content.exists()) {
return;
}
try {
try {
out = new OutputStream(fileToAppendTo, FileSystem.UTF8, true);
synchronized (this) {
this.openStre... | 5 |
@Override
public void evaluateTheHand(Hand player){
dealerBrain = new DealerAI(player);
Vector<Card> throwAway = dealerBrain.whichCardsShouldISwap();
int num = throwAway.size();
Hand newHand = new Hand();
for (int y = 0; y < hand.size();y++){
boolean seen = false; ... | 5 |
public static double paretoInverseCDF(double alpha, double beta, double prob) {
if (prob < 0.0 || prob > 1.0) throw new IllegalArgumentException("Entered cdf value, " + prob + ", must lie between 0 and 1 inclusive");
double icdf = 0.0D;
if (prob == 0.0) {
icdf = beta;
} else {
if (prob == 1.0) {
icdf... | 4 |
int allocateClusters(int tailCluster, int count) throws IOException {
// - bitmap of free clusters in memory?
// - chunk with free block counting for sequential allocation?
// - two stage allocation with "gray"
// +final static int CLUSTER_GALLOCATED = 0x80000000;
// +final... | 8 |
public SendGUI() {
initComponents();
} | 0 |
public boolean isExpired() {
if (keepAliveTimeMsecs == 0) {
return false;
}
return ((System.currentTimeMillis() - keepAliveTimeMsecs) >= timeEntered);
} | 1 |
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Scanner scanner2 = new Scanner(System.in);
String invoer, invoerOpnieuw;
boolean opnieuw = false;
System.out.print("Dit programma test of je invoer een palindroom is");
do {
System.out.print("\nVoer een zin, woord of ci... | 7 |
public void reloadGMCommands() {
gmcommands.clear();
try {
ClassFinder classFinder = new ClassFinder();
String[] classes = classFinder.listClasses("net.sf.odinms.client.messages.commands.Jounin", true);
registerGMCommand(new HelpGMCommand()); // register the helpcomma... | 5 |
public JSONObject increment(String key) throws JSONException {
Object value = this.opt(key);
if (value == null) {
this.put(key, 1);
} else if (value instanceof Integer) {
this.put(key, ((Integer) value).intValue() + 1);
} else if (value instanceof Long) {
... | 5 |
public java.io.Serializable fromDOM(Document document) {
automatonMap.clear();
Automaton a = createEmptyAutomaton(document);
Node parent = document.getDocumentElement()
.getElementsByTagName(AUTOMATON_NAME).item(0);
if(parent == null) parent = document.getDocumentElement();
return re... | 1 |
public void insert(Node root, Node n){
if(root == null|| n == null) return;
if(root.getData() > n.getData()){
if(root.getLeft() == null){
root.setLeft(n);
System.out.println("Added node to left of "+root.getData()+" of value "+n.getData());
}else{
insert(root.getLeft(),n);
}
}el... | 6 |
public Tile(int x, int y, TileType type, Match match) {
this.x = x;
this.y = y;
this.type = type;
bombers = new LinkedList<IBomber>();
this.match = match;
} | 0 |
public boolean yatzy(){
for(int i=1; i<5; i++){
if(nopat[0].getValue()!=nopat[i].getValue()){
return false;
}
}
return true;
} | 2 |
@Override
public int hashCode() {
int result = cueMovto != null ? cueMovto.hashCode() : 0;
result = 31 * result + (cueNaturaleza != null ? cueNaturaleza.hashCode() : 0);
result = 31 * result + (cueCuentaConcatenada != null ? cueCuentaConcatenada.hashCode() : 0);
return result;
} | 3 |
@Override
public void keyPressed(KeyEvent arg0) {
// TODO Auto-generated method stub
if (arg0.getKeyCode() == KeyEvent.VK_W)
{
this.canMove = false;
this.move("up");
}
if (arg0.getKeyCode() == KeyEvent.VK_S)
{
this.canMove = false;
this.move("down");
}
if (arg0.getKeyCode() == KeyEvent.VK... | 4 |
private void evaluateClustersWithRespectToClass(Instances inst, String fileName)
throws Exception {
int numClasses = inst.classAttribute().numValues();
int[][] counts = new int[m_numClusters][numClasses];
int[] clusterTotals = new int[m_numClusters];
double[] best = new doub... | 8 |
public void switchMenu()
{
try
{
menuSwitch.get();
} catch (NullPointerException e)
{
while (isReadyFX == false)
{
}
}
menuSwitch.set(!menuSwitch.get());
} | 2 |
@Override
public void update(GameContainer gc, StateBasedGame sb, float delta) {
if (cooldown <= 0) {
cooldown = 0;
onCooldown = false;
} else if (onCooldown) {
if(invincibleTime >=3000){
invincible=false;
}
cooldown -= delta;
invincibleTime+=delta;
}
} | 3 |
protected void alignText() {
int xLoc, yLoc;
int spacing = Math.max((int)Math.round(font.getSize() * spacingRatio), 1);
int endIndex;
switch (vAlign) {
case (V_TOP) : yLoc = this.getLocationY(); break;
case (V_CENTER) : yLoc = this.getLocationYC() - font.getSize(... | 8 |
public void cleanTab(){
//Trovo il numero reale di elmenti nel vettore
int num=0;
//Trovo il nmero di descrittori mossa corretto
for(int i=0;i<desmosse.length;i++)
if(desmosse[i]!=null)
++num;
//Creo il vettore ben dimensionato
DescrittoreMossa[] res = new DescrittoreMossa[num];
int c=0;... | 4 |
private void setLabelDropTarget()
{
fieldLabel.setDropTarget(new DropTarget(this, new DropTargetListener()
{
private final DataFlavor entityFieldDataFlavor = new DataFlavor(EntityField.class,
EntityField.class.getName());
... | 7 |
@Override
public Value evaluate(Value... operands) throws Exception {
// we need two operands
if (operands.length != input())
throw new EvalException("Error: wrong number of operands");
// get operands
Value l = operands[0];
Value r = operands[1];
// if they are identical
if (l.getType().isNumeric()... | 4 |
public void moveTo(double toPosition) {
//get the free space in front of us on this road
double freeSpace = checkFreeSpaceAhead();
//calculate velocity
double velocity = (_velocity / (_brakeDistance - _stopDistance)) * (freeSpace - _stopDistance);
//System.out.println("V1 = " + velocity)... | 3 |
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 fe... | 8 |
@Override
public boolean canDespawn(LivingEntity entity)
{
if (entity == null)
return false;
final boolean async = !P.p().getServer().isPrimaryThread();
for (Entry<Plugin, Protector> entry : protectors.entrySet())
{
if (!entry.getKey().isEnabled())
continue;
Protector protector = entry.... | 8 |
String reverse(String s1){
char c[]=new char[s1.length()];
c=s1.toCharArray();
for(int i=0;i<(s1.length()/2);i++){
char temp=c[(s1.length()-1)-i];
c[(s1.length()-1)-i]=c[i];
c[i]=temp;
}
return new String(c);
} | 1 |
public boolean recursiveSymmetric(TreeNode left, TreeNode right) {
if(left == null && right == null) return true;
if((left == null && right != null) || (left != null && right == null)) return false;
if(left.val != right.val) return false;
boolean l = recursiveSymmetric(left.left, right.r... | 8 |
@Test
public void heapTest(){
long start = System.currentTimeMillis();
for (int i = 0; i < 1000000; i++){
heap.insert(i);
}
long end = System.currentTimeMillis();
long totaltime = end - start;
System.out.println("Time spent adding 1 000 000: " ... | 1 |
public void Pesquisar() throws IOException, ClassNotFoundException{
Scanner sc = new Scanner(System.in);
Reader fileReader = new FileReader("registros.txt");
BufferedReader br = new BufferedReader(fileReader);
String showReg = null;
System.out.println("Digite um nome");
String pesquisa = sc.next();
whil... | 3 |
public AnnealerAdapterI run() {
aa.initialState();
double t = 0.5;
double acceptRate = 0.5;
for (int i = 1; i < evalSMax; i++) {
aa.nextState();
// the normal annealing process
if (aa.costDecreasing()) {
aa.accept();
acceptRate = (1.0/500.0) * (499.0 * (acceptRate + 1));
} else {
doub... | 8 |
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_W)
ya = -game.getSpeedx();
if (e.getKeyCode() == KeyEvent.VK_S)
ya = game.getSpeedx();
if (e.getKeyCode() == KeyEvent.VK_A)
xa = -game.getSpeedx();
if (e.getKeyCode() == KeyEvent.VK... | 4 |
public int[] getPlacementResourceCards(Coordinate coord) {
coord = coord.normalizeCoordinate();
int cardsEarned[] = new int[5];
for (int i = 0; i < cardsEarned.length; i++) {
cardsEarned[i] = 0;
}
// Get the node at the coordinate
Node settlementLocation = nodeSet.get(... | 6 |
public boolean isTintedGlass() {
return tintedGlass;
} | 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.