method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
da879feb-4770-4310-8f75-d06e0acd96f3 | 3 | public void buildForest() {
intervalForest = new IntervalForest();
// Add all chromosomes to forest
if (useChromosomes) {
for (Chromosome chr : genome)
intervalForest.add(chr);
}
// Add all genes to forest
for (Gene gene : genome.getGenes())
intervalForest.add(gene);
//---
// Create (and ad... |
b8e65faf-022a-4025-ab29-f1521e4ff5e2 | 4 | public String execute(LogInObject logInObject) throws SQLException{
String answer = "";
String result = authenticateUser(logInObject.getAuthUsername(), logInObject.getAuthPassword(), logInObject.getIsAdmin());
switch (result){
case "1":
logInRO.setLogOn(false);
logInRO.setExplanation("The email or pa... |
1bac4855-c07f-4fa7-8a9f-f215dbbf3ae9 | 9 | int insertKeyRehash(float val, int index, int hash, byte state) {
// compute the double hash
final int length = _set.length;
int probe = 1 + (hash % (length - 2));
final int loopIndex = index;
int firstRemoved = -1;
/**
* Look ... |
9fef0e44-78dc-4da4-a9d3-0a48130e3da0 | 8 | public Point move(Point[] pipers, // positions of dogs
Point[] rats) { // positions of the rats
npipers = pipers.length;
System.out.println(initi);
Point gate = new Point(dimension/2, dimension/2);
if (!initi) {
this.init();initi = true;
}
Point current = pipers[id]; // Where the pipers are rig... |
29afc33c-c90e-47c9-b80a-162715084483 | 6 | final public DBAccess open(final String connectionString)
throws ClassNotFoundException {
String user = null;
String password = null;
String driver = null;
String url = null;
// Split the connection string into commands.
final String[] commands = connectionS... |
f451ff2d-3c7a-4e07-bace-9f7645443459 | 0 | public int getScrollableUnitIncrement(Rectangle visibleRect,
int orientation, int direction) {
return 5;
} |
03aeeea8-ea05-4404-9ba9-9dcdf726825a | 0 | public KeyStroke getKey() {
return KeyStroke.getKeyStroke('u');
} |
2310292b-cc93-4407-857a-bbacdf90bcd5 | 4 | @Override
public void run() {
if (!Inventory.isFull()) {
fish();
} else {
Item[] bob = Inventory.getItems();
for (int c = 0; inventoryCheck(); c++) {
bob[c].getWidgetChild().interact("Drop");
Time.sleep(100);
if (c == 29 && inventoryCheck()) {
c = 0;
}
}
}
} |
5b516ea5-0b02-46f3-969b-07b4aee51b58 | 7 | public P371E() {
Scanner sc = new Scanner(System.in);
// because we will deal with segments
N = sc.nextInt() - 1;
Pos[] pos = new Pos[N+1];
for (int i = 0; i < N+1; i++) {
int x = sc.nextInt();
pos[i] = new Pos(x, i+1);
}
Arrays.so... |
d919d8ca-b159-43c9-8a9a-ac6e98f1c4de | 0 | public BufferedImage getImage() {
BufferedImage bi = new BufferedImage(width,height, BufferedImage.TYPE_INT_RGB);
bi.setRGB(0,0,width,height,pixels,0,width);
return bi;
} |
e3c497b2-a5d1-412c-9677-713028ce32c4 | 4 | public static Calendar jauJd2cal(double dj1, double dj2) throws JSOFAIllegalParameter
{
/* Minimum and maximum allowed JD */
final double djmin = -68569.5;
final double djmax = 1e9;
long jd, l, n, i, k;
double dj, d1, d2, f1, f2, f, d;
/* Verify date is acceptable. */
d... |
c1e017c2-95c5-499c-92c0-ac39dde1227a | 2 | public void testForFields_datetime_DM() {
DateTimeFieldType[] fields = new DateTimeFieldType[] {
DateTimeFieldType.dayOfMonth(),
DateTimeFieldType.minuteOfHour(),
};
int[] values = new int[] {25, 20};
List types = new ArrayList(Arrays.asList(fields));
... |
68f3f80e-814f-4503-ba39-5b2832ed5579 | 5 | public static void main(String[] args) throws IOException {
Scanner scan = new Scanner(System.in);
BufferedReader buf = new BufferedReader(
new InputStreamReader(System.in));
String line = "";
BigInteger n = new BigInteger("0");
BigInteger aux = new BigInteger("0");
d: do {
line = buf.readLine();
... |
fad321ee-83da-4890-ad2b-344c6f2dfc31 | 0 | @RequestMapping(value="/{tripID}/detailsTravelTrip", method=RequestMethod.GET)
public String detailsTravelTrip(@PathVariable("tripID") String tripID, Model model){
TravelTrip tempTravelTrip = travelTripService.findById(Integer.parseInt(tripID));
model.addAttribute("detailsTravelTrip", tempTravel... |
b3a70f45-1778-47b3-82dd-c188e5631c15 | 1 | public Parser(String pathname) {
this.file = new File(pathname);
try {
readFile();
}
catch(FileNotFoundException e) {
System.err.println("File: " + pathname + " not found!");
e.printStackTrace();
}
extractAssemblercode();
} |
012d6834-ce24-4ee6-8cfe-25018a71e88c | 2 | private static boolean handleIsValidUser(Integer u) {
if (u < 0) {
System.err.println("Not a valid user");
return false;
} else {
UserModel userModel = new UserModel();
Iterable<Entry> userQuery = userModel.query("{id:" + u + "}");
if (!userQue... |
d3fde89d-05bb-4403-89d2-77880c75cb35 | 4 | public static void main(String[] args) throws IOException
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
Map<String, Integer> map = new HashMap<>();
while (true) {
try {
int id = Integer.parseInt(reader.readLine());
String ... |
bfb69edb-5d1d-48aa-acaa-1aed5ee4f205 | 3 | public int GetNpcListHP(int NpcID) {
for (int i = 0; i < maxListedNPCs; i++) {
if (NpcList[i] != null) {
if (NpcList[i].npcId == NpcID) {
return NpcList[i].npcHealth;
}
}
}
return 0;
} |
56c00c2b-a198-4cc3-8558-0baad2cd2bca | 8 | @Override
public void update(Level level, int x, int y, int z, Random rand) {
boolean var8 = false;
boolean var6;
do {
--y;
if (level.getTile(x, y, z) != 0 || !canFlow(level, x, y, z)) {
break;
}
if (var6 = level.setTile(x, y,... |
0bff7f3b-c1d8-490e-ab4a-d7e42d5b3b63 | 1 | public static HealthColorPixelType healthColorPixelTypeFor(Color color, int id) {
HealthColorPixelType type = healthColorPixels.get(color);
if (type == null) {
type = new HealthColorPixelType(id, color);
healthColorPixels.put(color, type);
}
return type;
} |
7423d6ed-f0b1-4b62-abf1-beef5f5e9e19 | 8 | private boolean doOp (NodeOps op, double threshold, double input) {
switch (op) {
case GREATER_THAN:
return input > threshold;
case LESS_THAN:
return input < threshold;
case GREATER_THAN_OR_EQUAL_TO:
return input >= threshold;
... |
89d5dc76-8c0b-4343-8a32-c0e284893be5 | 4 | private boolean touchRobotMov(int pos) {
boolean toca = false;
for (SimulatorRobot robot : Board.robots) {
if (robot != this) {
ArrayList<Line2D.Double> linies = this.getBoundLines();
ArrayList<Line2D.Double> liniest2 = robot.getBoundLines();
... |
ac71da2c-70de-4030-ac74-3854de66416c | 4 | public ParametricEquation(String equ_x, String equ_y, double tstart, double tend, double dt){
this.tstart = tstart;
this.tend = tend;
this.dt = dt;
equx = new Equation(equ_x);
equy = new Equation(equ_y);
Vector<Variable> variables = equx.getVariables();
if(variables.size()!=1)
throw new EquationExce... |
26226d7e-bf0c-461b-b9c3-e19a6066279e | 0 | public GrabAbility(String name, String trigger) {
super(name, trigger);
} |
4c248d7b-f703-4d7d-becc-d5ee14fd50da | 1 | public AttributeInfo copy(ConstPool newCp, Map classnames) {
AnnotationsAttribute.Copier copier
= new AnnotationsAttribute.Copier(info, constPool, newCp, classnames);
try {
copier.memberValue(0);
return new AnnotationDefaultAttribute(newCp, copier.close());
}
... |
e13cc907-7cdf-4b4f-bb30-7ae330a8783f | 2 | private double getBulletPower() {
if (power != null) {
return power;
}
double bulletPower = 1.95;
if (state.targetDistance < 140) {
bulletPower = 2.95;
}
bulletPower = Math.min(state.robotEnergy / 4.0, bulletPower);
bulletPower = Math.min(state.targetEnergy / 4.0, bulletPower);
bulletPower = Ma... |
75888b8e-c4fd-49c0-bd3c-1dc99f68d332 | 2 | private void transformTree(TreeNode node) {
TreeNode left = node.left;
TreeNode right = node.right;
reverse(node);
if(left != null) transformTree(left);
if(right != null) transformTree(right);
mergeToRight(node);
} |
fb0d9ec0-cb68-4e67-8220-c0a096f5ed17 | 0 | public int getFieldLineIndex() {
return fieldLineIndex;
} |
39b308b6-d635-4baa-961c-51fcc82068b0 | 9 | private static void runclient(String[] args) throws FileNotFoundException,
IOException {
//Get the addresses of machines from the property file
Properties prop = new Properties();
FileInputStream fis = new FileInputStream("./boltdb.prop");
prop.load(fis);
fis.close();
ClientArgs clientArgs = new ClientAr... |
01dc0a28-b7e4-439c-a5ea-10c81c989cec | 9 | public static MessageHandler getMessageHandler(Message message, ChatView chatView, ChatModel chatModel) throws UnknownMessageException {
if (message instanceof ServerErrorMessage) {
if (message instanceof FatalErrorMessage) {
return new ServerErrorMessageHandler(message, chatView, c... |
b78c62db-a304-4392-945d-dc4bb71cbf98 | 9 | public static boolean isValueCode(char ch)
{
return ch == '@'
|| ch == ':'
|| ch == '%'
|| ch == '+'
|| ch == '#'
|| ch == '<'
|| ch == '>'
|| ch == '*'
|| ch == '/'
... |
00861775-4011-46e3-9471-03bb49e68d6c | 9 | private void writeToFile(double value) {
/*we assume the file doesn't already exist*/
boolean newlyCreated = true, alreadyWritten = false;
/*we count the number of lines in the file*/
int count = 0;
try {
File file = new File("/users/cristioara/workspace/CN_Tema06/out.txt");
/*if file doesn't exi... |
fb582f19-fc7d-4169-863f-b59c473ee501 | 2 | private void addGlobalSearchMenuItems(Menu submenu) {
MenuItem pageSearchItem = new MenuItem(submenu, SWT.PUSH);
pageSearchItem.addListener(SWT.Selection, new Listener () {
public void handleEvent(Event e) {
if (globalSearch.globalSearchAction()) {
pageSearch.setSearchParameters(globalSearch.getLastSear... |
3d95d9a0-7ed3-41d2-aeb2-a60e3887bb39 | 6 | @Override
public void actionPerformed(ActionEvent event) {
if (event.getActionCommand().equals(VentanaPrincipal.COMANDO_ABRIR_REPRODUCCION)) {
ventanaPrincipal.manejoVentanaReproduccion('a');
}else if (event.getActionCommand().equals(VentanaReproduccion.COMANDO_CERRAR_REPRODUCCION)) {
ventanaPrincipal.manejo... |
fbe0fc53-1c4e-49b3-a66b-2f38e36950d0 | 2 | protected void processSkipBlocks(List<String> skipBlocks) {
if(generateStatistics) {
for(String block : skipBlocks) {
statistics.setPreservedSize(statistics.getPreservedSize() + block.length());
}
}
} |
de205f77-f19e-46c7-aa84-9fdbeab090cc | 5 | @Override
public List<Role> findRoleByAccountId(int accountId) {
List<Role> list = new ArrayList<Role>();
Connection cn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
cn = ConnectionHelper.getConnection();
ps = cn.prepareStatement(QT... |
40c3292b-f6a3-4aa7-a372-8dcfb8f20d8c | 5 | public void update() {
float newX = x + moveAmountX;
float newY = y + moveAmountY;
moveAmountX = 0;
moveAmountY = 0;
ArrayList<GameObject> objects = Game.rectangleCollide(newX, newY, newX + SIZE, newY + SIZE);
ArrayList<GameObject> items = new ArrayList<GameObject>();
boolean move = true;
f... |
18b5bb13-c9b6-431e-b4fd-61e58cf4c58f | 6 | public static double getDouble(String prompt, double low, double high) {
final int ALLOWABLE_INPUT_FAILURES = 3; // Avoid leaving a user stuck in here infinitely. If they fail to enter an int after 3 tries, bail out anyway.
String response;
int inputFailureCount = 0;
while (true) { // use an infinite loop. Exit... |
6e94a6a1-c23c-4760-b27d-4361a2ee7bd0 | 9 | @Override
public int hashCode() {
if (hashCode == 0) {
int result = fromViewId != null ? fromViewId.hashCode() : 0;
result = 31 * result + (fromAction != null
? fromAction.hashCode()
: 0);
result = 3... |
b23d6a49-05b1-4b66-837a-94eb02d6fafb | 2 | private synchronized int count_servers(int numberOfUsers, int thrPerEngine) {
int servers;
if (thrPerEngine == 0) {
servers = 0;
} else {
servers = numberOfUsers / thrPerEngine;
if (numberOfUsers % thrPerEngine > 0) {
servers++;
}
... |
520f50f7-4cfc-45a6-bf5e-4563083a4333 | 7 | private ArrayList<String[]> splitPacketsFromStream(String message){
ArrayList<String[]> packets = new ArrayList<>();
ArrayList<String> tempPacket = new ArrayList<>();
int i = 1;
int j = 1;
if(!Character.isDigit(message.charAt(1))){
tempPacket.add(PacketTypes.INVALID.toString());
packets.add(tem... |
5916df6f-7c00-4228-8ec6-e7020db01391 | 7 | @Override
public void actionPerformed(ActionEvent e) {
// Get selected action.
final String action = (String) comboBox.getSelectedItem();
// Get all panels that are drawn.
Component[] panels = pane.getComponents();
// Selected panels.
final ArrayList<GElement> elementPanels = new ArrayList<GElement>();
... |
214bb709-8f9a-4acd-94e4-d1c6917ab335 | 3 | public static ArrayList getOpOp(String arg_op) throws SQLException, ClassNotFoundException, NumberFormatException {
ArrayList sts = new ArrayList();
Connection conPol = conMgr.getConnection("PD");
ResultSet rs;
if (conPol == null) {
throw new SQLException("Numero Maximo de Co... |
187a4d89-5c61-41ef-b342-330add73b9dc | 1 | public void dumpInstruction(alterrs.jode.decompiler.TabbedPrintWriter writer)
throws java.io.IOException {
writer.closeBraceContinue();
writer.print("catch (");
writer.printType(exceptionType);
writer.print(" "
+ (exceptionLocal != null ? exceptionLocal.getName() : "PUSH")
+ ")");
writer.openBrace(... |
7a1e8a08-db54-4822-afed-2f9925bca74b | 9 | private String postprocessing(String world) {
// TODO Auto-generated method stub
boolean cond;
cond = "".equals(world)
|| "zeus".equals(world)
|| world.endsWith("a")
|| world.endsWith("e")
|| world.endsWith("i")
|| world.endsWith("o")
|| world.endsWith("u")
|| world.endsWith("r")
... |
90471419-474f-42c5-a8de-b49f977f3962 | 3 | public static void killme(int num) {
if (num==1){
if (server1 != null) {server1.interrupt();}
}else{
if (server2 != null) {server2.interrupt();}
}
} |
cd5bff7d-639b-4c60-ba8f-2ba494acf010 | 4 | public String getAmount(){
String result = "";
if(gold < 1000) result = Integer.toString(gold);
if(gold >= 1000) result = Integer.toString(gold / 1000) + "k";
if(gold >= 1000000) result = Integer.toString(gold / 1000000) + "m";
if(gold >= 1000000000) result = Integer.toString(gold / 1000000000) + "b";
... |
ada489a6-4893-491b-b301-6bf9afee7f01 | 3 | private void pasteText(){
if(activField.equals("textArea"))
textArea.insert(pasteFromClipboard(),textArea.getCaretPosition());
if(activField.equals("fieldNameFile"))
fieldNameFile.setText(pasteFromClipboard());
if(activField.equals("fieldCommandLine"))
fieldCo... |
423ded8d-5094-4aa0-bc62-5a69c60229af | 2 | @Override
public boolean removeAll(Collection<?> c)
{
boolean removed = false;
for (Object o : c) {
removed |= remove(o);
}
return removed;
} |
a1a16efb-bff2-4f55-9dd6-45dcfb1ac103 | 1 | @Test
public void hahmoPutoaaKorkealta() {
pe.siirra(0, -50);
int hahmonKoordinaattiAlussa = pe.getY();
t.lisaaEste(e);
for (int i = 0; i < 100; i++) {
pe.eksistoi();
}
assertTrue("Hahmo ei pysähtynyt esteesen vaan jatkoi y = "
+ pe.getY()... |
b2fc2fc7-c13e-4605-a94a-319474f8f3f3 | 1 | public void evaluateStack(){
validateEvaluateStack();
while(!operatorStack.empty()){
operandStack.push( op.performOperation(operandStack.pop(), operandStack.pop(), operatorStack.pop()) );
}
} |
98207256-2e35-4d0b-8634-01dc552fc460 | 8 | private void unfilterPaeth(byte[] curLine, byte[] prevLine) {
final int bpp = this.bytesPerPixel;
int i;
for(i=1 ; i<=bpp ; ++i) {
curLine[i] += prevLine[i];
}
for(int n=curLine.length ; i<n ; ++i) {
int a = curLine[i - bpp] & 255;
int... |
6c48271a-35cd-4009-ac9e-941f5cb72536 | 0 | public void setOutline(Color outline) {
this.outline = outline;
} |
03833af6-b4b4-47db-ab69-14ca5d0061f0 | 5 | public int pointToSymbol(int midCount, ByteSet exclusions) {
int sum = 0;
for (int mid = 0; ; ++mid) {
if (mid != EOF_INDEX && exclusions.contains(mid)) continue;
sum += _count[mid];
if (sum > midCount) return (mid == EOF_INDEX) ? ArithCodeModel.EOF : mid;
}
} |
3311e60b-1001-448c-b3f5-a3742ed09d63 | 0 | public void setTipoMovimiento(String tipoMovimiento) {
this.tipoMovimiento = tipoMovimiento;
} |
0c6b18f7-1699-4235-a7af-78f4dd477ad6 | 8 | @Override
public AlgorithmResult<V, E> start(final V vertex, final V startVertex, final V endVertex) throws IllegalGraphException
{
if (startVertex == null)
{
throw new IllegalArgumentException("The start vertex can not be null");
}
if (endVertex == null)
{
... |
75c3b7c2-f026-4b87-b8f5-400f49e8e4ec | 8 | public void generateSearchResults(){
irLists = new ArrayList<IRList>();
q = queryParser.nextQuery();
// while (q != null){
// ArrayList<DocScore> docScores = iRmodel.getRanking(q.toQueryHash());
// PageRank pageRank = new PageRank();
// ... |
be6fd58c-5357-4cbf-a0bb-b2ab914763f1 | 2 | public ArrayList<ArrayList<Float>> ArraytoArrayList(float[][] arr){
ArrayList<ArrayList<Float>> arrayL = new ArrayList<ArrayList<Float>>();
for (int j = 0; j < arr[0].length; j++) {
ArrayList<Float> tempL = new ArrayList<Float>();
for (int i = 0; i < arr.length; i++) {
tempL.add(arr[i][j]);
}
arr... |
192abebf-9c15-4622-9ef2-0f349d54e348 | 6 | private static int[] LastNWLine(int m, int n, String A, String B) {
int[][] K = new int[2][n + 1];
for (int i = 1; i <= m; i++) {
for (int j = 0; j <= n; j++)
K[0][j] = K[1][j];
for (int j = 1; j <= n; j++) {
if (A.charAt(i - 1) == B.charAt(j - 1))
K[1][j] = K[0][j - 1] + 1;
else
K[1][j]... |
65ecd87d-ce68-4160-9aeb-46bbaaf523bf | 5 | @Override
public void encode() throws IOException {
System.out.println("Starting compression of file \"" + sourceFile.getFileName() + "\" to \"" + destinationFile.getFileName() + "\"");
totalTimer = new Timer().start();
// Count the number of occurences of each character in the file
printMessage("Counting char... |
a7eb9adc-acac-4130-9453-91be43667521 | 7 | private static void parseConfig(StyleConfig styleConfig, Element doc) {
NodeList childs = doc.getChildNodes();
for (int i = 0; i < childs.getLength(); i++) {
Node node = childs.item(i);
if ("is-fix-size".equals(node.getNodeName())) {
styleConfig.setIsFixSize(Boolean.parseBoolean(node
.getTextContent... |
8cc282b7-3881-4c14-a0bf-493c49c896e0 | 2 | @Override
public int[] batchUpdate(String... sql) {
try {
Connection connection = getConnection();
Statement stmt = connection.createStatement();
for (String string : sql) {
stmt.addBatch(string + ';');
}
int[] out = stmt.executeBatch();
JdbcUtil.closeStatement(stmt);
JdbcUtil.closeConnectio... |
ff0fca07-0a19-49ac-a8be-0d8606a7bf43 | 9 | Item newInvokeDynamicItem(final String name, final String desc,
final Handle bsm, final Object... bsmArgs) {
// cache for performance
ByteVector bootstrapMethods = this.bootstrapMethods;
if (bootstrapMethods == null) {
bootstrapMethods = this.bootstrapMethods = new ByteVe... |
6b88d4a9-95e1-4f22-bf50-54776ee86a3f | 8 | public void parse(HttpParams params) {
if (params.exists("swLat")) {
swLat = Double.parseDouble(params.getFirst("swLat"));
}
if (params.exists("swLon")) {
swLon = Double.parseDouble(params.getFirst("swLon"));
}
if (params.exists("neLat")) {
neLat = Double.parseDouble(params.getFirst("neLat"));
}
... |
1b92f4b2-b8f4-490a-b79e-fbf4b306519f | 8 | private boolean validMovesExist(){
List<Integer> diceOptions = diceRoll;
//Check bar
Location barOfPlayerInTurn = getBarOfPlayerInTurn();
int barCount = getCount(barOfPlayerInTurn);
if(barCount > 0){
for(int j = 0; j < diceOptions.size(); j++){
Location to = getToLocationFromBar(diceOptions.get(j)... |
7d23633e-3e4d-44f1-8a0c-b2cf86894519 | 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... |
02ced060-b7f8-439d-98e4-a4587de9a2c3 | 7 | @Override
public String execute() throws Exception {
if (cid == 0 || account ==null)
return ERROR;
System.out.println("have the account:" + account + " cid:" + cid);
HttpSession session=ServletActionContext.getRequest().getSession();
User host = (User) session.getAttribute(com.ccf.action.user.UserLogi... |
8e832bfa-6e14-47e5-ae24-2f56af1e4eed | 8 | public GTFSPlugin getPlugin(){
if (plugin == null){
synchronized (this) {
String pluginName = properties.getProperty("plugin");
if (pluginName == null){
plugin = new DefaultPlugin();
}else{
try{
Class<?> pluginClass = Class.forName(pluginName);
boolean validPlugin = false;
... |
a1f95564-6c59-4024-9bb2-82a45153601e | 8 | @Override
public boolean okMessage(final Environmental myHost, final CMMsg msg)
{
if(((msg.targetMajor()&CMMsg.MASK_MALICIOUS)>0)
&&(!CMath.bset(msg.sourceMajor(),CMMsg.MASK_ALWAYS))
&&((msg.amITarget(affected)))
&&(CMLib.flags().isAnimalIntelligence(msg.source())))
{
final MOB target=(MOB)msg.target();
... |
3c07c474-8e6a-4a6b-bbdf-5bfbb92ab575 | 9 | public int maxProfit(int[] prices) {
if (prices == null || prices.length == 0) {
return 0;
}
int[] left = new int[prices.length];
int[] right = new int[prices.length];
int maxSofar = 0, minSofar = 0;
for (int i = 0; i < prices.length; i++) {
if (... |
b84080cf-5ee3-42fe-8ef1-68f7070729ad | 3 | private void clearPath() {
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
if(lab.getWalkways()[i][j] == null) lab.getWalkways()[i][j] = true;
}
}
} |
09beb4cc-1e68-4294-a700-3e9ed1cd16e8 | 4 | private boolean recoverRequest(Request request) {
if (request.site == null) {
System.out.println("error: recovery request have no site");
return false;
}
if (request.site != null)
if (!this.siteMap.containsKey(request.site)) {
System.out.prin... |
01ac6f94-cd26-4717-b009-e2077705556b | 1 | private String extractImageID(final String leaseDescription) {
assert leaseDescription.startsWith("api services lease granted by ");
String currentImageID = leaseDescription.substring(30);
final int firstSpaceIndex = currentImageID.indexOf(" ");
if (firstSpaceIndex > 0) {
currentImageID = currentI... |
d70b9246-807c-4196-b350-f6fe6f46f668 | 0 | public PaymentEntity() {
setId(System.nanoTime());
} |
7a82dfc6-1187-4154-8a1c-5bc837ca7d5f | 2 | public void seeking() {
if (getDistanceToTarget() < SEEKING_TO_ATTACKING_DISTANCE) {
setState(STATE_ATTACKING, "distance to " + target + " is within attacking distance while seeking");
return;
} else if (getDistanceToTarget() > IDLING_TO_SEEKING_DISTANCE) {
setState(STATE_IDLING, "distance to target is out... |
c86cebab-7a7d-437c-982c-6fd1e214340a | 8 | @Override
public boolean mayICraft(final Item I)
{
if(I==null)
return false;
if(!super.mayBeCrafted(I))
return false;
if((I.material()&RawMaterial.MATERIAL_MASK)!=RawMaterial.MATERIAL_WOODEN)
return false;
if(CMLib.flags().isDeadlyOrMaliciousEffect(I))
return false;
if(!(I instanceof Container))... |
bb46d13b-d876-436f-93a2-e16d6526d9a6 | 3 | @Override
public void update() {
if (Physics.checkCollisions(this, ball))
ball.paddleBounce(getCenterY());
float speed = (ball.getCenterY() - getCenterY()) * DAMPING;
if (speed > MAX_SPEEDY)
speed = MAX_SPEEDY;
else if (speed < -MAX_SPEEDY)
speed... |
dabd33d3-081b-477f-b1be-0369289e4b43 | 9 | @Override
public HeightMap applyTo(HeightMap... heightMaps){
double[][] finalHeights = heightMaps[0].getHeights();
int xSize = finalHeights.length;
int ySize = finalHeights[0].length;
for(int iteration = 0; iteration<numIterations; iteration++) {
if (iteration % 10 == 0) ... |
c613dab7-4d7e-48b6-a780-5de1914ab7ae | 0 | public Limbs getLimbs() {
return limbs;
} |
be944942-c1ee-44e5-b7d4-ea11da650b3e | 0 | public LowerTilter() {
requires(Robot.tilter);
} |
6264f2a8-5f02-4cef-8538-86068c1b3163 | 2 | public static int loadTexture(BufferedImage image) {
int[] pixels = new int[image.getWidth() * image.getHeight()];
image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0,
image.getWidth());
ByteBuffer buffer = BufferUtils.createByteBuffer(image.getWidth()
* image.getHeight() * BYTES_PER_PIXEL... |
00eb1a20-c7f4-4f94-acea-086928e54a65 | 8 | private void evalNewArray(int pos, CodeIterator iter, Frame frame) throws BadBytecode {
verifyAssignable(Type.INTEGER, simplePop(frame));
Type type = null;
int typeInfo = iter.byteAt(pos + 1);
switch (typeInfo) {
case T_BOOLEAN:
type = getType("boolean[]");
... |
171d6f02-f41b-4895-bf76-de81af181484 | 1 | public void test_DateTime_setHourZero_Gaza() {
DateTime dt = new DateTime(2007, 4, 1, 8, 0, 0, 0, MOCK_GAZA);
assertEquals("2007-04-01T08:00:00.000+03:00", dt.toString());
try {
dt.hourOfDay().setCopy(0);
fail();
} catch (IllegalFieldValueException ex) {
... |
e860a932-66c8-4ec3-8c14-c3ccc6678c03 | 4 | public void method353(int i, double d, int l1) {
// all of the following were parameters
int j = 15;
int k = 20;
int l = 15;
int j1 = 256;
int k1 = 20;
// all of the previous were parameters
try {
int i2 = -k / 2;
int j2 = -k1 / 2;
int k2 = (int) (Math.sin(d) * 65536D);
int l2 = (int) (Math.... |
606416ba-bb92-485c-a369-7f1ca3382d66 | 2 | public void makeMove(Piece piece) {
if(validMove(piece)) {
ArrayList<Piece> captured = piece.getCapturedPieces(this);
for(Piece p : captured) {
p.setColor(p.getColor().getOpposite());
}
addPiece(piece);
}
} |
2cc0be6a-2ed6-45c7-a973-e1c5a8bcdbd6 | 7 | public boolean getvar2(String stat) {
StringTokenizer str = new StringTokenizer(stat, ",");
while (str.hasMoreTokens()) {
String line = str.nextToken();
String first = "", second = "", relation = "";
boolean check = false;
for (int i = 0; i < line.length(); i++) {
if (line.charAt(i) == '=' || line.c... |
52cde674-b0a4-4437-a47f-0c706de4925e | 1 | private String parseDuration(String time){
if (time != null){
double number = Double.parseDouble(time)/60;
return String.format("%.2f", number)+ " mins";
}
return "NA";
} |
991de421-a5d7-494e-b0ac-f17f3d3ad7f6 | 9 | public void sortColors(int[] A) {
if(A == null || A.length == 0) return;
int first = 0;
int end = A.length -1;
while (first <= end &&A[first] == 0) first++;
first--;
while (end >= 0 && A[end] == 2) end--;
end++;
int i = first+1;
while (i < end){
... |
7c13f174-d067-45ee-a6a7-a98e7ecaa808 | 8 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
//GEN-FIRST:event_jButton1ActionPerformed
list = new LunchDao();
} catch (SAXException ex) {
Logger.getLogger(addItemToLunchMenu.class.getName()).log(Level.SEVERE, null, ex);
} catch (ParserCon... |
a6b47f98-c6f5-4a56-bd6e-3f6b442b241e | 0 | public Table (String filePath){
super();
this.filePath = filePath;
robot = new Robot();
robot.X = 200;
robot.Y = 150;
robot.teta = 0;
} |
9ef2a016-ae0a-4c06-b8f3-a14f383dc35d | 8 | public void putAll( Map<? extends K, ? extends Short> map ) {
Iterator<? extends Entry<? extends K,? extends Short>> it = map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends K,? extends Short> e = it.next();
this.put( e.getKey(), e.getValue() );
... |
fdcb4c81-ca33-44cc-a518-e2f4afc80a0c | 2 | public Player waitForServerPlayer() throws IOException {
// TODO Send server our player info
this.send("JOIN " + this.ourPlayer.getName() + " " + this.ourPlayer.getSignature());
while (true) {
String[] tokens = this.inStream.readLine().split(" ");
if (tokens[0].equals("JO... |
ff4478d4-83d6-408d-9183-efbe9059e541 | 9 | public void actionPerformed(ActionEvent e) {
JButton currentButton = (JButton) e.getSource();
final int index = (int) currentButton.getClientProperty("index");
day = (index < COL) ? 0 : 1;
time = index % COL;
if (selectMany) {
Color btnBack = currentButton.getBackground();
if (btnBack.equals(Col... |
a1e0a57f-24ca-471b-8cfe-14d0446df89c | 4 | static final private HashMap<String,ProcedureDefinition> procedureRecur(HashMap<String,ProcedureDefinition> procedures) throws ParseException, CompilationException {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case TO:
procedure(procedures);
procedureRecur(procedures);
... |
1d7435c1-b610-4abf-aa83-3c2ce52baf08 | 1 | private static List<Appointment> findDailyByDaySpan(long uid,
long startDay, long endDay) throws SQLException {
List<Appointment> aAppt = new ArrayList<Appointment>();
// select * from Appointment where frequency = $DAILY
// and startTime <= $(endDay+DateUtil.DAY_LENGTH)
// and lastDay >= $startDay
Prepar... |
3393efa1-4ef9-476a-aa03-f65c6a245443 | 7 | public void changeTeamTemplate(String username, int newTemplateNumber) {
PreparedStatement newData = null;
PreparedStatement studentFinder = null;
int studentID = -1;
try {
studentFinder = connect.prepareStatement(
" select userID from User " +
... |
25de1a18-22b8-4648-bffa-9e97e0c2f02c | 6 | private void addLabyrinth(int height, int length) {
for (int i = 1; i < height; i++) {
for (int j = 1; j < length; j++) {
if (border(i,j,length,height)) {
super.addBricks(new Point(i, j));
} else if (everyFourthLine(i,j,length,... |
acdbad6f-324a-4ae1-addf-61a0f6f13405 | 9 | public static void query(String tagFile, String[] rpnQuery) {
Expression expression = null;
try {
expression = Querior.parse(rpnQuery);
}
catch(ParseException e) {
System.out.println("Problem parsing expression: " + e);
return;
}
if (ex... |
0e216ade-102f-48bb-92b4-9c1ae931b3f1 | 8 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
if(!super.invoke(mob,commands,givenTarget,auto,asLevel))
return false;
if((!auto)
&&(!mob.isMonster())
&&(!disregardsArmorCheck(mob))
&&(!CMLib.utensils().armorCheck(mob,CharClass.ARMOR_LEA... |
ad7f46a5-099c-4d4b-9409-5724caed88c5 | 9 | public boolean isInside(int x1, int y1, int x2, int y2)
{
int tmp = x1;
if (x2 < x1) {
x1 = x2;
x2 = tmp;
}
tmp = y1;
if (y2 < y1) {
y1 = y2;
y2 = tmp;
}
return (x1 < x && x < x2) && (y1 < y && y < y2)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.