method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
a4530820-334a-4c32-aa09-e451bf180483 | 8 | @Override
public int[] getInts(int par1, int par2, int par3, int par4)
{
int i1 = par1 - 1;
int j1 = par2 - 1;
int k1 = par3 + 2;
int l1 = par4 + 2;
int[] aint = this.parent.getInts(i1, j1, k1, l1);
int[] aint1 = IntCache.getIntCache(par3 * par4);
for (in... |
25e5d26d-89b2-42a1-8128-210ff4d59adc | 0 | public BasicSword(){
this.name = Constants.BASIC_SWORD;
this.attackScore = 2;
this.attackSpeed = 2;
this.money = 0;
} |
c34e1206-45d3-4782-9024-d89a55e51890 | 6 | @Override
public void reduce(UserIdPairWritable key, Iterator<UserRatingPairWritable> it, OutputCollector<Text, Text> output, Reporter reporter) throws IOException {
double correlation = 0;
// If this is the same user and not a pair, simply use 1 as correlation. We know for a fact that our algorithm
// implemen... |
e62d5606-814c-4b85-ac79-5fba9b2f443e | 8 | private void applyBuoyancy(float[][] f) {
float g = gravity * timeStep;
float b = thermalExpansionCoefficient * timeStep;
float t0;
switch (buoyancyApproximation) {
case Model2D.BUOYANCY_AVERAGE_ALL:
// TODO: Should we include solid state cells or should we not?
// The logic of including all cells is to... |
7180d2e9-c455-4742-94a3-2b1181f4444e | 7 | @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
String world = null;
if(sender instanceof Player)
{
Player p = (Player)sender;
if(args.length == 1)
{
boolean enable;
if(args[0].equals("true"))
enable = true;
else if(args[0].e... |
eef4b547-037d-4343-abbc-4f0f59a97c91 | 3 | public Palaute validateAndConvert() throws ValidointiPoikkeus {
/*
* Tarvitaan oma kääreluokka, joka säilyttää Mapia,
* jossa on arvona ArrayListeja. Tavallinen Map ei käy,
* sillä yhdellä avaimella voi olla monta arvoa.
* */
ValidointiVirheet virheet = new ValidointiVirheet();
// Luodaan vali... |
c9e1a28b-3d5e-484e-9974-386b25b05a51 | 3 | private byte[] decrypt(byte[] d, int start, int end, int key, int skip) {
if (end - start - skip < 0) {
skip = 0;
}
byte[] o = new byte[end - start - skip];
int r = key;
int ipos;
int c1 = 52845;
int c2 = 22719;
for (ipos = start; ipos < end; i... |
9694534e-444f-4f16-88e7-a3c74553e064 | 3 | public static void associationFormat(Object[] varsin) {
// ReplaceVars = variables que se van a sustituir
// NewVars = Variables nuevas que cogen el contenido de las ReplaceVars
String vars = (String) varsin[0];
String phrase;
int where;
try{
where = ... |
3b2f2103-e03e-4557-a39f-3c33faa7f436 | 4 | public static void main(String[] args) {
Message m = new Message("Test Message", "");
m.addDestinationAddress("918888324979");
m.addDestinationAddress("919405964956");
API api = new API("3478866", "GreatDharmatma", "VPQOUUULMHdHJd");
try {
api.enableSessionMode();
... |
22bcaaeb-d909-46f5-aea6-9b8e420c513f | 6 | private final int method465(Model model, int i) {
int j = -1;
int k = model.anIntArray1627[i];
int l = model.anIntArray1628[i];
int i1 = model.anIntArray1629[i];
for (int j1 = 0; j1 < anInt1626; j1++) {
if (k != anIntArray1627[j1] || l != anIntArray1628[j1]
... |
245c1149-b93b-4d93-9799-b8107ec76ab7 | 4 | @Override
public void mouseEntered(MouseEvent e) {
label.setBorder(BorderFactory.createLineBorder(Color.RED));
if(e.getModifiersEx() == MouseEvent.BUTTON1_DOWN_MASK && label.getOnCanvas()){
label.drawTile(canvas.getCurrentTile(), canvas.getCurrentLayer());
}
if(e.getModif... |
88a3a619-a4f8-4352-86bd-0a135c91847d | 3 | public void visit(final String name, final Object value) {
if (values == null) {
values = new ArrayList(this.desc != null ? 2 : 1);
}
if (this.desc != null) {
values.add(name);
}
values.add(value);
} |
edebcbf6-4e3a-43d3-adf7-ba25bd1e5ed0 | 0 | @Test
public void EnsurePatternIsParsedCorrectly() {
String patternarray[] = patternSix.getPatternArray();
assertEquals(6, patternarray.length);
assertEquals("alan", patternarray[0]);
assertEquals("friend", patternarray[1]);
assertEquals("warbyparker", patternarray[2]);
assertEquals("*", patternarray[3]);
... |
1d8fc88f-c251-4508-94a6-ee1e18516cd4 | 9 | */
private static <T extends Comparable<T>> void sortMain(String sortsToRun, ArrayList<T> lst){
long startTime, endTime;
double execTime;
// Create a copy of 'lst'
ArrayList<T> lstCopy = new ArrayList<T>(lst);
// Sort the list using Java's sorting implementation
startTime = System.nanoTime();
... |
4723b9da-0958-4a68-b333-dd0efb9f21ff | 5 | void kaynnistaKierros(){
kierros++;
try{
ui.kierros.setText("Kierros: " + kierros);
} catch (Exception e) {
//testien ui päivityksen ohitukseen, koska testeissä ui = null
}
for (int i = 0; i < 4; i++) {
suoritaVuoro(pelaajat.... |
9876a2c8-7317-4b22-8455-762fdee9b8d4 | 9 | private void processParameter(Parameter param,
String valueToParse) {
// if this argument has already been parsed at least once...
if (result.getObject(param.getID()) != null) {
if (((param instanceof FlaggedOption)
&& (!((FlaggedOption) param).allowMultipleDeclarat... |
b189807a-a6d2-43d8-a82c-660d1e73c209 | 6 | private void editActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editActionPerformed
String parameterType = (String)table.getModel().getValueAt(table.getSelectedRow(), 0);
switch (parameterType) {
case "String":
try {
StringParameterWind... |
d0d69b7a-5286-4e31-9a8d-70b2aa47e9f2 | 3 | public static Map
cloneMap(
Map map )
{
if ( map == null ){
return( null );
}
Map res = new TreeMap();
Iterator it = map.entrySet().iterator();
while( it.hasNext()){
Map.Entry entry = (Map.Entry)it.next();
Object key = entr... |
25f5bbfd-bc4d-42ee-a49f-d40ad2c2b2a9 | 9 | static final void method1736(int i, Color color, Color color_7_, Color color_8_, String string, byte b) {
anInt2011++;
try {
Graphics graphics = Node_Sub38_Sub20.aCanvas10309.getGraphics();
if (Node_Sub46.aFont7555 == null) {
Node_Sub46.aFont7555 = new Font("Helvetica", 1, 13);
}
if (color_8_ == nul... |
67f33289-dacc-4357-ad0b-b7e49426cdd2 | 9 | public String readLine() {
int b;
byte c;
StringBuilder sb = new StringBuilder();
try {
while (true) {
if (count == limit) {
fill();
}
if (limit == -1)
break;
b = buf[cou... |
02e649e2-711a-4411-b282-3b0af485b930 | 7 | private final boolean cons(int i) {
switch (b[i]) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
return false;
case 'y':
return (i == k0) ? true : !cons(i - 1);
default:
return true;
}
} |
45f61cfa-941a-4918-bad7-bf5a6d826f49 | 5 | *@param cadena
**/
public void coincidencias(beansMiembro mim, String cadena){
boolean contiene = false;
if(cadena.length() == 0){
if(mim.getNick().indexOf(cadena) > -1)
contiene = true;
}
if(mim.getNick().endsWith(cadena) || mim.getNick().startsWith(cadena) || contiene == true){
System.out.println(... |
f81ed67a-9958-47b8-b36d-15fc8620089e | 6 | public boolean getBoolean(String key) throws JSONException {
Object o = get(key);
if (o.equals(Boolean.FALSE) ||
(o instanceof String &&
((String)o).equalsIgnoreCase("false"))) {
return false;
} else if (o.equals(Boolean.TRUE) ||
(o ins... |
681d27ce-3454-471e-bcdb-51c5ef972c38 | 4 | public static void shutdown() {
Settings.saveProperties(Constants.SETTINGS_PATH);
if (model != null) {
model.shutdown();
model = null;
}
if (exct != null) {
exct.shutdown();
exct = null;
}
if (chooser != null) {
... |
f17cab0a-2811-4159-b9f5-f2f61e2ffdc0 | 5 | public void showMaklerMenu() {
//Menüoptionen
final int NEW_MAKLER = 0;
final int EDIT_MAKLER = 1;
final int DELETE_MAKLER = 2;
final int BACK = 3;
//Maklerverwaltungsmenü
Menu maklerMenu = new Menu("Makler-Verwaltung");
maklerMenu.addEntry("Neuer Makler", NEW_MAKLER);
maklerMenu.addEntry("Makler b... |
8f97572d-dcc1-41ea-98db-7ca6186bbcbd | 6 | public ConnectionWrapper getConnectionWrapper() throws SQLException
{
synchronized (this.mutex)
{
int x = this.lastConnection;
ConnectionWrapper res = null;
for (int y = 0; y < pool.size(); y++)
{
x++;
x %= pool.size();
if (!pool.get(x).isTaken())
{
res = pool.get(x);
res.setT... |
24a53dbc-acf3-4030-a749-6c1bc0b9d4e9 | 5 | @Override
public void drawMainMenu()
{
System.out.println("Welcome to Super Minesweeper Turbo, HD Edition!");
System.out.println("Please select an option from the following:");
System.out.println("----------------------------------------");
System.out.println("-'new' ------------------ New Game -");
Sy... |
f983ceeb-2300-45a7-9d41-f2c6b90613e5 | 9 | public void setValue(ELContext context,
Object base,
Object property,
Object val) {
if (context == null) {
throw new NullPointerException();
}
if (base != null && base.getClass().isArray()) {
con... |
b2dec7c2-4f0e-4d0d-8384-fd1766b91f48 | 0 | public void send(String str){
out.println(str);
Frame.println("Mesege sended to "+ id +" message: " + str);
} |
61fe913a-2b4d-49c1-a10d-3bebe5d2b23b | 4 | @Override
public String execute(SessionRequestContent request) throws ServletLogicException {
String page = ConfigurationManager.getProperty("path.page.editcity");
resaveParamsSaveCity(request);
try {
Criteria criteria = new Criteria();
City city = (City) request.getS... |
21d60639-7580-429d-afad-db7a68884b4d | 0 | public void Listener() throws Exception {
/**
* Init and start server
*/
conn.init(null);
conn.start();
} |
143fddef-bfe2-4519-8997-28801181d4b3 | 4 | @Test
public void testTargetRandomSelection() {
ComputerPlayer player = new ComputerPlayer();
// Pick a location with no rooms in target, just three targets
board.calcTargets(23, 7, 2);
int loc_24_8Tot = 0;
int loc_22_8Tot = 0;
int loc_21_7Tot = 0;
// Run the test 100 times
for (int i=0; i<100; i++) {
BoardC... |
7d0563c9-3148-44f1-8885-dc27f5997720 | 6 | String type() {
if (idx == null && val.getClass().isArray()) {
String t = val.getClass().getComponentType().getSimpleName();
int len = Array.getLength(val);
StringBuilder b = new StringBuilder();
for (int i = 0; i < len - 1; i++) {
... |
268a927b-5294-47db-9f6f-b33dcd5fbda9 | 5 | @Override
public double getXRotation()
{
double lowest = 9001;
double highest = 0;
int y = 0;
if (getRotationAngle() == 180)
y = -20;
if (getRotationAngle() == 360)
y = 20;
for (Block block : blockArray)
{
if (block.getXValue() > highest)
highest = block.getXValue();
if (block.getXValue(... |
dacb81a4-4ea0-4983-8581-4e4fc3cb71a0 | 4 | public int findNextPlace() {
Random randomizer = new Random();
// first transposition
int amountOfPlaces = this.field[this.place - 1].listAmount();// massiv 0 - 9
ListElement current = this.field[this.place - 1].getHead();
int randomChoise = randomizer.nextInt(amountOfPlaces);
... |
b51955ee-aef2-4995-b5bc-dcbfe7d504b9 | 3 | @Override
public Product getProduct(int id) throws SQLException {
Product searchedProduct = null;
Session session=null;
try{
session=HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
searchedProduct = (Product)session.get(Product.class, id);
session.getTransaction().comm... |
c92d446f-1b38-4fd1-b167-acb96bf04100 | 8 | public void stop()
{
Principal user=null;
try
{
// Handle run as
if (_runAs!=null && _realm!=null)
user=_realm.pushRole(null,_runAs);
if (_servlet!=null)
_servlet.destroy();
_servlet=null;
... |
7b1b7b8f-61c7-455f-a916-129ae8ff0814 | 0 | public String getTicketUrl() {
return ticketUrl;
} |
3c1d5366-d9b5-43dd-b001-7be3b75a4d6d | 0 | @Override
public void keyPressed(KeyEvent e) {
keys[e.getKeyCode()] = true;
// add key to queue for thread to send
keystr.add("true:" + e.getKeyCode());
} |
98793b59-f9e8-445e-a274-56e9e284015d | 3 | @Override
public boolean equals(Object obj) {
if (obj == this)
return true;
if (!(obj instanceof Vertex))
return false;
Vertex v = (Vertex) obj;
return v.x == x && v.y == y;
} |
a7469e17-c56b-4da9-a977-d72979e3be03 | 1 | public void logEntering(String message) {
if(debug) {
int i = indent.getAndIncrement();
System.out.println(indent(i) + ">" + message);
}
} |
6709dc0e-effa-4198-8cb6-1ce5ef3a6800 | 4 | public void readStringFromFile()
{
// make sure the file is legit.
if(!fl_file.exists())
{
fl_handler.textFileFailed(UIStrings.ERROR_BAD_FILEPATH + fl_file.getPath());
}
// read from the file.
String file_contents;
try
{
file_contents = new Scanner(f... |
51337457-8efd-4d7c-976e-b682effb0df2 | 2 | public void testPropertyCompareToHour() {
TimeOfDay test1 = new TimeOfDay(TEST_TIME1);
TimeOfDay test2 = new TimeOfDay(TEST_TIME2);
assertEquals(true, test1.hourOfDay().compareTo(test2) < 0);
assertEquals(true, test2.hourOfDay().compareTo(test1) > 0);
assertEquals(true, test1.hou... |
ee914e32-5f0a-4684-8a2e-253fcfdc9f7c | 6 | public static final SyslogIF createInstance(final String protocol, final SyslogConfigIF config) throws SyslogRuntimeException {
if (protocol == null || "".equals(protocol.trim())) {
throw new SyslogRuntimeException("Instance protocol cannot be null or empty");
}
if (config == null) {
throw new SyslogRuntim... |
305c1cd4-fd9a-4800-b7ed-3074815c93b3 | 0 | @Override
public void handleFile(File file) {
System.out.println(file.getPath());
} |
4e1e34af-d862-4c38-90ea-04b61f9c3afc | 5 | PortWatcher(Session session,
String address, int lport,
String host, int rport,
ServerSocketFactory factory) throws JSchException{
this.session=session;
this.lport=lport;
this.host=host;
this.rport=rport;
try{
boundaddress=InetAddress.getByName(address);
ss=... |
3bba5936-1f40-4dce-9d8e-dba437835e07 | 1 | private String firstHelpOptionName() {
if (firstHelpOption != null) {
return firstHelpOption.nameList.name;
} else {
return null;
}
} |
92497ca5-abc2-428e-ad86-8861c97d78db | 2 | public NMEA()
{
//data
data = new HashMap< Class<? extends NMEASentence>, NMEASentence >();
events = new HashMap< Class<? extends NMEASentence>, NMEAEvent >();
} |
b9d4e976-fafb-49bc-8fef-413322d50124 | 5 | public static void main(String[] args) {
//First we create the required resources
RessourcesCreator.updateFolders();
//We wait for their creation as the compiler would rather start the game
while(!MAP_FOLDER.exists() || !SKIN_FOLDER.exists() || !TEMP_FOLDER.exists())
try {
Thread.sleep(50);
} catch (I... |
d4f2d0d9-52ad-41b0-aeac-53735ed30b74 | 4 | public void actionPerformed(ActionEvent e) {
if (e.getSource() == addHSList) {
JFileChooser chooser;
chooser = new JFileChooser();
chooser.setCurrentDirectory(new java.io.File("."));
chooser.setDialogTitle("Select HyperSpin Directory...");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
... |
755ac768-8a88-4866-88be-75991250bdda | 7 | public Object nextContent() throws JSONException {
char c;
StringBuffer sb;
do {
c = next();
} while (Character.isWhitespace(c));
if (c == 0) {
return null;
}
if (c == '<') {
return XML.LT;
}
sb = new Str... |
9b587e6e-8d72-4365-9f9e-cce805edf3f1 | 7 | @Override
public void onClick(int x, int y) {
if(displayState == DISPLAY_MENU){
menu.onClick(x, y);
} else if(displayState == DISPLAY_GAME_END){
gameEnd.onClick(x, y);
} else if(displayState == DISPLAY_GAME) {
int boardCornerX = (winWidth-400)/2 - 10... |
89275f4e-e0b2-4c6f-a2c4-3a9827b696d6 | 9 | @Override
public int compareTo(LinkTriple other) {
int diff1 = 0, diff2 = 0, diff3 = 0;
if ( subj != other.subj ) {
if ( subj != null )
diff1 = subj.compareTo(other.subj);
else
diff1 = 1;
}
if ( pred != other.pred ) {
if ( pred != null )
diff2 = pred.compareTo(other.pred);
else
... |
a7ca36a7-7aae-4e98-9d75-cc66f5de7b09 | 2 | public double calculateAverageEscapeProbability(long seed, double tolerance) {
Random rng = new Random(seed);
int count = 0;
int numberOfPoints = (int) (this.xMax * this.yMax * 10);
double currentAvg;
double newAvg = -1;
currentAvg = avgEscProbForNRandomPoints(numberOfPoints, rng);
while (Math.abs(curr... |
9f245d35-2319-4d0e-bb97-f971dd9c8e7e | 0 | @Override
protected void setColoredExes() {
ParametricCurve bSplayn= new BSplaynCurve(allex);
coloredEx = bSplayn.Calculation();
} |
4710622e-117e-4a23-a67d-b2769f664ef8 | 5 | void countBedFile(String fileName) {
// Open file
int readNum = 1;
for (Variant read : new BedFileIterator(fileName)) {
try {
readLengthCount++;
readLengthSum += read.size();
countMarker(fileName, read);
if (verbose) Gpr.showMark(readNum, SHOW_EVERY);
readNum++;
} catch (Exception e) {
... |
cfe6c6c1-6102-49fb-9772-0fdc8ed782c4 | 5 | public boolean makeHod(int[] hod) {
for(int i = hod[0]; i <= hod[2]; i++) {
for (int j = hod[1]; j <= hod[3]; j++) {
if (this.board[i][j] != 0) {
return false;
}
}
}
for(int i = hod[0]; i <= hod[2]; i++) {
for (int j = hod[1]; j <= hod[3]; j++) {
this.board[i][j] = 1;
}
}
return t... |
b12eb0e8-e276-41ce-b60a-4857b0646ff5 | 8 | public Void visitContainedProcedures(ContainedProceduresContext ctx) {
if (ctx.children == null) return null;
increaseIndentLevel();
int loc = 1;
for (ParseTree child : ctx.children) {
if (child instanceof ProcedureContext) {
visitProcedure((ProcedureContext) child);
if (loc == c... |
2587e035-3919-4bee-9d37-1816a348a23f | 2 | public boolean compare_RGB(short red1, short green1, short blue1,
short red2, short green2, short blue2) {
return ((red1 == red2) && (green1 == green2) && (blue1 == blue2));
} |
b8aab746-4516-4285-8e58-5dd9a8bb5f28 | 5 | static protected String toDecFrac(double duration) {
long n, d, ggT;
d = (long) 26240 * 12;
n = (long) (duration * d);
ggT = ggT(d, n);
d /= ggT;
n /= ggT;
if (n == 1) {
if (d == 1) {
return "";
} else if (d == 2)
return "/";
}
if (d == 1)
return Integer.toString((int) n);
else if (... |
34f4e23b-895d-41e8-9b16-be69bc1d9e76 | 3 | public static String padding(int width) {
if (width < 0)
throw new IllegalArgumentException("width must be > 0");
if (width < padding.length)
return padding[width];
char[] out = new char[width];
for (int i = 0; i < width; i++)
out[i] = ' ';
r... |
94086911-d910-4a5d-84a4-9110bc6fe493 | 9 | private void doMenuLogic() {
if(menuControlsBuffer.isEmpty()) {
return;
}
int key = 0;
try {
key = menuControlsBuffer.dequeue();
} catch (InterruptedException e) {
e.printStackTrace();
}
if(key == KeyEvent.VK_UP) {
if(selectedMenuItem == 0) {
selectedMenuItem = 2;
} else {
... |
c5a2b71e-e593-4b1f-9717-943f6d126412 | 6 | public static double HammingDistance(String a, String b) {
if (a.isEmpty() || a == null || b.isEmpty() || b == null)
return -1;
char[] arr1 = a.toCharArray();
char[] arr2 = b.toCharArray();
int result = 0, low = Math.min(arr1.length, arr2.length), high = Math
.max(arr1.length, arr2.length);
for (int i ... |
f52ab233-4da5-4c82-9faa-e0a14501bc25 | 2 | private Element addLineElement(Document doc, Element linesElement, FileData fileData, int i, Element lineElement) {
if (i < fileData.getLines().size()) {
Integer hits = fileData.getLines().get(i);
if (hits != null) {
lineElement = doc.createElement("line");
... |
b9d250f4-5651-49e7-abb6-6da0a723a509 | 9 | static private OctNode recurseParse(Integer currentDepth, ByteBuffer buffer, Float[] origin, Float length) throws IOException, OctreeException {
Byte type = buffer.get();
try {
switch (type) {
case OctNode.OCTNODE_EMPTY:
Byte value = buffer.get();
... |
0a83585a-32ff-478b-a7f3-8338d6cabc8f | 7 | public void ParseEvaluationPatterns(GameConfigData xmlGameConfig, GameConfig modelGameConfig) throws SlotModelException {
ArrayList<com.akamon.slots.model.EvaluationPattern> previouslyAddedPaylines = new ArrayList<com.akamon.slots.model.EvaluationPattern>();
for (EvaluationPattern evalPattern : xmlGame... |
be31e83c-0318-4e02-a558-09f6baf1918e | 9 | public static Color parseColor(String str) throws NumberFormatException
{
if (str == null || str.equals(mxConstants.NONE))
{
return null;
}
else if (rgbRegex.matcher(str).matches())
{
return parseRgb(str);
}
else if (!str.startsWith("#"))
{
Color result = htmlColors.get(str);
// LATER: Ret... |
c82b3a36-9d59-4c0b-87cc-0121b55bd8e2 | 0 | @Basic
@Column(name = "comment")
public String getComment() {
return comment;
} |
37b333d3-c3fd-4e3e-b20b-2c2f7e256530 | 5 | public void questionSave(LinkedList<Question> questions) {
try {
Document doc = DOMfunctions.getDocument();
Element rootElement = doc.createElement(QUESTIONS);
doc.appendChild(rootElement);
for (Question q : questions) {
Element question = doc.createElement(QUESTION);
rootElement.appendChild(que... |
e7075de7-f23f-409d-b775-bd7e917d2fd2 | 2 | private static void roomToFight() {
int choice = -1;
while(choice != 0)
{
choice = 100;
printHeroList();
System.out.println("Please enter what level of room that you would like to enter (integer from 1 to 10).\n"
+ "Or please enter zero to go back to the main menu.\n");
try{
choice = kb... |
1a54569f-7981-4e53-8824-7e8078f52323 | 6 | @Override
public Sondage find(int id) {
Sondage found = null;
PreparedStatement pst = null;
ResultSet rs = null;
try {
pst=this.connect().prepareStatement("select * from Sondage where id= ?");
pst.setInt(1, id);
rs=pst.executeQuer... |
db607b4f-965a-4ba5-a286-d4564dd2852c | 9 | private static Color[][] getLightingMap(GameMap gmap){
int width = gmap.getWidth();
int height = gmap.getHeight();
Color[][] retMap = new Color[width][height];
for(Light l: gmap.getContainedLights()){
int rad = l.getLightRadius();
int lxs = l.getLightPosition().x;
int lys = l.getLightPosition().y;
f... |
63b002aa-8513-4f39-add5-b77ae2ececdf | 7 | public final boolean canEquip(final Map<String, Integer> stats, final int itemid, final int level, final int job, final int fame, final int str, final int dex, final int luk, final int int_) {
if (level >= stats.get("reqLevel") && str >= stats.get("reqSTR") && dex >= stats.get("reqDEX") && luk >= stats.get("req... |
359e0e79-88e4-45b0-95b0-da85047fe1b3 | 2 | public int get (int option_)
{
int rc = 0;
if (option_ == ZMQ.ZMQ_MAX_SOCKETS)
rc = max_sockets;
else
if (option_ == ZMQ.ZMQ_IO_THREADS)
rc = io_thread_count;
else {
throw new IllegalArgumentException("option = " + option_);
}
... |
65fa8406-9bbc-4ae5-83e6-311d0f6d0c9d | 7 | private void makeTableCycle(double[] P1, double[] P2, double[] P3) {
double T;
double[] H, D, W;
H = new double[n];
D = new double[n];
W = new double[n];
for (int i = 0; i < n - 1; i++) {
H[i] = P1[i + 1] - P1[i];
W[i] = (P2[i + 1] - P2[i]) / H[i];
}
W[n - 1] = W[0];
for (int i = 1; i < n - ... |
6ef4c506-745e-4c0d-8bde-ab1f56c19c22 | 0 | @Before
public void init_isGameOver(){
game = new Game();
board = mock(Board.class);
} |
2ca1c4de-0e1b-49a7-a697-5319b17199b0 | 7 | protected void landingOn(PlayerClass pPlayer)
{
if(this.owned == false && pPlayer.account.getBalance() >= this.buyPrice)
{
if(cout.buyFleet() == true)
{
pPlayer.account.addBalance(-this.buyPrice, pPlayer.getName(), false);
GUI.setOwner(pPlayer.getPlayerPos(), pPlayer.getName());
this.currentOwner =... |
e7c9720b-78ad-46df-87c1-019660360e0a | 8 | public int compare(QueryMetaData o1, QueryMetaData o2)
{
long left = o1.sizeExpected > -1 ? o1.sizeExpected :
o1.sizeUB > -1 ? o1.sizeUB : o1.sizeLB;
if (left == -1)
return 0;
long right = o2.sizeExpected > -1 ? o2.sizeExpected :
o2.sizeUB > -1 ? o2.sizeUB : o2.sizeLB;
if (right == -1 |... |
58119917-41c9-4b6f-b12a-ad494614182b | 7 | public int get(final int index) {
final int[][][][][][][] map1 = map[index >>> 28];
if (map1 == null)
return NOT_FOUND;
final int[][][][][][] map2 = map1[(index >>> 24) & 0xf];
if (map2 == null)
return NOT_FOUND;
final int[][][][][] map3 = map2[(index >>> 20) & 0xf];
if (map3 == null)
return NOT_... |
4051284c-f445-4a72-8fa0-4afeff51d492 | 6 | private boolean matchTree(BTnode orignal, BTnode treeToFind)
{
if(orignal == null && treeToFind == null)
{
return true;
}
if(orignal == null || treeToFind == null)
{
return false;
}
if(orignal.data != treeToFind.data)
{
return false;
}
return(matchTree(orignal.left, treeToFind.lef... |
01907681-13c0-40b4-a89a-a3055a2d83cc | 3 | @Override
public String toString() {
String result="[";
for(int i=0;i<this.size();i++) {
String g=this.get(i);
Integer id=GenreList.lowercaseValueToId.get(g.toLowerCase());
if(id!=null) {
result+="("+id.toString()+")";
}
result+=g;
if(i+1<this.size()) {
result+=", ";
}
}
return res... |
82359304-a267-41b7-b24e-22d170229db6 | 0 | public Locale(int id) {
this.id = id;
} |
0077c87f-c73f-40c5-9138-d59317f4b969 | 6 | @SuppressWarnings("resource")
public void serve(int port) throws IOException {
ServerSocket serverSocket = new ServerSocket(port);
while (true) {
final Socket socket = serverSocket.accept();
Thread thread = new Thread(new Runnable() {
@Override
... |
9e89922c-8a4c-4640-8f61-1077e91f13e6 | 0 | @Override
public void startDocument() {} |
92ca015f-3ee1-495e-bdd5-0a213a359536 | 3 | private List<String> getWebLinks() throws IOException {
URL url = response.getURL();
String new_base_url = "http://" + url.getHost().toString() + "/";
if (!base_url.contains(new_base_url) || temporaryInternalHrefs.size() == 0) {
base_url = new_base_url;
}
Document doc = Jsoup.parse(response.ge... |
e4208741-c105-4839-8e63-31d8ba256047 | 5 | public static AgentDataContainer makeResponse(ResultSet resultSet, AgentDataContainer agentDataContainer) {
NameTypePair[] metadata = null;
List<Object[]> data = null;
if (resultSet != null) {
try {
ResultSetMetaData rsmd = resultSet.getMetaData();
in... |
82426598-f9a9-49ef-991b-5659ee166346 | 1 | public void visitCode() {
mv.visitCode();
if (constructor) {
stackFrame = new ArrayList();
branches = new HashMap();
} else {
superInitialized = true;
onMethodEnter();
}
} |
03b2607f-5405-4666-a29a-438e6b7cf0c4 | 9 | public int findTwoBiggestDistinct(int[] arr) {
if (arr.length < 2) {
//no such numbers
System.out.println("no such numbers");
return arr[0];
}
int big1 = arr[0];
int big2 = arr[1];
int i = 2;
while (i < arr.length && big1 == big2) {
big2 = arr[i];
i++;
}
if (big1 != big2) ... |
95da66f7-7f32-4d0c-a967-7d871c76b9d0 | 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... |
3b254543-915b-4a98-8081-8b750c26f154 | 0 | public String getDepartureStation() {
return this._departureStation;
} |
19662554-b648-4469-8f6b-5de604b88337 | 8 | public void execute() {
boolean en = true;
if (hasEnable()) {
en = pins[bits + 2].value;
}
if (pins[0].value && !lastClock && en) {
int i;
for (i = bits - 1; i >= 0; i--) {
int ii = i + 2;
if (!pins[ii].value) {
... |
d3876cf2-35a1-42b9-9bc7-6949863d12f1 | 5 | public static void checkForAssetUpdates(boolean verbose) {
boolean assetUpdateRequired = false;
try {
assetUpdateRequired = AssetBuilder.assetsUpdateRequired("./data/assets");
} catch (IOException ex) {
Logger.warning("Updater.checkForAssetUpdates", "An error occ... |
99e11362-0ca9-45ed-a154-03c7b24b0737 | 5 | public void cancelBehaviour(Behaviour b) {
if (b == null) return ;
if (! agenda.includes(b)) return ;
while (agenda.size() > 0) {
final Behaviour popped = popBehaviour() ;
if (popped == b) break ;
}
if (agenda.includes(b)) I.complain("Duplicate behaviour!") ;
actor.assignAction(null)... |
ec45a91a-ad99-40d0-9e30-1ed78f584c64 | 4 | private boolean sendMsg(TACMessage msg) {
try {
String msgStr = msg.getMessageString();
URLConnection conn = url.openConnection();
conn.setRequestProperty("Content-Length", "" + msgStr.length());
conn.setDoOutput(true);
OutputStream output = conn.getOutputStream();
output.write(m... |
75b82bfb-9577-4be3-9e65-ef4a70a3fcb3 | 0 | public final short getID(){return (short)(data >> 4);} |
91a69684-3df0-4112-bb1e-3374ad66dac2 | 1 | public static void main(String[] args) {
try {
new TestingFramework();
} catch (Exception e) {
e.printStackTrace();
}
} |
65029d25-873d-45f4-a172-057a1380affe | 2 | private static String[] argsFromString(String s) {
Vector<String> vec = new Vector<String>(100);
try {
ArgParser.stringToArgs(vec, s, /* allowQuotedStings= */false);
} catch (StringScanException e) {
e.printStackTrace();
System.exit(1);
}
String[] result = new String[vec.size()];
... |
be25c19f-3999-4482-b4a6-f9fab770c6ba | 6 | private boolean isAttackPlaceAboveNotHarming(int position, char[] boardElements, int dimension) {
if (isPossibleToPlaceOnPreviousLine(positionAboveRight(position, dimension))
&& isPositionInRangeOnTheRight(position, dimension)) {
if (isBoardElementAnotherFigure(boardElements[position... |
6bfc989d-3e23-4542-bfd4-ab8cc3f05a2f | 8 | private boolean redSeaEffectNeeded(Block block, boolean up) {
if (rarpConfig.isRailProtection() && rarpConfig.isEnableRedSeaEffekt()) {
if (up) {
Material checkBlockType = block.getRelative(0, 1, 0).getType();
rarpLogger.debug("RedSeaEffekt One up", checkBlockType);
if (checkBlockType == Material.WATER... |
db41ba65-1638-4dac-afb8-811c3df0f00b | 9 | private static boolean checkForChange(Boardable newPath[]) {
if (lastSuccessPath != null && newPath == null) return true ;
if (newPath == null || lastSuccessPath == null) return false ;
//
// If the path doesn't connect the same points, ignore it-
if (Visit.last(newPath) != Visit.last(lastSuccessPa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.