method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
cca16778-819d-45a8-97f3-6f49d669e1ef | 4 | public static void CanBeDama(Casella pCasella){
//controlla se la casella non ha ancora una dama
if(pCasella.getDama().getColore().equals(Dama.Colori.NULL)){
//capisce su quale versante va fatta la dama
if(pCasella.getPedina().getColore().equals(Pedina.Colori.BIANCO)){
... |
2366fd21-b6bc-4f35-8d63-b4143e0bf6fc | 1 | @Override
public List<Integer> save(List<LinkDirectionCity> beans, GenericSaveQuery saveGeneric, Connection conn) throws DaoQueryException {
try {
return saveGeneric.sendQuery(SAVE_QUERY, conn, Params.fill(beans, (LinkDirectionCity bean) -> {
Object[] objects = new Object[2];
... |
9703cf4e-a497-4c0a-8b83-7a2c68dd10e1 | 9 | public ArrayList<Element> parse() throws HPPPlusException {
ArrayList<Parseable> parseList = (ArrayList<Parseable>) data.clone();
for (int i=0;i<handlers.size();i++) {
Element handler = handlers.get(i);
for (int j=0;j<parseList.size();j++) {
if (handler.isMatch(p... |
f631f1ba-3bc9-429d-9989-c105a3679c8c | 1 | private void menuConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuConnectActionPerformed
Globals.global_connection = new dbConn(Globals.FD_database);
this.setTitle(Globals.FD_database + " Connected=" +Globals.global_connection.get_connection_state());
combo_persons.r... |
34c02df5-40da-4c93-9021-b29d102564a9 | 3 | private int skip(int startIndex) {
// System.out.print("Skipping past index: ");
// System.out.println(startIndex);
int condition = -1; // not a valid condition (so we can tell
// later if
// something goes wrong)
try { // in case we throw an IndexOutOfBoundsException on
// eleme... |
90fd8788-a693-41bb-a22b-cb4aca70277c | 5 | public static void main(String[] args) {
double n;
int count = 1;
int maxN = 0;
int max = 0;
for (int i = 1; i < 1000000; i++) {
n = i;
count = 1;
while (n != 1) {
if (isEven(n)) {
n = n / 2;
} else {
n = (n * 3) + 1;
}
count++;
if (n == 1) {
break;
}
}... |
acd3312e-024b-4feb-84e3-b4f8a12f8bba | 5 | @Override
public int lastIndexOf( Object elem )
{
if( elem == null )
{
for( int i = size - 1; i >= 0; i-- )
{
if( elementData[i] == null )
{
return i;
}
}
}
else
{
for( int i = size - 1; i >= 0; i-- )
{
if( elem.equals( elementData[i] ) )
{
return i;
}
}
... |
7ff78450-f242-4650-9df6-13068a5a3207 | 4 | public static void directselectionsorting(int[] a ){
for (int i = 0; i < a.length; i++) {
int k = i;
for (int j = i+1; j < a.length; j++) {
if (a[k]>=a[j]) {
k = j;
}
}
if (k != i) {
int tmp;
tmp = a[i];
a[i] = a[k];
a[k] = tmp;
}
}
} |
f84a6b74-3f0e-40e7-9d24-6359100e5ed3 | 8 | private void persist(PersistAction persistAction, String successMessage) {
if (selected != null) {
this.setEmbeddableKeys();
try {
if (persistAction != PersistAction.DELETE) {
this.ejbFacade.edit(selected);
} else {
... |
b7807763-c752-4f9d-99e1-b7e08f9cb5a5 | 4 | private void btnProcesarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnProcesarActionPerformed
String ruta = tfArchivo.getText();
String origen = (String) selectOrigen.getSelectedItem();
String grupo = (String) selectGrupo.getSelectedItem();
//revision de que hay... |
7aa3865a-3406-41c8-8e62-b82f2d3e15ba | 1 | public void closeSocket() {
try {
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
} |
330a9450-07d3-44e1-ab84-c94571c667d6 | 9 | static void verifyDivergenceDirichletArgs(double[] xs, double[] ys) {
if (xs.length != ys.length) {
String msg = "Parameter arrays must be the same length."
+ " Found xs.length=" + xs.length
+ " ys.length=" + ys.length;
throw new IllegalArgumentException(m... |
11cd0862-f76b-4d1b-a3bc-dcf11e73a93d | 3 | private boolean followPath() {
if (pathing) {
if (path.size() == 0) {
return false;
}
if (pathindex == path.size() - 1) {//we finished the path
pathing = false;
return false;
}
parent.moveTo(path.get(pat... |
e0cc2c10-9631-4074-8ef3-4c47f05691be | 5 | public Indir<Resource> getres(final int id) {
synchronized (rescache) {
Indir<Resource> ret = rescache.get(id);
if (ret != null)
return (ret);
ret = new Indir<Resource>() {
public int resid = id;
Resource res;
p... |
0af46648-6423-4da5-bb60-b84bff6c16d4 | 6 | public void solveDFS(char[][] board, int r, int c){
if(r < 0 || r >= R || c >= C || c < 0) return;
if(board[r][c] == 'X') return;
if(visited[r][c]) return;
visited[r][c] = true;
solveDFS(board, r-1,c);
solveDFS(board, r+1,c);
solveDFS(board, r,c-1);
solve... |
c35208bd-9933-4b0f-bcb8-a5dfa83f08ab | 3 | public int priority()
{
for (int i = 0; i < priorities.length; i++)
{
for (char operator: priorities[i])
{
if (operator == value) return priorities.length - i;
}
}
return 0;
} |
2c7f1415-c6f5-4c80-8678-661ce11697e5 | 0 | public final long getMessageDelay() {
return _messageDelay;
} |
a041e9ed-8060-48be-b133-11a39ca13678 | 6 | public void promoteNameToValue() throws IOException {
expect(JsonToken.NAME);
Iterator<?> i = (Iterator<?>) peekStack();
Map.Entry<?, ?> entry = (Map.Entry<?, ?>) i.next();
stack.add(entry.getValue());
stack.add(new JsonPrimitive((String)entry.getKey()));
} |
63ee7342-9f62-4d43-bbac-799ea34d25e1 | 5 | public boolean tjekPeriode(int periodeFra, int periodeTil) throws MonthException {
if (periodeFra < 1 || periodeFra > 12 || periodeTil < 1 || periodeTil > 12) {
throw new MonthException();
} else {
if (periodeFra > periodeTil) {
throw new MonthException();
... |
5f0ede85-8eef-4707-a66f-4c80810a92da | 4 | public static void main(String[] args) {
while (true) {
try {
// Post-increment is zero first time:
if (count++ == 0)
throw new ThreeException();
System.out.println("No exception");
} catch (ThreeException e) {
System.out.println("ThreeException");
} finally {
System.out.println("In ... |
481c1b92-3e93-425c-9e91-e38035c2a0e7 | 7 | public void crawler() //抓取微博
{
init();
Date lastestDate = lastTime;
String urlsuffix = '/' + uid;
for(;;)
{
try {
Document page = PageFetcher.getPage(cookies, baseUrl + urlsuffix); //获取页面
List<Weibo> weibos = PageResolver.resolveUserPage(page, uid, screenName); //分析页面,得到微博
if(weibos.i... |
da4b467d-52bd-4615-a1d0-a7c5629e37b2 | 5 | protected void recursiveBalance(TreeNode currentNode) {
setBalance(currentNode);
int balance = currentNode.balance;
if (balance == -2) {
if (height(currentNode.left.left) >= height(currentNode.left.right)) {
currentNode = rotateRight(currentNode);
} else {
currentNode = doubleRotateLeftRight(curre... |
bb353428-02d7-46c1-ae54-0f2d71a28acc | 3 | public ImageBean getImage(int idimage){
ImageBean imageBean = null;
try {
PreparedStatement statement = connection.prepareStatement(GET_IMAGE_BY_ID);
statement.setString(1, new Integer(idimage).toString());
ResultSet resultSet = statement.executeQuery();
if(resultSet.next() == false) return nu... |
842abc27-df4f-41e0-93ab-b79810fad93d | 5 | public void calculateNextGeneration() {
System.out.println(population.size());
//// Prepare
calculateCumulativeFitness();
//// Reproduce species
int speciesToReproduce = (int)(REPRODUCTION_RATE * POPULATION_SIZE);
speciesToRepr... |
cd3835c4-5b13-4a72-a02a-a3e7b6ff3c6b | 9 | public int func_50024_a(int par1, int par2)
{
int var3 = par2;
boolean var4 = par1 < 0;
int var5 = Math.abs(par1);
for (int var6 = 0; var6 < var5; ++var6)
{
if (var4)
{
while (var3 > 0 && this.text.charAt(var3 - 1) == 32)
... |
7507e279-4b0e-414b-9aec-02a977897608 | 0 | public EsteenTyyppi getTyyppi() {
return tyyppi;
} |
ff725cb3-0f27-4a0e-b45e-0e51535a0780 | 1 | public String Apagar(){
String r = "";
if(dao.Apagar(entidade)){
r = "listagemFuncao.xhtml";
return r;
}
else{
return r;
}
} |
317ca9be-d8fb-48ea-adc6-a6777a4ca558 | 3 | public boolean canImport(TransferSupport support) {
if (!support.isDrop()) { //only supports drops, change this
return false;
}
if (!support.isDataFlavorSupported(new DataFlavor(Card.class, "Card")) &&
!support.isDataFlavorSupported(localObjectFlavor)) {
return false; //only import Card and Integer obje... |
24cabb17-d263-45a7-b0c9-7b0f6c27ef80 | 2 | @Transient
public static boolean isValidServerTypeClassName(String className){
Object object = null;
try{
object = Class.forName(className).newInstance();
}catch(Exception e){
return false;
}
if(object instanceof Model)
return true;
return false;
... |
dc63186a-60e8-42d3-aeab-60b590ba52ef | 5 | final void method1227(byte i, int i_61_, int i_62_, ItemLoader class255) {
try {
if (i == 42) {
anInt2099++;
if (i_62_ == -1)
anIntArray2092[i_61_] = 0;
else if (class255.getItemDefinition(-125, i_62_) != null) {
anIntArray2092[i_61_]
= Class273.bitOr(1073741824, i_62_);
method1234(-100... |
4a2af113-5a0b-49a5-93a8-3efc88884ff0 | 4 | public void removeUnreachable() {
if ((preOrder == null) || (edgeModCount != preOrder.edgeModCount)) {
buildLists();
}
final Iterator iter = nodes.entrySet().iterator();
while (iter.hasNext()) {
final Map.Entry e = (Map.Entry) iter.next();
final GraphNode v = (GraphNode) e.getValue();
if (v.preO... |
29fd70ea-a589-404e-8276-d2770a4f7558 | 4 | protected boolean on_board(int [] move, int i){
if (x + move[0] * i > -1 && x + move[0] * i < 8) {
if (y + move[1] * i > -1 && y + move[1] * i < 8) {
return true;
}
}
return false;
} |
e478449f-a3f2-46a2-a112-ef195810b593 | 7 | @Override
public void writeBytes(byte[] b, int offset, int length) throws IOException {
int bytesLeft = BUFFER_SIZE - bufferPosition;
// is there enough space in the buffer?
if (bytesLeft >= length) {
// we add the data to the end of the buffer
System.arraycopy(b, offset, buffer, bufferPositio... |
40336fd1-c445-4753-b8fc-7e71fa73ff8c | 5 | public Wave44(){
super();
MobBuilder m = super.mobBuilder;
for(int i = 0; i < 3000; i++){
if(i % 8 == 0)
add(m.buildMob(MobID.ONIX));
else if(i % 7 == 0)
add(m.buildMob(MobID.MACHOP));
else if(i % 6 == 0)
add(m.buildMob(MobID.GRAVELER));
else if(i % 5 == 0)
add(m.buildMob(MobID.MAROWAK... |
263a68d0-101a-48f3-99e3-5b04493fe604 | 2 | public boolean canSubmit() {
if (System.currentTimeMillis() > timeStart
&& System.currentTimeMillis() < timeEnd)
return true;
else
return false;
} |
7d87829d-0732-4d16-b90d-4b942aec8a29 | 5 | protected static Ptg calcAtanh( Ptg[] operands )
{
if( operands.length != 1 )
{
return PtgCalculator.getNAError();
}
double dd = 0.0;
try
{
dd = operands[0].getDoubleVal();
}
catch( NumberFormatException e )
{
return PtgCalculator.getValueError();
}
if( (dd > 1) || (dd < -1) )
{
ret... |
5ec09c9c-45ed-443a-9c9d-c01c3cb4de4d | 0 | @Test
public void testNum2wordWithZeroOrOne() {
assertTrue(_phonewordFinder.num2words("3569370").size() > 0);
assertTrue(_phonewordFinder.num2words("3569371").size() > 0);
assertTrue(_phonewordFinder.num2words("03569371").size() > 0);
} |
8d4562a8-e20d-4378-9cb8-848e66b66a19 | 8 | public String simplifyPath(String path) {
Stack<String> S = new Stack<>();
String[] pathArray = path.split("/");
for (int i = 0; i < pathArray.length; i++) {
if (!S.isEmpty() && pathArray[i].equals(".."))
S.pop();
else if (pathArray[i].length() == 0 || pat... |
101b18c1-77a2-4781-b1aa-39cc4e409f40 | 8 | private static void findIncSubSeq(int[] arr) {
int oldStart = 0, oldSum = 0, sum = 0, start = 0;
start = arr[0];
sum += start;
for(int i = 1; i < arr.length; i++)
{
if(arr[i-1] == arr[i] -1)
{
sum += arr[i];
}
else
{
if(sum > oldSum)
... |
6d3215d9-63ef-4319-8ee1-f0799e01149c | 4 | private boolean validTargetNotParent(Sprite s){
boolean returnVal = true;
if(s instanceof Ship){
Ship ship = (Ship)s;
if(parent == ship) returnVal = false;
}else if(s instanceof Turret){
Turret turret = (Turret)s;
if(parent == turret.parent) returnVal = false;
}else{
//expand validtarget here
}... |
0a6e2334-754a-4f28-8818-b10e8588bb80 | 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 Grade)) {
return false;
}
Grade other = (Grade) object;
if ((this.id == null && other.id != null) || (this.id !... |
ae4d27e8-68ac-4edc-b3a1-23773eccd58a | 3 | public void putBit(int bit) throws IOException {
if (!(bit == 0 || bit == 1)) {
throw new IllegalArgumentException("argument must be 0 or 1");
}
// If the buffer has eight bits, need to flush it first.
if (numBits == 8) {
flushBits();
}
// Add th... |
290a70ff-b4f6-4862-be4b-b4aede3820d2 | 2 | public Rectangle getCurrentFrameRect() {
int x = 0, y = 0;
if (frameSize.height > 0 && frameSize.width > 0) {
y = ((int) currentFrame / fpl) * (frameSize.height + borderWidth);
x = ((int) currentFrame % fpl) * (frameSize.width + borderWidth);
}
return new Rectan... |
48faa2ce-848e-4a34-a660-84ac2a608c81 | 5 | private boolean gebaeudeZerstoeren()
{
boolean erfolg = false;
int angreifererfolg = ermittleAngreiferErfolg();
if ( angreifererfolg == 0 )
{
erfolg = false;
}
else if ( angreifererfolg > 0 )
{
ArrayList<Land> laendereien = this.opfer.getLandListe();
int i = 0;
while ( i < laendereien.size... |
237d1912-6ab1-4a72-a145-f33188998e19 | 5 | public void edit(Feed feed) throws NonexistentEntityException, Exception {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
feed = em.merge(feed);
em.getTransaction().commit();
} catch (Exception ex) {
... |
7de4b480-66ab-4ed5-b7da-39993b2bdcc4 | 5 | public static boolean isNumber(CharSequence s) {
boolean ret = true;
for (int i = 0; ret && i < s.length(); i++) {
Character c = s.charAt(i);
if (i == 0 && c == '-') continue;
if (!Character.isDigit(c)) ret = false;
}
return ret;
} |
9f9ae470-059d-4bcd-97c9-80ff1548966a | 6 | public static final boolean containsWord(String container, String searchedWord, String seperatorChars) {
if (searchedWord == null)
return false;
int startIndex = container.indexOf(searchedWord);
if (startIndex == -1) {
return false;
}
if (startIndex == 0 || seperatorChars.indexOf(container.charAt(startI... |
38b72de8-735e-4f42-be41-dccb046a7ffa | 7 | public String cryptanalyseCle(IMessage clair, IMessage crypte) {
/*
* Mthode determinant d'abord la longueur de la cl, puis effectuant une cryptanalyse de
* type Cesar sur les "sous messages"
*/
try {
long d=new Date().getTime();
int l=this.longueurCleMin(clair, crypte,true);
String key="";
int... |
9b8a5f97-8f68-453e-b73e-eea30c5e3805 | 6 | public static void main(String [] args) throws SQLException
{
ConnectionHandler C = new ConnectionHandler();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String userType = "";
String userID = "";
String userPwd = "";
LoginHandler L;
System.out.println("Hello, are you a manag... |
f8a99b5b-2278-4b82-a904-5ed912a13d87 | 6 | boolean match(String s) {
// expect whitespace after token?
boolean alone = s.endsWith(" ");
s = s.trim();
if (!text.startsWith(s)) { return false; }
if (alone && text.length() > s.length()) {
char n = text.charAt(s.length());
if (n != '#' && !Character.isWhitespace(n)) { return false; }
}
for(char ... |
b6a8c778-33ae-4d46-84b2-049d9ff973ce | 7 | public int placeMeeple(Player player, int xBoard, int yBoard, int xTile,
int yTile) {
// Don't allow a player to play on a 'null' tiletype.
if (gameBoard[yBoard][xBoard] == null
|| gameBoard[yBoard][xBoard].getTileType(xTile, yTile) == null) {
return 1;
}
// First we need to check the correctness of... |
5cc90b76-64d8-4b1b-93be-07dca0552a69 | 6 | private final int method642(int i, short i_305_, int i_306_) {
int i_307_ = Class10.anIntArray179[method637(i, i_306_)];
TextureDefinition class12
= ((AbstractToolkit) aHa_Sub1_5353).aD4579.getTexture(i_305_ & 0xffff, -6662);
int i_308_ = ((TextureDefinition) class12).aByte201 & 0xff;
if (i_308_ != 0) {
i... |
56071f8c-66ef-46e8-ba56-161eec94b05c | 8 | public static void WeekEleven() throws IOException
{
System.out.println("So what did Damon learn this week?");
boolean next = false;
BufferedReader r = new BufferedReader (new InputStreamReader(System.in));
while (!next)
{
System.out.println("Knowledge: " + DamonStats.Knowledge);
System.out.prin... |
f76d547b-a413-404d-bc6f-0d4ab72caee5 | 5 | Client getClientByName(String name){
ArrayList < Client > tclients = new ArrayList < Client > ();
tclients.addAll(clients);
for (int i = 0; i < channels.size(); i++) {
ArrayList < Client > clients = channels.get(i).getUsers();
for (Client c: clients) {
if ... |
7adcb5fb-9017-4f6e-9ee1-ffb7614a903c | 7 | public int mostVisitedAction() {
int selected = -1;
double bestValue = -Double.MAX_VALUE;
boolean allEqual = true;
double first = -1;
for (int i=0; i<children.length; i++) {
if(children[i] != null)
{
if(first == -1)
fi... |
6fe51518-cdf9-48a4-ad94-22f179f8e7ee | 4 | @EventHandler
public void handleFishCatchings(PlayerFishEvent event) {
Player player = event.getPlayer();
User user = EdgeCoreAPI.userAPI().getUser(player.getName());
Entity caught = event.getCaught();
if (user != null && caught instanceof Fish) {
Cuboid cuboid = Cuboid.getCuboid(player.getLoca... |
9d73521b-8505-47fd-bca6-320c42fdc854 | 1 | public void printer(double number) {
if ((number - Math.floor(number)) == 0) {
text.setText(String.valueOf((int)number));
} else {
text.setText(String.valueOf(number));
}
} |
296fe7ef-9171-4ecb-bafc-8197de1c08b0 | 9 | @Override
public TokenStream tokenStream(String fieldName, Reader reader) {
// whitespace tokenizer
TokenStream result = new WhitespaceTokenizer(Version.LUCENE_36, reader);
// covert to lowercase
result = new LowerCaseFilter(Version.LUCENE_36, result);
// remove separators and strange characters
CharT... |
ada2101c-3279-4673-a06a-d3d4bfc247f3 | 6 | public void renderBlockFallingSand(Block block, World world, int i, int j, int k) {
float f = 0.5F;
float f1 = 1.0F;
float f2 = 0.8F;
float f3 = 0.6F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
float f4 = block.getBlockBright... |
698bc858-9608-4c6f-bc87-f17aaed43b25 | 3 | public Boolean actualizar_marca(String marca, String marcaNuevo) {
Boolean est = false;
List DNList = new cDN().leer_por_marca(marca);
Transaction trns = null;
sesion = HibernateUtil.getSessionFactory().openSession();
try {
trns = sesion.beginTransaction();
... |
c2cfa857-12d4-444a-bdbb-befe64edee5c | 5 | public static void main(String[] args) {
Scanner lea = new Scanner(System.in);
do{
System.out.println("Direccion: ");
String path = lea.next();
if(!path.equalsIgnoreCase("exit")){
System.out.println("Append? (s/n): ");
... |
5c5efe9d-eb83-44dd-b1aa-4c86c6f4259c | 8 | public static Insert prepareInsert(Object t, String keyspace, String table,String w_cl) {
Insert insert = QueryBuilder.insertInto(keyspace, table);
Class<?> c = t.getClass();
try {
for (Field f : c.getDeclaredFields()) {
f.setAccessible(true);
if (f.... |
caacefea-c093-4745-8910-ba650b487c7b | 8 | public void render(Screen screen){
if(dir==0){
if(walking){
animUp.setSpeed(50);
sprite=animUp.next();
}else {
sprite = Sprite.player_up;
animUp.resetAnim();
}
}
if(dir==1){
if(walking){
animRight.setSpeed(50);
sprite=animRight.next();
... |
1f86383e-a83f-4027-83d7-bbcfda16ce92 | 2 | public double[] standardizedPersonRanges(){
if(!this.dataPreprocessed)this.preprocessData();
if(!this.variancesCalculated)this.meansAndVariances();
return this.standardizedPersonRanges;
} |
c0b47a3f-fa30-4a82-9e0b-cd96913ecab1 | 9 | public void countOffSetPerCurrentDay(){
for(int i = 0; i < x_length; i++){
for(int j = 0; j < y_length; j++){
int coins_per_neighbout = this.state_for_day[i][j]/COINS_DISTRIBUTED_PER_NUM;
int take_away_from_current_cell = 0;
if(numb... |
b10f515f-4691-4423-b36f-1396ee423ac4 | 9 | int[] merge(int[] arr){
int min=arr[1]-arr[0];
int index=0;
for(int i=0;i<arr.length;i+=2){
if(arr[i+1]-arr[i]<min){
min=arr[i+1]-arr[i];
index=i;
}
if(i+3<arr.length && arr[i+2]>arr[i] && arr[i+3]>arr[i+1]){
if(... |
8f0a696d-76e3-4540-992d-0888fa214dbc | 6 | public void tileInit()
{
//Stringville
for(int i=0; i<50; i++)
tile[167+i][495]=WATER;
for(int i=0; i<50; i++)
tile[167+i][496]=WATER;
for(int i = 0; i < 500; i++)
{
for(int j = 0; j <500; j++)
{
tile[i][j] = LOW_GRASS;
}
}
// tile[30][30] = 1;
// tile[11][490] = 1;
// tile[14][4... |
8d28a908-ce56-49da-b1ca-aa2d921c174f | 6 | public void loadBoardConfig() throws BadConfigFormatException, FileNotFoundException {
// Create a file reader and wrap it in a scanner to read the file
FileReader boardConfigFile = new FileReader(boardConfigFilename);
Scanner fileScanner = new Scanner(boardConfigFile);
// Initialize variables
String[] cel... |
46f7b7ca-ff1e-4782-a61a-8f7923e38098 | 0 | public String toString() {
return "Point - X: " + x + " Y: " + y;
} |
d9e4aa6b-0b79-4d19-8679-9c1116cc4862 | 9 | public Node add_1(Node a, Node b){
Node resHead = null;
Node resTail = null;
int carry = 0;
while(a != null && b != null){
int value = a.value + b.value + carry;
Node n = new Node(value%10);
if(resHead == null){
resHead = n;
resTail = n;
}
else{
resTail.next = n;
... |
d125e87e-b426-48cb-bcf3-0419edb167a6 | 4 | public String getType(){
String returnString = "";
//supertype
if(!supertype.equals("")){
returnString = supertype + " ";
}
//types
for(int i = 0; i < type.size(); i++){
returnString += type.get(i) + " ";
}
//dash and subtypes
if(subtype.size() != 0){
returnString += "- ";
fo... |
b8289ead-2fd6-4a6e-b037-258353062f87 | 9 | public void testBindFunctions() throws Exception {
Bindings bindings = null;
bindings = parse("${ns:f0()}").bind(context.getFunctionMapper(), null);
assertSame(context.getFunctionMapper().resolveFunction("ns", "f0"), bindings.getFunction(0));
try { bindings.getFunction(1); fail(); } catch (Exception e) {}
... |
060c2b79-da32-4c84-8e2b-ada82dacef31 | 7 | @Override
@SuppressWarnings("deprecation")
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final DBRefBase dbRefBase = (DBRefBase) o;
if (_id != null ? !_id.equals(dbRefBase._id) : dbRefBase._id != n... |
535c11dd-596f-4dbb-90df-11f44adef5cc | 6 | public void update() {
if (chess.getTurn() % 2 == 0) {
turns.setText("Black turn");
} else {
turns.setText("White turn");
}
if (chess.getInfo() == 0) {
info.setText("");
}
if (chess.getInfo() == 1) {
... |
acc5f311-7f8e-4538-8c89-a1d2ff722817 | 8 | public Updater(Plugin plugin, int id, File file, UpdateType type, boolean announce) {
this.plugin = plugin;
this.type = type;
this.announce = announce;
this.file = file;
this.id = id;
this.updateFolder = plugin.getServer().getUpdateFolder();
final File pluginFile... |
38469093-ee31-4566-b758-53fb96f2bce7 | 6 | private static final int hexToInt(char c) throws ParseException {
if ('0' <= c && c <= '9') {
return c - '0';
} else if ('a' <= c && c <= 'f'){
return c - 'a' + 10;
} else if ('A' <= c && c <= 'F') {
return c - 'A' + 10;
} else {
throw new ParseException("None-hex character in un... |
80df60f6-d618-4df9-bbf9-b12029d8a2c7 | 0 | public int specialAttack3() {
return skill3.attack(this.getAgility(), this.getLuck());
} |
005f4413-17a6-4b15-a75b-9db0dd5549db | 2 | protected void loadFilters() {
filterArray = new BufferedImageOp[1];
short[] straight = new short[256];
short[] subtracted = new short[256];
for (int i = 0; i < 256; i++) {
straight[i] = (short)i;
if (i > 8) {
subtracted[i] = (short)(i - 8... |
6d18fb27-3e0d-4d31-bea9-398eef47f70e | 1 | private void checkEnd() {
if (end) {
throw new IllegalStateException("Cannot call a visit method after visitEnd has been called");
}
} |
b56c5ad0-65f9-4dd4-bf97-10fb45c6c174 | 7 | protected void load() throws MaltChainedException {
try {
final BufferedReader in = new BufferedReader(getGuide().getConfiguration().getConfigurationDir().getInputStreamReaderFromConfigFile(getModelName()+".dsm"));
final Pattern tabPattern = Pattern.compile("\t");
while(true) {
String line = in.readLine(... |
6f9c373a-d7cb-45ff-8ab8-5a990efd6453 | 9 | public boolean checkForObstruction(Location init, Location fin, Tile[][] obstructedBoard, Piece pieceToCheck)
{
//I'm thinking that I should take the locations, subtract the columns and rows from final and initial positions, then iterate over the differences
//Once I'm iterating over the differences, I check if th... |
28a40877-b26a-41a8-ab4e-36d19848c79e | 5 | public void loadFromReader(TSLReader reader) throws InvalidTSLException, IOException
{
clear();
if(reader.getState() != TSLReader.State.OBJECT)
{
throw new IllegalStateException("Current value is not a TSL Object");
}
while(true)
{
reader.moveNext();
switch(reader.getState(... |
28f8ea50-d059-46f8-99f0-8b3571ee0d18 | 2 | public Account findAccount(String accountName, String clientId) throws XStoreException{
Account account = null;
logger.info("accountName - " + accountName);
logger.info("clientId - " + clientId);
try {
TypedQuery<Account> qry = em.createQuery("select A from Account A where A.client.clientName=:clientId and A... |
a1ca4310-5b7c-44bd-9b62-71339e7b72fc | 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.versionLi... |
ced8df73-d36e-4e39-b505-37049c969c15 | 3 | public void paint(Graphics g) {
//Background
g.setColor(background);
g.fillRect(0, 0, Run.window.getWidth(), Run.window.getHeight());
//
//Title
g.setFont(titleFont);
g.setColor(Color.white);
g.drawString(pauseTitleText, 50, 50);
//
//Buttons
g.setFont(buttonFont);
if (!hoveringResume)... |
3cbe5119-ff38-48f5-ab48-7b61e876f08f | 7 | public void revertCheck(Player player){
Block playerBlock = player.getLocation().getBlock();
Iterator<Block> iterator = revertMap.get(player).iterator();
while(iterator.hasNext()){
Block nextBlock = iterator.next();
int xCheck = abs(nextBlock.getX()) - abs(playerBlock.get... |
42649a2c-0594-46d1-baee-d4f422c30363 | 5 | public static void runGame() {
GameController game = new GameController();
while (s2.team[0].isLebendig()) {
s1.team[0].attack(s2.team[0]);
//s2.team[0].attack(s1.team[0]);
for (int i = 0; i < s1.getAnzahl(); i++){
if (s1.team[i].isLebendig() == false){
s1.loesche(s1.team[i]);
}
}
... |
c3b9565d-25cc-4096-8613-a9cf236acf05 | 2 | protected Point getBlockSnap() {
if (currentlyPlacing != null) {
int x = (gameController.getCurrentMousePosition().x
+ gameController.getMapOffsetX())
/ BlockManager.getBlockWidth()
* BlockManager.getBlockWidth();
int y = (gameC... |
b2d148de-ae73-4074-bfd7-afa85e0f49ef | 8 | public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof PieDataset)) {
return false;
}
PieDataset that = (PieDataset) obj;
int count = getItemCount();
if (that.getItemCount() != count) {
return... |
19967319-59d4-41a2-9101-a40f46d5b2e6 | 6 | public synchronized void monter(Festivalier fest) {
// le festivalier est-il dans une navette?
boolean in = false;
// tant qu'il n'y a pas de navette, le festivalier s'endort.
// une fois reveille, il essaie de monter dans une navette.
while (nNavettes == 0 || !in) {
try {
wait();
} catch (Exception... |
4880d355-25dd-4325-bfce-5f8de54931b6 | 8 | public void dumbDecelerate(double amount) {
if(x == 0.0) {
//do nothing
} else if(x > 0.0) {
if (x - amount > 0.0) {
x = x - amount;
} else {
x = 0.0;
}
} else {
if (x + amount < 0.0) {
x = x + amount;
} else {
x = 0.0;
}
}
if (y == 0.0) {
//do nothing
} else if(y... |
adca76ba-e252-4575-bd63-73270ddf8cef | 7 | private void handleAndroidManifestFile(String apk, IManifestHandler handler) {
File apkF = new File(apk);
if (!apkF.exists())
throw new RuntimeException("file '" + apk + "' does not exist!");
boolean found = false;
try {
ZipFile archive = null;
try {
archive = new ZipFile(apkF);
Enumeration<?>... |
eb59c5d7-e771-4705-a06c-3b7604c2f3b8 | 6 | @Override
public String execute(SessionRequestContent request) throws ServletLogicException {
String page = ConfigurationManager.getProperty("path.page.editdirection");
resaveParamsSaveDirection(request);
try {
Criteria criteria = new Criteria();
Direction direction =... |
1f477997-6b66-4932-b1b5-3175bbbd2e35 | 6 | private static void organize(File dir) {
File all = new File(dir, "z_all");
if(!all.exists()){
all.mkdir();
}
for (File temp : dir.listFiles()) {
if (temp.isDirectory() && !temp.getName().equals("z_all")) {
int index = 0;
for (File file : temp.listFiles()) {
if (!file.isDirectory()) {
i... |
ae2626d8-2868-4885-9588-ba78ea450b3e | 7 | @Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == jbtReset){
enablerListener.enableSortButton(false);
resetRadioButtons();
resetDataFields();
// clear text fields on stats panel
controller.getStatsPanel().clearTextFields();
// Clear sort panel tex... |
96d4a22c-774a-4085-807f-8e8ab2b2fb76 | 5 | private void createDOMTree(){
Element rootEle = dom.createElement("table");
dom.appendChild(rootEle);
Element idsRoot = dom.createElement("vertexes");
rootEle.appendChild(idsRoot);
for (int i = 0; i < ids.size(); i++) {
Element vertex = dom.createEle... |
ec290c09-001e-4b0d-89f5-0cfed5a536e3 | 9 | @Override
public boolean tick(Tickable ticking, int tickID)
{
if(!super.tick(ticking, tickID))
return false;
if(affected instanceof SailingShip)
{
final SailingShip I=(SailingShip)affected;
if(I.subjectToWearAndTear())
{
final PhysicalAgent currentVictim = I.getCombatant();
if(currentVictim ... |
ed69222d-ec93-45a3-9a6a-4a9f7c58bd92 | 4 | private void copyArray(Object obj) {
if (obj instanceof ArrayList<?>) {
ArrayList<Value> value = new ArrayList<>();
@SuppressWarnings("unchecked")
ArrayList<Object> data = (ArrayList<Object>) obj;
for (Object o : data) {
value.add(new Value(o));
}
data_ = value;
} else {
ArrayList<Value> ... |
da3bba3f-9b67-4ad4-bd96-09a7690a0b9b | 0 | public void addGameListener(GameListener listener) {
listeners.add(listener);
} |
cbf0fd98-9aff-4bcc-a49e-b0d080226f67 | 1 | private static String fillString( String in, int len )
{
String out = new String(in);
while ( out.length() < len )
out = " " + out;
return(out);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.