method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
30077e92-4e8d-42b1-b2ff-71bf23fa4886 | 1 | public SearchEngineStep(ChessGameConfiguration cgc, List<? extends Piece> availablePieces){
this.cgconfig = cgc;
this.availablePieces = availablePieces;
} |
79029a12-a107-4ddc-bd10-07f1861955ae | 8 | private FileMenu()
{
super("File");
setMnemonic(KeyEvent.VK_F);
add(new JMenu("New") {
{
setMnemonic(KeyEvent.VK_N);
add(new SeedMenuItem());
add(new FileMenuItem());
add(new Rand... |
1a7e44d9-26ed-4786-a350-e70cf233baa7 | 3 | @Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((length == null) ? 0 : length.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
} |
4557cd11-76aa-46a7-8750-21c16b8b4ffb | 4 | private boolean isPrime(long pNumber){
boolean check = false;
long n = pNumber;
for (int i = 0; primes.get(i) <= n/2; i++) {
if(i > Math.sqrt(n)){
break;
}
while (n % primes.get(i) == 0) {
n /= primes.get(i);
break;
}
}
if(pNumber == n){
check = true;
}
return check;
} |
99212e82-b7ee-4f89-be4e-0805e1ebad24 | 3 | public static Dir parse(HtmlElement element, String str){
switch(str){
case "ltr":
return LTR;
case "rtl":
return RTL;
case "AUTO":
default:
return AUTO;
}
} |
3399fd28-72b5-415c-b187-9af41d470b2c | 9 | public static void main(String args[]) {
//output header
System.out.println("Day \tDaily \tSales Graph");
//intialize days
int days = 0;
//create week loop
for (int week = 0; week < 5; week++) {
//create day loop
for (int day = 1; day < 8 && days < 31; day++) {
//increment days
days++;
//a... |
c9a0db7a-13c6-4c2b-bba7-018096c2badc | 7 | 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 feel.
* For details see http://down... |
879a1867-c505-4b55-bad8-5ce0eba0f846 | 3 | public JMenuBar getGameMenuBar() {
// spiel
JMenu menuFile = new JMenu("Spiel");
JMenuItem itmNew = new JMenuItem("Neues Spiel starten");
JMenuItem itmReload = new JMenuItem("Level neu starten");
JMenuItem itmSave = new JMenuItem("Spiel speichern");
JMenuItem itmLoad = new JMenuItem("Spiel laden");
JMenu... |
fbe11df2-d805-46c5-ba5c-b2c7cbdb1110 | 9 | private int getPriority(int number) {
if (number >= 0 && number <= 5) {
return 1;
}
if (number >= 6 && number <= 9) {
return 2;
}
if (number >= 10 && number <= 12) {
return 3;
}
if (number >= 13 && number <= 14) {
... |
47519586-a246-433a-9fc7-585ca789e589 | 1 | private ArrayList<String> castSendEverything(){
ArrayList<String> res = new ArrayList();
res.add(this.identifier);
for(Argument arg : this.arrayarg){
res.add(arg.getId());
res.add(arg.getType());
}
res.add(this.methodtype.getIdentifier());
return res;
} |
2ac92949-bcf5-468e-b6ef-0beef6063914 | 0 | private void baz() {
} |
58c6fbef-780e-4d6b-8182-c556aee5f185 | 1 | @Override
public void draw() {
super.draw();
Text.drawString(flash > 0.5f ? text + CARET : text, getBounds().getX(), getBounds().getY(), getTextModifier());
} |
b6477b5d-dbcc-43dd-9f08-5b4f4babc0dd | 1 | @Override
public void call(ExecutionError error, StatefulContext context) {
String msg = "Execution Error in StateHolder [" + error.getState() + "] ";
if (error.getEvent() != null) {
msg += "on EventHolder [" + error.getEvent() + "] ";
}
msg += "wi... |
fd3534fd-e216-47c1-96c3-f09a472f2f85 | 1 | public static void maxminBonus(Manager[] a, Pair<? super Manager> result)
{
minmaxBonus(a, result);
PairAlg.swapHelper(result); // OK--swapHelper captures wildcard type
} |
57d642e0-01aa-41de-9853-861d90d8e444 | 7 | protected List<I3Mud> getSortedI3Muds()
{
Vector<I3Mud> list = new Vector<I3Mud>();
if(!i3online())
return list;
final MudList mudList=Intermud.getAllMudsList();
if(mudList!=null)
{
for(final I3Mud m : mudList.getMuds().values())
{
if(m.state<0)
{
boolean done=false;
for(int v=0;v<... |
664fc7fc-8248-47e0-b006-dffb1f5e5a56 | 1 | @Override
public double getObjectiveValue() {
if (objectiveValue != null) return objectiveValue;
else calculateObjectiveValue();
return objectiveValue;
} |
4953aca9-3bae-4742-b952-21d8d7f87af7 | 0 | public Historialclinico getHistorialClinicoidHistorialClinico() {
return historialClinicoidHistorialClinico;
} |
bf28f8c0-d952-4f1b-bed8-a453abd3a1f9 | 8 | public static String getBasePath() {
String userName = System.getProperty("user.name");
String s = System.getProperty("file.separator");
String osName = System.getProperty("os.name");
String basePath;
if (osName.equalsIgnoreCase("windows 7")) {
basePath = "C:" + s + ... |
188afe9d-9b65-44c4-8ea6-adbb19cc8cd4 | 1 | private List listChildren(Expr expr) {
final List children = new ArrayList();
if (expr instanceof StoreExpr) {
expr = ((StoreExpr) expr).target();
}
expr.visitChildren(new TreeVisitor() {
public void visitStoreExpr(final StoreExpr expr) {
// Ignore the RHS.
children.add(expr.target());
... |
588bc724-7683-4b99-87f6-dfd984582a1c | 6 | public void decrypt(){
if(c!=null && c.size()>0){
List<BigInteger> plainblocks = new ArrayList<BigInteger>();
for(ElGamal_ciphertextblock b: c){
// -------------------------
// -- Hier programmieren ---
// -------------------------
plainblocks.add(b.c_2.multiply(b.c_1.modPow(this.k_d.negate(), t... |
0e723c05-77df-4f8e-bfd9-40208cfe3853 | 1 | @Override
public synchronized void up()
{
super.up();
if (bulbPower < images.size())
{
bulbPower++;
}
sendImageToGUI();
} |
e792fcef-183c-40e9-b8f8-6dc9d3d11f44 | 5 | public ArrayList<DuplicateMusicObject> executeSQLDuplicates(String sql, String keyColumn,String duplicateTitle) throws SQLException {
HashMap<String,DuplicateMusicObject> retVal = new HashMap<String,DuplicateMusicObject>();
Statement stmt = null;
ResultSet rs = null;
try {
if (connection == null... |
4f334390-6ed0-4470-84da-c56adcf5fa13 | 1 | public void unregister(String name) throws IOException {
if (name == null) {
return;
}
Network handler = clients.remove(name);
broadcast(new Message("", name + " disconnected."));
System.out.println(name + " disconnected.");
} |
e904bf59-295c-4256-9f34-54d45ed8c625 | 9 | static String evaluate(PageContext pageContext, String body) throws JspException {
Matcher matcher = TOKEN_PATTERN.matcher(body);
StringBuffer result = new StringBuffer();
// Find any tokens that need to be replaced
while (matcher.find()) {
String[] parts = matcher.group(2).... |
495db961-aa2d-4388-b150-99c2adadb7c5 | 9 | public boolean isPalindrome() {
if (_root == null) {
return false;
}
if (_root.Next == null || (_root.Next.Next == null && _root.Data == _root.Next.Data)) {
return true;
}
final Stack<T> stack = new Stack<T>();
Node<T> by1Runner = _root;
Node<T> by2Runner = ... |
785920fb-d675-4274-8767-e512ea539f87 | 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 feel.
* For details see http://down... |
cca91e8b-a579-47f4-aaf3-81ca1225a497 | 1 | public SeatChart clone()
{
SeatChart cloneChart = new SeatChart(this.seat.length);
for(int index =0; index < this.seat.length ; index++)
{
cloneChart.seat[index] = this.seat[index];
}
return cloneChart;
} |
bcca1003-5c8e-415c-9dcd-161ca4e098c5 | 1 | public boolean type(char key, java.awt.event.KeyEvent ev) {
if(key == 27) {
wdgmsg(fbtn, "click");
return(true);
}
return(super.type(key, ev));
} |
0c93dc99-9091-44c9-a55c-7bae525abcbd | 8 | public String getToken() {
cadtmp = "";
for (int x = this.getBegin(); x < this.getCad().length(); x++) {
chartmp = this.getCad().charAt(x);
this.setBegin(x);
if (chartmp != ' ') {
if (Pattern.matches(this.getMatchValue(), chartmp + "")) {
... |
8ce5db82-9f6e-402c-a61c-7a7e331d42c9 | 3 | public static void main(String[] args) {
JFrame frame = new JFrame("BuilderDemo - " + args[0]);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
String[][] matrix = read_data_file("BuilderDemo.dat");
if (args[0].equals("JTable_Table")) {
frame.getContentPane().add(new JT... |
624c087d-05d2-4a13-9a82-d7d0c6f2ff97 | 6 | @EventHandler
public void SpiderStrength(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.getSpiderConfig().getDouble("Spider.Streng... |
ec323960-f423-4fd5-8559-ba2f51b046e1 | 2 | private static boolean isValidTotalSeats(Integer totalSeats) {
return totalSeats != null && totalSeats >= TOTALSEATS_MIN && totalSeats <= TOTALSEATS_MAX;
} |
89cc2db1-cfc4-4648-9d35-00337ddc0ee9 | 0 | public String getDescription() {
return this.description;
} |
af3958eb-4c3d-4b12-b3a0-b938d91cf731 | 6 | private void calculateTokenProbabilities(){
BufferedReader input;
try{
input = new BufferedReader(new FileReader("training.txt"));
String line = input.readLine();
String[] toks = line.split("\\s");
nbad = Integer.parseInt(toks[0]);
//System.out.println("nbad=" + nbad);
ngood = Integer.... |
f7b29ce6-99c2-4014-ad4c-6842a834c286 | 9 | public void EnterBuilding(PersonAgent person, String roleRequest)
{
System.out.println(person.getName() + ": Entering RestaurantBK as " + roleRequest);
if(roleRequest.equals("Customer"))
{
restPanel.addCustomer(person);
}
else if(roleRequest.equals("Waiter"))
{
restPanel.addWaiter(person);
}
else... |
1481ab1b-1c93-409a-8dc6-1d087e3884b2 | 2 | public BudgetBreakdown processTotalMoneyAvailableCalculation(BudgetBreakdown breakdown, BigDecimal salary,
BigDecimal totalAllItems) {
BigDecimal totalMoneyAvail = new BigDecimal(BigInteger.ZERO);
BigDecimal totalMoneyAvailPerWeek = new B... |
3a6e8916-c3a5-4f43-a66d-e507accd9773 | 0 | @Override
public void startSetup(Attributes atts) {
super.startSetup(atts);
addActionListener(this);
} |
97962fa4-a5e4-4ece-870d-db50e375668d | 1 | private InputStream getFileReader(File file) {
InputStream fileReader = null;
try {
fileReader = new FileInputStream(file);
this.log.fine("Create new FileInputStream: " + fileReader.toString());
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
fileReader... |
e5baa05f-1e06-46a2-bce2-1b953ee86294 | 4 | private void mutate(){
for(int i = 0; i < position.length; i++){
for(int k = 0; k < position[i].length; k++){
if(Math.random() < mutationProbability){
if(position[i][k] < 1){
position[i][k] = 1;
}else{
position[i][k] = 0;
}
}
}
}
} |
a64123c6-73d7-43e3-a98c-ddf515d7c9db | 6 | @EventHandler
public void onPlayerMove(PlayerMoveEvent ev){
Player player = ev.getPlayer();
for (KotHMatch match : plugin.getRunningMatches()){
boolean contains = match.getPlayers().contains(player);
if (KotHPlayerListener.ignoreYaxis){
if (match.getRegion().isWithinRegionIgnoreY(player.getLocation()) & ... |
c4bd2486-70a0-4cf1-a4e6-2f8dd919f550 | 6 | @Override
@SuppressWarnings("unchecked")
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Node<T,E> other = (Node<T,E>) obj;
if (value == null) {
if (other.value != null)
return false;
} else if... |
de334246-3cee-4cfb-bb2b-75f813d50525 | 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 Class)) {
return false;
}
Class other = (Class) object;
if ((this.id == null && other.id != null) || (this.id !... |
18658294-8d3d-4489-90b6-86d8088ee890 | 7 | private Color getColor(int id){
switch(id){
case 1: return Color.blue;
case 2: return Color.yellow;
case 3: return Color.green;
case 4: return Color.orange;
case 5: return Color.black;
case 6: return Color.white;
case 7: return Color.CYAN;
default: return Color.magenta;
}
} |
adc5a4a2-7633-45b9-a311-73ede7fba59b | 0 | private void Reset(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Reset
programmerThread.stop();
world.worldDeleter();
world.initWorld();
lastPane = programmerFrame;
hidePanels(lastPane);
//paint
this.repaint();
}//GEN-LAST:event_Reset |
484924f8-d625-4d4e-a1f9-017b7e56e39d | 0 | public Paciente getPaciente() {
return paciente;
} |
073184b3-28a1-4841-bd4d-1cc04c6aceb5 | 8 | public int fGetColumnIndex (String strXLS, String strSheetName, String strColumnName)
{
try
{
//Create the FileInputStream obhect
FileInputStream file = new FileInputStream(new File(strXLS));
//Get the workbook instance for XLS file
HSSFWorkbook workbook = new HSSFWorkbook(file);
... |
9e27b809-7d7e-4cec-8104-bf250df77cd9 | 1 | @Override
public void close() throws XMLStreamException {
if (mReader != null) {
try {
mReader.close();
} finally {
mReader = null;
}
}
} |
7e89e31d-1eda-47c8-9588-47643935bd5d | 9 | public void playerTick()
{
while (action > 0)
{
if (queue != null)
{
//System.out.println(queue);
queueTurns--;
if (queueTurns <= 0)
{
if (queue.equals("Road"))
location.road = true;
else
{
location.grid.addUnit(EntityData.get(queue), owner, location.row, location.c... |
a493042e-2df3-40da-a0bd-c17743fe669d | 4 | private void displayInfo(Character ch){
Map<String, Integer> main = ch.getMainAttrs(), attrs = ch.getAttrs();
Map<String, Attribute> sec = ch.getSecondaryAttrs();
StringBuilder builder = new StringBuilder(ch.getName()).append("\n||Atributos principales||\n");
builder.append(displayMapInf... |
2933724f-3f30-4c08-b285-5761c8dd5276 | 6 | @Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
String action = request.getParameter("act");
if(action != null) {
try {
RequestContext context = new RequestContext(request);
if(context.isLogged(... |
a728fe44-2ac3-47ab-9b59-66cfbc67c78c | 7 | @Override
public void utiliser(Session session,
ReservationDTO reservationDTO) throws InvalidHibernateSessionException,
InvalidDTOException,
InvalidCriterionException,
InvalidCriterionValueException,
InvalidSortByPropertyException,
ServiceException {
if(sessio... |
a49ee4b3-95f5-4832-b190-4902281c9696 | 1 | public void skipWhiteSpace() {
while (Character.isWhitespace(buf[idx])) {
idx++;
}
} |
c75b0931-ba7d-4251-8318-2925970efc27 | 3 | private boolean merkkiOsaLukua() {
if (!paikkaSisaltyySyotteeseen()) {
return false;
}
if (paikkaSisaltaaNumeron()) {
return true;
}
if (paikkaSisaltaaDesimaalipisteen()) {
return kasitteleDesimaalipiste();
}
... |
b9f776cb-3f45-41fd-bd58-d5b33e29941f | 6 | public void put(int searchID, String value){
if(value == null || value.equals("")) throw new IllegalArgumentException("Illegal value: " + value);
if(searchID == 0) throw new IllegalArgumentException("Illegal searchID: " + searchID);
try {
this.stmt = this.conn.prepareStatement("INSERT INTO api_results (k, v... |
3c6381cb-5ca4-425c-9f85-888e9da3c417 | 2 | private void expand4(byte[] src, byte[] dst) {
for(int i=1,n=dst.length ; i<n ; i+=2) {
int val = src[1 + (i >> 1)] & 255;
switch(n-i) {
default: dst[i+1] = (byte)(val & 15);
case 1: dst[i ] = (byte)(val >> 4);
}
}
} |
d5b3f44b-60ca-4649-a391-1795c533d86c | 5 | public void open(){
if (isOpen)
return;
if (bombsBeingRevealed && getValue() != 9){
return;
}
if (markIndex > 0){
return;
}
if (!hasStarted)
MainFrame.startTimer();
getModel().setPressed(true);
getModel().setEnabled(false);
isOpen = true;
chooseIcon(true);
//System.out.println("(" + xP... |
5a08f8ed-20b7-488a-9d68-0e9b1c124601 | 2 | public void setWidget(QWidget widget)
{
QWidget w = currentWidget();
if (w != null) {
removeWidget(w);
w.dispose();
}
if (widget != null) {
addWidget(widget);
}
} |
fe91ec23-c605-4102-8f89-0260e78bc307 | 1 | @Test
public void isDeserializedCorrectly() throws IOException {
UnsubscribeMessage msg = new UnsubscribeMessage("topic/1");
msg.addTopic("topic/2");
msg.addTopic("topic/3");
byte[] data = msg.toBytes();
MessageInputStream in = new MessageInputStream(
new ByteArrayInputStream(data));
UnsubscribeMessage... |
0309d2ac-ad96-4b2f-b682-ae01bf7eb8d8 | 2 | @Override
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
switch (request.getPathInfo()) {
case Pages.AUTH_PAGE:
doAuthenticate(request, response);
break;
case P... |
1427990b-6dda-4503-8224-a8db8b6d98aa | 2 | public void displayGameState() {
System.out.println("*************** Current Game State *****************");
for (int i = 0; i < getBoardSize(); i++) {
for (int j = 0; j < getBoardSize(); j++) {
System.out.print(boardArray[i][j] + " ");
}
System.out.pr... |
e5567eaf-d5d8-4707-a369-e19cfc135c51 | 8 | public boolean maintainBounderies(float pf_width, float pf_height, Ball ball) {
boolean paddleStuck = false;
/*Check if the paddle or a ball resting on paddle is outside the playing field's bounderies and move the paddle inside if that is the case*/
/*Check against the x bounderies*/
if((ball.x - ball.... |
dae06d22-91e7-460b-b4f0-ad698bc15c24 | 4 | public void stageBounds(final Sprite sprite, final Scene scene) {
double _x = sprite.getX();
double _width = sprite.getWidth();
double _plus = (_x + _width);
double _width_1 = scene.getWidth();
double _minus = (_width_1 - this.stageBoundary);
boolean _greaterThan = (_plus > _minus);
if (_gre... |
4025a80a-69be-4baf-99b2-258b2f21ec0f | 7 | private String decryptAndProcessServerResponse(String responseHexData) {
try {
String hexDataBody = parseHeadAndReturnDataBody(responseHexData);
int encryptionScheme = getEncyptionSchemeFromResponse(responseHexData);
String decryptedData = null;
if(encryptionScheme == 4 && hexDataBody != null ){
decryp... |
e496dc7d-5022-4445-9e6d-44a781aabc1f | 6 | public static int[] HSBtoRGB(float hue, float saturation, float brightness)
{
if (saturation == 0)
return convert(brightness, brightness, brightness, 0);
hue = hue - (float) Math.floor(hue);
int i = (int) (6 * hue);
float f = 6 * hue - i;
float p = brightness * (1 - saturation);
float q = brightness * (1 - sat... |
d10a5b6b-517b-445d-a7cd-e23668ce41e0 | 1 | public void leaveMatch(String userName){
setStatusToIdle(userName);
deletePlayerFromMarker(userName);
deletePlayerFromTeam(userName);
try {
cs = con.prepareCall("{call SET_MATCHID_TO_ZERO(?)}");
cs.setString(1, userName);
cs.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
} |
62525563-9ca2-46d6-8db3-4f666e29d7cc | 5 | public Item getItem(long id) {
Item item = null;
Connection con = null;
Statement stmt = null;
try {
DBconnection dbCon = new DBconnection();
Class.forName(dbCon.getJDBC_DRIVER());
con = DriverManager.getConnection(dbCon.getDATABASE_URL(),
... |
0499ae13-ca7e-4360-88c2-eba3cb55bf95 | 1 | private static void generateHeader(Sheet s){
Row r = s.createRow(0);
String[] headers = ProcessedCell.getTags();
Cell c = null;
for(int i = 0; i < headers.length; i++){
c = r.createCell(i);
c.setCellValue(headers[i]);
}
} |
ba376976-6462-48b0-aebe-712d23da611d | 5 | private ArrayList<Tuple> countParse(ParseTree tree, int depth) {
ArrayList<Tuple> counts = new ArrayList<Tuple>();
if (tree.childIsTerminal()) {
String pos = getPOS(tree.getLabel());
Tuple tup = new Tuple(pos, tree.getLabel(), 1);
counts.add(tup);
return ... |
c2db09e5-ddbc-4d01-9bd5-dea006e0e74c | 0 | public boolean equals(Object obj) {
Product product = (Product) obj;
return this.getCode().equals(product.getCode());
} |
187d1d79-1de5-4ee1-8f8b-d54258e1e3c2 | 3 | public PhraseType getType(int termNum) {
String pos = posTags.get(termNum);
if (pos.startsWith("NN") || pos.startsWith("JJ")) return PhraseType.NOUN;
else if (Pattern.matches("\\p{Punct}", this.terms.get(termNum))) return PhraseType.PUNCTUATION;
return PhraseType.OTHER;
} |
a045c393-c11a-4099-baa4-49b225583473 | 3 | private void initImages() {
for (int i = 0; ; i = (i == 0 ? 2 : i * 2)) {
String name = Integer.toString(i) + ".png";
try {
BufferedImage image = ImageIO.read(new File(name));
numbers.add(i);
images.add(image);
} catch (Exceptio... |
68ab5c66-f263-41d3-ac62-4d26b4b2cfe2 | 4 | public List<MapperRealJvmCost> readRealMapperJvmCost(String dir, int splitSizeMB) {
List<MapperRealJvmCost> list = new ArrayList<MapperRealJvmCost>();
File input = new File(dir);
try {
BufferedReader reader = new BufferedReader(new FileReader(input));
String[] title = reader.readLine().split("\t");
St... |
05f474a5-6ad6-45cd-8b86-6022e32650ce | 2 | public void calculate(){
sheet = new OpenGLTexture[sheet_width][sheet_height];
float sprite_width = 1/(float)sheet_width;
float sprite_height = 1/(float)sheet_height;
for(int x = 0; x < sheet_width; x++){
for(int y = 0; y < sheet_height; y++){
float xPos = x... |
d0c4007b-55c1-4d6a-b7f5-4a895e353a4b | 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 feel.
* For details see http://down... |
29a4203b-8d6f-4292-81a7-c4070e16d409 | 9 | private boolean r_combo_suffix() {
int among_var;
int v_1;
// test, line 91
v_1 = limit - cursor;
// (, line 91
// [, line 92
ket = cursor;
// substring, line 92
... |
0ed2b79f-fda7-4bae-98b7-b9c0d75e298f | 7 | * @param path The path to follow.
* @return True if the unit has completed the path and can move further.
*/
private boolean followPath(Unit unit, PathNode path) {
// Traverse the path to the destination.
for (; path != null; path = path.next) {
if (path.getLocation() == unit.g... |
972daf0b-7479-41b6-b1f9-41ebb115a19f | 5 | public String strStr(String haystack, String needle) {
if (needle.isEmpty())
return haystack;
if (haystack.isEmpty())
return null;
int m = 0; // the beginning of the current match in haystack
int i = 0; // the position of the current character in needle
int[] T = kmpTable(needle);
while (m + i < hay... |
fafe5f31-5062-413a-ba2c-9ba9c3dfba07 | 4 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof TestUser_1)) return false;
TestUser_1 that = (TestUser_1) o;
if (years != that.years) return false;
if (!name.equals(that.name)) return false;
return false;
} |
45c986f9-bf2c-409c-8ad0-c6b8a9c3a26f | 4 | private Position calculatePosition(int number) {
switch (number) {
case 0:
return new Position(position.getX() + 1, position.getY());
case 1:
return new Position(position.getX(), position.getY() + 1);
case 2:
return new Position... |
346da5f5-f761-43a8-9a91-c6a5842476fb | 8 | public boolean putContent(String url, String file) throws MalformedURLException {
URL u = createURL(url);
URLConnection connection = createConnection(u);
if(connection == null) return false;
InputStream in;
try {
in = connection.getInputStream();
} catch (I... |
245e28f4-02b3-4bc2-841b-fc0ecd23ea3e | 5 | private ExtDecimal factorial() {
if (type == Type.NUMBER) {
if (compareTo(ONE) != 1) {
return ONE;
} else {
return multiply(dec().factorial());
}
} else if (type == Type.POSITIVEZERO) {
return ONE;
} else if (type ==... |
69480a22-b5f6-4221-9d7d-319e31eec9c8 | 0 | @Test
public void testSetResting() throws IOException {
System.out.println("setResting");
int resting = 5;
AntBrain ab = new AntBrain("cleverbrain1.brain");
Ant instance = new Ant(ab,true,0);
instance.setResting(resting);
int result = instance.getResting();
... |
62a7e6f3-becd-4c09-801c-fc60b3f18f96 | 4 | private void checkHit(int aoe)
{
Enemy e = (Enemy) getOneIntersectingObject(Enemy.class);
if (e!= null)
{
if (debuffList != null ){
for (int i = 0; i < this.debuffList.length; i++){
e.addDebuff(debuffList[i], 1, elementId, power);
... |
9b50b01b-614f-4c89-91fb-a5295b8597bb | 8 | private Hex makeHex(int i, int j)
{
// System.out.printf( "makeHex( %d, %d)%s", i, j, Const.CRLF);
Hex newHex;
// int u,v; // Actual hex coordinates, in H2-space.
// u = i - j/2;
// v = j;
Point2D.Double v0, v1, v2, v3, v4;
Edge e0, e1, e2, e3;
v0 = new Point2D.Dou... |
1e2379a1-c403-4ef0-b934-5cde2c35d372 | 9 | public void friends() {
HttpURLConnection conn = null;
URL url;
try {
url = new URL("http://restletlab.appspot.com/users");
// url = new URL("http://localhost:8888/users");
conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("GET");
conn.s... |
6d4a344f-20d8-4c86-9af1-5f1e49d1f40c | 3 | public boolean verifyIntegrity(){
MessageDigest digest;
try {
digest = MessageDigest.getInstance("MD5");
if( Arrays.equals( digest.digest((username+message).getBytes("UTF-8")), messageDigest) ){
return true;
}
} catch (NoSuchAlgorithmException e1){
e1.printStackTrace();
}
catch(Unsupport... |
572ae7fc-a0f6-4cba-aae1-e40f40b470d6 | 9 | @Override
public void executeMsg(Environmental host, CMMsg msg)
{
super.executeMsg(host,msg);
if((msg.target()==affected)
&&(affected instanceof Room)
&&((msg.targetMinor()==CMMsg.TYP_LOOK)||(msg.targetMinor()==CMMsg.TYP_EXAMINE))
&&((CMLib.flags().canSeeHidden(msg.source()))||(msg.source().Name().equals(te... |
8e148ae8-0591-46ef-acae-280a02a40519 | 6 | public static void main(String args[]){
Scanner input = new Scanner(System.in);
System.out.print("Enter First Edge Length: ");
int firstEdge = input.nextInt();
if (firstEdge > 0)
{
System.out.print("Enter Second Edge Length: ");
int secondEdge = input.n... |
296061b1-ee1e-4cf1-8f8d-2f38255c5365 | 3 | public final byte[] data ()
{
if (data == null && type == type_lmsg) {
if (buf.arrayOffset () == 0)
data = buf.array();
else {
data = new byte [size];
System.arraycopy (buf.array (), buf.arrayOffset (), data, 0, size);
}
... |
ad19e095-211e-4e6c-9f82-7e2697aadc1f | 9 | @Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == tfBtn) {
editTf();
} else if (e.getSource() == cancelBtn) {
ok = false;
setVisible(false);
} else if (e.getSource() == paramBtn) {
ParameterManager pm = new ParameterManager(params);
pm.setVisible(true);
params = pm.get... |
67c68e3c-d05c-48de-99e1-6cefd2873b16 | 1 | @Test
public void testReserveInvalidUserId()
{ int x;
try {
assertEquals(new Book().Reserve(56342, 123), 0);
} catch (IOException e) {
System.out.println("Invalid data");
}
} |
263b0a3f-2186-4352-ba82-29af3c387c96 | 2 | @Override
@SuppressWarnings("InfiniteLoopStatement")
public void run() {
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
messageSystem.execForAbonent(this);
}
} |
2e103921-d67f-4a94-a3c9-91d9d666c9e3 | 6 | @Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
try {
this.commands.execute(cmd.getName(), args, sender, sender);
} catch (CommandPermissionsException e) {
sender.sendMessage(ChatColor.RED + "You don't have permission.");
} catch (MissingNestedCommandExc... |
c374d002-e44a-4323-aac0-ad9d56741ca7 | 1 | @Test
public void multiply_test() {
try{
double [][]mat1= {{1.0,2.0}, {3.0,1.0}};
double []mat2= {2,1};
double[]result = Matrix.mult(mat1, mat2);
double exp[]={4.0,7.0};
Assert.assertArrayEquals(exp, result, 0.0);
}
catch (Exception e) {
// TODO Auto-generated catch block
fail("Not yet imple... |
ecab89d0-fb81-4b56-a19d-125e32388797 | 6 | public List<List<String>> split(List<String> strings) {
List<List<String>> result = new ArrayList<List<String>>();
List<String> chunk;
chunk = new ArrayList<String>();
for (String string : strings) {
if (string.matches(splitter_pattern)) {
if (!chunk.isEmpty()) {
result.add(chunk... |
7e49116c-2db9-4fc9-a4d3-d120f18c8c4b | 6 | private void runRaid(RaidSettings raidSettings) throws CantRunRaidException {
Raid raid = new Raid(raidSettings);
raid.run();
this.messagesToDisplay.addAll(raid.getMessagesToDisplayOnceRaidIsOver());
List<Survivor> deadSurvivors = raid.getSurvivorsHurtDuringRaid();
// Removing dead survivors from the... |
08feabb3-20f1-4573-93ad-edb6b89222fe | 4 | private NBTTag getTag(NBTCompound tag, String name, Class<?> type)
{
for(int a = 0; a < tag.tagList.size(); a++)
{
NBTTag t = tag.tagList.get(a);
if(t.name.equals(name))
{
if(t.getClass().equals(type))
{
return tag.tagList.get(a);
}
}
}
return null;
} |
86670144-c077-4396-99cc-ded1b3e98e2a | 1 | public Material GetMaterial(String name) {
Material mat = Material.matchMaterial(name);
if (mat != null) {
return mat;
}
return null;
} |
5c5f1010-09e6-4713-be38-6d2535dcb1ef | 5 | public boolean pressFloorButton(int floor) {
Lib.assertTrue(inElevator && floor >= 0 && floor < numFloors);
if (elevators[elevator].doorsOpen &&
elevators[elevator].floor == floor)
return false;
manager.postEvent(ElevatorEvent.eventFloorButtonPressed,
floor, elevator, true);
if ... |
93e58fc6-c4da-4ade-a317-d3f973672c3e | 9 | private void initSectorVals(int GS) {
//
// Set up the requisite data stores first-
final Vec3D seedVals[][] = new Vec3D[GS][GS] ;
final int seedSize = (mapSize / DETAIL_RESOLUTION) + 1 ;
final HeightMap sectorMap = new HeightMap(seedSize) ;
final float heightVals[][] = sectorMap.value() ;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.