text stringlengths 14 410k | label int32 0 9 |
|---|---|
private int partition(char[] arr, int left, int right) {
char pivotEle = arr[(left + right) / 2];//just pick the middle one
while (left <= right) {
while (arr[left] < pivotEle)
left++;
while (arr[right] > pivotEle)
right--;
if (left <= right) {
swap(arr, left, right);
left++;
right--;... | 4 |
public static String trimExtension(String text, String separator) {
int index = text.lastIndexOf(separator);
if (index == -1) {
return text;
} else {
return text.substring(0, index);
}
} | 1 |
@Before
public void setUp() {
} | 0 |
private Content processParamTags(boolean isNonTypeParams,
ParamTag[] paramTags, Map<String, String> rankMap, TagletWriter writer,
Set<String> alreadyDocumented) {
Content result = writer.getOutputInstance();
if (paramTags.length > 0) {
for (int i = 0; i < paramTags.le... | 8 |
public static BufferedImage gaussianFilterWithDepthMap(File file) {
// Get depthMap
DepthImage depthImage = new DepthImage(file);
if (!depthImage.isValid())
return null;
BufferedImage depthMap = toGrayScale(depthImage.getDepthMapImage());
BufferedImage originImage = depthImage.getOriginalColorImage();
Bu... | 9 |
public void think() {
List<MouseEvent> mouseEvents = board.getMouseEvents();
//System.out.println("MOUSEVENTS: " + mouseEvents.size());
if(mouseEvents.size() > 0) {
MouseEvent e = mouseEvents.get(0);
//System.out.println("Clicked: " + e.getX() + "-" + e.getY());
int x = e.getX() / (int)Chess.SQUARE_PIXEL... | 7 |
public static DoorDirection makeFromChar(char initial) {
switch(initial) {
case 'U':
return UP;
case 'D':
return DOWN;
case 'L':
return LEFT;
case 'R':
return RIGHT;
default:
return NONE;
}
} | 4 |
public void expandsLeaf(Coordinate coord) {
Coordinate subCoord;
for (int i = 0; i < 4; i++) {
subCoord = coord.copy();
switch (i) {
case 0:
subCoord.moveNorth();
break;
case 1:
subCoord.moveEast(dimension);
break;
case 2:
subCoord.moveSouth(dimension);
break;
case 3:
s... | 7 |
public synchronized boolean setLevel(String str,int level){
//返回是否拥有这个属性 如果有则返回true 没有就返回false
//如果没有 会自动为你添加属性
boolean has = false;
for (int i = 0; i < getLoreSize() ; i++) {
String line = getString(i);
if(line.contains(str)) {
if(line.contains(": ")... | 8 |
public Object invokeAdvice(Method method, Object invoker) throws Throwable
{
Object result;
final long tid = Thread.currentThread().getId();
final ThreadMXBean bean = ManagementFactory.getThreadMXBean();
MethodInfo caller = null;
if (Cpu.getInstance().getThreadProf... | 6 |
@Override
public void execute(CommandSender sender, String worldName, List<String> args) {
this.sender = sender;
if (worldName == null) {
error("No gate given.");
reply("Usage: /gworld setweather <worldname> <sun|storm>");
} else if (args.size() == 0) {
error("No weather given.");
reply("Usage: /g... | 5 |
public List<String> getNextLink() {
if (inFile == null) {
openFile();
}
if (open) {
try {
return inFile.readLine();
} catch (IOException ex) {
closeFile();
Logger.getLogger(ReadSimpleLi... | 3 |
public static DayTypeEnumeration fromString(String v) {
if (v != null) {
for (DayTypeEnumeration c : DayTypeEnumeration.values()) {
if (v.equalsIgnoreCase(c.toString())) {
return c;
}
}
}
throw new IllegalArgumentException(v);
} | 3 |
private int[] getNumbers () {
boolean numberBegin = false;
boolean addDigit = false;
boolean isDigit;
int numberBeginPos = -1;
int[] vector;
int position = 0;
char eachChar;
String vector1;
String temporary = "";
vector = new int[50];
... | 9 |
public static void main(String[] args){
List<String[]> list = new N_Queens().solveNQueens(4);
String[] board;
for(int i = 0; i< list.size();i++){
board = list.get(i);
for(int j = 0 ; j < board.length;j++)
System.out.println(board[j].toString());
... | 2 |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
} | 0 |
void populateWinPanel(){
setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
panelWidth = getWidth();
panelHeight = getHeight();
labelWidth = panelWidth/(BrackEm.bracketData.getTotalRoundsW() + 1); // Include final winner (+1)
int startingLabels = 2*(BrackEm.bracketData.getSecondPlayersW... | 9 |
public Client_Part2(){
Socket socket = null;
ObjectOutputStream out = null;
ObjectInputStream in = null;
try {
Object[] input = new Object[4];
Object[] output;
socket = new Socket("127.0.0.1", 4444);
out = new ObjectOutputStream(socket.get... | 8 |
@Override
public void render() {
if(previousScreen != null && previousScreen instanceof GameScreen){
GameScreen prevGameScreen = (GameScreen) previousScreen;
if(!prevGameScreen.outTransitionFinished()){
prevGameScreen.renderOut(Gdx.graphics.getDeltaTime());
return;
}
else{
previousScreen = nu... | 5 |
private void addFileMenu() {
JMenuBar jb = this.getJMenuBar();
if (jb == null)
jb = new JMenuBar();
JMenu menu = new JMenu("file");
JMenuItem newItem = new JMenuItem("new simulation ...");
saveItem = new JMenuItem("save");
saveAsItem = new JMenuItem("save as");
JMenuItem openItem = new JMenuItem("ope... | 6 |
private boolean shouldCollide(PositionChangedObservable o) {
ShouldCollideWithPowerFailureVisitor visitor = new ShouldCollideWithPowerFailureVisitor(o);
for(PositionChangedObservable e : hoveringElements)
e.accept(visitor);
return visitor.shouldCollide();
} | 1 |
public static ClassData getPrimitiveClassFor(TypeType type) {
switch (type) {
case BOOLEAN: return boolClassData;
case BYTE: return byteClassData;
case CHAR: return charClassData;
case SHORT: return shortClassData;
case INT: return intClassData;
... | 9 |
private ByteBuffer createQueue(String queueName, String address) {
ClientConnectionLogRecord record = new ClientConnectionLogRecord(
address, SystemEvent.QUEUE_CREATION,
"Received request to create queue " + queueName + " from "
+ address + ".");
LOGGER.log(record);
Connection conn = null;
try {
... | 8 |
public static PlotData2D setUpVisualizableInstances(Instances testInstances,
ClusterEvaluation eval)
throws Exception {
int numClusters = eval.getNumClusters();
double [] clusterAssignments = eval.getClusterAssignments();
FastVector hv = new FastVector();
Instances newInsts;
Attr... | 9 |
public Counter nextTurn(Counter lastPlaced, Board b) {
Counter next = Counter.EMPTY;
if (lastPlaced == Counter.BLACK) {
next = Counter.WHITE;
} else if (lastPlaced == Counter.WHITE) {
next = Counter.BLACK;
}
return next;
} | 2 |
public int t3Lookback( int optInTimePeriod,
double optInVFactor )
{
if( (int)optInTimePeriod == ( Integer.MIN_VALUE ) )
optInTimePeriod = 5;
else if( ((int)optInTimePeriod < 2) || ((int)optInTimePeriod > 100000) )
return -1;
if( optInVFactor == (-4e+37) )
optInVFact... | 6 |
public ZoomDataRecord next() {
// Is there a need to fetch next data block?
if (zoomRecordIndex < zoomRecordList.size())
return (zoomRecordList.get(zoomRecordIndex++));
// attempt to get next leaf item data block
else {
int nHits = getHitRegion(selectionRegi... | 2 |
private void fechavenceFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_fechavenceFieldKeyTyped
// TODO add your handling code here:
if (!Character.isDigit(evt.getKeyChar()) && evt.getKeyChar() !='-' && !Character.isISOControl(evt.getKeyChar()))
{
Toolkit.getDefa... | 4 |
public boolean addClient(String s){
boolean added = false;
for(byte i = 0; i < maxPlayers; i++){
if(!added){//make sure not to add a person multiple times
if(clients[i] == ""){
clients[i] = s;
added = true; //they've been added.
currentPlayers++;
}
}
}
System.out.println("curre... | 5 |
public void clearSelected() {
selectedNodes.clear();
} | 0 |
public synchronized void broadcast(String message, Player player) {
for (Player client : players) {
if (client == null)
continue;
if (player == client)
continue;
if (client.getUser().getGameSocket() != null)
client.getUser().getGameSocket().sendMessage(message);
}
} | 4 |
public void drawInverse(int i, int j) {
i += offsetX;
j += offsetY;
int l = i + j * DrawingArea.width;
int i1 = 0;
int j1 = height;
int k1 = width;
int l1 = DrawingArea.width - k1;
int i2 = 0;
if (j < DrawingArea.topY) {
int j2 = DrawingArea.topY - j;
j1 -= j2;
j = DrawingArea.topY;
i1 += ... | 6 |
public static void main(String[] args) {
//创建一个serversocket
try(AsynchronousServerSocketChannel serverSocketChannel = AsynchronousServerSocketChannel.open()) {
//判断是否打开
if (serverSocketChannel.isOpen()) {
//判断支持那些optiosn
Set<SocketOption<?>> socket... | 8 |
public List<String> getFirstDefinition(Collection<PearsonDictionaryEntry> entries) {
List<String> definition = new ArrayList<String>();
for (PearsonDictionaryEntry entry : entries) {
for (PearsonWordSense sense : entry.getSenses()) {
if (sense.getDefinition() != null && !"".equals(sense.getDefinition())) {
... | 4 |
@Override
public Object execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
Contexto oContexto = (Contexto) request.getAttribute("contexto");
//Parte para saber el tipo de usuario
UsuarioBean oUsuarioBean;
oUsuarioBean = (UsuarioBean) request.getSessio... | 3 |
public long getId(){
return id;
} | 0 |
public static void main(String[] args) {
// TODO Auto-generated method stub
ticTACtoe game1 = new ticTACtoe();
game1.table = new char[3][3];
game1.populate();
game1.print();
boolean win = true;
int x1 = 0, y1 = 0;
int x2 = 0, y2 = 0;
int last=0;
System.out.println("You will play against the compute... | 7 |
public static void insert(User currUser, Tables tables, Statement stmt,
String query) {
ResultSet rset = null;
if (query.toLowerCase().contains("users")) {
} else {
Iterator tableIter = tables.getIter();
while (tableIter.hasNext()) {
String table = (String) tableIter.next();
// System.out.pr... | 9 |
public DisjointSet(int n) {
root = new int[n + 1];
for (int i = 0; i < root.length; i++) {
root[i] = i;
}
rank = new int[n + 1];
} | 1 |
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj == null) return false;
if (obj.getClass() != this.getClass()) return false;
Picture that = (Picture) obj;
if (this.width() != that.width()) return false;
if (this.height() != that.height()) return... | 8 |
private void parseDocument() throws XPathExpressionException {
XPath xpath = XPathFactory.newInstance().newXPath();
NodeList forceList;
NodeList cityList;
NodeList characterList;
Node structure;
Node technology;
Database db = Database.getInstance();
... | 3 |
@Override
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
if (gameOver) {
if (keyCode == KeyEvent.VK_F2) {
startGame();
return;
}
}
pt.flag = false;
switch (keyCode) {
case KeyEvent.VK_LEFT:
currentTetro.toLeft();
break;
case KeyEvent.VK_RIGHT:... | 7 |
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(new File("transform.in"));
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("transform.out")));
int N = in.nextInt();in.nextLine();
char[][] before = new char[N][N];
for (int ... | 8 |
@Override
public int hashCode() {
int result;
long temp;
result = boxId;
result = 31 * result + (boxDate != null ? boxDate.hashCode() : 0);
temp = amount != +0.0d ? Double.doubleToLongBits(amount) : 0L;
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp... | 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 feel.
* For details see http://down... | 6 |
public ROUI() {
robotInstance = new RORobotInstance();
robotInstance.getDashboardData().addObserver(this);
robotInstance.getJoystickHandler().addObserver(this);
addKeyListener (this);
buildGUI();
} | 0 |
public void mouseReleased(MouseEvent e) {
if (e.getModifiers() == MouseEvent.BUTTON1_MASK) {
if (isValidPosition(e.getX(), e.getY())) {
mouseX = e.getX();
mouseY = e.getY();
}
selectObstacle(e.getX(), e.getY());
mouseLeftClick = fal... | 9 |
public SignatureVisitor visitInterfaceBound() {
if (state != FORMAL && state != BOUND) {
throw new IllegalArgumentException();
}
SignatureVisitor v = sv == null ? null : sv.visitInterfaceBound();
return new CheckSignatureAdapter(TYPE_SIGNATURE, v);
} | 3 |
public List<Card> removeOne(List<Card> mutableCards, final List<Card> constCards ) {
List<Card> copyRun = new ArrayList<Card>(constCards);
ListIterator<Card> cardsIterator = copyRun.listIterator();
while(cardsIterator.nextIndex() < copyRun.size() && mutableCards.size() >= 0) {
int potentialmatch = cardsIte... | 3 |
public CtrlConnexion getCtrl() {
return ctrl;
} | 0 |
static final void method2165(boolean bool, String string) {
anInt6287++;
if (string != null) {
if (string.startsWith("*"))
string = string.substring(1);
String string_0_ = Class285_Sub1.unformatUsername(string);
if (string_0_ != null) {
for (int i = 0;
((i ^ 0xffffffff)
> (Class348_S... | 9 |
public void delAll(String path)
{
File file = new File(path);
if (file.isFile() || (file.list().length == 0)) {
file.delete();
} else {
String[] files = file.list();
for (String f : files) {
System.out.println(file.getPath());
delAll((file.getPath()) + File.separator + f);
... | 3 |
public ArrayList<HashMap<List<Integer>, HashSet<Integer>>> lshBucketA(HashMap<Integer, ArrayList<Integer>> sigList, HashMap<Integer, ArrayList<Integer>> semanList) {
ArrayList<HashMap<List<Integer>, HashSet<Integer>>> lshBuckets = lshBucket(sigList);
for (int j = 0; j < lshBuckets.size(); j++) {
... | 9 |
public Being split() {
dynamicStats.get(StatType.D_EATEN).addToValue(-30.0);
return new CellCreature(new Point3(pos), constStats, childDynamicStats.clone(), classID);
} | 0 |
public void save(){
if(this.getId() != null){
String q = "SELECT id, name " +
"FROM positions " +
"WHERE id = ?";
try {
PreparedStatement statement = Speciality.getConnection().prepareStatement(q,
ResultSet.T... | 5 |
private void printLet(Node t, int n)
{
if (t.getCdr().isNull())
{
t.getCar().print(n+4, false);
System.out.println();
if (n > 0)
{
for (int i = 0; i < n; i++)
System.out.print(" ");
}
t.getCdr... | 3 |
public void add(
int i,
String name,
String find,
String replace,
boolean ignoreCase,
boolean regExp
) {
addName(i,name);
addFind(i,find);
addReplace(i,replace);
addIgnoreCase(i,ignoreCase);
addRegExp(i,regExp);
} | 0 |
private long readLong()
{
switch ( type )
{
case MatDataTypes.miUINT8:
return (long)( buf.get() & 0xFF);
case MatDataTypes.miINT8:
return (long) buf.get();
case MatDataTypes.miUINT16:
return (long)( buf.getShort() & ... | 9 |
private int checkInteger(String integer) throws Exception {
try {
int res = Integer.parseInt(integer);
if(res<0)
throw new Exception("Valeur négative interdite");
return res;
} catch (NumberFormatException e) {
throw new Exception("Champ numerique non valide");
} // Integer... | 2 |
public void setFieldValue(FieldAccessCommand fac, Object value) throws Throwable {
Object object = ObjectResolver.resolveObjectReference(fac.getObjectName());
System.out.println("Found Object: " + object);
Field field = null;
try {
field = object.getClass().getField(fac.getM... | 4 |
public Object getValueAt(int rowIndex, int column) {
if (rowIndex >= hits.size()) {
// Feature row
CDDFeature feature = features.get(rowIndex-hits.size());
switch (column) {
case 0:
return feature.getAccession();
case 1:
return feature.getFeatureType()+" feature";
case 2:
return fe... | 9 |
public String taulukkoTulostusmuotoon(String[] taulukko){
String palautettava = "";
for (int i = 0; i < taulukko.length; i++) {
palautettava += taulukko[i] + "\t";
}
return palautettava.substring(0, palautettava.length()-1);
} | 1 |
public void testGetField() {
YearMonth test = new YearMonth(COPTIC_PARIS);
assertSame(COPTIC_UTC.year(), test.getField(0));
assertSame(COPTIC_UTC.monthOfYear(), test.getField(1));
try {
test.getField(-1);
} catch (IndexOutOfBoundsException ex) {}
try {
... | 2 |
public void collision(PhysicsCollisionEvent event) {
System.out.println("Ghosty Collision impulse is "+event.getAppliedImpulse());
if (event.getObjectA() == this || event.getObjectB() == this){
if(event.getAppliedImpulse()>50){
playHitSound(event.getPositionWorldOnA(),event.g... | 3 |
public static RelatedToEnumeration fromString(String v) {
if (v != null) {
for (RelatedToEnumeration c : RelatedToEnumeration.values()) {
if (v.equalsIgnoreCase(c.toString())) {
return c;
}
}
}
throw new IllegalArgumentException(v);
} | 3 |
public Integer getValue(int x, int y, int z)
{
VariableResolver resolver = this.resolver.clone();
for (Enumeration<String> e = modifiers.keys(); e.hasMoreElements();)
{
String key = e.nextElement();
resolver.setVariable(key, modifiers.get(key).getValue(x, y, z));
}
resolver.setVariable("xPos", x);
re... | 6 |
public synchronized void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(BUTTON_NEW_GAME)) {
if (JOptionPane.showConfirmDialog(view,
"Start a new game of the current size?",
"New Game?",
... | 6 |
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UsermanForm usermanForm = (UsermanForm) form;// TODO Auto-generated method stub
String output ="doneedit";
String login = usermanForm.getLogin();
String password = usermanFor... | 4 |
public void draw(Graphics g) {
towerFrame.draw(g);
barrelCell.draw(g);
ammoCell.draw(g);
baseCell.draw(g);
/*************************
*** Taarn og knapper ****
*************************/
for(int i = 0; i < towerButtons.size(); i++){
if(i == activeTowerIndex)g.setColor(Colors.red);
else ... | 7 |
public void update(float dt) {
music.update(dt);
if (tempSong)
prevSong.update(dt);
Array<Song> rmv = new Array<>();
for (Song s : songsToKill) {
s.update(dt);
if (!s.fading)
rmv.add(s);
}
songsToKill.removeAll(rmv, false);
if(!menus.isEmpty())
menus.peek().update(dt);
} | 4 |
@Override
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
if (args.length == 0) {
Main.courier.send(sender, "requires-argument", "message", 0);
return false;
}
final String text = Edit.join(args, ... | 5 |
public void setupOverlay(Hashtable<String, Connection> connections)
{
//add all nodes to graph
addNodesToGraph(connections);
List<Connection> connList = new ArrayList<Connection>(connections.values());
//first iteration
for(int i = 0; i < connList.size(); ++ i)
{
int destinationIndex;
if(i == con... | 8 |
public String interpreterWeatherCondition(String conditionRating){
String weatherCondition = "";
switch (conditionRating){
case "0.0":
weatherCondition = "veryBad";
break;
case "0.25":
weatherCondition = "bad";
break;
case "0.5":
weatherCondition = "ok";
break;
case "0.75":... | 5 |
private static void deleteFile(File file) {
if (file == null || !file.exists()) {
return;
}
// 单文件
if (!file.isDirectory()) {
boolean delFlag = file.delete();
if (!delFlag) {
throw new RuntimeException(file.getPath() + "删除失败!");
} else {
return;
}
}
// 删除子目录
for (File child : file.l... | 5 |
public void doGet(HttpServletRequest request, HttpServletResponse response) {
response.setContentType("text/html");//设置服务器响应的内容格式
// response.setCharacterEncoding("gb2312");//设置服务器响应的字符编码格式。
DButil ab = new DButil();
try {
PrintWriter pw = response.getWriter();
St... | 2 |
private void detectEncoding( char[] cbuf, int off, int len )
throws IOException
{
int size = len;
StringBuffer xmlProlog = xmlPrologWriter.getBuffer();
if ( xmlProlog.length() + len > BUFFER_SIZE )
{
size = BUFFER_SIZE - xmlProlog.length();
}
xmlProlog... | 8 |
public static void main(String[] args) throws IOException, FileNotFoundException{
long startTime = System.currentTimeMillis();
BufferedReader br = new BufferedReader(new FileReader("knapsack_big.txt"));
String[] split = br.readLine().trim().split("(\\s)+");
int weightCapacity = Integer.parseInt(split[0]);
... | 6 |
public Chlodzenie produkujemyChlodzenie(){
return new ChlodzenieDlaLaptopa();
} | 0 |
public int getNeedReport() {
return NeedReport;
} | 0 |
public static TreeNode commomAncestorWithBinaryTreeHasParent(TreeNode p,TreeNode q){
Map<TreeNode,Boolean> ancestorPath = new HashMap<TreeNode,Boolean>();
while(p.parent != null){
ancestorPath.put(p, true);
p = p.parent;
}
while(q.parent != null){
if(ancestorPath.get(q)){
return q;
}
q = q.pa... | 3 |
public static ReplicationResult SendAndRecv2(HttpClient client,
ContentExchange exchange) throws BookStoreException {
int exchangeState;
try {
client.send(exchange);
} catch (IOException ex) {
throw new BookStoreException(
BookStoreClientConstants.strERR_CLIENT_REQUEST_SENDING, ex);
}
try {
... | 7 |
public static void parseAndRegister(Node convertorsNode) {
NodeList nodeList = convertorsNode.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if ("convertor".equals(node.getNodeName())) {
Node aliasNode = node.getAtt... | 9 |
public static byte[] B64tobyte(String ec) {
String dc = "";
int k = -1;
while (k < (ec.length() - 1)) {
int right = 0;
int left = 0;
int v = 0;
int w = 0;
int z = 0;
for (int i = 0; i < 6; i++) {
k++;
v = B64.indexOf(ec.charAt(k));
right |= v << (i * 6);
}
for (int i = 0... | 8 |
public void loadCenter(FileSystem fs, Path path, Configuration conf){
SequenceFile.Reader reader ;
try {
reader = new SequenceFile.Reader(fs, path, conf);
IntWritable key = (IntWritable) reader.getKeyClass().newInstance();
FloatArrayWritable value = (FloatArrayWritable) reader.getValueClass().newIn... | 6 |
public static void main(String[] args) {
Scanner input = new Scanner( System.in );
int num1 = 0;
int num2 = 0;
int num3 = 0;
int sum = 0;
int product = 0;
int average = 0;
int smallest = 0;
int largest = 0;
System.out.print( "Please enter first integer: ");
num1 = input.nextInt();
Syste... | 9 |
public void putchar(ArrayList<String> ret,char c){
if(c=='1'){
ret.add("");
}
else if(c=='2'){
ret.add("a");
ret.add("b");
ret.add("c");
}
else if(c=='3'){
ret.add("d");
ret.add("e");
ret.add("f")... | 9 |
private boolean isDisplayModeAvailable(
int screenWidth, int screenHeight, int screenColorDepth ) {
DisplayMode[] displayModes = this.graphicsDevice.getDisplayModes();
for( DisplayMode mode : displayModes ) {
if( screenWidth == mode.getWidth() && screenHeight == mode.ge... | 4 |
@SuppressWarnings("unchecked")
private void createObjectReceiveServer() {
ServerSocket serverSocket = null;
try {
serverSocket = new ServerSocket(Integer.parseInt(port));
while (true) {
byte[] data = readData(serverSocket);
//convert bytes from socket into an object
if ((data[0] == -84) && (data[... | 9 |
public static void main(String[] args) {
Watch.start();
int lim = 1_000_000;
boolean[] primeTable = Utils.primeTable(lim);
List<Integer> primes = new ArrayList<>();
for (int i = 0; i < lim; i++)
if (primeTable[i]) primes.add(i);
int maxLen = 0, s = 0, maxS = 0... | 8 |
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
Block block = event.getClickedBlock();
Player player = event.getPlayer();
if (!worldmanager.isHiddenWorld(player.getWorld()))
{
return;
}
if (event.getAction().equals(Action.RIGH... | 5 |
public static void main(String[] args) {
byte op = 0;
do{
System.out.print("\n\t***GESTION DE PRESTAMOS*\n1. Agregar Prestamos.\n" +
"2. Pagar cuota.\n3. Ver informacion de prestamo.\n4. Salir.\n" +
... | 8 |
public void run() {
Scanner scanner = new Scanner(System.in);
do {
if (level == null) {
if (scanner.hasNextLine()) {
level = scanner.nextLine();
}
message("Enter level: ");
level = scanner.nextLine();
}
program.init(level);
program.run(this);
Integer result = null;
while (resu... | 7 |
public static boolean calcWaterNeeded(double playerGuess) {
boolean result;
if (playerGuess < 0 || playerGuess > 25) {
result = false;
} else {
int berrieEaten = (int) (Math.random() * 15);
System.out.println("Berries Eaten = " + berrieEaten);
d... | 3 |
@Override
public void draw(FrameBuffer buffer) {
buffer.blit(texture, 0, 0, buffer.getOutputWidth() - x, y, width, height, widthDest, heightDest, 0, false);
for(String str : namePrimitives)
primitives.get(str).blit(buffer);
} | 1 |
@Override
public boolean importData(TransferHandler.TransferSupport dataInfo) {
if (!dataInfo.isDrop()) {
return false;
}
if (!dataInfo.isDataFlavorSupported(DataFlavor.stringFlavor)) {
return false;
}
JList list = (JLis... | 4 |
@Override
public List<Bounty> getOwnBounties(String issuer) throws DataStorageException {
List<Bounty> bounties = new ArrayList<Bounty>();
Set<String> keys = this.config.getConfigurationSection("bounties").getKeys(false);
for (String key : keys) {
try {
int keyVa... | 4 |
public static void q4(String[] args) throws Exception{
//Question 7.4: Write methods to implement the multiply, subtract, and divide
//operation for integers. Use only the add operator.
SOP("Running q4");
Scanner s = new Scanner(System.in);
SOP("Please Enter two numbers to perform computation on");
SOP2("Nu... | 7 |
public static Method[] getterMethodDrilldown(Class<?> type, String property)
throws NoSuchMethodException {
Class<?> innerClass = type;
Method method;
if (property.startsWith("./")) {
property = property.substring(2);
}
String[] path = property.split("[./]... | 9 |
public List<Interval> merge(List<Interval> intervals) {
List<Interval> result = new ArrayList<Interval>();
if (intervals == null || intervals.size() == 0)
return result;
HashMap<Integer, Integer> processedIntervals = new HashMap<Integer, Integer>();
ArrayList<Integer... | 9 |
public String encodeFromFile( String rawfile )
{
byte[] ebytes = readFile( rawfile, ENCODE );
return ebytes == null ? null : new String( ebytes );
} // end encodeFromFile | 1 |
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.