method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
58b6a4c4-6103-4a66-abb8-2fce31bf12dd | 5 | public void drawGrid(Graphics g) {
Graphics2D g2d = (Graphics2D)g.create();
for (int r = 0; r < data.length; r++) {
for (int c = 0; c < data[r].length; c++) {
// change color according to the cell state
switch (data[r][c]) {
case TetrisBoard.EMPTY:
g2d.setColor(Color.DARK_GRAY);
break;
... |
bb44aa93-c0dc-465a-a281-36d75d6557f0 | 0 | public void setPaese(String paese) {
this.paese = paese;
} |
b6ab35ec-16b5-4b5a-9310-61d65d5dd1ab | 1 | private static void method505(char arg0[]) {
char ac1[] = arg0.clone();
char ac2[] = { 'd', 'o', 't' };
Censor.method509(null, ac1, ac2);
char ac3[] = arg0.clone();
char ac4[] = { 's', 'l', 'a', 's', 'h' };
Censor.method509(null, ac3, ac4);
for (int i = 0; i < Censor.aCharArrayArray624.length; i++) {
C... |
75c7501b-f7c5-4ee8-a000-014cb26fc0fc | 3 | public boolean canBuildCity() {
if(cities>0&&resources.getOre()>2&&resources.getWheat()>1)
return true;
return false;
} |
7d193a9b-22b0-4d47-88c5-84764e68592c | 1 | private static double totalSize(HLLCounter ... hs) {
byte[] R = new byte[hs[0].getByteArray().length];
for(int i = 0; i < hs.length; i++) {
R = safeUnion(R, hs[i].getByteArray());
}
return estimateSize(R, getAlpha(R.length));
} |
8c04329d-f3c5-4c66-a26f-92aced5fc485 | 4 | private void set_curr_reader(get_settings settings){
if(settings == null) return;
session_language = null;
session_language = settings.get_last_lang();
session_meter = settings.get_last_meter();
if(session_meter > 0 && session_meter < 3)
sel_reader.setSelectedIndex(session_meter-1);
else
sel_... |
2b5667e2-6046-4f73-b3aa-8602b93824d2 | 7 | @Override
public void itemStateChanged(ItemEvent e) {
if (e.getSource().getClass() == JCheckBox.class) {
JCheckBox sender = (JCheckBox) e.getSource();
if (sender == showGrid) {
if (e.getStateChange() == ItemEvent.SELECTED) {
plotterPanel.setShowGri... |
0ce4a173-c3d0-47f1-a2d0-9b6e62b7e3a8 | 9 | @Override
public void run() {
int op;
do {
listPayMeansAUX = pmc.getListPaymentMeans();
op = menu();
switch (op) {
case 0:
break;
case 1:
System.out.println("You chose to add Cash:");
... |
aeeac71b-546f-4f71-bff9-84c7061439e9 | 4 | public static void main(String[] args) {
//int x = 47;
//String s = "Hola";
try {
FileReader fr = new FileReader("LeerArchivo.txt");
BufferedReader bf = new BufferedReader(fr);
String sCadena;
while ((sCadena = bf.readLine())!=null) {
System.out.println("La cadena es: "+sCad... |
900bbc4d-caf2-45dc-adc6-54d01fab952f | 4 | void run(String fileName) {
try {
in = new BufferedReader(new FileReader(fileName));
out = new PrintWriter(FILE_NAME + ".out");
solution();
} catch (IOException e) {
out.println("Can not open file");
} catch (WrongDataInFileException e) {
out.println("Wrong data");
} finally {
try {
... |
c37cc627-877c-4a34-bac6-34b2f2da63cc | 3 | private void writeFin(String user, int glID, String resName,
double cost, double cpu, double clock)
{
// Write into a results file
FileWriter fwriter = null;
try
{
fwriter = new FileWriter(user + "_Fin.csv", true);
} catch (Exception ex)
... |
f563dab4-8b5b-4d5f-a094-4d48df4f5cbe | 5 | private static double distance(double referencePoint, double xVelocity, double centerX, double radius) {
// System.out.println("Calling distance with reference point " + referencePoint);
double paddleGap = Constants.stageWidth * .6;
// System.out.println("Paddle Gap is " + paddleGap);
if (xVelocity > 0 && referen... |
937f48f5-740e-4f71-86e9-ea1a45f0f0c3 | 5 | static final boolean method1842(int i, int i_0_, int i_1_, int i_2_,
int i_3_, int i_4_, int i_5_, int i_6_,
int i_7_) {
anInt6134++;
if (i_1_ != -1)
return false;
if ((i + i_5_ ^ 0xffffffff) >= (i_3_ ^ 0xffffffff)
|| (i_5_ ^ 0xffffffff) <= (i_3_ - -i_6_ ^ 0xffffffff))
return false;
i... |
0907da54-5170-4266-8693-d343b9900046 | 9 | @Override
public String stateStringSubject(Rider R)
{
switch(rideBasis)
{
case Rideable.RIDEABLE_AIR:
case Rideable.RIDEABLE_LAND:
case Rideable.RIDEABLE_WATER:
case Rideable.RIDEABLE_WAGON:
return "being ridden by";
case Rideable.RIDEABLE_TABLE:
return "occupied by";
case Rideable.RIDEABLE_SIT:... |
df5e119e-ca5c-4815-8fae-63fc73997e00 | 6 | private String getFile(String link)
{
String download = null;
try
{
// Open a connection to the page
URL url = new URL(link);
URLConnection urlConn = url.openConnection();
InputStreamReader inStream = new InputStreamReader(urlConn.getInputStrea... |
764fb1c2-d9ad-48fc-be25-0c69e2aa3477 | 1 | public Tile getTileAt(int tx, int ty) {
return (bounds.contains(tx, ty)) ?
map[ty - bounds.y][tx - bounds.x] : null;
} |
b7c3963e-701a-4d36-923b-225f5bccdb58 | 6 | @Override
public final T rollback() throws InvalidProcessStateException, ProcessRollbackException {
if (state != ProcessState.EXECUTION_FAILED && state != ProcessState.EXECUTION_SUCCEEDED
&& state != ProcessState.PAUSED) {
throw new InvalidProcessStateException(this, state);
}
// only rollback if componen... |
409b5d5c-0fac-4f5d-9582-9c71224fe122 | 4 | private void btnAddAssetToTheListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddAssetToTheListActionPerformed
selectedAsset = (Asset) listAssetsList.getSelectedValue();
boolean exists=false; // check if asset id exists (can't check for object because of different hash code)
... |
2a97ab09-1079-46cf-b0bd-8ab31edcd94a | 6 | public int doNestedTermConjunctions(IndexSearcher s,
int termsInIndex,
int maxOuterClauses,
int maxClauses,
int iter
) throws IOException {
int ret=0;
long nMatches=0;
for (int i... |
da76ccd9-1f6a-4c92-b9d6-21061fa8eec8 | 4 | public String saveString() {
String savefile = "";
for (int i=0; i<vortexSpaces.length; i++) {
Space space = vortexSpaces[i];
if (space != null) {
if (space instanceof Room) {
Room room = (Room)space;
int[] location = room.getPreciseLocation();
savefile += room.getId() + " " + room.getConst... |
f5321554-7552-47df-b524-a003ba1d3a14 | 1 | public boolean addOpenFormat(String formatName, OpenFileFormat format) {
if (isNameUnique(formatName, openerNames)) {
format.setName(formatName);
openerNames.add(formatName);
openers.add(format);
// Also add it to the list of formats stored in the preferences
Preferences.FILE_FORMATS_OPEN.add(forma... |
9fa556f8-8648-47f9-b7f3-d37570a0e7f8 | 2 | private int[][] createEtat(String etat) {
int etat_courrant[][] = new int[9][9];
int n = 0;
for(int i =0 ; i < 9; i++){
for(int j = 0 ; j< 9; j++){
etat_courrant[i][j] = Integer.parseInt( (String) etat.subSequence(n,n+1));
n++;
}
}
return etat_courrant;
} |
b6bc73c1-f61d-45a4-aa0f-6feb7a9cb5f7 | 4 | private static void createInfo() {
MainMenuUI mainMenu = new MainMenuUI();
int option = mainMenu.createInformation();
switch (option) {
case 1:
createProduct();
break;
case 2:
createCategory();
break;
case 3:
createUser();
break;
case 0:
break;
default:
mainMenu.showOptionNotVal... |
81ab7101-8ce5-4930-874b-bf736a62f0fc | 4 | static final private ArrayList<AbsStatementNode> ifParamSup() throws ParseException, CompilationException {
ArrayList<AbsStatementNode> val2;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case OPENBRACKET:
jj_consume_token(OPENBRACKET);
val2 = listInstructions();
jj_consume_token(CLOSEBRACKE... |
d1250674-5856-473f-9fdf-75696cb6419b | 6 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Holiday other = (Holiday) obj;
if (day != other.day)
return false;
if (month != other.month)
return false;
if (year != other.year)
r... |
65efae07-7865-4071-8b7f-dbccbd586ff2 | 8 | private static PreparedStatement setParametersInPreparedStatement(
PreparedStatement preparedStatement, Object... parameters) throws SQLException {
int i = 1;
for (Object parameter : parameters) {
if (parameter instanceof String) {
preparedStatement.setString(i, (Stri... |
9c3a219e-a953-4e96-9c48-6bf2c140e89a | 9 | @Override
public void run() {
// System.err.print("lkhk");
/*
* DatagramSocket sock = null; try { sock = new DatagramSocket(1234);
* sock.setBroadcast(true);
* sock.connect(InetAddress.getByName("255.255.255.255"), 1234);
*
* } catch (SocketException e1) { // TODO Auto-generated catch block
* ... |
a442a26d-e170-482f-8877-d6ddd79e8329 | 9 | public static void iterateOverFields(Class<?> clz,Class<?> goUpto,ReflectionCallback<Field> callback) {
try{
for(Class<?> c=clz; c!=null && (goUpto==null || goUpto.isAssignableFrom(c)) ; c=c.getSuperclass()) {
for(Field f : c.getDeclaredFields()) {
f.setAccessible... |
5878ba3d-1b58-47c9-9aab-3ba03849771d | 4 | @Override
public List<BankRequiredItem> getItemsNeededFromBank() {
List<BankRequiredItem> list = new ArrayList<BankRequiredItem>();
if (ctx.backpack.select().id(AIR_RUNE).isEmpty()) {
list.add(new BankRequiredItem(0, false, null, AIR_RUNE));
}
if (ctx.backpack.select().id(LAW_RUNE).isEmpty()) {
list.ad... |
f7a0f052-de6b-4430-91dd-8a32bce277c5 | 2 | public int commonPrefixedPathNumber(String prefix) {
int count = 0;
PGridPath prefixPath = new PGridPath(prefix);
for (String path : unsolvedPaths_.keySet()) {
PGridPath otherPath = new PGridPath(path);
if (otherPath.hasPrefix(prefixPath)) {
++count;
... |
9e549cbb-3967-4e41-b49a-cbaed02f7e2c | 6 | private void listenForDatabaseServers() {
if (this.listeningSocket != null) {
byte[] buffer = new byte[100];
DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
while (this.running && this.dbServers.isEmpty()) {
try {
this.listeningSocket.receive(packet);
InetAddress address = pa... |
7fb97500-b65b-41b4-acb1-cb2693bc1e82 | 7 | private void HTTPbuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_HTTPbuttonActionPerformed
// TODO add your handling code here:
try {
CustomURLClassLoader loader = new CustomURLClassLoader();
Class<?> c = loader.loadClass("PersistentAnimationTester");
... |
113c1842-4ecf-46c1-bc64-ab10a66a454a | 9 | public void update(){
final STATE state = this.now_state;
switch(state){
case STATE_NORMAL:
/* プレイヤーが移動要求をしてきたら*/
if(player.get_now_state() == Player.STATE.STATE_MOVE_STAGE_EVENT){
/* マップとイベントを停止する */
this.event_manager.set_now_state(EventManager.STATE.STATE_STOP);
this.now_state = STATE.STATE_... |
d278858b-832b-40e1-a3ae-a7dfe627f907 | 1 | public void testPlus_int() {
Minutes test2 = Minutes.minutes(2);
Minutes result = test2.plus(3);
assertEquals(2, test2.getMinutes());
assertEquals(5, result.getMinutes());
assertEquals(1, Minutes.ONE.plus(0).getMinutes());
try {
Minutes.MAX_V... |
82a843a4-eba2-4bf8-9684-96ab2854c6fc | 2 | public void test_17_overlap_rand() {
int numTests = 10;
int minLen = 10;
System.err.print("\nOverlap random test:\n");
Random rand = new Random(20100812);
for( int maxlen = 10, i = 1; maxlen < 10000; maxlen += 10, i++ ) {
for( int it = 0; it < numTests; it++ )
overlapRandTest(maxlen, minLen, rand);
... |
a05ef608-0508-4cc1-be37-0c9e909d48bc | 6 | @Override
public void run() {
while (true) {
try {
synchronized (this) {
while (queries.isEmpty()) {
this.println("Waiting for query");
this.wait(1000); // for something to do
}
this.println("Query received");
ChannelQueryPair<Channel, Query> channelQueryPair = queries.poll();
... |
3ae85bbf-2835-4dc2-b55f-d59622d3d1f4 | 6 | public static HashMap<Integer, List<Double>> getMap() throws Exception
{
HashMap<Integer, List<Double>> map = new HashMap<Integer, List<Double>>();
BufferedReader reader = new BufferedReader(new FileReader(
new File(ConfigReader.getChinaDir() + File.separator +
"metabolites" + File.separator +
... |
61c7b9c9-f3b6-4638-879e-35c0174f8779 | 9 | public int compare(Datum other) {
if (this.godina > other.godina){
return -1;
} else if (this.godina >= other.godina && this.mjesec > other.mjesec){
return -1;
} else if (this.godina >= other.godina && this.mjesec>= other.mjesec && this.dan > other.dan){
return -1;
} else if (this.godina == other.go... |
9397355c-9e6e-4abb-a4d7-88c87b4ed05e | 4 | public void damage(int damage, int dir, Mob toDamage, Mob attacker){
if(target == null) target = attacker;
if(damage > 0){
for(int i = 0; i < (damage * 3); i++) dungeon.addParticle(new BloodParticle(dungeon.getParticles().size(), x, y, 0xffE04141, 2, 0.4, dungeon, random));
dungeon.addParticle(new TextPart... |
5fd4e8a8-b202-4a17-9d1e-5a54b681923e | 8 | public static void main(String args[])
{
String j[] = new String[2];
j[0] = "Paul";
j[1] = "Jean";
MainManager mm = new MainManager(10, j);
Joueur j1 = mm.getJoueurs()[0];
Joueur j2 = mm.getJoueurs()[1];
try {
System.out.println(j1.getCaseActuelle().getNom());
System.out.... |
32f9f025-45d9-4f53-a66a-c5bce5d87c3b | 9 | protected void FillBuff() throws java.io.IOException
{
if (maxNextCharInd == available)
{
if (available == bufsize)
{
if (tokenBegin > 2048)
{
bufpos = maxNextCharInd = 0;
available = tokenBegin;
}
else if (tokenBegin < 0)
bufpos = maxN... |
da4f06b8-3234-4a53-b6b3-d1efb8cc264a | 3 | public boolean getScrollableTracksViewportHeight()
{
if (scrollableHeight == ScrollableSizeHint.NONE)
return false;
if (scrollableHeight == ScrollableSizeHint.FIT)
return true;
// STRETCH sizing, use the greater of the panel or viewport height
if (getParent() instanceof JViewport)
{
return (... |
37ef58e5-6a9c-44c7-822e-051a7fb63f1a | 5 | void initWesternEncoding( byte[] ustrdata ) throws NegativeArraySizeException
{
// get the row, col and ixfe information
cch = ByteTools.readShort( ustrdata[0], ustrdata[1] );
int dlen = cch + 0;
grbit = ustrdata[2];
offer = 3;
// is is double byte stream?
if( (grbit & 0x1) == 0x1 )
{
dlen *= 2;
... |
ba10fdc4-5885-4952-b606-7884bbfd4c11 | 1 | @Override
public Geometry getGeometry() {
if (geometry != null) {
return geometry;
}
render();
geometry = getGeometryForBoundingBox(text.getBBox());
return geometry;
} |
c01eb80c-ceb4-48b6-a06b-62f0da8aa218 | 2 | @EventHandler
public void onCMD(PlayerCommandPreprocessEvent e) {
Player player = e.getPlayer();
if ((!plugin.randomText.contains(player)) && (!e.getMessage().contains("verify")))
{
e.setCancelled(true);
}
} |
c10f6b4d-f0c4-4ab7-a3fa-24618709bcc1 | 8 | public static String getIsoDate(Calendar origCalendar) {
if (origCalendar == null) return null;
// Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
// calendar.setTime(date);
StringBuffer buffer = new StringBuffer();
// doing a calendar.get() causes *all* fields to be set!
... |
110af54f-3fd8-4c68-8d51-415d696b43ce | 6 | public Box2D cropBy(Box2D box) {
if (xpos < box.xpos) xpos = box.xpos ;
if (ypos < box.ypos) ypos = box.ypos ;
if (xmax > box.xmax) xmax = box.xmax ;
if (ymax > box.ymax) ymax = box.ymax ;
if (xmax < xpos) { xmax = xpos ; xdim = 0 ; }
else xdim = xmax - xpos ;
if (ymax < ypos) { ymax = ypos ... |
0563da04-8a86-4f6e-a767-1b679350d8cf | 1 | public void accept(Visitor visitor) {
for (Element element : mElements) {
element.accept(visitor);
}
} |
ff00525e-634e-4c52-9f3e-f8a71dddc067 | 7 | public void addData(int num) {
if (leftMaxQueue.isEmpty() && rightMinQueue.isEmpty()) {
rightMinQueue.add(num);
return;
} else {
int leftMax = leftMaxQueue.peek();
int rightMin = rightMinQueue.peek();
if (num < leftMax) {
if (leftMaxQueue.size() > rightMinQueue.size()) {
rightMinQue... |
47e42516-ce46-4e0f-ace0-554b29fb88c9 | 4 | public static void loadSettingsFromJSON(JSONObject json, String tagToApply) {
for (Object obj : (JSONArray)json.get("settings")) {
JSONObject setting = (JSONObject)obj;
if (tagToApply == null) {
if (setting.get("tag") != null) {
setSetting(setting.get(... |
198f873d-26ac-49f0-a0ce-726ddb4c1c25 | 1 | public void render(Graphics g)
{
g.setColor(new Color(0, 0, 0, 150));
g.fillRect(0, 0, Game.WIDTH, Game.HEIGHT);
g.setColor(Color.BLACK);
g.fillRect(x, y, w, h);
g.setColor(Color.WHITE);
g.fillRect(x + bW, y + bW, w - 2 * bW, h - 2 * bW);
swi... |
e0ea6cb8-4a8c-48aa-8e43-c5275e246e64 | 5 | protected WhereisHelper getHelper() {
OsEnum os = OsEnum.getOS(System.getProperty("os.name"));
switch (os) {
case WINDOWS_XP:
case WINDOWS_VISTA:
case WINDOWS_SEVEN:
return new WhereisStubHelper();
case LINUX:
case MAC_OSX:
return new WhereisHelper();
default:... |
f99ae83d-b986-4b3b-805d-c6a885c3fecb | 1 | @Override
public int getFirstSlotLocationX() {
return isNotPlayerInventory() ? centerX-49 :centerX - 2 - (72);
} |
10aac2c7-bbea-4531-8504-0168ae08efd5 | 0 | public int getPhoneNumber() {
return phoneNumber;
} |
38ae1eba-3979-41b4-83c6-5ae10c8e7449 | 6 | private static void errorMessage(String message, String expecting) { // Report error on input.
if (readingStandardInput && writingStandardOutput) {
// inform user of error and force user to re-enter.
out.println();
out.print(" *** Error in input: " + message + "\n");
out.... |
7755b28b-52ba-4ff0-8f24-b334a7f0f56d | 1 | @Override
public List getErrors() {
return dataSet != null ? dataSet.getErrors() : Collections.emptyList();
} |
db4e3786-bce1-44a4-bc46-fcc1617c049d | 6 | protected boolean find_recovery_config(boolean debug)
{
Symbol error_token;
int act;
if (debug) debug_message("# Finding recovery state on stack");
/* Remember the right-position of the top symbol on the stack */
Symbol right = ((Symbol)stack.peek());// TUM 20060327 removed .right
... |
b9dc200d-e2f2-41d8-a387-8495b8e330fb | 6 | public static String generate() {
String[] vowel = {"A", "E", "I", "O", "U", "Y"};
String[] consonant = {"B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "V", "W", "X", "Z"};
String randName = "";
Random rnd = new Random();
int nameLength = rnd... |
59d6d4f2-a0ba-4982-8576-a92a1b541e5d | 3 | public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof HttpRequest) {
HttpRequest req = (HttpRequest) msg;
if (is100ContinueExpected(req)) {
ctx.write(new DefaultFullHttpResponse(HTTP_1_1, CONTINUE));
}
... |
1c13833f-2fca-4ebf-a8f9-240651219226 | 9 | protected void loadFields(com.sforce.ws.parser.XmlInputStream __in,
com.sforce.ws.bind.TypeMapper __typeMapper) throws java.io.IOException, com.sforce.ws.ConnectionException {
super.loadFields(__in, __typeMapper);
__in.peekTag();
if (__typeMapper.isElement(__in, CreatedBy__typeInfo)) {
... |
98f7a49c-542b-4649-a1e2-fe589065350f | 7 | @Override
public long fastCount(int scanSpan, int countOut) {
if (daoFunc != null) {
return daoFunc.fastCount(scanSpan, countOut);
} else {
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
SqlC sqlC = SqlC.select(voClass);
int count = 1;
sqlC.limit(new Pager(count, scanSpan));
... |
888ea0fd-5191-48d8-bfce-5c168b35f6c8 | 0 | public Journal getJournal() {
return journal;
} |
a7ba9bb9-44b7-4437-92f0-c704c09df38a | 4 | public boolean isSorted() {
int length = this.array.length, i;
length--;
for (i = 0; i < length; i++) {
if (this.array[i].compareTo(this.array[i + 1]) < 0
|| this.array[i].equals(this.array[i + 1])) {
continue;
} else {
... |
075dbd07-e0e5-4397-9a64-8c58192b255b | 4 | private static void saveSettings() {
File settings = new File("test.txt");
Logger.log("CONFIG", "Using " + settings.getAbsolutePath() + " as settings");
if (!settings.exists()) {
try {
settings.createNewFile();
} catch (Exception e) {
Logger.log("SEVERE", "ERROR CREATING SAVEFILE!");
}... |
a75691a4-72c4-4b1c-aa47-283e0980aac5 | 2 | private void createContents(final Shell shell) { //Creates the box contents
// Creates the box contents
int lineSpace = 20; //Space between lines
int horizMargin = 5; //Horizontal margin
int vertMargin = 5; //Vertical margin
int bottomMargin = 6; //Bottom margin
int interSpace = 20; //Space between boxes
... |
0eeb4d4d-9405-428e-ac25-5416ebf42780 | 4 | public void updateStats(int[] bowl, int round)
{
// Once you receive the first bowl, calculate the size of a bowl
if (!firstBowlReceived) {
for (int i = 0; i < bowl.length; i++) {
this.bowlSize += bowl[i];
}
firstBowlReceived = true;
}
... |
2e0db460-d879-42d0-aabe-7fdb27fc8ab5 | 5 | @SuppressWarnings("resource")
public static void copyFolder(File src, File dest) throws IOException {
if (src.isDirectory()) {
if (!dest.exists()) {
dest.mkdir();
}
String files[] = src.list();
for (String file : files) {
File srcFile = new File(src, file);
File destFile = new File(dest, file... |
3c09abaa-0941-4cde-8a42-9dd1e1549ea0 | 8 | public int maxProfit3(int [] prices){
if(prices == null || prices.length <= 1) return 0;
int [] diff = new int [prices.length - 1];
for (int i = 0; i < prices.length - 1; ++i){
diff[i] = prices[i+1] - prices[i];
}
int [] DP = new int[diff.length];
DP[0] = diff... |
891fcaeb-5001-4225-9e21-e9170b18c518 | 1 | public void init(boolean forEncryption, KeyParameter params)
{
if(params instanceof KeyParameter)
{
workingKey = ((KeyParameter) params).getKey();
setKey(workingKey);
return;
}
throw new IllegalArgumentException("invalid parameter passed to RC4 in... |
b7202bc8-6f63-4af3-87c5-7921d4c872ca | 9 | public void draw(Graphics2D g) {
if (Float.isInfinite(x) || Float.isInfinite(y) || Float.isNaN(x) || Float.isNaN(y)) {
System.err.println("Warning: NaN pos: " + getUID());
return;
}
int tx = (int) x;
int ty = (int) y;
int r = (int)this.r;
g.translate(tx, ty);
if (getType() == Visode.TYPE_L... |
6934ee44-3bd1-4ae2-9e4f-e2331a6629d4 | 7 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof Storage))
return false;
Storage other = (Storage) obj;
if (size != other.size)
return false;
if (type == null) {
if (other.type != null)
return false;
} else ... |
f67f500d-5b09-451b-87ec-28c4a2f46daa | 7 | public Instance createInstance(InstanceContext context) {
RunInstancesRequest runInstancesRequest = new RunInstancesRequest();
runInstancesRequest.withImageId(context.getImageId())
.withMinCount(1).withMaxCount(1);
if (context.getInstanceType() != null) {
runInstancesRequest.withInstanceType(context.ge... |
9069f8cc-3658-48f4-b0d4-d346eeddaff2 | 4 | @Override
public void keyReleased(int key, char c) {
switch(key) {
case Input.KEY_UP:
player.stopMoving(Direction.NORTH);
break;
case Input.KEY_DOWN:
player.stopMoving(Direction.SOUTH);
break;
case Input.KEY_LEFT:
player.stopMoving(Direction.WEST);
break;
case Input.KEY_RIGHT:
player.sto... |
aff56d5b-11fb-4af8-9d2f-3fc13eb503fa | 3 | protected Pattern(int load) {
if (load == NOLOAD) {
loadString = "None";
} else if (load == LOWLOAD) {
loadString = "LOW_LOAD";
} else if (load == HIGHLOAD) {
loadString = "HIGH_LOAD";
}
grid = createGrid();
dotArray = computeDotArray();
} |
4d7de80a-e221-4759-b8f8-2ac8bea4b19c | 6 | public boolean onPlayerDestroyBlock(int par1, int par2, int par3, int par4)
{
ItemStack stack = mc.thePlayer.getCurrentEquippedItem();
if (stack != null && stack.getItem().onBlockStartBreak(stack, par1, par2, par3, mc.thePlayer))
{
return false;
}
int var... |
b909851d-27db-41b1-bcbe-ae01e8e10799 | 8 | public void paint(Graphics g) {
switch (this.selectedObject) {
case DrawPanel.Selection:
if (pointList.size() > 0) {
for (GraphicsPrimitive gp : shapeList) {
if (gp.contains(pointList.get(pointList.size() - 1))) {
if (!gp.isSelected()) {
gp.getBoundingBox().draw(g);
}
break;... |
86d22c2d-d41e-4533-a7cf-7853cc31490d | 8 | String consumeLetterThenDigitSequence() {
int start = pos;
while (pos < length) {
char c = input[pos];
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
pos++;
else
break;
}
while (!isEmpty()) {
char c = ... |
72304474-4b4e-403f-9352-d3b0711ad235 | 3 | public int getUniqueID(){
int id = 0;
boolean unique = false;
while (!unique){
unique = true;
for (int x = 0; x < mobs.size(); x++){
if (id == mobs.get(x).getID()){
unique = false;
id++;
}
}
}
return id;
} |
2b39a9bd-4c18-4032-9f26-bbf3bdad5cdd | 9 | @Override
public AbstractClientState receiveMessage(ClientMessage message) {
if (message == null) {
LogoutMessage m = new LogoutMessage();
m.setClientId(this.getClient().getClientID());
this.game.receive(m);
AuthenticationService.logout(this.getClient());
logger.info("client " + this.getClient()
... |
371b1e4b-29ce-41a2-b98a-e79e5d7b9518 | 8 | public void setTemplateOff(int[][] strandMut, int res1, int res2, boolean shellRun, boolean templateOnly){
templateOffA96ff = new Amber96ext(m, distDepDielect, dielectConst, doSolvationE, solvScale, vdwMultiplier);
boolean savedEnergyEvalSC[] = new boolean[m.numberOfResidues];
boolean savedEnergyEvalBB[] = new... |
7923bfb7-3ce8-46ff-8ad6-fee71f19344f | 0 | public void addChatGuiListener(ChatGuiListener listener) {
chatGuiListener.add(listener);
} |
05d5c287-cc8a-48bd-81a8-035d7b5cb827 | 4 | @Override
public void ParseIn(Connection Main, Server Environment)
{
Room Room = Environment.RoomManager.GetRoom(Main.Data.CurrentRoom);
if (Room == null)
{
return;
}
Main.Data.BadgesSelected.clear();
for(int i = 0;i<SLOTS;i++)
{
... |
ec09f6ff-f62a-45a2-a21c-129217959abd | 4 | public void setType (int type) {
_type = type;
ImagesManager imgMng = ImagesManager.INSTANCE;
switch (type) {
case TYPE_RED:
_image = imgMng.getImage(KEY_RED);
break;
case TYPE_GREEN:
_image = imgMng.getImage(KEY_GREEN);
break;
case TYPE_BLUE:
_image = imgMng.getImage(KEY_BLUE);
break;
c... |
dea2a68f-3f30-4484-b48c-3862c48206a7 | 6 | public void loadDataFromFile()
{
FileConfiguration config = getConfig();
List<AGPlayer> list = new ArrayList<AGPlayer>();
for(String pName : config.getKeys(false))
{
List<Shrine> shrines = new ArrayList<Shrine>();
for(String s : config.getStringList(pName+".found")) {
Shrine shrine = sH.getShri... |
6e11c0ca-2db2-421e-b7a3-6fa5a49b6f58 | 4 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
PeripheralDevice other = (PeripheralDevice) obj;
if (deviceGroup != other.deviceGroup)
return false;
return true;
} |
9087abfe-66f4-49c5-8ff6-8d1c27aec41f | 3 | public static List<FavoritesTag> constructTag(Response res) throws WeiboException {
try {
JSONArray list = res.asJSONObject().getJSONArray("tags");
int size = list.length();
List<FavoritesTag> tags = new ArrayList<FavoritesTag>(size);
for (int i = 0; i < size; i++) {
tags.add(new FavoritesTag(list.get... |
eea8ca08-97b1-46a6-bc3b-344acf2dfad3 | 8 | private void lstCommandeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lstCommandeMouseClicked
// TODO add your handling code here:
Vector v;
dtm = (DefaultTableModel) tblArticle.getModel();
while (dtm.getRowCount() != 0) {
dtm.removeRow(0);
}
... |
1e441622-5c25-4e8d-a0a6-9a8f20ac3cb5 | 4 | public String getMapValue(Field field) throws IllegalAccessException{
Map<String, String> newMap = new HashMap<String, String>();
Map<?, ?> map = (Map)field.get(obj);
int m = 0;
for (Map.Entry entry : map.entrySet()) {
if (m < getMaxAmount(field)) {
newMap.... |
6d60c6f3-7506-49a4-9d86-47f6d071d6d4 | 8 | public static <VertexType extends BaseVertex
, EdgeType extends BaseEdge<VertexType>>
BaseGraph<VertexType, EdgeType> sum(BaseGraph<VertexType, EdgeType> g1, BaseGraph<VertexType, EdgeType> g2) {
BaseGraph<VertexType, EdgeType> g = g1.createEmptyGraph();
HashMap<VertexType, VertexType> t... |
81db19ee-7abc-42df-92a4-7eeabcf0b0aa | 4 | public static Gender with(String genderAbriviation) {
if (genderAbriviation == null || genderAbriviation.isEmpty())
return null;
if ("M".equalsIgnoreCase(genderAbriviation))
return MALE;
if ("W".equalsIgnoreCase(genderAbriviation))
return FEMALE;
return null;
} |
4af3acf8-bc28-4473-a155-4723b8aed69b | 7 | protected void paintComponent(Graphics g){
super.paintComponent(g);
Graphics2D g2D = (Graphics2D)g;
if (gui.networkInitiated){
double[][] weightMatrix = gui.getNetwork().getWeightMatrix();
int gridRowsBefore;
int position;
int posInGrid;
... |
a289add8-1f20-4527-a18e-9df4692f4edd | 4 | public static int characterSize(int character) throws JSONException {
if (character < 0 || character > 0x10FFFF) {
throw new JSONException("Bad character " + character);
}
return character <= 0x7F ? 1 : character <= 0x3FFF ? 2 : 3;
} |
bcbb2288-50d1-460f-b097-279f5ff440aa | 1 | public boolean removeChild(Row row) {
if (row.isChildOf(this)) {
mChildren.remove(row);
row.mParent = null;
return true;
}
return false;
} |
e3abc9db-cad5-4eb9-8628-ecbb82daa928 | 8 | private Tuple<Integer, Integer> traceDirection(Set<Tuple<Integer, Integer>> set,
int board[][], int player,
int startX, int startY, int dx, int dy) {
Tuple<Integer, Integer> res = new Tuple<>(0, 0);... |
c48fea6c-f4a2-4a00-9433-c62283c5356c | 7 | public static void main(String[] args)
{
try
{
// Print out 10 hashes
for(int i = 0; i < 10; i++)
System.out.println(PasswordHash.createHash("p\r\nassw0Rd!"));
// Test password validation
boolean failure = false;
System.out... |
caad4f3f-5634-4f33-b878-acfdc5f784c6 | 3 | public boolean isOpen() {
if (ctx.widgets.getValidated(new Filter<Widget>() {
@Override
public boolean accept(Widget element) {
return element.getParentId() == WIDGET_ID && element.getId() == 60;
}
}).get(0) == null) {
return false;
... |
7538e3d8-04f9-4b39-ad46-a8ce561537f2 | 7 | @EventHandler
public void GhastNightVision(EntityDamageByEntityEvent event) {
Entity e = event.getEntity();
Entity damager = event.getDamager();
String world = e.getWorld().getName();
boolean dodged = false;
Random random = new Random();
double randomChance = plugin.getZombieConfig().getDouble("Ghast.Night... |
2b3d5a11-ea18-4302-b2f3-8ff98934e46e | 1 | public int getDefense()
{
int result = defense + cityDefense;
for (Artifact a: active.values()) {
result += a.defense;
}
return result;
} |
bfb2bf6f-6d0c-454d-a485-649900b36756 | 3 | public String getHelpText(HelpType command) throws MemorygameException {
String helpText = "";
switch (command) {
case OBJECTIVE:
case ONE_PERSON_GAME:
case TWO_PERSON_GAME:
helpText = command.getHelpText();
break;
... |
fab1cf32-afdc-46ef-bdfe-46bff5078803 | 2 | @Override
public String getDefaultExtension() {
Iterator i = getExtensions();
while (i.hasNext()) {
String key = (String) i.next();
Boolean value = (Boolean) extensions.get(key);
if (value.booleanValue()) {
return key;
}
}
return null;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.