method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
eee689e7-e686-4fe3-9426-70cf53da835c | 9 | @Override
public void tick(LinkedList<GameObject> lstObj) {
super.tick();
if (this.isAlive()) {
velX = Math.signum(velX) * 3;
walkLeft.runAnimation();
walkRight.runAnimation();
for (GameObject tmpObj : lstObj) {
if (this != tmpObj) {
... |
86b06d8a-8866-4b61-836b-f5cfb283cd50 | 1 | public boolean method284(int arg0, byte arg1, int arg2, int arg3, Entity entity, int arg5, int arg6, int arg7, int arg8, int arg9) {
if (entity == null) {
return true;
} else {
int i2 = arg9 * 128 + 64 * arg5;
int j2 = arg8 * 128 + 64 * arg3;
return method287(arg6, arg9, arg8, arg5, arg3, i2, j2, arg2, ... |
24c8e9fa-834d-4d47-9341-d6e1ee291888 | 8 | public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s;
while ((s = br.readLine()) != null) {
StringTokenizer st = new StringTokenizer(s);
int n = Integer.parseInt(st.nextToken());
... |
d721691c-867f-4f52-bc49-72765dbde4ec | 9 | public List<Interval> insert(List<Interval> intervals, Interval newInterval) {
if (intervals.isEmpty()) {
intervals.add(newInterval);
return intervals;
}
List<Interval> result = new ArrayList<>(intervals.size());
Iterator<Interval> iter = interva... |
610c85bd-d8b0-4cd6-ad2a-a9d94fcf6817 | 4 | public void update(GameContainer container, StateBasedGame game, int delta,
int mouseX, int mouseY) {
if (contains(mouseX, mouseY) && !current.equals(mouseOver)) {
current = mouseOver;
currentColor = mouseOverTxtColor;
mouseEnter.play(1, RLGame.SOUND_VOLUME);
} else if (!contains(mouseX, mouseY) && !cur... |
d3d1f17d-580e-41e0-b3dc-51d344ef1d6e | 0 | public byte[] getPgenCounter() {
return pgenCounter;
} |
772e583e-c7af-4eb8-82e8-8a0a9a49dd40 | 9 | @Override
public void keyPressed(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_UP:
System.out.println("Move up");
break;
case KeyEvent.VK_DOWN:
currentSprite = characterDown;
if (robot.isJumped() == false) {
robot.setDucked(true);
robot.setSpeedX(0);
}
break;
case KeyEve... |
c37b2a90-ceb0-4808-a5d3-e54abed97309 | 7 | public static void main(String[] args) throws Exception
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int a = Integer.parseInt(reader.readLine());
int b = Integer.parseInt(reader.readLine());
int c = Integer.parseInt(reader.readLine());
int d... |
dfe22e5b-4273-49b6-9fbf-d08e89bcee9b | 3 | static public boolean deleteDirectory(File path) {
if (path.exists()) {
File[] files = path.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
deleteDirectory(files[i]);
} else {
file... |
7d394c42-dbc6-4632-a752-a3b7f20fd6d6 | 1 | private TrainNumber CreateG101() {
TrainNumber rs = new TrainNumber();
rs.setId(UUID.randomUUID());
rs.setName("G101");
Route route = new Route();
route.setId(UUID.randomUUID());
route.setStartDate(new LocalDate(0L));
route.setEndDate(LocalDate.now().plusYears(10));
rs.getRoutes().add(route);
for... |
253ff9ac-bed5-4724-9978-c5cf92b81815 | 7 | @EventHandler(priority = EventPriority.MONITOR)
public void bucketEmpty(PlayerBucketEmptyEvent event){
if(plugin.getArena(event.getPlayer())!= null){
int a = plugin.getArena(event.getPlayer());
if(!event.isCancelled()){
if(plugin.canjoin.get(a)){
if(plugin.Playing.get(a).contains(event.getPlayer().get... |
a2e94da0-2722-47af-844c-d10ea68fe1ac | 1 | public String toString(){
String str = identifier.getNewName(false) + "(";
if(argumentListOpt!=null)
str += argumentListOpt.toString();
str += ")";
return str;
} |
7ec3579c-de8a-4fb2-a6f5-8f9f27b4b7ad | 0 | @Id
@Column(name = "POP_PROVEEDOR_ID")
public Integer getPopProveedorId() {
return popProveedorId;
} |
f4a804e6-425b-4ad6-b805-519040e6429e | 4 | public PlayerShip getNewShip() {
switch(shipPreference) {
case BOMBER:
return new actor.ship.types.Bomber();
case FIGHTER:
return new actor.ship.types.Fighter();
case SCOUT:
return new actor.ship.types.Scout();
case ... |
4629f685-bbf8-4147-922a-974550204859 | 6 | public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringBuilder out = new StringBuilder();
String line = "";
while ((line = in.readLine()) != null && line.length() != 0) {
int n = Integer.parseInt(line.trim());
if (n == 0)... |
01ed9363-88b1-4bb2-9eb8-e03f9b6c3277 | 1 | public String getInput() {
String str = "";
try {
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(System.in));
str = bufferedReader.readLine();
} catch (IOException ex) {
ex.printStackTrace();
}
String returnStr = str.toLowerCase();
return returnStr;
} |
32241fe8-900c-4be9-8f6f-45de12699685 | 3 | public void setProductType(ProductType productType) {
if (this.productType == productType) return;
if (this.productType != null) {
this.productType.removeTray(this);
}
this.productType = productType;
if (productType != null) {
this.productType.addTray(this);
}
} |
d52ed276-b642-4ea5-b533-300f5df68b11 | 9 | public static void evaluateTwoParsers(File parserDataA, File parserDataB) {
BufferedReader brA = getReader(parserDataA);
BufferedReader brB = getReader(parserDataB);
String strLineA;
String strLineB;
int sentencesCounter = 1;
int partialMatches = 0;
int completeMatches = 0;
int word... |
e8220a75-279a-453f-8e13-479d63e26929 | 7 | public Triple getTriple(String identifier) throws InvalidRecordException{
Predicate pred = null;
Node sub = null;
Node obj = null;
//Check for the Triple, if not add it to the KnowledgeGraph
if (!(tripleMap.containsKey(identifier))){
StringTokenizer st = new StringTokenizer(identifier," "); ... |
6f7d9f89-c8a4-4187-9cf3-a686c897bd2e | 5 | @Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
//刷新选中状态
selectNone();
for(int i = 0; i < model.size(); i++) {
CheckStore<E> store = model.get(i);
if(store.isSelected()) {
uiCheckBoxList.addCheckBoxListSelectedIndex(i);
}
}
//大小
if(popSize != null && popSize.height != 0 &&... |
c4530ec1-5be8-4e4b-8e21-dd6f547130b3 | 6 | @EventHandler
public void CreeperRegeneration(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.getCreeperConfig().getDouble("Creeper... |
64dd1fed-3f89-4416-a133-a35e3e73cb7c | 3 | private static Map<String, String> parse(String fileName)
{
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = null;
Map<String, String> map = new HashMap<String, String>();
try
{
builder = builderFactory.newDocumentBuilder();
}
catch(ParserConfigu... |
ac690f63-c362-45fa-b435-75ef54a3a90c | 4 | public short getMinimumDifference_as_short(){
short diff = (short)0;
if(this.type==8 || this.type==9){
ArrayMaths am = this.sort();
short[] sorted = am.getArray_as_short();
diff = (short)(sorted[1] - sorted[0]);
short minDiff = diff;
for(int i=... |
2ba4f4cd-4dd0-434d-8de6-2cd27770bc35 | 1 | @Override
public void windowClosed(WindowEvent e) {
if (e.getID() == WindowEvent.WINDOW_CLOSED) {
this.setVisible(false);
this.dispose();
}
//To change body of implemented methods use File | Settings | File Templates.
} |
e40e7e9d-52c8-4f1c-aceb-a5f9adb3ef06 | 1 | @Override
public boolean interpret(String context) {
if (context.contains(data)) {
return true;
}
return false;
} |
db36c6fd-9c7c-4065-b295-30c84f95589a | 6 | private void jTextField1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField1FocusLost
// TODO add your handling code here:
try{
if(esCarga){
if((jTextField1==null)||(jTextField1.getText().equals("")))
jTextField1.requestFocus();
... |
627e0bd6-c18a-4734-b00f-15e2f095d426 | 5 | public String parse(String input){
String output = input.replace("(SERVERNAME)", pl.getServer().getName())
.replace("(BUKKITVERSIONLONG)", pl.getServer().getVersion())
.replace("(BUKKITVERSION)", pl.getServer().getBukkitVersion())
.replace("(MAXPLAYERS)", "" + pl.getServer().getMaxPlayers())
.replace(... |
34a3e6d5-cb53-467a-ad50-ff85a0d6cbfd | 3 | @Override
public void setType(BlocType b) {
BlocType t = super.getType();
checkInvariants();
super.setType(b);
checkInvariants();
if(t==BlocType.MURMETAL){
if(!(super.getType() == BlocType.MURMETAL)){
throw new PostConditionError(
"getType(B) == BlocType::MURMETAL et "+
"getType(setType(... |
c786f126-efc4-41c0-a252-0bc23d34e6c1 | 7 | @Override
public boolean okMessage(final Environmental myHost, final CMMsg msg)
{
if(!super.okMessage(myHost, msg))
return false;
if((affected instanceof MOB)
&&(msg.target()==affected)
&&(msg.sourceMinor()==CMMsg.TYP_ADVANCE))
{
final MOB mob=(MOB)affected;
if((mob.getVictim()==msg.source())
&&... |
be3d66a4-e51b-4c21-92a3-afa0bd34181b | 1 | public void fillInGenSet(Set in, Set gen) {
if (instr != null)
instr.fillInGenSet(in, gen);
} |
349eb276-7a3b-401a-831b-56deef3f0b10 | 6 | @Override
public void draw(Graphics g) {
int x = this.column * Board.CELL_SIZE;
int y = this.row * Board.CELL_SIZE;
g.setColor(Color.GRAY);
g.fillRect(x, y, Board.CELL_SIZE, Board.CELL_SIZE);
if (roomInitial == 'X'){
g.setColor(Color.RED.darker().darker());
... |
538a2a84-c18b-46b9-8de5-c9f51a036ddf | 0 | public static void main(String[] args) {
RecursionSteps r = new RecursionSteps();
System.out.println(r.Steps(4));
} |
38c51428-db0b-4c24-8be3-c620a2ba067b | 9 | protected synchronized void initializeJar() {
//Check to see if we are already initialized
if(isInitialized()) return;
//we can't initialize non-jar non-zip resources
if(!isJar() && !isZip()) {
initialized_flag = true;
return;
}
try {
File f = null;
... |
fde083cc-4b0f-4df5-9caa-b7c0f5a8e12a | 1 | public void setStatus(boolean status){
currentImage = status ? greenLamp : redLamp;
repaint();
} |
fecfc2a2-e746-435b-8b48-31ed42fc174e | 9 | public Object getValueAt(int rowIndex, int columnIndex) {
assert((columnIndex >= 0) && (columnIndex <= 2));
Iterator i = scoreSet.iterator();
int j = 0;
while(i.hasNext()) {
if(j == rowIndex) {
Object... |
424098f7-709e-45ff-9091-05747010a68c | 9 | protected void _socketReceivingMessage(ByteBuffer _buf)
{
//将数据放入缓冲中
try
{
_m_bByteBuffer.put(_buf);
}
catch (BufferOverflowException e)
{
//长度不足,此时提示
ALServerLog.Error("_socketReceivingMessage length is too long, Socket Buffer need... |
b452ef2d-b254-4843-aaa5-04e1fe1ba31e | 2 | public void update() {
Window window = vc.getFullScreenWindow();
if (window != null) {
BufferStrategy s = window.getBufferStrategy();
if (!s.contentsLost()) s.show();
}
} |
9088d995-d7d2-4d1c-8df0-c73069a4d3bb | 6 | @Override
public void keyPressed(KeyEvent e) {
if (isAlive) {
if (e.getKeyChar() == 'w') {
player.setDy(-4);
keyDown[2] = true;
} else if (e.getKeyChar() == 's') {
player.setDy(4);
keyDown[3] = true;
} else i... |
3f7a4193-0059-4cab-ab66-d768b49734e1 | 5 | public static void disposeImages() {
// dispose loaded images
{
for (Image image : m_imageMap.values()) {
image.dispose();
}
m_imageMap.clear();
}
// dispose decorated images
for (int i = 0; i < m_decoratedImageMap.length; i++) {
Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decora... |
6fbcf28b-6837-4438-b85f-b6109fef15bb | 4 | public int get(ParameterName variableName, int defaultValue){
if(map.containsKey(variableName)){
if(map.get(variableName) instanceof Integer || map.get(variableName) instanceof Float || map.get(variableName) instanceof Double){
return Math.round(((Number)map.get(variableName)).floatValue());
}
throw new ... |
303951f4-4118-4d54-bc0b-b552325bbfe9 | 6 | private static MiniScriptValue readValue(CompileInfo ci, String p){
p = p.trim();
if(p.isEmpty()){
makeDiagnostic(ci, Kind.ERROR, "no.value.empty");//$NON-NLS-1$
return null;
}else{
if(p.charAt(0)=='['){
return readPtr(ci, p);
}else if(p.charAt(0)=='r' || p.charAt(0)=='R'){
if(p.length()>1 && ... |
13d0d975-223b-47b6-bfff-4390e6c382da | 0 | public static void main(String[] args)
{
String[] words = { "Mary", "had", "a", "little", "lamb" };
Pair<String> mm = ArrayAlg.minmax(words);
System.out.println("min = " + mm.getFirst());
System.out.println("max = " + mm.getSecond());
} |
a20094af-a8eb-4653-b109-9bc783a4c927 | 1 | public void addLiens(List<ZLien> liens)
{
Iterator<ZLien> e = liens.iterator();
while (e.hasNext())
addLien((ZLien) e.next());
} |
ccc4385f-0834-4932-ad77-2731faa869f8 | 6 | private boolean validMove(int x, int y, ArrayDeque<Point> path){
if(avatar.getAvilableMoves() == 0)
return false;
//Return false if it out of bounds of the map array.
if(!inBounds(x,y))
return false;
//Returns false if the tile does not correspond to a accessible square
if(!worldMap[x][y].isIsTile())
... |
463a6f1d-5e4e-46b8-9869-b37cd6e554cb | 6 | public synchronized void serviceChanged(ServiceEvent event) {
String[] objectClass = (String[]) event.getServiceReference().getProperty("objectClass");
// If a dictionary service was registered, see if we
// need one. If so, get a reference to it.
if (event.getType() == ServiceEvent.REGISTERED) {
if (m_ref ... |
1f30bb69-dbd7-4fa6-9c51-cebff3a369be | 7 | public LoreBookPanel() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException exception) {
exception.printStackTrace();
} catch (InstantiationException exception) {
exception.printStackTrace();
} catch (IllegalAccessException exception) {
excepti... |
770ae682-329a-4b9d-a9ed-dc0c91b0f449 | 3 | public void init(){
//setup root
Root = new Node(null,new Point(0,0,TreeSize),new Point(TreeSize,0,TreeSize),new Point(0,0,0), new Point(TreeSize,0,0));
Root.Parent = null;
//not doing this recursively, because it's not jumping out at me, I think I'm seeing problems with initialization t... |
799079db-b685-4b68-85f7-a26ee0a68174 | 5 | @Override
public boolean onPointerMove(int mX, int mY, int mDX, int mDY) {
if(mX > x && mX < x + width && mY > y && mY < y + height) {
pointerOver = true;
if(tooltip != null) {
tooltip.setLocation(mX+20, mY+20);
}
}
else {
point... |
dbb7393c-ea16-4daf-aaf9-b4129c434169 | 6 | public static void getModsFrom(File dir, File parentFile) throws Exception
{
if (dir.isDirectory())
{
for (int i = 0; i < dir.listFiles().length; i++)
{
if (dir.listFiles()[i].isDirectory())
{
getModsFrom(dir.listFiles()[i], parentFile);
}
else if (dir.listFiles()[i].toString().endsWith(... |
c5e9cdb8-4a79-4fc8-8d8f-10a4eb5cfc10 | 0 | @Override
public void execute(VirtualMachine vm) {
System.out.println(vm.peekRunTimeStack());
} |
18f60d95-7164-4dd0-ba94-95235939d110 | 3 | public void render(Graphics g)
{
g.setColor(buttonColor);
g.fillRect(x, y, w, h);
if(disabled) {
g.setColor(disabledColor);
g.fillRect(x, y, w, h);
}
else if(shade) {
g.setColor(pressed ? shadeColor : hoverColor);
g.fillRect(x, ... |
dbf95147-76de-492a-b60e-6a2a22edb335 | 1 | public static ArrayList<Score> get() {
try {
String data = "action=" + URLEncoder.encode("get", "UTF-8");
String result = connect(data);
return createScores(result);
} catch(Exception e) {
e.printStackTrace();
}
return null;
} |
bc9bd850-fdda-4537-9f52-ec5695ce47da | 4 | @Override
public void renameDirectory(String directory, String newname)
{
if (!dirEntries.containsKey(directory.toLowerCase())) return;
DirEntry de = dirEntries.get(directory.toLowerCase());
DirEntry parent = de.parentDir;
String parentpath = "";
if (parent != nu... |
e1bfdae1-1118-43d5-a680-9e26db23f8d6 | 3 | private static void checkForRuntimeRetention( Class<? extends Annotation> annotationType )
{
Retention retention = annotationType.getAnnotation( Retention.class );
if ( retention == null || RetentionPolicy.RUNTIME != retention.value() )
{
throw new IllegalArgumentException( "Anno... |
b98b16bc-6f3b-4e3f-9084-cebffce0b1d3 | 5 | public static WordSet generateSet(int tipo){
//Selección de la implementación a utilizar
switch (tipo){
case 1: return new SimpleSet();
case 2: return new RedBlackTree();
case 3: return new SplayTree();
case 4: r... |
df54fb62-60c2-4828-9af2-ddaa03066630 | 8 | public void fixSequence(SAMSequenceRecord sequenceRecord) throws MD5MismatchError {
String found_md5 = sequenceRecord.getAttribute(SAMSequenceRecord.MD5_TAG);
if (confirmMD5) {
if (found_md5 != null) {
byte[] bytes = referenceSource.getReferenceBases(sequenceRecord, true);
if (bytes == null) {
Strin... |
bc2e2ca6-7853-43f9-b60b-e1505add7454 | 3 | int syncHeader(byte syncmode) throws BitstreamException
{
boolean sync;
int headerstring;
// read additional 2 bytes
int bytesRead = readBytes(syncbuf, 0, 3);
if (bytesRead!=3) throw newBitstreamException(STREAM_EOF, null);
headerstring = ((syncbuf[0] << 16) & 0x00FF0000) | ((syncbuf[1] << 8) & 0x0000FF0... |
80fe3158-05cc-496c-b80a-103098bde53a | 0 | String getMessage() {
return this.message;
} |
8f5d9532-aa86-48fa-94f5-0ee1b95ea2db | 2 | public static void inversion(Deck in){
int pos1 = (int) (Math.random() * (1+in.cards.size()));
int pos2 = (int) (Math.random() * (1+in.cards.size()));
if(pos1>pos2){
int temp = pos1;
pos1 = pos2;
pos2 = temp;
}
String temp;
int j = pos2;
for(int i=pos1; i<(j-1); i++){
j--;
temp = in.... |
cc444f7b-0064-4139-b3fc-61f157f439c8 | 0 | public String getManufacturerId() {
return manufacturerId;
} |
3ede1ebb-9dbb-499e-9f6b-bc1f6cec8d5c | 0 | public Logger() {
log = this;
} |
3cca2156-c601-4d34-98f4-1a041ffd505f | 0 | public String getDescription() {
return "JFLAP 3 File";
} |
3288d435-7125-442d-a820-d583a5bf2f99 | 2 | public String getNanopostsDir(boolean outbox) {
String nanopostsDir;
if (!outbox) {
nanopostsDir = MainClass.NANOPOSTS_DIR + System.getProperty("file.separator");
} else {
nanopostsDir = MainClass.OUTBOX_DIR + System.getProperty("file.separator");
}
... |
9fda9a2b-2ff7-4342-9f61-999fdd527dde | 3 | @Override
public void show() {
System.out.println(name + ", type in the required information for a new auction item." + "\n");
System.out.println("Name of product:");
try {
productName = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("Description of product:")... |
a579b0a4-6ac1-4d93-864f-64775261dedd | 9 | public Position findFirstEmptyCell(Direction direction) {
if (direction == Direction.DOWN) {
for (int x = 0; x < getWidth(); ++x) {
for (int y = 0; y < getHeight(); ++y) {
Cell cell = getCell(x, y);
if (cell.isAccessible() && cell.getContent().equals(Cell.EMPTY_CHARACTER)) {
return new Position... |
bf8b29c8-a799-4ea9-ade4-9dea9d2c54a9 | 3 | public FeatureNode [] parseRow(String [] row) {
FeatureNode [] example = new FeatureNode[row.length-1];
int maxindex = 0;
for (int i=1; i<row.length; i++) {
String [] iv = row[i].split(":");
int index = Integer.parseInt(iv[0... |
385b0ead-7464-44ad-88ab-ba04a94ab1f2 | 8 | public Exam(int examMark) {
if (examMark > 100 || examMark < -1) {
invalidCount++;
} else if (70 <= examMark && examMark <= 100) {
studentCount++;
distinctionCount++;
} else if (50 <= examMark && examMark <= 69) {
studentCount++;
passCount++;
} else if (0 <= examMark && examMark <= 49) {
stude... |
5529bc64-634f-41df-ac38-22f0916f6234 | 2 | public void test_02() {
readFile("tests/indexer_test_01.fastq");
// Sort all references
String latest = "";
Collections.sort(references, seqIndex);
// Check that is was sorted correctly
for( Long ref : references ) {
DnaAndQualitySequence seq = seqIndex.get(SequenceReference.getSeqIdx(ref));
int sta... |
c55cd34f-7ee9-4009-bf21-307b6ebe2b76 | 2 | @Override
public void run() {
/*if (HyperPVP.games == 19) {
this.restart(30, 15);
this.restart(15, 5);
this.restart(10, 5);
this.restart(5, 1);
this.restart(4, 1);
this.restart(3, 1);
this.restart(2, 1);
this.restart(1, 1);
HyperPVP.needsRestart = true;
return;
} else {
HyperPVP.g... |
acbe6345-20bf-45e5-8f1d-92ef26ffd7dc | 0 | public void setX(int newX)
{
this.x = newX;
} |
a47543af-648e-440e-9f26-b79a24536824 | 9 | public boolean hasBooleanValue() {
switch (constType.type) {
case CodeConstants.TYPE_BOOLEAN:
case CodeConstants.TYPE_CHAR:
case CodeConstants.TYPE_BYTE:
case CodeConstants.TYPE_BYTECHAR:
case CodeConstants.TYPE_SHORT:
case CodeConstants.TYPE_SHORTCHAR:
case CodeConstants.T... |
70eef941-6346-40a5-8160-22e383ffb576 | 8 | @SuppressWarnings("unchecked")
private void loadFile() {
if (fc.showOpenDialog(panel) != JFileChooser.APPROVE_OPTION) {
return;
}
File loadFile = fc.getSelectedFile();
try {
BufferedReader reader = new BufferedReader(new FileReader(loadFile));
List<String[]> dataGrid = new ArrayList<String[]>();
St... |
eb139564-c85c-450f-aeda-5b796b96614d | 5 | public static int searchHelper(int[] arr, int tgt, int p, int r) {
if ( p > r) {
return -1;
}
int m = (p + r) / 2;
int valMid = arr[m];
// trivial case
if ( valMid == tgt ) {
return m;
}
// non trivial cases
if ( valMid < tgt ) {
if ( arr[r] >= tgt ) {
return searchHelpe... |
922bdef3-48d0-40a6-9c04-95a2e018beeb | 2 | @Override
public void act() {
if (!checkLife()) {
removeSelfFromGrid();
}
while (this.exp > this.nextExp) {
this.exp -= this.nextExp;
levelUp();
}
} |
2bc3b60d-7070-453f-8200-475c644e758c | 5 | @Test(timeout = 500)
public void testParesAntesImpares() {
int par = 0;
int impar = 0;
int random = 0;
int tam = 0;
int ndx = 0;
int obtido = 0;
int esperado = 0;
List<Integer> lista = null;
String tmpl = null;
String msg = null;
random = getRandom();
if (random % 2 == 0) {
par = rando... |
62a03bbb-8311-4993-9406-ee1bb913b93f | 4 | public static void refreshMessages() {
String lastMsg = Session.current().get("lastMsg");
ChatRoom chatRoom = getCurrentChatRoom();
if ( chatRoom == null )
return; //do something here ...
Date lastDate = new Date();
DateFormat formatter = new SimpleDateFormat(DATE_FORMAT);
Session.c... |
65e21979-77c3-4fdf-9817-991e91ed0cb8 | 8 | public void drawLevel(Graphics g){
for(int y = (int) ((Game.cameraLocation.y*scale)/tileHeight), yLoc = (int) -((Game.cameraLocation.y*scale)%tileHeight); y < height && yLoc < game.window.getHeight(); y++, yLoc += tileHeight){
for(int x = (int) ((Game.cameraLocation.x*scale)/tileWidth), xLoc = (int) -((Game.camera... |
b87b93e6-e8d2-4e9f-95dc-1f07be941bd7 | 4 | public void loadWave(String name, String location, int concurrent) {
SoundWave wave = null;
URL waveLocation = Thread.currentThread().getContextClassLoader().getResource(location);
if (waveLocation != null) {
try {
wave = new SoundWave(waveLocation, concurrent);
} c... |
6c84ef2f-66ab-41a2-a6a7-82a39d1e30a2 | 9 | private BeanKey findParameterKey(final Object parameterOwner, final Class<?> parameterClass,
final Type parameterType, final Annotation[] annotations) {
final String qualifier = qualifierHandler.getQualifier(parameterOwner, annotations);
if (isProvider(parameterClas... |
4da80a7c-4c56-4e14-9511-3408deb09ce2 | 7 | private void doDistrDEEMaster(int numMutable, int strandMut[][],
ParamSet sParams, String strandDefault[][],
String minPEM, String maxPEM, double initEw, PrunedRotamers<Boolean> prunedRotAtRes,
boolean doMinimize, RotamerSearch rs, String sfFile, String rotFile, boolean useSF,
int numSpPos, int typeDEE, bo... |
bab7ddd6-5e32-4c5c-8e78-b813b9e7d5de | 6 | @Override
protected boolean handleInternal(AbstractAction action, Agent agent) {
if (messageToSend == null) {
AbstractAction interestingPart = getInterestingPart(action);
if (interestingPart == null) {
// not interested in this action
return true;
}
values = new HashMap<String, String>();
if (... |
2a6c7412-ded1-459d-a951-f54e8018f1f4 | 1 | public void setConditionalSentence(boolean b) {
final CycSymbol value = b ? CycObjectFactory.t : CycObjectFactory.nil;
put(CONDITIONAL_SENTENCE, value);
} |
b5eed19e-ccbe-45d8-84be-5c04afff5274 | 3 | public SingleTreeNode uct(StateObservation state) {
SingleTreeNode selected = null;
double bestValue = -Double.MAX_VALUE;
for (SingleTreeNode child : this.children)
{
double hvVal = child.totValue;
double childValue = hvVal / (child.nVisits + this.epsilon);
... |
ab2e3b71-50a7-4e33-a708-59ba8613d0ca | 7 | public static TransactionExecutor newLockingExecutor() {
TransactionExecutor.Validator validator = new TransactionExecutor.Validator() {
@Override
public boolean validate() {
if (!WriteSet.getLocal().tryLock()) {
return false;
}
... |
2b5e8935-ade4-4b21-9ed8-955b879018fb | 9 | public void load() {
config = new YamlConfiguration();
worldEntries = new HashSet<WorldEntry>();
worldProperties = new HashSet<WorldProperties>();
try {
config.load(new File(plugin.getDataFolder(), "config.yml"));
ConfigurationSection worldLinks = config.getConf... |
97689d5d-2d65-48d7-9269-9caa23be8041 | 3 | public Node nodeAt(int x, int y) {
String s = coordString(x, y);
if (node_map.containsKey(s)) {
Node n = node_map.get(s);
if (n.x == x && n.y == y)
return n;
}
return null;
} |
0a70f9aa-565c-411e-a2a2-ee4f350d4466 | 0 | public Liste getListe() {
return liste;
} |
0232f657-6fcf-49c4-9cc1-f9b3decba967 | 2 | @SuppressWarnings("unchecked")
public void loadDb() {
try {
this.setMusicBuffer((HashMap<String, MusicPersisted>)
this.getMusicDbIn().readObject());
this.setUserBuffer((HashMap<Email, UserPersisted>)
this.getUserDbIn().readObject());
} catch (IOException e) {
this.setMusicBuffer(new HashM... |
b4f4c0ca-3188-4c34-b998-4a04b273a2df | 8 | static public void compareStrings() {
String one = "one";
String two = "two";
String var1 = "one";
String var2 = "Two";
String pieceOne = "o";
String pieceTwo = "ne";
// Comparison is equal
if (one.equals(var1))
System.out.println("String o... |
0c0eb558-cfb0-467d-bec1-78a1e953f3f0 | 0 | public void setSolFechaHora(Date solFechaHora) {
this.solFechaHora = solFechaHora;
} |
c166e2ab-3454-4634-87e2-ff03fba45608 | 0 | public ThreadingIT() throws FileNotFoundException {
out = new PrintStream(new OutputStream() {
@Override
public void write(int b) throws IOException {
// just do nothing
}
});
xmlRunListener = new TestLinkXmlRunListener(out, "donald");
... |
c466a20f-f6aa-45bb-8122-88f89465b0bc | 4 | private int digitalSum(int x) {
int[] number = new int[1000];
number[0] = 2;
int len = 1;
int high = 0;
for (int i = 2; i <= x; i++) {
for (int j = 0; j < len; j++) {
number[j] = number[j] * 2 + high;
high = number[j] / 10;
number[j] = number[j] % 10;
}
if (high > 0) {
number[len] = h... |
08db0af0-5bdc-4845-afe6-5aa9c8b082c8 | 8 | public int [][] multiResultsetWins(int comparisonColumn, int [][] nonSigWin)
throws Exception {
int numResultsets = getNumResultsets();
int [][] win = new int [numResultsets][numResultsets];
// int [][] nonSigWin = new int [numResultsets][numResultsets];
for (int i = 0; i < numResultsets; i++) {... |
08486295-e3f0-4ebf-b42a-3375adcfd42b | 5 | @Override
public void update()
{
for (Input i : pressedKeys)
{
switch (i)
{
case PLR1RIGHT:
rp.playerGo(1, Const.right);
break;
case PLR1LEFT:
rp.playerGo(1, Const.left);
... |
509a99a9-26f9-4925-8528-f1d7f9f1ce4d | 9 | @SuppressWarnings("unchecked")
public static LinkedHashMap<String,Object> objectToArray(Object object) {
LinkedHashMap<String,Object> data= new LinkedHashMap<String,Object>();
if (object == null) return data;
if (Functions.method_exists(object,"toArray")) {
Object retObj = Functions.call_method(object,"toArr... |
6ac15225-db34-4a66-b5d9-bb2930b505ac | 3 | public static List<Node> bfs(double graph[][],int s)
{
int length=graph.length;
List<Node> nodeList=NodeUtil.generateNodeList(graph);
nodeList.get(s).distance=0;
nodeList.get(s).state=1;
Queue<Node> queue=new LinkedList<Node>();
queue.add(nodeList.get(s));
while(!queue.isEmpty())
{
Node u=queu... |
fc632135-c324-4fd5-9a7d-91e8daa737b9 | 7 | public void InitView() {
pane = new VBox();
//Stworzenie wykresu
lineChart = LinearChartManager.linear();
lineChart.setTitle("");
//Poczatkowo zakres dat to 3M
selectedRange = DataRange.THREEMONTH;
selectedChart = "line";
//Stworzenie tabelki
ta... |
4d4af2b7-5d91-4409-881f-ebb442c7d65c | 9 | public void openWindow() throws IOException {
openedWindows++;
if (frame != null)
return;
frame = new JFrame(EditorPanel.WINDOW_NAME);
frame.setIconImage(U.getAppIcon());
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
Point p = U.Config.readFrameSize();
U.setFrameSize(frame, p.x, p.y... |
0da7ee8f-f2cb-41da-9258-39dcc021bc02 | 5 | public void HandleKeyboardEvent()
{
int key = Keyboard.getEventKey();
if (IsInKeyRange(key))
{
if (Keyboard.getEventKeyState())
{
if (mRecordingKeys)
{
if (key == 14)
{
if (inputString.length() > 0)
{
inputString = inputString.substring(0, inputString.length() - 1);
... |
0288e640-c672-454c-8da5-5dd11f189cc1 | 9 | public boolean variable_declaration() {
// check format: type identifier ["[" "]"] ["=" assignment_expression ] ";"
boolean variableHasBeenAdded = false;
Variable_SAR variableSar = null;
typePush(new Type_SAR(lexicalAnalyzer.getToken(), scope));
if (!typeExists()) {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.