text stringlengths 14 410k | label int32 0 9 |
|---|---|
@Override
public Iterator<NPuzzleMove> getMoves()
{
List<NPuzzleMove> moves = new ArrayList<NPuzzleMove>();
if (exists( openX + 1, openY ))
{
moves.add( new NPuzzleMove( openX + 1, openY ) );
}
if (exists( openX - 1, openY ))
{
moves.add( new NPuzzleMove( openX - 1, openY ) );
}
if (exists( o... | 4 |
public static void main(String[] args) throws Exception {
String fileName = "vectors.txt";
// Global.initializeDataBaseSimulator(fileName);
ArrayList<DataPoint> points = new ArrayList<DataPoint>();
ArrayList<Association> left = new ArrayList<Association>();
ArrayList<Association> associations = new ArrayList<... | 4 |
public void scrollCellToView(JTable table, int rowIndex, int vColIndex) {
if (!(table.getParent() instanceof JViewport)) {
return;
}
JViewport viewport = (JViewport) table.getParent();
Rectangle rect = table.getCellRect(rowIndex, vColIndex, true);
Rectangle viewRect =... | 9 |
public Ui(){
bg = new GreenfootImage (1000, 230);
cache = new GreenfootImage [6];
cache[0] = new GreenfootImage ("UI/general.png");
cache[1] = new GreenfootImage ("UI/buildTower.png");
cache[2] = new GreenfootImage ("UI/sendMobs.png");
cache[3] = new GreenfootImage ("UI/s... | 4 |
public static boolean CheckPlayers(int noplayers) {
if ((noplayers >= 2) && (noplayers <= 8))
return true;
else
return false;
} | 2 |
public void render(Graphics2D g){
Graphics2D g2d = (Graphics2D)finalBoard.getGraphics();
g2d.drawImage(gameBoard, 0, 0, null);
for (int row = 0; row < ROWS; row++) {
for (int col = 0; col < COLS; col++) {
Tile current = board[row][col];
if(current == null) continue;
current.render(g2d);
}
}... | 3 |
public Msg recvpipe(Pipe[] pipe_) {
// Deallocate old content of the message.
Msg msg_;
// Round-robin over the pipes to get the next message.
while (active > 0) {
// Try to fetch new message. If we've already read part of the message
// subsequent part shou... | 5 |
public static Value changePlayer(Value player) {
Value state = empty;
switch(player) {
case x: {state = o; break;}
case o: {state = x; break;}
}
return state;
} | 2 |
public void eventPosted(TimeflecksEvent t)
{
if (t.equals(TimeflecksEvent.GENERAL_REFRESH))
{
GlobalLogger.getLogger().logp(Level.INFO, "MainWindow",
"eventPosted",
"MainWindow responding to general refresh event.");
this.refresh();
}
else if (t.equals(TimeflecksEvent.EVERYTHING_NEEDS_REFRESH)... | 8 |
private double getFreeSpaceInOutsideVehicleAcceptor(VehicleAcceptor va) {
try {
//if va is null, return 0
if (va == null) {
return 0;
}
List<Vehicle> cars = va.getCars();
//the va has cars, return the last backPos
return cars.get(cars.size()).get... | 2 |
public static void step(Page page, int step) {
StyledDocument doc = page.getStyledDocument();
AbstractDocument.BranchElement section = (AbstractDocument.BranchElement) doc.getDefaultRootElement();
if (step < 0 && isSmallest(section))
return;
Enumeration enum1 = section.children();
AbstractDocument.Branc... | 9 |
public void enableBillTypes()
{
if (isFirstBill){
isFirstBill=false;
reset();
ack();
d.readToPort();
try {Thread.sleep(900L);} catch (InterruptedException e) {e.printStackTrace();}
d.writeToPort("02030C34FFFFFF000000B5C1");
... | 6 |
public float getU() {
if(animation != null) {
return animation.getU();
}
return tex.getU();
} | 1 |
private void moveNewZipFiles(String zipPath) {
File[] list = listFilesOrError(new File(zipPath));
for (final File dFile : list) {
if (dFile.isDirectory() && this.pluginExists(dFile.getName())) {
// Current dir
final File oFile = new File(this.plugin.getDataFol... | 7 |
public void setDAO(String daoLine) {
if (daoLine.equals("Mock")) {
dao = new MockDAO();
}
else if (daoLine.equals("MySQL")) {
dao = new MySQLDAO();
}
} | 2 |
public int get(final int index) {
final int i0 = index >>> 22;
int[][] map1;
if (i0 != 0) {
if (map == null)
return NOT_FOUND;
map1 = map[i0];
if (map1 == null)
return NOT_FOUND;
} else
map1 = map10;
int[] map2 = map1[(index >>> 11) & 0x7ff];
if (map2 == null)
return NOT_FOUND;
... | 4 |
public void stop() {
if (!stop) {
stop = true;
}
} | 1 |
public void transferKE(float amount) {
if (iAtom <= 0)
return;
float k0 = getKin();
if (k0 < ZERO)
return;
synchronized (forceCalculator) {
for (int i = 0; i < iAtom; i++) {
if (!atom[i].isMovable())
continue;
k0 = EV_CONVERTER * atom[i].mass * (atom[i].vx * atom[i].vx + atom[i].vy * atom[... | 8 |
public static long transfer( InputStream in,
OutputStream out,
long maxReadLength,
int bufferSize )
throws IllegalArgumentException,
IOException {
byte[] buffer = new byte[ bufferSize ];
int len;
long totalLength = 0;
long bytesLeft = maxReadLength; // Math.max( maxReadLength, bufferSize )... | 3 |
public void paintComponent(Graphics g){
super.paintComponent(g);
BoardObject[][] tiles = board.getBoardTiles();
if (tiles == null) return; // before board is made ...
// draws stuff
//Draw each tile on the board.
for(int y=0; y<Board.SIZE; y++){
for(int x=0; x<Board.SIZE; x++){
if(tiles[y][x] != nu... | 7 |
protected void attemptToGrowFruit()
{
System.out.println(getName() + " is attempting to grow some fruit.");
// for each unit of growth that does not contain a fruit
for(int i = getFruits().size(); i < getSize(); i++)
{
if(Math.random() < 0.01)
{
getFruits().add(getFruit());
... | 2 |
private static String encrypt(final int key, final String text) {
String encryptedText = "";
logger.log(Level.INFO, "Plain text: {0}", text);
for (int level = 0; level < key; level++) {
for (int n = 0; n < text.length() / (2 * key - 2) + 1; n++) {
if (level != 0 && le... | 6 |
@Override
public void mousePressed(MouseEvent e) {
if (calculated) {
return;
}
Tile targetTile = getTileAt(e.getX(), e.getY());
int button = e.getButton();
if (targetTile != null) {
targetTile.handleClick(button);
if (targetTile.getState().... | 6 |
public final void levelDone() {
if (!inGameState("InGame") || inGameState("LevelDone")
|| inGameState("LifeLost") || inGameState("GameOver") ) return;
// System.err.println(
// "Warning: levelDone() called from other state than InGame." );
//}
clearKey(key_continuegame);
removeGameState("StartLevel");
r... | 6 |
public void initializeBoard() {
gameArray = new PlayableSquare[60];
for (int i = 0; i < 60; i++) { gameArray[i] = new PlayableSquare(Integer.toString(i)); }
redHomeArray = new PlayableSquare[6];
greenHomeArray = new PlayableSquare[6];
blueHomeArray = new PlayableSquare[6];
... | 5 |
public SetUndoAmountAction () {
super("Set Undo Amount", null);
//this.environment = environment;
} | 0 |
private List<Mapper> estimateMappers() {
List<Mapper> newMapperList = new ArrayList<Mapper>();
if(isSplitSizeChanged || isMapperConfChanged) {
MapperEstimator mapperEstimator = new MapperEstimator(finishedConf, newConf);
//split size is changed
if(isSplitSizeChanged) {
//List<Long> splits... | 9 |
@Override
public void onReceived(long delta, long bytes) {
} | 0 |
public static String doRecognition(int[] positions){
String bestMatchString = null;
float bestMatchPercentage = 0;
for(Gesture item : gestureList){
float variance = 0;
for(int i=0; i<4; i++){
variance += (float) Math.abs( item.getPosition(i) - positions[i]/(SignalProcessor.getMaxSignalValue()*0.01) );
... | 4 |
public BlockListener(LogOre plugin) {
this.plugin = plugin;
} | 0 |
@Override
public void run() {
// TODO Auto-generated method stub
Random rand = new Random(50);
Random ano_rand = new Random(20);
int rand_num;
int wiget_send = 0;
int money_send = 0;
while (true) {
// get a random number between 0-2
rand_num = rand.nextInt(proc_num);
// for send the marker
... | 9 |
@EventHandler
public void onWeatherChange(WeatherChangeEvent event) {
notifyAboutUpdate();
Random r = new Random();
Boolean voteInProgress = false;
//Check if the world is enabled
if (getFileConfig().getStringList("Worlds").contains(event.getWorld().getName())) {
... | 8 |
void applyForce()
{
//PhBody.applyForceToCenter(new Vec2(0,-3));
setForcesFromBodiesAffect();
if (BackJoint == null) return;
//parent.text(f.length(),100,100);
float CurrentJointLength = BackJoint.getLength();
LWormPart wp = (LWormPart) BackJoint.getBodyB().getUserDa... | 9 |
public int sizeEffective() {
int count = 0;
for (String gene : this)
if (geneSets.hasValue(gene)) count++;
return count;
} | 2 |
boolean validateMove(movePair movepr, Pair pr) {
Point src = movepr.src;
Point target = movepr.target;
boolean rightposition = false;
if (Math.abs(target.x-src.x)==Math.abs(pr.p) && Math.abs(target.y-src.y)==Math.abs(pr.q)) {
rightposition = true;
}
if (Math.abs(target.x-src.x)... | 7 |
public boolean combineLocal() {
StructuredBlock firstInstr = (catchBlock instanceof SequentialBlock) ? catchBlock
.getSubBlocks()[0] : catchBlock;
if (firstInstr instanceof SpecialBlock
&& ((SpecialBlock) firstInstr).type == SpecialBlock.POP
&& ((SpecialBlock) firstInstr).count == 1) {
/* The except... | 9 |
public void draw1(Graphics g, ImageObserver observer) {
if (image1 != null)
g.drawImage(image1, x, y, width, heigth, observer);
} | 1 |
public void writePairedNodeInformation( String filepath ) throws Exception
{
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(filepath)));
writer.write("nodeA\tnodeB\tparentA\tparentB\tnodeLevel\tsameParents\tleastCommonDistnace\talignmentDistance\talignmentDistanceMinusPredictedDistance\tnumS... | 7 |
private Element parseBranch() throws ParserException, XMLStreamException {
String condition = getAttribute("condition");
startElement("branch");
Labelled left = null, right = null;
while (look().isStartElement()) {
String name = getNameOfStartElement();
if (name.equals("left")) {
if (left != null) {
... | 7 |
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, SQLException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
String id=request.getParamet... | 3 |
public void doDelimitedMultiLine() {
try {
final String data = ConsoleMenu.getString("Data ", DelimitedMultiLine.getDefaultDataFile());
DelimitedMultiLine.call(data);
} catch (final Exception e) {
e.printStackTrace();
}
} | 1 |
public boolean isAABBInMaterial(AxisAlignedBB var1, Material var2) {
int var3 = MathHelper.floor_double(var1.minX);
int var4 = MathHelper.floor_double(var1.maxX + 1.0D);
int var5 = MathHelper.floor_double(var1.minY);
int var6 = MathHelper.floor_double(var1.maxY + 1.0D);
int var7 ... | 7 |
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
int testCases = 0;
while (T > 0) {
T--;
int N = sc.nextInt();
testCases++;
int lowJumps = 0;
int highJumps = 0;
int ... | 5 |
@Override
public void removeEdgesBetween(N from, N to) {
if(containsNode(from) && containsNode(to)) {
for(Edge<N> edge : edgesFrom(from)) {
if(edge.to.equals(to)) {
nodes.get(from).remove(edge);
}
}
for(Edge<N> edge : edgesFrom(to)) {
if(edge.to.equals(from)) {
nodes.get(to).remove(... | 6 |
public void updateGroup(Group group, List<Group_schedule> list)
{
try
{
PreparedStatement ps;
if(group.getId()>0)
{
ps = con.prepareStatement( "UPDATE groups SET name=?, level=?, capacity=?," +
" stud_age=?, teacher=? WHERE id=?" );
ps.setInt( 6, group.getId() );
}else{
... | 4 |
public String createListInfo(String exceptName) {
String temp = "<SESSION_ACCEPT>";
for (ClientInfo node : client_list) {
if (node.name.equals(exceptName))
continue;
temp += "<PEER>";
temp += "<PEER_NAME>" + node.name + "</PEER_NAME>";
temp += "<IP>" + node.ip + "</IP>";
temp += "<PORT>" + node.p... | 2 |
public synchronized void downloadLatestVersion ()
{
FileOutputStream fos = null;
try
{
if (remoteVersion == null)
{
this.updateCheck();
}
plugin.getLogger().info("Downloading latest version...");
ReadableByte... | 5 |
public static void DamonMarksReport()
{
System.out.println("Damon's final exam mark is: " + DamonStats.Final);
System.out.println("Damon's midterm exam mark is: " + DamonStats.Midterm);
System.out.println("Damon's final mark for the term is: " + (DamonStats.Final* 0.75 + DamonStats.Midterm * 0.25));
} | 0 |
private static List<Shape> buscarSubparce(List<Shape> shapes, String subparce){
List<Shape> shapeList = new ArrayList<Shape>();
for(Shape shape : shapes)
if (shape != null && shape instanceof ShapeSubparce)
if (((ShapeSubparce) shape).getSubparce().equals(subparce))
shapeList.add(shape);
return sha... | 4 |
@Override
public ArrayList<String> load() throws IOException {
ArrayList<String> words = new ArrayList<String>();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader reader = new BufferedReader(isr);
String line = reader.readLine();
while (line != null) {
words.add(line);
line = reader.re... | 1 |
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < fieldNames.length; i++)
sb.append(fieldNames[i] + "\t" + types[i] + (multipleValues[i] ? "\tmultiple" : "") + "\n");
return sb.toString();
} | 2 |
public boolean isAncestorToDescendent(final GraphNode v, final GraphNode w) {
return (preOrderIndex(v) <= preOrderIndex(w))
&& (postOrderIndex(w) <= postOrderIndex(v));
} | 1 |
public static void testFileIO(){
// File I/O contained in java.io package (imported)
FileInputStream infile=null;
FileOutputStream outfile=null;
File inf=new File("input.txt");
File outf = new File("output.txt");
try{
infile = new FileInputStream(inf);
outfile = new FileOutputStream(outf);
... | 5 |
public ArrayList<String> getFailure(){
ArrayList<String> fail = new ArrayList<String>();
if(failures.contains(Signal)){
fail.add(Signal);
}
if(failures.contains(Break)){
fail.add(Break);
}
if(failures.contains(Engine)){
fail.add(Engine)... | 3 |
public boolean canPlaceRoom(int roomX, int roomY, int roomWidth, int roomHeight) {
if (roomX < 1 || roomY < 1 || roomX + roomWidth > sizeX - 2 || roomY + roomHeight > sizeY - 2) {
return false;
}
for (int x = roomX; x < roomX + roomWidth; x++) {
for (int y = roomY; y <... | 9 |
@Test public void itShouldSerialize() throws Exception
{
MultiLineString multiLineString = new MultiLineString();
multiLineString.add(Arrays.asList(new LngLatAlt(100, 0), new LngLatAlt(101, 1)));
multiLineString.add(Arrays.asList(new LngLatAlt(102, 2), new LngLatAlt(103, 3)));
Assert.assertEquals("{\"coordinat... | 0 |
private void writeSheet(XSSFSheet sheet, List list) throws IOException {
int size = list.size();
int colno = 6;
if (size < 2) {
return;
}
//
for (int i = 0; i < size; i++) {
for (int j = 0; j < 4; j++) {
sheet.createRow(i * 4 + j);
}
}
ExcelUtils.copyEdge(wb, sheet, size);
for (int i = 0... | 5 |
@Override
public void run()
{
if (Main.DEBUG)
{
System.out.println("SpeakThread Started");
}
Audio audio = Audio.getInstance();
while (isRunning)
{
try
{
Main.putIntoSpeakLatch.await();//wait for items to be put ... | 9 |
private void loadConfig(){
File liftFolder = new File(getDataFolder().getPath() + "/elevators/");
File signFile = new File(getDataFolder().getPath() + "/signs.yml");
if(!liftFolder.exists() || !signFile.exists()){
try{
liftFolder.mkdirs();
signFile.createNewFile();
}catch(IOException e){
e... | 3 |
public static String toString(JSONObject jo) throws JSONException {
StringBuffer sb = new StringBuffer();
sb.append(escape(jo.getString("name")));
sb.append("=");
sb.append(escape(jo.getString("value")));
if (jo.has("expires")) {
sb.append(";expires=");
s... | 4 |
private Predicate[] getSearchPredicates(Root<Passenger> root)
{
CriteriaBuilder builder = this.entityManager.getCriteriaBuilder();
List<Predicate> predicatesList = new ArrayList<Predicate>();
String name = this.example.getName();
if (name != null && !"".equals(name))
{
predic... | 8 |
private void createTextField() {
textField = new TextField(getString());
textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
textField.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent t) {
if (t.getCod... | 7 |
@Override
public void keyTyped(KeyEvent e) {
int s = e.getKeyChar()-48;
if(s<=0 || s>9) {
System.out.println("input is not 1-9");
} else {
Button b = (Button) e.getComponent();
String right = b.getLabel().trim();
int right2 = Integer.parseInt(right);
if(right2 == s) {
b.setLabel(String.valueO... | 3 |
public static void createConfig() {
File dir = new File(System.getProperty("user.dir") + "/config");
// Create save directory
if(dir.mkdir()) {
try {
saveConfig();
} catch(Exception e) {
System.err.println("Config file failed to be created");
e.fillInStackTrace();
}
System.out.print... | 2 |
public static void clearCache(){
for(String id : cacheClips.keySet()){
stop(id);
cacheClips.get(id).close();
}
cacheClips.clear();
System.out.println("[SoundManger] Clearing cache.");
} | 1 |
public String minWindow(String s, String t) {
Map<Character, Integer> map = new HashMap<Character, Integer>();
for (char c : s.toCharArray()) {
map.put(c, 0);
}
for (char c : t.toCharArray()) {
if (map.containsKey(c)) {
map.put(c, map.get(c) + 1);
} else {
return "";
}
}
int sta... | 9 |
private void lstCommandeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lstCommandeMouseClicked
// TODO add your handling code here:
article.removeAllElements();
articleLoiseau.removeAllElements();
int indice = 0;
for (Commande c : lesCommandes) {
if (l... | 8 |
public void doPost (HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
{
// --------
// Handle email sending
// -------
// If a valid email address is provided
if (req.getParameter("email") != null && req... | 9 |
public void setConcurrent(){
this.concurrent = true;
} | 0 |
@Override
public void actionPerformed(ActionEvent e) {
boolean global = tb.getSelected();
boolean state = this.selected;
boolean result = false;
if (!global)
{
tb.setSelected();
this.setSelected(true);
result = true;
}
else
{
if (state)
{
this.setSelected(false);
tb.setSelected()... | 4 |
@Override
public float millisecondsPlayed()
{
switch( channelType )
{
case SoundSystemConfig.TYPE_NORMAL:
if( clip == null )
return -1;
return clip.getMicrosecondPosition() / 1000f;
case SoundSystemConfig.TYPE_STREAMING:... | 4 |
@Override
public Void visitIndent(IndentToken token) {
assertExpected(token);
// If we're dealing with a comment, just smile and wave
if (tokens.peek().getType() == TokenType.COMMENT) {
setExpected(TokenType.COMMENT);
return null;
}
/... | 8 |
@Override
public void solve() {
double A = 0, B = 0, C = 0, D = 0;
updateRightWeights();
updateLeftWeights();
for (Term t : leftTerms) {
if (t instanceof XTerm) {
A += ((XTerm) t).coefficient;
} else if (t instanceof Constant) {
C += t.weight;
}
}
for (Term t : rightTerms) {
if (t inst... | 7 |
public void setEditValue(int n, EditInfo ei) {
if (n == 0) {
inductance = ei.value;
}
if (n == 1) {
ratio = ei.value;
}
if (n == 2 && ei.value > 0 && ei.value < 1) {
couplingCoef = ei.value;
}
if (n == 3) {
if (ei.ch... | 7 |
public void dmgUpdate(int i, int j, int k, int l) {
Obstacle[][] obs = level.getObstacles();
int dmg = 0;
if ((y+height)/Obstacle.getHeight()>=0){ // Could be out of the map
while (l<height){
int tmpK = k;
int tmpJ = j;
while(tmpK<width && i>=0){
dmg += obs[i][tmpJ].getDmg();
// if (obs[i]... | 5 |
public boolean checkMethodInvocation( Method method ) {
if( method == null )
return false; // result not specified
// Method must be public
if( ! Modifier.isPublic(method.getModifiers()) )
return false;
return
method.getName().equals("doAnything") ||
method.getName().equals("doSomething"... | 5 |
public Matrix subtract(Matrix a) {
if (a == null) {
return null;
}
if ((!this.isJagged && !a.isJagged) && this.sameOrder(a)) {
double[][] new_elements = new double[this.rowCount][this.columnCount];
for (int row = 0; row < this.rowCount; row++) {
... | 6 |
public Path obtainRevisionContent(long timestamp)
{
// Check first if the specific revision is a binary revision. If it is, we're done.
Path specificRevision = getRevisionInfo(timestamp);
if(!FileOp.isPlainText(specificRevision))
{
logger.debug("Revision for file " + file.toString() + " (" + timestamp + ") ... | 7 |
public void playerLeaveWorld(World world, Player player){
List<Player> playersInWorld = world.getPlayers();
if (playersInWorld.size() < 1 && !plugin.doNotUnload.contains(world.getName())){
Bukkit.getServer().unloadWorld(world, true);
String worldName = world.getName();
for (String worldN : plugin.mainWorld... | 7 |
protected void updateBall() {
ball.move();
ball.bounceOffWalls(isEndless);
ball.bounceOffPaddle(paddle1, player1);
ball.scorePoint(player1, player2, isEndless);
if (!isEndless) {
ball.bounceOffPaddle(paddle2, player2);
}
ball.teleport(isTeleport, telep... | 1 |
private void zoomtoRouteArea()
{
final double fromNodeX = fromNode.getxCoord();
final double fromNodeY = fromNode.getyCoord();
final double toNodeX = toNode.getxCoord();
final double toNodeY = toNode.getyCoord();
final double xDistance = Math.max(fromNodeX, toNodeX) - Math.min(fromNodeX, toNodeX);
fi... | 2 |
private Map<SecondLevelId, Object> getValue() {
while(true) {
if (firstVal == null && !firstCursor.hasNext()) {
return null;
}
if (firstVal == null) {
firstVal = firstCursor.next();
secondCursor = iterable.iterator();
... | 6 |
@Override
public void executeMsg(final Environmental myHost, final CMMsg msg)
{
super.executeMsg(myHost,msg);
if(!(affected instanceof MOB))
return;
final MOB mob=(MOB)affected;
if((msg.amISource(mob))
&&(msg.tool()!=this)
&&(!CMath.bset(msg.sourceMajor(),CMMsg.MASK_CHANNEL))
&&((CMath.bset(msg.sour... | 8 |
public static <T extends Comparable<? super T>> int bestPivotStrategy(ArrayList<T> list, int start, int end){
int middle = (end + start)/2;
if(list.get(middle).compareTo(list.get(start)) < 0){
normalSwap(list, start, middle);
}
if(list.get(end).compareTo(list.get(start)) < 0){
normalSwap(list, start, end... | 4 |
public static String downloadToString(String url) {
URL website = null;
try {
website = new URL(url);
} catch (MalformedURLException e) {
System.out.println("Couldn't connect to "+url);
return null;
}
URLConnection connection = null;
try {
connection = website.openConnection();
} catch (IOExc... | 6 |
public boolean isIdentity(){
boolean test = true;
if(this.numberOfRows==this.numberOfColumns){
for(int i=0; i<this.numberOfRows; i++){
if(this.matrix[i][i]!=1.0D)test = false;
for(int j=i+1; j<this.numberOfColumns; j++){
if(this.matri... | 6 |
private void barInput(int time){
//draw a moving bar watch out for out of boundary
int length=8;
for(int bar=0; bar<time/20; bar++){
int intercept=20*bar;
for(int i=intercept;i<time;i++){
for(int j=0;j<length;j++){
if(i+j-intercept<column && i+j-intercept>=0){
output.get(i).add(new int[]... | 7 |
public static Row copyRow(Sheet sheet, Row sourceRow, int destination) {
Row newRow = sheet.createRow(destination);
// get the last row from the headings
int lastCol = sheet.getRow(0).getLastCellNum();
for (int currentCol = 0; currentCol <= lastCol; currentCol++) {
Cell newCe... | 9 |
@SuppressWarnings("unused")
@Test
public void testGlyphIterator() {
//Create a few regions with text lines, words and glyphs
Page page = new Page();
PageLayout pageLayout = page.getLayout();
TextRegion r1 = (TextRegion)pageLayout.createRegion(RegionType.TextRegion);
TextLine t11 = r1.createTextLine();
Wor... | 9 |
public void run() {
try {
boolean running = true;
while (running) {
try {
String line = null;
while ((line = _breader.readLine()) != null) {
try {
_bot.handleLine(line);
... | 9 |
public static boolean isLeftButton(MouseEvent e, Boolean ctrlDown, Boolean shiftDown, Boolean altDown)
{
return (e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0 &&
(e.getModifiersEx() & MouseEvent.BUTTON2_DOWN_MASK) == 0 &&
(e.getModifiersEx() & MouseEvent.BUTTON3_DOW... | 8 |
private void initContent()
{
setBounds(100, 100, 400, 300);
getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
contentPanel.setLayout(new BorderLayout(0, 0));
tabbedPane = new JTabbedPane(JTabbedPa... | 1 |
public void GoRight(WumpusPolje[][] wumpusWorld) {
WumpusPolje oce = tmpPolje;
tmpPolje = wumpusWorld[tmpPolje.m_x][tmpPolje.m_y + 1];
obiskanaPolja.add(tmpPolje);
tmpPolje.m_oce = oce;
this.m_points += WumpusRating.action;
WumpusHelper.Print(WumpusSteps.PremikNaPolje(tmpPolje.m_x, tmpPolje.m_y));
/... | 9 |
static final char method462(byte i, int i_20_) {
anInt5216++;
int i_21_ = 0xff & i;
if ((i_21_ ^ 0xffffffff) == -1)
throw new IllegalArgumentException("Non cp1252 character 0x"
+ Integer.toString(i_21_, 16)
+ " provided");
if ((i_21_ ^ 0xffffffff) <= -129 && i_21_ < 160) {
int i_22... | 5 |
protected static int toUShort(final byte b1, final byte b2) {
int x = (short) (Instruction.toUByte(b1) << 8)
| Instruction.toUByte(b2);
if (x < 0) {
x += 0x10000;
}
return x;
} | 1 |
public int trap(int[] A) {
// Start typing your Java solution below
// DO NOT write main() function
int max = 0;
int n = A.length;
for (int i = 0; i < n; i++) {
if (A[i] > A[max])
max = i;
}
int tmpH = 0;
int res = 0;
for (int i = 0; i < max; i++) {
if (tmpH > A[i])
res += (tmpH - A[i]);... | 6 |
public static void main(String args[]) throws FileNotFoundException {
Scanner in = new Scanner(System.in);
System.out.println(">Enter your new file name:");
String fileName = in.nextLine() + ".txt";
boolean exist = false;
String[] files = FileLister.getFilesArrayString();
for (int i = 0; i < files.length... | 3 |
double getKth(int[] a, int[] b, int k) {
int m = a.length;
int n = b.length;
if (n == 0)
return a[k - 1];
if (m == 0)
return b[k - 1];
if (k == 1)
return Math.min(a[0], b[0]);
// divide k into two parts
int p1 = Math.min(k / 2, m);
int p2 = Math.min(k - p1, n);
if (a[p1 - 1] < b[p2 - 1])
... | 5 |
@Override
public void keyTyped(KeyEvent e) {
JTextField f = (JTextField) e.getSource();
// Only accept numbers and decimals in the average mark JTextField
if ( (!Character.isDigit( e.getKeyChar() )) && (e.getKeyChar() != '.') ) {
e.consume();
// Set and display a helpful toolt... | 6 |
public int trap(int[] height) {
int water = 0;
if (height.length < 3) {
return water;
}
// find max height and its position
int maxHeight = 0;
int maxHeightPos = 0;
for (int i = 0; i < height.length; i++) {
if (height[i] > maxHeight) {
maxHeight = height[i];
maxHeightPos = i;
}
}
... | 7 |
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.