method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
935cfd93-b307-4052-8999-cb65d664e0b5 | 3 | private void exit() {
anInt4 = -2;
cleanUpForQuit();
if (frame != null) {
try {
Thread.sleep(1000L);
} catch (Exception exception) {
}
try {
System.exit(0);
} catch (Throwable exception) {
}
}
} |
d77490bb-670d-43b2-8a94-f79990b16ed9 | 6 | public static final int getTaxAmount(final int meso) {
if (meso >= 100000000) {
return (int) Math.round(0.06 * meso);
} else if (meso >= 25000000) {
return (int) Math.round(0.05 * meso);
} else if (meso >= 10000000) {
return (int) Math.round(0.04 * meso);
... |
bd79581b-2e87-4f29-be6d-30eed7435d10 | 1 | @Override
public byte getMistakePercent() {
int questions = getFinishedQuestions();
return questions > 0 ? (byte) (100 - getRightPercent()) : 0;
} |
96192419-eb7a-4196-afb1-23e486d37b54 | 4 | public CostList(final CostPair... pairs) {
TreeMap<Resource, Integer> resources = new TreeMap<>();
for (CostPair pair : pairs) {
if (pair.getCost() == 0) {
continue;
}
if (resources.containsKey(pair.getResource())) {
// increment by cost if it already exists
resources.put(pair.getResource(),
... |
cf4a5c6c-a75c-46c8-949d-a66a60bfe563 | 2 | static void drawBoard()
{
//song.stopPlayFile();
//song.startPlayFile();
for(int i=0;i<pad.length;i++)
{
for(int l=0;l<pad[i].length;l++)
{
pad[i][l]=new Rectangle(j,startxpos,startypos,40,40,defColor);
startxpos+=55;
}
startypos+=55;
startxpos=10;
}
red=new Text(j,10,175,"Red:"+redw... |
5f2ea362-656f-4d2a-ba1d-0149aaca3504 | 9 | public Updater(Plugin plugin, int id, File file, UpdateType type, boolean announce) {
this.plugin = plugin;
this.type = type;
this.announce = announce;
this.file = file;
this.id = id;
this.updateFolder = plugin.getServer().getUpdateFolder();
final File pluginFile... |
dbdcf1ea-7816-4e99-8b3d-dfe8e1257e99 | 9 | @Override
public void actionPerformed(ActionEvent ae){
int accion = Integer.parseInt(ae.getActionCommand());
switch(accion){
case 1:
System.out.println("Simple");
this.seleccionarEquipo();
break;
case 2:
Sys... |
f1790c15-30cc-4ba7-adef-1e4307fb81e9 | 5 | public void solveDFSMaze(){ //Use DFS algorithm to try and find the exit now!
Scanner input = new Scanner(System.in);
MazeCell current = getStartCell(),neighbor;
int number;
ResetVisits();
current.visit();
if(theStack.isEmpty() == false){
System.out.println("Stack must be emptied before runni... |
6d61cf5c-4404-44ae-bded-7ba8a19e7497 | 7 | private void SicherungButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SicherungButtonActionPerformed
// TODO add your handling code here:
if (neueSicherungQuellen.getQuellpfade().size() > 0 && !"".equals(neueSicherungQuellen.getZielpfad().trim()))
{
// Sicher... |
38b5fc43-ad20-45b5-8848-b410cec8e671 | 6 | public boolean intersects(Spatial s){
if(!(s == null || s.width <= 0 || s.height <= 0)) {
return s.getRight() > this.x
&& s.getBottom() > this.y
&& s.x < this.getRight()
&& s.y < this.getBottom();
}
return false;
} |
7056eaca-9f26-4d83-afee-029dc17ea3d2 | 6 | public boolean hapus(String no_beli){
boolean adaKesalahan = false;
Connection cn = null;
try{
Class.forName(Koneksi.driver);
} catch (Exception ex){
adaKesalahan = true;
JOptionPane.showMessageDialog(null,"JDBC Driver tidak ditemukan atau rusak\n"+ex,... |
98e33ccc-e57c-4082-a6f0-aacea7aa29b6 | 6 | public int Delete_Data(ProfileInfo DataObj) {
//System.out.println("ProfileDAO.Delete_Data()");
int res = 0;
ProfileInfo profileObj = null;
String sql = "DELETE FROM profile WHERE `Profile_Name`=?";
try {
profileObj = (ProfileInfo)DataObj;
con = getConnection();
pstmt = con.prepareSta... |
36cde4ca-9bee-4e78-bd2c-de1abe024c51 | 7 | public static void printNumbersFrom(Scanner in, int width, int precision, PrintWriter out){
int i = 0;
while(in.hasNext()){
// Zeilensprung jeder 10. Zahl
if ( i%10 == 0 && i>0){
out.println();
i=0;
}
// Wenn nächste gelesene Zahl eine Ganze Zahl ist..
if (in.hasNextInt()){
i++;
... |
dfeaf940-df26-4ca7-9b99-66fd2dd68e2a | 3 | public String toString(int index) {
StringBuilder sb = new StringBuilder();
initFields();
// For each field
for (String fname : fieldNames) {
if (!fname.isEmpty()) { // Non empty field?
try {
// Get field, array and value = array[index]
Field f = fieldByName.get(fname);
Object array = f.... |
a9806f2f-8968-4d45-962a-127ac7e74121 | 3 | void put(final MethodWriter owner, final ByteVector out, final int source,
final boolean wideOffset) {
if ((status & RESOLVED) == 0) {
if (wideOffset) {
addReference(-1 - source, out.length);
out.putInt(-1);
} else {
addReferenc... |
cc7679b2-ae96-48c9-9d18-1a4da841b094 | 7 | public int countPredicate(String predicate){
int count=0;
//Triples
for (Triple t:triples){
if (t.getPredicate().equals(predicate)){
count++;
}
}
//Triples in MSGs
if (msgs!=null){
for (MSG msg:msgs){
for (Triple t:msg.getTriples()){
if (t.getPredicate().equals(predicate)){
count... |
edd429f6-8fc8-4d88-b5ea-510405ac15a0 | 0 | @Around(value = "")
public void afterThrowing()
{
log.info("Exception in method: ");
} |
dddb7e11-2550-42e9-8c10-72cf349858b1 | 6 | @Override
public Tipo validarSemantica() throws Exception {
Tipo izq,der;
izq=izquierdo.validarSemantica();
der=derecho.validarSemantica();
if (izq instanceof TipoInt){
if (der instanceof TipoInt || der instanceof TipoFloat ){
return izq;
}
... |
adf3efa9-9285-4771-9e45-14db7e6ff3ed | 3 | public void readMap(String fn) throws IOException {
FileInputStream fin = new FileInputStream(fn);
BufferedInputStream bin = new BufferedInputStream(fin);
DataInputStream in = new DataInputStream(bin);
int w = in.readInt() + 1;
int h = in.readInt() + 1;
in.readFloat();
in.readFloat();
in.readFloat();
... |
3e018327-af72-43b3-b501-36cfff06005a | 1 | public static double round(double value, int places) {
if (places < 0)
throw new IllegalArgumentException();
BigDecimal bd = new BigDecimal(value);
bd = bd.setScale(places, BigDecimal.ROUND_HALF_UP);
return bd.doubleValue();
} |
1de04431-44a5-4592-a39b-5104ff18118a | 8 | protected void paintSelection(Graphics graphics) {
if (selectionStart == -1)
return;
graphics.setXORMode(true);
graphics.setBackgroundColor(ColorConstants.white);
TextFragmentBox frag;
for (int i = 0; i < fragments.size(); i++) {
frag = (TextFragmentBox) fragments.get(i);
// Loop until first visible... |
727f5cd0-df8f-4496-8648-c9ce4f4b47fd | 1 | public void setPunto(String jugador) {
if (jugador == "player1")
this.puntosJugador1 += 1;
else
this.puntosJugador2 += 1;
setChanged();
notifyObservers();
} |
3285b108-235c-41ca-b700-579277c37f83 | 7 | public static String getDiaEnLetra(){
GregorianCalendar calendario = new GregorianCalendar();
int dia = calendario.get(calendario.DAY_OF_WEEK);
String dato = "";
switch(dia){
case 1: dato = "Domingo"; break;
case 2: dato = "Lunes"; break;
... |
95d1666a-a60c-463c-95a3-adcb21517a4e | 3 | public void checkGameInput() {
float velocityX = 0;
if (moveLeft.isPressed()) {
velocityX-=player.getSpeed();
}
if (moveRight.isPressed()) {
velocityX+=player.getSpeed();
}
player.setVelocityX(velocityX);
if (jump.isPressed())
{
... |
aa221383-eeb6-4d20-9bdf-ef693f82b661 | 3 | public void update() throws ModelException {
TradeKingForeman foreman = new TradeKingForeman();
if (fields != null) {
try {
response = foreman.makeAPICall(MarketBuilder.getQuotes(
ResponseFormat.XML,
new String[] { symbol.getSymbol() }, fields));
} catch (ForemanException e) {
throw new Mo... |
8acf41cb-3049-41de-8ebd-bc6077c7dc94 | 4 | @Override
public boolean equals(Object o) {
if(o instanceof SimpleHashMap) {
if(this.entrySet().equals(((SimpleHashMap<?, ?>)o).entrySet())) {
return true;
}
}
return false;
} |
45e98019-f711-4f01-85fc-9e345ee67b4b | 5 | public void stopListening() {
if (!isRunning)
return;
isRunning = false;
while (!this.uploadFinished) {
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
}
}
for (Map.Entry<String, BufferedReader> e... |
c10d9e0a-76c0-49db-b154-229e61e111f6 | 0 | @Override
public void actionPerformed(ActionEvent e) {
collapseEverything((OutlinerDocument) Outliner.documents.getMostRecentDocumentTouched());
} |
271b0b0e-6603-43bb-a163-2497be7f224d | 2 | public void drawHalfSphere(float r, int scalex, int scaley)
{
BufferData data = RobotRace.VBOUtil.bufferHalfSphere(1F, scalex, scaley);
if(r != 1F)
gl.glScalef(r, r, r);
RobotRace.VBOUtil.drawBufferedObject(data);
if(r != 1F)
gl.glScaled(1/r, 1/r, 1/r... |
54f06ae9-b30f-4588-8b90-d7af72f22910 | 5 | public static boolean next_permutation(int[] vec) {
int tmp;
for (int i = vec.length - 2; i >= 0; i--)
if (vec[i + 1] > vec[i])
for (int j = vec.length - 1; j >= 0; j--)
if (vec[j] > vec[i]) {
tmp = vec[i];
v... |
ecd919e4-c55d-4685-ad59-af89bb0f4c79 | 2 | private static void showStadings(ApiAuthorization auth) {
StandingsParser parser = StandingsParser.getInstance();
try {
StandingsResponse response = parser.getResponse(auth);
StandingsList factionStandings = response.getFactionStandings();
Iterator<ApiStanding> factionIter = factionStandings.iterator();
... |
255b4fb2-1d55-4da1-ab43-451fd198c581 | 4 | public Type createRangeType(ReferenceType bottom) {
/*
* tArray(y), tArray(x) -> tArray( y.intersection(x) ) obj , tArray(x)
* -> <obj, tArray(x)> iff tArray extends and implements obj
*/
if (bottom.getTypeCode() == TC_ARRAY)
return tArray(elementType
.intersection(((ArrayType) bottom).elementType)... |
7b9171ea-a15d-4b0b-a355-74b2eac20103 | 8 | public void solve(){
Solver solver = new Solver();
String line = "";
int count;
try {
while(true){
line = bf.readLine();
if(line == null)
break;
if(line.startsWith("#") || line.isEmpty())
continue;
//String[] parts = line.split("\\|");
count = 0;
for(int i = 0; i < 81; i++){... |
cc2c4322-332a-4190-9927-66772b5488d1 | 6 | public void log(int numberOfTweets, String[] tweetedTrends) {
String trends = "";
for (String tweetedTrend : tweetedTrends) {
if (tweetedTrend.equals("")) break;
else trends += tweetedTrend + ", ";
}
if (!(trends.equals(""))) trends = trends.substring(0, trends... |
a892f31b-7b20-4608-abb4-3abe63c48cde | 2 | public static UserAction getByActionCode(int actionCode) {
for (UserAction userAction : UserAction.values()) {
if (userAction.getActionCode() == actionCode) {
return userAction;
}
}
throw new UnsupportedOperationException(String.format("Action for code %d ... |
16bbdc74-0b9c-4d5b-8dca-a16dd1b78f08 | 8 | public BusinessDayAdjustments readBusinessDayAdjustments(XMLStreamReader2 streamReader) throws XMLStreamException {
BusinessDayConventionEnum businessDayConvention = null;
List<String> businessCenters = null;
int startingDepth = streamReader.getDepth();
while(streamReader.hasNext()) {
switch(strea... |
dc3c375c-a208-4fa8-82d2-4140e30674d3 | 9 | public int GetHighestNumberPrimesFromSubstitution(int subValue) {
if(!_factorizer.IsKnownPrime(subValue)) return 0;
List<Integer> values = GetListOfValues(subValue);
List<Integer> primeList;
if(values.size() == 1) return 1;
int count = 0;
for(int i = 0; values.size() > I... |
e393be62-dd2b-430a-bb47-297f2579e66b | 8 | private Element generateTableJustInBase(Document doc, TableInfo tbl) throws ParserConfigurationException {
/** Пример того что должно получится на выходе
* <Table place="base">
* <sTableName>CMS_WF_STATUS</sTableName>
* <sOwner>
* <file></file>
* <base>C... |
91dd20c1-7fba-41da-a194-cac595c7ba57 | 6 | public static void main(String[] args) throws Exception {
String cmd = args[0].intern();
if(cmd == "render") {
PosixArgs opt = PosixArgs.getopt(args, 1, "aw:f:s:");
boolean aa = false;
String font = "SansSerif";
int width = 100, size = 10;
for(char c : opt.parsed()) {
if(c == 'a') {
a... |
031241e6-6747-47da-a563-a152f4f1e93b | 9 | public void menuLoop(String fileName)
{
boolean test = false;
while(!(test))
{
String input = view.menuOptions();
switch(input)
{
case "find":
view.find(courses);
break;
case "add":
view.add(courses);
break;
case "remove":
view.remove(courses);
break;
case ... |
a5587d60-8271-4434-88e8-966455a82e30 | 1 | public static BufferedImage LoadImage(String filepath){
URL resource;
BufferedImage image=null;
try{
resource = Empous.class.getResource(filepath);
image = ImageIO.read(resource);
}
catch (IOException ex) {
System.out.println("Couldn't find image!");
System.out.println(filepath);
System.e... |
36a78234-1965-4623-a1d0-c2cf49b9b378 | 8 | @Override
public boolean okMessage(Environmental host, CMMsg msg)
{
if(((msg.sourceMinor()==CMMsg.TYP_QUIT)
||(msg.sourceMinor()==CMMsg.TYP_SHUTDOWN)
||((msg.targetMinor()==CMMsg.TYP_EXPIRE)&&(msg.target()==shelter))
||(msg.sourceMinor()==CMMsg.TYP_DEATH)
||(msg.sourceMinor()==CMMsg.TYP_ROOMRESET))
&&... |
7cc897b3-0184-46a1-8165-dfd43a38a08e | 0 | private SystemUtil() {} |
0db2660c-93bd-4c6d-abe9-81cbedb850c1 | 4 | public static void filledEllipse(double x, double y, double semiMajorAxis, double semiMinorAxis) {
if (semiMajorAxis < 0) throw new RuntimeException("ellipse semimajor axis can't be negative");
if (semiMinorAxis < 0) throw new RuntimeException("ellipse semiminor axis can't be negative");
double ... |
e82fdb6f-3122-462f-868e-95691feca8c8 | 0 | public Context(State state) {
this.state = state;
} |
baeb8355-e6f7-4d76-ba24-0500cd1f904d | 5 | void goToImageByID(String newID){
//Seach for image in current list of images
//Goto if found
for(int i=0;i<imageIDs.length;i++){
if(imageIDs[i].equals(newID)){
currentI = i;
imageChanged();
mainGUI.tagTree.repaint();//Needs to update n... |
ba477e02-7cdc-4813-b329-3ba9a2bd583c | 3 | public void colorizeGraph(LabelPropagationCluster[] graphClusters) {
if(graphClusters == null) {
return;
}
for (LabelPropagationCluster cluster : graphClusters) {
Color color = cluster.getColor();
for (Node node : cluster.getNodes()) {
colori... |
86b6034d-f0fb-47f9-9262-b728fbe00be3 | 2 | @Override
public float calculateDesire() {
float desire = 0;
//figure out the distance between player and mob
int actorX = ai.getActor().getMapX();
int playerX = registry.getClosestPlayerX(ai.getActor().getCenterPoint(), MAX_DISTANCE);
int distance = Math.abs(playerX - actor... |
bbd2badc-ac56-49b8-93c0-942e3a092489 | 4 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String userid = request.getParameter("userid");
System.out.print(userid);
String name = request.getParameter("username");
String password = request.getParam... |
7c47c4b8-8a39-4c3a-a9ed-15a8798c603a | 6 | public static void main( String[] args ) {
ProgramRunner pr = new ProgramRunner();
pr.schedule( new ProgramSegment() {
boolean quit = false;
@Override public void run(ProgramShell shell) {
long startTime = shell.getCurrentTime();
System.err.println("I am starting. Time = "+startTime);
final I... |
a90968c8-6eb2-4899-bb3d-9e4acc15dc46 | 7 | private boolean onCommandModVersion(CommandSender sender, Command command, String label, String cmd, String[] args)
{
if (sender.hasPermission(ReplicatedPermissionsPlugin.ADMIN_PERMISSION_NODE))
{
if (args.length > 1)
{
String modName = args[1].toLowerCase();
if (args.length > 2)
{
floa... |
da6afb38-f892-4702-ba5a-054768957170 | 5 | public boolean makePass(SkiPass sp) {
if (sp.isBlocked()) {
return false;
}
if (isExpired(sp)) {
sp.block();
return false;
}
if (!isActivated(sp)) {
return false;
}
if (!system.validate(sp)) {
sp.block... |
b4892b3e-2109-484a-bf44-962983ccc3f3 | 4 | @Override
public void actionPerformed(ActionEvent event) {
String string = "";
if(event.getSource() == textField1) {
string = String.format("textField1: %s",
event.getActionCommand());
}
... |
cd7a3bf1-ebb4-4a64-91ab-b64fdd69e597 | 6 | public static void main(String args[]) {
/*
* Set the Nimbus look and feel
*/
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/*
* If Nimbus (introduced in Java SE 6) is not available, stay with the
* default look and fe... |
1b1392c1-4389-4937-a281-2dac70ab95cc | 2 | protected static String preprocessor(String wikiText) {
if (RegEx.find(Patterns.IMAGE_OTHER_VARIANT, wikiText) == true) {
wikiText = RegEx.removeAll(wikiText, Patterns.IMAGE_OTHER_VARIANT);
}
if (RegEx.find(Patterns.IMAGE_CURLY, wikiText) == true) {
wikiText = RegEx.rem... |
7bf834e1-c9ff-475d-a5c5-83df578bde4d | 5 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Point other = (Point) obj;
if (posX != other.posX)
return false;
if (posY != other.posY)
return false;
return true;
} |
033c8277-19da-4c34-87a4-a49df79c22e8 | 9 | @Override
public boolean tick(Tickable ticking, int tickID)
{
if(!super.tick(ticking,tickID))
return false;
if(affected==null)
return false;
if(!(affected instanceof MOB))
return true;
final MOB mob=(MOB)affected;
if((!mob.amDead())&&((--diseaseTick)<=0))
{
diseaseTick=DISEASE_DELAY();
mob... |
f320a008-be22-46c9-b0fd-7fca6826c864 | 0 | protected JTable initParseTable() {
tablePanel = new LLParseTablePane(table);
return tablePanel;
} |
7e18c3ad-14e0-4b50-9a96-2b041d1eb3b5 | 9 | public InternalServer createSampXmlRpcServer() throws IOException {
String path = getXmlrpcPath();
ServerSocket socket = createServerSocket( getPort() );
String logType = getLogType();
OriginAuthorizer oAuth = getOriginAuthorizer();
PrintStream logOut = System... |
db064436-4013-41c0-894e-c53b82aae98c | 3 | private static void compareTwoCharArrays( char[] data1, char[] data2 )
throws MVDTestException
{
if ( data2.length != data1.length )
throw new MVDTestException(
"Original and read versions not the same length");
for ( int i=0;i<data2.length;i++ )
{
if ( data1[i] != data2[i] )
throw new MVDTestExc... |
046a2e2d-b8e8-4023-a44c-215cbe460956 | 9 | public static ArrayList<String> subspace(String method, int d, ArrayList<Term> sort){
//Create array of terms only
ArrayList<String> SortedTerms = new ArrayList<String>();
for(Term e : sort){
SortedTerms.add(e.text);
}
ArrayList<String> reduced = new ArrayList<String>();
int D = 100*2^d;
if(metho... |
e0eccbf4-221a-43bb-80a2-c756526c15c0 | 2 | @Override
public int matches( long[] sequenceA, int indexA, long[] sequenceB, int indexB, int count )
{
for (int i = 0; i < count; i++)
{
if (sequenceA[indexA + i] != sequenceB[indexB + i])
{
return i;
}
}
return count;
} |
d7ebd3c8-0018-44af-aded-d5e90283c134 | 7 | public List<Goods> getSellGoods(int limit, Unit unit) {
List<Goods> result = new ArrayList<Goods>();
List<Goods> settlementGoods = getCompactGoods();
Collections.sort(settlementGoods, exportGoodsComparator);
int count = 0;
for (Goods goods : settlementGoods) {
if (!w... |
85d47bef-aac2-45c2-af21-f407827a28b8 | 7 | public void getInput(){
String command;
Scanner inFile=new Scanner(System.in);
do {
this.display();//display the menu
// get command entered
command= inFile.nextLine();
command=command.trim().toUpperCase();
switch... |
54da7909-ccd1-4e12-9e14-935980a6ec5c | 4 | public boolean validarVehiculo(Vehiculo vehiculo, Persona p, EntityManager manager) {
boolean resultado = false;
if (vehiculo != null) {
if (manager.find(Vehiculo.class, vehiculo.getMatricula()) != null) {
resultado = true;
System.out.println("No se pudo agreg... |
6d61c33d-bf31-4584-b62f-1cdc1ae9035e | 6 | @Override
public void render(Graphics2D g)
{
Shape outline;
if (connectedObject instanceof Circle)
{
double radius = connectedObject.getRadius();
double diameter = radius * 2;
double x = connectedObject.getPosition().getX() - radius;
... |
a395f0c7-373a-475a-8698-22f198854510 | 5 | public static CycAccess getNewCycAccessInteractively() {
CycAccess cycAccess = null;
String hostname = "localhost";
final Integer[] ports = {3600, 3620, 3600, 3660, 3680};
Integer port = ports[0];
while (cycAccess == null) {
hostname = JOptionPane.showInputDialog("Specify host machine:", hostn... |
5ac91f18-ee6e-4c44-bb2e-eed4730d1d70 | 7 | private void getSenseInstruction() {
currentState = new BrainState(BrainState.INSTRUCTION_PICKUP);
char read = (char) readAhead;
readNext();
if(checkCharacter(read, 'e')) {
read = (char) readAhead;
readNext();
if(checkCharacter(read, 'n')) {
read = (char) readAhead;
readNext();
if(checkChar... |
2da26ca8-10c8-4109-bd28-adf742c1cfbe | 0 | public PartA getPartA() {
return partA;
} |
82d7764f-fbfa-4050-a382-330d4ad0ef6e | 0 | public final void deVoice(String channel, String nick) {
this.setMode(channel, "-v " + nick);
} |
9aedf80c-7223-44c7-ac5d-4424826fc0e8 | 8 | private Element getEdgesElement(ArrayList<Arc> listOfArcs, Document doc) {
Element edges = doc.createElement("edges");
for (Arc a : listOfArcs) {
Element edge = doc.createElement("edge");
String type = "";
String resourceType = "";
Attr edgeType = doc.c... |
f2694068-0e2c-484a-b97d-73f02bba6f7f | 1 | public boolean validSetupForMove(Field currentField, Field emptyField) {
return currentField.hasPiece() && !emptyField.hasPiece();
} |
d3d37a67-45dd-4cc8-963b-7ea6822245d8 | 8 | public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof KeyedValues)) {
return false;
}
KeyedValues that = (KeyedValues) obj;
int count = getItemCount();
if (count != that.getItemCount()) {
r... |
a3b5a16b-2b14-4590-945e-9c6d5519f756 | 4 | private int generateX() {
int x = (int) (Math.random() * Game.WIDTH);
if (x >= 32 && x <= Game.WIDTH - 32
&& (x > handler.playerObject.getX() + 100 || x < handler.playerObject.getX() - 100)) {
return x;
} else {
return generateX();
}
} |
552f65be-12ac-4b09-95dd-e878c51e9645 | 9 | private void traceDirectRegister(String reg, int lineNum, AndrCodeBlock block, HashSet<String> result)
{
if(block.getVisitedFlag())
return;
block.setVisitedFlag(true);
String[] code = block.getBlockCode(); //可能从寄存器判断值是不是在本方法中确定,如果是带P的寄存器就是从其它地方传过来的
if(reg.startsWith("p"))//暂不处理在本方法以外的
{
System.ou... |
fe39f64a-4fd9-4c4e-96ef-e7650c5bafaa | 3 | public int getFieldIndex(String fieldName, Type fieldType) {
for (int i = 0; i < fields.length; i++) {
if (fields[i].getName().equals(fieldName)
&& fields[i].getType().equals(fieldType))
return i;
}
return -1;
} |
4bca4ab0-586b-4c1d-98f1-79c8942835db | 5 | public static String getOrdinal(int value){
if((value%100)>10&&(value%100)<20){
return "th";
}
value=value % 10;
switch(value){
case 1:
return "st";
case 2:
return "nd";
case 3:
return "rd";
default:
return "th";
}
} |
5ae890cc-53dc-4f25-8f2a-8d569d9af693 | 3 | public void body(){
// Process events until END_OF_SIMULATION is received from the
// GridSimShutdown Entity
Sim_event ev = new Sim_event();
while ( Sim_system.running() )
{
super.sim_get_next(ev);
// if the simulation finishes then exit the loop
... |
5e490acf-5995-4e70-b287-7143e66cb30b | 6 | public void unfreezePlayer(int playerID) {
Player p = this.playerIDs.get(playerID);
if (p!= null) {
Location l = p.getLocationInFrontOf();
Player toUnfreeze = null;
for (Player player: playerIDs.values()) {
if (player.getLocation().equals(l)) {
toUnfreeze = player;
break;
}
}
if (to... |
5f7f7178-5c6f-4f99-8041-ff7857fd08c9 | 4 | public int searchLeftRight() {
if (x % BOX_SIZE != 0) {
for (int a = 0; a < MOVEMENT_SMOOTHING; a++) {
if ((x + a) % BOX_SIZE == 0) {
return x + a;
}
if ((x - a) % BOX_SIZE == 0) {
return x - a;
}... |
cbd742a0-8ad0-4fca-9175-0d9fcd68b53a | 3 | public static <PROJECTION, RESULT, TYPE> Order<PROJECTION> getMultiFieldOrder(FieldSortOrder<? super RESULT, TYPE>... sortOrders)
{
List<FieldOrder<PROJECTION, RESULT, TYPE>> orders = new ArrayList<FieldOrder<PROJECTION, RESULT, TYPE>>();
for(FieldSortOrder<? super RESULT, TYPE> sort : sortOrders)
... |
d1750afb-a8c7-41a7-9dcf-b8edff44a7fb | 5 | private void unfilter(byte[] curLine, byte[] prevLine) throws IOException {
switch (curLine[0]) {
case 0: // none
break;
case 1:
unfilterSub(curLine);
break;
case 2:
unfilterUp(curLine, prevLine);
... |
9b9a08c5-0235-45c7-a408-48a8878b961f | 6 | public static void main(String[] args)
{
System.out.println(" 5 .");
sc = new Scanner(System.in);
double[] a = new double[5];
int[] m = new int[5];
int s=0;
//
for (int i = 0; i < 5; i++){
if (sc.hasNextDouble()){
a[i] = sc.nextDouble();}
else {
... |
1af341fa-6ebb-4b69-8b2e-81b7b3930e4c | 5 | public void handle(LinkedList<NewNode> nns,Hashtable<Integer,Node> nodeList){
LinkedList<Integer> canReach = getCanReach(nodeList);
for(NewNode nn:nns){
for(int v:canReach){
if(nn.getNodes().contains(v)){
this.addCanReachNode(nn);
break;
}
}
if(nn.getNodes().contains(unit.getStart())){... |
c63ca994-d522-4113-ba6c-fa1d772f6848 | 7 | public static TextureData loadTextureDataFromFile(String path) {
// URL url = ResourceLoader.class.getResource(path);
File file = new File(path);
if (!file.canRead())
return null;
TextureData texData = null;
if (path.contains(".jpg")) {
try {
texData = TextureIO.newTextureData(file, false, TextureIO... |
c8622945-ba9e-46bc-a792-1a31c2aed402 | 7 | public List<Randevu> findRandevular(Hasta hasta, Doktor doktor){
List<Randevu> randevular = new ArrayList<Randevu>();
for (Randevu randevu : randevuListesi) {
if(hasta == null){
if(randevu.getDoktor().getAdSoyad().equalsIgnoreCase(
doktor.getAdSoyad())){
randevular.add(randevu);
}
}
else... |
366c0821-85ae-4ed5-9552-60d9b0fa046d | 7 | public int addReservation(int numberOfPeople, Date appointmentTime,
int numberOfSlots) {
int tableId = -1;
int slot = getSlot(appointmentTime);
for (Integer tableSize : tableMap.keySet()) {
if (tableSize < numberOfPeople)
continue;
List<Table> tables = tableMap.get(tableSize);
for (Table t : tab... |
c12aca0d-65c5-412c-979a-6e0fddb188e9 | 2 | int firstMatch(String s, int fromIndex, String p) {
for (int i = fromIndex; i < s.length() - p.length() + 1; i++) {
if (headMatch(s, i, p))
return i;
}
return -1;
} |
667fdc5a-9324-478f-a9c4-44a8a9994f2a | 0 | @Test
public void determineHighestFlush_ifFiveOfSameSuit_returnsSetOfFiveCards() {
assertFlushOfSize(getAllFlushCards(nonStraightFiveFlush()), 5);
} |
a314c314-7dea-48ea-abbe-548a7872d0ed | 0 | public static void main(String[] args) {
ParcelScope p = new ParcelScope();
p.track();
} |
0953df3e-9b64-4892-b904-cf7b80e3bbcd | 3 | @SuppressWarnings("unchecked")
public void put(String k, E v) {
int hash = Math.abs(k.hashCode() % SIZE);
Entry<E> e = (Entry<E>) table[hash];
if(e != null) {
// it means we are trying to insert duplicate
// key-value pair, hence overwrite the current
// p... |
47a71487-cb4e-44e7-85e8-90d38693857b | 3 | public void run() {
request = new ServiceRequest(host+"/"+path+"?"+StaticValues.JSON_GET_VAR, threadId);
request.run();
ServiceDirectory sd = JsonObjectMapper.mapToServiceDirectory(request.getContent());
if( sd == null ) return;
for( String dir: sd.getFolders() ) {
DirectoryCrawler dirCrawler = ne... |
0436adc5-86b2-47d0-9871-afd774755c87 | 1 | @Test
public void testInvalidWrite() { //Writing to an invalid index should have no effect
registers.write(16, testOperand);
for (int i = 0; i < 16; i++) {
assertNull(registers.read(i)); //Check that no registers have been wrongly updated in event of false index
}
} |
81203c82-981e-438f-bcd6-36b7497e3e22 | 9 | @Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
if (request.getParameter("command").equals("Insert")) {
String name = request.getParameter("name");
String description = request.getParameter("... |
52a7e0f0-ce23-4f23-bc89-fcb97ad9d505 | 3 | private static String fixMsg(String msg, Object... vars) {
if (vars != null) {
for (int i = 0; i < vars.length; i++) {
if (vars[i] == null) {
break;
}
msg = msg.replace(vars[i].toString(), vars[++i].toString());
}
... |
13c3e796-595f-4e03-af20-b4afdae49e42 | 5 | @Override
public boolean canImport(TransferHandler.TransferSupport support) {
if(!support.isDrop())
return false;
DialogNode selected;
try {
byte[] bytes = (byte[]) support.getTransferable().getTransferData(DialogNode.dmselFlavor);
selected = DialogNode.readFromBytes(bytes);
} catch (Except... |
4e6f0bc0-ec65-464a-a55d-1da7e378fc21 | 9 | public String disambiguateName(String name) throws ParsingException {
String[] fields = name.split("[.]");
if (fields.length == 2 && (!fields[0].equals("null")))
return name;
if (fields.length > 2)
throw new ParsingException("Field " + name + " is not a valid field refe... |
05b1e3ba-0e64-4bfa-8ec9-1127baed6ae0 | 8 | @Override
public boolean add(T e) {
if (e == null)
throw new RuntimeException("Does not permit nulls");
int code=e.hashCode();
int hash =hash(code);
int hash2 = hash2(code);
int hash3 =hash3(code);
hash =hash & mask;
hash2 =hash2 & mask;
hash3 =hash3 & mask;
//inlining for performance. makes add a... |
68d706ed-c950-4e51-b6e1-305481aa8ad2 | 2 | public boolean iterate(String value) {
if (value == null) {
return true;
}
if (result == null) {
result = new ArrayList<String>();
}
result.add(value);
return true;
} |
05cc995c-07da-4313-9610-307aa72f66f3 | 6 | private void btnLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLogActionPerformed
//Создаем обьект доступа к таблице пользователей
UsersDAO users = new UsersDAO();
try {
//Проверка регистрации и активности пользователя
Users user;
if ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.