method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
695f8a6f-cf15-48da-ac51-32b959f9dc47 | 8 | public List<Point> findPath(int startx, int starty, int endx, int endy) {
NodeSet openSet = new NodeSet();
nodes.get(startx).get(starty).costFromStart = 0;
nodes.get(startx).get(starty).predictedTotalCost = nodes.get(startx)
.get(starty).costFromStart
+ manhattanDistance(startx, starty, endx, endy);
ope... |
416cd73c-67e1-47f4-83f5-ddd4c85d0cae | 5 | private void createWindow(){
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName() );
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} ... |
f99d05d9-ce46-4193-a35c-14f6ccb9c6dc | 7 | @Override
public int adjustedArmor(MOB mob)
{
int currDex=mob.charStats().getStat(CharStats.STAT_DEXTERITY);
final int maxDex = mob.charStats().getMaxStat(CharStats.STAT_DEXTERITY);
int dexBonus = 0;
if(currDex > maxDex)
{
dexBonus = currDex - maxDex;
currDex = maxDex;
}
double baseDex=mob.baseCha... |
861d2412-a838-49f1-9453-0023084e5160 | 6 | public void drawDice(Graphics2D g, int dice)
{
if(dice == 1)
{
g.setColor(Color.WHITE);
g.fillRect(550, 400, field_size, field_size);
g.setColor(Color.BLACK);
g.fillOval(567, 417, 6, 6);
}
else if(dice == 2)
{
g.setC... |
259c3fed-86fc-406a-95b9-b28322118c8c | 1 | public static AlgorithmTypeFactory getInstance() {
if (instance == null) {
instance = new AlgorithmTypeFactory();
}
return instance;
} |
a77d3581-be0e-47cc-b83d-9ec33076abbc | 8 | public static int getSideSnowGrassTexture(IBlockAccess blockAccess, int x, int y, int z, int side) {
if (!isBetterGrass()) {
return 68;
} else {
if (isBetterGrassFancy()) {
switch (side) {
case 2:
--z;
break;... |
a040fc3f-4d2a-4074-b6af-d5cf430255e1 | 2 | public static ArrayList<ItemSet> findRuleSubsets(ItemSet candidates, ArrayList<ItemSet> sets){
ArrayList<ItemSet> allRuleSets = sets;
if(!allRuleSets.contains(candidates)){
allRuleSets.add(candidates);
}
for(int i = 0; i < candidates.getItemSet().size();i++){
ArrayList<Item> subset = new ArrayLi... |
20bda932-aaa2-4bc0-976f-605596544471 | 7 | public boolean canMoveTo(int inLocX, int inLocY,Entity thnStore) {
Entity thnStore2;
DuskObject objStore = null;
Script scrStore;
boolean blnStore;
try {
objStore = objEntities[inLocX][inLocY];
} catch(Exception e) {}
if (SCR_IGNORE_COL != null) {
while (objStore != null) {
if (objStore.isLiving... |
a761877f-c1bb-4ef0-aee0-761c173a20bf | 1 | private void checkEnd() {
if (end) {
throw new IllegalStateException(
"Cannot call a visit method after visitEnd has been called");
}
} |
fadeb9eb-f77e-44a9-98d3-6192e8c0d07d | 6 | private void setUpLookAndFeel() {
//<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://download.oracle.com/javase/tutorial/uiswing/lookandfee... |
f70e68fe-0c9a-444f-a602-de7b2d4486d7 | 5 | private void createHtmlOutput ( Shell shell,
ICompilationUnit compUnit ) {
// TODO Auto-generated method stub
String directory;
IResource res = compUnit.getResource ();
boolean newDirectory = true;
directory = getPersistantProperty ( res, path );
if ( directory != null && directory.length() > 0 ) {
... |
675fd88a-7824-4824-bbff-7b471474f417 | 3 | public ComplexPoly nthDerivative(int n){
ComplexPoly dnydxn;
if(n>this.deg){
dnydxn = new ComplexPoly(0.0);
}
else{
dnydxn = new ComplexPoly(this.deg-n);
Complex[] nc = Complex.oneDar... |
449b4c6c-0151-40c8-a9fd-78c7651f048a | 7 | private void copyCheckboxAndSlidderValuesToTextfield(final Component comp){
//final Component comp = event.getComponent();
if( comp instanceof MyComponent ){
final MyComponent myComp = (MyComponent)comp;
final int actvY = myComp.getCompRelationY(); //First time use!! LOL! (... |
bfaac9ab-6ff1-4c25-93ac-95b4757cfd0f | 2 | public CountButton(int x, int y, int width, int min, int max, int step, int value) {
super(x, y, width, 32);
this.min = min;
this.max = max;
this.step = step;
this.value = value;
minus = new ArrowButton(x, y, 326, 16);
minus.addClickEvent(new ClickEvent() {
@Override
public void trigger() {
C... |
b6e4a10c-74d4-4d09-88ba-d9e327b65c12 | 6 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
KineticLaw other = (KineticLaw) obj;
if (math == null) {
if (other.math != null)
return false;
} else if (!math.equals(other.math))
r... |
ad17e8e4-b6cf-4aea-a84c-d3bc0dd8af46 | 3 | public void close() throws IOException {
if (inStream != null) {
inStream.close();
}
if (errStream != null) {
errStream.close();
}
if (conn != null) {
conn.disconnect();
}
} |
3f03f1ba-1df3-4596-b2b3-805f8f246b77 | 0 | public GUIManager getGUI() {
return this.gui;
} |
cff1e679-88f4-4de9-8b17-1a462fb9103f | 4 | public void updateFromScorecard(Scorecard scorecard) {
ArrayList<Integer> scores = scorecard.getScoresForHole(holeNumber);
for (int score : scores) {
addTimePlayed();
if (score == 1) { addHolesInOne(1); }
if (score < bestScore) { bestScore = score; }
averageScore = (averageScore + score) / timesPlayed;
... |
6122d719-189f-4616-ae0d-575ce169c4d5 | 4 | private void SelectJButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SelectJButtonMouseClicked
//if merchant was not selected then pop warning
int[] rowsSelected = loyaltyProgramJTable.getSelectedRows();
if(rowsSelected.length > 0 && rowsSelected.length < 2){
//st... |
cfc423ed-f1bf-44f1-aedc-014ca4165f6d | 1 | public synchronized boolean isFull() {
if (getMaxSize() > getSize()) {
return false;
} else {
return true;
}
} |
948f3f15-f89e-4103-ae71-fcb1a9ca3db4 | 8 | public void addBloodStain( int x , int y ) {
BufferedImage stain = resource.getImage( Trollface.IMG_BLOODSTAIN );
int stainWidth = stain.getWidth( );
int stainHeight = stain.getHeight( );
// Gives the stain a random angle
BufferedImage maniStain = new BufferedImage( stain.getWidth( ) , stain.getHeight( ) ,... |
3426ba2a-3b6f-4696-b45a-6e546841384a | 9 | private void gameLoop() {
World.setDefaultThread(Thread.currentThread());
buffer=new FrameBuffer(width, height, FrameBuffer.SAMPLINGMODE_NORMAL);
buffer.enableRenderer(IRenderer.RENDERER_SOFTWARE);
buffer.setBoundingBoxMode(FrameBuffer.BOUNDINGBOX_NOT_USED);
buffer.optimizeBufferAccess()... |
0b9ea82b-6d76-46cb-bf27-e879b03924ed | 1 | public void output() {
ListElement current = head;
while (current != tail.next()) {
System.out.print(current.getValue() + " ");
current = current.next();
}
System.out.println();
} |
0b7f7a01-e216-4061-a7dc-8336efab3a70 | 3 | @Override
public void paint(Graphics g) {
if (state == GameState.Running) {
g.drawImage(background, bg1.getBgX(), bg1.getBgY(), this);
g.drawImage(background, bg2.getBgX(), bg2.getBgY(), this);
paintTiles(g);
ArrayList<Projectile> projectiles = robot.getProjectiles();
for (int i = 0; i < projectiles.... |
2ad37b6c-9219-4f9a-99e6-8a9685196d2e | 0 | public void setImporte(float importe) {
this.importe = importe;
} |
1f92fa7d-a3ae-4084-abb7-d907f618dc3a | 7 | @Override
public void fill(Parameter parameter, Type type, Annotation[] annotations)
{
boolean isFlag = false;
boolean isNamed = false;
for (Annotation annotation : annotations)
{
if (annotation instanceof Flag)
{
if (isNamed)
... |
2ff49fd4-4b39-42ff-bc55-e004af790b7c | 4 | private String formatClass(String str)
{
String class_abbrv = "";
String class_num = "";
String class_section = "";
String formattedString = "";
int firstSub = 0;
int secondSub = 0;
int thirdSub = 0;
int fourthSub = 0;
int fifthSub = 0... |
5adff967-6f17-4653-a591-f320c10b920e | 5 | private void lineSelectHandler(Page currentPage, Point mouseLocation) {
if (currentPage != null &&
currentPage.isInitiated()) {
// get page text
PageText pageText = currentPage.getViewText();
if (pageText != null) {
// clear the currently sele... |
baa50fd7-5c7a-4b84-9185-22f14710895e | 6 | public void handleLeftClick(double x, double y, SUIComponent concerned){
if(host.equals(concerned))
frame.goTo(new HostPanel(frame));
else if(cancel.equals(concerned))
frame.goTo(new MainMenuPanel(frame));
else if(join.equals(concerned))
frame.goTo(new JoinPanel(frame));
else if(avatar_set.equals(conce... |
02a31b03-f593-49c2-8605-0918eee94325 | 8 | public void modify() throws IOException{ //Modify question - both prompt and answers
String s;
int val = 0;
Out.getDisp().renderLine("Would you like to change the prompt? (Y/N)");
s = Input.inputString();
if (s.equals("Y")||s.equals("y")){
Out.getDisp().renderLine(prompt);
Out.getDisp().renderLine("P... |
9226d344-fd27-41e7-8c5b-c7cec23c9494 | 7 | public static boolean isValidDate(String stringDate) {
if (stringDate.length() == 10) {
String stringDay = stringDate.substring(0, 2);
String separatorOne = stringDate.substring(2, 3);
String stringMonth = stringDate.substring(3, 5);
String separatorTwo = stringDa... |
c3bf2b67-51fc-4d38-9b25-dd8b4ae70aef | 5 | public static void main(String... args) {
ExecutorService executors = Executors.newCachedThreadPool();
Runnable task = new Runnable() {
@Override
public void run() {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
... |
243ea8e7-40bf-4aba-8c8c-636064b0864b | 1 | public long getElapsedTicks() {
long cur=System.currentTimeMillis();
long l=cur-ticks;
if (l>=granularity) {
ticks=cur-(l%granularity);
return l/granularity;
}
return 0;
} |
b9766e3f-09c7-4466-b09a-a5ccf847a4f6 | 8 | private void stop() throws IOException, InterruptedException {
if (responding && !action.isOther())
return;
GoogleResponse gr = null;
responding = true;
started = false;
if (!testMode) {
System.out.println("Stopped");
microphone.close();
microphone.open();
System.out.println("Process");
lcd.... |
11676ba2-ca11-432f-a3a9-f7615dad2339 | 8 | protected Instances determineOutputFormat(Instances inputFormat)
throws Exception {
FastVector atts;
FastVector values;
Instances result;
int i;
// attributes must be numeric
m_Attributes.setUpper(inputFormat.numAttributes() - 1);
m_AttributeIndices = m_Attributes.getSelecti... |
911396b7-e907-44e9-a20f-e2e9143b4923 | 1 | public boolean isGrey() {
if (myColor.equals(GREY))
return true;
return false;
} |
6ea92eea-bf09-4545-9507-90d4c8d1d884 | 7 | public static void makeCompactGrid(Container parent,
int rows, int cols,
int initialX, int initialY,
int xPad, int yPad) {
SpringLayout layout;
try {
layout = (SpringLayout) parent.getLayout();
} catch (... |
b9a32088-e671-4c39-b8f8-752314e218bd | 5 | public static String matchMovieFromRT(String jsonResponse, Movie movie)
throws JSONException
{
JSONObject jsonObject = new JSONObject(jsonResponse);
JSONArray jsonArray = jsonObject.getJSONArray("movies");
for (int i = 0; i < jsonArray.length(); i++)
{
JSONObj... |
c50e779b-9bfe-4c14-9b73-62e710b49685 | 6 | public void processKeyboard()
{
if(Keyboard.isKeyDown(Keyboard.KEY_F1))
{
state_mgr_.setActive("Elevation");
}
else if(Keyboard.isKeyDown(Keyboard.KEY_F2))
{
state_mgr_.setActive("Temperature");
}
else if(Keyboard.isKeyDown(Keyboard.KEY_F3))
{
state_mgr_.setActive("Rainfall");
}
else if(Ke... |
5a2172a3-7de8-40ae-a5b8-a624551c8f65 | 3 | public void visitingLocalitiesCheck()
{
// handles the home locality being 'North'
if (refereeClass.getHomeLocality().equals("North"))
{
// set the north check box to be selected,
// and un-select the other check boxes
northCheckBox.setSelected(true);
centralCheckBox.setSelected(false);
southCheck... |
3601987e-cef4-4ae3-b6fc-2a08ed256ba0 | 3 | @Override
public Operation create(Scanner scanner) throws FactoryException {
try {
String type = scanner.next();
if (type.equals("median"))
return new MedianOperation();
else if (type.equals("average"))
return new AverageOperation();
... |
706d2abc-ffe8-4384-8250-5418a73a6019 | 1 | public void updateQueue(Queue<core.GroupOfUnits> units)
{
int i = 0;
WidgetMap mapWidget = battle.getMapWidget();
queue.clearLevel(3);
queue.clearLevel(4);
p2u = new Position2Object<core.GroupOfUnits>();
for (core.GroupOfUnits u: units) {
queue.getImageStack(i/3, i%3).setLayer(3, new gui.WidgetImage(u.t... |
8d44797c-3411-48ad-b67c-8a3130e11b52 | 7 | @Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
final Player s = (Player)sender;
if (plugin.getLookup().isEnabled()) {
final Player[] onlineplayer = Bukkit.getOnlinePlayers();
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnabl... |
3e37afd7-4802-45bc-bd2e-cf725e5a0a47 | 7 | public static String convert(String s, int nRows) {
String[] rows = new String[nRows];
int rowIndex = 0;
int next;
if (nRows == 1)
next = 0;
else
next = -1;
for (int i = 0; i < s.length(); i++) {
if (rowIndex == 0 || rowIndex == nRows - 1)
next = -next;
if(rows[rowIndex] == null) rows[rowInd... |
6fcabe78-f460-4448-af91-c80dd0648fc0 | 7 | public void showValues() {
String attribute;
ArffSortedTableModel model;
ArffTable table;
HashSet values;
Vector items;
Iterator iter;
ListSelectorDialog dialog;
int i;
int ... |
7fbb1515-9f65-4e34-80fb-08bb155bb3ff | 6 | public int[] sampling(int k) throws OutOfRangeSampleSize{
int centroidIndexes[]=new int[k];
//choose k random different centroids in data.
Random rand=new Random();
rand.setSeed(System.currentTimeMillis());
if(k <= 0 || k > this.distinctTuples)
throw new OutOfRangeSampleSize("Errore! - Numero di iterate... |
f038fe24-c642-42e4-8f94-5aef22647921 | 7 | protected void act() {
if(state == -1) {
doBehavior(new DodgeBehavior());
}
else if(state == 0) {
float rotation = Robot.getInstance().getOdometryPoseProvider().getPose().relativeBearing(goal.getLocation())%360;
if(rotation > 180) {
rotation = -(360 - rotation);
}System.out.println(rotation);
A... |
02b72c3a-6c56-4b95-9f45-79f52d192d1e | 3 | public String toString()
{
String res = "";
for (int indiceParcoursLongueurMap=0; indiceParcoursLongueurMap<Plateau.LONGUEUR_DE_LA_MAP; indiceParcoursLongueurMap++)
{
for (int indiceParcoursLargeurMap=0; indiceParcoursLargeurMap<Plateau.LARGEUR_DE_LA_MAP; indiceParcoursLargeurMap++)
{
if (this.platea... |
b877c997-37f9-4731-b201-41550cc4cc23 | 5 | public void keyPressed(KeyEvent key){
//WASD moves
origX = x;
origY = y;
switch (key.getKeyChar()){
case 'w' : this.y = this.y - logicHandler.getPlayer().getSpeed(); break;
case 'a' : this.x = this.x - logicHandler.getPlayer().getSpeed(); break;
case 'd' : this.x = this.x + logicHandl... |
52b2722e-aa88-46fc-9aa9-65d70ab0f539 | 2 | protected void defineFeedTypeIfNecessary(String content) {
if (type == Type.Undefined) {
int maxSearchLen = Math.min(300, content.length() );
boolean isRSS = content.substring(0, maxSearchLen).indexOf("<rss") != NOT_FOUND;
type = isRSS ? Type.RSS : Type.Atom;
}
} |
c6c8a8db-11e0-4ea7-88f7-407d13d22ae3 | 8 | private Object createNewAppContext() {
// Add the current thread to our disposeAppContextThreadMap if it does not exit already
if (!disposeAppContextThreadMap.containsKey(Thread.currentThread())) {
disposeAppContextThreadMap.put(Thread.currentThread(), new Disposal());
}
// same as SunToolkit.createNewAppCo... |
e24d0043-09c0-4342-aa58-851619138983 | 9 | @Override
public List<String> getExpiredAcctOrCharsList()
{
final List<String> expired = new ArrayList<String>();
if(CMProps.getBoolVar(CMProps.Bool.ACCOUNTEXPIRATION))
{
final long now=System.currentTimeMillis();
if(CMProps.isUsingAccountSystem())
{
for(final Enumeration<PlayerAccount> e = CMLib.p... |
becb8733-67a6-475e-8272-5ff2605b216f | 5 | public static void main(String[] args) {
@SuppressWarnings("resource")
Scanner scan = new Scanner(System.in);
String userInput = scan.nextLine();
Pattern digitRegex = Pattern.compile("[\\d\\.]+");
Matcher digitMatch = digitRegex.matcher(userInput);
ArrayList<String> numbers = new ArrayList<>();
A... |
41aca17f-1aef-4d20-9925-715909cc0d04 | 2 | public static void main(String args[])
{
//total count is 41411,each time fetch 2000 records
int total=41411;
int limit=2000;
connection conn;
SQLconnection sqLconnection;
conn=new connection();
sqLconnection=conn.conn();
ExecutorService executorService = Executors.newFixedThreadPool(total/limit);
lo... |
98d64439-2781-4cf8-9891-b4a21a569813 | 0 | public String getCmd()
{
return name;
} |
d2d1fd6b-05b6-41d6-a746-206b42f5fa63 | 7 | private Tuple hashJoin() throws TransactionAbortedException, DbException {
Tuple t;
Field f;
if (iterFirst) {
// First run-through, Create Hash Relations
hashBlock = new HashMap<Field, ArrayList<Tuple>>();
while(children[0].hasNext()) {
blockBlock = new ArrayList<Tuple>();
t = children[0].next();
... |
0d03e6e3-edfa-4715-be71-ef484ce8a69f | 1 | public void SetSolenoidValue(int channel, boolean value){
solenoid[channel - 1] = (byte) (value ? 1:0);
} |
9d64cab6-8815-4212-baef-edc2770e5750 | 8 | @Override
public void caseADeclEnquantoDefinicaoComando(ADeclEnquantoDefinicaoComando node)
{
inADeclEnquantoDefinicaoComando(node);
if(node.getPontoVirgula() != null)
{
node.getPontoVirgula().apply(this);
}
if(node.getFimEnquanto() != null)
{
... |
07f3e615-19d7-4351-bc15-33ede30f0e27 | 9 | public void onSignal(final long time, String loc, String cell) throws IOException {
boolean isInside = KbUtils.getInstance().isInside(loc, cell);
AccountSnapshot accountSnapshot = new AccountSnapshot(start, imsi, time, isInside, true, lastStart, lastTime, lastInside, lastRecentDays, lastStatus);
... |
1111e741-68a8-41ed-81c4-28e47b496a3b | 3 | private void createWindow()
{
frame = new JFrame("Wumpus World");
frame.setSize(840, 640);
frame.getContentPane().setLayout(new FlowLayout());
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
gamepanel = new JPanel();
gamepanel.setPreferredSize(... |
15da037a-8695-4151-9191-b27c8b8ce80e | 0 | public int getId(){
return id;
} |
e4f06f4f-657d-4f4a-8303-5b0349a12c54 | 9 | private CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) {
char[] sa = src.array();
int sp = src.arrayOffset() + src.position();
int sl = src.arrayOffset() + src.limit();
sp = (sp <= sl ? sp : sl);
byte[] da = dst.array();
int dp = dst.arrayOffset() + dst.position();
int dl = dst.arrayOffset() + dst.l... |
805d83ca-35ad-4a74-bd7e-dcd173becaf5 | 0 | public static Labo selectOne(EntityManager em, String code_lab) throws PersistenceException {
Labo unLabo = null;
unLabo = em.find(Labo.class, code_lab);
return unLabo;
} |
d37ca3a8-41f4-49c1-bc6e-a0d7c227972c | 5 | public void tapCard(String ID, boolean tapped) {
for (Object e : table.getComponents()) {
if ((e.getClass().equals(TCard.class)
|| e.getClass().equals(Token.class))
&&((TCard) e).getID().equals(ID)) {
if (tapped) {
((TCard) ... |
c41afc3c-dd5f-4a5c-951b-0d1cb0059e3d | 3 | public User findUser(String userName) {
if (userList == null) {
loadUsers();
}
for (User u : userList) {
if (u.getUserData().getUserName().equals(userName)) {
return u;
}
}
return null;
} |
7334d7ed-cfc9-436b-8e9c-1501ba77273c | 3 | @Override
public void collisionCheck(ArrayList<BreakoutComponent> al) {
Rectangle cr = new Rectangle();
al.remove(super.r);
for (int i = 0; i < al.size(); i++) {
cr = al.get(i).r;
if (super.r.intersects(cr)) {
if (super.r.intersects(cr)){
verticalCollision();
System.out.println("r... |
0618d048-2de1-4ccb-8f73-d22a29c4ab22 | 4 | public static void printAsTree(List<Integer> array, int i){
/*Checks if the tree isnt empty*/
if(array.isEmpty() != true){
/*Checks if there is a right node*/
if(i*2+1 <= array.size()){
printAsTree(array, i*2+1);
}
int s = i;
int level = (int)Math.ceil(Math.log(s+1)/Math.log(2));
/*Pri... |
6e1f876b-ffbf-4077-b284-c765ac8d09db | 6 | public void process() {
for (int i = 0; i <= 5000; i++) {
if (globalItemID[i] != 0)
globalItemTicks[i]++;
if ((hideItemTimer+showItemTimer) == globalItemTicks[i]) {
// misc.println("Item Removed ["+i+"] id is ["+globalItemID[i]+"]");
if(!globalItemStatic[i]) {
removeItemAll(globalItemID[i], glo... |
1d4b739f-7591-4ae6-8ccf-4d1e05118dce | 2 | public List<Order> findOrder(String accountName, String clientId) throws XStoreException{
List<Order> orders = null;
logger.info("accountName - " + accountName);
logger.info("clientId - " + clientId);
try {
TypedQuery<Order> qry = em.createQuery("select O from Order O where O.account.client.clientName=:clien... |
09108e86-d7c6-4954-993f-2c9c1784795e | 3 | @After
public void after() throws Exception {
try {
proxy.exit();
} catch (Exception e) {
// This should not happen. In case it does, output the stack trace for easier trouble shooting.
e.printStackTrace();
}
try {
server.exit();
} catch (IOException e) {
// This should not happen. In case it ... |
5ba8231b-3662-4869-a552-3c5db0119657 | 8 | public static int search3(int[] A, int target) {
if (A.length == 0)
return -1;
int l = 0;
int r = A.length - 1;
int m;
while (l <= r) {
m = (l + r) / 2;
if (target == A[m]) {
return m;
} else if (A[l] <= A[m]) {
// left sorted
if (target < A[m] && target >= A[l]) {
r = m - 1;
... |
09faf3ee-ebb7-4a3d-9433-21dc69834829 | 9 | public static void main(String[] args) throws Throwable {
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
int N=10000;
ArrayList<int[]> lAdy[]=new ArrayList[N];
dijkstra=new int[10000];
visitados=new boolean[10000];
for(int i=0;i<N;i++)lAdy[i]=new ArrayList<int[]>();
for(int H,M;(N... |
41b5d5a0-54be-4cf6-8b7f-055dab9b6f3c | 4 | static BigInteger solve(int d, int l) {
if (l == n)
return BigInteger.ONE;
if (dp[d][l] != null)
return dp[d][l];
BigInteger cur = BigInteger.ZERO;
if (d - 1 >= 0)
cur = cur.add(solve(d - 1, l + 1));
cur = cur.add(solve(d, l + 1));
if (d + 1 <= k)
cur = cur.add(solve(d + 1, l + 1));
return dp[... |
05808555-841a-4dd3-aec4-e869260786b6 | 4 | public static String basename (String pathname) {
if (pathname == null || pathname.length () == 0) return ".";
String[] paths = pathname.split ("/");
for (int index = paths.length - 1; index >= 0; --index) {
if (paths[index].length () > 0) return paths[index];
}
return "/";
} |
2c3a5081-eb3b-4fc6-b242-8726b86e3269 | 4 | private Matrix getMelFilterBanks()
{
//get boundaries of the different filters
double[] boundaries = getMelFilterBankBoundaries(minFreq, maxFreq, numberFilters);
//ignore filters outside of spectrum
for(int i = 1; i < boundaries.length-1; i++)
{
if(boundaries[i] > sampleRate/2 )
{
... |
a1779f4a-d1e8-4445-a519-088c01a53d22 | 3 | public void startElement(String arg0, String arg1, String qname,
Attributes attrs) throws SAXException {
if(qname.equals("is:lineofsquares")){
this.environment = new Environment(Integer.parseInt(attrs.getValue("length")));
}
else if(qname.equals("is:white")){
((Environment)this.environment).addSquare(Squ... |
1148a659-8658-491b-a575-f9e268cb52d3 | 4 | private Statement cnx()
{
Statement st = null;
try
{
if(usr != null && pwd != null && url != null)
{
Connection cnx = (Connection) DriverManager.getConnection(url, usr, pwd);
st = (Statement) cnx.createStatement();
}
} catch (SQLException e) {
e.printStackTrace();
}
return st;
} |
ed0b992e-a48c-4c73-88b7-2cee63aab5b8 | 0 | @Override
protected void generateFrameData(ResizingByteBuffer bb)
throws FileNotFoundException, IOException {
// TODO: don't just reload frame, regenerate it
bb.put(this.reload());
} |
ca9b3dd5-342c-4b09-8b61-aa46d57a88a1 | 6 | public Spire makeSpire(int wall, int xR, int yR, int zR, int xsR, int ysR, int zsR, int dw) {
// When the wall was created, the variables were mapped as follows
// -Z wall: x = Wx y = Wy
// -X wall: x = Wy y = Wz
// -Y wall: x = Wx y = Wz
Spire temp;
switch (wall) {
... |
56e0a96a-b910-42ec-bd63-af40db564e80 | 7 | public synchronized boolean saveTemplates() {
if (templates==null)
return true;
if (directory==null || !directory.isDirectory())
return false;
// Blow away all old XML files to start anew, as some might be from
// templates we're removed from the template manager.
File[] oldXMLFiles = directory.listFi... |
ad7c7d46-3667-4822-bf10-b92475a04018 | 5 | public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String line = "";
StringBuilder out = new StringBuilder();
while ((line = in.readLine()) != null && line.length() != 0) {
int times = Integer.parseInt(line.trim());
for (in... |
d8ab3070-b410-4be1-861e-70ab6809df61 | 4 | public void enqueue (AbstractQueue<QueueElement> queue, QueueElement qe)
throws InterruptedException, TimeoutException {
Object[] params = new Object[2];
params[0] = queue;
params[1] = qe;
logger.entering(loggerName, "enqueue", params);
boolean bQStatus = fa... |
2f2a8738-b229-4704-a058-c809f7efbb38 | 3 | private static String listAllPrimeNumbersForGivenRange(int range) {
StringBuffer primeStr = new StringBuffer();
// set all values for the array to true
boolean[] primes = new boolean[range];
Arrays.fill(primes, true);
// prime number must be greater than 1, therefore int is as... |
9e325246-f8b1-4109-be81-14c28a08c30c | 0 | @Override
public void run() {
} |
cc78bec2-1a4a-4eb4-b921-a906b6e9f7bd | 5 | public void update(float dt) {
GameState g = gameStates.peekFirst();
boolean faded = game.getSpriteBatch().update(dt);
if(fading){
if(fadeType==1){
volume += dt * fadeType;
if (volume < 0)
volume = 0;
} else
volume = Game.musicVolume;
// g.getSong().setVolume(volume);
if(faded)
... |
593c1514-10aa-4361-99d2-b7944fdf12d5 | 7 | public void executePQ(GraphNode<T> currentNode) {
//BinaryHeap<GraphNode<T>> minHeap = new BinaryHeap<>(graph.getNumV(), BinaryHeap.HeapType.MIN_HEAP);
//minHeap.enqueue(currentNode);
//for (GraphNode<T> node:graph.getNodes()){
// node.distance = IntegerAlgs.MAX_VALUE;
//}
... |
72b52f95-a675-4a1a-9dcb-67c544bc2803 | 6 | public void removePlayersBuildingsUnits(Player player) {
for (Cell[] cell1 : cells) {
for (Cell cell : cell1) {
// remove buildings
if (cell.getBuilding() != null) {
if (Teams.comparePlayers(cell.getBuilding().getOwner(),
player)) {
cell.building = null;
}
}
// remove units
... |
989b2eb5-2ebc-4e41-97fa-c0590f5f8ab1 | 6 | public static boolean compareBare(String ion, int ii){
boolean test = false;
if(ion.equals(IonicRadii.ions1[ii])||ion.equals(IonicRadii.ions2[ii])||ion.equals(IonicRadii.ions3[ii])||ion.equals(IonicRadii.ions4[ii])||ion.equals(IonicRadii.ions5[ii])||ion.equals(IonicRadii.ions6[ii])){
test = ... |
3cdc9740-0b21-49a9-ad05-98d8380d28ed | 1 | public String toString()
{
if (nome != null)
return nome.toString();
return id + "";
} |
5ed2fe8e-afa1-4178-8605-b06534e6784e | 5 | public void setDays(int monthDays, int initWeek, int day) {
/**
* void setDays(int monthDays,int initWeek,int day)
*
* @para monthDays 本月天数
* @para initWeek 初始星期
* @para day 今天日 设置月历
*/
setDateNull();
for (int i = initWeek; i < initWeek + monthDays + 1; i++) {
if ((i - initWeek + 1) == day) ... |
c3e1d6e7-1fcb-4ae2-b355-314dfcc4b5db | 9 | @Override
public void and(Filter filter) {
if(filter == null
|| !(filter instanceof ThreadSafeCBloomFilter)
|| filter.vectorSize != this.vectorSize
|| filter.nbHash != this.nbHash) {
throw new IllegalArgumentException("filters cannot be and-ed");
}
ThreadSafeCBloomFil... |
6cfc2a9d-f4bb-42b3-8ab3-bfba1f9ca0be | 8 | public Route shortestPath(Node src)
{
PriorityQueue<Node> priorityQueue = new PriorityQueue<Node>();
Route r = new Route();
r.setDelayAtSrc(0);
r.getArrivalTime().add(0);
r.getRouteNodeList().add(src);
r.setRouteTravelTime(0);
src.setRouteUptoNode(r);
priorityQueue.add(src);
Node u = src;
while(u.g... |
aab34b48-254d-4359-9524-696203b44fff | 0 | public static int getIntegerValue(String attr) {
return Integer.parseInt(prop.getProperty(attr));
} |
f5ff2f96-9437-4678-a90a-91089969cd64 | 1 | public String getMethodName() {
return isSuper() ? "super" : "this";
} |
ce8da7d5-5222-4acd-a2dd-3eba07f03b03 | 8 | public void tick() {
super.tick();
// change in x and y
int dx = 0, dy = 0;
if (!this.getOuterBounds().intersects(player.getOuterBounds())) {
if (player.getX() > getX()) {
dx++;
} else if (player.getX() < getX()) {
dx--;
}
if (player.getY() > getY()) {
dy++;
} else if (player.getY(... |
4f4bb009-7f82-481b-8ce5-33a59d44c07f | 3 | public void addItemsToProductCombobox() {
productsComboboxItems.clear();
String item = "<html><font color='red'>Add New Product</font></html>";
productsComboboxItems.add(item);
if(driver.getPersonDB().getSupplierList().size()>0){
for (StockItem stockItem : driver.getStockDB().getStockList()) {
Product pr... |
a2afca07-854d-42eb-b3e7-6a1ec48f99e4 | 3 | public static int createAccount(String name, byte[] pass)
throws SQLException {
PreparedStatement checkStatement = DatabaseManager
.prepare("SELECT * FROM \"Users\" WHERE \"name\" = ?;");
checkStatement.setString(1, name);
ResultSet checkResult = checkStatement.executeQuery();
DatabaseManager.registerRes... |
b16f711e-b326-4e81-82f0-be8c430feb91 | 1 | public boolean safeTrigger(final EventEnum event, final C context) {
try {
return trigger(event, true, context);
} catch (LogicViolationError logicViolationError) {
return false;
}
} |
65ff6af3-df7b-478d-83bc-8089f6b415d4 | 0 | public OutOfBoardException(int x, int y) {
super("This square does not exist: "+x+","+y);
} |
d8e9c6e2-1858-4d0a-bdde-263bbb3ace33 | 7 | @Override
public void populate(World world, Random random, Chunk source)
{
if (!source.getBlock(7, 0, 7).getBiome().equals(Biome.MUSHROOM_ISLAND))
return;
int treeNum = random.nextInt(5);
int mooNum = random.nextInt(4)+1;
ArrayList<Location> locs = Helper.getBlockLocations(source, Material.MYCEL);
Array... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.