method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
605788ff-2a97-4c73-962b-44c971f82823 | 1 | public boolean isEmpty() {
if (getSize() > 0) {
return false;
} else {
return true;
}
} |
28547045-3382-4fa7-a15a-5ca6bbc28140 | 9 | public static void main(String[] args) {
/**
* Le programme accepte jusqu'entre 1 et 3 argument :
* - le premier est le lien vers le fichier en entrée contenant les tâches
* - le deuxième est le type de simulation attendu [OPTIONNEL]
* - le troisième est le répertoire de sortie [OPTIONNEL]
*/
Stri... |
d1c8b946-d751-4772-8ea9-63a7f3d58ff7 | 0 | public boolean getHuff(){
return toBeHuffed;
} |
72b18f59-d1be-4bf3-8f14-08a4aeee7f95 | 0 | public void setItemId(int itemId) {
this.itemId = itemId;
} |
0c59a7f4-2ee8-4028-8140-06cc93b52b08 | 4 | public static void main(String[] args) {
if (InstanceChecker.lockInstance("./lock")) {
final RemoteResourcesServer localServer = RemoteResourcesServer
.newInstance(args, true);
localServer.start();
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
RemoteReso... |
e4b1ef79-17e0-4702-b869-222856d8e75f | 0 | public Dimension getPreferredScrollableViewportSize() {
return getPreferredSize();
} |
ec94fb7a-5b68-4063-9ae4-467e02a0ea95 | 3 | private void destroy(float x, float y) {
beeHitBox.setLocation(x + 8,y);
for(int i = 0; i < map.length; i++){
if(beeHitBox.intersects(map[i])){
if(map[i].type != 0){
map[i].type = 0;
}
}
}
} |
35cd65e0-c97b-4288-a5d9-5612793926a9 | 8 | public int handleRequest(long uid, String password, String... param) {
Connection conn = null;
int result = -1;
JSONArray jsonArray = new JSONArray();
try {
conn = DataBaseManager.getInstance().getConnection();
if(conn != null && param != null && param.length > 0){
Statement stat = conn.createStatemen... |
bd09e6eb-44f3-4264-9e2f-f3b62b37794c | 9 | private int getMaxIntervalOverlapCountUsingCountingSort(
List<Interval> intervals) {
if (intervals == null || intervals.size() == 0){
return 0;
}
int[] countArray = new int[1441]; // There are at most 24*60+1 = 1441
// different times
TimeInteger[] times = new TimeInteger[2 * intervals.size(... |
5e4c2ed8-d45e-412e-b8e5-33b458586a50 | 3 | private void parseChannelList(Element el){
Element network = (Element)el.getElementsByTagName("Network").item(0);
mp.put("Network", network.getFirstChild().getNodeValue());
NodeList nl = el.getElementsByTagName("Channel");
if(nl != null && nl.getLength() > 0)
{
... |
50edff12-d268-4144-aaa2-2dea24186284 | 3 | @Override
public void actionPerformed(ActionEvent e) {
if (!end){
n.moveR();
if(n.x==650){end=true;}
}else {n.moveL();
if(n.x==10){end=false;}}
repaint();
} |
653d2073-449e-4a75-9b69-22d88d9b14db | 7 | public ConnexionExtend(){
arrayy=new ArrayList<String>();
geomms=new ArrayList<String>();
arrayy.clear();
geomms.clear();
Connection con = null;
try{
Class.forName("org.postgresql.Driver");
con = DriverManager.getConnection("jdbc:postgresql://"+ConnexionBaseDonnees.getHote()+":"+ConnexionBaseDon... |
dae2356e-0240-4938-b21c-1a0f8bb315fa | 2 | public boolean dropTrap(int x, int y) {
// Tries to drop a trap at passed location. Since ZombieLevel has a
// method in place for this that checks if the location is valid,
// this just off-loads the grunt work to that.
if (player.getFireTrapCount() > 0) {
if (level.dropTrap... |
cea4ac1c-f603-4f3d-bda0-228ac91e9c1c | 3 | protected boolean isFinished() {
return (shooter.topSwitch.get() || shooter.left.getD() >= shooter.height || shooter.right.getD() >= shooter.height || feeder.isIn);
} |
8fde167e-f3be-48c1-855d-420f1cfd8558 | 4 | private byte[] generateHandshake() {
int i;
byte[] handshake = new byte[68];
handshake[0] = (byte) 19;
String protocol = "BitTorrent protocol";
for (i = 1; i < 20; i++)
handshake[i] = (byte) protocol.charAt(i-1);
for (i = 20; i < 28; i++)
handshake[i] = 0;
for (Byte b : torrentInfo.info_hash.array()... |
2389c4d4-7e53-4658-abe8-26309dd121a1 | 7 | public Imagenes algoritmoRotacion_I(Imagenes antigua_imagen, double angulo, boolean interp){
Imagenes nueva_imagen = new Imagenes();
nueva_imagen.setRotated();
//Recogiendo los puntos
double x, y;
x = 0;
y = 0;
double E[], F[], G[], H[];
E = new double [2];
F = new double [2];
H = new d... |
d8ab2fb5-d9d8-4bf2-801d-e0d0119d745f | 0 | public int getMargaritas() {
return margaritas;
} |
f21a8b31-c8da-4c94-a73d-7ad851a1e630 | 6 | public static String str_ireplace(String s,String d, String src) {
if (src == null || s == null || d == null) return "";
String lcSrc = src.toLowerCase();
String lcS = s.toLowerCase();
int sLen = s.length();
int pos = lcSrc.indexOf(lcS);
if (pos == -1) {
return src;
}
while (pos > -1) {
src = src... |
8ac4bd6c-7c51-4d22-816c-74b1b9a17dae | 6 | private void addBreach() {
squareSelector.reset();
squareSelector.setCriteria(new SquareCriteria() {
private final String desc = "Add: Breach";
public String getDescription() { return desc; }
public boolean isSquareValid( SquareSelector squareSelector, int roomId, int squareId ) {
if ( roomId < 0 || ... |
8ca0445b-ffe8-484b-bc48-45c6b7f5734f | 8 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String type = request.getParameter("type");
HttpRequest req = Enum.valueOf(HttpRequest.class, type.trim());
IprocessHttpRequest iRequest = null;
HttpSession session = request.getSession();
Str... |
cad6ef12-77c1-4ea5-8994-327ab2197a32 | 5 | public LinkedList < TileModel > getTiles () {
if ( tilesList == null ) {
tilesList = new LinkedList < TileModel > ();
for ( int i = 0; i < tiles.length; i++ ) {
if ( tiles [ i ] != null ) {
for ( int j = 0; j < tiles [ i ].length; j++ ) {
... |
74e9dd5b-77ad-4774-9339-19c23161c1ad | 1 | public ArrayList<Player> multiPlayer(int x){
ArrayList<Player> players = new ArrayList<>(x);
for (int i=0;i<x;i++)
{
players.add(cPlayer());
}
return players;
} |
fee7d92b-d192-4822-b916-0038bb2273e7 | 3 | public boolean hit(int x, int y) {
int i = cellAt(x, y);
if (i == -1) return false;
if (i == 0) return true;
int size = i + 1;
while (body.size() > size) {
body.remove(i + 1);
}
return true;
} |
5060fb2f-4ead-4415-abaf-9e77a14dd2ce | 4 | @Override
public Transferable createTransferable(JComponent c)
{
if (c instanceof mxGraphComponent)
{
mxGraphComponent graphComponent = (mxGraphComponent) c;
mxGraph graph = graphComponent.getGraph();
if (!graph.isSelectionEmpty())
{
originalCells = graphComponent.getExportableCells(graph
.... |
fa7a9e20-0928-4bc6-9d3b-c16652d9d3c9 | 9 | public void atualizaArquivoJobsAbertos(String numJob, String operacao) {
Map<Integer, String> jobs = null;
Integer chave;
String job = "";
Scanner scan;
//se operacao tiver apenas um digito, coloca um zero na frente ex: 05
operacao = operacao.length() == 1? 0+operacao :... |
8e20d6da-cfc2-4c1f-89c7-84b0455bf882 | 5 | @Override public String toString()
{
String res = "= Match between: ";
for ( int _t = 0; _t < this.players.size(); _t++ )
{
res += this.players.get( _t ).name();
if ( _t + 2 < this.players.size() ) res += ", ";
else if ( _t + ... |
43aede7f-e7d0-4fbb-9c2b-76a71b484278 | 5 | private static void populateInstalledTextures (ModPack pack) {
int mcversion = Integer.parseInt(pack.getMcVersion().replace(".", ""));
File textureVersionFile = new File(Settings.getSettings().getInstallPath(), pack.getDir() + sep + "minecraft" + sep + getTPDirectory(mcversion) + sep + "textureVersions... |
6e7e4d8b-70a9-4fd2-a1df-e67ed53af182 | 7 | @Override
public void executeMsg(final Environmental myHost, final CMMsg msg)
{
super.executeMsg(myHost,msg);
if(!(affected instanceof MOB))
return;
final MOB mob=(MOB)affected;
if((msg.amISource(mob))
&&(msg.tool()!=this)
&&(!CMath.bset(msg.sourceMajor(),CMMsg.MASK_CHANNEL))
&&((CMath.bset(msg.sour... |
7f3395ad-b0cd-44ea-bd32-22603889b570 | 2 | public void merge(MultiMap<K, V> other) {
if (other != null) {
for (Entry<K, ArrayList<V>> entry : other.data.entrySet()) {
put(entry.getKey(), entry.getValue());
}
}
} |
c6b2ab4e-473f-486f-bf63-8de6246f4146 | 2 | @Override
protected int[] orderArray() {
heapLen = array.length;
for(int i = 0; i < len(); i++) {
bubbleUp(i);
}
for(int i = 0; i < len(); i++) {
popToEnd();
}
return array;
} |
8932d382-e020-4274-aebe-e878073da01d | 0 | public static Simulator getSimulator() {
return simulator;
} |
20cf39a5-54cb-49a2-8cae-6230e4724d42 | 5 | public void toggleSign(DB_Timers timer, Boolean enabled) {
String text = (enabled ? "" : "<DISABLED>");
Integer timerID = timer.getId();
DB_StartSign startSign = this.getStartSign(timerID);
DB_StopSign stopSign = this.getStopSign(timerID);
if (startSign != null) {
Sign sign = this.getSign_Start(startSign);... |
ebf04a7f-1c78-4f66-a106-3e84d82f7665 | 7 | public boolean hasSignedness() {
switch(operator) {
case SHR: case TIMES: case DIVIDE:
case GT: case GEQ: case LT: case LEQ:
return true;
}
return false;
} |
ec5ded87-c91c-4474-8d44-f4c5fecd63e9 | 9 | private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed
//TODO:Métodos para ligar uma ou outra (factory)?
//TODO: Falar com o prof sobre o singleton que está no eclipse
//int[] type = new int[3];
//type[0]=1;
//Person p1 = new Person(-1,"lala@lala.com", "", "a... |
cf32e7d1-6f5f-4a27-9e28-910a0003517b | 0 | public String getName()
{
return name;
} |
cc7b3ae0-5c0a-4a35-b9ad-a66bcef900b0 | 1 | public void removeMember(Instance instance) {
if (numOfMembers == 1) {
featureVector = new FeatureVector();
numOfMembers = 0;
}
else {
this.featureVector.scalarDivide(-1.0/numOfMembers);
this.featureVector.add(instance);
this.featureVector.scalarDivide(-1.0);
numOfMembers -= 1;
this.featureVe... |
d94b992e-77e5-4e28-866f-9643dc05048b | 7 | public static Cons getRoleNamesAndValues(Stella_Object instanceref) {
{ Stella_Object instance = Logic.getInstance(instanceref);
KeyValueList table = KeyValueList.newKeyValueList();
if (instance == null) {
return (null);
}
{ Proposition p = null;
Iterator iter000 = ((Iterato... |
c4b606e1-7ee5-4242-a53a-e2e95ccf0180 | 8 | @SuppressWarnings({ "deprecation" })
public void keyPressed(KeyEvent e)
{
if(e.getKeyCode()==KeyEvent.VK_G){// Gshop
threadRobot.suspend();
threadRepaint.suspend();
new shop(ut).setVisible(true);
}
else if(e.getKeyCode()==KeyEvent.VK_ESCAPE||e.getKeyCode()==KeyEvent.VK_DELETE){
threadRo... |
fc41c853-38ef-4190-9ac1-2a11b36b034d | 2 | public double calculateClusterDistance(Cluster cluster1, Cluster cluster2) {
Instance instance1, instance2;
double distance = 0, count = 0, tempDist = 0;
for (int i = 0; i < cluster1.size(); i++) {
instance1 = cluster1.get(i);
for (int j = 0; j < cluster2.size(); j++) {
instance2 = ... |
00ec3c18-5a87-454f-bced-787e96e6986b | 6 | public void run() {
InetAddress group = null;
MulticastSocket socket = null;
try {
socket = new MulticastSocket(port);
group = InetAddress.getByName(multicast);
} catch (UnknownHostException e) {
e.printStackTrace();
... |
2b8427bc-d368-4a6e-bb0c-e0a329233b03 | 0 | public SignatureMethodType getMessageAuthScheme() {
return messageAuthScheme;
} |
e7a1816c-65a6-4ee1-97fc-ecef879bb82c | 6 | public void upgrade(T snap) {
Transaction me = Thread.getTransaction();
Locator oldLocator = this.start.get();
T version = (T) oldLocator.fastPath(me);
if (version != null) {
if (version != snap) {
throw new SnapshotException();
} else {
return;
}
}
ContentionM... |
4084d521-1424-4ec0-942f-2265c79dae0a | 3 | @Override
public boolean commit() throws LoginException
{
if (debug)
{
LOG.debug("committing authentication");
}
if (!succeeded)
{
return false;
}
userPrincipal = new UserPrincipal(username);
addNonExistentPrincipal(userPr... |
108ea1cf-0fed-4f7e-a3b8-6fb57397199a | 8 | public void execute(CommandSender sender, Command command, String[] args) {
if(!command.getLabel().equalsIgnoreCase("pay")) return;
if(!Permissions.COMMANDS_PAY.validate(sender)) {
Messenger.noPermissions(sender);
return;
}else if(!(sender instanceof Player)) {
... |
578089a9-c7ea-43e6-a1db-550222ec4e80 | 0 | public int getCRIT() {
return crit;
} |
bd3298da-b772-4789-b52d-053ae320f77c | 8 | void floyd(int rows) {
for (int i = 0; i < rows; i++) {
for (int j = 0; j < rows; j++) {
distancias[i][j] = grafo[i][j];
padres[i][j] = i;
if (grafo[i][j] == INF || i == j) {
padres[i][j] = -1;
}
}
}
for (int k = 0; k < rows; k++) {
// print(distancias);
for (int i =... |
86a6e8af-0322-4fe9-8acb-17bd9b6db2e7 | 8 | void addRecipe(Object factoryType, Object par2ArrayOfObj[])
{
String s = "";
int i = 0;
int j = 0;
int k = 0;
if (par2ArrayOfObj[i] instanceof String[])
{
String as[] = (String[])par2ArrayOfObj[i++];
for (int l = 0; l < as.length; l++)
... |
a008af95-2453-4bde-ac65-990591432ff5 | 6 | private boolean equipUnit(Unit unit, Role role, Colony colony) {
if (role == Unit.Role.SOLDIER) role = Unit.Role.DRAGOON; // Special case
List<EquipmentType> equipment = role.getRoleEquipment(spec());
if (equipment.isEmpty() || !unit.isPerson()) return false;
boolean result = false;
... |
db11d386-a1af-4fab-b790-643f24145b24 | 9 | @Override
protected MoveResult determineMoveResult() {
MoveResult result = MoveResult.OK;
if (redButterfly != null && isSurrounded(redButterfly)) {
result = MoveResult.BLUE_WINS;
} else if (blueButterfly != null && isSurrounded(blueButterfly)) {
result = MoveResult.RED_WINS;
} else if (turn >= maxTurns) ... |
85501189-fb04-4540-b5b0-3c8135ac26d9 | 9 | protected static FastVector pruneCadidates(FastVector allCandidates, FastVector kMinusOneSequences) {
FastVector prunedCandidates = new FastVector();
boolean isFrequent;
//for each candidate
for (int i = 0; i < allCandidates.size(); i++) {
Sequence candidate = (Sequence) allCandidates.elementAt(i)... |
c4371d7b-0f7f-4404-b55b-d6edb3fe429f | 1 | public void Set_rho_zM(float[] rho){
for(int i = 0; i < rho.length; i++){
rho_z[i] = rho[i];
}
} |
e315f2a5-73fc-4047-8603-cbef286f9119 | 6 | public void createProject(RedmineManager mgr, String prjId)
throws RedmineException {
Project projectByKey = null;
String projectId2 = prjId;
try {
projectByKey = mgr.getProjectByKey(projectId2);
} catch (NotFoundException e) {
if (getLog().isDebugEnabled()) {
getLog().debug("Project not found.");
... |
73321453-d6ef-420d-8ecb-f4bf8492f5b6 | 4 | public ListNode sortList(ListNode head){
if(head == null || head.next == null) return head;
ListNode point = head;
int[] arr = new int[9999];
int idx = 0;
while(point != null){
arr[idx++] = point.val;
point = point.next;
}
quickSort(arr, 0, idx-1);
point = head;
for(int i = 0; i<idx; i++){
po... |
b955e0ee-8d72-4a05-a980-e5dd1f41717b | 6 | private void drawUnfinishedInput(Graphics2D grafik)
{
if(mode == MODE_CREATE && mousepressed)
{
grafik.setColor(Color.RED);
grafik.drawLine(movedpos[0], movedpos[1], draggedpos[0], draggedpos[1]);
}
else if(mode == MODE_DELETE && mousepressed)
{
int p1x = 0;
int p1y = 0;
int lx = 0;
int ... |
88a54223-b8ac-4cfe-9b6f-305bdd3fbc46 | 9 | private static boolean controlBasefiles() {
boolean ret = FileUtil.controlDirectory(Constants.PROGRAM_WORKBASE_IMG_PATH);
if (ret) {
ret = FileUtil.control(Constants.EDITOR_DEFAULT_BACKGROUNDIMAGE);
}
if (ret) {
ret = FileUtil.control(Constants.EDITOR_USERIMG);
... |
79ee4ef6-aaca-47dc-8a26-86a71da3be25 | 1 | public void run() {
for(int i = 1 ; i < 100 ; i ++)
{
System.out.println("Runnable implements Thread " + i + " !");
}
} |
1f02bf91-93cf-4eb9-bab7-0846defd1f4c | 2 | public void insert(IntegerNode newNode) {
if (this.head == null){
this.head = newNode;
} else {
if (this.head.getNext() == null){
this.head.setNext(newNode);
} else {
this.head.setNext(newNode);
}
}
count++;
} |
b02c17b8-2cb7-4a24-8e56-bbea67fe241d | 2 | @Override
protected Void doInBackground() throws Exception {
Client loginClient = new Client(4096 * 2, 4096 * 2);
loginClient.getKryo().setRegistrationRequired(false);
loginClient.getKryo().register(PacketLogin.class);
loginClient.getKryo().register(PacketLoginResponse.clas... |
79fbe9de-5545-4e28-a591-ff6271d7c04e | 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... |
545e8ee4-d723-4a5d-86e1-3dc4f9fc6353 | 9 | @Override
public Object getValueAt(int rowIndex, int columnIndex) {
if (briefe == null || rowIndex >= briefe.size()) {
return null;
}
BeitragBrief row = briefe.get(rowIndex);
SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy");
... |
b7b611cc-6b8f-4bee-a899-1a05b352ed51 | 1 | public boolean canAdd(){
if(maxStacks-stack > 0) return true;
return false;
} |
a1299307-0e5f-4ef4-9e3f-58e15ccdb823 | 4 | public static boolean isVisible(Class<?> clazz, ClassLoader classLoader) {
if (classLoader == null) {
return true;
}
try {
Class<?> actualClass = classLoader.loadClass(clazz.getName());
return (clazz == actualClass);
// Else: different interface class found...
} catch (ClassNotFoundException ex) {
... |
307a8ab1-34b9-4265-908b-0ef038b18c7c | 7 | public synchronized int updateService(int id, String path, String type, String title, String description) {
int serviceId = -1;
boolean found = false;
conn.query("select * from "+SCHEMA+".services where server_id = '"+id+"' and path = '"+path+"' and servicetype = '"+type+"'");
ResultSet rs = conn.getQueryRes... |
97f9d913-2123-4cee-8dcf-b2a90456d611 | 9 | public static void main(String args[]) throws Throwable {
Scanner sc=new Scanner(System.in);
for (;sc.hasNextInt();) {
int N=sc.nextInt();
int[] arr=new int[N],arr2=new int[N];
for(int i=0;i<N;i++)arr[i]=arr2[N-i-1]=sc.nextInt();
int[] lis1=lis(arr),lis2=lis(arr2),nLis1=new int[lis1.length],nLis2=new in... |
1bac7456-12b4-4512-9408-943a4328e45f | 2 | @Override
public InputStream getResourceAsStream(final String string) {
final File file = new File(this.dir, string);
if (file.exists()) {
try {
return new FileInputStream(file);
} catch (FileNotFoundException ex) {}
}
... |
202bb7fa-6b64-4fe0-b2b8-c599f4d748ed | 5 | @Override
public double calculateDistance(double[] target, double[] spiketrain) {
double d;
List<Integer> targetSpikes = new ArrayList<Integer>();
List<Integer> spiketrainSpikes = new ArrayList<Integer>();
for (int i = 0; i < target.length; i++){
if(spiketrain[i] >= t... |
2ea2defc-a190-439f-9b68-f466a58807af | 3 | private static boolean isAlpha(char c) {
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
} |
4e043600-33a5-431a-8025-e3aec4f9af4f | 2 | public boolean hasElement(T a)
{ if(this.a.equals(a))
{ return true;}
else if(this.next!=null)
{ return this.next.hasElement(a);
}
else
{ return false;
}
} |
0dac54aa-a4cb-446c-959a-2c53f847a8ef | 6 | private boolean r_attached_pronoun() {
int among_var;
// (, line 86
// [, line 87
ket = cursor;
// substring, line 87
if (find_among_b(a_2, 37) == 0)
{
return false... |
21cd4f61-a129-4630-96fc-07ee7f695766 | 4 | private void updateGridCoords(
int gridx,
int gridy,
int gridw
)
{
if( gridx != CURRENT )
this.gbc.gridx = gridx;
if( gridy != CURRENT )
this.gbc.gridy = gridy;
if( gridw == USE_FULL_WIDTH ) {
this.gbc.gridwidth = this.gridWidth;
} else if( gridw != CURRENT ) {
this.gbc.gridwidth ... |
82a9f4d7-7ae8-4e88-b2aa-218fd4ce0d87 | 0 | public void setTimeStamp(Clock hostTimeStamp){
this.timeStamp = hostTimeStamp;
} |
c4041572-8436-441d-96ec-12ef4114e504 | 9 | public int move(int destX, int destY){
if(canMove(destX, destY) == false){
return -1;
}
else{
this.x = destX;
this.y = destY;
//if Hero is at the exit location of the current map, move to next map
if(this.x == map.getExitLocX() && this.y == map.getExitLocY()){
if(mapIndex < NUM_MAPS){
map ... |
6b27d64c-56b9-427a-bd97-03fb4991240b | 4 | public CMD_RoomChange(CommandSender sender, String name, String [] args) {
Bukkit.getServer().getPluginManager().getPlugin("CR").reloadConfig();
if (args.length == 1) {
if (!new isPrivate().IsPrivate(args[0])) {
config.getConfig().set("Player."+name+".CR", args[0]);
sender.sendMessage(ChatColor.GRAY+"Suc... |
1f447d92-c1fd-4b86-a09e-7e40184553f9 | 5 | public boolean treeMatch(TreeNode<Integer> n1, TreeNode<Integer> n2) {
if (n1 == null & n2 == null)
return true;
if (n1 == null || n2 == null)
return false;
if (n1.data != n2.data)
return false;
return treeMatch(n1.left, n2.left) && treeMatch(n1.right, n2.right);
} |
a1fe88f4-a8f4-4f3b-a897-fe83bd22b57c | 3 | public static boolean checkForPress(int button){
while(Keyboard.next()){
if(Keyboard.getEventKeyState()){
if(Keyboard.getEventKey() == button) return true;
}
}
return false;
} |
edee50ec-9000-4b33-82e2-c20c030d8153 | 1 | public double next(Random r) {
double d = r.nextDouble() * (max - min) + min;
try {
in.setFieldValue(new Double(d));
} catch (Exception ex) {
ex.printStackTrace();
}
return d;
} |
d3f7f90f-9717-4507-93ec-2f2aa3167153 | 9 | private static double[] calculateErrorSurfaceAnnealing(){
// Prepare output file
FileWriter outFile;
try{
outFile = new FileWriter("surf_anneal.txt");
}catch(Exception e){
System.out.println("ERROR! Couldn't open surf_anneal.txt");
... |
b8d27cbe-3ab7-46ff-bdf1-b26ba2028418 | 5 | @Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("<tr");
//boolean rowWithNesting = hasNestedTable();
if ( isHidden() )
sb.append(" class=\"hidden\"" );
//else if ( rowWithNesting )
// sb.append(" class=\"nested... |
9f65f8a2-5cde-4eb3-98f7-be3b2088cb7d | 5 | @Override
public boolean saveAsSkinToDefaultDirectory(Skin skin, String newName) {
if (skin == null) {
IllegalArgumentException iae = new IllegalArgumentException("Invalid skin!");
LOGGER.error(iae.getMessage(), iae);
throw iae;
}
if ((newName == null) |... |
61950095-a40a-4d9b-a371-adbf1dc59b73 | 2 | public void keyReleased(KeyEvent e) { //stops the paddle from moving when the key is released
int key = e.getKeyCode();
if (key == KeyEvent.VK_LEFT) { //set to 0, hence no motion
dx = 0;
}
if (key == KeyEvent.VK_RIGHT) { //set to 0, hence no motion
dx = 0;
... |
f9286766-747c-4c62-a28c-2b2419a77422 | 7 | protected void processItem(ResultSet rs) throws SQLException, IOException {
int cmcId = rs.getInt("p_page_id");
String url = null;
String text = null;
String title = rs.getString("p_title");
String content = rs.getString("p_content");
log.info("Parsing item: " + cmcId);
// Need to... |
88f75bf6-8b48-4697-a7f9-918d61f86d47 | 9 | protected boolean engineVerify(
byte[] sigBytes)
throws SignatureException
{
byte[] hash = new byte[digest.getDigestSize()];
digest.doFinal(hash, 0);
byte[] sig;
byte[] expected;
try
{
sig = cipher.processBlock(sigBytes, 0, ... |
371c347d-fe44-4457-8bc3-3df343ceb782 | 6 | @Override
public double[] computeValue(final char refBase, FastaWindow window, AlignmentColumn col) {
values[ref] = 0.0;
values[alt] = 0.0;
if (col.getDepth() > 0) {
Iterator<MappedRead> it = col.getIterator();
while(it.hasNext()) {
MappedRead read = it.next();
if (read.hasBaseAtReferencePos(col... |
6293b7a5-3b9f-4998-b653-f8dc5ce69334 | 0 | @Test
public void testAreTherePriceForQuantity() throws Exception {
assertTrue(product.areTherePriceForQuantity(1));
assertTrue(!product.areTherePriceForQuantity(15));
} |
1ce3fd0f-58d9-4e0c-abc9-9d5db90279d3 | 5 | private static void help()
{
boolean repeat = true;
while (repeat == true)
{
Object [] options = {"Instrument Replacer", "File Splitter",
"Volume Changer", "Back"};
int n = JOptionPane.showOptionDialog(null, genHelp, "General Info",
... |
45153d65-cbb5-4c90-838e-570ceb99a2a0 | 0 | public ConfigurationController getController() {
return controller;
} |
d6d2b391-2846-4744-a585-0931f608082d | 1 | public static void main(String[] args) throws IOException {
ObjectMapper mapper = new ObjectMapper();
BufferedReader bufferedReader = new BufferedReader(new FileReader("D:\\Java SE\\src\\json\\jackson_tree_model\\file.json"));
JsonNode jsonRoot = mapper.readTree(bufferedReader);
... |
97cde807-43d0-4d6c-837a-861e185bbb85 | 5 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Block other = (Block) obj;
if (this._color != other._color && (this._color == null || !this._color.equals... |
4f0dc8ec-0b71-49ce-bf73-50fa8ad32f93 | 6 | private static InetAddress getIP(String ifacename) throws SocketException, UnknownHostException {
Enumeration<NetworkInterface> ifs = NetworkInterface.getNetworkInterfaces();
NetworkInterface iface;
Enumeration<InetAddress> addresses;
InetAddress ip;
while(ifs.hasMoreElements() && (iface = ifs.nextElement()) ... |
d8c8e8a1-349a-45b9-a986-01ee7ba87c45 | 5 | private Coordinate calculateLowestFreeCoordinateUP(Coordinate c, Player p) {
Coordinate result = null;
Node nodeHoveringOver = Node.getNode(Coordinate.getCoordinate(c.getX(), c.getY()));
if(nodeHoveringOver.isActive() && nodeHoveringOver.getOwner().getOwner()==p){
//return null;
}
else{
result = c;
f... |
a5466ea0-563c-429b-9e90-e68a5e3c5627 | 2 | @Override
public void render(SpriteBatch batch) {
boolean d = true;
for (int i = 0; i < animations.length; i++) {
animations[i].render(batch);
d = animations[i].isDone;
}
if (d)
done();
} |
05aa7d62-574c-484f-a53f-0eb844dd3902 | 5 | private static void skipWhitespace() {
char ch=lookChar();
while (ch != EOF && Character.isWhitespace(ch)) {
readChar();
if (ch == '\n' && readingStandardInput && writingStandardOutput) {
out.print("? ");
out.flush();
}
ch = lookChar();
}
... |
09765105-b62c-412f-a00c-fa3a7bcb71f4 | 3 | public static void main(String[] args) {
try {
Socket s = new Socket("localhost", 7002);
ObjectOutputStream oos = new ObjectOutputStream(s.getOutputStream());
ObjectInputStream ois = new ObjectInputStream(s.getInputStream());
oos.writeObject(new Integer(5));
oos.writeObject(new... |
218fdef5-4ed4-49da-9436-c879b70334c7 | 5 | public static void main(String[] args) {
// number of rows
final int NUM = 10;
// initialize the array
int[][] a = new int[NUM][];
for (int i = 0; i < NUM; i++) {
a[i] = new int[i + 1];
a[i][0] = 1;
a[i][i] = 1;
}
// fill in the number
for (int i = 2; i < NUM; i++)
for (int j = 1; j < i; j... |
55c5d27e-8ab1-4bf2-917e-efdb8a259ee5 | 9 | @Override
public List<ChessPosition> getPosCanMove(ChessPosition current) {
List<ChessPosition> pos = new ArrayList<ChessPosition>();
int x,y,upBound,lowBound,leftBound,rightBound,value,cy,cx;
int Tdx[] = {0,-1,1,2,2,1,-1,-2,-2} ;
int Tdy[] = {0,-2,-2,-1,1,2,2,1,-1} ;
int dx[] = {0,0,1,0,-1};
int dy[] = {0... |
627b1d6c-fbc7-4cf5-9160-55b6b5a1df96 | 7 | private void parseThreadsCode(List<String> tlines, Map<String, UserObject> name_object) {
String objId = "";
StringBuilder sb = null;
for(int i = 0; i < tlines.size(); i++) {
String line = tlines.get(i);
if(line.startsWith("[") && line.endsWith("=>")) {
objId = line.substring(line.indexOf('@') + ... |
55f002cd-9486-4e9a-81b7-eb06b3d86860 | 9 | @Override
public int hashCode() {
int result = tagName.hashCode();
result = 31 * result + (isBlock ? 1 : 0);
result = 31 * result + (formatAsBlock ? 1 : 0);
result = 31 * result + (canContainBlock ? 1 : 0);
result = 31 * result + (canContainInline ? 1 : 0);
result = 3... |
00416ccc-2137-4b45-8153-73c2996c8d9d | 7 | public void run() throws BadCharacterException, BadNumberException
{
StringBuilder numberLexeme = new StringBuilder();
int currentPos = 0;
while(currentPos < expr.length)
{
//ignore white space
if(expr[currentPos] == ' ' || expr[currentPos] == '\t' || expr[currentPos] == '\n')
{
currentPos++;
... |
819b3b61-7880-43c5-be0c-7b859b1db202 | 9 | private ShapeModel checkShape(ShapeModel model, Integer posX, Integer posY, Integer checkX, Integer checkY, String rotation) {
Position actualPosition;
Boolean found = true;
ShapeModel shape = new ShapeModel(model.length, model.height, model.score, new HashSet<Position>());
for (Position p : model.toke... |
55168758-2069-4a56-822a-2ad34c165baa | 3 | @Override
public void run() {
while (this.isRunning) {
try {
// Tell model to update, send next key press.
// or 0 if no new keypress since last update.
this.gameModel.gameUpdate(nextKeyPress());
this.view.repaint();
Thread.sleep(this.updateInterval);
} catch (GameOverException e) {
/... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.