text stringlengths 14 410k | label int32 0 9 |
|---|---|
private JSONWriter append(String string) throws JSONException {
if (string == null) {
throw new JSONException("Null pointer");
}
if (this.mode == 'o' || this.mode == 'a') {
try {
if (this.comma && this.mode == 'a') {
this.writer.write('... | 7 |
protected void TrusteeMF() {
for (int iter = 1; iter <= numIters; iter++) {
loss = 0;
errs = 0;
// gradients of B, V, W
DenseMatrix BS = new DenseMatrix(numUsers, numFactors);
DenseMatrix WS = new DenseMatrix(numUsers, numFactors);
DenseMatrix VS = new DenseMatrix(numItems, numFactors);
// rate... | 8 |
public void union(int x, int y) {
if (x == y) {
return;
}
x = find(x);
y = find(y);
if (rank[x] < rank[y]) {
root[x] = y;
rank[y]++;
} else {
root[y] = x;
rank[x]++;
}
} | 2 |
@Override
public boolean equals(Object o) {
if (this == o) { return true; }
if (o == null || this.getClass() != o.getClass()) { return false; }
Dictionary n = (Dictionary) o;
return dictionary.equals(n.dictionary);
} | 3 |
private void harvest(Level level, int x, int y) {
int age = level.getData(x, y);
int count = random.nextInt(2);
for (int i = 0; i < count; i++) {
level.add(new ItemEntity(new ResourceItem(Resource.seeds), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
}
count = 0;
if (age == 50) {
... | 4 |
public void init(String url, String saveTo, boolean logging, boolean allowReadCache, boolean forceTagging) {
state = UIState.START;
textFieldDirectory.setText(saveTo);
chckbxLog.setSelected(logging);
chckbxUseCache.setSelected(allowReadCache);
chckbxForceTag.setSelected(forceTagging);
try {
rootPage = Ab... | 2 |
public static String toString(JSONObject jo) throws JSONException {
boolean b = false;
Iterator keys = jo.keys();
String string;
StringBuffer sb = new StringBuffer();
while (keys.hasNext()) {
string = keys.next().toString();
if (!jo.isNull(s... | 3 |
private static String join(final String[] args, final String delim) {
if (args == null || args.length == 0) return "";
final StringBuilder sb = new StringBuilder();
for (final String s : args) sb.append(s + delim);
sb.delete(sb.length() - delim.length(), sb.length());
return sb.... | 3 |
public Module getModuleByChain(List<String> chain) {
int index = 0, size = chain.size();
Module module = getRootModule();
while(null != module && index < size) {
module = module.getSubModule(chain.get(index++));
}
return module;
} | 2 |
private Opcode toOpcode( byte opcode ) throws InvalidFrameException {
switch ( opcode ) {
case 0:
return Opcode.CONTINUOUS;
case 1:
return Opcode.TEXT;
case 2:
return Opcode.BINARY;
// 3-7 are not yet defined
case 8:
return Opcode.CLOSING;
case 9:
return Opcode.PING;
case 10:... | 6 |
private void printSeries (int fizzNumber, int buzzNumber, int limit) {
for (int i = 1; i <= limit; i++) {
if (i % fizzNumber == 0 && i % buzzNumber == 0) {
System.out.print("FB");
} else if (i % fizzNumber == 0) {
System.out.print("F");
} else if (i % buzzNumber == 0) {
System.out.print("B");
... | 6 |
private boolean checkDuplicate(int vx, int vy){
for(int i=0; i<_X.size(); i++){
if(_X.get(i)==vx){
if(_Y.get(i)==vy){
return false;
}
}
}
return true;
} | 3 |
private int readInteger(SeekableStream in) throws IOException {
int ret = 0;
boolean foundDigit = false;
int b;
while ((b = in.read()) != -1) {
char c = (char)b;
if (Character.isDigit(c)) {
ret = ret * 10 + Character.digit(c, 10);
... | 9 |
RedisConstants()
{
String env = System.getenv(this.name());
if (env == null)
{
env = System.getProperty(this.name());
if (env == null)
{
throw new RuntimeException("Property:" + this.name() + " is not an env or property");
}
}
value = env;
} | 2 |
private void advance() {
while (delegate.hasNext()) {
T element = delegate.next();
if (filter.accept(element)) {
next = element;
return;
}
}
next = null;
} | 2 |
public void removeDeadFlyUps() {
List<FlyUp> toDelete = new ArrayList<FlyUp>();
for(FlyUp fly:flyups) {
if(fly.timeSinceCreation() >= 3300) toDelete.add(fly);
}
for(FlyUp fly:toDelete) {
flyups.remove(fly);
}
} | 3 |
public void moveAll(String name, GameObject object) {
Chest c = null;
Avatar a = null;
String loc = null;
ArrayList<GameObject> shadowChest = new ArrayList<GameObject>();
for (Avatar v : avatarLocations.keySet()) {
if (v.getName().equals(name)) {
a = v;
loc = v.getLocationName();
}
}
for (G... | 8 |
protected ArrayList<Location> getMoveLocations()
{
ArrayList<Location> moveLocs = new ArrayList<Location>();
int facingDirection = getDirection();
Location loc = getLocation();
//Find and test all locations half left, in front, and half right of location of this
for(... | 2 |
@Override
public void setEnvFlags(Environmental E, int f)
{
if(E instanceof Item)
{
final Item item=(Item)E;
// deprecated, but unfortunately, its here to stay.
CMLib.flags().setDroppable(item,CMath.bset(f,1));
CMLib.flags().setGettable(item,CMath.bset(f,2));
CMLib.flags().setReadable(item,CMath.bs... | 7 |
public Unmark(int marker, int state) {
this.state = state;
this.marker = marker;
} | 0 |
public void dessineTousNoeud(Graphics g) {
// Si il n'y a pas d'itineraire d�fini, alors
// il n'y a pas de noeud
if (itineraire == null)
return;// ...donc on quitte
/*
* Cette liste contient toutes les adresse de livraison deja livre qui
* ne doivent pas etre redessine car leur couleur doit rester ce... | 6 |
public List<Graph> getErrorToProgressGraph() {
Map<Integer, Double> timeProgress = new HashMap<Integer, Double>();
Map<Integer, Integer> timeCount = new HashMap<Integer, Integer>();
Map<Integer, Double> stepsProgress = new HashMap<Integer, Double>();
Map<Integer, Integer> stepsCount = new HashMap<Integer, Integ... | 7 |
private void doHearbeats() {
new Timer().schedule(new TimerTask() {
@Override
public void run() {
// this code will be executed after 5 seconds
masterLogger.logMessage("===>> Heartbeats @ sec = "
+ executionTime);
for (Iterator<Entry<Integer, ReplicaLoc>> iterator = replicaPaths
.entrySe... | 5 |
@Override
public String toString() {
StringBuffer s = new StringBuffer();
for (Student student : students) {
s = s.append(student).append(System.lineSeparator());
}
return s.toString();
} | 1 |
public ImageIcon loadIcon(String image){
try {
return new ImageIcon(ImageIO.read(new File(image)));
} catch (Exception e) {
e.printStackTrace();
}
return null;
} | 1 |
public Admin lookup(String username) throws DAOPoikkeus {
Admin admin;
Connection connection = avaaYhteys();
String sql = "select id, username, password_hash, salt from Admin where username = ?";
try {
PreparedStatement usernameLookup = connection.prepareStatement(sql);
usernameLookup.setString(1, usernam... | 2 |
public void rewindNbytes(int N)
{
int bits = (N << 3);
totbit -= bits;
buf_byte_idx -= bits;
if (buf_byte_idx<0)
buf_byte_idx += BUFSIZE;
} | 1 |
public List<Double> decode(Chromosome chromosome) {
if (chromosome.size() % 2 != 0)
throw new IllegalArgumentException(
"Chromosomze length must be an even number.");
if (decimalPlaces < 0)
throw new IllegalArgumentException("decimalPlaces must be >= 0");
List... | 9 |
public static void main(String[] args)
{
/***
* Dear TA's,
*
* There are certainly better ways of doing unit testing...
* I know this isn't software practices so I won't complain. However
* it may be advisable in the future to allow JUnit or frameworks of
* our own creation.
*
* <... | 8 |
private void updatePistonState(World par1World, int par2, int par3, int par4)
{
int var5 = par1World.getBlockMetadata(par2, par3, par4);
int var6 = getOrientation(var5);
boolean var7 = this.isIndirectlyPowered(par1World, par2, par3, par4, var6);
if (var5 != 7)
{
... | 6 |
private List<Issue> searchIssues(User visitor, Long creator, Long assignee, String title, String priority, String status) {
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Issue> criteriaQuery = criteriaBuilder.createQuery(Issue.class);
Root<Issue> fr... | 6 |
public final void initUI() {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.setBorder(BorderFactory.createEmptyBorder(40, 40, 40, 40));
setLayout(new BorderLayout());
panel.add(Box.createHorizontalGlue());
slider = new JSlider(0, 150, 0);
slider.setPreferred... | 5 |
public static void bellmanFord(int s) {
dist[s] = 0;
for (int k = 0; k < V - 1; k++)
for (int i = 0; i < V; i++)
for (int j = 0; j < adj[i].size(); j++) {
Edge neigh = adj[i].get(j);
int v = neigh.v, p = neigh.p;
if (dist[i] != INF && dist[i] + p < dist[v])
dist[v] = dist[i] + p;
}
... | 9 |
private void idct_direct(double F[][], double f[][]) {
double a[] = new double[N];
a[0] = sqrt(1. / N);
for (int i = 1; i < N; i++) {
a[i] = sqrt(2. / N);
}
double summ = 0;
double koeff = 0;
for (short i = 0; i < N; i++) {
for (short j =... | 5 |
public static void editEmployee() {
System.out.print("Pick employee number: ");
int choice = scInt.nextInt();
Prototype temp;
if ((choice > employeeList.size()) || (choice < 1)) {
System.err.println("Fatal Error! Number not on list!");
System.exit(1);
}
temp = employeeList.get(choice - 1);
employeeL... | 9 |
private void pause() throws InterruptedException {
if (ponderFactor == 0) return;
TimeUnit.MILLISECONDS.sleep(rand.nextInt(ponderFactor * 250));
} | 1 |
public static int parseTime(final String time) {
int sum = 0;
String buffer = "";
for (int i = 0; i < time.length(); i++) {
final char c = time.charAt(i);
if (Character.isDigit(c)) {
buffer += c;
} else {
int amount = Integer.... | 9 |
@Override
public boolean onCommand(CommandSender sender, Command command,
String label, String[] args) {
if(!sender.hasPermission(pluginMain.pluginManager.getPermission("thf.trains"))){
sender.sendMessage("");
... | 6 |
private void initSymbolTable()
{
symbolTable = new SymbolTable();
symbolTable.setParent(null);
symbolTable.setDepth(0);
symbolTable.insert("readInt");
symbolTable.insert("readFloat");
symbolTable.insert("printBool");
symbolTable.insert("printInt");
symbolTable.insert("printFloat");
symbolTable.inser... | 0 |
public ArrayList<Player> getPlayersInRadius(Entity e, int radius){
ArrayList<Player> result = new ArrayList<Player>();
float ex = e.getX();
float ey = e.getY();
for(int i = 0; i < players.size(); i++){
Player entity = players.get(i);
float x = entity.getX();
float y = entity.getY();
float dx = Math.... | 2 |
private void jButtonChangeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonChangeActionPerformed
try {
// TODO add your handling code here:
char[] mdp = jPasswordFieldOldPass.getPassword();
StringBuilder sb = new StringBuilder();
for (int ... | 7 |
public void genNotes(double c) {
double totalProb = 0;
// randomly generate Note length
for (int i = 0; i < prob.length; i++) {
if (possibleCount[i] <= c) {
totalProb += prob[i];
}
}
double randGen = Math.random() * totalProb;
int counter = -1;
while (randGen > 0) {
counter++;
if (possibl... | 7 |
public void setProblemList(ProblemList problemList) {
this.problemList = problemList;
} | 0 |
public void run(int gen, ArrayList<Section> current, int semlen) {
randomize(current); //randomize the order that the sections are in
establish(current, semlen); //establish the population to chromosome length of semlen
//Population is now set up, time to select for breeding
int i = 0;
ArrayList<... | 9 |
public void affichageTableur(String pretexte, ArrayList<ArrayList<Integer>> al)
{
System.out.println(pretexte);
System.out.println("[");
for(ArrayList<Integer> mot : al)
System.out.println("\tPosition : " + al.indexOf(mot) +"(" + tableurNonTrie.indexOf(mot) + ")\t" + mot);
... | 1 |
protected void paintTabs(Graphics g, Rectangle clip, Insets insets) {
int xOffset = getXOffset();
TabSet tabs = getTabSet();
int lastX = clip.x - 10;
int maxX = clip.x + clip.width + 10;
int maxY = getUnitsFontHeight() + TabHeight;
double zoom=1.0f;
if (getTextPane()... | 9 |
public boolean createWhen(){
if(grade=='c' || grade=='b')
return stage.count%(50*stage.fps/frequency+1)==0 && stage.second()>=startTime;
else
return stage.count%(300*stage.fps/frequency+1)==0 && stage.second()<=16 && stage.second()>=startTime;
} | 5 |
public static void cssDetails(File fileName, DetailObject detailObject) {
detailObject.updateNumberOfFiles();
DetailObject.updateTOTAL_NUMBER_OF_FILES();
try {
BufferedReader bufferedReader = new BufferedReader(new FileReader(fileName));
String line;
while ((line = bufferedReader.readLine()) != null) {
... | 6 |
public void broadcastMessage(String message, Client client, boolean fromGame) {
if (!fromGame && game != null
&& !game.parsePublicMessage(message, client)) {
return;
}
message = KCodeParser.parse(message, !client.isModerator(), 5, 10, 20);
message = Server.get().parseSmileys(message);
if (message.isE... | 5 |
public static boolean isTypeArray(Class<?> type) {
return (type != null && type.isArray());
} | 2 |
public static final List<Integer> getEnabledSecTypes() {
List<Integer> result = new ArrayList<Integer>();
result.add(secTypeVeNCrypt);
result.add(secTypeTight);
for (Iterator<Integer> i = enabledSecTypes.iterator(); i.hasNext();) {
int refType = (Integer)i.next();
if (refType < 0x100 && ref... | 3 |
public static <K, V extends Comparable<? super V>> Map<K, V>
sortByValue( Map<K, V> map )
{
List<Map.Entry<K, V>> list =
new LinkedList<Map.Entry<K, V>>( map.entrySet() );
Collections.sort( list, new Comparator<Map.Entry<K, V>>()
{
public int compare( Map.Ent... | 2 |
public static Collection<Roll> getInstance(){
if(roll_list==null){
roll_list=new ArrayList<Roll>();
}
return roll_list;
} | 1 |
protected BoundMethod match(PathPattern<Method> pattern, PathInput input, Object self) {
Method method = pattern.getTarget();
if (method != null) {
input.bind(method);
pattern.match(input);
return new BoundMethod(self, method, input.getParameters());
} else {... | 1 |
public HTTPRequestHandler()
{
} | 0 |
public Object remove(Object key) {
accessTimes.remove(key);
return map.remove(key);
}//remove | 0 |
@PUT
@Path("/{id}")
@Consumes(MediaType.APPLICATION_JSON)
public Response updateCustomer(final @PathParam("id") int id, Customer cust) {
if (id != cust.getId()) {
throw new WebApplicationException(Response.status(Status.CONFLICT)
.entity("Cannot change id of existing customer.").build());
}
validateCus... | 1 |
public void addBall()
{
try
{
Ball ball = new Ball();
comp.add(ball);
for (int i = 1; i <= STEPS; i++)
{
ball.move(comp.getBounds());
comp.paint(comp.getGraphics());
Thread.sleep(DELAY);
}
}
catch (InterruptedEx... | 2 |
public void createItem(int newItemID) {
int Maxi = server.itemHandler.DropItemCount;
for (int i = 0; i <= Maxi; i++) {
if (server.itemHandler.DroppedItemsID[i] < 1) {
server.itemHandler.DroppedItemsID[i] = newItemID;
server.itemHandler.DroppedItemsX[i] = (absX);
server.itemHandler.DroppedItemsY[i] = ... | 4 |
static public void adjustBeginLineColumn(int newLine, int newCol)
{
int start = tokenBegin;
int len;
if (bufpos >= tokenBegin)
{
len = bufpos - tokenBegin + inBuf + 1;
}
else
{
len = bufsize - tokenBegin + bufpos + 1 + inBuf;
}
int i = 0, j = 0, k = 0;
... | 6 |
public void disconnect() {
ClientDisconnectMessage cdm = new ClientDisconnectMessage(username);
try {
output.writeObject(cdm);
} catch (IOException e) {
System.out.println("Exception with sending disconnect message " + e);
}
try {
if(input != null) input.close();
}
catch(Exception e) {}
... | 7 |
public void concatenar(Lista<E> pLista){
if(talla == 0){
cabeza = pLista.getHead();
talla = pLista.getTalla();
cola = pLista.getTail();
return;
}
cola.siguiente = pLista.getHead();
pLista.getHead().previo = cola;
cola = pLista.getTa... | 1 |
public GameBoard() {
board = new Piece[8][8];
hcolor = new Color(1.0f, 1.0f, 0, 0.5f);
bBlack = new Color(80, 48, 18);
bWhite = new Color(193, 144, 97);
try {
Image spritesheet = new Image("data/pieces.png");
pieces = new Image[6][2];
for (int ... | 3 |
public static Quiz getQuizByQuizID(int quizID) {
String statement = new String("SELECT * FROM " + DBTable + " WHERE qid = ?");
PreparedStatement stmt;
try {
stmt = DBConnection.con.prepareStatement(statement);
stmt.setInt(1, quizID);
ResultSet rs = stmt.executeQuery();
if (!rs.next()) {
System.out... | 2 |
public boolean validatePayment(Transaction transaction) {
String paymentType = transaction.getPayment().toString();
boolean paid = false;
switch (paymentType) {
case "CashPayment":
registerUI.setCashPayment();
break;
case "CreditPayment":
registerUI.setCreditPayment();
paid = transaction.get... | 5 |
private void ensureSubItemsLoaded() {
if (loadedSubItems)
return;
loadedSubItems = true;
if (getFirst() != null) {
// get first child
Reference nextReference = getFirst();
Reference oldNextReference;
OutlineItem outLineItem;
... | 5 |
@Override
public boolean init(List<String> argumentList, DebuggerVirtualMachine dvm) {
if (argumentList.size() > 0) {
UserInterface.println("This command takes no arguments.");
HelpCommand.displayHelp(this);
return false;
}
breakpoints = new ArrayList<Str... | 3 |
private void setObstacleVelocity(float[][] u, float[][] v) {
int count = 0;
float uw, vw;
for (int i = 1; i < nx1; i++) {
for (int j = 1; j < ny1; j++) {
if (!fluidity[i][j]) {
uw = uWind[i][j];
vw = vWind[i][j];
count = 0;
if (fluidity[i - 1][j]) {
count++;
u[i][j] = uw - u... | 8 |
@Override
public void focusLost(FocusEvent arg0) {
try {
String Str = _view.edt_ID.getText();
if (!Str.isEmpty()) {
search(Integer.parseInt (Str));
}
} catch (NullPointerException E){
Er... | 3 |
@Override
public void close() throws AudioDeviceException {
boolean failed = false;
for ( AudioDevice dev : this.mDevices ) {
try {
dev.close();
}
catch (AudioDeviceException e) {
failed = true;
}
}
if ( failed ) {
throw new AudioDeviceException( "couldn't close all of the underlying Aud... | 3 |
public int compareTo(Object o)
{
Location l = (Location)o;
if (l.prio < prio) return 1;
if (l.prio > prio) return -1;
return 0;
} | 2 |
public void updateLongestRoad(int p) {
if (_numRoads[p] > _longestRd) {
if (_longestRd_Owner != -1) {
_points[_longestRd_Owner] -= 2;
}
_points[p] += 2;
_longestRd = _numRoads[p];
if (p == _playerNum && p != _longestRd_Owner) {
_chatBar.addLine("9" + "You have the Largest Road Network! You n... | 6 |
@Override
public void onMessage(String channel, String sender, String message) {
String filter = MdBtConstants.BOTNAME + ": ";
boolean toMe = false;
boolean shouldLearn = !sender.equals("habbes")
&& !sender.equals("mlvn");
if (message.startsWith(filter)) {
toMe = true;
message = message.replaceFir... | 8 |
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
if (!this.pretarate()) {
this.msg("Campos incompletos o erróneos.");
}
}//GEN-LAST:event_jButton1ActionPerformed | 1 |
public boolean isVariable(String variable) {
return myVariables.contains(variable);
} | 0 |
public T[] getBFS() {
Queue<Node<T>> queue = new ArrayDeque<Node<T>>();
T[] values = (T[]) new Comparable[size];
int count = 0;
Node<T> node = root;
while (node != null) {
values[count++] = node.id;
if (node.lesser != null)
queue.add(node.l... | 4 |
private CtField getDeclaredField2(String name) {
CtMember.Cache memCache = getMembers();
CtMember field = memCache.fieldHead();
CtMember tail = memCache.lastField();
while (field != tail) {
field = field.next();
if (field.getName().equals(name))
re... | 2 |
static void DVP()
{
Scanner in = new Scanner(System.in);
final Board b = Board.readBoard(in);
ArrayList<Integer> nextPiece = new ArrayList<Integer>();
while(in.hasNextInt())
nextPiece.add(in.nextInt());
Searcher s;
for (int i = 2; i < 7; i++){
s = new DLDFS(new LinearWeightedSum(new double[] {... | 6 |
public float[][] getM()
{
float[][] res = new float[4][4];
for(int i = 0; i < 4; i++)
for(int j = 0; j < 4; j++)
res[i][j] = m[i][j];
return res;
} | 2 |
public void consolidate(){
// add feedback boxes to forward path boxes
this.closedPath = this.forwardPath.copy();
for(int i=0; i<this.nFeedbackBoxes; i++){
this.closedPath.addBoxToPath(this.feedbackPath.get(i));
}
// combine forward path boxes
this.forwardPa... | 4 |
public void processImage() throws Exception {
byte[] originalImageBytes = baseImageProvider.getImage();
byte[] watermarkImageBytes = watermarkImageProvider.getImage();
if (originalImageBytes == null) {
throw new Exception("Original Image is not loaded");
}
if (water... | 4 |
public static void main(String [] args){
ExecutorService executor= Executors.newFixedThreadPool(numThreads);
List<Future<Long>> list=new ArrayList<Future<Long>>();
for(int i=0; i<20000; i++){
Callable<Long> worker=new MyCallable();
Future<Long> submit=executor.submit(wor... | 4 |
public void removePush() {
if (exprStack != null)
instr = exprStack.mergeIntoExpression(instr);
super.removePush();
} | 1 |
public String createMaskFromDatePattern(String datePattern) {
String symbols = "GyMdkHmsSEDFwWahKzZ";
String mask = "";
for (int i = 0; i < datePattern.length(); i++) {
char ch = datePattern.charAt(i);
boolean symbolFound = false;
for (int n = 0; n < symbols.l... | 4 |
public static boolean fileprocess(String downloadpath, String filepath, String []paras, String sn){
int errorcode=0;// print error code in the final output file;
int errornum = 14;
String result="";
File downloadfile = new File(downloadpath+"\\temp_test.txt");
File outputfile = new File(filepath);
doub... | 8 |
@Override
public void applyAllChanges() throws ApplyChangesException {
// Make a "backup" first
Document backup = null;
try {
TransformerFactory tfactory = TransformerFactory.newInstance();
Transformer tx = tfactory.newTransformer();
DOMSource source = n... | 4 |
@Override
public synchronized Voiture circule() {
Voiture v;
int length = vehicules.length;
for (int i = length - 1; i >= 0; i = i - 1) {
v = vehicules[i];
if (v != null) {
v.avancer();
}
}
if (waittingForInsertion == null) {
return null;
}
v = waittingForInsertion;
waittingForInsert... | 3 |
public static String getID(ProjectileType type){
switch(type){
case BOULDER:
return "boulder";
case FIREBALL:
return "fireball";
case ICE_SPIKE:
return "icespike";
case ITEM:
return "item";
case SPELL:
return "greenfire";
case ELECTRO_BALL:
return "electroball";
default:
return "";
... | 6 |
public static File moveFile(File sourceFile, File destinationDir)
{
if (destinationDir == null || !destinationDir.isDirectory ())
return null;
File movedFile = new File (destinationDir.getAbsolutePath () + File.separator
+ sourceFile.getName ());
if (sourceFile.renameTo (movedFile))
return movedF... | 3 |
public static Contributor findContributor(String domain) {
loadContributors();
Contributor contributor = Contributor.contributors.get(domain);
if(contributor == null) {
for(Contributor cont : Contributor.contributors.values()) {
if(cont.getDomain().equalsIgnoreCase(domain) ||
cont.getName().equ... | 6 |
public void run(){
while(this.status == Bullet.ALIVE){
try {
Thread.sleep(Constant.bullet_sleep_time);
} catch (InterruptedException e) {
e.printStackTrace();
}
if( Game.status == Game.STATUS_ON){//judge the status
if(judgeIfIn()){
if( this.status == Bullet.ALIVE){
this.m... | 5 |
public void stop()
{
if ( !isRunning )
return;
isRunning = false;
} | 1 |
public boolean codopValido(String cod){
int punto=0, tam=cod.length();
boolean flag=false;
if(tam > 5){
return false;
}
else
if(!Character.isLetter(cod.charAt(0))){
return false;
}
else{
for(int i=1;i<tam && !flag;i++){
if(!(Character.isLetter(cod.c... | 9 |
public void vecinos_apartir_inicio(Casilla nodopadre){
//verificar que no esten en lista cerrada
if(nofin==0){
int tamCerrado=listas.tamañoL_Cerrados();
Casilla temp =new Casilla();
Casilla ini =new Casilla();
int xi=nodopadre.getcordena... | 8 |
@Override
Color getColor(String color) {
if (color == null) {
return null;
}
if (color.equalsIgnoreCase("RED")) {
return new Red();
} else if (color.equalsIgnoreCase("GREEN")) {
return new Green();
} else if (color.equalsIgnoreCase("BLUE")) {
return new Blue();
}
return null;
} | 4 |
public static ColorRGBA getColor(int type) {
switch(type) {
case GRASS:
return new ColorRGBA(0.2f, 0.8f, 0.2f, 1.0f);
case DIRT:
return new ColorRGBA(0.3f, 0.3f, 0f, 1.0f);
case STONE:
return new ColorRGBA(0.6f, 0.6f, 0.6f, 1.0f... | 7 |
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 boolean isPermutation_Hashtable(String s1, String s2){
if(s1.length() != s2.length())
return false;
Hashtable<Character,Integer> ht = new Hashtable<Character,Integer>();
//put all characters in s1 to the hash table
for(int i=0;i<s1.length();i++){
char k = s1.charAt(i);
if(!ht.containsKey(k))... | 7 |
private void updateLocations(GameContainer gc, StateBasedGame sbg)
throws SlickException {
//Update the bullet's position.
for(int i = 0;i<bulletList.size();i++){
Bullet bullet = bulletList.get(i);
bullet.move();
// Removes bullets that go off screen.
if ((bullet.returnX() > 639 || bullet.returnX() ... | 8 |
public void setIdPos(int idPosLogEnt) {
this.idPosLogEnt = idPosLogEnt;
} | 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.