method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
7d0c88fe-6d90-40e4-937e-6791a00ddbaf | 3 | public static void main(String[] args) {
final String host;
final int port;
if(args.length == 2) {
host = args[0];
try {
port = Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
Syst... |
66fa4575-1f24-42f6-8f69-352cf628bb70 | 9 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
if((!auto)&&(!mob.isInCombat()))
{
mob.tell(L("You must be in combat first!"));
return false;
}
MOB target=mob;
if((auto)&&(givenTarget!=null)&&(givenTarget instanceof MOB))
target=(M... |
96554a9e-1a70-49f0-a1a7-050504c60341 | 9 | public void update() {
time++; // every second time is incremented by 60 (because update is 60 times per second)
// if (time % 60 == 0) { // event that happens once per second
if (time % (random.nextInt(50) + 30) == 0) { // event that happens once between 30 to 80 seconds
// xa *= -1; // reverse dir... |
6ff2f690-35c4-40a7-a744-9efe7da351fc | 6 | @EventHandler
public void IronGolemHarm(EntityDamageByEntityEvent event) {
Entity e = event.getEntity();
Entity damager = event.getDamager();
String world = e.getWorld().getName();
boolean dodged = false;
Random random = new Random();
double randomChance = plugin.getIronGolemConfig().getDouble("IronGolem.H... |
1d93415d-7179-461e-a6ee-d818c5de253a | 7 | void menuOpenURL() {
animate = false; // stop any animation in progress
// Get the user to choose an image URL.
TextPrompter textPrompter = new TextPrompter(shell, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
textPrompter.setText(bundle.getString("OpenURLDialog"));
textPrompter.setMessage(bundle.getString("En... |
4836fe01-3c55-49ef-8703-86719365f44f | 3 | public static void main(String[] args) {
String filename = null;
Player p = null;
//Build the map of the game
map m = new map();
if (args.length==0) {
System.out.print("Please enter a valid game file name!\n");
System.exit(1);
}
else{
filename = args[0];
}
try {
... |
3f739517-65f2-48ac-9f18-68612f362cb4 | 4 | void setup(Object associations[], String description) {
Batch appB = new Batch(), reqB = new Batch(), conB = new Batch() ;
Batch toAdd = null ;
for (Object o : associations) {
if (o == APPEALS ) toAdd = appB ;
else if (o == REQUIRES ) toAdd = reqB ;
else if (o == CONFLICTS) toAdd = c... |
5cb9015b-6c22-4cda-b2f5-053f69c3464d | 9 | public static int lengthOfLongestSubstring(String s) {
if(s == null || s.length() == 0){
return 0;
}
if(s.length() == 1){
return 1;
}
int max = 0;
int curLen = 0;
byte[] sb = s.getBytes();
int table[] = new int[129];
for(i... |
a4945534-770d-4721-aaf5-5a31a593c9b7 | 2 | private void jConnectBtnActionPerformed(java.awt.event.ActionEvent evt) {
if (!connected) {
try {
joy1Selection.setEnabled(false);
joy2Selection.setEnabled(false);
InetAddress.getByName(jIPField.getText());
robotInstance.getPacketTransmitter().setRemoteTarget(jIPField.getText(), 2... |
5df4253a-0c5a-4444-8e7c-114ff30a1ea8 | 8 | private int drawSeg(final Graphics2D seg,
final double length, final double rot, final int oldNo) {
int no = oldNo;
double pos = 0.0;
final double end = Math.max(length - segLen * 0.5, 0.0);
while(pos <= end) {
final Graphics2D s = (Graphics2D) seg.create();
if(isFirst &&... |
6ce934b0-283c-47cf-af09-34c81c2c9614 | 9 | public String nextToken() throws JSONException {
char c;
char q;
StringBuffer sb = new StringBuffer();
do {
c = next();
} while (Character.isWhitespace(c));
if (c == '"' || c == '\'') {
q = c;
for (;;) {
c = next();
... |
d4e786d9-808d-451f-a6ca-363f0b231bed | 6 | public boolean isPrime(long number){
int counter = 0;
long factor = 0;
boolean isPrime = true;
if (number==2){
return true;
} else if (number%2 == 0){
return false;
}
while(isPrime && factor <= number/2){
if (counter < primeCounter){
counter = counter + 1;
factor = Prime[counter];
... |
241bc02c-c2ac-4a8b-a2d5-7d80e4e7f73f | 3 | public void playNotesOnChannel(int index,
int [] notes,
int [] durations,
int [] intensities)
{
// set the channel based on the index
channel = channels[index];
// loop through the array of notes
... |
1f543273-8974-4afa-b448-b479d07594e1 | 7 | public String[] Myself(boolean place)
{
try{
driver.get(baseUrl + "/content/lto/2013.html");
//global landing page
driver.findElement(By.xpath("/html/body/div[2]/div/div/div/div/div/div/div[3]/ul/li[3]/a")).click();
//Hong Kong landing page - Order Now button
driver.findElement(By.xpath("/h... |
bede6dc6-5d96-4cfe-97f3-6fd59b10e09e | 5 | public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String line = "";
StringBuilder out = new StringBuilder();
int t = 1;
while ((line = in.readLine()) != null && line.length() != 0) {
int[] ab = readInts(line);
if (ab[0] ... |
3d1a50cc-7cbb-4873-83c6-fddccd2f4ade | 5 | public static void main(String[] args) throws Exception {
int iterations = 1000000;
int mode = GREGORIAN_MODE;
long seed = 1345435247779935L;
if (args.length > 0) {
iterations = Integer.parseInt(args[0]);
if (args.length > 1) {
if (args[1].startsW... |
db1bef38-15e9-4358-bc80-39cde0435ee0 | 5 | public static void main(String args[]) {
Logger log = Logger.getLogger("MAIN");
Properties pt = new Properties();
pt.setProperty("connection.host", "127.0.0.1");
pt.setProperty("connection.port", "21");
pt.setProperty("user.login", "kurt");
pt.setProperty("user.password"... |
d92929fc-3ed9-41fa-a50d-46d2b3528eb4 | 9 | @Override
public boolean equals(Object other) {
if (other == this) { return true; }
else if (!(other instanceof WildcardTypeDesc)) { return false; }
WildcardTypeDesc type = (WildcardTypeDesc) other;
return ((this.lowerBounds == null && type.lowerBounds == null) ||
(t... |
42f073e2-6316-4020-a684-abe0eeb2cd2b | 7 | @Override
public <N, T> T getFirstValue(TKey<N, T> key, Enum<?>... qualifiers) {
T result = null;
List<QualifiedValue<?>> values = fields.get(key);
if (values != null && values.size() > 0) {
for (QualifiedValue<?> value : values) {
if (checkQualifier(value, qualif... |
34c57845-d47f-442d-b501-596834d48614 | 2 | public boolean GetSearchIfSequenceUsingTheBus(int sequence)
{
for(int seq:this.sequence)
{
if (seq == sequence)
return true;
}
return false;
} |
5dcdf315-e964-4a50-9522-23a650ab0945 | 4 | private static int TakeInput(){
int num = -1;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while (true)
{
try {
num = Integer.parseInt(br.readLine());
if (num>=0 && num < B... |
aee8d851-19ce-410e-ac0f-e7ae4c1cddd0 | 3 | public void checkChars(String msg, String str, MutableString mut)
{
if (str.length() != mut.length())
{
fail(msg + " (strings have different lengths): " +
str.length() + " vs. " + mut.length());
} // if the lengths differ
for (int i = 0; i < str.length(); i++)
{
... |
ccbea682-c4af-4e8f-94b4-30d87d99e2ba | 1 | private boolean jj_2_29(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_29(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(28, xla); }
} |
53cd8e7a-7895-4f2d-b95a-f1f17787fd24 | 7 | public Binomial union(Binomial k1, Binomial k2) {
Binomial k = new Binomial();
//valitaan juuri mergen avulla
k.root = merge(k1, k2);
if (k.root == null) {
return k;
}
Binomialnode previous = null;
Binomialnode current = k.root;
Binomialnode ne... |
87f513ca-56a8-4ab3-a0dc-d5e985f4459f | 6 | 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... |
a60796cc-d53a-47cd-a49e-d66267a41d7b | 5 | private boolean allowedNetwork() throws SocketException {
boolean allowed = false;
Enumeration e = NetworkInterface.getNetworkInterfaces();
while (e.hasMoreElements()) {
NetworkInterface ni = (NetworkInterface) e.nextElement();
Enumeration e2 = ni.getInetAddresses();
... |
0300013b-21cd-4b2c-a40e-f7c6e6a6fdab | 2 | public void deleteRefereeClassFromList(RefereeClass r)
{
// set relevant position in refereeClassArray to null
refereeClassArray[getPositionInRefereeClassArray(r.getRefereeName())] = null;
// decrement number of elements in the array
elementsInArray--;
// create a new array of non-null values and
// ... |
13f8dfb9-47f7-4af5-9efb-930ba65fb1f8 | 3 | private final String formatAmount(final Object amountObject) {
final DecimalFormat df =
new DecimalFormat( "#,###,###,###,###,###,###,###,##0.00" );
if (amountObject instanceof String) {
if (!((String) amountObject).matches(NUMBERS)) {
return "0.00";
... |
dab7f0a7-15e2-4db8-9420-4fedbf4236a2 | 6 | private void copyRGBtoABGR(ByteBuffer buffer, byte[] curLine) {
if(transPixel != null) {
byte tr = transPixel[1];
byte tg = transPixel[3];
byte tb = transPixel[5];
for(int i=1,n=curLine.length ; i<n ; i+=3) {
byte r = curLine[i];
by... |
002fbb6d-a30e-4ddc-b2d0-e73adef9994b | 6 | @Override
public void run() {
if (Updater.this.url != null) {
// Obtain the results of the project's file feed
if (Updater.this.read()) {
if (Updater.this.versionCheck(Updater.this.versionName)) {
if ((Updater.this.ver... |
9b60c2d0-c635-4312-9adf-bff38f8f8e8c | 5 | synchronized void backward(float[] in, float[] out) {
if (_x.length < n / 2) {
_x = new float[n / 2];
}
if (_w.length < n / 2) {
_w = new float[n / 2];
}
float[] x = _x;
float[] w = _w;
int n2 = n >>> 1;
int n4 = n >>> 2;
in... |
30aac3ee-a78e-4157-a4e8-d8f0b84014cc | 9 | public void printWriter(String tomorrowDate) //laver en liste over check-ins
{
Connection conn = null;
Statement stmt = null;
try{
//Registrer JDBC driver
Class.forName("oracle.jdbc.driver.OracleDriver");
//Åben forbindelsen
conn = DriverManag... |
f8694450-1093-4985-a2b7-2de32c2ac35b | 2 | @Override
public void init(){
for (GameObject go:Engine.getScreen().getRoot().getChildren()){
if (go.hasComponent("level")){
level = (Level)go.getComponent("level");
}
}
sy = parent.getScale().getY();
sx = parent.getScale().getX();
} |
aa376616-29e7-4aa7-8643-3e8d8a21aed1 | 5 | public void runRecv(){
DataInputStream inputStream;
try {
inputStream = new DataInputStream(socket.getInputStream());
} catch (IOException e) {
LOG.severe("Could not get inputstream! " + e.getMessage());
return;
}
while(!Thread.interrupted()){
... |
2da2022c-7c91-4504-a4ca-e44589255e75 | 0 | public List<Integer> getIntellingentMovementHistory() {
return intellingentMovementHistory;
} |
9d9cd539-3776-40ca-b10e-f1d5d360fbf6 | 8 | public void tick() {
inputTick(input);
if (pressedTimer > 0) pressedTimer--;
int xm = 0;
if (input.up) xm--;
else if (input.down) xm++;
if (xm != 0) moveSelection(xm);
if (input.enter && pressedTimer <= 0) {
pressedTimer = 30;
int state = getCurStateID();
press();
if (getCurStateID() != state)... |
87142648-c275-4650-aed5-c24f0bcc23a6 | 4 | public static javax.net.ServerSocketFactory getServerSocketFactory()
throws IOException {
if (isSslEnabled()) {
if (sslFactory == null) {
try {
sslFactory = BogusSslContextFactory.getInstance(true)
.getServerSocketFactory();... |
3e2a2537-8335-4c74-87bb-91652005aeb1 | 3 | private int handleD(String value,
DoubleMetaphoneResult result,
int index) {
if (contains(value, index, 2, "DG")) {
//-- "Edge" --//
if (contains(value, index + 2, 1, "I", "E", "Y")) {
result.append('J');
i... |
ae5c7f03-04bb-4ae2-bad0-0d7ed594ec90 | 1 | public int patientsLengthIteratively() {
int patientsCounter = 1;
while (nextPatient != null) {
patientsCounter++;
nextPatient = nextPatient.nextPatient;
}
return patientsCounter;
} |
5e7bb441-cd6b-44f8-9876-06c40e52ed3d | 4 | public void processCollision(int weapon, int enemy, char type){
switch (type) {
case 'c': { // cannon hits enemy ship
updateScore('c');
cannons.remove(weapon);
sinkingShips.add(initials.get(enemy));
initials.remove(enemy);
... |
09c4c2f0-6e31-4631-94cb-e6f3905f39c3 | 3 | public void removePath(Byte A, Byte B) {
if(networkTreeMap.containsKey(A)) {
networkTreeMap.get(A).remove(B);
}
if(networkTreeMap.containsKey(B)) {
networkTreeMap.get(B).remove(A);
}
if(autoUpdate) {
update();
}
} |
9d28e761-8958-4237-8cd4-7ae3e71082c2 | 4 | private static <T extends Comparable<? super T>> void insertionSort(
T[] a, int left, int right) {
for (int p = left + 1; p <= right; p++) {
T tmp = a[p];
int j;
for (j = p; j > left && tmp.compareTo(a[j - 1]) < 0; j--)
a[j] = a[j - 1];
a[j] = tmp;
}
} |
e9a37868-ae9c-4895-bd21-4bac2104b591 | 5 | public void joinRoom(String message, String currentname, Socket socket){
room = message.substring(6);
if(roomlist.containsKey(room)){
roomnum = Integer.parseInt((roomlist.get(room)).toString());
//Checks if a user is in the room already
if((rooms.get(roomnum-1)).containsKey(currentname)){
try{
... |
1dbede9f-c0c8-49b4-bcf5-17f3df224fe6 | 5 | public int[][] getDijkstraRoutedArray() {
int[][] daRgb = rgb;
int i = this.destI_pos;
int j = this.destJ_pos;
double cost = 0;
if (graph[i][j].getPath() != null) {
cost = graph[i][j].getDistanceFromStartPoint();
while (graph[i][j].getPath() != null) {
... |
fee4b06f-ba81-496b-a917-baa83af9224d | 4 | @Override
public boolean blocked(PathFindingContext context, int x, int y) {
if(x < 0 || y < 0 || x >= width || y >= height){
return true;
}
return tiles[x][y].isSolid();
} |
c0ee2774-5545-4efa-8946-a0778f08b6bf | 2 | public static LabFactory getInstance()
{
INSTANCE_LOCK.readLock().lock();
if (INSTANCE == null)
{
INSTANCE_LOCK.readLock().unlock();
INSTANCE_LOCK.writeLock().lock();
try
{
if (INSTANCE == null)
{
INSTANCE = createInstance();
}
}
finally
{
INSTANCE_LOCK.writeLock().unlock();
}
... |
51de8922-2d8b-42a2-9c70-57d52bd06250 | 3 | @Before
public void setUp() {
calendarUsers = new CalendarUser[3];
events = new Event[3];
//기존 등록된 유저 삭제
this.calendarUserDao.deleteAll();
//기존 등록된 이벤트 삭제
this.eventDao.deleteAll();
//디폴트 유저 등록
CalendarUser setupCreateUser1 = new CalendarUser("user1@example.com","user1","User1");
CalendarUser... |
9dc0d3d1-38e3-46d1-a620-6ba04a901327 | 6 | public void testReadMultithreadedWrite() throws IOException, InterruptedException {
final int numThreads = 16;
final int insertsPerThread = 256;
final int numEntries = numThreads*insertsPerThread;
final ByteChunk[] keys = new ByteChunk[numEntries];
final ByteChunk[] values = new ByteChunk[numEntries];
... |
1488f291-6efc-49ea-aac2-7f3c6737a2ea | 0 | public ClientListUI(ClientListSelectorReceiver callback)
{
setDefaultCloseOperation(EXIT_ON_CLOSE);
this.callback = callback;
setLayout(new GridLayout(0,1));
clientList.setLayout(new GridLayout(0,1));
clientList.setVisible(true);
add(clientList);
JButton selectButton = new JButton("Select");
sele... |
865b6598-2a7c-43c5-9c82-5e73d0bd322c | 2 | public void testPropertySetSecond() {
LocalTime test = new LocalTime(10, 20, 30, 40);
LocalTime copy = test.secondOfMinute().setCopy(12);
check(test, 10, 20, 30, 40);
check(copy, 10, 20, 12, 40);
try {
test.secondOfMinute().setCopy(60);
fail();
... |
9361bc42-fe86-43fc-bf4d-b1c6b44b0969 | 5 | private int solveStack(int nextRank) throws InvalidEquationException {
//Create variables for the current section of equation
NumericalExpression e2 = null;
NumericalExpression e1 = null;
OperatorExpression op = null;
try{
//Pop the first numerical expression off stack (rhs)
e2 = (NumericalExpression)e... |
6beedcf1-8013-4db7-86ee-2b174b14c2c8 | 6 | public void propertyChange(PropertyChangeEvent e) {
String name = e.getPropertyName();
// If they change the text area's font, we need to update cell
// heights to match the font's height.
if ("font".equals(name) ||
RSyntaxTextArea.SYNTAX_SCHEME_PROPERTY.equals(name)) {
for (int i=0; i<getCompone... |
d7511566-03b0-4296-9084-5aa51e590c54 | 7 | protected void selectPoint(double[] point) {
if (!isSet || (this.dim != 2 && this.dim != 3)) {
logger.info("Point was picked with no useable Fundamental Region.");
return;
}
logger.info("Selected Point (" + point[0] + "," + point[1] +
(this.dim == 3 ? "," + point[2] : "") + ")");
... |
9cb33269-ee55-49d2-9e23-4af1a2201c9e | 8 | public final void attrSplit(int attr, Instances inst) throws Exception {
int i;
int len;
int part;
int low = 0;
int high = inst.numInstances() - 1;
PairedStats full = new PairedStats(0.01);
PairedStats leftSubset = new PairedStats(0.01);
PairedStats rightSubset = new PairedStats(0.0... |
6a0e5bac-d673-4698-be05-d9b2fe176a5d | 7 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CurrencyInfo that = (CurrencyInfo) o;
if (code != null ? !code.equals(that.code) : that.code != null) return false;
if (rate != null ? !rate.eq... |
a3641e21-2e79-42c0-af30-1f982c8de708 | 4 | public void inverteOrientacao(){
if(orientacaoVetorEmLinha == 'c')
orientacaoVetorEmLinha = 'b';
else if(orientacaoVetorEmLinha == 'b')
orientacaoVetorEmLinha = 'c';
else if(orientacaoVetorEmLinha == 'd')
orientacaoVetorEmLinha = 'e';
else if(orientacaoVetorEmLinha == 'e')
orientacaoVetorEmLinha = '... |
eec8591c-99cf-4553-a6fa-9d6d098fa55a | 9 | private int[][] down() {//all numbers will down and combine when possible
int[][] egrid = clone2DArray(grid);
for (int xIndex = 0; xIndex < 4; xIndex++) {
for (int yIndex = 0; yIndex < 3; yIndex++) {
if (egrid[yIndex + 1][xIndex] == 0) {
for (int a = yInde... |
2bda0e9a-538b-43ba-8e6d-3625fc653067 | 3 | public Class<? extends Number> getReturnType(ObjectStack stack) throws NoSuchMethodException, SecurityException
{
Class<?> clazz = null;
if (methodName != null)
{
Method method = stack.getActualRepresentation().getRepresentedClass().getMethod(methodName);
String colname = NameGenerator.getColumnName(method... |
40507bd9-9131-4503-8dd4-8b9e03c302a6 | 3 | public String basicInfo()
{
String str = getName();
str += "\nMass (in kilograms): " + getMass() + " of maximum " + getMaxMass();
str += "\nVolume used (in litres): " + getVolume() + " of maximum " + getMaxVolume();
str += "\nContents:";
if(getContents() == null || get... |
bfaa92b3-9d72-4791-b0bb-dee5e898315b | 3 | private void live() throws Exception {
long start = System.currentTimeMillis();
FileWriter wr = new FileWriter(OUTPUT_FOLDER + "/model" + System.currentTimeMillis() + ".csv");
StringBuilder b = new StringBuilder();
b.append("#,");
// Print header
for (ConnectionDistributor d : distrib... |
465e4ce5-8ad4-49a5-97b4-53c6b0b18d84 | 5 | private synchronized JSONArray getLocations(String userKey) {
JSONArray locations = null;
if (userKey == null || userKey.isEmpty())
return locations;
try {
String url = this.urlManager.getUserInfo(Constants.APP_KEY, userKey);
JSONObject jo = getJson(Methods.... |
768b8721-c744-4027-aef1-bef57b1295dc | 3 | * if the queue is empty
*/
public E dequeue() throws EmptyQueueException {
if (this.isEmpty())
throw new EmptyQueueException();
else {
E temp = array.get(front);
if (front < array.size() - 1)
front++;
else {
front = 0;
}
if (front == rear) {
front = -1;
rear = 0;
... |
bac08b8a-2a0f-46c9-8388-3ac84ea38059 | 8 | public void splitNode(BallNode node, int numNodesCreated) throws Exception {
correctlyInitialized();
double maxDist = Double.NEGATIVE_INFINITY, dist = 0.0;
Instance furthest1=null, furthest2=null, pivot=node.getPivot(), temp;
double distList[] = new double[node.m_NumInstances];
for(int i=node.m... |
e742125a-0fbd-48a2-ad6b-bff06169d2cf | 5 | @Override
public boolean equals(Object note) {
if (note != null) {
if (this == note) {
return true;
} else if (note instanceof HindustaniNote){
if (this.octave == ((HindustaniNote)note).getOctave()
&& this.swar == ((HindustaniNote)note).getSwar()) {
return true;
}
}
}
return fals... |
6a2db650-9712-403f-94ba-0e9ff840f1f4 | 8 | public void paint(Graphics g){
this.setDoubleBuffered(true);
Insets in = getInsets();
g.translate(in.left, in.top);
//int[][] gameboard = logic.getGameBoard();
int cols = gameBoard.length;
int rows = gameBoard[0].length;
for (int c = 0; c < cols; c++){
for (int r = 0; r < rows... |
c477de5a-011b-4181-aa4c-d990c5ec2bf2 | 3 | public String renameFolder() {
if (selectedFolder == null) {
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error",
"You have not selected a folder for renaming"));
return null;
}
FolderDTO folder = (FolderDTO) selectedFolder.getData();
if (... |
e2b35c88-f4ac-4e2b-9418-4f4bd84b3109 | 3 | private void stopUpdate() {
if(periodicAddonUpdate != null && !stopwatchRunning && timers.size() == 0)
stopPeriodicUpdate();
} |
8764cb0e-d760-472c-be37-aa8fd9fbc757 | 4 | public static long prochainPremier(long num) {
if (num <= 1) throw new IllegalArgumentException();
if (num != 2 && num % 2 == 0) {
num++;
}
while (!Num1.estPremier(num)) {
num += 2;
}
return num;
} |
e8a813da-18f6-494a-894a-8bb02eaa7569 | 6 | public static void main(String[] args) {
// Create an inventory of Widgets
List<Widget> widgetList = new LinkedList<Widget>();
widgetList.add( new Widget( "Widget 1", "The first kind of widget") );
widgetList.add( new Widget( "Widget 2", "The second kind of widget") );
widgetList.add( new Widge... |
8927cbcc-5551-478e-b4db-ae7868db8d43 | 3 | public Square[][] kinging(Square[][] theBoard)
{
for (int x = 0; x < 8; x++)// kinging.
{
if (theBoard[x][7].getPiece() == '@')
{
theBoard[x][7].king();
} else if (theBoard[x][0].getPiece() == '$')
{
theBoard[x][0].king(... |
740b9566-3d8d-4b5f-8a2f-1eed14fcd119 | 2 | public Action poolCurrentAction() {
if(actions.isEmpty()) {
return null;
}
Action next = actions.poll();
if(loop) {
next.reset();
actions.add(next);
}
return next;
} |
462543b1-8f53-46d4-a088-f2cb940b7b43 | 1 | public boolean replaceSubBlock(StructuredBlock oldBlock,
StructuredBlock newBlock) {
if (catchBlock == oldBlock)
catchBlock = newBlock;
else
return false;
return true;
} |
8a77c516-33a4-4b24-b7f7-02a157e4d1a5 | 5 | public void run() {
while(model.GRAVITY) {
Point location = model.getRobotLocation();
boolean inTheAir = location.y < 175;
boolean aboveAHole = model.getHoles().contains(new Rectangle(location.x,
location.y + 25, 25, 25));
if(inTheAir || aboveAHole) {
if(model.canRobotMove(Direction.DOWN)) {
... |
6879726a-a5f4-449d-a346-ca092f9cb040 | 4 | public int verschilInDagen(DatumGregCal d) {
int MILLIS_IN_DAY = 1000 * 60 * 60 * 24;
DatumGregCal startDate;
DatumGregCal endDate;
if (this.kleinerDan(d)) {
startDate = d;
endDate = this;
}else {
startDate = this;
endDate = d;
}
long endInstant = endDate.getCalender().getTim... |
3a13c021-3d0c-452c-aacb-d099270b9f30 | 0 | @Before
public void setUp() throws Exception {
System.out.println("start");
getDriver().get("http://www.google.com");
} |
7bf96f39-6861-4916-83f3-a8fe37f6672b | 1 | public String getDescription() {
String desc = getLabel();
if (desc.length() == 0)
return Universe.curProfile.getEmptyString(); // I am a badass.
return getLabel();
} |
1544e2d6-1287-4d19-a9dc-1ec3913e9364 | 5 | public static InputMode abilityInputMode(AbilityType type) {
if (type == null) {
return null;
}
switch (type) {
case abil_aim_fire:
return AIM;
case abil_tar_heal:
return TARGET;
case abil_dir_cleave:
... |
fc432957-1798-47d1-a9ec-b2ca44c1591c | 8 | public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine();
int n = s.length();
int[] p = new int[n+1];
p[0] = -1;
int k = -1;
for(int i=1; i<=n; i++) {
w... |
157a37ac-cbb7-48b5-9001-7dbad887a977 | 6 | @Override
public void update(){
if(getLives() <= 0){
dead = true;
this.fire.dead = true;
}
if(newBorn){
--counter;
}
if(counter == 0){
newBorn = false;
counter = Constants.INVINSIBLE;
}
action = control.action(game);
if(action.thrust == 1){
thrusting = true;
showFire();
... |
aaea4627-07f9-4536-8057-2a12bb6bdc4f | 5 | protected void showSelectedHotel(SessionRequestContent request) {
String selected = request.getParameter(JSP_SELECT_ID);
Hotel currHotel = null;
if (selected != null) {
Integer idHotel = Integer.decode(selected);
if (idHotel != null) {
List<Hotel> list = (... |
867ff2be-da41-46e4-be1a-e985120d5567 | 3 | public boolean validarIngresoFecha(String fecha) {
if (fecha == null)
return false;
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
if (fecha.trim().length() != dateFormat.toPattern().length())
return false;
dateFormat.setLenient(false);
try {
dateF... |
6dd53dd7-696f-4a33-aeaa-0ce14f1fdd91 | 7 | public void compFinalResult() {
do {
iStage++;
compAllocation();
if (compDistribution()) {
/* deadline can not be satisfied */
if (!bDeadline) {
System.out.println("CostMinmin: THE DEADLINE CAN NOT BE SATISFIED!");
return;
} else {
System.out.println("\nNEW ROUND WITHOUT CHECKING:... |
1416de3a-cf4f-49a6-8aea-7a839a8b178b | 8 | public void renderRaisedSprite(int xp, int yp, Sprite s) {
int w = s.W;
int h = s.H;
xp -= xOffs;
yp -= yOffs;
int[] iso = twoDToIso(xp, yp);
xp = iso[0];
yp = iso[1];
for (int y = 0; y < h; y++) {
int ya = y + yp - h; // absolute position
... |
881e8389-2690-4cd0-ab60-1ec7f42d1244 | 8 | private static List<ImageFileProvider> unzip (final File droppedFile) {
try {
final List<ImageFileProvider> providers = new ArrayList<ImageFileProvider> ();
Enumeration<? extends ZipEntry> entries = new ZipFile (droppedFile).entries ();
for (int i = 1; entries.ha... |
9746293f-3cff-44a0-95a2-614fb9928596 | 6 | private void invariant() throws InvalidFrageException
{
InvalidFrageException e = new InvalidFrageException(this);
if (getFragestellung() == null || getFragestellung().isEmpty())
e.addInvalidField("fragestellung");
if (getModul() == null)
e.addInvalidField("modul");
if (getSchwierigkeitsgrad() == null... |
9e0c807f-4f31-4a57-9ba7-c07a695ca52b | 3 | @Override
public Event next() {
String input = null;
try {
input = br.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(input == null || input.equals("")){
return null;
}
else{
return new UserHomeState(as, input);
}
} |
cd07e0fd-d44a-4932-aef7-303885689265 | 7 | Levels()
{
Properties props = System.getProperties();
for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements(); )
{
String propName = (String) e.nextElement();
if (propName.startsWith(LEVEL_PREFIX))
{
String levelKey = (propNa... |
69dccd42-e5a6-4a30-9153-a77a33bde8d2 | 6 | public void generateMipMaps(ByteBuffer data, int width, int height, boolean test) {
ByteBuffer mipData = data;
for (int level = test ? 0 : 1; level <= 4; level++) {
int parWidth = width >> level - 1;
int mipWidth = width >> level;
int mipHeight = height >> level;
... |
f5d18854-6460-40a2-96e6-df7a4bd1d6c2 | 0 | public static void main(String[] args) {
System.out.println(1.0 + 2.0); // 3.0
System.out.println(2.0 - 3.0); // -1.0
System.out.println(3.0 * 4.0); // 12.0
System.out.println(16.0 / 5.0); // 3.2
System.out.println(16.0 % 5.0); // 1.0
} |
8d9b507f-d4d3-4f16-8378-95581e59dc7c | 8 | @Override
protected boolean wrappedHandle(Request r, Template t) {
t.putVariable("title", "Profile");
File[] possibles = Profile.getInstance().getPossibleProfiles();
if (r.getGetVars().isSet("i")) {
// select the profile
int i = -1;
try {
i = Integer.parseInt( r.getGetVars().getValue("i") );
... |
823b14ea-ad36-40b1-89f3-b2206b2bdd4f | 7 | public int _offsetToX(int line, int offset)
{
TokenMarker tokenMarker = getTokenMarker();
/* Use painter's cached info for speed */
FontMetrics fm = painter.getFontMetrics();
getLineText(line,lineSegment);
int segmentOffset = lineSegment.offset;
int x = horizontalOffset;
/* If syntax coloring is disa... |
266f5385-8d63-48eb-916b-b37f6f69e4b7 | 5 | private void determineRemainingTransition() {
myTransitionsMap=new HashMap <Integer, ArrayList <String>>();
myNeededTransitionMap=new HashMap <Integer, ArrayList <String>>();
myReadSets=new TreeSet <String>();
myStateMap=new HashMap <Integer, State>();
State[] s=automaton.getStates();
for (int i=0; i<s.leng... |
a58386d7-dcbb-4b70-83c5-a1701a570e0e | 5 | public static void main (String args[]) {
Neo4jAdapter adapter = new Neo4jAdapter();
adapter.connect();
adapter.insert();
adapter.queryParams();
if (args.length > 0) {
String s = args[0];
switch (Integer.valueOf(s)) {
case 1:
adapter.doQ... |
35b7716d-2747-45c1-b128-1853b742cd15 | 5 | private void procesarLogIn(String id, String tipo, String message) {
final String nick = message.substring(0, message.lastIndexOf("|"));
final String uuid = message.substring(message.lastIndexOf("|") + 1);
switch (tipo) {
case "c":
String idServer = getServerIdByNick(... |
444ebf47-39f3-4890-b634-d7f2dae8fba0 | 4 | public List<Recording> alignWithDB(List<Recording> recordings){
Recording returnrec = null;
for(Iterator<Recording> it = recordings.iterator(); it.hasNext(); ){
Recording recording = it.next();
returnrec = this.find(recording.getId(), recording.getType());
if(!returnrec.isComplete()){
if(returnrec.g... |
ee6c3ee4-c8a4-43ff-955e-d4dd6742e9cb | 1 | public void addRet(int var) {
if (var < 0x100) {
addOpcode(RET);
add(var);
}
else {
addOpcode(WIDE);
addOpcode(RET);
addIndex(var);
}
} |
b99d8c8b-5bd2-4906-9769-2c42ceccfaff | 1 | public ArrayList<Integer> conversionASCII(String mot)
{
char[] tabchar = mot.toCharArray();
ArrayList<Integer> chaine = new ArrayList<Integer>();
for( int i=0 ; i < mot.length() ; i++)
{
chaine.add((int)tabchar[i]);
}
return chaine;
} |
364dc810-8698-49b5-a8a4-067ba4f032c6 | 3 | public static void main(String[] args){
//buy some item
buyItemTester(Constants.AKAVIRI_SWORD);
buyItemTester(Constants.ANGEL_BODY_ARMOR);
buyItemTester(Constants.ANGEL_HEAD_ARMOR);
// show storeage
ItemStorageInventory.create().showStorage();
// get an item from the list
//getItemTester(Consta... |
cde65878-928a-4d48-b193-6214500809d8 | 4 | static private String readDBFromSettingsFile() {
BufferedReader r = null;
try {
r = new BufferedReader(new FileReader("MICEsettings.ini"));
} catch (FileNotFoundException e) {
e.getMessage();
}
String res = null;
if (r != null) {
try {... |
5f305247-2507-47e2-8f0b-18c68110f7ac | 5 | public String getDefaultName() {
switch (((IntegerType) getHint()).possTypes) {
case IT_Z:
return "bool";
case IT_C:
return "c";
case IT_B:
case IT_S:
case IT_I:
return "i";
default:
throw new jode.AssertError(
"Local can't be of constant type!");
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.