method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
7a3e03ae-17dd-4838-a6aa-912a429e6d60 | 7 | private final void encode(final ByteArrayBuffer fb, final char c) {
if (c < 0x80) {
fb.append((byte) c);
} else if (c < 0x800) {
fb.append((byte) (0xc0 | c >> 6));
fb.append((byte) (0x80 | c & 0x3f));
} else if(c < 0xD800){
fb.append((byte) (0xe0 |... |
9f7d7d35-2925-421f-bae2-189e3be92334 | 2 | @Override
public String toString() {
StringBuffer info = new StringBuffer();
info.append("Layer Name :: ").append(getName()).append("\n");
info.append("logical Queue : ").append(logicalQueue).append("\n");
info.append("Draw List : ").append(drawableList);
// Output drawable
info.append(drawableList.size()... |
1bf6b2c5-c9a2-440c-8d7b-e65666134ed0 | 9 | private void load() {
String packageName = "Exercises";
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
ArrayList<String> names = new ArrayList<String>();
URL packageURL = classLoader.getResource(packageName);
if (packageURL != null) {
File folder = new File(packageURL.getFile().r... |
28262f04-54e5-43f2-8941-7d367ac45fdc | 8 | public void adjustRGB(int adjustmentR, int adjustmentG, int adjustmentB) {
for (int pixel = 0; pixel < pixels.length; pixel++) {
int originalColour = pixels[pixel];
if (originalColour != 0) {
int red = originalColour >> 16 & 0xff;
red += adjustmentR;
if (red < 1)
red = 1;
else if (red > 255... |
2c3fda60-03ca-4bed-afd7-a946b275adc9 | 2 | private void reloadMode(ModeEnum myMode) {
String[] modes = comboMode.getItems();
String label = myMode.getLabel();
for (int index = 0; index < modes.length; index++) {
if (label.equals(modes[index])) {
comboMode.select(index);
break;
}
... |
b758f8d0-fa2a-4183-84fb-1da7e7c4678b | 8 | private void dessineCamembert(Noeud n, Graphics g,
HashMap<String, Color[]> historique, DrawStrategy strategy,
Color couleur_demande) {
// on dessine le noeud de destination
// differement selon la strategie defini
if (strategy == DrawStrategy.LAST_WIN) {
// Si la strategy est LAST_WIN, il suffit
// d... |
1c80639c-a53e-4f09-9adf-b30defbaf271 | 1 | public int getInt() {
String textv = ((TextEntry)wdg()).text;
try{
Integer ival = Integer.parseInt(textv);
return ival.intValue();
}
catch(NumberFormatException e){
return 0;
}
} |
c51e1771-bade-4d42-8f71-1656da87e1ca | 4 | public static void filledRectangle(double x, double y, double halfWidth, double halfHeight) {
if (halfWidth < 0) throw new IllegalArgumentException("half width must be nonnegative");
if (halfHeight < 0) throw new IllegalArgumentException("half height must be nonnegative");
double xs = scaleX(x)... |
cf7b31c0-8a9b-4d9a-aca8-c9b699cc38ef | 0 | public String execute() {
return "SUCCESS";
} |
0fd78d60-cf48-4617-9c17-b8bbf5da04f3 | 1 | public Connection(Socket socket) throws java.io.IOException{
this.socket = socket;
if (socket!=null) {
setInputStream(socket.getInputStream());
setOutputStream(socket.getOutputStream());
}
} |
ffebafd1-a58c-471f-acf4-3980a11c1c14 | 1 | protected static String processEmphasis(String text) {
String[] arr = text.split("\\|");
if (arr.length == 2) {
return "<span class=\"emphasis\">" + arr[1] + "</span>";
}
return "<span class=\"emphasis\">" + arr[1] + "</span><span class=\"afterEmphasis\">" + arr[2] + "</span>... |
1412117d-5251-487e-a8ff-c15bc1e74ba7 | 7 | Power(String name, int properties, String imgFile, String helpInfo) {
this.name = name ;
this.helpInfo = helpInfo ;
this.buttonTex = Texture.loadTexture(IMG_DIR+imgFile) ;
this.properties = properties ;
} |
f7d65c75-a994-432d-8924-a09bbbc0afa3 | 2 | public int swapOddAndEvenBit(int origNum){
int resultNum = 0;
//make a new Num with origNum shift right by 1;
System.out.println("origNum="+origNum);
int shiftedNum = origNum >> 1;
System.out.println("shiftedRight="+shiftedNum);
//XOR origNum and shiftedNum, then bit 0 would be XOR of bit(0,1), bit 1 =... |
40173fdd-ac99-4087-8f94-c1f61be45047 | 2 | public boolean hasIntArg() {
try{
String s = peek();
if(s.isEmpty()) {
return false;
} else {
Integer.valueOf(s);
}
} catch(NumberFormatException e) {
return false;
}
return true;
} |
5679a89f-b89c-4b20-aeb3-32349f37af4c | 5 | public IVPNumber divide(IVPNumber number, Context context, DataFactory factory, HashMap map) {
IVPNumber result = factory.createIVPNumber();
map.put(result.getUniqueID(), result);
if(getValueType().equals(IVPValue.INTEGER_TYPE) && number.getValueType().equals(IVPValue.INTEGER_TYPE)){
int resultInt = context.ge... |
a73de40c-c2b0-4c51-bc32-2c386d5ae234 | 8 | public static Direction flip_x_dir(Direction d) {
switch (d) {
case NW:
return NE;
case W:
return E;
case SW:
return SE;
case N:
return N;
case S:
return S;
cas... |
a71719eb-26b1-4401-a0b6-de9e429103e5 | 9 | public void copyAsRtf() {
int selStart = getSelectionStart();
int selEnd = getSelectionEnd();
if (selStart==selEnd) {
return;
}
// Make sure there is a system clipboard, and that we can write
// to it.
SecurityManager sm = System.getSecurityManager();
if (sm!=null) {
try {
sm.checkSystemClip... |
facea919-7019-457f-872d-83247034e744 | 0 | public void setCode_sec(String code_sec) {
this.code_sec = code_sec;
} |
91f385a2-0659-4b27-96fd-d26b460c83ec | 4 | @Override
public void mouseReleased(MouseEvent event) {
if (mSortColumn != null) {
if (mSortColumn == mOwner.overColumn(event.getX())) {
if (mOwner.isUserSortable()) {
boolean sortAscending = mSortColumn.isSortAscending();
if (mSortColumn.getSortSequence() != -1) {
sortAscending = !sortAscendi... |
28de82e6-ce74-42c0-87c5-698fc9ce6404 | 3 | public boolean contains(Point p) {
Point p0 = this.getXY();
int s2 = this.getParent().getConnectorSize() / 2;
return (p.x >= p0.x - s2 && p.x <= p0.x + s2 && p.y >= p0.y - s2 && p.y <= p0.y
+ s2);
} |
98180723-8690-4259-912d-a8d0f10f86cd | 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... |
837cffbd-f5c2-485b-b00e-f82a0ebc24a0 | 2 | public static void add(Record rec, User user, int score) throws SQLException
{
if (rec != null && user != null)
{
String sql = "INSERT INTO score_history (record_id,user_id,score_date,score_value) VALUES (?,?,now(),?)";
PreparedStatement ps = Connect.getConnection().getPreparedStatemen... |
0f234f0e-d82f-4891-8caf-00a49e82540f | 6 | public Boolean isWellFormed(String strParentheses) {
if (strParentheses == null) {
return false;
}
// Idea is to have two counters, one for open parentheses '{' and one
// for close '}'
// Read one character at a time and increment one of the counters
// If any given point of time count of close parenthe... |
9086f705-f385-4b23-bf41-58d30bc2c8e1 | 4 | protected Batch <String> descOngoingUpgrades() {
final Batch <String> desc = new Batch <String> () ;
if (upgrades == null) return desc ;
for (int i = 0 ; i < upgrades.length ; i++) {
if (upgrades[i] == null || upgradeStates[i] == STATE_INTACT) continue ;
desc.add(upgrades[i].name+" ("+STATE_DESC... |
d4025667-3bb4-4be6-bd83-0c36291f08b1 | 9 | * @param mes the messsage
*/
private void handleMONOPOLYPICK(StringConnection c, MonopolyPick mes)
{
if (c != null)
{
Game ga = gameList.getGameData(mes.getGame());
if (ga != null)
{
ga.takeMonitor();
try
... |
470cfd2b-7987-434b-9af3-4a73c38c0320 | 1 | public static void renderButton(Graphics g, Rectangle r, String s)
{
if(r.contains(Main.mse))
{
g.drawImage(Button2, r.x, r.y, r.width, r.height, null);
}
else
{
g.drawImage(Button1, r.x, r.y, r.width, r.height, null);
}
g.setFont(new Font(Font.SANS_SERIF, (int)(r.height/1.75), (int)(r.height/1.75)... |
9b4b02d9-9afd-4f7f-bfb4-dad937b634bd | 4 | public void setAttribute(String asName, String asVal, boolean abMultiAttr) {
if (UtilityMethods.isValidString(asName) && UtilityMethods.isValidString(asName)) {
if (abMultiAttr) {
getAttrList().add(new Attribute(asName, asVal));
} else {
Attribute laAttr =... |
99b929e4-4dd9-46a6-a374-aac0ff89b71b | 2 | public static void main(String[] args) {
ShopifyService service = new ShopifyService();
String url ="https://0f99730e50a2493463d263f6f6003622:1a27610dee9600dd8366bf76d90b5589@shopatmyspace.myshopify.com/admin/customers.json";
try{
final HttpClientContext context = HttpClientContext.create();
Closeable... |
f314c567-6052-4692-8570-c7224a7bf6c4 | 7 | protected void landingOn(PlayerClass pPlayer)
{
this.victim = pPlayer;
if(this.owned == true && this.currentOwner == pPlayer && ownsAllColours() == true) // If you own your own property, you can upgrade.
{
buyMenu();
}
if(this.owned == false && pPlayer.account.getBalance() >= this.buyPrice) // If not owned,... |
73b7e22c-9a01-4f46-84dc-540e953644b2 | 1 | @Override
public void setSelected( Selection selection ) {
super.setSelected( selection );
connection.updateSelection();
ItemSelectionEvent event = new ItemSelectionEvent( connection, selection );
for( ItemSelectionListener listener : listeners()){
listener.itemSelectionChanged( event );
}
} |
4e4120ae-3f81-47c4-a2b5-8522e39a136c | 1 | private String options() {
String options = "";
int commandNumber = 1;
for (Command command : commands){
options += commandNumber++ + ") " + command.name() + "\n";
}
return options;
} |
895d03d1-8d6c-4775-b1e3-a2861d4fb126 | 7 | public Object nextValue() throws JSONException {
char c = this.nextClean();
String string;
switch (c) {
case '"':
case '\'':
return this.nextString(c);
case '{':
this.back();
return new JSONObject(this);
... |
f138dae7-a103-4dd1-97c2-5337adce98de | 3 | @Override
public String toString() {
String result = "[";
int i = 0;
while (i < capacity) {
if (queue[i] != null) {
result += queue[i] + ", ";
}
i++;
}
if (result.length() > 2) {
result = result.substring(0, result.length() - 2);
}
result += "]";
return result;
} |
51085705-3e2d-44c0-8a49-543792b1ab2c | 0 | public static void createIcons() {
// Create a buffered image from the is not property image.
Image isNotPropertyImage = ICON_IS_NOT_PROPERTY.getImage();
BufferedImage isNotImage = new BufferedImage(TRUE_WIDTH, BUTTON_HEIGHT, BufferedImage.TYPE_INT_ARGB);
Graphics2D gIsNotImage = isNotImage.createGraphics();
... |
5af581de-0ee6-4724-ad72-325713f39cf0 | 3 | private final static long getDays(long year) {
final Long entry = Time.daysSince1970.get(year);
if (entry != null) {
return entry;
}
long days = 0;
for (long y = 1970; y < year; ++y) {
final boolean leap = isLeap(y);
if (leap) {
days += 366;
} else {
days += 365;
}
}
Time.daysSince1... |
de50b2b7-6185-4c7e-bbab-e36c9b2862cd | 5 | protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out) {
CoderResult result;
while (true) {
// output buffered data
if (buf.hasRemaining()) {
result = super.decodeLoop(buf,out);
// stop if out of output space or err... |
1ae1b861-0067-4208-8eb0-afc193c315ac | 8 | protected void pasteBufferedComponent(int x, int y) {
if (pasteBuffer instanceof ImageComponent) {
ImageComponent ic = null;
try {
ic = new ImageComponent(((ImageComponent) pasteBuffer).toString());
} catch (Exception e) {
e.printStackTrace();
return;
}
ic.setLocation(x, y);
addLayeredCo... |
b1066bce-4809-4f9d-813a-b92df8ef1efb | 7 | public void actionPerformed(ActionEvent e) {
this.setCmd(e.getActionCommand());
if (isCmd("debugmode")) {
if (this.getInfo().chckbxDebug.isSelected()) {
this.getCore().settings.set(this.getCore().showDebug, "true");
} else {
this.getCore().settings.set(this.getCore().showDebug, "false");
}
... |
513f4f65-6434-4eba-91ae-bed3151d9248 | 6 | public void loadMapFromFile(File selFile) {
BufferedReader csvReader = null;
try {
csvReader = new BufferedReader(new FileReader(selFile));
} catch (FileNotFoundException ex) {
ex.printStackTrace();
}
int fieldCount = 0;
int lineCount = 0;
... |
79373180-1bbf-436d-900c-4dfe86cc32b5 | 3 | @Override
public double getWidth() {
double width = 0;
double x = getX();
double temp = 0;
ModelSubset[] subs = getAnimatedModel().getSubsets();
for (int i = 0; i < subs.length; i++) {
for (int j = 0; j < subs[i].getVertices().length; j++) {
temp = subs[i].getVertices()[j].getX() - x;
Math.abs(tem... |
4aca28bc-f034-49d9-9a95-cc8b607039a8 | 9 | private synchronized IndexReader doReopenNoWriter(final boolean openReadOnly, IndexCommit commit) throws CorruptIndexException, IOException {
if (commit == null) {
if (hasChanges) {
// We have changes, which means we are not readOnly:
assert readOnly == false;
// and we hold the write... |
fbc4991e-a46e-4333-a266-56e9a860bf4d | 3 | public synchronized void write(Transaction ta, int pageId, String data) {
incrementLSN();
// write the data to a file
// one file for each page
// LSN also into the file for redoing
log(ta.getTaId(), LogType.WRITE, pageId, data);
Page page = new Page(pageId, logSequenceNumber, data, ta);
buffer.put(pa... |
ebc6b748-d7db-4205-9e33-2f3048325340 | 4 | private static void insertionSort(int[] arr) {
if(arr.length < 2) return;
int firstUnsortedNum;//第一个未排序的数,我们认为arr[0]已经排好序,因而从arr[1]开始
for(int i=1; i<arr.length; i++){
firstUnsortedNum = arr[i];
int j = i - 1;
while(j>=0 && firstUnsortedNum < arr[j]){//和已排好序的数进行比较,从最后一个已排序数开始
arr[j+1] = arr[j];
... |
7ff55b88-0c2f-4619-b87b-e1d00c4b111f | 1 | public boolean supprimerLocation(int numero){
System.out.println("ModeleLocations::supprimerLocation()") ;
Location location = rechercherLocation(numero) ;
if(location != null){
location.getVehicule().setSituation(Vehicule.DISPONIBLE) ;
this.locations.remove(location) ;
return true ;
}
else {
retu... |
c6cac3f0-4740-4fb2-8fbd-85f26b10997f | 4 | public boolean connect (String IP, boolean scan)
{
try
{
if(scan){
socket = findServer();
if(socket == null){
jTextField2.setText("Status: No Server Found");
return false;
}
... |
e3874f75-1b2a-4c8d-9acb-7d2a4b1365a9 | 4 | public void newProject() throws IOException {
boolean canceled = false;
if (isChanged) {
Object[] options = { Tools.getLocalizedString("YES"),
Tools.getLocalizedString("NO") };
JFrame frame = new JFrame();
int n = JOptionPane.showOptionDialog(frame,
Tools.getLocalizedString("EXIT_DIALOGUE"),
... |
910d6710-a77b-45e1-8196-9fef66e7a27a | 8 | @Override
public void e(float sideMot, float forMot) {
if (this.passenger == null || !(this.passenger instanceof EntityHuman)) {
super.e(sideMot, forMot);
this.W = 0.5F; // Make sure the entity can walk over half slabs,
// instead of jumping
return;
}
EntityHuman human = (EntityHuman) this.passe... |
e44139b1-d455-4bb6-80ba-3d4490556bfe | 8 | public static Coordinates readMoveFromKeyboard() {
Coordinates result = null;
while (result == null) {
System.out.print(">");
String str = null;
int row = 0, column = 0;
BufferedReader d = new BufferedReader(new InputStreamReader(
Syst... |
1662f0a0-cfd4-4a85-87db-ca10a9456774 | 8 | public int getValue() {
int status = 0;
status |= (negative ? 0x80 : 0);
status |= (overflow ? 0x40 : 0);
status |= (memory_access ? 0x20 : 0);
status |= (index_register ? 0x10 : 0);
status |= (decimal_mode ? 0x8 : 0);
status |= (irq_disable ? 0x4 : 0);
status |= (zero ? 0x2 : 0);
status |= (carry ? 0... |
fa95ea04-88a0-49b7-b798-51a4e780e4b1 | 7 | protected void actionPerformed(GuiButton par1GuiButton)
{
if (!par1GuiButton.enabled)
{
return;
}
if (par1GuiButton.id == 2)
{
String s = getSaveName(selectedWorld);
if (s != null)
{
deleting = true;
... |
69b7a037-e1df-4355-8f3e-5ccf6cca1287 | 8 | private static boolean
classMatcher(REGlobalData gData, RECharSet charSet, char ch)
{
if (!charSet.converted) {
processCharSet(gData, charSet);
}
int byteIndex = ch / 8;
if (charSet.sense) {
if ((charSet.length == 0) ||
( (ch > charSet.le... |
a7d0a3c0-03ab-4e60-bbe6-3e94cbdad0ba | 1 | @Override
public boolean getUserExists(String username) {
boolean userExists = false;
// Find an user record in the entity bean User, passing a primary key of
// username.
User user = emgr.find(entity.User.class, username);
// Determine whether the user exists
if (user != null) {
userExists = true;
... |
f5fe895c-5323-4ecc-8694-a3b84527ef91 | 8 | public boolean equals(Object passedObj)
{
//Checks if the object exists
if (passedObj == null)
{
return false;
}
//Checks to ensure the class is an instance of this class
if(!(passedObj instanceof MyAllTypesSecond))
{
return false;
}
if(passedObj == this)
{
return true;
}
MyAllTy... |
6ef39d8e-fd96-47f8-b93b-4ed4e981085f | 8 | @Override
public ArrayList<seed> move(ArrayList<Pair> initTreelist, double initWidth, double initLength, double initS) {
treelist = initTreelist;
width = initWidth;
length = initLength;
s = initS;
seedgraph = new SeedGraph(initTreelist, initWidth, initLength, initS);
boards = new Boards(seedgraph);
Arra... |
81fddb52-bc3c-4c7a-94ad-e1b29a9ea1ed | 5 | @Override
public final boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof OCPTelno)) {
return false;
}
OCPTelno other = (OCPTelno) obj;
if (!A... |
7b8af52e-15a2-49ef-81a4-ae274a6bb584 | 9 | public void refreshGameControl() {
// mortgageOption
gamecontrol.optionPanel.removeAll();
int y=50;
if (showThrowDiceBtn) {
// Insert dice button
JButton copy = choices.get(0);
copy.setSize(gamecontrol.optionPanel.getWidth(),50);
c... |
2f0c54f9-445b-46eb-a4b6-0cba1b54e486 | 4 | public static void main(String[] args) {
// -------------------------Initialize Job Information------------------------------------
/*********************************Big Experiments*********************************/
//String startJobId = "job_201301181454_0001";
//String jobName = "Big-uservisits_aggre-pig-5... |
523aee3c-fe35-48b7-a5e9-a405f46e400c | 0 | public Pelaaja() {
super(0, 0);
xNopeus = 0;
xSuunta = 0;
isoHyppy = 0;
putoamiskiihtyvyysPerFrame = 1;
terminaalinopeus = 50;
/**
* Nopeudeksi määritetään terminaalinopeus, koska jos pelaaja alottaa
* ilmasta, haluamme sen putoavan täysiiiiiii
... |
222447de-8b1c-4b9c-9482-1c94ff9254a1 | 5 | String getHelpText() {
boolean letters = ((characters & LETTERS) == LETTERS);
boolean digits = ((characters & DIGITS) == DIGITS);
boolean ascii = ((characters & SYMBOL) == SYMBOL);
return "Allowed characters:"
+ (letters ? " letters" : " ")
+ (digits ? " digits" : " ")
+ (ascii ? " ascii" : " ")
... |
66ca09ec-4920-4724-be0c-d19fff406f20 | 3 | public void addPart3(Statement statement, String line) {
String counterPartyAccount = line.substring(10, 44).trim();
CounterParty counterParty = new CounterParty();
if (!counterPartyAccount.trim().equals("")) {
BankAccount bankAccount = new BankAccount(counterPartyAccount);
... |
b0fa7e63-c246-486d-8bfe-56cbd318bae6 | 0 | private void jCheckBoxComptesRendusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxComptesRendusActionPerformed
//Récupération de la méthode contrôleur 'afficherComptesRendus'
this.getCtrlM().afficherComptesRendus();
}//GEN-LAST:event_jCheckBoxComptesRendusActionPerformed |
a6c83954-0a0f-4749-a62e-ad67d092203a | 3 | private void addUniform(String uniformName, String uniformType, HashMap<String, ArrayList<GLSLStruct>> structs) {
boolean addThis = true;
ArrayList<GLSLStruct> structComponents = structs.get(uniformType);
if (structComponents != null) {
addThis = false;
for (GLSLStruct ... |
93d8f225-7921-49c1-993c-cca9d24f1b81 | 5 | public ArrayList<String> getRequirementString() {
ArrayList<String> requirements = new ArrayList<String>();
if(!item1.equals("None")) {
requirements.add(item1 + ":" + item1Qty);
}
if(!item2.equals("None")) {
requirements.add(item2 + ":" + item2Qty);
... |
50741af9-961a-4a5b-bce9-548176788f1d | 4 | public List<Disciplina> getDisciplinasPreferidasComNivel(
int nivelPreferencia) throws PreferenciaInvalidaException {
switch (nivelPreferencia) {
case 1:
return this.listaDisciplinasP1;
case 2:
return this.listaDisciplinasP2;
case 3:
return this.listaDisciplinasP3;
case 4:
return this.listaDisc... |
52f77931-822f-4d2a-9fef-456fe787bfd9 | 6 | public void update(Contestant c) throws InvalidFieldException {
if (c.getFirstName() != null) {
setFirstName(c.getFirstName());
}
if (c.getLastName() != null) {
setLastName(c.getLastName());
}
if (c.getID() != null) {
setID(c.getID());
}
if (c.getPicture() != null) {
setPicture(c.getPicture... |
68839666-94bd-4162-85de-a0184bef2628 | 4 | public static boolean deleteFile(Path file) {
boolean ret = false;
if ((file != null) && Files.exists(file, LinkOption.NOFOLLOW_LINKS)) {
try {
if (file.toFile().canWrite()) {
Files.delete(file);
}
ret = !Files.exists(file,... |
ad16acce-c1cd-405a-a912-cdf3083057d9 | 1 | public TroubleInputStream(InputStream in, Filter[] filters) {
super(in);
this.filters = filters;
hasFilters = filters != null && filters.length > 0;
} |
1e212232-d269-40a5-b465-6730b9b4d3b4 | 4 | public void makeDeclaration(Set done) {
super.makeDeclaration(done);
/*
* Normally we have to declare our exceptionLocal. This is automatically
* done in dumpSource.
*
* If we are unlucky the exceptionLocal is used outside of this block.
* In that case we do a transformation.
*/
if (exceptionLo... |
51d38dfa-adf9-4414-827c-090c4ffd6083 | 1 | public Main() {
movingObjects = new LinkedList<MovingObject>();
units = new LinkedList<Unit>();
units.add(new Summoner(50, 50));
units.add(new Summoner(100, 100));
units.add(new Collector(200, 50));
units.add(new Collector(200, 100));
buildings = new LinkedList<Building>();
buildings.add(new ManaA... |
c06391b8-5bd3-410e-870a-7fe977211b0b | 6 | @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
ProcessManager other = (ProcessManager) obj;
if ... |
e76385bc-f7ae-456d-b48d-81edd9f0bef6 | 9 | boolean validWallSet(boolean[][] w) {
// copy array
boolean[][] c;
c = new boolean[w.length][w[0].length];
for (int i=0; i<w.length; i++) {
for (int j=0; j<w[0].length; j++) c[i][j] = w[i][j];
}
// fill all 8-connected neighbours of the first empty
// square.
boolean found = false;
search: fo... |
7ade89d1-bcf0-4026-ad57-5bebbed4dd89 | 5 | private ArrayList<Language> sortProbability(double[] prob) {
ArrayList<Language> list = new ArrayList<Language>();
for(int j=0;j<prob.length;++j) {
double p = prob[j];
if (p > PROB_THRESHOLD) {
for (int i = 0; i <= list.size(); ++i) {
if (i == ... |
5ab89615-32d4-4962-a55b-d30658d281f2 | 6 | public void handleControl(ucEvent e){
if(e.getSource() == castor.source){
switch(e.getCommand()){
case 3: setMouseAction("Mirsel"); prisec = true; mirrefflag[1] = 0; break;
case 4: mirrefflag[1] = 1; prisec = true; setMouseAction("Mirsel");break;
}
}
if(e.getSource() == pollux.source){
switch(e.getComma... |
1b8bf7ce-2a5d-49f1-b886-39b22094fd92 | 1 | public static void toggleMoveableInheritanceText(Node currentNode, JoeTree tree, OutlineLayoutManager layout) {
CompoundUndoablePropertyChange undoable = new CompoundUndoablePropertyChange(tree);
toggleMoveableInheritanceForSingleNode(currentNode, undoable);
if (!undoable.isEmpty()) {
undoable.setName("Toggle... |
d05750b9-fdec-4f8d-978a-f13f76a232d3 | 9 | public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Function1 function1 = new Function1();
Function2 function2 = new Function2();
Function3 function3 = new Function3();
Function4 function4 = new Function4();
Function5 function5 = new Function5();
Function6 function6 = new F... |
e1d441e4-2564-4160-a0f8-b0bcfb320941 | 8 | private void drawMarking(Graphics2D g2) {
float yMarkingHeight = (getSize().height - (topMargin + bottomMargin)) / (float)yMarkCount;
int baseLineIndex = yMarkCount / 2;
int startY = topMargin;
double delta = (plotMaxY - plotMinY) / yMarkCount;
g2.setFont(fontLabel);
... |
1ab75878-6b56-40de-9f82-75592e738976 | 9 | public boolean checkHypergeometricParams(int k, int N, int D, int n) {
if ((k < 0) || (N < 0) || (D < 0) || (n < 0)) return false;
/* Change of variables
* drawn not drawn | total
* defective a = k b = D - k | D
* nondefective c = n - k d = N + k - n - D | N - D
* ----------------------... |
b638c0d9-ca1f-4d09-a44a-afbe4b199c84 | 8 | protected void drawRadarPoly(Graphics2D g2,
Rectangle2D plotArea,
Point2D centre,
PlotRenderingInfo info,
int series, int catCount,
double headH, double h... |
d40656c3-94d3-4c5d-900d-e8a332f9f91c | 8 | public static String colorizeParameter5(int param) {
String color = "";
if(param <= 15) color = "red";
if(param > 15 && param <= 30) color = "yellow";
if(param > 30 && param <= 70) color = "green";
if(param > 70 && param <= 85) color = "purple";
if(param > 85) co... |
16a1f1cb-e4dd-4353-82a0-e91bab0086a2 | 7 | protected void onDeathUpdate()
{
++this.deathTime;
if (this.deathTime == 20)
{
int var1;
if (!this.worldObj.isRemote && (this.recentlyHit > 0 || this.isPlayer()) && !this.isChild())
{
var1 = this.getExperiencePoints(this.attackingPlayer);... |
60d86b2e-69de-4456-a2a4-ba5bc3d146dd | 4 | public void testCaddie (Connection conn) throws IOException, BDException {
if (session.getAttribute("config") == null) {
char d = BDRequetes.getTypeCaddie(conn);
if (d == 'P'){
BDRequetes.checkCaddieLifetime(conn);
session.setAttribute("config", "P");
}
else {
int d2 = BDRequetes.get... |
d76ec4ac-bb1e-4af2-ab8b-0598a4d68218 | 4 | private UrlSource() {
this.urlList = new LinkedList<>();
try (
InputStream urlStream = this.getClass().getResourceAsStream("URLSET.txt");
BufferedReader urlReader = new BufferedReader(new InputStreamReader(urlStream));) {
String url;
while (true) {... |
c0b1575c-e1c3-4e76-a686-5fb6ea31ad4e | 6 | public static ArrayList<Point> graham(ArrayList<Point> points) {
ArrayList<Point> bestPoints = new ArrayList<Point>();
Point tP = points.get(closestPoint(points));
points.remove(closestPoint(points));
sort(points, tP);
points.add(0, tP);
ArrayList<Point> uniqArray = new ... |
53aa08e4-9efe-441e-a0a4-a87b50b50328 | 5 | public void determinecounter(int grade) {
switch (grade / 10) {
case 10:
case 9:
acount++;
break;
case 8:
bcount++;
break;
case 7:
ccount++;
break;
case 6:
dcount++;
break;
default:
fcount++;
break;
}
} |
51412763-5864-4a9d-9661-db7456b8e4f5 | 3 | @Override
public void parse() throws IllegalArgumentException
{
try
{
setEncoding(Encoding.getEncoding(buffer[0]));
}
catch (IllegalArgumentException ex)
{ // ignore the bad value and set it to ISO-8859-1 so we can continue parsing the tag
setEncoding(Encoding.ISO_... |
97642b45-3629-4e1b-be55-5e318b396f23 | 9 | @Test
public void testConstructor_IllegalArgumentException() {
boolean exceptionThrown = false;
try {
new PaymentResponse(null, 1, ServerResponseStatus.SUCCESS, null, "buyer", "seller", Currency.BTC, 12, System.currentTimeMillis());
} catch (IllegalArgumentException e) {
exceptionThrown = true;
}
asse... |
d5fba127-5a1f-4ce1-861b-dc4d754f92c9 | 9 | public static Direction getReversed(Direction d) {
switch (d) {
case DOWN:
return UP;
case DOWNLEFT:
return UPRIGHT;
case DOWNRIGHT:
return UPLEFT;
case LEFT:
return RIGHT;
case RIGHT:
return LEFT;
case UP:
return DOWN;
case UPLEFT:
return DOWNRIGHT;
case UPRIGHT:
... |
7b95564e-03aa-4858-97e7-e47ef5c7b1a9 | 9 | static public Calendar interpret(String value)
{
if(igpp.util.Text.isEmpty(value)) return null;
if(value.indexOf("-") != -1) return parse(value, CONVENTION); // Treat as convention format
// Intrept unitized values
Calendar time = getNow();
String[] part = value.split(" ", 2);
if(part.length < ... |
ed574aaf-cf32-43b7-8068-ebf6da87fb5d | 7 | public JPopupMenu getMenu() {
if (elm == null) {
return null;
}
if (elm instanceof TransistorElm) {
scopeIbMenuItem.setState(value == VAL_IB);
scopeIcMenuItem.setState(value == VAL_IC);
scopeIeMenuItem.setState(value == VAL_IE);
scopeVb... |
5433b381-1ada-4486-b9bb-baf143779a60 | 7 | @SuppressWarnings("unchecked")
public boolean equals(Object o){
if(o == null) return false;
if(o.getClass() == getClass()){
ShareableHashSet<V> other = (ShareableHashSet<V>) o;
if(other.currentHashCode != currentHashCode) return false;
if(other.size() != size()) return false;
if(isEmpty()) r... |
f5582f0d-9617-4649-88ea-a00758b841b9 | 0 | @Override
public String getColumnName(int column) {
return this.columnNames[column];
} |
c8cef589-8400-4be6-a8fc-fa1891e8d289 | 6 | public static long[] getPrimeSmallerThanK(int k, boolean print) {
long[] primes = new long[k];
primes[0] = 2;
int currPrimeCount = 1;
for(int i=3;i<=k;i+=2) { // even number cannot be prime
boolean isPrime = true;
long sqrt = (long) Math.sqrt(i);
for(int j=0; j<currPrimeCount && primes[j]<=s... |
5935e12c-9daa-4721-9286-79e06c850c65 | 3 | public long getAllPopulation() {
long returnedPopulation = 0;
for (AstronomicalObject astronomicalObject : elements) {
if ((astronomicalObject.getClass() == InhabitedPlanet.class) || (astronomicalObject.getClass() == NaturalSatellite.class)) {
returnedPopulation += astronomic... |
24a88075-b357-4b77-a242-b887ac80239f | 5 | @SuppressWarnings("unchecked")
@Test public void fuzzyTest() {
final Random rng = new Random(42);
for(int n = 0; n < 1000; n++) {
for(int k = 0; k < 100; k++) {
final int l = rng.nextInt(n + 1), r = n - l;
A a1 = emptyArray(), b1 = emptyArray();
final ArrayList<Integer> a2 = new... |
415d3fc5-0254-4257-8302-d9ef3f5e5a50 | 1 | void initTranstoForm()
{
textInput.setText(getCommaStringFromArrayList(sim.getAlphabetFromTransitions()));
AutoCompleteComboBoxModel acm = new AutoCompleteComboBoxModel();
ArrayList<String> t = new ArrayList<String>();
t.add("[same state]");
Dfa d = getdFAMainWin().getDfaSim().g... |
08e10af8-12ea-4e87-8635-0936c63ded31 | 1 | private boolean cellIsFree(int x, int y){
if(field[x][y] == DEFAULT_CELL_VALUE){
return true;
} else {
return false;
}
} |
97906470-42aa-4806-921d-eeb9aaf91eb3 | 3 | public Labyrinth(int height, int width) {
try {
caseArray = new Case[height][width];
for (int a = 0; a < height; a++) {
for (int b = 0; b < width; b++) {
caseArray[a][b] = new Case(a, b);
}
}
cells = height * wid... |
8bdb23e8-01c1-488e-a0ee-5e7d93054e75 | 8 | private static int checkTypeSignature(final String signature, int pos) {
// TypeSignature:
// Z | C | B | S | I | F | J | D | FieldTypeSignature
switch (getChar(signature, pos)) {
case 'Z':
case 'C':
case 'B':
case 'S':
case 'I':
case 'F':
case 'J':
case 'D':
return pos + 1;
default:
retu... |
346d9703-8f54-479a-9f72-2b9636ca5b52 | 7 | public void loadFile(String path) throws IOException {
String thisLine; // variable to read each line.
BufferedReader myInput = null;
try {
FileInputStream fin = new FileInputStream(new File(path));
myInput = new BufferedReader(new InputStreamReader(fin));
// for each line until the end of the file
wh... |
9bc9f9f6-255f-46b9-ab29-3584e1278466 | 2 | @Override
protected void decode(ChannelHandlerContext chc, ByteBuf buf, List<Object> out) throws Exception {
byte id = buf.readByte();
byte[] data = new byte[buf.readableBytes()];
buf.readBytes(data);
Class<? extends Packet> clazz = Packet.packetIdMap.get(id);
if (cl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.