text stringlengths 14 410k | label int32 0 9 |
|---|---|
public static void determineWinners() {
System.out.printf("%s has %d points.\n", dealer.getName(), dealer.getHand().getPoints());
for (Player p : playerList) {
for (int i = p.getNumberOfHands() - 1; i >= 0; i--) {
System.out.printf("%s has %d points for hand%d.\n", p.getName(), p.getHand(i).getPoints(), i... | 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 boolean getKeyDown(int keyCode) {
return getKey(keyCode) && !lastKeys[keyCode];
} | 1 |
public void load(String file)
{
// when we load a new file, stop playback of other file.
stop();
// Don't try all this if the sequencer is not open.
if ( !sequencer.isOpen() ) {
System.err.println("Cannot load a midiFile. The sequencer is not open.");
... | 3 |
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() instanceof Timer){
int s = rand.nextInt(aliens.size());
if (s%3 ==0 && s%5 ==0){
fireAlien(s);
}
if(!reverse) {
for (int i = 0; i < aliens.size(); i++) {
... | 9 |
public String getAge() {
return age;
} | 0 |
private boolean collision(Rectangle future, Rectangle[] walls){
for(int i = 0; i< walls.length; i++){
if(future.intersects(walls[i])){
return true;
}
}
return false;
} | 2 |
public void setAppletContext(String htmlName, URL documentBase, URL codeBase, String appletProxyOrCommandOptions) {
this.htmlName = htmlName;
isApplet = (documentBase != null);
String str = appletProxyOrCommandOptions;
if (!isApplet) {
// not an applet -- used to pass along command line options
if (str.in... | 8 |
public static final Rectangle inset(int amount, Rectangle bounds) {
bounds.x += amount;
bounds.y += amount;
bounds.width -= amount * 2;
bounds.height -= amount * 2;
if (bounds.width < 0) {
bounds.width = 0;
}
if (bounds.height < 0) {
bounds.height = 0;
}
return bounds;
} | 2 |
private void ConnectionButtonClicked(MouseEvent evt) {
if(Settings.activatePremium){
if(!UsernameField.getText().trim().equals("")){
if(!passwordField.getPassword().toString().trim().equals("")){
login(UsernameField.getText().trim(), new String(passwordField.getPassword()));
... | 4 |
public static JSONObject toJSONObject(String string) throws JSONException {
JSONObject o = new JSONObject();
HTTPTokener x = new HTTPTokener(string);
String t;
t = x.nextToken();
if (t.toUpperCase().startsWith("HTTP")) {
// Response
o.put("HTTP-Versi... | 2 |
@Override
public synchronized int readBit() throws BitStreamException
{
int res = this.delegate.readBit();
this.current <<= 1;
this.current |= res;
this.out.print((res & 1) == 1 ? "1" : "0");
this.lineIndex++;
if (this.mark == true)
this.out.pr... | 9 |
private boolean calculateWindowSize()
{
boolean sizeIsOkay = true;
int outsideFrameWidth = this.getWidth();
int outsideFrameHeight = this.getHeight();
if (outsideFrameWidth < MIN_WINDOW_WIDTH)
{
outsideFrameWidth = MIN_WINDOW_WIDTH;
sizeIsOkay = false;
}
if (outsideFrameHeigh... | 5 |
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof SampleAttribute)) {
return false;
}
SampleAttribute other = (SampleAttribute) object;
if ((this.sampleAttribute... | 5 |
public boolean accept(File dir, String name) {
boolean isAcceptable = false;
for (int i = 0; i < m_extensionList.size(); i++) {
String ext = m_extensionList.get(i);
if (!ext.startsWith("."))
ext = "." + ext;
isAcceptable = name.endsWith(ext);
if (isAcceptable)
break;
... | 3 |
@Override
public void setNull(int intId, String strTabla, String strCampo) throws Exception {
Statement oStatement;
try {
oStatement = (Statement) oConexionMySQL.createStatement();
String strSQL = "UPDATE " + strTabla + " SET " + strCampo + " = null WHERE id = " + Integer.toS... | 1 |
public GUIViewPanel(Grid initGame){
super();
game = initGame;
dx = 50;
dy = 50;
try {
floor = ImageIO.read(getClass().getResource("/WumpusImages/Ground.png"));
blood = ImageIO.read(getClass().getResource("/WumpusImages/Blood.png"));
goop = ImageIO.read(getClass().getResource("/WumpusImages/Goop.png")... | 1 |
public static void bstTest() {
for (int i = 0; i < 100; i++) {
BST tree = new BST();
Make make = new Make();
ArrayList<Integer> list = make.list();
for (int n = 0; n < list.size(); n++) {
tree.insert(list.get(n));
if (n % 10 == 0)... | 5 |
public ConvertCFGLL(GrammarEnvironment environment) {
super("Convert CFG to PDA (LL)", null);
this.environment = environment;
} | 0 |
@Override
public void itemStateChanged(ItemEvent e) {
if (textEntryField == null) {
// We we're unable to find a JTextField component that was a decendant of this
// JFileChooser so we need to abort.
return;
}
String filename = textEntryField.getText();
if (filename == null || filename.equals(""... | 8 |
public String getName() {
return this.name;
} | 0 |
public static void send() {
while (true) {
Socket socket = null;
byte[] readInput = new byte[80];
DatagramPacket packett = null;
byte[] m = null;
byte[] input = null;
try {
input = new byte[80];
packett = new Da... | 2 |
public void finish(UQuest plugin, Player player, boolean showText){
Quester quester = plugin.getQuestInteraction().getQuester(player);
int id = quester.getQuestID(); //For the event to know which quest id the player had
//set them to having no active quest
quester.setQuestID(-1);
//set them to having no qu... | 5 |
public static int diferencaMatriz(int[][] matriz){
int[][] original = {{1, 2, 3},{4, 5, 6},{7, 8, 0}};
int dif = 0;
int a;
int b;
int N = 3;
for (a=0; a<3; a++){
for(b=0; b<3; b++){
if (original[a][b] != matriz[a][... | 5 |
public Causa eliminacionImputadoPorTeclado(){
@SuppressWarnings("resource")
Scanner scanner = new Scanner (System.in);
String texto;
int expediente;
Long dni;
Causa causa = new Causa();
try {
System.out.println("Eliminar Imputado de Causa");
System.out.println("--------------------------");
whil... | 9 |
private String getFormatedChange(String change)
{
StringBuilder sb = new StringBuilder("<font color=\"");
final String typePattern = "[{].+[}]";
Pattern pattern = Pattern.compile(typePattern);
Matcher matcher = pattern.matcher(change);
List<String> matchList = new ArrayList<>();
while(matcher.find())
ma... | 8 |
public void setId(Long id) {
this.id = id;
} | 0 |
public int[][] resetMatrix() {
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[0].length; j++) {
if (matrix[i][j] == 0) {
row[i] = true;
col[j] = true;
}
}
}
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[0].le... | 7 |
public String handleCommand(String stp) {
if(stp.toLowerCase().startsWith("tenable")){
if(enabled){
enabled = false;
return "Commands Disabled.";
}else{
enabled = true;
return "Commands Enabled.";
}
}
if(enabled){
//cannot be a switch case, it wont recognise .startsWith, which me... | 8 |
public int length() {
return this.myArrayList.size();
} | 0 |
@Override
public void run() {
ServerSocket socket;
boolean isRefreshRequest = false;
System.out.println("Webserver starting up on port "+ SERVER_PORT);
System.out.println("(press ctrl-c to exit)");
try {
// create the main server socket
socket = new ServerSocket(SERVER_PORT);
} catch (Exception e)... | 9 |
@Override
public IStatementObject deserialize(JsonElement json, Type typeOfT,
JsonDeserializationContext context) throws JsonParseException {
JsonObject obj = json.getAsJsonObject();
Class<?> klass = null;
try {
if (obj.has(OBJECT_TYPE)) {
String objectType = obj.get(OBJECT_TYPE).getAsJsonPrimitiv... | 8 |
public void giveItems() {
Client o = (Client) Server.playerHandler.players[c.tradeWith];
if(o == null) {
return;
}
try{
for(GameItem item : o.getTradeAndDuel().offeredItems){
if (item.id > 0) {
c.getItems().addItem(item.id, item.amount);
}
}
c.getPA().removeAllWindows();
c.tr... | 8 |
public DirectScrollPanelArea checkAndConvertToArea(Point where) {
DirectScrollPanelArea area;
if (mContentBounds.contains(where)) {
area = DirectScrollPanelArea.CONTENT;
} else {
if (mHeaderBounds.contains(where)) {
area = DirectScrollPanelArea.HEADER;
} else {
area = DirectScrollPanelArea.NONE;
... | 2 |
@SuppressWarnings("serial")
private void vali() throws NoSuchAlgorithmException, IOException {
List<String> list = new ArrayList<String>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
final String token = mainForm.getInputToken().getText();
final String timestamp = sdf.format(new Date(... | 7 |
private void stopAllMunitions() {
for (EnemyLauncher el : enemyLauncherArr) {
try {
if (el.getCurrentMissile() != null) {
el.getCurrentMissile().join();
}
el.stopRunning();
el.interrupt();
el.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
for (Launc... | 9 |
public void userCraft(long id, String recipeId) {
User user = getUser(id);
Recipe recipe = getRecipe(recipeId);
List<ItemTemplate> ingredients = recipe.getIngredients();
List<String> ingrNames = new ArrayList<String>();
for (ItemTemplate item : ingredients) {
ingrNam... | 5 |
public void testGetFieldType() throws Throwable {
MockPartial mock = new MockPartial();
assertEquals(DateTimeFieldType.year(), mock.getFieldType(0));
assertEquals(DateTimeFieldType.monthOfYear(), mock.getFieldType(1));
try {
mock.getFieldType(-1);
fail();... | 2 |
public List<Contact> getContact(Contact c) {
List<Contact> list = new ArrayList<Contact>();
for(Contact contact : plateforme)
{
if(!c.getNom().isEmpty())
{
if(c.getNom().equalsIgnoreCase(contact.getNom()))
list.add(contact);
}
if(!c.getPrenom().isEmpty())
{
if(c.getPrenom().equalsIgnor... | 9 |
public void parsedAimAvailable(AimParseEvent event) {
AimParser aimParser = (AimParser)event.getSource();
String tumorID = aimParser.getTumorID();
String tumorName = aimParser.getTumorName();
Tumor tumor = new Tumor(tumorID, tumorName);
String raterID = aimParser.getRaterID();
String raterNam... | 7 |
public void fullReset(){
int i;
gold = 0;
for(i = 0; i < backpack.length; i++){
backpack[i] = null;
}
for(i = 0; i < equipment.length; i++){
equipment[i] = null;
}
} | 2 |
private void waitForConnection() {
// retrieve the local Bluetooth device object
LocalDevice local = null;
StreamConnectionNotifier notifier;
StreamConnection connection = null;
// setup the server to listen for connection
try {
local = LocalDevice.getLocalDevice();
local.setDiscoverable(Discove... | 4 |
public void setDateEmbauche(String dateEmbauche) {
this.dateEmbauche = dateEmbauche;
} | 0 |
@Transactional
@RequestMapping(value = {"/app/saveIssue"}, method = RequestMethod.POST)
public ModelAndView saveIssue(HttpServletRequest request,
@RequestParam(required = false) Long id,
@RequestParam String title,
... | 6 |
private void preserveRemainingInboundData() {
if (mInboundData.hasRemaining()) {
mUnderflowData = ByteBuffer.allocate(mInboundData.remaining());
mUnderflowData.put(mInboundData);
mUnderflowData.flip();
}
} | 1 |
private void handlePublicQueue() {
HospitalPart hp = HospitalPart.PUBLIC;
Sector sec = sectors.get(hp);
LinkedBlockingDeque<Patient> q = doc_queues.get(hp);
if (sec.hasBusyDoc()) {
int[] tmp = sec.getFinishTimes();
for (int i = 0; i < sec.getDocCount(); i++) {
if (tmp[i] == clock) {
Patient p =... | 8 |
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println("Number of strings to follow:");
int numberOfStringsToFollow = s.nextInt();
s.nextLine();
String[] strings = new String[numberOfStringsToFollow];
int maxStringLength = 0;
for... | 5 |
public int inCityDefenseBonus(Hero hero)
{
if (buildings.contains(CastleBuilding.CASTLE)) {
return 12;
} else if (buildings.contains(CastleBuilding.CITADEL)) {
return 8;
} else if (buildings.contains(CastleBuilding.FORT)) {
return 4;
}
return 0;
} | 3 |
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof DatasetAttribute)) {
return false;
}
DatasetAttribute other = (DatasetAttribute) object;
if ((this.datasetAttri... | 5 |
static public CTTrajectory<Double> cutTrajectory(CTTrajectory<Double> trj, double cutPercentage) //? TODO test
throws IllegalArgumentException {
if( trj == null)
throw new IllegalArgumentException("Error: null trajectory");
if( trj.getTransitionsNumber() == 0)
throw new IllegalArgumentException("Error: em... | 9 |
private void initGUI() {
int position;
this.setLayout( new BorderLayout() );
this.setOpaque( false );
// attributes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
panelInven = new JPanel( new GridLayout( 4, 10 ) );
panelInven.setBorder( GUI.setupAreaBorder( "Inventory" ) );
... | 4 |
@Override
public void update(GameContainer container, StateBasedGame game, int delta)
throws SlickException {
metronome.update(container, delta);
player.update(container, delta);
if (metronome.isNewBeat()) {
processBeat(container);
}
prompts.update(container, delta);
for (GameObject o : gameObj... | 6 |
private boolean isBorderBiomes(Tile tile, Point[] surrPoints) {
boolean out = false;
for (Point p : surrPoints) {
Tile t = MyzoGEN.getOutput().getTile(p);
if (t != null && t.tile != tile.tile && Tiles.getPrecedence(t.tile) > Tiles.getPrecedence(tile.tile)) {
out = true;
break;
}
}
return out;
... | 4 |
public Instance(String[] args) throws FatalError, IOException {
// configure plans
PlanBoeseBeute.initiate();
PlanBoeseKrieg.initiate();
PlanBoeseRespekt.initiate();
PlanAngriff.initiate();
// reset config
new Config();
// reset user
new User();
this.parseArguments(args);
if (this.modus.equal... | 9 |
public static char[] build_keyed_alphabet(String k)
{
char[] result=new char[26];
String k_u=k.toUpperCase();
boolean[] filled=new boolean[26];
int pos=0;
for(int i=0;i<k_u.length();i++)
{
char cur_c=k_u.charAt(i);
int char_pos=cur_c-'A';
if(filled[char_pos])
{
continue;
}
result[pos]... | 4 |
public void lengthReturn() {
if (length != FRAME_HEIGHT / 5) {
duration++;
if (duration == 1000) {
length = FRAME_HEIGHT / 5;
duration = 0;
}
}
} | 2 |
protected static byte[] getCertificateBytes() {
if (certificateBytes == null) {
InputStream certifacteStream = getCertificateStream();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
try {
int bytesRead = 0;
while ((bytesRea... | 3 |
void select_imagesource(String direction) {
if (this.image_file != null) {
File file = null;
File folder = image_file.getParentFile();
File[] listOfFiles = folder.listFiles();
HashMap<String, File> imageFiles = new HashMap<String, File>();
for (int i = 0; i < listOfFiles.length; i++) {
file = list... | 9 |
public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException {
List<String> incidents = new ArrayList<String>();
//compile the individual incident dates into a list
while (values.hasNext()) {
incidents.add(values.next().toString());
}
i... | 8 |
private void addSong() //tilføjer en sang
{
clear();
System.out.println("Add Song:");
System.out.println();
try
{
Scanner sc = new Scanner(System.in, "ISO-8859-1");
System.out.print("Title: ");
String title = sc.nextLine();
... | 4 |
public static void main(String[] args) throws IOException {
// System.out.println(
// Thread.currentThread().getContextClassLoader().getResource(""));
// System.out.println(FileUtil.class.getClassLoader().getResource(""));
// System.out.println(ClassLoader.getSystemResource(""));
// ... | 8 |
protected String InferLangFromCookie(HttpServletRequest httpRequest)
{
// Try to locate a cookie that states the user's language preference.
// Calling applications should use this name when setting the cookie.
// Cookie name: "language-preference"
// Permissible values: "fr" or "en"
t... | 3 |
public DisplayObject addChildAt(DisplayObject child, int index) {
DisplayObjectImpl impl =
((ContainerImpl) overlay).addChildAt(child.getOverlay(), index);
if (impl != null) {
children.add(index, child);
}
return (impl != null ? child : null);
} | 2 |
@Override
public void start(ExecutorTask executorTask) {
if(ImageManager.imagesFinder.getRandomFilename(WaterMarkModel.isJpgTreatment(),WaterMarkModel.isPngTreatment(),WaterMarkModel.isGifTreatment()) == null){
return;
}
Rectangle panelRect=ArtiMarkFrame.panelWatermarkVie... | 7 |
public double mageDefTest() {
double defenceBonus = c.playerBonus[8] == 0 ? 1 : c.playerBonus[8];
if(defenceBonus < 50)//1
defenceBonus = 50;//1
double defenceCalc = defenceBonus * c.playerLevel[1];
if (c.prayerActive[0])
defenceCalc *= 1.05;
else if (c.prayerActive[3])
... | 7 |
public void testPropertySetMonth() {
YearMonth test = new YearMonth(1972, 6);
YearMonth copy = test.monthOfYear().setCopy(12);
check(test, 1972, 6);
check(copy, 1972, 12);
try {
test.monthOfYear().setCopy(13);
fail();
} catch (IllegalArgum... | 2 |
public byte[] scanForSpeech(byte[] dataBuffer) {
ByteArrayOutputStream speechData = new ByteArrayOutputStream();
boolean isSpeech = false;
int tailIndex = 0;
for (int headIndex = 9; headIndex < dataBuffer.length; headIndex= headIndex+10) {
// process this segment
byte[] currentBuffer = Arrays.copyOfRange(... | 6 |
String[] countWords(String sentence, int returnWordCount) {
// check input parameter
if (sentence == null || sentence.isEmpty()) {
System.out.println("Sentence not defined");
return null;
}
// check input parameter
if (returnWordCount <= 0) {
System.out.println("Return Words must be greater tha... | 8 |
public static List<Throwable> getVerificationFailures() {
List<Throwable> verificationFailures = verificationFailuresMap.get(Reporter.getCurrentTestResult());
return verificationFailures == null ? new ArrayList<Throwable>() : verificationFailures;
} | 1 |
public double calculatePlatformAndOtherConsuptionsW(SoftwareSystem system) {
double consumption = 0;
for (HardwareSetAlternative hardwareSetAlternative : system.getHardwareSystem().getHardwareSetAlternatives())
if (system.getActuallyUsedHardwareSets().contains(hardwareSetAlternative.getHardwareSet())) {
doub... | 2 |
public void send(Object oo){
try {
if(this.running){
out.writeObject(oo);
out.flush();
}
} catch (IOException e) {
e.printStackTrace();
}
} | 4 |
public List<Class<? extends Peuple>> getPeuplesPris() {
return peuplesPris;
} | 1 |
public TurnOff(){
super(Color.OFF);
} | 0 |
private boolean connectWithServer() {
//Hacemos una comprobacion rápida de la ip.
JLabel label = autConnectPane.isVisible() ? autInfo : connInfo;
label.setText("Comprobando...");
if (URI.isWellFormedAddress(serverIP.getText())) {
try {
//Comprobamos que la di... | 5 |
public static void main(String args[]) {
String encryptedPassword = encrypt("user");
System.out.println("The encrypted password for user is - "
+ encryptedPassword);
} | 0 |
public FromIterator(Iterable<T> source, Selector<T, Iterable<T2>> selector)
{
this._source = source.iterator();
this._selector = selector;
} | 0 |
public void create(Args args) throws IOException {
//根据autoCodeConfig中的配置,调用coder生成代码
AutoCodeConfig config = AutoCodeConfig.loadConfig(args);
if(args.getOptions() == null || args.getOptions().size() <= 0){
throw new RuntimeException("options is empty");
}
if(args.g... | 4 |
private void VM_Parse(Element vms)
{
vect_vms = new ArrayList();
ArrayList<String> atts = new ArrayList<>(Arrays.asList("mips","cpu","ram", "bw", "size", "vmm"));
List liste_vm = vms.getChildren();
int nb_vm = liste_vm.size();
System.out.println("There is"+ nb_vm + " VM(s)" )... | 8 |
public void testDateConverter() {
System.out.println("** testDateConverter **");
final int year = 2008;
final int dayOfMonth = 22;
final int hour = 7;
final int minute = 3;
final CycNaut cycDate = new CycNaut(DateConverter.MINUTE_FN, minute,
new CycNaut(DateConverter.HOUR_FN, hour,
... | 1 |
public void volcarDatos(ArrayList<Usuarios> libros){
DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
while(model.getRowCount()>0)model.removeRow(0);
for(Usuarios u : libros){
Object[] fila = {
u.getCodigo(),
u.getNombre(),
... | 2 |
public int DondeJugar() {
if (MesaIsNull()) {
return 1;
} else {
if ((Mesa.getAux().info.C1 == Ftemp.C1 || Mesa.getAux().info.C1 == Ftemp.C2) && (Mesa.getAux().info.C2 == Ftemp.C1 || Mesa.getAux().info.C2 == Ftemp.C2)) {
return 0;
} else {
... | 9 |
public void clearKeys(Class c) {
if (modelManager.frame == null)
return;
Atom[] atoms = modelManager.frame.atoms;
for (int i = 0; i < modelManager.frame.atomCount; i++) {
if (SiteAnnotation.class == c)
atoms[i].annotationKey = false;
else if (InteractionCenter.class == c)
atoms[i].interactionKey ... | 7 |
public void setColor(String color) {
this.color = color;
} | 0 |
public void deal() {
if (deck.getDeck().size() >= 4) {
deck.deal(player);
deck.deal(dealer);
dealer.getHand().get(0).flip();
dealer.refreshImage();
info.update(deck);
dealButton.setEnabled(false);
hitButton.setEnabled(true);
standButton.setEnabled(true);
if (player.getMoney() >= bet)
do... | 2 |
static public String openOrder( int orderId, Contract contract, Order order, OrderState orderState) {
String msg = "open order: orderId=" + orderId +
" action=" + order.m_action +
" quantity=" + order.m_totalQuantity +
" symbol=" + contract.m_symbol +
" exchange=" + contract.m_ex... | 8 |
boolean formula(){
char ch = get();
if(ch=='('){
boolean f1 = formula();
ch = get();
if(ch=='*'){
boolean f2 = formula();
get();
return f1&&f2;
}
else if(ch=='+'){
boolean f2 = formula();
get();
return f1||f2;
}
else{
get();
boolean f2 = formula();
get();
... | 9 |
public Location getAdjacentLocation(int direction) {
// reduce mod 360 and round to closest multiple of 45
int adjustedDirection = (direction + HALF_RIGHT / 2) % FULL_CIRCLE;
if (adjustedDirection < 0)
adjustedDirection += FULL_CIRCLE;
adjustedDirection = (adjustedDirection / HALF_RIGHT) * HALF_RIGHT;
int... | 9 |
public boolean trainCanMove() {
if (train.size() == 0)
return true;
else {
int totalWeight = 0;
for (int i = 0; i < train.size(); i++) {
switch (train.get(i).getClass().getSimpleName()) {
case LOCOMOTIVE:
totalWeight += ((Locomotive) train.get(i)).getGrossWeight();
break;
case PASSEN... | 6 |
private static File[] createFileArray(BufferedReader bReader,
PrintStream out) {
try {
java.util.List list = new java.util.ArrayList();
java.lang.String line = null;
while ((line = bReader.readLine()) != null) {
try {
// kde seems to append a 0 char to the end of the reader
if (ZERO_CHAR_STR... | 4 |
public TreeNode sortedArrayToBSTRec(int[] num, int s, int e){
if(s > e) return null;
if(s == e) {
return new TreeNode(num[s]);
}
int mid = (s+e) >> 1;
TreeNode t1 = sortedArrayToBSTRec(num, s, mid - 1);
TreeNode t2 = sortedArrayToBSTRec(num, mid + 1, e);
... | 2 |
public static Battlefield create(){
if(battleField == null ){
battleField = new Battlefield();
}
return battleField;
} | 1 |
public static void cartesianToPolar(Graph graph, ArrayList vertices) {
double theta, r;
Point2D cartesian;
for (int i=0; i<vertices.size(); i++) {
cartesian = graph.pointForVertex(vertices.get(i));
if (cartesian.getY() != 0)
theta = Math.atan(cartesian.getY() / cartesian.getX());
else
theta = Mat... | 2 |
@Override
public long readVLong() {
byte b = bytes[pos++];
if (b >= 0) return b;
long i = b & 0x7FL;
b = bytes[pos++];
i |= (b & 0x7FL) << 7;
if (b >= 0) return i;
b = bytes[pos++];
i |= (b & 0x7FL) << 14;
if (b >= 0) return i;
b = bytes[pos++];
i |= (b & 0x7FL) << 21;
... | 9 |
public DisplayMode findFirstCompatibleMode(
DisplayMode modes[])
{
DisplayMode goodModes[] = device.getDisplayModes();
for (int i = 0; i < modes.length; i++) {
for (int j = 0; j < goodModes.length; j++) {
if (displayModesMatch(modes[i], goodModes[j])) {
... | 3 |
public static int getMax(int intArr[], int len){
int max = intArr[0];
for (int i=1; i<len; i++){
if (intArr[i]>max)
max = intArr[i];
}
return max;
} | 2 |
public void actionPerformed( ActionEvent evento )
{
String comando = evento.getActionCommand( );
if( BOTON_INICIAR.equals( comando ) )
{
ventanaPrincipal.iniciar( );
}
else if( BOTON_STEP.equals( comando ) )
{
ventanaPrincipal.avanzar... | 3 |
public void delete() throws SQLException {
if(this.isNew()) {
return;
}
PreparedStatement statement = connect.prepareStatement(" delete from `" + tableName + "` where `id` = " + id );
statement.executeUpdate();
this.id = 0;
} | 1 |
private double[] initProbability() {
double[] prob = new double[langlist.size()];
if (priorMap != null) {
for(int i=0;i<prob.length;++i) prob[i] = priorMap[i];
} else {
for(int i=0;i<prob.length;++i) prob[i] = 1.0 / langlist.size();
}
return prob;
} | 3 |
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof LightNode)) {
return false;
}
LightNode other = (LightNode) obj;
if (!color.equals(other.color)) {
return false;
}
if (Float.floatToIntBits(i... | 5 |
@Test
public void determineHighestFlush_ifFourOfSameSuit_returnNull() {
assertNull(getAllFlushCards(fourFlushWithStraight()));
} | 0 |
Subsets and Splits
SQL Console for giganticode/java-cmpx-v1
The query retrieves a limited number of text entries within a specific length range, providing basic filtering but minimal analytical insight.