method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
e6bb4caf-a383-46b0-ad8d-961a492d9624 | 4 | public boolean dead()
{
if (P1character.equals("White"))
{
return whiteKnight.ifDead();
}
else if (P1character.equals("Bond"))
{
return jamesBond.ifDead();
}
else if (P1character.equals("Ninja"))
{
return redNinja.if... |
414493ad-f74d-411f-b667-44cf00a72f88 | 4 | @Override
public int compareTo(TimeStampedValue tsv) {
if(this.t > tsv.t ){
return 1;
}else if(this.t < tsv.t){
return -1;
}else if(this.t == tsv.t){
if(this.rk > tsv.rk){
return 1;
}else{
return -1;
... |
08ffa389-fcb0-4c21-b387-016d6bb27567 | 8 | public int getLevel(String str){
for (int i = 0; i < getLoreSize() ; i++) {
String line = getString(i);
if(line.contains(str)) {
if(line.contains(": ")) {
String strs[] = line.split(": ");
if(strs[0].contains(str)){
... |
019b3a19-02b2-4566-a3ee-3dd147d5ad1d | 8 | public static final void startChannel_Main() {
try {
initialProp = new Properties();
final FileReader channelConfig = new FileReader(System.getProperty("net.sf.odinms.channel.config"));
initialProp.load(channelConfig);
channelConfig.close();
final Regi... |
77094476-3c4e-4834-92f6-562b2443e14d | 1 | private void verifyAssignable(Type expected, Type type) throws BadBytecode {
if (! expected.isAssignableFrom(type))
throw new BadBytecode("Expected type: " + expected + " Got: " + type + " [pos = " + lastPos + "]");
} |
151904b6-5966-4232-bc92-24928455f307 | 5 | public static void main(String[] args) {
// TODO Auto-generated method stub
TravessiaDeserto tD = new TravessiaDeserto();
mapa = new Mapa();
caminhao = mapa.getCaminhao();
caminhao.carregar(5);
do{
Console.print(tD.imprimeStatus());
Console.print("\n");
String opcao = getOpcao();
switch (o... |
3d914a71-e6fe-439f-8272-d066a4363f41 | 3 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final TabelOutletClass other = (TabelOutletClass) obj;
if (!Objects.equals(this.classId, other.classId)) {
... |
dec7ca85-476a-45e3-9cdd-a6d2dcf6518c | 0 | public void increment() {
i++;
System.out.println(i);
} |
5c915e4b-bc92-488c-aa50-0badf91726f2 | 3 | private EntityType getType(String s, CommandSender sender) {
if (s.equalsIgnoreCase("enderdragon")) {
if (!plugin.hasPerm(sender, "spawnmob.enderdragon", false)) {
sender.sendMessage(ChatColor.YELLOW
+ "You do not have permission to spawn enderdragon.");
return null;
} else {
return EntityType... |
9eeb8934-bc88-484e-a3dc-5692794e656d | 3 | @Override
public List<Funcionario> ListByNome(String nome) {
Connection conn = null;
PreparedStatement pstm = null;
ResultSet rs = null;
List<Funcionario> funcionarios = new ArrayList<>();
try{
conn = ConnectionFactory.getConnection();
pstm = conn.prep... |
b05daa5c-a281-4b7b-a814-8e49c6537a1c | 6 | public void actionPerformed(ActionEvent e) {
if(e.getSource() == pause){
if(checkButtonClick == 1){
game.getWorld().pause();
checkButtonClick = 2;
pause.setText("Resume");
}
else if(checkButtonClick == 2){
checkButtonClick = 1;
gam... |
c256039c-f8d4-422b-b13d-0739fc8e99c8 | 2 | public GridLayout_Table(String[][] matrix) {
m_table.setLayout(new GridLayout(matrix[0].length, matrix.length));
m_table.setBackground(Color.white);
for (int i = 0; i < matrix[i].length; ++i) {
for (int j = 0; j < matrix.length; ++j) {
m_table.add(new Label(matrix[j][... |
0660a021-8358-40b8-be06-6b95aa03ebf9 | 6 | static public void updateNodePictureType(PropertyTree node) {
if(node==null) {
return;
}
if (!FileMetadata.class.isAssignableFrom(node.getNodeProperty().getDataType())) {
// not a file node?
return;
}
FileMetadata fm = (FileMetadata) node.getValue();
if(fm==null) {
// no metadata?
return;
}... |
a956a0c6-1357-4b62-91b0-c057e0a0f1b3 | 1 | public void setupOpenGL() {
try {
Display.setDisplayMode(new DisplayMode(600, 600));
Display.setVSyncEnabled(true);
Display.setTitle("Reverberations");
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
System.exit(-1);
}
} |
40b9861f-69fa-4144-8ac8-b24c418e9c7c | 8 | public static void main(String[] args) throws Exception {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ServerConsole window = new ServerConsole();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
EventQueue.invokeLater(new Ru... |
b7f2b371-82be-49f0-ad16-adcba4dfd098 | 0 | public void patternHtmlCode(){
this.htmlCode = CrawlResultFormat.webPageHead(this) + this.htmlCode;
this.htmlCode += CrawlResultFormat.webPageTail();
} |
308c2d0f-a752-4277-a44c-aaed8bdf7af9 | 7 | private boolean doKeyword(Segment line, int i, char c)
{
int i1 = i+1;
if(token == S_END)
{
addToken(i - lastOffset,Token.LITERAL2);
token = Token.NULL;
lastOffset = i;
lastKeyword = i1;
return false;
}
int len = i - lastKeyword;
byte id = keywords.lookup(line,lastKeyword,len);
if(id == ... |
16380409-8043-4322-b0a2-62c54108cff4 | 5 | public boolean matches(String word, Dictionary dic) {
if (p == null || !p.matches(word)) {
return false;
}
String adyWord = word.charAt(adyecentIndexes.get(i)) + adyecentRestrictions.get(i);
for (int i=0; i<adyecentRestrictions.size(); i++) {
if (!dic.contain(adyWord) &&
!dic.contain(new StringBuilde... |
6a0442f1-45a3-4ebc-9c63-1e7d961f1155 | 4 | public static void main(String[] args) throws IOException {
print("You're running a Dosim Online server :D");
server.start();
print("Enter your port, so I could set up a server: ");
int port = scanner.nextInt();
server.bind(port);
// Initialize
int[] numsOfFloors = new int[NUM_OF_BUILDINGS];
for (int ... |
52f57849-bec2-4c85-9f74-6c8ebe23ce01 | 2 | public String getUTF8(int i) throws ClassFormatException {
if (i == 0)
return null;
if (tags[i] != UTF8)
throw new ClassFormatException("Tag mismatch");
return (String) constants[i];
} |
22271749-c48b-4678-8623-7d3634577d38 | 7 | public static void main(String... args) throws IOException {
MyScanner sc = new MyScanner();
String txt = sc.next();
int lCount = 0;
int hCount = 0;
if (!lastPartIsCorrect(txt)) {
System.out.println("-1");
return;
}
for (int i = 0; i < txt.... |
79fb253c-77de-4b1a-bdf0-a36fc88149c4 | 3 | @Test
public void resolve() {
int sum = 0;
for (int a = 1; a <= 10000; a++) {
int b = d(a);
if (a != b && d(b) == a) {
sum += a;
}
}
print(sum);
} |
2e526599-b71e-4211-8283-73eb4d9acc8c | 1 | public void showCommands(){
int index = 1;
System.out.println("### showCommands ###");
for(Command c : _commands){
System.out.print(index++);
System.out.println(" "+c._name);
}
System.out.println("### ############ ###");
} |
09add70b-4a19-4d9c-bdbf-65fee532344f | 5 | public static int determinant(int[][] matrix){
//preconditions
if(matrix == null)throw new IllegalArgumentException("matrix must not be null");
for(int i = 0; i < matrix.length; i++){
if(matrix.length != matrix[i].length)throw new IllegalArgumentException("matrix must be square!");
}
if(matrix.length ==... |
f91d4ab1-2254-4571-8b63-20364597ef93 | 7 | public static byte[] getHash (File f) throws IOException {
if (!f.exists()) throw new FileNotFoundException(f.toString());
InputStream close_me = null;
try {
long buf_size = f.length();
if (buf_size < 512) buf_size = 512;
if (buf_size > 65536) buf_size = 65536... |
fb193b78-6686-44dc-97eb-faabdea0bf24 | 7 | public ArrayList<jade.tree.Tree> go(){
for(int i=0;i<intrees.size();i++){
for(int j=0;j<names.size();j++){
if(intrees.get(i).getExternalNode(names.get(j)) == null){
System.out.println("name: "+names.get(j)+" not in tree. exiting....");
System.exit(0);
}
/*
* added for nodes whose parents ... |
b9cd0f70-7603-4a03-8783-94a61ff16fb5 | 5 | public static void togglePlayersTownyChannel( String player, Boolean inTown, Boolean inNation ) throws SQLException {
BSPlayer p = PlayerManager.getPlayer( player );
String channel = p.getChannel();
String newchannel;
if ( !inTown ) {
p.sendMessage( Messages.TOWNY_NONE );
... |
320cd8e7-e88a-4cb2-aea8-b3090ba801b0 | 9 | public static void loadAnimations() {
resourceManager = new ResourceManager();
//load the animation for DirtTile
final int NUM_DIRTTILE_FRAMES = 1;
BufferedImage[] dirtTile = new BufferedImage[NUM_DIRTTILE_FRAMES];
long[] timesDirtTile = {2000};
resourceManager.loadImage("res/img/tiles/dirt1.png", "DirtT... |
4eb2554f-2cb6-4286-b398-7bf38d8aa75f | 4 | public void display() {
int iter = 0, seed = 0;
double tStart, t1, t2, paintTime = 0.;
tStart = getTime();
if (width != getWidth() || height != getHeight()) {
im.resize(getWidth(), getHeight());
width = getWidth(); height = getHeight();
}
System.out.format("Window si... |
92542655-ee7f-4084-8de6-e6954fef07da | 1 | private void deleteTouristList(Criteria criteria, AbstractDao dao) throws DaoException {
List<Tourist> list = (List<Tourist>) criteria.getParam(DAO_ORDER_TOURIST_LIST);
for (Tourist t : list) {
Criteria bean = new Criteria();
bean.addParam(DAO_ID_TOURIST, t.getIdTourist());
... |
6087f4e7-22db-472a-ad80-551b8a0b0ca8 | 0 | public ArrayList<Villager> getPopulation()
{
return population;
} |
093894a8-f247-46e4-9923-7f5519b2a705 | 3 | public static Field getField(Class<?> cl, String field) {
for (Field f : cl.getFields()) if (f.getName().equals(field)) return f;
return null;
} |
72e2d458-499a-4966-b88b-42b018b878a6 | 1 | public Object opt(String key) {
return key == null ? null : this.map.get(key);
} |
40e019b9-f1ac-48b2-b7ca-b4eac437944d | 9 | public static void main(String[] args) {
Film[] sammlung = {new Film("Batman Begins", 134, FSK.ab12),
new Film("Pulp Fiction", 148, FSK.ab16),
new Film("From Dusk till Dawn", 87, FSK.ab16),
new Film("Machete", 100, FSK.ab18)
};
Saal gelb ... |
1c560033-1b13-434b-8203-d27ff830d1f3 | 6 | @Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Session)) {
return false;
}
final Session session = (Session) o;
if (id != null ? !id.equals(session.id) : session.id != null) {
return false;
}
if (lapSet != null ? !lapSet.equals(session.la... |
8e5c7655-ff0f-4a3c-9836-5def4a6292d0 | 3 | public static String removeStart(String str, String remove) {
if (isEmpty(str) || isEmpty(remove)) {
return str;
}
if (str.startsWith(remove)) {
return str.substring(remove.length());
}
return str;
} |
3b504ee4-bebb-4eff-b367-55e87b44079b | 2 | @Override
public void Parse(Session Session, EventRequest Request)
{
Map<Integer, CatalogPage> Primary = Grizzly.GrabHabboHotel().GrabCatalogHandler().GrabPrimaryPages();
Session.GrabResponse().Initialize(ComposerLibrary.CataIndex);
Session.GrabResponse().AppendBoolean(true);
Session.GrabResponse().AppendI... |
99e9592d-b119-4626-8ce0-fa483794615a | 4 | @Override
protected boolean next() {
switch(state()) {
case one_byte_size_ready:
return one_byte_size_ready ();
case eight_byte_size_ready:
return eight_byte_size_ready ();
case flags_ready:
return flags_ready ();
case message_ready:
... |
48899b4a-e71a-4d57-9a31-0ee038e4ce01 | 5 | public void flatten(TreeNode root) {
// Start typing your Java solution below
// DO NOT write main() function
if (root == null)
return;
Stack<TreeNode> sta = new Stack<TreeNode>();
ArrayList<TreeNode> res = new ArrayList<TreeNode>();
while (root != null || sta.size() > 0) {
while (root != null) {
... |
774b2045-17ff-474a-ae8a-631e3bcd5abe | 5 | public static ArrayList<Channel> getDefaultChannels( String server ) {
ArrayList<Channel> chans = new ArrayList();
for ( Channel c : channels ) {
if ( c.getName().equals( "Global" ) || c.getName().equals( "Admin" ) || c.getName().equals( server ) || c.getName().equals( server + " Local" ) ) ... |
86c0afe3-9595-4258-a4d5-69cbe7f09de0 | 3 | public E argMax() {
double maxCount = Double.NEGATIVE_INFINITY;
E maxKey = null;
for (Map.Entry<E, Double> entry : entries.entrySet()) {
if (entry.getValue() > maxCount || maxKey == null) {
maxKey = entry.getKey();
maxCount = entry.getValue();
}
}
return maxKey;
} |
98b80093-830b-4904-8141-4ce7a0ee4515 | 4 | public void resetAllGameActions() {
for (int i=0; i<keyActions.length; i++) {
if (keyActions[i] != null) {
keyActions[i].reset();
}
}
for (int i=0; i<mouseActions.length; i++) {
if (mouseActions[i] != null) {
mouseActions[i].re... |
196fde47-c42a-4661-87bd-6e6fb5ad47b4 | 5 | @POST
@Path("/PlayerRequest/{facebookID}/{name}")
@Consumes("application/json")
public Player playerPOSTRequest(@PathParam("facebookID") long facebookID,
@PathParam("name") String name, ArrayList<String> JsonInput) {
// Set up the 3 arrays we need from the master JSONInput 2D array
ArrayList<Long> friendIDsL... |
d8cd32e2-41d6-4f5e-a356-3ab070ccf6ba | 9 | public String strStr(String hayStack, String needle) {
int hayStackLength = hayStack.length();
int needleLength = needle.length();
if(hayStackLength == 0 && needleLength == 0)
return "";
if(needleLength == 0)
return hayStack;
for(int i = 0; i < hayStackLength; ++i){
if(hayStackLength - i + 1 < ... |
c9eea79a-3419-4757-93ca-a032bd780576 | 2 | public void draw()
{
//DEsenhando tudo:
for (int y = 0; y < MAP_SIZE_H; y++) {
for (int x = 0; x < MAP_SIZE_W; x++) {
tileset.startUse();
tileset.renderInUse((int)tileMaps[y][x].getColisionRect().getX(), (int)tileMaps[y][x].getColisionRect... |
cfe26109-e45f-4af1-a5b7-875680baf07b | 1 | public static void call(final String mapping, final String data) throws Exception {
// wll provide a clean format for printing the date to the screen
final SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
// delimited by a comma
// text qualified by double quotes
// ig... |
936d7b6f-8deb-482f-ad74-5d1f88a154d8 | 4 | public JSONWriter key(String string) throws JSONException {
if (string == null) {
throw new JSONException("Null key.");
}
if (this.mode == 'k') {
try {
this.stack[this.top - 1].putOnce(string, Boolean.TRUE);
if (this.comma) {
... |
85ddef91-1d6e-4264-a1e5-73a188d5aa94 | 2 | public void generateForceField() {
final Position position = getGrid().getElementPosition(this);
if (position != null) {
Map<ForceFieldGenerator, Direction> neighbours = getNearbyForceFieldgenerators(position);
for (Entry<ForceFieldGenerator, Direction> neighbour : neighbours.entrySet())
createForceFiel... |
03eec258-4427-4458-b1f9-25b10182964b | 7 | private void find(int r, String[] rowStrings, String[] columnStrings){
int n = rowStrings[r].length();
String[] gen = new String[3];
for(int i=0; i<=n; i++){
for(int j=i; j<=n; j++){
gen[0] = rowStrings[r].substring(0,i);
gen[1] = rowStrings[r].substri... |
de064184-ed78-4f14-b9c5-ddb4a3f297dc | 1 | private CycList<Object> queryVariablesLow(final CycList<CycVariable> queryVariables,
final CycObject query,
final CycObject mt,
final InferenceParameters queryProperties,
final long timeoutMsecs)
throws UnknownHostException, IOException, CycApiException {
final Stri... |
14dcad90-4892-4683-a783-c178c2e7618c | 5 | public synchronized boolean removePlayer(int slotID) {
if (!_isOpen) {
return false;
}
if ((slotID < 0) || (slotID >= _slots.size())) {
return false;
}
if (!_slots.get(slotID).isOccupied()) {
return false;
}
_slots.get(... |
5854ca36-77b1-4374-aefa-3ad3865dd175 | 9 | @Override
public double getClippedValue(double input, double clip) {
double result = 0;
double flag = 0;
if (input >= a && input <= b) {
flag = (input - a) / (b - a);
if (result < clip) {
result = flag;
} else {
result = cli... |
d59a1f8d-4974-44b2-a7cc-563bd36bbd1b | 1 | private static void writeFiles() throws IOException {
int i = 0;
for (StringBuilder sb : outStrings) {
FileWriter fw = new FileWriter(new File("uliss18_" + i++));
fw.write(sb.toString());
fw.flush();
fw.close();
}
} |
d69735aa-4eb0-4716-82de-6f14c154e426 | 6 | public void makeDeclaration(Set done) {
if (constrAna != null)
constrAna.transform();
if (staticConstructor != null) {
new TransformConstructors(this, true,
new MethodAnalyzer[] { staticConstructor }).transform();
}
// If output should be immediate, we delay analyzation to output.
// Note that thi... |
259d1a7f-039a-4ab2-873b-0b42083726fa | 9 | @Override
public void itemStateChanged(ItemEvent e) {
if(comboBox.getName().equals("flightnr")){ //Do something to flight panel
if (e.getStateChange() == ItemEvent.SELECTED) {
int flightNr = Integer.parseInt(e.getItem().toString());
registertrolley.flightroute.setFlightNr(... |
251cec88-767e-4f60-aa6b-e3006c67a026 | 3 | public String toString() {
if(ranges.size() == 0) {
return "{[]}";
}
sortRanges();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("{");
int index = -1;
int last = ranges.size() - 1;
for(PERange range : ranges) {
index++;
stringBui... |
b8c1e424-4e86-489f-9564-857f9b9df8a4 | 2 | private void init(int total, int pageNumber, int limit){
//设置基本参数
this.total=total;
this.limit=limit;
this.pages=(this.total-1)/this.limit+1;
//根据输入可能错误的当前号码进行自动纠正
if(pageNumber<1){
this.pageNumber=1;
}else if(pageNumber>this.pages){
this.... |
11564282-30f7-4eb3-8b7f-e4e106337a02 | 8 | public static ModPack loadObject(File saveFile) {
if(!saveFile.exists()) return null;
if(!FileUtils.getFileExtension(saveFile).equals("json")) return null;
ModPack temp;
try {
temp = (ModPack) FileUtils.readObject(saveFile, new ModPack());
} catch (Exception e) {
... |
405cc18d-8856-4599-b91d-3b97814d5f87 | 4 | private boolean valid(int[] delta) {
int newX = gapX + delta[0];
int newY = gapY + delta[1];
if(newX < 0 || board[0].length <= newX) { return false; }
if(newY < 0 || board.length <= newY) { return false; }
return true;
} |
3cf16ce2-fb47-4275-bd30-c6766e67157c | 8 | public void execute() {
SimpleDateFormat sdf = new SimpleDateFormat("EEEE d MMMM yyyy 'at' h:mm a z");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
logger.info(Messages.STARTING.value());
// logger.info(Messages.STARTING_PARAM_PROJECT.value(this.mavenProject));
logger.info(Messages.STARTING_PARAM_REPO.value... |
e936b894-f4bc-48d9-ad72-2cf135914199 | 6 | public static boolean isPalindrome(int x) {
if(x == 0) {
return true;
}
if(x < 0) {
return false;
}
int len = 1;
int tmp = x;
while((tmp/10) >= 1) {
len++;
tmp = tmp/10;
}
int[] position = new int[len];
for(int i=len;i>0;i... |
69938d1c-742c-4686-8d6a-bf335bb14596 | 9 | @Override
public void updateLong() {
boolean nearArea;
Point placeablePoint, areaPoint;
Placeable placeable = null;
int[] powerValues = this.getPower();
//loop through the placeable to figure out power for each one
try {
for (String key : placeables.keySe... |
08eae2c8-1684-4bbf-b964-67365dc27853 | 0 | public int getId() {
return id;
} |
87e1a1a1-a68c-42dc-85fb-f7059d97c1ce | 3 | public String retrieve_associated_ip(int port)
{
if (this.ip_port.containsValue(port))
{
Iterator<String> itr = this.ip_port.keySet().iterator();
while (itr.hasNext())
{
String current_ip = itr.next();
if (this.ip_port.get(current_ip) == port)
return current_ip;
}
}
return null;
} |
bdfe2af6-fd3f-4d75-b087-d5f64ab09fc5 | 7 | @Override
public void mouseClicked(MouseEvent e) {
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setJobName("Utskrift av tralleseddel");
printJob.setPrintable(new Printable() {
@Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterExcepti... |
b0c2c936-3149-44c3-a7cd-f64320dc6864 | 2 | public void series() {
System.out.println("Enter the no till which the series is required");
int num = in.nextInt();
if (num <= 0) {
System.out.println("Please enter a valid number");
}
else {
for (int f3 = 0; f3 < num; f3++) {
output = f1 + f2;
f1 = f2;
f2 = output;
System.out.print("... |
579e3496-d417-43cd-9245-df433f343ac5 | 5 | public void testGoalWithModulePrefix6() {
String goal = "no_such_module:no_such_predicate(0)";
try {
Query.hasSolution(goal); // should throw exception
fail(goal + " (nonexistent module prefix) wrongly succeeded"); // shouldn't get to here
} catch (org.jpl7.PrologException e) { // expected exception class
... |
11a45c0a-b30a-45a4-a493-816a78b9cb0c | 2 | private void removeAllComponentsInContainer(Container container){
for (Component component : container.getComponents()) {
if(component instanceof Container){
Container childContainer = (Container) component;
removeAllComponents(childContainer);
//System.out.println("removed all components on:" + childContai... |
f8bd4c33-0164-47c0-9679-a1d50b830809 | 3 | public int checkMoleculeID(int IDCheck){
int index=-1;
for(int i=0; i<graphNodes.size(); i++){
if( (graphNodes.get(i).getID()==IDCheck) && (graphNodes.get(i).getType() == _MOLECULE_) ){
index=i;
}
}
return index;
} |
51c1bb20-9108-49fc-89c0-05a5542d2335 | 4 | private static Node parseLeft(ParserContext ctx) {
Token left = ctx.currentToken;
if (left instanceof Identifier) {
return new VariableNode(((Identifier) left).getName());
} else if (left instanceof Value) {
return new ConstNode((Integer) ((Value) left).getValue());
... |
27e86e6f-3e69-4939-8c06-cc47df2a9047 | 8 | protected int countNeighbours(int col, int row) {
int total = 0;
total = getCell(col-1, row-1) ? total + 1 : total;
total = getCell( col , row-1) ? total + 1 : total;
total = getCell(col+1, row-1) ? total + 1 : total;
total = getCell(col-1, row ) ? total + 1 : total;
total = getCell(col+1, row ) ? total +... |
580bd5e1-71a8-458f-93fa-9355e3a9144d | 0 | public int getCourse(int course) {
return course;
} |
2f251e4f-4903-4208-8ef4-cc4c4d8a6909 | 5 | public IntersectionResult intersect(final Ray ray) {
final Vector v = center.minus(ray.origin);
if (material.isOpaque() && v.squaredLength() < radius * radius) {
return IntersectionResult.MISS;
}
final double b = v.dot(ray.direction);
final double discriminant = b * b - v.dot(v) + radius * radius;
if (di... |
c5a856ec-c5a0-4a8f-89bd-ece24e44c57f | 6 | public Whitelist parser(WhitelistRule whitelistRule) {
List<AttributeGroup> list = whitelistRule.getAttributeGroups();
Map<String, List<String>> attributeGroupMap = new HashMap<String, List<String>>(list.size());
for (AttributeGroup group : list) {
attributeGroupMap.put(group.getName(), group.getAttributes())... |
ea660340-e59d-45ee-970a-1ae9f07a9c54 | 4 | public void tick() {
time++;
if (time >= lifeTime) {
remove();
return;
}
xx += xa;
yy += ya;
x = (int) xx;
y = (int) yy;
List<Entity> toHit = level.getEntities(x, y, x, y);
for (int i = 0; i < toHit.size(); i++) {
Entity e = toHit.get(i);
if (e instanceof Mob && !(e instanceof AirWizard)) ... |
7d4aefb3-c7d2-49c0-922e-3d2784a488e2 | 6 | public static void turno(Cancha prueba1, Pelota pelota)
{
//defino que equipo ataca y cual defiende
int atacante, defensor;
if(prueba1.getEquipoX(0).isAtacante())
{
atacante=0; defensor=1;
}
else
{
atacante=1; defensor=0;
}
... |
0d8e1580-6ba8-4dd9-8671-3da02bf9a8e6 | 1 | @Test
public void testTimeStep_ANNUAL_MEAN_YAMPA_OCT() throws Exception {
printDebug("----------------------------");
printDebug("Annual Mean with Period Yampa starting in Oct: " + this.toString());
printDebug("----------------------------");
CSTable t = DataIO.table(r2, "obs");
... |
5cd522dc-fe70-4ce6-a076-249c4b9fde0e | 8 | @Override
public int encode(byte[] array, int blkptr, int len)
{
if ((array == null) || (blkptr + len > array.length) || (blkptr < 0) || (len < 0))
return -1;
final int len8 = len & -8;
final int end8 = blkptr + len8;
int i = blkptr;
try
{
... |
42c82e37-97b1-43e4-8065-598cd451819e | 4 | public void tick()
{
// if(frame.getWidth() != realSize.width || frame.getHeight() != realSize.height)
// frame.pack();
if(!gameOver)
{
if(readyToSwap)
{
endTurn();
}
if(swappingNow)
{
readyToSwap = false;
timerPos--;
if(timerPos == 0)
{
swappingNow = false;
t... |
3bb5c2d4-46dc-4a82-91d8-68818f034ba0 | 8 | private static int bfs(int start, double mat[][], int cc, int girth) {
int baba[] = new int[cc];
int dist[] = new int[cc];
for (int i = 0; i < cc; i++) {
baba[i] = AlgorithmUtils.Max_Int;
dist[i] = AlgorithmUtils.Max_Int;
}
dist[start] = 0;
baba[s... |
9c1bd6ea-7c0f-4c28-b019-e5650634453f | 8 | private boolean copy_slot( NonBlockingHashMap topmap, int idx, Object[] oldkvs, Object[] newkvs ) {
// Blindly set the key slot from null to TOMBSTONE, to eagerly stop
// fresh put's from inserting new values in the old table when the old
// table is mid-resize. We don't need to act on the results he... |
f9142ed1-75db-49fc-827a-5196cde95441 | 7 | public static void main(String[] args) throws Throwable {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder( );
for (String ln ; (ln = in.readLine())!= null; ) {
int n = Integer.parseInt(ln.trim());
if(n==0)break;
lines = new String[n];
int ... |
9ad13da1-3ae9-4d59-a5bf-36b57f3bf83b | 8 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
Type other = (Type) obj;
if (arraySize != other.arraySize)
return false;
if (isArray != other.isArray)
return false;
if (isClass != other.isClass)
return false;
if (name == null) {
... |
94ece3ff-70c5-406b-92a7-dbb6613b3a22 | 3 | public void insert(int i, Key key) {
if (i < 0 || i >= NMAX) throw new IndexOutOfBoundsException();
if (contains(i)) throw new IllegalArgumentException("index is already in the priority queue");
N++;
qp[i] = N;
pq[N] = i;
keys[i] = key;
swim(N);
} |
e5064ce4-072f-4be0-aeeb-ca8d91f0850f | 0 | private AIPaddle getAiPaddle() {
return new AIPaddle(width-(int)(HORIZONTAL_SCALE * width), 0, SPEED_AI, width, height, (int)(HORIZONTAL_SCALE * width), (int)(VERTICAL_SCALE * height));
} |
0e6482ea-88cf-459c-a970-215bb6d6b07c | 4 | public int getLevel(int skill) {
int[] skills = ctx.getClient().getSkillLevels();
if (skills == null || skills.length == 0 || skill < 0
|| skill >= skills.length) {
return -1;
}
return skills[skill];
} |
71d18a24-9ede-47ed-9c7f-9b55bf7b69a8 | 0 | public double getCantidad() {
return cantidad;
} |
f3bbd442-b230-42de-aadc-7c70979f4435 | 3 | public WeakReference<Object> get(Object obj)
{
WeakReference<Object> res = null;
Long id = (long) System.identityHashCode(obj);
List<WeakReference<Object>> bucket = buckets.get(id);
if (bucket != null)
{
synchronized (bucket)
{
// iterate over the references in the bucket until we find
... |
6646194c-ccc9-4a7f-8b0f-0260e4e7f86f | 9 | public void paint(java.awt.Graphics g_) {
Graphics2D g = (Graphics2D) g_;
g.setColor(Color.LIGHT_GRAY);
g.fillRect(0, 0, getWidth(), getHeight());
Utilities.drawCheckerPattern(g.create(0, 0, getViewWidth(), getViewHeight()),checkerSize);
g.drawImage(image,0,0, image.getWidth()*zoom, image.getHeight()*zoom,0,0... |
ebe082f1-1120-4217-b712-1ac76ed68b1d | 1 | protected void setColoredExes() {
ArrayList<Excel> temp = CubeGenerator.generateCube(side, base, center);
coloredEx.clear();
for(Excel ex: temp)
{
ex.setX(ex.getX() + Dx);
ex.setY(ex.getY() + Dy);
coloredEx.add(ex);
}
} |
5b713577-52f5-40a9-bd4e-9835027570fa | 2 | public void setLoadingStatusFont(String font) {
if ((font == null) || font.equals("")) {
this.loadingFont = UIFontInits.LOADINGSTATUS.getFont();
} else {
this.loadingFont = font;
}
somethingChanged();
} |
73f826e1-1ad0-4439-a806-2533df83a319 | 7 | public static String doubleToString(double d) {
if (Double.isInfinite(d) || Double.isNaN(d)) {
return "null";
}
// Shave off trailing zeros and decimal point, if possible.
String string = Double.toString(d);
if (string.indexOf('.') > 0 && string.indexOf('e') < 0 &&
... |
ab08caab-97b1-4090-8be0-2cf1d16f5d11 | 8 | public void run() {
// start the drones
for (Drone drone : drones.values()) {
System.out.println(String.format("Sending initial destinations to drone %d", drone.getDroneId()));
while (drone.addDestination(_droneLocations.get(drone.getDroneId()).get(0))) {
_dron... |
e1faeb16-11fb-41b2-be6a-09f2622af8c8 | 1 | private boolean jj_2_56(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_56(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(55, xla); }
} |
dbc2d39b-937f-4c3a-a72d-a1b87f6139bf | 3 | @Test
public void test_solvable_matrix_size_2_solve() throws
ImpossibleSolutionException,UnsquaredMatrixException,
ElementOutOfRangeException{
int height=2;
int width=2;
float[][] matrix;
float[] resultVector;
float[][] knownMatrix = new f... |
97ab0006-6945-4cdf-b8ee-2173548279bc | 0 | @Test
public void canNotGetWord_whenWordDoesNotExist() {
trie.add("abc");
assertFalse(trie.contains("abcd"));
} |
c88e9f49-8509-40e2-84c7-ec031439378a | 4 | public double jumpTime(double timeStep) {
double loopTime = 0;
Position calculatedPosition = this.getPosition();
while(this.getWorld().liesWithinBoundaries(calculatedPosition, this.getRadius()) && (!this.getWorld().isAdjacent(calculatedPosition, this.getRadius()) || this.getPosition().distance(calculatedPositi... |
3e24e7e8-cff7-43b1-b9a6-83aa99a7de10 | 0 | public List<Integer> getShortestHistory() {
return shortestHistory;
} |
f049465f-dc25-44c8-9a5d-91760bed2ced | 2 | public void setUnits(List<GroupOfUnits> u)
{
if (u == null) {
units = new ArrayList<GroupOfUnits>();
} else {
units = u;
}
for (GroupOfUnits unit: units) {
unit.setOwner(this);
}
} |
c2f375f4-0f72-4a69-bacd-d15a01587bcf | 2 | public void setPhone(String phone) {
if(phone == null || phone.isEmpty()){
throw new IllegalArgumentException();
}
this.phone = phone;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.