text stringlengths 14 410k | label int32 0 9 |
|---|---|
@Override
public boolean dispatchKeyEvent(KeyEvent e) {
if (e.getID() == KeyEvent.KEY_PRESSED) {
} else if (e.getID() == KeyEvent.KEY_RELEASED) {
if (e.isControlDown() && e.getKeyChar() != 'y' && e.getKeyCode() == 89) {
System.out.println("ctrl + y - ... | 9 |
@Override
public void addValeur(Valeur valeur) throws ProfondeurMaximaleAtteinteException {
int cle = valeur.getCle();
if (arbre.getRacine() == null) {
arbre.setRacine(new NoeudBinaireImplementation(valeur));
} else {
int i = 2;
NoeudBinaireImplementation... | 8 |
public boolean containsKey(K key) {
if (root == null)
return false;
Node node = root;
while (true) {
if (key.compareTo(node.mKey) < 0) {
if (node.left == null)
return false;
else
node = node.left;
} else if (key.compareTo(node.mKey) > 0) {
if (node.right == null)
return f... | 6 |
public EvenChecker(IntGenerator g, int ident) {
generator = g;
id = ident;
} | 0 |
public <T> Object doInvoke(MethodInvocation invocation) {
// 统一异常处理,日志,参数检查
try {
return invocation.proceed();
} catch (PrecondictionException e) {
logger.error("Precondiction Error", e);
return new CommonResp<T>(false, e.getErrorCode(), e.getMessage());
} catch (BizException e) {
String errorDesc =... | 5 |
public static String formatDate(Date date) {
return isToday(date) ? TODAY.format(date) : NOT_TODAY.format(date);
} | 1 |
@Override
public int compareTo(Shape shape) {
return Double.compare(getArea(), shape.getArea());
} | 0 |
public static void main(String[] args)
{
SkipListOfStrings ss = new SkipListOfStrings();
if (! ss.contains("a"))
{
System.out.println("a is not in the list");
} // if
ss.add("a");
ss.add("bb");
ss.add("ccc");
ss.add("dddd");
ss.add("eeeee");
if (ss.contains("... | 7 |
public static ArrayList<Rating> getTestSet(String file) {
ArrayList<Rating> testset = new ArrayList<Rating>();
InputStream fis = null;
BufferedReader br;
try {
fis = new FileInputStream(file);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
br = new ... | 3 |
public Army split(Army newArmy) {
Army h = new Army();
for(Legion l : newArmy.getUnits()) {
for(Legion a : units) {
if (l.getType() == a.getType()) {
if(l.getCount() > a.getCount()) {
l.setCount(l.getCount() - a.getCount());
h.add(a);
} else {
h.add(l);
remove(l.getType());... | 4 |
@Override
public void setDefaultChannel(ChatChannel channel)
{
this.defaultChannel = channel;
if (defaultChannel != null)
{
for (ChatChannelPlayer channelPlayer : players.values())
{
if (channelPlayer.getCurrentChannel() == null)
{
defaultChannel.join(channelPlayer.getPlayer());
chann... | 3 |
private void updateLeftAndRight() {
final StringBuilder sb = new StringBuilder();
for (final ChangedFile f : this.unstagedFiles.values()) {
if (sb.length() == 0) {
sb.append("<html><font face=\"Courier New\">");
} else {
sb.append("<br/>");
}
sb.append(f.toString());
}
sb.append("</font></h... | 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 Wave50ChampionBlue(){
super();
MobBuilder m = super.mobBuilder;
for(int i = 0; i < 4500; i++){
if(i % 8 == 0)
add(m.buildMob(MobID.GYARADOS));
else if(i % 8 == 0)
add(m.buildMob(MobID.PIDGEOT));
else if(i % 6 == 0)
add(m.buildMob(MobID.CHARIZARD));
else if(i % 5 == 0)
add(m.buil... | 8 |
public ArrayList<Unit> getPlayersUnits(Player player) {
ArrayList<Unit> units = new ArrayList<Unit>();
for (Cell[] cell1 : cells) {
for (Cell cell : cell1) {
if (cell.getUnit() != null) {
if (Teams.comparePlayers(cell.getUnit().getOwner(), player)) {
units.add(cell.getUnit());
}
}
}
... | 4 |
public static byte[] gzip(String input) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gzos = null;
try {
gzos = new GZIPOutputStream(baos);
gzos.write(input.getBytes("UTF-8"));
} catch (IOException e) {
e.printStackTrace... | 3 |
private Method findMethod(Class clazz, String callName, Argument[] args)
{
Method method = null;
METHOD_LOOP:
for (Method m : clazz.getMethods())
{
if (!m.getName().equals(callName)) continue;
Class[] paramTypes = m.getParameterTypes();
if (args.length != paramTypes.length) continue;
for (i... | 5 |
public void method1() {
this.method2();
} | 0 |
@Override
public int filterRGB(int x, int y, int argb) {
if (mIncludeAlpha || (argb & OPAQUE) == OPAQUE) {
int darkenBy = (int) (((argb >> 16 & 255) * 0.3 + (argb >> 8 & 255) * 0.59 + (argb & 255) * 0.11) / 2.55);
argb = argb & OPAQUE | mRed * darkenBy / 100 << 16 | mGreen * darkenBy / 100 << 8 | mBlue * darke... | 2 |
public int getDirection() {
return this.direction;
} | 0 |
@Override
public void handle(KeyEvent keyEvent) {
TextField txt_TextField = (TextField) keyEvent.getSource();
if (txt_TextField.getText().length() >= maxLength) {
keyEvent.consume();
}
if(keyEvent.getCharacter().matches("[0-9.]")){
if(txt_TextField.getText().c... | 6 |
private void newAttachmentButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newAttachmentButtonActionPerformed
JFileChooser filechooser = new JFileChooser();
filechooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int result = filechooser.showOpenDialog(null);
... | 3 |
public synchronized MessageBlock getNextBlock(final int size, final long time) {
int length = size;
int offset = currentOffset;
/*
* Search first for block to resent.
*/
MessageBlock mb = checkForMissingBlocks(size, time);
if (mb != null)
return mb;
/*
* Then send the next block if available.
... | 3 |
public RondPoint(int taille) {
int j, i;
VoieInterne vi, suivante;
VoieExterne sortie;
ArrayList<VoieEnum> voiesEnum;
voiesExternes = new ArrayList<VoieExterne>();
voiesInternes = new ArrayList<VoieInterne>();
voiesEnum = new ArrayList<VoieEnum>();
for (i = 0; i < 4; i = i ... | 2 |
public static Tile get(int id) {
for (Tile tile : tiles)
if (tile.tileID == id) return tile;
return tileVoid;
} | 2 |
@Override
public void run() {
getNetworkHandler().fireNetworkEvent(new NetworkEvent(NetworkEvents.START_CLIENT, "Starting client..."));
setClient(true);
setServer(false);
echoSocket = setUpConnection(port, hostname);
// return if connection went to hell or w/e
if (echoSocket == null)
return;
getNetw... | 3 |
public Token next() throws IOException
{
// reset the value builder
value.setLength( 0 );
// if there's a token waiting, return it
if( next != null )
{
current = next;
next = null;
return current;
}
while( true )
{
int read = source.read();
if( read == -1 )
{
if( value.length() ... | 8 |
public void setParamValues(double[] paramValues) {
this.paramValues = paramValues;
int index = 0;
for (int i = 0; i < paramData.length; i++) {
double[] data = new double[paramData[i].getCalibrationDataSize()];
if (paramValues.length < data.length) {
... | 3 |
public static List<String> splitLine(String l)
{
StringBuilder[] builders = new StringBuilder[] { new StringBuilder(), new StringBuilder(), new StringBuilder() } ;
int segment = 0;
boolean seeking = false;
for (int i = 0; i < l.length(); i++)
{
char next = l.charAt(i);
if (Character.isWhitespace(ne... | 6 |
public static int countNeighbours(long world, int col, int row) {
int c = 0;
if (getCell(world, col - 1, row - 1) == true) {
c += 1;
}
if (getCell(world, col, row - 1) == true) {
c += 1;
}
if (getCell(world, col + 1, row - 1) == true) {
c += 1;
}
if (getCell(world, col - 1, row) == true) {
... | 8 |
public static void parseVaccFile(String file) {
int[] numVaccines = VaccinationSimulation.numberOfVaccinesSpread;
String[] fractions = {"1.0","0.8","0.6","0.4","0.2"};
String[][] data = new String[numVaccines.length][fractions.length];
int row = 0;
int col = 0;
try {
BufferedReader in = new BufferedReade... | 9 |
public void MenuFrame()
{
JFrame menuFrame = new JFrame("Menu Tool ");
JMenuBar jMenuBar = new JMenuBar();
JMenu m1 = new JMenu("File");
JMenu m2 = new JMenu("Save");
JMenu m3 = new JMenu("load");
JMenu m4 = new JMenu("Quit");
JMenuItem i1 = new JMenuItem("New File");
JMenuItem i2 = new JMenuI... | 0 |
public boolean end() {
return this.eof && !this.usePrevious;
} | 1 |
public void actionPerformed(ActionEvent event) {
Component source = null;
try {
source = (Component) event.getSource();
} catch (Throwable e) {
// Might not be a component, or the event may be null.
// Who cares.
}
performAction(source);
} | 1 |
public Action(Peg x, Peg y, Peg z, Action parent, int type, int diskNum)
{
this.x = x;
this.y = y;
this.z = z;
this.diskNum = diskNum;
while ((width = 3 * Peg.width + horMargin*4) <= 250) {
horMargin += 10;
}
height = Peg.height + vertMargin*2;
... | 5 |
public ComplexMatrix(Complex[][] m) throws Exception {
/*
* Here (i, j) notation is used. i - a row index j - a column
* index j=1 j=2
* i=1 [ [ 11, 12],
* i=2 [ 21, 22] ]
*
* c o l s
* r [ [ 11, 12, 13],
* o [ 21, 22, 23],
* w [ 31, 32, 33] ]
* s
... | 2 |
public void doPost( HttpServletRequest req, HttpServletResponse reponse ) throws ServletException, IOException{
req.setCharacterEncoding("UTF-8");
// Création de l'objet
String id = req.getParameter("id");
if(id != null)
{
User user = ofy().load().type(User.class).parent(KeyFactory.createKey... | 4 |
public static int characterSize(int character) throws JSONException {
if (character < 0 || character > 0x10FFFF) {
throw new JSONException("Bad character " + character);
}
return character <= 0x7F ? 1 : character <= 0x3FFF ? 2 : 3;
} | 4 |
public void Stop()
{
if (isRunning)
isRunning = false;
} | 1 |
public void insertEnd(int red, int green, int blue, Object runlength) {
if (size == 0) {
setHead(tail = new SListNode((short) red, (short) green,
(short) blue, runlength, null));
} else {
tail.next = new SListNode((short) red, (short) green, (short) blue,
runlength, null);
tail = tail.next;
}
... | 1 |
public void run() {
synchronized(this){
try {
URL Url = new URL(this.url);
URLConnection conn = Url.openConnection();
conn.setDoOutput(true);
conn.setReadTimeout(10000);
status=true;
returned=false;
JProgres... | 6 |
@Override
public int attack(double agility, double luck) {
if(random.nextInt(100) < luck)
{
System.out.println("I just threw a fire ball!");
return random.nextInt((int) agility) * 2;
}
return 0;
} | 1 |
public void setCombineAnimation(boolean combineAnimation) {
this.combineAnimation = combineAnimation;
if(combineAnimation) scaleCombine = 1.5;
} | 1 |
public void formAndCallURL(int URLid)//location
{
String location=null;
if(URLid == 0) //Stereograhic projection
{
//Get location from html file
location = getParameter("location0");
}
if(URLid == 1) //Lamber Conformal Conic
{ ... | 9 |
public void addTumorTab(Tumor tumor){
TumorPanel tumorPanel = new TumorPanel();
tumorPanel.setBackground(xipColor);
//add adjudicator
JTabbedPane tabbedPanePrevReport = new JTabbedPane();
JTextArea textAreaPrevReport = new JTextArea(10, 70);
textAreaPrevReport.setBackground(xipLightBlue);
textAre... | 9 |
private Node nodeIfInBounds(int x, int y) {
if(x > 0 && y > 0 && x < map.getWidth() && y < map.getHeight() && !map.isBlocked(new Vector2(x, y)))
return nodes[x][y];
return null;
} | 5 |
@Override
public boolean beginPath(final NestedTimerPath root, final TimerStatistics call) throws IOException {
sb.append(getPre());
if (call != null) {
final boolean belowThreshold = call.getTotalNanos() < totalNanosThreshold;
final boolean currentlySkippedLevelChanges = roo... | 8 |
public static void main(String args[]){
initDisplay();
drawDisplay();
canvas.setPaint(Color.BLACK);
canvas.drawString("You go first: drag your mouse between two vertices to move.", 100, 550);
// comment-in the second line and comment-out the first to use your Player class... | 9 |
public PlayerGridFactory(Grid grid, FullGridFactory factory) {
if (grid == null)
throw new IllegalArgumentException("Grid can't be null!");
if (factory == null)
throw new IllegalArgumentException("Factory can't be null!");
this.factory = factory;
this.grid = grid;
generatePlayerList(2); // Default se... | 2 |
public StructuredBlock prevCase(StructuredBlock block) {
for (int i = caseBlocks.length - 1; i >= 0; i--) {
if (caseBlocks[i].subBlock == block) {
for (i--; i >= 0; i--) {
if (caseBlocks[i].subBlock != null)
return caseBlocks[i].subBlock;
}
}
}
return null;
} | 4 |
public static void apply(Op op) {
Document doc = textArea.getDocument();
int pos = textArea.getCaretPosition();
if (op == null)
return;
try {
if (op.getOpType() == OpType.INSERT_CHAR) {
Insertion insertion = (Insertion) op;
//builde... | 5 |
public StopWatch() {
start = System.currentTimeMillis();
} | 0 |
int getUTFIndex(String str) {
// Check if it is in the pool already
Integer index=UTFs.get(str);
if (index==null) { // add UTF to the pool
index=new Integer(poolEntries++);
try {
constPool.write(1); // CONSTANT_Utf8 = 1;
constPool.writeUTF(str);
} catch (java.... | 3 |
private boolean touchVertically(Line first, Line second ) {
Point fEnd = first.getEnd();
Point sEnd = second.getEnd();
if (fEnd.getX() != sEnd.getX()) {
return false;
}
Point fStart = first.getStart();
Point sStart = second.getStart();
if ((fStart.... | 7 |
public void setFunFecmod(Date funFecmod) {
this.funFecmod = funFecmod;
} | 0 |
@Override
public void action() {
this.parentAgent = ((PatientAgent) this.myAgent);
switch (step) {
case 1:
if (parentAgent.getHospitalAgent() != null) {
step++;
} else {
block();
}
break;
case 2:
if (((PatientAgent) this.myAgent).getAppointment() != 0) {
step +=2;
} else {
... | 7 |
public void clearTheSkys(Hashtable<Room,MapRoom> mapRooms)
{
for(final Enumeration<Room> e=mapRooms.keys();e.hasMoreElements();)
{
final Room R=e.nextElement();
final Room UP=R.rawDoors()[Directions.UP];
if((UP!=null)
&&(UP.roomID().length()==0)
&&(UP instanceof GridLocale))
{
final List<Room... | 9 |
@Override
public void command(Command command) {
switch (command) {
case OPEN:
if (open) {
open = false;
passable = false;
opaque = true;
spriteID = closedsprite;
} else {
... | 2 |
@Test
public void findHighestFlushOrStraight_whenFlushOrStraightPossible_returnsFlush() {
Hand hand = findHighestFlushOrStraight(sixFlushWithStraight());
assertEquals(HandRank.Flush, hand.handRank);
assertEquals(Rank.Jack, hand.ranks.get(0));
assertEquals(Rank.Ten, hand.ranks.get(1));
assertEquals(Rank.Nine,... | 0 |
@SuppressWarnings("unchecked")
protected Object readResolve() throws ObjectStreamException {
try {
Class messageClass = Class.forName(messageClassName);
Method newBuilder = messageClass.getMethod("newBuilder");
MessageLite.Builder builder =
(MessageLite.Builder) newBuilder.... | 5 |
public String dibujarMunieco() {
String retornar = "";
switch (this.cantidadErrores) {
case 0:
retornar = " ";
break;
case 1:
retornar = " " + "O" + "<br>";
break;
case 2:
retornar = " " + "O" + "<br>" + "/";
break;
case 3:
retornar = " " + "O" + "<br>" + "/" + "|";
break;
case 4:
... | 7 |
public int compare(RegisteredChunkyListener i, RegisteredChunkyListener j) {
int result = i.getPriority().compareTo(j.getPriority());
if ((result == 0) && (i != j)) {
result = 1;
}
return result;
} | 2 |
public static List<File> getFileList(String loc, String fileEnd)
{
if (fileEnd == null)
{
fileEnd = "";
}
if (loc == null)
{
loc = dir;
}
// Directory path here
String file;
File folder = new File(loc);
File[] li... | 7 |
public static Image exponentialNoise(Image original, double lambda, double p) {
if (original == null)
return null;
Image expo = original.shallowClone();
for (int x = 0; x < original.getWidth(); x++) {
for (int y = 0; y < original.getHeight(); y++) {
double rand = Math.random();
double noise = 1;
... | 4 |
protected void paintComponent(Graphics g){
super.paintComponent(g);
//System.out.println("repainted");
Graphics2D g2 = (Graphics2D) g;
//draw the player
Player player = GUI.g.player;
Image img = player.playerImage;
g2.drawImage(img, player.xPosition, player.yPosition, null);
//draw items
fo... | 7 |
public void testInit() {
for (int x = 24995; x < 25000; x++) {
int y = 25001;
worldHash.addTile(x, y, Tile.WALL_STONE);
}
for (int x = 25001; x < 25005; x++) {
int y = 25001;
worldHash.addTile(x, y, Tile.WALL_STONE);
}
worldHash.add... | 4 |
public ArrayList<Integer> grayCode(int n) {
ArrayList<Integer> result = new ArrayList<Integer>();
if (n == 0)
return result;
// form two arrays, digitArray is digit from lower position to higher
// position, so digitsArray[0] meaning 0/1 on the lowest position of n,
// valueArray is decimal value represe... | 8 |
public void draw(GOut g) {
if (!Config.showMyAvatar)
this.c.x = newc;
else
this.c.x = oldc;
int i = 0;
int w = frame.sz().x + margin;
long now = System.currentTimeMillis();
synchronized (ui.sess.glob.buffs) {
for (Buff b : ui.sess.glob.... | 9 |
public void run() {
try {
// start read server
Selector selector = Selector.open();
ServerSocketChannel server_channel = ServerSocketChannel.open();
server_channel.configureBlocking(false);
server_channel.socket().bind(new InetSocketAddress("localhost", read_port));
server_channel.registe... | 9 |
@Override
public void evaluateLabels(Map<String, Integer> labelValues, int position)
throws TokenCompileError {
data.evaluateLabels(labelValues, position);
int dest = data.getUnresolvedWord();
int delta = dest - position;
// Q: If the instruction's size might be 2 words, the... | 3 |
public static void manageStudents() {
System.out.print("Do you want to add (0) or delete (1) a student ? ");
int res = -1;
while (res < 0 || res > 1) {
Scanner sc = new Scanner(System.in);
res = sc.nextInt();
}
switch (res) {
case 0:
createStudent();
break;
case 1:
if (FileReadService.sL... | 6 |
public
boolean isOK() {
if (getTitle()==null || getTitle().isEmpty())
return false;
return true;
} | 2 |
public boolean addOneProduct() {
if (quantity < product.getStock()) {
quantity++;
return true;
}
return false;
} | 1 |
public boolean loadBoard(String[] countriesArray, String[] adjacenciesFileArray, String[] continentsFileArray) {
isLoaded = false;
countriesMap = new HashMap<String, Country>();
continentsMap = new HashMap<String, Continent>();
// Populates countriesMap
for (i = 0; i < countriesArray.length; i++) {
... | 5 |
public int indexOfItemId(int itemId) {
int beginIndex = 0, halfIndex, endIndex = itemIds.length;
if(itemIds.length > 0) {
while(true){
halfIndex = (endIndex - beginIndex) / 2 + beginIndex;
if(itemId < itemIds[halfIndex]){
if(endIndex - beginIndex <= 1){
return -1;
}
endIndex = halfIn... | 6 |
public void mouseClicked(MouseEvent e)
{
System.out.println("Click Mouse !");
} | 0 |
public static void javaDetails(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) {
... | 8 |
public void receiveFrame(USART.Frame frame) {
int data = frame.value;
if (mode) { // Instruction mode
switch (data) {
case CLEAR_SCREEN:
clearScreen();
break;
case SCROLL_LEFT:
scrollLeft();
... | 8 |
int bitDiff(int a, int b) {
int count = -1;
while (a < b && b < 0) {
b <<= 1;
count++;
}
return count;
} | 2 |
public ArrayList<Ocupacion> resultQueryOcup(String sql){
ArrayList<Ocupacion> ocuList = new ArrayList<Ocupacion>();
try {
rs = stm.executeQuery(sql);
try {
while(rs.next()){
Ocupacion item = new Ocupacion(rs.getInt("idocupacion"),
rs.getString("ocupacion"));
ocuList.add(item);
... | 3 |
public void taBort (String hornNamn)
{
Punkt[] h = new Punkt[this.horn.length - 1];
int i = 0;
int j = 0;
while (i < horn.length && j < h.length) {
if (hornNamn == horn[i].getNamn()) {
i++;
}
else {
h[j] = horn[i];
i++;
j++;
}
}
this.horn = h;
} | 3 |
public final NTSParser.dvar_annot_return dvar_annot() throws RecognitionException {
NTSParser.dvar_annot_return retval = new NTSParser.dvar_annot_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
Token name=null;
Token LPAR_S76=null;
Token RPAR_S78=null;
... | 8 |
@SuppressWarnings("unchecked")
public static <T extends Number> T mul(T e1, T e2, Class<T> type) {
T result = ElementOpUtils.getNeutralMulElem(type);
switch (type.getSimpleName()) {
case "Byte":
return (T) (Byte) (byte) ((Byte) e1 * (Byte) e2);
case "Short":
return (T) (Short) (short) ((Short) e1 * (S... | 6 |
private GASolution<int[]> algorithmRun() {
GASolution<int[]> best = null;
for (int iter = 0; iter < maxiter; iter++) {
gBestChanged = false;
evaluate();
// for (int i = 0; i < popSize; i++) {
// evaluator.evaluate(population.getSolAt(i));
// }
best = Collections.min(population.getSols());
if (glo... | 7 |
protected void optimize1() throws Exception {
//% main routine for modification 1 procedure main
// while (numChanged > 0 || examineAll)
// numChanged = 0;
int nNumChanged = 0;
boolean bExamineAll = true;
// while (numChanged > 0 || examineAll)
// numChanged = 0;
while (nNumCha... | 8 |
public int isInside(int p_x, int p_y)
{
for (Rectangle r : rectList)
{
if((r.getX()<p_x && p_x<(r.getX()+r.getWidth())) && (r.getY()<p_y && p_y<(r.getY()+r.getHeight())))
{
return rectList.indexOf(r);
}
}
if((getX()<p_x && p_x<(getX()+getWidth())) && (getY()<p_y && p_y<(getY()+getHeight())))
... | 9 |
public void timedTipActions(){
if(showTip1){
tipSteps++;
switch(tipSteps){
case 1:{
drawTip1 = true;
break;
}
case 2:{
drawTip1 = false;
drawTip2 = tru... | 4 |
public AbstractEntity getEntity(String name) {
if (!entityCache.containsKey(name)) {
//create it from a string
boolean isSolid = true;
int buyValue = -1;
int sellValue = -1;
Element root = document.getRootElement();
for (Iterator i = root.elementIterator(); i.hasNext(); ) {
... | 8 |
* if the Loop is empty
*/
public E removeCurrent() {
E tmp = curr.getData();
if (tmp == null || numItems == 0)
throw new EmptyLoopException();
if (numItems == 1) {
msgLoop = new DblListnode<E>();
numItems--;
return tmp;
}
curr.getPrev().setNext(curr.getNext());
curr.getNext().set... | 3 |
public void handlePlayerInventoryClick(InventoryClickEvent e) {
if(e.getSlotType() == ARMOR) {
e.setCancelled(true);//Doesn't work in creative mode (Bukkit bug)
((Player)e.getWhoClicked()).updateInventory();
}
} | 1 |
public static boolean hasAtLeastOneMethodWithName(Class<?> clazz, String methodName) {
Assert.notNull(clazz, "Class must not be null");
Assert.notNull(methodName, "Method name must not be null");
Method[] declaredMethods = clazz.getDeclaredMethods();
for (Method method : declaredMethods) {
if (method.getName... | 8 |
public void insertString(int offs, String str,
javax.swing.text.AttributeSet a) throws BadLocationException
{
String texto = getText(0, getLength());
try
{
if (Character.isDigit(str.charAt(0)))
{
super.remove(0, getLength());
texto = texto.replace(".", "");
StringBuffer s = new StringBuffe... | 7 |
public static void setWordWrap(IEditorPart editor, boolean state) {
if (editor == null) {
return;
}
// editor (IEditorPart) adapter returns StyledText
Object text = editor.getAdapter(Control.class);
if (text instanceof StyledText) {
StyledText styledText ... | 2 |
public void start() {
timer.schedule(new TimerTask() {
public void run() {
update();
timer.cancel();
}
private void update() {
try {
String line;
BufferedReader in = new BufferedReader(
new InputStreamReader(JFrameMain.proc
.getErrorStream()));
while ((line = in.r... | 4 |
private void loadFromFile() {
try {
FileInputStream file = new FileInputStream(filename);
properties = new Properties();
properties.loadFromXML(file);
file.close();
} catch (Exception e) {
System.err.println( e.getMessage() );
}
} | 1 |
public IP4(int t1, int t2, int t3, int t4) throws MalformedIPException {
StringBuffer errorMessage = new StringBuffer("");
if ((t1 < 1) || (t1 > 254))
errorMessage.append(
"tuple1 is malformed. Must be between 2 and 254.\n");
if ((t2 < 1) || (t2 > 254))
errorMessage.append(
"tuple2 is malformed. ... | 9 |
public void doA03(MsgParse mp)
throws SQLException {
if (!mp.visit.getPatient_class().isEmpty())
try {
// use the mrn in the A03 to identify the patient (we want the pid)
// use patient.pid as visit.patient_pid
// where visit.patient_pid = patient.pid
... | 2 |
public static void main(String[] argsv) {
// Setting op a bank.
Bank christmasBank = new Bank();
christmasBank.addAccount(new BankAccount(BigInteger.valueOf(100)));
christmasBank.addAccount(new BankAccount(BigInteger.valueOf(50), BigInteger.valueOf(-1000)));
// Print the balanc... | 2 |
public static void qsortSpecialForRoman(int a[], int l, int r){
if(l>=r) return;
int i=l, j=r, m=i+j>>1;
do{
while(a[i]<a[m]) ++i;
while(a[j]>a[m]) --j;
if(i<=j){
int t=a[i]; a[i]=a[j]; a[j]=t;
++i; --j;
}
}w... | 7 |
@Test
public void testListMock() {
NoteService s = new MockNoteService();
for (Iterator<NoteEntity> iter = s.list().listIterator(); iter.hasNext();) {
NoteEntity note = iter.next();
System.out.println(note);
}
} | 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.