method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
8c7c5692-8d2b-4748-9137-db20d13d6273 | 6 | public void handle(String target,Request baseRequest,HttpServletRequest request,HttpServletResponse response)
throws IOException, ServletException
{
baseRequest.setHandled(true);
String command = request.getHeader("command");
String key = request.getHeader("key");
String... |
bf1a5faf-8446-459b-8e0b-c753750b52c9 | 8 | @SuppressWarnings("unchecked")
public static void readFinishedTasks(){
ObjectInputStream inputStream = null;
ArrayList<TaskModel> obj = new ArrayList<TaskModel>();
try {
inputStream = new ObjectInputStream(new FileInputStream("FinishedCategories.ser"));
obj = null;
while((obj = (ArrayList<TaskModel... |
681c4ea3-b93e-4505-b7ef-7a315707d3dd | 2 | public void visitInnerClassType(final String name) {
if (state != CLASS_TYPE) {
throw new IllegalStateException();
}
CheckMethodAdapter.checkIdentifier(name, "inner class name");
if (sv != null) {
sv.visitInnerClassType(name);
}
} |
553987ef-81bb-4326-8d33-cf55a9e97e58 | 9 | public void run() {
firstPlayer = true;
boolean done = false;
while (!done) {
firstPlayer = true;
if (aiOne > 0 && summoner1.getStunDuration() < 0.1) {
if (aiOne > 1) {
//use Abilities or item activation
}
if (summoner1.getAutoCooldown() < 0.1) {
applyAuto(summoner1, summoner2);
}
... |
edab8480-fbd7-4a1a-9f1b-2e044b02c16e | 8 | static void string( StringBuilder a , String s ){
a.append("\"");
for(int i = 0; i < s.length(); ++i){
char c = s.charAt(i);
if (c == '\\')
a.append("\\\\");
else if(c == '"')
a.append("\\\"");
else if(c == '\n')
... |
6e4a23af-084f-40f2-9e50-f69439484b0d | 2 | public void removeElement(Element element) {
if (element == null)
throw new IllegalArgumentException("The given parameters are invalid!");
final Position elemPos = getElementPosition(element);
if (validPosition(elemPos))
getSquare(elemPos).removeElement(element);
} |
f6ddb828-1584-4486-a1f6-53864c73197c | 5 | private void update() {
final int ASCII = getSkinnable().getCharacter().isEmpty() ? 20 : getSkinnable().getCharacter().toUpperCase().charAt(0);
final String ON_STYLE = getSkinnable().getSegmentStyle().ON_CLASS;
final String OFF_STYLE = getSkinnable().getSegmentStyle().OFF_CLASS;
... |
55e02765-d203-487e-91f4-9258e4455659 | 4 | public void setSenao(List<?> list)
{
for(PComando e : this._senao_)
{
e.parent(null);
}
this._senao_.clear();
for(Object obj_e : list)
{
PComando e = (PComando) obj_e;
if(e.parent() != null)
{
e.parent()... |
52cd128a-bd14-4dc8-befe-f9c44d43965c | 6 | public boolean getBoolean(int index) throws JSONException {
Object o = get(index);
//#if CLDC!="1.0"
//# if (o.equals(Boolean.FALSE) ||
//#else
if (o.equals(JSONObject.FALSE) ||
//#endif
(o instanceof String &&
((String)o).toLowerCase().equals("false"))) {
... |
151e8a39-fe1b-4689-a3b3-92ca462f21ff | 1 | public static void main(String[] args) throws IOException {
Verzameling A = new Verzameling(20, 3);
System.out.println("Verzameling A:\n" + A + "\n");
Verzameling B = new Verzameling(20, 4);
System.out.println("Verzameling B:\n" + B + "\n");
System.out.println("A deelverzamling van B?: " + A.deelverzamelingV... |
54356f0b-4703-47c8-8eb8-5719b9d235ff | 1 | public final void setZipCode(String zipCode) {
if(zipCode.length() != 5){
throw new IllegalArgumentException();
}
this.zipCode = zipCode;
} |
b634469c-1e1b-4896-aaaa-a16f8258e14c | 3 | @Override
public void endElement(String name) {
if (bodyFlag && isPrint(name)) {
tagPos--;
for (int i=0;i<tagPos;i++){
System.out.print(" ");
}
System.out.println("</" + name + ">");
}
} |
6dac4ef8-9a60-4c95-94a5-dfdedabe22c1 | 5 | public static String standardCheck(String sequence, OrgCodonTable codonTable, Standard format){
int offset;
String codonToBeModified;
String optimalCodon;
AminoAcid aminoAcid;
// TODO only handles required restriction sites need to figure out how to work this with settings
for(int i = 0; i < format.ge... |
dced0dd2-127d-4dd6-a54c-d11109a3e169 | 6 | public Node detectCycle(Node head) {
Node slow = head;
Node fast = head;
while (fast!= null && fast.next!=null) {
slow = slow.next;
fast = fast.next.next;
if (slow == fast )
break;
}
if (fast == null || fast.next == null)
return null;
slow = head;
while(slow != fa... |
7b038c78-a68b-49ba-831d-f1fca481848b | 8 | public Response serve( String uri, String method, Properties header, Properties parms, String data )
{
try{
String response_string=null;
if(data!=null){
data=data.toUpperCase();
System.out.println(DateFormat.getTimeInstance(DateFormat.FULL).format(Calendar.getInstance().getTime()));
System.out.prin... |
d989fa23-de75-4ddb-90c2-3b987e446b25 | 6 | private void sendHandshake() throws InvalidHandshakeException {
String path;
String part1 = uri.getPath();
String part2 = uri.getQuery();
if( part1 == null || part1.length() == 0 )
path = "/";
else
path = part1;
if( part2 != null )
path += "?" + part2;
int port = getPort();
String host = uri.ge... |
a12b53ed-f020-4ab9-bdbd-e4c35d56955b | 3 | public void leaveChannel(Player p, String channelName) {
// Sanity-Check
if (!customChannel.containsKey(p.getName())) {
Messenger.tell(p, Msg.MISC_NOT_IN_CHANNEL);
} else {
/*
* To send a message to remaining channel players, we are going to get
* the channel name BEFORE removing the player, othe... |
91cf0898-8c59-467a-8241-99b22980f486 | 8 | public boolean accept(File f) {
if (f.isDirectory()) {
return true;
}
String extension = FileTools.getExtension(f);
if (extension != null) {
if (extension.equals("tiff") ||
extension.equals("tif") ||
extension.equals("gif") ||
... |
2c2cd321-229e-47a4-87ea-af7289ee4477 | 9 | private String assembleQuery(List list) {
if (list == null) {
return null;
}
StringBuffer buf = new StringBuffer();
for (int i = 0; i < list.size(); i++) {
if (i != 0) {
buf.append(QUERY_NVP_DELIM);
}
String[] pair = (String[]) list.get(i);
if (pair != null && pair.length == 2) {
St... |
e3204256-1518-4288-a616-0f4a6c162ddd | 4 | @Override
public String toString(){
String x="";
if(type==0)
x="Info:";
else if(type==1)
x="Warning:";
else if(type==2)
x="Error:";
if(LineNo>0)
x+="Line "+LineNo;
x+=" "+message+" "+extras;
return x;
... |
a3236d6f-8218-4c32-81fe-0d80b159c71e | 9 | public boolean skipPast(String to) throws JSONException {
boolean b;
char c;
int i;
int j;
int offset = 0;
int length = to.length();
char[] circle = new char[length];
/*
* First fill the circle buffer with as many characters as are in the... |
0296ad4e-1941-46dd-a731-08987f172078 | 4 | private static void merge(int data[], int temp[], int low, int middle, int high){
// pre: data[middle..high] are ascending
// temp[low..middle-1] are ascending
// post: data[low..high] contains all values in ascending order
int ri = low; // result index
int ti = low; // temp index
in... |
223a4386-19a7-42ef-8379-f787a6f6605f | 8 | private boolean isPrime(int n) {
if (n < 2) {
return false;
} else if (n == 2 || n == 3) {
return true;
} else if (n % 2 == 0 || n % 3 == 0) {
return false;
} else {
double max_divisor = Math.sqrt(n);
int divisor = 5;
... |
c542ad52-aa22-48ea-a74b-bb8909a05f88 | 8 | public String toStringSummary() {
String result;
String titles;
int resultsetLength;
int i;
int j;
if (m_NonSigWins == null)
return "-summary data not set-";
result = "";
titles = "";
resultsetLength = 1 + Math.max((int)(Math.log(getColCo... |
83a45cd1-4a64-4fa3-b2ef-2dc5414fae76 | 3 | public void printImage() throws FileNotFoundException{
FileReader fileInput;
BufferedReader fileReader;
fileInput = new FileReader("./images/"+name.toLowerCase());
fileReader = new BufferedReader(fileInput);
String line;
try {
while((line = f... |
c9c96aa1-7a24-4dd1-8451-687d61386a6e | 6 | private void createNodesInt(DefaultMutableTreeNode top) {
boolean sectionExists = false;
DefaultMutableTreeNode section = null;
DefaultMutableTreeNode slide = null;
for (int i = 1; i < SafetyNet.slideShow.getTree().size(); i++){
// Add elements to slide color based on i with default values
... |
2175f9ae-4f50-4fba-811b-d0bb0f3263d2 | 1 | public void writeBytes(byte[] b) throws IOException {
for (byte i : b)
write(i);
} |
d9da8055-e9f8-47fd-83b5-255510198bbd | 8 | public static void htmlDescribeRules(String title, String head, LogicObject relation, org.powerloom.PrintableStringWriter stream, boolean ruleP) {
{ Cons rules = edu.isi.powerloom.PLI.getRules(relation, null, null).consify();
boolean ruleWrittenP = false;
OntosaurusUtil.htmlWriteHeaderWithTable(stream,... |
366c7229-f1ed-48ea-956d-181fdefc906c | 1 | public void addBuffers(GameAction action) {
if (!buffers.contains(action)) {
this.buffers.add(action);
}
} |
8edd6b39-7811-4a89-84c2-96d0297fdb84 | 7 | public static void testValidity(Object o) throws JSONException {
if (o != null) {
if (o instanceof Double) {
if (((Double) o).isInfinite() || ((Double) o).isNaN()) {
throw new JSONException(
"JSON does not allow non-finite numbers.");
... |
722beab8-d0c3-48c1-80a9-0aa6077f5612 | 4 | private boolean forbiddenNeighbourhood(Hero hero, int x, int y)
{
Hero other;
for (int i=-1; i<=1; ++i) {
for (int j=-1; j<=1; ++j) {
other = (Hero)p2h.get(x+i, y+j);
if (other != null && other.getColor() != hero.getColor()) {
return true;
}
}
}
return false;
} |
eb0ead25-6443-47f7-b47d-ee493e501969 | 5 | private void dropItems(World world, int x, int y, int z)
{
Random random = new Random();
TileEntity te = world.getTileEntity(x, y, z);
if (!(te instanceof IInventory))
return;
IInventory inventory = (IInventory) te;
for (int i = 0; i < inventory.getSizeInventor... |
dad36a39-36f1-4059-b0ec-2abe882c94b4 | 1 | public void write2bytes(long n) throws IOException {
long b0 = n & 0xff;
long b1 = (n & 0xff00) >> 8;
if (le) {
write(b0); write(b1);
} else {
write(b1); write(b0);
}
} |
5c50feda-f9a2-4a81-bd5f-d95027077d62 | 0 | public String getName() {
return name;
} |
90e20060-be9d-477b-bd45-062ee54cf80d | 6 | public void buildFrame() {
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
try {
SPClient spClient = client;
client.getChatroom().logout(spClient);
} catch (RemoteException e1) {
e1.printStackTrace();
}
}
});
mainPanel = new JPanel(new Bord... |
91e17361-0514-491f-b5ea-1d6b3edfbe5c | 2 | @Override
public void actionPerformed(JTable table)
{
if (table != null)
{
final MediaElement[] selected = getSelected(table);
boolean toSet = !selected[0].getSeen();
for (MediaElement mediaElement : selected)
mediaElement.setSeen(toSet);
}
else
media.toggleSeen();
... |
4b351ac6-15fc-4910-8da8-7794bf6e3019 | 0 | Ex4() {
super(11);
System.out.println("Ex4 constructor");
} |
5a985356-0c88-430e-a6de-6b7a551681ef | 2 | @Override
public Response download(DownloadFileRequest request) throws IOException {
DownloadTicket ticket = request.getTicket();
File file = new File(dir+"/"+ticket.getFilename());
if(ChecksumUtils.verifyChecksum(ticket.getUsername(), file, 1, ticket.getChecksum())) {
byte[] data = FileUtils.readFile(dir,tic... |
5dffd3b0-01d7-468c-bd39-1fcf0b02010b | 4 | private void stopPosition() {
StreamsterApiInterfaceProxy proxy = new StreamsterApiInterfaceProxy();
Position[] positions = new Position[0];
try {
positions = proxy.getPositions();
} catch (RemoteException ex) {
Logger.getLogger(JobTradeUp.class.getName()).log(Lev... |
aff51171-838d-44a8-9105-2a5f21356542 | 3 | public ArrayList<String> getOximata(){
/*
* epistefei ta oxhmata ths vashs
*/
ArrayList<String> oximata=new ArrayList<String>();
try {
pS = conn.prepareStatement("SELECT * FROM oximata");
rs=pS.executeQuery();
while(rs.next())
oximata.add(rs.getString("id"));
} catch (SQLException e) {
e.p... |
5e41ee83-e0ca-4de2-bdb7-26bc54afdfa3 | 2 | public void visitAttribute(final Attribute attr) {
buf.setLength(0);
buf.append(tab).append("ATTRIBUTE ");
appendDescriptor(-1, attr.type);
if (attr instanceof Traceable) {
((Traceable) attr).trace(buf, labelNames);
} else {
buf.append(" : unknown\n");
}
text.add(buf.toString());
if (mv != null)... |
961e66f3-ddd5-4fea-a734-5b70f0cb8e21 | 8 | public boolean equals(Object o) {
if (o == this)
return true;
if (o instanceof Type && ((Type) o).typecode == TC_CLASS) {
ClassInterfacesType type = (ClassInterfacesType) o;
if (type.clazz == clazz && type.ifaces.length == ifaces.length) {
big_loop: for (int i = 0; i < type.ifaces.length; i++) {
f... |
6ec08472-00ad-45f8-ab41-629eaba7e6f7 | 6 | public ICodec getInstance()
{
if( iCodecClass == null )
return null;
Object o = null;
try
{
o = iCodecClass.newInstance();
}
catch( InstantiationException ie )
{
instantiationErro... |
3893367c-2640-44d2-9992-016f2f4b9d65 | 2 | @Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((_first == null) ? 0 : _first.hashCode());
result = prime * result + ((_second == null) ? 0 : _second.hashCode());
return result;
} |
89176664-c084-48af-9c37-dca1c563223b | 8 | private void padNetworkCommand ( Grid grid, CommandSender sender, Pad pad, String[] args ) {
// First things first, make sure that we can modify the network properties of any pad.
if ( !sender.hasPermission( "grid.pad.network.modify" ) ) {
sender.sendMessage(Grid.getChatPrefix() + "You do not have permission ... |
c05afc7f-1f58-4941-81e9-878cd95a30f9 | 7 | public int solution(final int[] input) {
final int N = input.length;
int candidate = 0;
int candidateIndex = -1;
int candidateOccurrences = 0;
for (int i = 0; i < N; i++) {
final int value = input[i];
if (candidateOccurrences ... |
f39c9dee-6aa3-4b02-806c-6a2c9359426a | 1 | public static boolean hasSelectedTray(Tray tray) {
if (tray == null) return false;
return StorageUnitDisplayPanel.selectedTrays.contains(tray);
} |
d89c2b7a-f537-4e0f-be39-892c2d76fc9f | 8 | final public void groupedCompareEquation() throws ParseException {
/*@bgen(jjtree) groupedCompareEquation */
SimpleNode jjtn000 = new SimpleNode(JJTGROUPEDCOMPAREEQUATION);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
jjtn000.jjtSetFirstToken(getToken(1));
try {
... |
a17be5c1-9452-4491-8f16-087052df4ac1 | 9 | private void checkCredentials(){
view.setEnabled(false);
LoginDao dao = new LoginDaoSQL();
try {
int type = view.getType();
String username = view.getUsername();
String password = view.getPassword();
if(username == null || username.trim().length() < 3)
throw new LoginException(1);
if... |
5b82962d-c6f0-4641-9bd9-151d27b4f79b | 5 | private static int distributeGrow(int amt, int[] values, int[] max) {
// Copy the values and sort them from smallest to largest
int[] order = new int[values.length];
System.arraycopy(values, 0, order, 0, values.length);
Arrays.sort(order);
// Find the next-to-smallest
int pos = 1;
while (pos < values.len... |
12c6937f-85f4-4f7c-8ca0-10ac9cfc7e96 | 7 | @Override
public void keyPressed(final KeyEvent keyEvent)
{
if (this.clavierDisponible) {
// blocage du clavier afin de le rendre inactif.
this.clavierDisponible = false;
final int code = keyEvent.getKeyCode();
if (code >= KeyEvent.VK_LEFT && code <= KeyEvent.VK_DOWN) {
int dx = 0;
int dy = 0;... |
f1fd777b-0bd0-4dd9-b4f6-49426034aae8 | 0 | public void markForDelete() {
this.markedForDelete = true;
} |
03f9f1e8-9c60-465f-9d9f-ae9e9081a123 | 6 | public static void main(String[] args) throws Exception {
final Pool<Fat> pool = new Pool<Fat>(Fat.class, SIZE);
ExecutorService exec = Executors.newCachedThreadPool();
for (int i = 0; i < SIZE; i++)
exec.execute(new CheckoutTask<Fat>(pool));
print("All CheckoutTasks created");
List<Fat> list = new ArrayList<... |
8600970f-2e01-4584-a404-9060007ff550 | 7 | public static void main(String args[]) {
// The default port number.
int portNumber = 2222;
if (args.length < 1) {
System.out.println("Usage: java MultiThreadChatServerSync <portNumber>\n"
+ "Now using port number=" + portNumber);
} else {
portNumber = Integer.valueOf(args[0]).int... |
6c554b42-35c6-4800-a95e-bdfde2b09140 | 1 | private int evalState(State s) {
// int diff = s.getnRed() - s.getnBlue();
int diff = (int)(((float)s.getnRed() - (float)getTotalAdjacentBlank(s,"red")/9)
- ((float)s.getnBlue() - (float)getTotalAdjacentBlank(s,"blue")/9));
if (me.equals("red")) {
return diff;
}
return -diff;
} |
cc45f3f7-08a6-44cc-9175-c8f4bfb6d920 | 0 | public String getOpenFileFormat() {
return (String) openFormatComboBox.getSelectedItem();
} |
8a1cf2af-0a38-4d29-82ca-b253539c8731 | 9 | private static void f(String s1, String s2, boolean[] b, char c, String str){
// System.out.print(str);
while (true){
boolean flag = true;
for (int i = 0 ; i < s1.length();i++){
if (b[i]== true) {
if (s1.charAt(i) == c){
char c_backup = c;
str += c;
c = s2.charAt(i);
... |
683e08a6-5450-493f-9e9b-4941895e8358 | 1 | public void setAjastus(){
int minuuttia = 0;
try { //vaatisi varmaan refaktorointia tämä metodi...
minuuttia = Integer.parseInt(minuuttimaara.getText());
ajastin.ajasta(minuuttia);
ajastin.lisaaUusiOpiskelu(mitaOpiskelet.getText(), minuuttia);
ok.setText("... |
cac634f0-cf68-4d16-8ea8-5458e8764874 | 5 | public static void test1()
{
try {
String databaseName = "mytest";
MySQLIdentity mytestAtMytest = MySQLService.createMyIdentity("localhost",databaseName, "mytest", "password");
MySQLService.createConnectionPool(mytestAtMytest);
for(int i = 0; i < 1000; ++i) {
IMySQLConnection conn = MySQLService.getC... |
4fdbbf2d-c9f9-4499-a858-5cebd077bea5 | 8 | protected void draw(Graphics2D g)
{
Vector.d.viewPort.x = x;
Vector.d.viewPort.y = y;
if (dead)
{
System.out.println("Player is dead!");
new TimedLevelReset(1500);
spawnDeathParticles(20);
return;
}
if (checkHitBullet())
{
dead = true;
}
g.setColor(Color.RED);
g.fillOval(x - radiu... |
b6501e5c-674c-4885-87be-42ec688c541d | 6 | public N getLowerNode(T payload)
{
N p = m_root;
while (p != null)
{
int cmp = compare(payload, p.getPayload());
if (cmp > 0)
{
if (p.getRight() != null)
p = p.getRight();
else
return p;
}
else
{
if (p.getLeft() != null)
... |
b63e5a32-97c1-498c-9b10-2f4b36347437 | 1 | public boolean isBossOnStatus() {
if(frame == null) buildGUI();
return bossStatus.isSelected();
} |
bd696ec9-b3cd-4f61-9e84-48134d1fbb6a | 7 | public boolean onItemUse(ItemStack var1, EntityPlayer var2, World var3, int var4, int var5, int var6, int var7) {
if(var7 == 0) {
--var5;
}
if(var7 == 1) {
++var5;
}
if(var7 == 2) {
--var6;
}
if(var7 == 3) {
++var6;
}
if(var7 ... |
07da5dbf-8c5f-441b-bddb-c0801a21d247 | 2 | private void blockedCheck(double x, double y) {
// AI shouldn't run through portals
// TODO this failed once
if(gameObject.isBlocked(x, y) || gameObject.isBeingPortaled(x, y)){
blocked();
}
} |
d6ef64be-0d02-4c8b-91f5-9a6bbfbc5d42 | 1 | private void restForAWhile() {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
} |
48e50ec9-33ff-4adb-be68-46e3d2441bba | 0 | @Test
public void virheellinenFormaattiPisteKonstruktoriTapausA() {
Este s = new Este(new Piste(200, 200), new Piste(100, 100));
Este r = new Este(100, 100, 200, 200);
assertTrue("Este ei muuttanut kulmia oikeiksi. " + s.toString(),
s.toString().equals(r.toString()));
} |
b841e730-bc71-47d3-97a9-82a21ed401bd | 8 | public static void jugar() throws ExcepcioJocRol{
if(Inventari.qJugadorsVius() < 2){throw new excInsuficientPlayers();}
ArrayList<Player> players = Inventari.getJugadors();
boolean error;
do{
for(Player p: players){
if(p.isDead()){continue;}//Si el player esta... |
d2fa92df-e644-4a41-b596-443895ca833c | 8 | public void start() {
connectionController = new Thread(new Runnable() {
@Override
public void run() {
String serverURL = BmUrlManager.getServerUrl();
ServerStatus latestServerStatus = serverStatus;
try {
URL url = new ... |
977871ab-5a0d-4b0c-b773-8409b037509c | 0 | public String getEmail()
{
return EMAIL;
} |
9c883c3f-8b33-47ae-a280-255b7ff8c63e | 9 | public void update(float delta) {
if (generateNewLevel)
generate(currentLevel);
if (startTime <= 0) {
startTime = System.currentTimeMillis();
}
if (lives <= 0)
gameover = true;
for (int i = 0; i < entities.size(); i++) {
entities.get(i).update(delta, this);
}
for (SwitchGate sg : switchGates) ... |
e1bcbd0e-a325-405b-b9e3-956058fc6b5e | 8 | private boolean validateKeyEvent(boolean isTextArea, Event event) {
int evtType = DOM.eventGetType(event);
int keyCode;
boolean shiftPressed;
if (evtType == Event.ONKEYDOWN) {
shiftPressed = DOM.eventGetShiftKey(event);
keyCode = DOM.eventGetKeyCode(event);
if ( ( (keyC... |
84c40353-c2c6-454e-adf8-48eb578802a4 | 4 | private void luoNoppaKomponentit() {
noppanapit = new ArrayList<>();
noppapanel = new JPanel();
noppapanel.setBorder(new BevelBorder(0));
int a;
if(heittely.getNopat().size() < 16){
GridLayout gl = new GridLayout(3, 5);
noppapanel.setLayout(gl);
... |
1fc704e8-f2f6-4d8d-81a5-8bb492759507 | 0 | public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setDaemon(true);
return t;
} |
b95ff474-6c4d-4d55-85ce-832c1a30d455 | 5 | public ArrayList<Integer> inorderTraversal(TreeNode root) {
ArrayList<Integer> result = new ArrayList<Integer>();
if( root == null ) return result;
Deque<TreeNode> stack = new ArrayDeque<TreeNode>();
Set<TreeNode> set = new HashSet<TreeNode>(); // visited set
stack.push( root )... |
386626f3-d34b-41da-9332-e2c164439e22 | 2 | @Override
public void layoutContainer(Container scrollbarContainer) {
JScrollBar scrollbar = (JScrollBar) scrollbarContainer;
switch (scrollbar.getOrientation()) {
case JScrollBar.VERTICAL:
layoutVScrollbar(scrollbar);
break;
case JScrollBar.HORIZONTAL:
layoutHScrollbar(scrollbar);... |
40a93aa0-24ea-46cd-86c4-b82c289de638 | 8 | private char[] build_key_alphabet(String k)
{
//I/J and W/X combined
char[] result=new char[24];
String k_u=k.toUpperCase();
boolean[] filled=new boolean[26];
int cur_pos=0;
for(int i=0;i<k_u.length();i++)
{
char cur_c=k_u.charAt(i);
if(cur_c=='J')
{
cur_c='I';
}
if(cur_c=='X')
{
... |
f36d21ae-c472-4768-9662-bf11455134cb | 7 | private void initStatusTileFontMenu(Color bg) {
this.statustextTilePanel = new JPanel();
this.statustextTilePanel.setBackground(bg);
this.statustextTilePanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
String initFontTmp = this.skin.getStatustextZoomedFont();
int init... |
ecdd1bf7-c3e4-4363-9df6-b8921b0d705a | 5 | public static String randomUID()
{
byte[] bytes = new byte[16];
rand.nextBytes(bytes);
StringBuilder ret = new StringBuilder();
for (int i = 0; i < bytes.length; i++)
{
if (i == 4 || i == 6 || i == 8 || i == 10)
ret.append('-');
ret.append(String.format("%02X", bytes[i]));
}
return ret.toStri... |
2ba1d80a-dce5-4f66-b2e4-1c0ce18f31c3 | 7 | @Override
public int setRandomImageIndex() {
int percent = rand.nextInt(100);
if (percent >= 32)
return 0;
else if (percent < 32 && percent >= 24)
return 1;
else if (percent < 24 && percent >= 16)
return 2;
else if (percent < 16 && percent >= 8)
return 3;
else
return 4;
} |
02b4d239-86e4-41d3-a34b-1cb4f22426d3 | 5 | @Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("promoteguard")){
if (!(sender instanceof Player)) { // If sender isn't a player send message and fail
sender.sendMessage("This command can Only be run by a player");
... |
21cf908a-b246-460b-9f83-c0bd6ca68aac | 9 | public TypeKind getPrimitiveTypeKind() {
switch (typetag) {
case TypeTags.BOOLEAN:
return TypeKind.BOOLEAN;
case TypeTags.BYTE:
return TypeKind.BYTE;
case TypeTags.SHORT:
return TypeKind.SHORT;
case TypeTags.INT:... |
e23e1090-cc28-4a6d-a2b4-ca9a5bac4d88 | 1 | @Test
public void transferInstrSTORE_testInvalidMemoryRef() { //Checks STORE instruction not created with invalid memory ref.
try {
instr = new TransferInstr(Opcode.STORE, 100, 1);
}
catch (IllegalStateException e) {
System.out.println(e.getMessage());
}
assertNull(instr);
} |
53209880-f38a-4ca0-8404-60bb9e7516e5 | 4 | @EventHandler(priority = EventPriority.LOWEST)
public void onBlockPlace(BlockPlaceEvent event) {
Database db = new Database();
// Get the block
Block b = event.getBlock();
Player p = event.getPlayer();
int playerId;
World w = b.getWorld();
int worldId = 1;... |
02910419-e020-4abf-ab2e-52fbb08caa5f | 7 | private void loadTags(String appId) throws RemoteException{
((DefaultListModel) this.myApplicationsAppMyTagsList.getModel()).clear();
//Get and render public tags
String[] publicTags = this.model.getPublicTags(appId);
if(publicTags!=null)
for(int i=0; i<publicTags.length; i++)
{
TagListItem tagI... |
08297a7a-6a84-4f8b-bed4-fd55a40384eb | 5 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Individual other = (Individual) obj;
if (this.genom != other.genom && (this.genom == null || !this.genom.equals(other.genom))) {
return f... |
c2b75c42-3532-41fc-b46a-593b5d2a7dd9 | 9 | private void calculateDistances(Position position) {
Queue<Position> positionsToProcess = new ArrayDeque<>();
distance = new int[map.getWidth()][map.getHeight()];
boolean[][] checked = new boolean[distance.length][distance[0].length];
for (int i = 0; i < distance.length; i++)
... |
e9fce4c1-ce75-4de7-abeb-cbe138c5fb04 | 7 | private void checkBeforeInvoke(int pcount, Object params) throws IllegalArgumentException {
if (pcount == 0) {
if (params != null) {
throw new IllegalArgumentException(
"The number of parameters in the command is 0," +
"but the params isn't null.");
}
}
el... |
1051825d-c981-4482-bcad-2ac3ecb1b4cc | 7 | public String getColor(ColorID color){
String clr;
switch(color){
case BLUE:
clr = "blue";
break;
case RED:
clr = "red";
break;
case ORANGE:
clr = "orange";
break;
... |
0238e9f7-e68f-49e4-b37e-a364f6a970ef | 2 | private int readOneChar() {
try {
if (oReader.ready())
return oReader.read();
else
return tError;
} catch (IOException e) {
return tError;
}
} |
e75817c1-647d-44be-b7a0-2fa521c45630 | 8 | public void subscribe(Class messageType, String fields) throws IOException {
if (! KismetMessage.class.isAssignableFrom(messageType)) {
throw new IllegalArgumentException("invalid message type: must implement KismetMessage interface");
}
Protocol protocol = (Protocol) messag... |
5881e9ff-3688-4b6a-b7c8-c75d9c9a7d61 | 8 | public static int findKthLargestSub(int[] nums, int start, int end, int k) {
int pivot = start;
int left = start;
int right = end;
while (left <= right) {
while (left <= right && nums[left] <= nums[pivot]) left++;
while (left <= right && nums[pivot] <= nums[right]) right--;
if(left < r... |
cb32058b-498c-4f8e-9042-7fdb77184881 | 4 | private boolean isPointLegal(int[] p) {
if (0 <= p[0] && p[0] < m.width
&& 0 <= p[1] && p[1] < m.height) {
return true;
}
return false;
} |
8d834512-7677-4f87-824e-751d41fde39a | 5 | public Writer write(Writer writer) throws JSONException {
try {
boolean b = false;
int len = length();
writer.write('[');
for (int i = 0; i < len; i += 1) {
if (b) {
writer.write(',');
}
Obj... |
3f0c4e44-cab0-479d-a2d3-ffe53da4a405 | 2 | public Object trapFieldRead(String name) {
Class jc = getClassMetaobject().getJavaClass();
try {
return jc.getField(name).get(getObject());
}
catch (NoSuchFieldException e) {
throw new RuntimeException(e.toString());
}
catch (IllegalAccessException... |
e0d2cead-09d3-434f-ae3c-aca48115a08c | 2 | public Object open() {
createContents();
UI.centerShell(getParent(), shell);
shell.open();
shell.layout();
Display display = getParent().getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return result;
} |
da410b8d-2033-4741-bdf1-546bb53f7cd8 | 6 | @Override
public void sequence(String id, String sequence, String quality) {
if ((sequence == null) || (sequence.length() == 0)) {
if (behavior == EmptySequenceBehaviour.WRITE) {
sequence = "";
quality = "";
} else if (behavior == EmptySequenceBehaviour.SKIP) {
return;
}
}
try {
writer.... |
4f479509-2f88-42fc-9508-ec09eb4e465a | 6 | private void substituteVar(Variable v, Variable newV){
// Goes throw each predicate in addList substituting the variable "v" by "newV"
for(int j = 0; j < addList.size(); j++){
Predicate p = addList.get(j);
addList.remove(j);
int pos = p.hasVariable(v);
if(pos != -1){
p.replaceVariable(newV, pos);
... |
5c1605a0-9782-4445-9641-bb61d70db0f8 | 2 | private String buildFormatCommand(Object obj) {
String command = getBasicFormatCommand(obj);
if (precise) {
command = SubLAPIHelper.makeSubLStmt(WITH_PRECISE_PARAPHRASE_ON,
new SubLAPIHelper.AsIsTerm(command));
}
//by default, don't emit links in generated NL.
if (getMode().equal... |
4ad3f68f-c34f-46ce-a9c8-215ca1ac1bab | 8 | private Cell getTopLeftNeighbour(int i, int j) {
Cell cell = null;
if (i > 0 && j > 0)
cell = cells[i - 1][j - 1];
else if (i == 0 && j > 0)
cell = cells[Game.CELLS_COUNT - 1][j - 1];
else if (i > 0 && j == 0)
cell = cells[i - 1][Game.CELLS_COUNT - 1];... |
4a3668ab-6add-4f85-bf98-6eabebb32f47 | 5 | private static void updateStringColumn(CyNetwork network, CyIdentifiable cyId,
String columnName, List<CDDFeature> features) {
List<String> dataList = new ArrayList<String>();
for (CDDFeature feature: features) {
if (columnName.equals(CDD_FEATURE))
dataList.add(feature... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.