method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
d0571c88-40cf-43e9-bf12-21d616ec513f | 4 | public boolean isValid(Coordinate coord) {
if (getCell(coord).getElementType() == ElementType.GRASS
|| getCell(coord).getElementType() == ElementType.LEAF
|| getCell(coord).getElementType() == ElementType.INTRUDE
|| getCell(coord).getElementType() == ElementType.GUARDIAN)
return true;
else
return ... |
b2ba660c-420f-4630-8adb-31e2a610278e | 2 | @RequestMapping("/helloworld")
public ModelAndView helloWord() {
teamNamesAfter.clear();
teamIdAfter.clear();
playerNames.clear();
multiplePlayerIds.clear();
multiplePlayerInformation.clear();
try {
long startTime = 0, endTime = 0, totalTime = 0;
JSONObject json = readJsonFromUrl("http://sandbox.bad... |
a36ab0d3-e614-414d-9558-312f5bbd2686 | 6 | public Integer call()
{
count = 0;
try
{
File[] files = directory.listFiles();
ArrayList<Future<Integer>> results = new ArrayList<Future<Integer>>();
for (File file : files)
if (file.isDirectory())
{
MatchCounter counter = new Match... |
eee0b8db-49d1-4e96-b9f3-2e1f70cfdcc0 | 4 | public int getAttitudeRank()
{
switch (this.Attitude)
{
case "Marginal":
return MARGINAL;
case "Non-Supportive":
return NONSUPPORTIVE;
case "Mixed":
return MIXED;
case "Supportive":
... |
88595954-b756-4874-9555-04125678074b | 6 | private static int alphaBeta(Configuration conf, int alpha, int beta,byte depth,byte max){
if ((conf.whoWin() != 0) || (depth >= max)){
return evaluation(conf);
}
else{
int meilleur = Integer.MIN_VALUE;
for (Configuration fconf : listeFils(conf)) {
int suiv=-alphaBeta(fconf, -beta, -alpha, (byte) (de... |
49bb8d5b-7a7c-4ce1-95ad-7d4caab500b5 | 4 | private int getNakshatraNaadiPosition(Nakshatra nakshatra) {
int naadiPosition = 0;
int starPosition = nakshatra.ordinal() + 1;
for (Integer[] nadiPositionGroup : naadiDetailsCache) {
int position = 1;
for (Integer nadiPosition : nadiPositionGroup) {
if (nadiPosition == starPosition) {
naadiPositio... |
bc325af4-d159-4e13-9b77-5a4f29050a3f | 0 | private int getState() {
return state;
} |
d000af80-90ab-484e-9f72-f2bfc08a22e9 | 5 | @Override
public void removeMulrk( Rk thisrk )
{
Mulrk mymul = (Mulrk) thisrk.getMyMul();
if( mymul != null )
{ // Part of a mulrk. JOY!
AbstractList vect = mymul.removeRk( thisrk );
boolean deletemulrk = false;
if( mymul.getColFirst() == thisrk.getColNumber() )
{
deletemulrk = true;
}
if(... |
382513db-e01d-4577-bef2-8cc3b03c75d3 | 9 | static void mark_sprites_colors()
{
int offs,color,i,pal_base;
int[] colmask=new int[16];
int[] pen_usage; /* Save some struct derefs */
/* Sprites */
pal_base = Machine.drv.gfxdecodeinfo[4].color_codes_start;
pen_usage=Machine.gfx[4].pen_usage;
for (color = 0;color < 16;color++) colmask[... |
f802d9c2-9899-4ca3-b524-5dcc690df068 | 1 | public void removeOnetimeLocals() {
if (instr != null)
instr = instr.removeOnetimeLocals();
super.removeOnetimeLocals();
} |
4f95d137-be8a-46a0-9e72-07de3dcb5144 | 6 | public CommandHandler getCommandHandler(String label) {
for (CommandHandler commandHandler : commandHandlers) {
boolean ignoreCase = commandHandler.getInfo().isIgnoreCase();
for (String commandLabel : commandHandler.getInfo().getLabels()) {
if (ignoreCase && commandLabel... |
a1d2ee29-d1d5-418f-bfcf-98ae7472c072 | 7 | private int findNearestPair(double key, double secondaryKey) {
int low = 0;
int high = m_CondValues.size();
int middle = 0;
while (low < high) {
middle = (low + high) / 2;
double current = ((Double)m_CondValues.elementAt(middle)).doubleValue();
if (current == key) {
double secon... |
ca20e031-5bd8-4c70-8cb6-6b2f77405584 | 6 | public void rMayusVerticesLocal(double paramRadio)
{
Iterator elemFuente;
Elemento entrada,salida;
Iterator elemDestino = destino.listaElementos();
double sumaDistancias,sumaValores,distancia,ponderacion,rMayor;
double dist[];
int count;
while(elemDes... |
aaa0f4ee-450a-470c-af19-477a137d17c8 | 9 | public static String whatTypeOfTriangleIsThis(double a, double b, double c)
{
if(!(isItARightTriangle(a,b,c))) return "";
if((a == b) || (b == c) || (a == c))
{
if((a != b) || (b!= c) || (a != c))
if(isRightTriangle(a,b,c)){
return "The triangle is right and isosceles";
}else
return "The tri... |
832d07ae-78cf-4843-98fa-ae619af85cb3 | 9 | static synchronized void Leader(int agentId, int agentType)
{
int[][] actualGrid = AgentNetworkController.getActualGrid();
int i, j, val, x, y;
int[] committedList;
ArrayList<int[]> committedPositionList = new ArrayList<int[]>();
Random random = new Random(System.nanoTime());
for(i=0... |
49d10501-3f24-453c-80e7-7af4090fdf1f | 6 | private void addSubArcsToSpecials()
{
if ( leftSubArc != null && leftSubArc.dataLen() >= MUM.MIN_LEN )
{
if ( leftSpecialArcs == null )
leftSpecialArcs = new SimpleQueue<SpecialArc>();
leftSpecialArcs.add( leftSubArc );
}
if ( rightSubArc != null && rightSubArc.dataLen() >= MUM.MIN_LEN )
{
if ( ... |
0e394ba8-658c-4ae6-8909-dcb7222bea57 | 5 | private static <T> Integer maximumFreqency(List<T> list) {
Map<T, Integer> map = new HashMap<>();
for (T t : list) {
Integer val = map.get(t);
map.put(t, val == null ? 1 : val + 1);
}
Entry<T, Integer> max = null;
for (Entry<T, Integer> e : map.entrySet()) {
if (ma... |
9f391e7b-78aa-48f5-ba64-462966f30ad0 | 4 | @Override
public void update(GameContainer gc, StateBasedGame sbg, int delta) {
//c//Check each Entity for collisions in the slowest, most straight-forward way. (Optimizations to come.)
//System.out.println("STEP");
for(int i = 0; i < collisionRoll.size(); ++i){
Collidable a = collisionRoll.get(i);
if (a.g... |
13035ac3-f776-42c4-b535-0c02791d13fe | 1 | * @param x A JSONTokener of the source text.
* @return A JSONObject combining the names and values.
* @throws JSONException
*/
public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x)
throws JSONException {
JSONArray ja = rowToJSONArray(x);
return ja != nul... |
a61f4795-fc1b-4762-925a-afed1e510759 | 2 | public void setColumn(int i, String column_str) {
int[] column_array = strToArray(column_str);
if (column_array.length != height)
return;
for (int j=0; j<height; j++) {
setElement(i, j, column_array[j]);
}
} |
31a407f7-7e9c-4720-a387-6a969d3ebde0 | 7 | private static int gcd(int u, int v) {
// simple cases (termination)
if (u == v)
return u;
if (u == 0)
return v;
if (v == 0)
return u;
// look for factors of 2
if ((~u & 1) == 1) // u is even
{
if ((v & 1) == 1) /... |
ee0677db-3398-42a2-a6ad-90c4e7c4955a | 4 | @Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(im, 0, 0, this);
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
g.setColor(new Color(255, 255, 255, 20));
g.fillRect(i * 50 - 4, j * 50 - 4, 48, 48);
g.setColor(new Color(255, 255, 255, 30));
g... |
0f2b04a0-b44e-4f4f-a23f-467aaf0cdd7f | 7 | public String getCText(){
System.out.println(parseTree.toString());
CText = "";
//Первоначально меняем некоторые синтаксические конструкции
for (Tree<TokenParser> child : parseTree.getSubTrees()) {
if(child.getHead().equals("%BlockProgram%")){
clearAllChildren... |
d38ee29f-df13-4bb7-b486-602a05b15fab | 6 | public String nextCDATA() throws JSONException {
char c;
int i;
StringBuffer sb = new StringBuffer();
for (;;) {
c = next();
if (end()) {
throw syntaxError("Unclosed CDATA");
}
sb.append(c);
i = ... |
2eeb94af-2a21-4a59-b726-24ef045cc5b2 | 9 | * @param client
*/
private void cmd_edit(final String arg, final Client client) {
final Player player = getPlayer(client);
if (arg.equalsIgnoreCase("new")) {
send("EDIT> This command only works with existing objects.", client);
return;
}
final Integer dbref = Utils.toInt(arg, -1);
MUDObject m = nu... |
f9689bb3-254d-49d4-9401-510d26b06212 | 9 | public static void main( String [ ] args )
{
AATree t = new AATree( );
final int NUMS = 40000;
final int GAP = 307;
System.out.println( "Checking... (no bad output means success)" );
for( int i = GAP; i != 0; i = ( i + GAP ) % NUMS )
t.insert( new MyInteger( ... |
926125c5-de7e-4c9e-acdf-d5d3eab0843e | 8 | private void processInputPlayer(Player uObj){
if (uObj.getPressedDown()) {
if(uObj.getVelY() < uObj.getInitVel()){
uObj.setVelY(uObj.getInitVel());
}
uObj.addVelY(uObj.getAccel());
}
if (uObj.getPressedUp()) {
if(uObj.getVelY() > -uObj.getInitVel()){
uObj.setVelY(-uObj.getInitVel());
}
u... |
984f9143-778a-4eea-b2ab-5ece6bfa4ef2 | 9 | public static void main(String[] arg)
{
Billetautomat automat = new Billetautomat();
int antalFejl = 0;
int retur;
retur = automat.getBilletpris();
if (retur != 10) {
System.out.println("FEJL, getBilletpris() != 10");
}
System.out.println("*** Tjek af salg af en billet");
automat.indsætPenge(10... |
bdc9fe04-8d1a-4279-87ef-f45b6eb1981b | 2 | @Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((col == null) ? 0 : col.hashCode());
result = prime * result + ((row == null) ? 0 : row.hashCode());
return result;
} |
d343f4bc-0bec-4761-a1d9-652a9fd73242 | 5 | public CheckResultMessage checkE05(int day) {
int r1 = get(13, 5);
int c1 = get(14, 5);
int r2 = get(17, 5);
int c2 = get(18, 5);
if (checkVersion(file).equals("2003")) {
try {
in = new FileInputStream(file);
hWorkbook = new HSSFWorkbook(in);
if (0 != getValue(r1 + day, c1 + 1, 3).compareTo(
... |
fba3a452-e060-4b1e-9d53-857e2c43524f | 6 | public void toRequest(HttpServletRequest request, HttpServletResponse response){
try{
if(request.getParameter("requestType").equals("addBasket")){
addBasket(request,response);
}else if(request.getParameter("requestType").equals("insertBasket")){
insertBasket(request,response);
}else if(request... |
9328003a-42fa-47d5-bd03-3bbae1193cd0 | 2 | public boolean matches( Class<?> clazz )
{
String classPackageName = clazz.getPackage().getName();
return classPackageName.equals( this.targetPackageName )
|| classPackageName.startsWith( this.targetPackageName + '.' );
} |
8c85c62a-0356-426d-8235-a78ad3373eb8 | 5 | public Object getValue() {
DataRow dataRow = getState().getDataRow();
InvestmentReportModel reportModel = (InvestmentReportModel)dataRow.getReportModel();
double yield = 0.0;
String securityName = (String)dataRow.getValue(securityField);
if (securityName.length() > 0) {
... |
5fee72b8-d6c0-4df0-a50b-774176c7ca58 | 2 | @Override
public void updateObserver(Game game,Roll roll){
Iterator<Player> it = game.getPlayerList().iterator();
Iterator<Integer> it2 = roll.getRollResult().iterator();
int player1 = it2.next();
int player2 = it2.next();
String result=it.next().getName();
if(player2... |
5f09129c-13a5-43df-aa7f-e5a27bbed084 | 4 | @Override
public void render() {
if(sprite != null && visible) {
float offsetX = (sprite.getWidth() - width) / 2;
float offsetY = (sprite.getHeight() - height) / 2;
float drawX = x - offsetX;
float drawY = y - offsetY;
Ren... |
583e03cb-adc4-492f-ba7e-6165a254d1c6 | 6 | private void handleMouseDown(int modifiersEx) {
ModelManager modelMgr = ModelManager.getInstance();
int materialID;
if ((modifiersEx & MouseEvent.BUTTON1_DOWN_MASK) != 0)
materialID = modelMgr.getPrimaryMaterialID();
else if ((modifiersEx & MouseEvent.BUTTON3_DOWN_MASK) != 0)... |
9e6f8ce4-80a5-4d73-986d-6b591eb4c158 | 1 | public static ArrayList<QuizCreatedAchievement> getAllAchievements() {
if (allAchievements.isEmpty())
loadAllAchievements();
return allAchievements;
} |
104b001f-c21a-4d13-b8fe-c2361200b83d | 4 | public int max(int hori, int verti, int dia) {
if (hori >= verti && hori >= dia) {
return hori;
} else if (verti >= hori && verti >= dia) {
return verti;
} else {
return dia;
}
} |
cb8ccbb4-8702-482a-912d-0c9aa984ab39 | 5 | public static int EditDistance(String s1, String s2){
/* m and n represent the length of two strings*/
int m = s1.length();
int n = s2.length();
/*creates 2-d array of lengths of strings*/
int[][] d = new int[m+1][n+1];
/*Top row of array is filled*/
for(int i=0;i <= m;i... |
c52b39cf-c722-439c-a839-faf5fcabee06 | 8 | public synchronized static Future<?> blink(GpioPinDigitalOutput pin, long delay, long duration, PinState blinkState) {
// perform the initial startup and cleanup for this pin
init(pin);
// we only blink for requests with a valid delay in milliseconds
if (delay > 0) {
... |
f97e640d-12dc-40fc-bcc4-1b679f76889f | 4 | public void downloadFailedFiles() throws IOException {
try {
GutenbergCrawlerHelper.init();
} catch (IOException e) {
e.printStackTrace();
}
BufferedReader br = new BufferedReader(new FileReader(new File(
"gutenberg/failurl.txt")));
String line = null;
int index = 0;
List<String> urls = Collecti... |
8b6bb7d2-2190-4a63-87cd-f8875a1ac1f3 | 3 | @Override
public void run() {
try {
for (Song song : currentPlayList) {
current = song;
try {
FileInputStream fis = new FileInputStream("songs/" + song.getFileName());
player = new Player(fis);
player.pla... |
843cdc69-49a9-490d-b617-07ac4a517181 | 3 | AbstractNode type() {
AbstractNode node = null;
if (test(IDENT)) {
node = constIdent();
} else if (test(ARRAY)) {
node = arrayType();
} else if (test(RECORD)) {
node = recordType();
} else {
failExpectation("type");
}
return node;
} |
6cc02d1a-d4b0-4171-8e48-93c3cae94d3e | 0 | public PINUsageModeType getPINUsageMode() {
return pinUsageMode;
} |
dd9b38ff-bf9d-46db-ba57-1c73cbcfb4bb | 7 | @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
cmbProductos = new com.jidesoft.swing.AutoCompletionComboBox();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel()... |
54a8ce35-67a8-4d67-810a-313ec40e7216 | 4 | public void extractConfig(final String resource, final boolean replace) {
final File config = new File(this.getDataFolder(), resource);
if (config.exists() && !replace) return;
this.getLogger().log(Level.FINE, "Extracting configuration file {1} {0} as {2}", new Object[] { resource, CustomPlugin... |
67b6aac1-3202-4d36-8679-1340f975622a | 9 | public void transform(final FlowGraph cfg) {
final File dir = new File("ValueFoldingOutdir");
if (ValueFolding.DUMP) {
// System.out.println(" Dumping Value Folding in directory: " +
// dir);
// try {
// cfgFile = new File(dir, "cfg.txt");
// cfg.print(new PrintWriter(new FileWriter(cfgFile), true... |
43c2373c-55ef-4b38-ae04-c6b190b78ed6 | 2 | private static void printGangupBoard(int[][] board) {
for (int y = 8; y >= 1; y--) {
String stringToPrint= y + " ";
for (int x = 1; x <= 8; x++) {
stringToPrint+= board[x-1][y-1] + " ";
}
GuiMaster.println(stringToPrint);
}
GuiMaster.println("\n" + " 1 2 3 4 5 6 7 8");
} |
9bd72aac-719f-47c9-b0ae-0977f6477b69 | 6 | public String convertColor(Color color)
{
int red = color.getRed();
int green = color.getGreen();
int blue = color.getBlue();
String redRep = binaryConvert(red);
String greenRep = binaryConvert(green);
String blueRep = binaryConvert(blue);
if(redRep.length() < 8)
{
while( redRep... |
16b5b5d5-93c1-4060-8866-943ac74d31ef | 4 | private void dealtDamage(int getX, int getY, int getWidth, int getLength, int getTime, int getDelay, double getDamage, int applyForce)
{
if (character.equals("P1"))
{
if (this.direction)
{
getWorld().addObject(new P1AttackArea(x, y, getWidth, getLength, getTim... |
64c90fc1-517c-44e8-a97c-ed9553a147a2 | 2 | private CHAR_TYPES getCharType(char charToFind) {
if (Character.isLetter(charToFind)) return CHAR_TYPES.LETTER;
else if (Character.isDigit(charToFind)) return CHAR_TYPES.NUMERIC;
else return CHAR_TYPES.SYMBOL;
} |
83db72bf-da74-43d1-9d05-5fb75917703d | 3 | public void BBCHome() {
logger.setLevel (Level.OFF);
WebDriver driver = new HtmlUnitDriver();
driver.get("http://www.bbc.co.uk");
System.out.println(driver.getTitle());
// Create a new instance of the search page class
// and initialise any WebElement fields in it.
... |
ff75566c-e649-4078-bbb8-2b16a48c2907 | 2 | public void start() {
try {
mServer.start();
logger.info("started embedded server" );
} catch (UnrecoverableKeyException e) {
e.printStackTrace();
logger.severe(e.toString());
System.err.println("Did you remember to set the keystore password property?");
} catch (Exception e) {
e.printStackTra... |
0e8f9ff4-b23c-4d3c-88ad-b4f19004345a | 2 | public static void main (String args[]) throws InterruptedException{
System.out.println("Starting");
Thread thread = new Thread(new Runnable(){
@Override
public void run() {
Random r = new Random();
for(int i=0;i<1E6;i++){
if (Thread.currentThread().isInterrupted()){
System.out.prin... |
dfcf372b-96d1-4c26-96a1-e2547f4944b2 | 0 | public void setGodMode(boolean a){
godMode = a;
} |
ddbf3b69-308f-4e29-a513-7ff368549c45 | 9 | public static BufferedImage read(Object img) {
try {
if (img instanceof File)
return ImageIO.read((File) img);
else if (img instanceof URL)
img = ((URL) img).openStream();
if (img instanceof InputStream) {
File tmp = File.createTempFile("demos_img", ".jpg");
FileHelper.write(tmp, (InputStream... |
d8c36f4b-b4f1-4db4-b311-742b30e2015b | 1 | public void createBook(String s) {
String filename = "bible_chinese.txt";
Path file = Paths.get(CBOL_HOME + filename);
Charset charset = Charset.forName("UTF-8");
try (BufferedWriter writer = Files.newBufferedWriter(file, charset)) {
writer.write(s, 0, s.length());
... |
26a5dc1a-78af-49c5-96b7-993e250fbc76 | 9 | @Override
public void createPossibleMoves() {
possibleMoves = new ArrayList<Square>();
//direction boolean is set to false if a piece is blocking the direction
boolean north = true, south = true, west = true, east = true;
for(int i = 1; i < ChessEngine.SQUARE_HEIGHT; i++) {
//if no more squares can be ... |
f7dccddd-f677-43c8-8051-039de169e97f | 4 | public Contact getMostRecentlySeenBucketContact()
{
final Contact[] mostRecentlySeen = new Contact[]{ null };
contacts.traverse(
new Cursor<NodeId, Contact>()
{
public SelectStatus select(Map.Entry<? extends NodeId, ? extends Contact> entry)
{
Co... |
e5da6a1a-d3dd-43bc-9e58-bc06cb517f6d | 3 | public void execute() {
CarWashState s = (CarWashState) state;
double timeBefore = s.getLatestUpdateTime();//Store time before updating to current time
int fastWashes = s.getAvailableFastWashes();
int slowWashes = s.getAvailableSlowWashes();
//Update idle time.
s.setIdleTime(s.getIdleTime() + (priorit... |
d8a18dc3-036a-4fac-b702-f6ba72acf979 | 9 | private void addRoom(String rex, String description, int north, int east, int south,int west){
// Kijken of de array nog plaats heeft voor een kamer
if (getRoomCounter() >= myRooms.length){
System.out.println("You have exceeded the maximum number of allowed rooms. So this one will be skipped");
}
else{
// K... |
b3ffcd4a-13ca-4906-a5a1-fd46f246ba93 | 7 | public static boolean areIdentical(LinkedListNode head1,
LinkedListNode head2)
{
if (head1 == null && head2 == null)
{
return true;
}
if (head1 == null && head2 != null)
{
return false;
}
if (head1 != null && head2 == null)... |
6148ebe2-ec70-4e6d-8f5e-166727a34990 | 8 | public void setSecretAlphabeticCipher(String secretAlphabeticCode) {
secretAlphabeticCode = secretAlphabeticCode.toLowerCase();
StringBuffer sb = new StringBuffer(secretAlphabeticCode);
for (int z=0; z<sb.length(); z++) {
char buchstabe = sb.charAt(z);
for (int i... |
ba501fed-755e-4cdc-855b-ad5f5776307c | 9 | public static void zero(int[][] matrix) {
boolean[] rows = new boolean[matrix.length];
boolean[] cols = new boolean[matrix[0].length];
// store which rows and columns have zeroes
for(int i = 0; i < matrix.length; i++) {
for(int j = 0; j < matrix[0].length; j++) {
... |
73c16887-4965-4b25-b1b4-a223c762f08b | 0 | public Object getParams() {
return params;
} |
92abb7ea-25ba-4d52-83f3-7e828ade8842 | 5 | private static Items binarySearchArray(Items[] items,
String target) {
Items retVal = null;
System.out.println("Binary Searching for " + target + ".");
Items currentItem = new Items();
boolean isFound = false;
int counter = 0;
... |
7723a54b-26f7-4af4-88a6-17b0e9f954a8 | 8 | public void changePersonDetails(Person person, String name, String email, String contactNumber, String address, int accessLevel, String password, String vatNumber, String contactName ){
this.person = person;
this.person.setName(name);
this.person.setEmail(email);
this.person.setAddress(address);
this.person.s... |
694b2045-7539-4f68-ba72-66edc6997116 | 9 | private byte[] decodeRLE8(int imSize, int padding, byte values[]) {
byte val[] = new byte[width * height];
int count = 0, l = 0;
int value;
boolean flag = false;
while (count != imSize) {
value = values[count++] & 0xff;
if (value == 0) {
switch(values[count++] & 0xff) {
case 0:
// End-of-s... |
33fbb464-c67b-44b6-8990-b6ef6cf36e5f | 5 | public void runTests()
throws IOException
{
String inputLine;
while ((inputLine = input.readLine()) != null) {
if (inputLine.trim().length() == 0 ||
inputLine.charAt(0) == '#') {
// echo blank and comment lines
output.println(inputL... |
1ebb4e1e-3ccb-4d3c-8e59-29bc1d16d7e1 | 3 | public void removeMarkers() {
for(int row=0; row<8;row++)
for(int column=0; column<8; column++)
if(isMarker(new Position(row,column)))
board[row][column]=null;
} |
8fdbbd7f-2e10-4168-8752-bea4956e1d94 | 0 | public static void main(String[] args) {
//节点流
Component component = new ConcreteConponent();
//过滤流
Component component1 = new ConcreteDecorator(component);
//过滤流
Component component2 = new ConcreteDecorator1(component1);
component2.dosomething();
//下面的方法和上面的方法实现的功能是一样的。
System.out.println("|... |
9e1a5a3f-8ad0-4c95-9d36-f2e93c1aa788 | 5 | public static int majorityElement(int[] num) {
if (null == num || 0 == num.length) return -1;
int elem = 0;
int nums = 0;
int len = num.length;
for (int i = 0; i < len; i++) {
if (0 == nums) {
elem = num[i];
nums = 1;
} else... |
fc2c8639-c21c-44d8-9a98-d39a5c984afa | 9 | @Test
public void testGetPhoneNumbers() throws InterruptedException{
driver.get(URL);
Thread.sleep(3000);
WebElement phone = driver.findElement(By.id("revPhone:firstField"));
WebElement city = driver.findElement(By.id("revPhone:city"));
WebElement search = driver.findElement(By.id("revPhone:search"));
t... |
e3ee6a49-f4f5-4f7f-bc02-6693d472c7ef | 7 | protected Component getPixelMapsPanel(TaskObserver taskObserver) throws InterruptedException
{
taskObserver.taskProgress("Pixel Maps", 0.1f);
if (Thread.currentThread().isInterrupted())
throw new InterruptedException("getPixelMapsPanel() was interrupted.");
PixelMapDataSource he... |
fb598a83-cf02-46d4-81f5-72c1e5808fe4 | 5 | public synchronized void flushToDisk() {
BufferedOutputStream outstream = null;
try {
outstream = new BufferedOutputStream(new FileOutputStream(userdataFile));
} catch (IOException ex) {
ex.printStackTrace();
System.err.println("Unable to create an outputstrea... |
7b9ab8bd-c3b8-4c53-8126-839a1f1f44f7 | 1 | public String[] copy(String[] board){
String[] newboard = new String[board.length];
for(int i = 0 ; i<board.length ; i++){
newboard[i] = board[i].substring(0);
}
return newboard;
} |
a63ec965-982a-4d2d-9298-406663e6dfbf | 3 | @Override
public double[] get3DData(int px, int py, int pz, int sx, int sy, int sz)
{
double[] da = a.get3DData(px, py, pz, sx, sy, sz);
double[] db;
if (a == b)
db = da;
else
db = b.get3DData(px, py, pz, sx, sy, sz);
int s = sx*sy*sz;
for(int i =... |
66a9d525-b478-4db8-bd41-e378a752fc57 | 8 | public static void changeLiveTuning() {
if(kbPanel == null){
return;
}
if((sineCombo.getSelectedIndex() > 0) || (jKeyStrings.getSelectedIndex() > 0))
try{
kbPanel.setFrequencies(tuningSchemes.getPitchShifts((String)jTunings.getSelectedItem(),2,jNotes.getSelectedIndex(),jTuningAdvancedPanel.getRootNote(),... |
39b14e86-eafc-40fb-8c04-9cbb9184beea | 5 | private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
final Object comparatorInfo = in.readObject();
if (comparatorInfo instanceof Comparator) {
this.childComparator = this.castComparator(comparatorInfo);
}... |
d31b246c-b171-45c0-ad83-b48f127b3dc2 | 6 | public static int solution(String S) {
if (S.isEmpty())
return 1;
// To Count the number of '(' character in String S.
int count = 0;
for (int i = 0; i < S.length(); i++) {
if (S.charAt(i) == '(') {
count++;
} else if (S.charAt(i) == ')') {
if (count > 0)
count--;
else
return 0;
... |
065ea52d-97b2-41a1-a7be-3ccd44ebd8c3 | 7 | private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
try {
if (validarDatos()){
//cargo Parametros del Reporte
Map parametros = new HashMap();
parametros.put("name_empresa", r_con.getRazon_soci... |
8ce049dc-173f-4fd4-9e2e-169d2b91b286 | 2 | public boolean equals(final Object o) {
if (o instanceof ClassEditor) {
final ClassEditor other = (ClassEditor) o;
if (!other.type().equals(this.type())) {
return (false);
}
return (true);
}
return (false);
} |
2913b4a1-213f-4009-bb40-6c5445e9e58c | 3 | @Override
public boolean match(PathInput input) {
String item = input.value();
for (String value : values) {
if (value.equals(item)) {
if (input.isBind()) {
bind(input, item);
}
input.next();
return tru... |
242cd47f-7c9e-4c19-b07c-ea7eb1cf83a0 | 8 | private void deleteKuuntelee() {
koodiTable.addListener(SWT.Selection, new Listener() {
public void handleEvent(final Event event) {
viiteTable.setVisible(true);
viiteTable.dispose();
viiteTable = new Table(shell, SWT.BORDER);... |
0d079986-85f6-4c98-9493-d69295fe6cb5 | 5 | public static void main(String username, String password, String ram) throws IOException {
List<String> args = new ArrayList<String>();
args.add(System.getProperty("java.home") + File.separator + "bin" + File.separator + "java" + (System.getProperty("os.name").toLowerCase().contains("win") ? "w" : ""));
args.add(... |
0f49e9ad-6cff-4c5c-9e27-38e7986c8f72 | 1 | public void visitFormalTypeParameter(final String name) {
declaration.append(seenFormalParameter ? ", " : "<").append(name);
seenFormalParameter = true;
seenInterfaceBound = false;
} |
86ba53c3-595b-4c71-a74c-4bc4a121c7be | 3 | public int getExternalUserIndexByEmailAndMeetingID(int meetingID, String email){
for(ExternalUser externalUser : externalUsers){
if(meetingID == externalUser.getMeetingID() && email.equals(externalUser.getEmail())) return externalUsers.indexOf(externalUser);
}
return -1;
} |
c17b13bd-230e-4053-ae26-a374126be91b | 9 | public static List<Location> circle (Location loc, Integer r, Integer h, Boolean hollow, Boolean sphere, int plus_y) {
List<Location> circleblocks = new ArrayList<Location>();
int cx = loc.getBlockX();
int cy = loc.getBlockY();
int cz = loc.getBlockZ();
for (int x = cx - r; x <= ... |
739c9947-0b78-415f-b4d8-ee621ece88eb | 5 | @Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Hospital)) {
return false;
}
Hospital other = (Hospital) object;
if ((this.idHospital == null && other.idHospit... |
ed7c2518-259d-4b47-a654-a4ae878b9a64 | 9 | private void menueTwo() {
boolean finished = false;
while (!finished) {
Operation op = communicator.opperation();
PolynomTuple tuple = null;
switch (op) {
case LEAVE_SUBMENU:
// back to main menü
finished = true;
break;
case INPUT_POLY:
Polynom inputPoly = communicator.polyInp... |
3f968db3-3c89-4b6b-bf7b-9e8e0928eedc | 7 | protected List<JavaFileObject> listClassesFromUrl(URL base, String packageName) throws IOException {
//TODO this will only work with file:// not jar://
if (base == null) {
throw new NullPointerException("base == null");
}
List<JavaFileObject> list = new ArrayList<JavaFileOb... |
7240f428-1229-404f-862c-fe8e943c7fe2 | 1 | public LabeledParameterized(Class<?> cl) throws Throwable {
super(cl);
initialiseLabels();
generateLabelledDescription();
} |
e1a5ab6d-349d-4745-9232-a8f84ed72703 | 4 | private boolean checkForLockedDoor(){
for(GameMatter itm : getArea().getItems()){
if(itm.getFace()==getFace()
&&itm instanceof Door){
if(((Door)itm).isLocked()){
//System.out.println("Door is locked");
JOptionPane.showMessageDialog(
null,
"This door is locked, try find the right ke... |
ecaf1ee8-1474-442e-bb19-68838ab6b0c3 | 8 | public void checkforclicked() {
MouseInfo mouse = Greenfoot.getMouseInfo();
if(mouse != null){
mx = mouse.getX();
my = mouse.getY();
}
if(mx >= 84 && mx <= 716 && my >= 242 && my <= 358) { //Greenfoot.getMouseInfo().getX() // alternativ
... |
b2880005-400f-4ce1-9099-7cf769bada10 | 1 | public boolean equals(Object o)
{
boolean equals = false;
if (o instanceof OutputChannels)
{
OutputChannels oc = (OutputChannels)o;
equals = (oc.outputChannels == outputChannels);
}
return equals;
} |
ffd4cee5-82f5-4a29-90cd-69eb6b4abad2 | 0 | @Before("execution(* com.laudandjolynn.springtest.springtechmanual.aop.IHello.hello(*)) && args(name)")
public void before2(JoinPoint joinPoint, String name) {
log.debug("喲喲," + name);
} |
0b8d5bcf-7ba7-4ca9-aef3-ccf35d17b4d0 | 9 | protected void computeRect(Raster[] sources,
WritableRaster dest,
Rectangle destRect) {
int formatTag = MediaLibAccessor.findCompatibleTag(sources, dest);
MediaLibAccessor srcMA =
new MediaLibAccessor(sources[0], destRect, format... |
2f8f78cc-8404-422a-b8b3-d39e953f3f84 | 2 | public Location get(final int portal){
if(portal == 1) return this.one;
else if(portal == 2) return this.two;
else throw new IllegalArgumentException("Portal number must be 1 or 2");
} |
0462edba-6bae-4f84-a10c-f258668e1682 | 6 | public void onDragRotate(int currX, int currY) {
int diffX = currX - startDragMouseLocX;
int diffY = -(currY - startDragMouseLocY);
switch (rotateMode) {
case DUAL_AXIS_ROTATE:
... |
b7f416d2-9ab0-44b0-a4b4-b8574c3cef1d | 2 | public void setOut(int i, boolean aBoolean) {
for (int j = 0; j < components.getLength(); j++) {
Componente component = components.get(j);
if (component.equals(i)) {
component.changeDigitalValue(aBoolean);
break;
}
}
repaint();... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.