text stringlengths 14 410k | label int32 0 9 |
|---|---|
@Test
public void testTimeTrue() {
try {
for (int i = 0; i < 1000; i++) {
account.buyShare("daniel", "BMW", 2);
account.sellShare("daniel", "BMW", 2);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BuySellHistory history = account.getA... | 3 |
@Test
public void resolve() {
for (int c = 999; c > 0; c--) {
for (int b = 1000 - c; b > 0; b--) {
int a = 1000 - b - c;
if (c > b && b > a && a > 0 && b > 0 && c > 0) {
if ((a * a + b * b) == c * c) {
print(a, b, c, a * b * c);
}
}
}
}
} | 8 |
public void setAge(int age) {
this.age = age;
} | 0 |
private String calcularTam(Double tam)
{
int cont = 2;
while(cont != 0 & tam >= 1024)
{
cont--;
tam = tam / 1024;
}
DecimalFormat df = new DecimalFormat("#.##");//Redondear
if(cont==2)
return df.format(tam) + " Byt... | 4 |
public void setConnectionInfo(ConnectionInfo connectionInfo) {
this.connectionInfo = connectionInfo;
} | 0 |
public static void newSkin(String... strings) {
if (strings.length != 4) {
throw new IllegalArgumentException();
}
if ((strings != null) && (model != null)) {
Skin newSkin = model.newSkin(strings[0], strings[1], strings[2], strings[3] == null ? null : Paths.get(strings[3... | 6 |
public String getTableFieldString() {
return tableFieldString;
} | 0 |
protected void doPrintHeader() {
if (m_Header.classAttribute().isNominal()) {
if (m_OutputDistribution) {
append("inst#" + m_Delimiter + "actual" + m_Delimiter + "predicted" + m_Delimiter + "error" + m_Delimiter + "distribution");
for (int i = 1; i < m_Header.classAttribute().numValues(); i++)
append(m_D... | 8 |
public void joined(ViewProxy proxy, String name) {
int id;
if (names[PLAYER_ONE - 1] == null) {
names[PLAYER_ONE - 1] = name;
id = PLAYER_ONE;
}
else {
names[PLAYER_TWO - 1] = name;
id = PLAYER_TWO;
//Tell player 2 about player 1
modelListeners.get(id-1).playerInfo(PLAYER_ONE, names[PL... | 3 |
public void integrityTime() {
if(this.getHour() == 24) {
this.setHour(0);
}
if(this.getMinutes() == 60) {
this.setMinutes(0);
this.setHour(this.getHour()+1);
}
if(this.getSeconds() == 60) {
this.setSeconds(0);
this.setMinutes(this.getMinutes()+1);
}
} | 3 |
private void restrictDepamandsFromSourceToTargetNodes() throws IloException {
Demand demand;
Node node;
IloLinearNumExpr flow;
for (int i = 0; i < nodes.length; i++) {
node = nodes[i];
for (int k = 0; k < demands.length; k++) {
flow = cplex.linearNumExpr();
// soma custos saindo do vertice
fo... | 6 |
private static Listing parseListing(StringBuilder l) {
html2xhtml(l);
// System.out.println(l);
Listing listing = new Listing();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
// Using factory get an instance of document builder
DocumentBuilder db = dbf.newDocumentBuilder()... | 9 |
public static String compression(String s) {
if(s == null || s.length() <= 2)
return s;
char start = s.charAt(0);
int count = 1;
StringBuilder result = new StringBuilder();
for(int i=1; i<s.length() ;i++) {
char c = s.charAt(i);
if( c == start )
count++;
else {
result.append(start + "" +... | 6 |
public P_BulkMakeTab(){
this.setLayout(new BorderLayout());
topPane = new JPanel();
keyLabel = new JLabel("Key");
keyTxtFld = new JTextField(10);
keyLabel = new JLabel("Enter key and tick checkbox to print just one card");
singleCardCB = new JCheckBox();
topPane.add(keyLabel);
to... | 7 |
private static int findDecBack(int[] A, int index){
for(int i=index-1;i>0;i--){
if(A[i] <= A[i-1]){
return index-i+1;
}
}
return index+1;
} | 2 |
private Char(BufferedImage charImage){
//kijken hoe breed een char is
int charWidth = charImage.getWidth() - 1;//standaardlengte, voor spatie en onbekende letters
for(int x = 0; x < charImage.getWidth(); x++){
boolean rowIsEmpty = false;
for(int y = 0; y < charImage.getHeight(); y++){
if(char... | 6 |
public void suffixTreeRec(ArrayList<String> SuffixList,TreeNode currentNode,int textSize)
{
ArrayList<ArrayList<String>> currentGroupList = makeGroup(SuffixList);
//old
//for(int i=0;i<currentGroupList.size();i++)
//{
//new
while(currentGroupList.size()>0)
{
ArrayList<Strin... | 3 |
private static void loadContributors() {
if(Contributor.contributors == null) {
Contributor.contributors = new HashMap<String, Contributor>();
SettingsProcessor processor = new SettingsProcessor(Contributor.contributors);
try {
Settings.getInstance().processNodes("/c:settings/c:contributors/c:contrib... | 5 |
boolean first(TK [] set) {
int k = 0;
while(set[k] != TK.none && set[k] != tok.kind) {
k++;
}
return set[k] != TK.none;
} | 2 |
public int getR() {
return this.r;
} | 0 |
public final void testReadPropertyDestinationIntIntIntInt() throws KNXException,
InterruptedException
{
try {
mc.readProperty(dco, -1, 2, 1, 1);
fail("invalid arg");
}
catch (final KNXIllegalArgumentException e) {}
try {
mc.readProperty(dco, 256, 2, 1, 1);
fail("invalid arg");
}
catch (final ... | 8 |
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 static double logGammaFunction(double x) {
double xcopy = x;
double fg = 0.0D;
double first = x + lgfGamma + 0.5;
double second = lgfCoeff[0];
if (x >= 0.0) {
first -= (x + 0.5) * Math.log(first);
for (int i = 1; i <= lgfN; i++)
second += lgfCoeff[i] / ++xcopy;
fg = Math.log(Math.sqrt(2.0... | 5 |
public void draw() {
if (context != null) {
double width;
if(isPlacedOnLeftOrRight()){
width = this.leftOrRightWidth;
}else{
width = this.topOrBottomWidth;
}
Rectangle2D legendArea = new Rectang... | 8 |
protected Node find(E e)
{
if (isEmpty())
return null;
Node u = root;
while (u.key != e && comparator.compare(e, u.key) != 0)
{
if (comparator.compare(e, u.key) < 0)
u = u.left;
else u = u.right;
if (u == null) retur... | 5 |
public String toString(Rarity r) throws IOException {
String name;
switch(r) {
case BASIC: name = "basic";
case FINE: name = "fine";
case MASTERWORK: name = "masterwork";
case RARE: name = "rare";
case EXOTIC: name = "exotic";
case ASCENDED: name = "ascended";
case LEGENDARY: name = "legendary"... | 8 |
public static void useStemmer(Stemmer stemmer, String[] options)
throws Exception {
Reader reader;
StringBuffer input;
Writer output;
String tmpStr;
boolean lowerCase;
// help?
if (Utils.getFlag('h', options)) {
System.out.println(makeOp... | 9 |
public void addAttendantToCourse(int courseId, int studentId) {
if(!isValidId(courseId) || !isValidId(studentId)) {
return;
}
Student student = studentDao.getStudent(studentId);
Course course = courseDao.getCourse(courseId);
if(student != null && course != null) {
course.getAttendants().add(stud... | 4 |
public void createDatabase(File databaseFile, File sqliteStatements) throws SQLException {
databaseFile.delete();
parseSqlite(sqliteStatements);
Connection connection = null;
Statement stmt = null;
ResultSet rs = null;
int result;
try {
String... | 6 |
public void actionPerformed(ActionEvent event) {
double a = Double.parseDouble( txtA.getText());
double b = Double.parseDouble( txtB.getText());
double c = 0;
String op = (String) ops.getSelectedItem();
if (op.equalsIgnoreCase("add"))
c = a + b... | 4 |
public static void initialize() {
Interperet.corner = fenrir.getCorner();
Interperet.setFirstPick();
System.out.println(Interperet.corner);
for (int i = Calculate.lookAhead - 1; i >= 0; i--) {
if (i < Calculate.lookAhead - 1 ) {
Calculate.scenarios[i] = new Gr... | 2 |
public void update(float gravity) {
currentAction.update();
currentAnimation.update();
velocityY += gravity;
if (velocityY < -20) velocityY = -20;
else if (velocityY > 20) velocityY = 20;
if (velocityX > 8) velocityX = 8;
else if (velocityX < -8) velocityX = -8... | 6 |
public void testMultipliedBy_int() {
Weeks test = Weeks.weeks(2);
assertEquals(6, test.multipliedBy(3).getWeeks());
assertEquals(2, test.getWeeks());
assertEquals(-6, test.multipliedBy(-3).getWeeks());
assertSame(test, test.multipliedBy(1));
Weeks halfMax = Weeks... | 1 |
public void setBlogCreatedDate(Date blogCreatedDate) {
this.blogCreatedDate = blogCreatedDate;
} | 0 |
public MetroGraph() throws DAOException {
DAOFactory factory = DAOFactory.getInstance();
DaoStation daoStation = factory.getDaoStation();
DaoMetroGraph daoMetroGraph = factory.getDaoMetroGraph();
vertices = new ArrayList<Vertex>();
// 1. Créer des objets Vertex sans Edge
List<Station> allStati... | 4 |
public static void main(String[] args) {
String startJobId = "job_201301281455_0001";
String hostname = "master";
int iterateNum = 192;
//String hostname = "m105";
//int iterateNum = 1;
//String jobDir = "/home/xulijie/MR-MEM/BigExperiments/";
String jobDir = "/home/xulijie/MR-MEM/SampleExperiments/";
... | 4 |
private void begin() {
geraCrivo();
int n = Integer.parseInt(readLn());
while (n != 0) {
if (n == 1) {
System.out.println("1 = 1");
} else if (n == -1) {
System.out.println("-1 = -1");
} else {
StringBuffer out = new StringBuffer();
out.append(n);
out.append(" = ");
if (n < 0) {
... | 9 |
public MoveResult resolveMove(StrategyBoard gameBoard, PlayerColor currentTurn,
PieceType pieceMoving, Location fromLocation, Location toLocation)
{
final MoveResult firstResult;
final Piece attacker = gameBoard.getPieceAt(fromLocation);
final Piece defender = gameBoard.getPieceAt(toLocation);
final MoveRe... | 9 |
protected void threadStarted() {
// wait for the SoundManager constructor to finish
synchronized (this) {
try {
wait();
}
catch (InterruptedException ex) { }
}
// use a short, 100ms (1/10th sec) buffer for filters that
// chang... | 2 |
public void drawRotated(Bitmap bitmap, int xOffs, int yOffs, int xo, int yo, int w, int h, int rotation) {
final double radians = Math.toRadians(rotation);
final double cos = Math.cos(radians);
final double sin = Math.sin(radians);
for(int y = 0; y < w; y++){
int yPix = y + y... | 9 |
private ModNode createChildNode(Element eTable) {
ModNode tableNode = new ModNode("", "");
String tempName = "";
String eName = "";
NodeList nNodeList = eTable.getChildNodes();
for (int j = 0; j < nNodeList.getLength(); j++) {
Node nNode = nNodeList.item(j);
if (nNode.getNodeType() == Node.ELEMENT_NODE)... | 9 |
public void draw(Bitmap bitmap, int xo, int yo) {
for (int y = 0; y < bitmap.height; y++) {
int yy = y + yo;
if (yy < 0 || yy >= this.height)
continue;
for (int x = 0; x < bitmap.width; x++) {
int xx = x + xo;
if (xx < 0 || xx >= this.width)
continue;
int color = bitmap.pixels[x + y * bi... | 7 |
public int node_alloc(int size) {
int idx;
int pidx;
if (size <= 0) {
System.err.println("node alloc: wrong size");
return 0;
}
pidx = FREE_NODE;
for (idx = free_head.next_idx; idx != FREE_NODE; idx = trie_buf[idx].free.next_idx) {
if (trie_buf[idx].free.size >= size) {
break;
}
pidx =... | 7 |
@Override
public void createFromXML(NodeList attributes) {
Node node = attributes.item(0);
while(node != null) {
GameActor a = null;
float X = 0;
float Y = 0;
if(node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equalsIgnoreCase("actor")) {... | 8 |
private boolean jj_2_66(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_66(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(65, xla); }
} | 1 |
public PhoneNumber(String phoneNum) {
phoneNum = phoneNum.replaceAll("-|\\s|\\.|\\(|\\)", "");
boolean isValid = true;
if (phoneNum.length() != 10)
isValid = false;
for (int i = 0; isValid && i < 10; i++)
if (!Character.isDigit(phoneNum.charAt(i)))
isValid = false;
if (isValid) {
areaCode = pho... | 5 |
public List<Entity> getEntitiesInRange(double x, double y, double radius) {
ArrayList<Entity> list = new ArrayList<Entity>();
for(Entity entity : entities) {
if(entity != null && !entity.isDead && entity.getDistance(x, y) <= radius) {
list.add(entity);
}
}
return list;
} | 4 |
public void outputAnnotationIndex(PrintWriter writer)
{
for (String ann : annotationIndex.keySet())
{
writer.print(ann);
writer.print(": ");
Set<String> classes = annotationIndex.get(ann);
Iterator<String> it = classes.iterator();
while (it.hasNext())
... | 3 |
public static int[][] toPrintable(int[] buildings) {
// 1 row for bottom 2 cols for walls and 2 for heights
int[][] res = new int[max(buildings)][buildings.length + 4];
for (int i = 0; i < res.length; i++) {
Arrays.fill(res[i], BLANK);
}
// Side walls
for (int... | 9 |
public static Blob getMstxAdsImageByGpid(int gpid) {
Blob result = null;
Connection con = DBUtil.getConnection();
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = con.prepareStatement("select gdata from mstx_ads_image where gpid = ?;");
pstmt.setInt(1, gpid);
rs = pstmt.executeQuery... | 8 |
@Override
public NettyHttpResponse error(Throwable error) {
if (error instanceof TooLongFrameException) {
response.setStatus(HttpResponseStatus.REQUEST_ENTITY_TOO_LARGE);
} else {
response.setStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);
}
// String message... | 3 |
static Object redirect(Object proxy, InvocationHandler handler, Method m,
Object... args) throws Throwable {
try {
return handler.invoke(proxy, m, args);
} catch (final Throwable t) {
if (t == null)
throw new Exception(
"An exception was here, but apparently it decided to g... | 6 |
public void actionPerformed(ActionEvent evt) {
viewer.moveFocusToDesktop();
if (evt.getSource() == disconnectButton) {
viewer.disconnect();
} else if (evt.getSource() == optionsButton) {
viewer.options.setVisible(!viewer.options.isVisible());
} else if (evt.getSource() == recordButton) {
viewer.rec... | 8 |
public static final Color checkColour(int red, int green, int blue)
{
if (red < 0)
red = 0;
else if (red > 255)
red = 255;
if (green < 0)
green = 0;
else if (green > 255)
green = 255;
if (blue < 0)
blue = 0;
else if (blue > 255)
blue = 255;
return new Colo... | 6 |
static Line[] mergeSegments(Line[] segsOrig) {
int n = segsOrig.length;
Line[] segs = new Line[n];
for (int i = 0; i < n; i++) {
segs[i] = segsOrig[i].a.compareTo(segsOrig[i].b) < 0
? segsOrig[i]
: new Line(segsOrig[i].b, segsOrig[i].a);
... | 8 |
public State read_state() {
State state = new State();
int i, j;
for (i = 0, j = 0; i < 3; i++, j += 7) {
WaveformGenerator wave = voice[i].wave;
EnvelopeGenerator envelope = voice[i].envelope;
state.sid_register[j + 0] = (char) (wave.freq & 0xff);
state.sid_register[j + 1] = (char) (wave.freq >> 8);... | 9 |
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
BeanInfo other = (BeanInfo) obj;
if (type == null) {
if (other.type != null)
return false;
} else if (!type.equals(other.type))
retur... | 6 |
@Override
public void buy(Command cmd)
{
cmd.execute();
if(Storage.getInstance().getRevenue() < 10000.0)
{
restaurant.setState(restaurant.getBadstate());
}else if(Storage.getInstance().getRevenue() >= 10000.0 && Storage.getInstance().getRevenue() < 20000.0)
{
restaurant.setState(restaurant.getNormalst... | 3 |
public int indexOf(Object inputData) {
ListNode currentNode = this.firstNode;
int position = 0;
boolean found = false;
for (; ; position++) {
if (currentNode == null) {
break;
}
if (inputData.equals(currentNode.getData())) {
... | 4 |
@Override
public void nativeKeyReleased(NativeKeyEvent arg0) {
// TODO Auto-generated method stub
if (lastkey==arg0.getKeyCode()){
ignore=false;
} else {
}
//ctrl+v (when keeping ctrl pressed nothing gets typed)
if (arg0.getKeyCode()==KeyEvent.VK_CONTROL && this.readyToType){
try {
Str... | 9 |
public void updateImage()
{
delayCounter++;
if(delayCounter>delay)
{
delayCounter=0;
frameNumber++;//updates frame to next frame
frameNumber%=totalFrame;// if surpass 3rd frame, back to frameNumber 0
//sets image to specific frameNumber by multiplying it with 500, aka width of the image
this.setImage(f... | 1 |
public PushedNotifications sendPayload(Payload payload, String[] deviceTokens)
throws CommunicationException, KeystoreException {
PushedNotifications notifications = new PushedNotifications();
if (payload == null) {
return notifications;
}
try {
if (!isConnected) {
initialize... | 5 |
public static void generateCornerHeuristics() {
// Make a cube and initialize it with a solved cube state
Cube cube = new Cube(Cube.GOAL.toCharArray());
// Make a new Queue to perform BFS
Queue<CubeNode> q = new LinkedList<CubeNode>();
// Put the solved/initial state of the corners on the queue
q.add(new ... | 4 |
public void merge(LeftistTreeNode root, LeftistTreeNode newNode) {
// Considering the tree.element with largest value on the top
if (root.parent == null && root.value.compareTo(newNode.value) < 0) { // invert here to change to small priority on top
if (newNode.right == null) {
... | 5 |
private static void displayEmployees(ResultSet rs)throws SQLException{
StringBuffer bf = new StringBuffer();
while (rs.next()){
bf.append(rs.getString("name")+" ");
bf.append(rs.getString("username")+" ");
bf.append(rs.getString("pass")+" ");
bf.append(rs.getDate("dob")+" ");
bf.append(rs.getStrin... | 1 |
public static void write(Writer output, AuTerm term) throws IOException {
if(term.getAnnotation() != null) {
output.write('@');
write(output, term.getAnnotation());
}
if(term instanceof AuMeta) {
output.write('M');
}else if(term instanceof AuVar) {
AuVar var = (AuVar)term;
output.write('V');
... | 7 |
public CommonResponse(final Boolean success, final String errorMessage) {
if (success != null) {
this.success = success;
}
if (errorMessage != null) {
this.errorMessage = errorMessage;
}
} | 2 |
public int len() {
return MPI_string.length;
} | 0 |
public String getGeneId() {
// Try ID
String geneId = get("id");
if (geneId != null) return geneId;
// Try 'locus'...
geneId = get("locus_tag");
if (geneId != null) return geneId;
// // Try 'gene'...
// geneId = get("protein_id");
// if (geneId != null) return geneId;
//
// // Try 'db_xref'.... | 2 |
public static boolean test(String falseString, String trueString) throws IOException{
InStream sr = new StringInStream(falseString);
OutStream sw = new StringOutStream();
FormatSettings formatSettings = new FormatSettings();
FormatOld.format(sr, sw, formatSettings);
if(trueStr... | 1 |
private int jjMoveStringLiteralDfa0_0()
{
switch(curChar)
{
case 35:
return jjStopAtPos(0, 13);
case 43:
return jjStopAtPos(0, 6);
case 44:
return jjStopAtPos(0, 9);
case 45:
return jjStopAtPos(0, 5);
case 46:
return jjStopAtPos(0, 7);
... | 9 |
public static int[] getLongestIncreasingSubsequence(int[] sequence) {
int[] start = new int[sequence.length + 1];
int[] previous = new int[sequence.length];
int length = 0;
int low;
int mid;
int high;
int newLength;
for(int i = 0; i < sequence.length; i++) {
low = 1;
high = length;
while(low ... | 6 |
@Override
public void destroy() {
for(ActorSlot as : actors) {
Application.get().getEventManager().queueEvent(new ActorDestroyedEvent(as.actor));
}
} | 1 |
@SuppressWarnings("rawtypes")
public void checkCollisions()
{
Rectangle r3 = prometheus.getBounds();
/*for (int j = 0; j<aliens.size(); j++)
{
Alien a = (Alien) aliens.get(j);
Rectangle r2 = a.getBounds();
if (r3.intersects(r2))
{
... | 3 |
private boolean validElement(Element element, Position position) {
if (element == null || position == null)
return false;
for (Map.Entry<Position, Square> entry : squares.entrySet())
if (entry.getValue().getElements().contains(element))
return false;
return getSquare(position).validElement(element);
... | 4 |
void constructNearestGraph() {
_Doc di, dj;
double similarity;
MyPriorityQueue<_RankItem> kUL = new MyPriorityQueue<_RankItem>(m_GFObj.m_k);
MyPriorityQueue<_RankItem> kUU = new MyPriorityQueue<_RankItem>(m_GFObj.m_kPrime);
_Node node;
for (int i = m_start; i < m_end; i++) {
di = m_GFObj.getTestDoc... | 6 |
public void load(File f) throws IOException {
DOMParser parser = new DOMParser();
if (f == null) {
System.out.println("File is null!");
}
try {
FileInputStream fis = new FileInputStream(f);
InputSource s = new InputSource(fis);
parser.parse(s);
} catch (SAXException e) {
// throw new IOException... | 4 |
public final GramaticaAst.expr_arith_return expr_arith() throws RecognitionException {
GramaticaAst.expr_arith_return retval = new GramaticaAst.expr_arith_return();
retval.start = input.LT(1);
Object root_0 = null;
Token MULT107=null;
Token DIV108=null;
Token MOD109=nu... | 8 |
public static void main(String [] args ) {
//Start time
double startTime = System.currentTimeMillis();
long i = 0;
long sum = 0;
while (i < 2000000){
if( isPrime(i) ) {
sum += i;
}
i++;
}
System.out.println(sum);
//End time
double endTime = System.currentTimeMillis();
... | 2 |
public static boolean valueClashesWithSkolemP(Skolem skolem, Stella_Object value) {
{ Surrogate type = skolem.skolemType;
if (type == null) {
return (false);
}
else if (!(((((QueryIterator)(Logic.$QUERYITERATOR$.get())) != null) &&
(((QueryIterator)(Logic.$QUERYITERATOR$.get()))... | 6 |
public static Map<term_t, Variable> namevarsToMap(Term nvs) {
try {
Map<term_t, Variable> vars_to_Vars = new HashMap<term_t, Variable>();
// while (nvs.isListPair() && nvs.arg(1).hasFunctor("=", 2)) {
while (nvs.arity() == 2 && (nvs.name().equals(JPL.LIST_PAIR_MODERN) || nvs.name().equals(JPL.LIST_PAIR_TRADI... | 5 |
public static int moreThanHalfTwo(int[] array){
int element = array[0];
int count = 1;
for(int i = 1;i<array.length;i++){
if(count == 0){
element = array[i];
}
if(array[i] == element){
count ++;
}else{
count --;
}
}
return element;
} | 3 |
private static byte[] readFile(String file) throws IOException {
// Open file
RandomAccessFile f = new RandomAccessFile(new File(file), "r");
try {
// Get and check length
long longlength = f.length();
int length = (int) longlength;
if (length != l... | 1 |
private void drawPieces(Graphics2D g2d) {
drawBoard.calculateTerritory();
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
if (drawBoard.getContents(i, j) != Intersection.Piece.EMPTY) {
if (drawBoard.getContents(... | 7 |
private static synchronized void ckpl() {
if(enabled) {
if(player == null) {
player = new Player();
player.start();
}
} else {
ncl.clear();
}
} | 2 |
public boolean isHitBrick(Brick brick) {
// TODO: change to event driven
if (this.getRect().intersects(brick.getRect()) && brick.getLive() == true) {// getRect创建矩形,用于判断碰撞,intersects方法用于判断矩形是否相交见api与tank1.6
if (y - YSPEED <= brick.getTop())
moveToDown = false;// 判断球与板碰撞以后改变球的运动方向,向上
else if (y + YSPEED >= ... | 6 |
public void setConcepto(String concepto) {
this.concepto = concepto;
} | 0 |
public boolean isWASD(int keyCode)
{
return keyCode == KeyEvent.VK_W || keyCode == KeyEvent.VK_A || keyCode == KeyEvent.VK_S || keyCode == KeyEvent.VK_D;
} | 3 |
public synchronized void change(T t, K k)
{
TreeSet<K> tKs=map1.get(t);
while((tKs!=null)&&(tKs.size()>=maxKsInMap1))
remove(t,tKs.first());
tKs=map1.get(t);
if(tKs==null)
{
tKs=new TreeSet<K>(comparator);
map1.put(t, tKs);
}
TreeSet<T> kTs=map2.get(k);
while((kTs!=null)&&(kTs.size()>=maxTsInM... | 8 |
public static void setupOpenGL() {
try {
if (FULLSCREEN && Display.getDisplayMode().isFullscreenCapable()) {
Display.setFullscreen(true);
Display.setVSyncEnabled(true);
}
else {
Dimension screenSize = Toolkit.getDefaultToolkit()... | 3 |
public static void main(String[] args) throws Exception{
long[] time;
time = new long[10];
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
int THREAD_COUNT = 10000;
Thread threads[];
threads = new Thread[THREAD_COUNT];
Calculate cal... | 5 |
private void unpaid_report() {
// todo: this function generates the unpaid report for the manager.
// I would format like this:
/*
* AdID: Name: Phone: Title: Cost: Content: width:20 Width:20 width:12
* width:30 width: 10 width: 200
*/
try {
String column_headers = "AdID:\t" + "Name:\t" + "Phone:\t... | 8 |
public final void createAlliance(final MapleClient c, final String name) {
if (allianceid != 0) {
c.getPlayer().dropMessage(1, "You are already in an Alliance!");
return;
}
if (checkAllianceName(name)) {
try {
if (name.equals("") || id <= 0) {
return;
}
Connection con = DatabaseConnection.... | 6 |
public static byte[] rstr(String hex) {
int length = hex.length();
byte[] bHex = new byte[length/2];
String temp = null;
int t = 0;
for (int i=0; i<length; i++) {
temp = "" + hex.charAt(i) + hex.charAt(++i);
bHex[t++] = (byte)Integer.parseInt(temp, ... | 1 |
public SongChangeData(final SongDataEntry voices,
@SuppressWarnings("hiding") final Main main) {
this.main = main;
this.date = stone.util.Time.date(voices.getLastModification()).split(
" ");
this.file = voices.getPath();
Debug.print("%s\n", this.file);
for (final Map.Entry<Integer, String> titleEntry :... | 8 |
boolean directLinkPossibleForGeometry(int row1, int col1, int row2, int col2) {
final int rowMin = Math.min(row1, row2);
final int rowMax = Math.max(row1, row2);
final int colMin = Math.min(col1, col2);
final int colMax = Math.max(col1, col2);
final LineSegmentInt seg = new LineSegmentInt(col1, row1, col2, ro... | 7 |
public String getCarSourceUrl() {
return carSourceUrl;
} | 0 |
Elem(String file) {
n++;
X = new double[inputNo];
actualY= new double[outputNo];
String[] arrs = file.split(",");
for(int i=0; i<inputNo; i++)
X[i]=Double.parseDouble(arrs[i]);
for(int i=inputNo; i<outputNo+inputNo; i++)
actualY[i-inputNo]=Double.parseDouble(arrs[i]);
... | 4 |
public Entry (int piece, PositionRange pieceRange, Path file, PositionRange fileRange) {
if (piece < 0 | pieceRange.getLength() != fileRange.getLength()) {
throw new IllegalArgumentException();
}
if (file == null) {
throw new NullPointerException();
... | 2 |
protected Image(java.awt.Image image, boolean mutable, boolean toGray, String name) {
Display.check();
// Give VM some time to cleanup every n images...
if(((++imageCreationCount) & 7) == 0){
try{
Thread.sleep(4);
}
catch(InterruptedExcepti... | 3 |
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.