method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
7a11d898-a169-474d-905c-3355746a2f0d | 6 | public Inventory(int size) {
ItemW = 8;
if (size == EXTRA_SMALL) {
ItemH = 1;
}
if (size == SMALL) {
ItemH = 4;
}
if (size == LARGE) {
ItemH = 8;
}
if (size == EXTRA_LARGE) {
ItemH = 8;
ItemW = 12;
}
w = ItemW * 8 * 8;
h = ItemH * 8 * 8;
x = (def.Frame.WIDTH / 2) - (w / 2);
y ... |
7dc88c0a-b008-4e53-90fa-8f02438f25ef | 6 | public void updateRender(Bitmap target, float delta){
target.Clear((byte) 0x00);
float halfWidth = target.getWidth() /2.0f;
float halfHeight = target.getHeight()/2.0f;
for(int i = 0; i < starX.length; i++){
starZ[i] -= delta * speed;
if(starZ[i]<=0)
InitStar(i);
int x = (int)((starX[... |
3a4374e9-09de-4a2c-9b64-0f5a35c95723 | 0 | protected final void setName(String name){
this.name = name;
} |
6cf50a0b-15b4-4a65-b043-63047737ce3b | 2 | @Override
public int compare(StdImage o1, StdImage o2) {
int result = Numbers.compare(o2.getWidth(), o1.getWidth());
if (result == 0) {
result = Numbers.compare(o2.getHeight(), o1.getHeight());
if (result == 0) {
result = Numbers.compare(o2.hashCode(), o1.hashCode());
}
}
return result;
} |
0593ac92-95b5-414a-bdfd-1c145b2a2ae6 | 4 | @Override
void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild)
{
// Replace child
if(this._condicao_ == oldChild)
{
setCondicao((PExpLogica) newChild);
return;
}
for(ListIterator<PComando> i = thi... |
35a629ae-bb8e-4ec9-82fd-39e2aa4c49a9 | 1 | public void doit(JvstCodeGen gen, Bytecode bytecode, ASTList args)
throws CompileError
{
if (gen.getMethodArgsLength(args) != 1)
throw new CompileError(Javac.proceedName
+ "() cannot take more than one parameter "
+ "for cas... |
aed0deec-da15-4a97-a57c-16875e95c9da | 5 | public JSONObject increment(String key) throws JSONException {
Object value = this.opt(key);
if (value == null) {
this.put(key, 1);
} else if (value instanceof Integer) {
this.put(key, ((Integer)value).intValue() + 1);
} else if (value instanceof Long) {
... |
522efade-ad5e-4ed6-9f1b-276672fa35b9 | 1 | public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ParkBoyOperator frame = new ParkBoyOperator();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
} |
e02ffef8-6bfb-4845-b12a-c98de4735573 | 5 | public LineUp getLineUp(int in)
{
if (lineUps == null || lineUps.size() == 0)
fillLineUp();
LineUp ret = null;
// Move and iterator to the right point
boolean found = false;
Iterator<LineUp> it = lineUps.iterator();
while (!found && it.hasNext())
{
LineUp temp = it.next();
if (temp.getLineUpNum... |
57ce5601-9fec-4cd8-b8f9-9be7fee8a0d8 | 1 | public static Appointment findById(long id) throws SQLException {
ResultSet resultSet =
Data._find(Appointment.class.getSimpleName(), "id", String
.valueOf(id));
if (!resultSet.next())
return null;
return createOneFromResultSet(resultSet);
} |
016253fe-04cc-4c1b-b1ba-917b8a3fff31 | 3 | public static int getReturnSize(String methodTypeSig) {
int length = methodTypeSig.length();
if (methodTypeSig.charAt(length - 2) == ')') {
// This is a single character return type.
char returnType = methodTypeSig.charAt(length - 1);
return returnType == 'V' ? 0 : usingTwoSlots(returnType) ? 2 : 1;
} el... |
0e33e25a-4181-49f0-b430-08d9a0f18fc7 | 2 | @Override
protected void handlePost(HttpRequest request) {
String uri = request.getPath();
if (uri.startsWith(JSCOVERAGE_STORE)) {
storeReport(request, uri);
} else {
if (configuration.isProxy())
proxyService.handleProxyPost(request);
else
... |
98a74ec0-563f-4e4f-96c9-8d303728d310 | 0 | public String getSaveLineEnding() {
return (String) saveLineEndComboBox.getSelectedItem();
} |
3cc7181a-b7bb-474e-b56d-e871a1197b5a | 2 | public boolean isConnected(){
Session _session=this.session;
if(_session!=null){
return _session.isConnected() && connected;
}
return false;
} |
e5b6b626-1601-4026-8c67-68ae29ebdb56 | 0 | @Test
public void predReturnsCorrectValue() {
l.insert(b);
l.insert(a);
assertEquals(a, l.pred(b));
assertEquals(null, l.pred(a));
} |
2fda508c-1030-40b1-a363-b6157c440141 | 2 | public int[][] strassen(int[][] X, int[][] Y) {
try {
int half = X.length / 2;
int full = X.length;
int[][] result = new int[full][full];
if (full == 2) {
result[0][0] = X[0][0] * Y[0][0] + X[0][1] * Y[1][0];
result[0][1] = X[0][0]... |
7eb34b1c-90ee-459c-af21-110ec4e420c1 | 9 | static String getArgVal(String[] args, String opt, boolean watchQuoting){
if ((args == null) || (args.length==0) || (opt==null) || opt.isEmpty()){
return null;
}
if (watchQuoting){
List<String> args2 = ServerUtils.concatQuotes(Arrays.asList(args));
args = args... |
c1e2a96e-d05c-4f06-9569-e36880974360 | 9 | @Override
public boolean onCommand(CommandSender sender, Command command,
String label, String[] args)
{
if (!(sender instanceof Player))
{
sender.sendMessage("Commands are designed to be run by players only.");
return true;
}
Player player = (... |
92371194-846e-444d-afd3-51d8f01f3236 | 5 | public List<Mob> getMobs(int y, Environment environment, Biome biome)
{
List<Mob> mobList = new ArrayList<Mob>(mobs.size());
for (Mob mob : mobs)
{
SpawnRequirements r = mob.getRequirements();
if (r == null || (r.meetsHeightRequirements(y) && r.meetsEnvironmentRequirements(environment) && r.meetsBiomeRe... |
cc762f98-b22d-4e14-97a6-90b6f2683191 | 0 | @Override
public String getDesc() {
return "Default";
} |
622c73ff-b665-4498-8a21-28e023cf7575 | 3 | public void setGrid(Grid<T> newGrid)
{
Grid<T> oldGrid = world.getGrid();
Map<Location, T> occupants = new HashMap<Location, T>();
for (Location loc : oldGrid.getOccupiedLocations())
occupants.put(loc, world.remove(loc));
world.setGrid(newGrid);
for (Location loc... |
e7edc658-62f2-467f-aa47-f212704d137b | 8 | private static String getNumber(String text, boolean borne, int min, int max) {
int nombre = 0; // contient le nombre entré
String choix = ""; // contient le texte entré par l'utilisateur
do {
choix = JOptionPane.showInputDialog(text);
// s'assurer que la réponse ent... |
a97de618-1d82-41bd-86a1-fd67a7e5bc91 | 0 | protected double returnPIDInput() {
return _speedSensor.getSpeedRpm();
} |
492d3a55-dccf-4770-b879-795b269640a9 | 8 | static int getSizeRank(Class aType) {
if (aType == Double.TYPE) {
return 1;
}
else if (aType == Float.TYPE) {
return 2;
}
else if (aType == Long.TYPE) {
return 3;
}
else if (aType == Integer.TYPE) {
return 4;
... |
d01e6cee-5a72-49d9-bb64-f2c97f6f4397 | 8 | private static void setStyle(HSSFWorkbook wb,String[][] astyle,HSSFCellStyle style)
{
for(int x=0;x<astyle.length;x++)
{
if(Style.BACKGROUNDCOLOR.equals(astyle[x][0])&&(!"".equals(astyle[x][1])))
{
String color = astyle[x][1] ;
short in... |
398cca6f-94e8-490b-b5fb-3c28de7a43e1 | 1 | public List<Double> getMinValueList() {
List<Double> result= new ArrayList<Double>();
double[] values= this.getMinValueArray();
for (int i= 0; i< values.length; ++i) {
result.add(Double.valueOf(values[i]));
}
return result;
} |
86a631ea-6606-4be1-b554-9ff4dd9002b2 | 8 | public static void main(String args[]) {
System.setProperty("javax.net.ssl.keyStore", "C:\\Users\\Tyler\\agent6262KeyStore");
System.setProperty("javax.net.ssl.keyStorePassword", "223196522419553181997");
System.setProperty("javax.net.ssl.trustStore", "C:\\Users\\Tyler\\agent6262KeySto... |
556fd76a-6851-4a96-b22b-024668320d08 | 1 | @Override
public int getErrorCount() {
return dataSet != null ? dataSet.getErrorCount() : 0;
} |
a9413bea-2cea-4052-8707-41567ab10faf | 8 | public void juokse() {
/**
* Ladattavan tason määrittävä iteraattori
*/
int tasonNumero = 0;
/**
* Valmistellaan ikkuna
*/
alustaIkkuna(tasonNumero);
/**
* Luuppi joka tapahtuu niin kauan kuin tasoja riittää
*/
while... |
a6d36ce9-9c86-466c-abf9-5ad7e71f5f6d | 2 | private void batchHandle(List<QueueEntry> batch) {
// Open session
try {
session = sqlSessionFactory.openSession(false);
} catch (Exception e) {
LOG.error("Could not open DB session: " + e.getMessage());
AisRecorder.sleep(5000);
return;
}
try {
// Handle individual message
for (QueueEntry q... |
21d26389-d377-455e-9b65-1d9dcfb467c3 | 8 | public Object insert(int index, Stage stage)
throws IllegalArgumentException, IndexOutOfBoundsException {
if (stages.containsValue(stage)) {
throw new IllegalArgumentException();
}
if (wired != null || stage == null) {
throw new IllegalStateException();
}
if (index < ... |
6147ee57-963c-47bf-b0de-78cd586b559b | 0 | public void setFrozen(boolean frozen) {
this.frozen = frozen;
} |
f61463af-47a0-4b07-8327-b50a4fb9c3ce | 4 | public List<Person> getMemberList( int group_id ){
if( !handler_group.initialize() || !handler_person.initialize() ){
System.out.println( "GroupServer : failed to initialize group and person hander!" );
return null;
}
List<Person> list = handler_group.getMemberList( group_id );
if( list == null ){
hand... |
76c86977-3375-4ab4-8b85-12839468339c | 2 | @Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((bid == null) ? 0 : bid.hashCode());
result = prime * result
+ ((username == null) ? 0 : username.hashCode());
return result;
} |
a96b9604-8193-4b79-a5b3-74f800b2f111 | 0 | public CombineAutomaton(AutomatonEnvironment environment) {
super("Combine Automata", null);
this.environment = environment;
} |
89323326-2ac7-4f22-b9c2-62c9b9098eba | 4 | public void createTable() throws SQLException {
String createString =
"create table "
+ "admin.EMPLOYEE "
+ "(USERNAME varchar(20) NOT NULL, "
+ "PASSWORD varchar(20) NOT NULL, "
+ "ACCESSRIGHTS integer NOT NULL)";
Statemen... |
d9f5aaec-6dc7-409b-baad-b81a54723c94 | 2 | @Override
public void stop() {
try {
writer.write("(quit)\n");
writer.flush();
process.waitFor();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} |
ef592fd2-c1f9-451c-b993-651a1d2389f2 | 0 | public static void main(String[] args) {
new Main();
} |
04bace31-37bb-4a09-9856-8a5be7321f6f | 9 | Font(int face, int style, int size) {
Display.check();
this.face = face;
this.style = style;
this.size = size;
StringBuffer buf = new StringBuffer();
String name;
int points =
javax
.microedition
.midlet
.ApplicationManager
.manager
.awtContainer
.getFont()
.getSize();
... |
2b3ad9e7-de74-4770-9cb3-50ccaaa2ddfa | 7 | public Collection<?> collection(String string) {
parseCheck();
Option<?> opt = options.get(string);
if (opt != null) {
if (opt instanceof CollectionOption<?, ?>)
return (Collection<?>) opt.value();
throw new RuntimeException("--" + opt.name
+ " is not a repeatable option");
}
throw new RuntimeE... |
1a62a610-bb15-4a0c-b690-a43238735124 | 8 | public static Color getSkillColor(int index) {
switch(index) {
case Skills.ATTACK:
return Color.red;
case Skills.STRENGTH:
return Color.green;
case Skills.DEFENSE:
return Color.blue;
case Skills.RANGE:
return Color.orange;
case Skills.MAGIC:
return Color.blue;
case Skills.CONSTITUTION:
r... |
cae682e0-fe9b-40c8-9277-afe9fdf7f11d | 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... |
377623f3-0a39-40b7-b25c-3f9402a78e6f | 4 | public boolean isBomb(Coord c) {
Coord c2;
int x1,x2,y1,y2,j;
j = 0;
x1 = c.getX(); //X-coördinaat van ophalen
y1 = c.getY(); //Y-coördinaat ophalen
for (Bomb i : bombGrid) { //Loop door alle bommen
c2 = i.getCoords();
x2 = c2.getX();
y... |
e2a82f9b-8f08-401c-81e2-b8e47c4dce78 | 6 | public static void main(String[] args) {
File f = new File("files/numeros.txt");
BufferedReader Buffer = null;
String Linea = null;
try {
Buffer = new BufferedReader(new InputStreamReader(
new FileInputStream(f)));
while ((Linea = Buffer.readLine()) != null) {
System.out.println(Linea);
try {... |
153e443e-5eab-4202-be1e-e9931f7767cd | 7 | public static int findMaxPathSum(int[] s1, int[] s2) {
int i = 0 ;
int j = 0;
int maxSum1 = 0;
int maxSum2 = 0;
int maxResultSum = 0;
while(true){
if(i == s1.length || j == s2.length){
break;
}
if(s1[i] < s2[j]){
... |
22186fc6-f22a-4be1-974d-0260894e506f | 4 | private void listFiles() {
try {
// Send blank message to server asking to list files
Message msg = new Message(true, COMMAND.L, 0, "", new byte[0][0]);
objectToServer.writeObject(msg);
objectToServer.flush();
// Print out the contents of each message for each folder
do {
msg = (Message) ob... |
8791cd50-b3a7-4cef-ae80-544612403b69 | 0 | @Test
public void EnsureWildCardRankisRightWhenPatternHasSingleWildCard() {
assertEquals(3, patternSix.getWildCardRank());
} |
c820278d-171b-43a8-95af-009cda211833 | 6 | public void promptFind() {
Object findObj = JOptionPane.showInputDialog(frame,
"What would you like to find? ", "Find All",
JOptionPane.QUESTION_MESSAGE, null, null, getSelectedText());
if (findObj != null) {
String find = findObj.toString();
if (!find.equals("")) {
if (getSelectedText() != null &... |
eea349f1-462f-4f27-9576-4cae60f18520 | 2 | public String getInput() {
String str = "";
String returnStr = null;
while (str == "") {
try {
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(System.in));
str = bufferedReader.readLine();
} catch (IOException ex) {
ex.printStackTrace();
}
returnStr = str.to... |
c4959241-3d62-4d1d-95ed-d856d3ce1623 | 2 | @Override
public void update() {
if(sceneHeight == 0) sceneHeight = EForm.LoginForm.getScene().getHeight();
if(Model.getIntance().getFirstUser().getNick().length() > 0) {
editLogin.requestFocus();
editLogin.setText("");
editPass.setText("");
labelError... |
3c5bae78-e7bd-4df3-a4f5-c9b01c6554ea | 5 | public void solve1(char[][] board) {
if(board == null || board.length == 0) return;
R = board.length;
C = board[0].length;
visited = new boolean[R][C];
for(int i = 0; i < R; ++i){
for(int j = 0; j < C; ++j){
if(board[i][j] == 'O'){
... |
c7cba9df-c074-4492-8f6c-770d269e1047 | 4 | private void validerMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_validerMouseClicked
// TODO add your handling code here:
if (jrbBlanc.isSelected()) {
choix=0;
} else if (jrbBleu.isSelected()) {
choix=1;
} else if (jrbVert.isSelected()) {
... |
b93d3014-e140-4068-9cd1-10ebc7334ce0 | 8 | public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args){
ChatColor yellow = ChatColor.YELLOW;
ChatColor red = ChatColor.RED;
if(args.length < 1) {
if(sender instanceof Player) {
Player player = (Player) sender;
if(player.hasPermission("CrazyFeet.crazyfire.a... |
75cd3b98-bf28-4646-829c-34fd8159e9b4 | 9 | public int readInteger() //exclusively for token
{
if(console)
{
if (buffer == null || !buffer.hasMoreTokens())
try
{
buffer = new StringTokenizer(myInFile.readLine());
return Integer.parseInt(buffer.nextToken());
... |
d4f61016-ff08-4e26-9020-ed57fa04ce75 | 6 | public void checkPoison()
{
int numPokes=0;
for (Pokemon aPartyPokemon : partyPokemon) {
if (aPartyPokemon != null && aPartyPokemon.status == Pokemon.Status.PSN) {
aPartyPokemon.health--;
drawPoison = true;
if (aPartyPokemon.health <= 0) {
... |
39147b2a-4b5a-4337-baf6-2ccf6bbff8e2 | 3 | public Configuration loadEmbeddedConfig(final String resource) {
final YamlConfiguration config = new YamlConfiguration();
final InputStream defaults = this.getResource(resource);
if (defaults == null) return config;
final InputStreamReader reader = new InputStreamReader(defaults, Custo... |
abe03089-aeb1-4f39-906f-f4034bc14a54 | 6 | public void update() {
for(KeyboardHandler kh : removeLater) {
listeners.remove(kh);
}
removeLater.clear();
for(KeyboardHandler kh : addLater) {
listeners.add(kh);
}
addLater.clear();
Keyboard.poll();
while(Keyboard.next()) {
... |
ba2a1a90-5bac-4237-9313-754611dd9392 | 7 | public void method276(int i, int j)
{
Ground class30_sub3 = groundArray[0][j][i];
for(int l = 0; l < 3; l++)
{
Ground class30_sub3_1 = groundArray[l][j][i] = groundArray[l + 1][j][i];
if(class30_sub3_1 != null)
{
class30_sub3_1.anInt1307--;
for(int j1 = 0; j1 < class30_sub3_1.anInt1317; j1++)
... |
2f403fcd-fbd4-4f5f-8936-c023064a6523 | 4 | @Override
protected void process(int bits[])
{
double signal = -1.0;
for ( int i = 0 ; i < bits.length ; i++ )
{
int bit = bits[i];
if ( bit == 1 )
signal *= -1;
int j = i * SignalPlot.DIVISIONS;
in... |
41dd817d-a41c-4d09-bf68-eec693a53f7d | 3 | @Override
public boolean equals(Object o) {
if (o == null) {
return false;
}
if (!(o instanceof Operand)) {
return false;
}
Operand operand = (Operand) o;
if (this.unwrapInteger() == operand.unwrapInteger()) {
return true;
}
return false;
} |
99b27eae-8d88-46b3-9f61-ac37e23df2e0 | 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... |
094d1162-cb4c-46c1-a6e8-ad7798ce6131 | 9 | public int getClosePlayer(int i) {
for (int j = 0; j < Server.playerHandler.players.length; j++) {
if (Server.playerHandler.players[j] != null) {
if (j == npcs[i].spawnedBy)
return j;
if (goodDistance(Server.playerHandler.players[j].absX, Server.playerHandler.players[j].absY, npcs[i].absX, npcs[i].abs... |
13e6f9c3-15a5-4774-825b-c9744745586a | 0 | public static void main(String[] args) {
ExecutorImplClassDemo executorImplClassDemo = new ExecutorImplClassDemo();
RunnableImpl runnable = new RunnableImpl();
executorImplClassDemo.execute(runnable);
System.out.println("main print:" + runnable.getCount());//executor会异步执行任务,此处会先打印结果
... |
e2578ac7-4eeb-4068-8f78-e47108f5a479 | 6 | public static StringWrapper javaTranslateGlobalName(Symbol namesymbol, boolean definitionP) {
if (namesymbol == null) {
return (StringWrapper.wrapString("NULL"));
}
if (!(definitionP)) {
if (namesymbol == Stella.SYM_STELLA_TRUE) {
return (Stella.$JAVA_TRUE_STRING_WRAPPER$);
}
... |
a1bc44c1-795a-4954-a7d9-04a4ec45fa72 | 8 | private void CreneauActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
switch(etat){
case Debut:
//interdit
break;
case Debut1:
this.donner1.frame_Seance(this.id_promo);
... |
6ad26c1e-e20d-4829-9e44-c7ae813587ec | 8 | public static Point[][] get128PlayersPositions(){
int maxPlayers = 128;
Point[][] pos = new Point[8][128];
for(int i = 0; i < maxPlayers;i++ ){
pos [0][i] = new Point(0,2*i);
}
for(int i = 0; i < maxPlayers/2;i++ ){
pos [1][i] = new Point(2 ,1+4*i);
}
for(int i = 0; i < maxPlayers/4;i++ ){
pos [... |
86d012f5-1cdf-473e-b5a8-9cec36af7857 | 5 | public static int[][] generateMatrix(int n) {
int[][] res = new int[n][n];
int start = 1;
int istart = 0, iend = n;
int jstart = 0, jend = n;
while (start <= (n * n)) {
for (int j = jstart; j < jend; j++) {
res[istart][j] = start;
start = start + 1;
}
for (int i ... |
f252ab4c-fd0a-476a-9d2c-691b05b55ddb | 5 | public static RandomListNode copyRandomList(RandomListNode head) {
if (null == head) return null;
List<RandomListNode> newList = new ArrayList<RandomListNode>();
Map<RandomListNode, Integer> rawmap = new HashMap<RandomListNode, Integer>();
Map<Integer, RandomListNode> dstmap = new HashMap<I... |
0e59b061-c0b6-429a-825b-dbd2bd9623f2 | 0 | @POST
@Path("addCar/{nbSeat}/{idEvent}")
@Consumes(MediaType.TEXT_PLAIN)
public void addACar(@PathParam("nbSeat") int nbSeat, @PathParam("idEvent") int idEvent){
System.out.println("Add a car to an event");
JpaTest.eventService.addCar(idEvent, nbSeat);
} |
fa956b74-f4c9-4b7f-b93b-766101136f0a | 8 | boolean validateMove(Point src, Point dst, int id) {
if (dst.x < 0 || dst.x > dimension)
return false;
if (dst.y < 0 || dst.y > dimension)
return false;
if (players[id].music) {
if (distance(src, dst) > MUSICPIPER_SPEED)
return false;
} else {
if (distance(src, dst) > PIPER_SPEED)
return fal... |
b52c1d07-4234-4722-a8cd-6f7499901f7e | 0 | public State getState() {
return state;
} |
f11d731d-b374-4657-a0cc-ffe2cdcc9bf6 | 2 | public void addTag(String tagString) {
if (tagString == null)
return;
try {
String statement = new String("INSERT INTO " + TagDBTable
+ " (qid, tag)"
+ " VALUES (?, ?)");
PreparedStatement stmt = DBConnection.con.prepareStatement(statement);
stmt.setInt(1, quizID);
stmt.setString(2, tagS... |
00742485-398b-4e40-a1c5-2a9f585a1222 | 0 | @Test
public void getNeighbourhoodTest(){
VertexSet set = new VertexSet();
set.addVertex(new City(2, 213, 150, Owner.Neutral));
set.addVertex(new City(3, 387, 150, Owner.Neutral));
set.addVertex(new City(6, 300, 300, Owner.Rom));
City testCity = city_graph.getCity(1);
assertTrue(city_graph.getNeighbo... |
2bef993e-f4c4-43f9-b6f6-8b81565bde1e | 8 | @Override
public void optimise(DeterministicFiniteAutomaton obj) {
Set<State> processed = new HashSet<State>();
List<State> nextList = new LinkedList<State>();
List<State> queue = new LinkedList<State>();
char[] alphabet = obj.getAlphabet();
State next = null;
State current = obj.getStartState();
queu... |
15bf2121-c807-41ad-a3f7-a829f999e5c2 | 5 | @Override
public AbstractOrocosComponent getComponent(String componentName, boolean introspect)
throws SystemNotConnectedException {
CTaskContext taskContext;
try {
if(orocosContext == null){
throw new SystemNotConnectedException();
}
org.omg.CORBA.Object o = orocosContext.resolve_str(componentNa... |
1fa3e76f-da5f-49b8-a264-9c6651f5a45b | 5 | public PositionDirection next(int gap) {
PositionDirection newPd = null;
int v = getValue() + gap;
if (v > 12) {
v %= 12;
}
switch (v) {
case 6:
newPd = CLOCK6;
break;
case 9:
newPd = CLOCK9;
break;
case 12:
newPd = CLOCK12;
break;
case 3:
default:
newPd = C... |
dcfb4453-a45f-40ba-b63e-8d6884ab0acf | 2 | @Override
public void setCourseNumber(String courseNumber) {
if(courseNumber == null || courseNumber.length() == 0) {
JOptionPane.showMessageDialog(null,
"Error: courseNumber cannot be null of empty string");
System.exit(0);
}
this.courseNumber = c... |
57c9e1e1-f392-4560-9f0f-4ed27dbf357e | 0 | @Override
public String getDesc() {
return "SpiralPierce";
} |
273ddcf0-2572-4a49-83bd-eae0f43ab240 | 0 | public void setSupplierId(Integer supplierId) {
this.supplierId = supplierId;
} |
43fd5649-45b5-4332-98d2-4acfe658e1f8 | 3 | public Bill findBillByDate(Household household, Calendar calendar)
throws InstanceNotFoundException {
Set<Bill> bills = household.getBills();
for (Bill bill : bills) {
if (((bill.getDate().get(Calendar.MONTH)) == (calendar
.get(Calendar.MONTH)))
&& ((bill.getDate().get(Calendar.YEAR)) == (calendar
... |
6c4cfcf6-6715-4308-a0e4-68e358c871e0 | 5 | @Override
public void update(GameContainer container, int delta)
throws SlickException {
super.update(container, delta);
Input in = container.getInput();
if (check("UP")) {
y += -speed * delta;
this.setAnim("up");
}
if (check("DOWN")) {
y += speed * delta;
this.setAnim("down");
}
if (che... |
13fd64f4-ccee-416d-8c7d-a94499ac2d8f | 0 | @Override
public ILoggerConfig getLoggerConfig() {
return loggerConfig;
} |
864e8f45-ee80-4560-b95f-3dac5d292325 | 6 | private static void buildCoreSet(Release set, List<SeperatorDefinition> seps) throws MalformedURLException {
for(MagicColor c: MagicColor.values()) {
if (!c.includeInDefaultSets())
continue;
for(Rarity r: Rarity.values()) {
if (r == Rarity.Mystic)... |
d77d3ef9-f77c-4c11-bde3-1527cb8fbd4a | 7 | public boolean calculateDistribution() {
bDeadline = true;
boolean bUsedNewResource = false;
double tmp = 0, rest = 0;
/* distribute tasks according to the sort */
int k;
double lastAllocation;
for (int i = 0; i < iClass; i++) {
print(iStage + " Distribution[" + i + "]");
tmp = 0;
rest = iaTask[... |
9ebe5273-8c6e-47cb-90da-a6039f0efb96 | 8 | public List<VisualPoint> getVisualPoints() {
List<VisualPoint> result = new ArrayList<VisualPoint>();
for (Point p : lBlue) {
if (colorSwap) {
VisualPoint newPoint = new VisualPoint(p.a, p.b, PointType.RED, false, p);
result.add(newPoint);
} else {
VisualPoint newPoint = new VisualPoint(p.a, p.b, ... |
7ed9c21f-8b59-405e-a6e4-8f7272d3ec35 | 4 | protected static Date parseDate(String str, String format) throws WeiboException{
if(str==null||"".equals(str)){
return null;
}
SimpleDateFormat sdf = formatMap.get(format);
if (null == sdf) {
sdf = new SimpleDateFormat(format, Locale.ENGLISH);
sdf.setTimeZo... |
b4c8389b-3241-4f1c-b037-1b267b4b185d | 9 | public void solve(char[][] board) {
if (board.length == 0) {
return;
}
boolean[][] visited = new boolean[board.length][board[0].length];
boolean[][] gray = new boolean[board.length][board[0].length];
for (int i = 0; i != board.length; i++) {
for (int j = ... |
d650f254-9a0d-4231-ad88-cd30247b024a | 3 | private void calculateEnabledState(JoeTree tree) {
Document doc = tree.getDocument();
if (doc == Outliner.documents.getMostRecentDocumentTouched()) {
Node node = tree.getEditingNode();
if (tree.getComponentFocus() == OutlineLayoutManager.ICON && tree.getNumberOfSelectedNodes() >= 2) {
setEnabled(tr... |
3942298d-dfae-4edc-ba35-2751be2245de | 6 | public void saveFile(String filename) {
try {
List<String> sections_list = new ArrayList<String>();
for (String key : map.keySet()) {
String section = key.split("\\.")[0];
if (!sections_list.contains(section)) sections_list.add(section);
}
... |
e76e046e-e1b6-4a75-a245-4f5c2afdc1d7 | 2 | public void alteraSite(String comandoSQL) throws Exception {
Connection con = null;
try {
abrirConexao();
} catch (Exception ex) {
throw ex;
}
try {
String conexao = new String();
Statement comando = (Statement) conbco.createStatem... |
1eb6f5ce-52a8-4fa6-8edf-85a431a86f94 | 5 | public static Item[] getAllItems(final boolean cached) {
final Item[] items = new Item[28];
final WidgetChild inventoryWidget = getWidget(cached);
if (inventoryWidget != null) {
final WidgetChild[] inventoryChildren = inventoryWidget.getChildren();
if (inventoryChildren.l... |
4f677527-0fca-4570-a963-1c20bc645c60 | 4 | public void cadastrarPaciente(Paciente p) throws ControllerException {
try {
if (ValidarPaciente(p)) {
pacienteDAO.save(p);
Publish publish = new Publish(p.getIdTopico(), uriHub);
publish.createTopic();
publishNewPaciente.publish(p.getIdTopico());
}
} catch (ObjetoNuloException | ... |
3da60b88-b4cd-498b-8bb9-655b26249eeb | 4 | public void saveCopy(int copyId){
try {
if(conn == null || conn.isClosed()){
conn = DatabaseConnection.getConnection();
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
conn.setAutoCommit(false);
PreparedStatement stm... |
125f06f8-7421-4e7e-bf45-0b8d6346cd38 | 1 | public void testSetMonthOfYear_int2() {
MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
try {
test.setMonthOfYear(13);
fail();
} catch (IllegalArgumentException ex) {}
assertEquals("2002-06-09T05:06:07.008+01:00", test.toString());
} |
514d6c5c-c6dd-449b-acae-2d8057df3f39 | 8 | public MClientCmdListener(String analyticsServerRef, String billingServerRef, ExecutorService mClientExecutionService) {
this.analyticsServerRef = analyticsServerRef;
this.billingServerRef = billingServerRef;
this.mClientExecutionService = mClientExecutionService;
// create EventListener Remote Object
try ... |
9ab11b30-6a16-4c8b-be01-7fc96ebd665c | 8 | public String buildUpdSql(
AdminTbl tbl,
String keyval,
List<AdminCol> updcols,
List<AdminCol> metacols,
List<AdminCol> keycols,
Map<String,String[]> data,
String userId,
String langCd)
{
StringBuilder sql = new StringBuilder();
//build the update set clause for editable fields
sq... |
1d2c8c06-2995-4c89-88a0-9eb4ab98e378 | 5 | public boolean hasTerm(String query){
for(int i = 0;i < chapters.size();i++){
if(chapters.get(i).getChapterName().toLowerCase().contains(query.toLowerCase())){
return true;
}
if(chapters.get(i).hasSubChapters()){
for(int j = 0;j < chapters.get(i).getSubChapters().size();j++){
if(chapters.get(i).... |
2355c40b-9425-467c-955b-4f8b0d69ab5a | 0 | public static ParticipantJsonConverter getInstance() {
return instance;
} |
54b2ee24-27c3-4fa6-8af4-e30dc4229c7d | 1 | public void testWithFieldAdded_DurationFieldType_int_2() {
LocalDate test = new LocalDate(2004, 6, 9);
try {
test.withFieldAdded(null, 0);
fail();
} catch (IllegalArgumentException ex) {}
} |
32655433-5147-4413-b800-282653fe5bbd | 0 | public static byte[] GenerateAuthenticatorServer(int status,
byte[] authenticatorClient, String sharekey)
throws NoSuchAlgorithmException {
byte[] keybyte = sharekey.getBytes();
byte[] buf = new byte[authenticatorClient.length + 4 + keybyte.length];
TypeConvert.int2byte(status, buf, 0);
System.arraycopy(a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.