method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
0629db93-613c-4fec-b356-2e315768808c | 1 | public static void main(String args[]) {
initialize();
while (true) {
// resets the board to the screen
Interperet.reset();
// moves the best move
Calculate.move(Calculate.bestMove());
}
} |
a9332a89-82ba-4b3a-89ee-1ca780ac6ca5 | 5 | protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
RequestDispatcher dispatcher = null;
try {
// get the action class to be called
// to do this, we grab the URL and take the ".action" off of it
String servletpath = request.g... |
e14035e5-04e9-4692-aa6b-2125d8eb1481 | 4 | public static String getSqlWhereWithValues(Map<String, Object> sqlWhereMap) throws SQLException {
if (sqlWhereMap.size() < 1)
return null;
StringBuffer sqlWhere = new StringBuffer();//SQL语句
Set<Entry<String, Object>> entrySets = sqlWhereMap.entrySet();
for (Iterator<Entry<String, Object>> iteraotr = entry... |
a9e113d8-ad72-4c30-93c3-2028f053378a | 2 | public void run() {
if (progressBar != null) {
progressBar.setMinimum(0);
progressBar.setMaximum(countClasses(0, ""));
}
readPackage(0, new HashMap(), "", 0);
TreeModelListener[] ls;
synchronized (listeners) {
ls = (TreeModelListener[]) listeners
.toArray(new TreeModelListener[listeners.size()]... |
32e3f306-6a09-4400-a494-6157556d563e | 8 | public JSONObject parseUserAnimeListXML(InputStream inputXML) throws MALException, IOException {
// My storage variables
final ArrayList<Anime> myAnime = new ArrayList<Anime>();
final JSONObject animeListData = new JSONObject();
final Anime currentAnime = new Anime();
final User currentUser = new User();
... |
331043c2-8524-40dc-b909-86d6078ef512 | 6 | @Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof UnitsValue<?>) {
UnitsValue<?> uv = (UnitsValue<?>) obj;
return mUnits == uv.mUnits && mValue == uv.mValue;
}
return false;
} |
df235c50-3a3c-4efb-a138-2ec272ff7276 | 3 | public void export(Exporter ex) throws SQLException, IOException {
ex.start(settings.getName());
String query = "SELECT entry_id FROM entry";
EnumSet<ExporterSettings> expSetting = ex.getSettings();
if (expSetting == null) {
expSetting = EnumSet.noneOf(ExporterSettings.class);
}
if (expSetting.contain... |
06e2c493-4763-4cb6-9bbb-839b09ecad8f | 9 | /* @ pure */ public Coordinate recursiveCheck(int x, int y, Mark mark, int xOffset,
int yOffset, boolean seenSomething) {
if (x < 0 || y < 0 || x > DIM - 1 || y > DIM - 1) {
return null;
} else if (fields[index(x, y)] == Mark.EMPTY) {
return null;
} else if (fields[index(x, y)] == mark && seenSomething) ... |
73c7a784-5728-4adf-8eb0-5547b68e0f55 | 6 | public final void encode(final IAMCodec codec, final IAMIndex source) throws IOException, IllegalArgumentException {
final int mappingCount = source.mappingCount();
final int listingCount = source.listingCount();
final IAMINDEXTYPE xmlIndex = new IAMINDEXTYPE();
xmlIndex.byteOrder = codec.getByteOrder().toStri... |
3986ceb8-4080-4447-8769-cf91c047e89e | 4 | public static void main(String[] args) {
try {
initParameters(args);
File file = new File(filePath);
Input input = InputReader.readInput(file);
List<Cluster> clusters = DBScan.run(input.getTimeSeries(), eps, minNrOfNeighbours);
runPlotPrintingThread(input, clusters);
runClusterPlotScript... |
98a2ee5b-8696-4df2-b8cf-4c73f320cb9b | 9 | public void update( final double ct ) {
// get the array of entities
final Entity[] entities = getEntities();
// update all entities
for( final Entity entity : entities ) {
entity.update( ct );
}
// check for collisions
for( final Entity entityA : entities ) {
for( final Entity entityB : ent... |
88eedeee-b81f-43c1-925f-1e175c7cd2e0 | 1 | public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Ventana window = new Ventana();
window.frmClienteChat.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
} |
06d2dcd0-b8ea-4c7d-af16-84970cdca8cc | 9 | private String prettyPrinterDados(List<Object> dados) {
int cont = 0;
StringBuilder pretty = new StringBuilder();
for (Object o : dados){
if (o instanceof EData1)
pretty.append((cont > 0) ? " e Temperatura" : "Temperatura");
else if (o instanceof EData2)
pretty.append((cont > 0) ? " e Hemoglobina" :... |
321abb5e-38a6-41a0-9602-4284c0b108d2 | 0 | private String classNameToZipEntryName(String className) {
return className.replace('.', '/')
+ ".class";
} |
7f8f63f8-568e-44c4-bf1b-0db32d8e9ed5 | 2 | public static void checkNotNull(Object o, Class<?> c) {
if (o == null) {
throw new PrecondictionException("");
}
} |
b1f8e8c4-bc25-4733-ba1c-d72931df702f | 4 | public void selectPreviousStream() {
int selectedRow = table.getSelectedRow();
int numberOfStreams = controlStreams.getStreamVector().size();
//no stream is selected
if(selectedRow == -1 && numberOfStreams > 0) {
selectedRow = numberOfStreams-1;
} else if (selectedRow >= (numberOfStreams-1)) {
select... |
b2d8d4bd-9e0e-4850-b5c8-3644477656b2 | 3 | public void setNumeroInt(TNumeroInt node)
{
if(this._numeroInt_ != null)
{
this._numeroInt_.parent(null);
}
if(node != null)
{
if(node.parent() != null)
{
node.parent().removeChild(node);
}
node.par... |
60dd738e-8da4-4700-9e32-e7facca613a8 | 0 | public String getRegion() {
return region;
} |
4361cc34-d374-436d-90c6-ce7db27930d7 | 4 | private static Token matchIdentifier(String word, int line, int position){
StringBuilder token = new StringBuilder();
int i=0;
for (; i<word.length(); i++){
char current = word.charAt(i);
if (!Character.isLetterOrDigit(current)){
break;
}
token.append(current);
}
if (i != 0) {
Keyword... |
08829e14-c740-4a14-af8a-5dd53d33433f | 0 | private void printScore() {
aiTimer.stop();
playerTimer = new Timer(SCORE_SHOW_DELAY, this); // TODO: 300
playerTimer.start();
ballMovement = false;
} |
2632192d-ef77-4dfb-b336-44050a1bda52 | 4 | public void run(){
try {
_serverSocket = new ServerSocket(_listenPort);
System.out.println("Listening...");
} catch (IOException e) {
System.out.println("Cannot listen on port " + _listenPort);
}
UserDatabase.getUsers();
Statistics statistics= Statistics.getStatisticsObject();
while (!_serverStop.g... |
95e51e1c-fc5c-4f48-bb08-6cb70fe8b4c8 | 4 | private boolean checkForObjectRestore(int i, float days, String root) {
// float[][] data = new float[dbSet.length][];
float[][] data = DataUtil.restore2D(root + File.separator + "OBJECTS"
+ File.separator + "DATA_" + days);
if (data == null)
return false;
// float[][][] pdata = new float[dbSet.length]... |
7b69c638-86c1-4c82-b5f7-320982ad6ea8 | 3 | @Override
public String toString() {
return "IkszorBinaryObject " +
"[encodedValue=" + IkszorManager.booleanArray2BinaryString(encodedValue) + "["+(encodedValue != null ? encodedValue.length : "null")+"]" +
", symmetricKey=" + IkszorManager.booleanArray2BinaryString(symmetricKey) + "["+(symmetricKey != null ... |
638a724a-651c-4578-b41d-a767ba258ead | 5 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Port other = (Port) obj;
if (this.numberOfBerthes != other.numberOfBerthes) {
return false;
... |
e5240fee-674b-433b-9ca7-3f91d9a0ab02 | 2 | private List<Teleporter> getTeleportersOfGrid(Grid grid) {
final List<Teleporter> teleporters = new ArrayList<Teleporter>();
for (Element e : grid.getElementsOnGrid())
if (e instanceof Teleporter)
teleporters.add((Teleporter) e);
return teleporters;
} |
f309cbf6-d837-4f91-8969-94562f13de07 | 0 | public void setLine(int line) {this.line = line;} |
e208e42c-b513-4557-8e8b-31d8b2c56708 | 1 | public static void testFindFieldsbyXpath() throws Exception {
try{
getDriver().get("http://www.google.com/webhp?complete=1&hl=en");
// assertEquals("Google", getDriver().getTitle());
// Find the text input element by its Xpath
WebElement element = getDriver().findElement(By.xpath("//in... |
3490c1b6-6c15-47c3-9131-66502ad2fc2b | 4 | @Override
public void setFloat(long i, float value)
{
if (value != 0.0 && value != 1.0) {
throw new IllegalArgumentException("The value has to be 0 or 1.");
}
if (ptr != 0) {
Utilities.UNSAFE.putByte(ptr + i, (byte) value);
} else {
if (isConst... |
7ec1b24c-80d1-4bb8-b0c6-7fd70cf09946 | 2 | public void deductCost(Player player) {
for (int i = 0; i < costs.size(); i++) {
Item item = costs.get(i);
if (item instanceof ResourceItem) {
ResourceItem ri = (ResourceItem) item;
player.inventory.removeResource(ri.resource, ri.count);
}
}
} |
f5e04885-2a82-42a0-becc-abee74f1840d | 6 | public void update() {
player.update();
player.checkAttack(enemies);
player.checkCoins(coins);
finish.update();
finish.checkGrab(player);
bg.setPosition(tileMap.getx(), tileMap.gety());
if(player.isDead()){
player.setPosition(100, 400);
player.revive();
player.reset();
restart();
... |
aea40c9a-2197-4df8-94ac-6f4aabeb3bca | 9 | public static Map<String, String> simpleCommandLineParser(String[] args) {
Map<String, String> map = new HashMap<String, String>();
for (int i = 0; i <= args.length; i++) {
String key = (i > 0 ? args[i - 1] : null);
String value = (i < args.length ? args[i] : null);
if (key == null || key.star... |
72947150-3a0f-4b7b-87e3-c5e123e8627a | 8 | public void connect() {
// STEP 1 - CONNECT ALL UNCONNECTED
// NEIGHBOURS------------------------------------------------
// picks random room based on index from 0 to times*times(nb. of rooms)
Random rand = new Random();
int currentRoom = rand.nextInt(roomBase * roomBase);
// the starting room for the pla... |
75253238-2c1e-4c54-a356-46433c9c5cd9 | 7 | @Override
public boolean onCommand(CommandSender sender, Command cmd, String label,
String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is not supported from console.");
return true;
}
if (!sender.hasPermission("timebasic.adweather") && (!sender.isOp()))... |
4fc85d32-4caf-4d38-9f50-1d1b48ac14fb | 9 | public String arabToRome(int arabNum, int digits){
String romeNum = "";
String[] digits1 = new String[]{"I","X","C","M"};
String[] digits2 = new String[]{"II","XX","CC","MM"};
String[] digits3 = new String[]{"III","XXX","CCC","MMM"};
String[] digits4 = new String[]{"IV","XL","CD"};
String[] digits5 = new St... |
2d201255-7a22-4515-90c7-34bf2c8a1ee3 | 7 | public void affichePacman(Graphics pacman, GestionGraphismes g)
{
String img = "pacman_"+mvmt;
if (ferme > 15)
img = img+"_ferme";
if (invincible && (timer > 100 || timer%10<5))
img = img+"_invincible";
if (!invisible || (invisible && timer % 15 < 10))
pacman.drawImage(g.getPacman(img), positionX, ... |
f1c9fd84-f6a1-49e9-b81e-f44ef4f16fe8 | 7 | public static void UpdateImportFile(String profile, String genername, String importfile)
{
File file = new File(profile);
if (file.exists())
{
try
{
// Create a factory
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// Use the factory to create a builder
... |
155511c8-c93b-4d3a-967d-a39e162289dc | 3 | public void handle(Packet packet) {
if (packet instanceof ConnectPacket) {
// do nothing, already handled elsewhere
} else if (packet instanceof ShootPacket) {
shoot();
} else if (packet instanceof AdjustShooterAnglePacket) {
System.out.println("recv");
double angle = ((AdjustShooterAnglePacket)packet... |
720e174e-cff2-489b-b3c3-779659ccebfe | 0 | public boolean hasMatchedWord(String wordnum) {
return dictionary.containsKey(wordnum);
} |
4fcac1fa-f76d-4b91-9158-7fda6b50007e | 3 | @Override
public String execute() throws Exception {
try {
Map session = ActionContext.getContext().getSession();
Campaign camp = (Campaign) session.get("campa");
CampaignDevice campdev = new CampaignDevice(camp, getPlatform());
getMyDao().getDbsession().sa... |
cb1180df-e221-4f2d-a31c-15777a39c16e | 9 | @Override
public String toString() {
if (type == NUM) {
return "NUM: " + value;
} else if (type == CMD) {
return "CMD: " + name;
} else if (type == UNK) {
return "UNK";
} else if (type == EOF) {
retur... |
8f539d96-2eae-47f2-9fd6-d987d58dfa7d | 5 | @Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
Player p = Bukkit.getPlayer(sender.getName());
if(cmd.getName().equalsIgnoreCase("hub")){
Bukkit.dispatchCommand(p, "warp hub");
return true;
}
if(cmd.getName().equalsIgnoreCase("kits")){
KitPvP.kit(p, ... |
6d6d6161-51df-483c-ae93-d93b0cc35bcb | 9 | public void mouseInput(){
int mouseX = Mouse.getX();
int mouseY = Mouse.getY();
if (!justRequested){
distributePoints(mouseX, mouseY);
justRequested = true;
}
for (int x = 0; x < windowslist.size(); x ++){
if (windowslist.get(x).recieveMouseEvent(mouseX, mouseY)){
break;
}
}
pane... |
e7cb73c5-7694-4efc-b417-f66b7d32bf78 | 9 | public final LogoParser.sum_return sum() throws RecognitionException {
LogoParser.sum_return retval = new LogoParser.sum_return();
retval.start = input.LT(1);
Object root_0 = null;
Token PLUS43=null;
Token MINUS44=null;
LogoParser.mult_return o1 =null;
LogoPar... |
519f35f7-78d5-425a-919f-d18d4b8ca6cc | 3 | public InstructionStack(final MethodEditor method) {
this.method = method;
this.stacks = new HashMap();
this.preexists = new HashMap();
// Initially only the parameters to the method prexist
final Type[] paramTypes = method.paramTypes();
this.currPreexists = new HashMap();
for (int i = 0; i < paramTypes.... |
ee97bceb-708c-4b87-9da3-19f170a35b55 | 2 | private boolean canNotPassWall(double x, double dx, double y, double dy){
for (Wall wall: walls){
if (wall.crossedWall(x, dx, y, dy)){
return true;
}
}
return false;
} |
a9e8c635-af43-4a7d-8370-42900bf53215 | 7 | protected String startSetToString() {
StringBuffer FString = new StringBuffer();
boolean didPrint;
if (m_starting == null) {
return getStartSet();
}
for (int i = 0; i < m_starting.length; i++) {
didPrint = false;
if ((m_hasClass == false) ||
(m_hasClass == true && i... |
3732f1b7-08fc-4f2a-a979-087751ea4d38 | 0 | @Override
public void deconnecter() throws SQLException {
getConnexion().close();
} |
5edf8583-95ce-4cf6-bf68-78bd04fe68d8 | 1 | public boolean estTerminee(){
if(this.etat == TERMINEE){
return true ;
}
else {
return false ;
}
} |
28059ed6-5e44-4774-a725-a779bfb2be48 | 6 | public void run(){
try {
while(true){
Thread.sleep(MS_PER_SHRINK); // milliseconds
synchronized(vTrapped){
for(SpaceObject uObj : vTrapped){
if(uObj.getRad() > 0){
double x = uObj.getCenterX();
double y = uObj.getCenterY();
uObj.setRad(uObj.getRad() - 1); //decrease radius
... |
d26fe3b0-189f-4f69-a4c3-54c389bca185 | 5 | private void merge(int[] left, int[] right)
{
int leftIndex = 0; // current left index
int rightIndex = 0; // current right index
int i = 0; // current index in a
// merge the left and right arrays into a
while (leftIndex < left.length &&
rightIndex < right.length)
{
if (... |
081bfdd0-3221-4cf9-b2d5-4ecf01b6f1bd | 4 | public HashMap<String, Integer> calculateDocumentOccuriences(
List<String> unique, List<List<String>> documents)
throws InvalidFormatException, IOException {
HashMap<String, Integer> map = new HashMap<>();
for (String uniqueToken : unique) {
map.put(uniqueToken, 0);
for (List<String> list : documents)... |
38bd48a7-5cfd-46ab-a902-9ba01bc8bcff | 2 | @Override
public void doLoopAction()
{
if (hit)
{
doHit();
}
if (changeAni)
{
setAnimation();
changeAni = false;
}
} |
1b354845-e140-4b1a-b485-965ca909a939 | 6 | public void act(){
//if it gone past the start menu
if (start){
MouseInfo mouse = Greenfoot.getMouseInfo();
uiAct();
s.run();
//if the level started, increase the time and prepare the spawn
if (levelStart){
prepareSpawn(... |
dea4dd2f-9674-480e-a878-40faef8d104a | 7 | private void tryMove() {
for(BB bb : level.collidables) {
if(bb.intersects(this.x + this.xa, this.y, width, height)) {
if(this.xa > 0) {
this.x = bb.getX() - width;
} else if(this.xa < 0) {
this.x = bb.getX() + bb.getWidth();
}
this.xa = -xa;
}
i... |
54058910-5800-401c-974c-1ae4aade0c74 | 5 | public synchronized byte[] sendMutualAuth(byte[] rndIFD, byte[] rndICC,
byte[] kIFD, SecretKey kEnc, SecretKey kMac)
throws CardServiceException {
try {
ResponseAPDU rapdu = transmit(createMutualAuthAPDU(rndIFD, rndICC,
kIFD, kEnc, kMac));
byte[] rapduBytes = rapdu.getBytes();
if (rapduBytes == nu... |
d8a5f60a-489a-4a73-97ae-13fd27fb9288 | 3 | @Override
public void updateUser(UserDTO user) throws SQLException {
Session session = null;
try {
session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
session.update(user);
session.getTransaction().commit();
}... |
b03350f8-e7a0-4cac-8c57-a256e50ab61d | 8 | static String makeRgbaData(int width, int height, int bpp, boolean has_alpha) {
final int CHECK_SIZE = 20;
assert (bpp == 4);
assert (has_alpha);
int rowstride = width * bpp;
char[] pixels = new char[height * rowstride];
for (int y = 0; y < height; y++) {
int i = 0;
for (int x = 0; x < width; x++)... |
02066883-0ffc-46af-b9ea-fcce2c848e79 | 2 | public double variance_of_ComplexRealParts() {
boolean hold = Stat.nFactorOptionS;
if (nFactorReset) {
if (nFactorOptionI) {
Stat.nFactorOptionS = true;
} else {
Stat.nFactorOptionS = false;
}
}
double[] re = this.array_as_real_part_of_Complex();
double variance = Stat.variance(re);
Stat.nF... |
433ebd91-40a0-48f2-a699-f164d87ca9aa | 8 | public void unDeplacement(){
this.flackBoy.avancer();
/*System.out.println("ANGLE = "+this.flackBoy.getTrajectoire().angleActuelle());
System.out.println("VITESSE = "+this.flackBoy.getTrajectoire().vitesseActuelle());
System.out.println("X = "+this.flackBoy.getX());
... |
68ce765e-8116-465e-853f-ee4763516a91 | 9 | public int getStringWidth(String par1Str)
{
if (par1Str == null)
{
return 0;
}
int i = 0;
boolean flag = false;
for (int j = 0; j < par1Str.length(); j++)
{
char c = par1Str.charAt(j);
int k = getCharWidth(c);
... |
c051cf0c-e958-481e-bc35-37defedf6dd2 | 9 | public static void main(String[] args) {
Scanner tecla=new Scanner(System.in);
String opcion=" ";
System.out.println("ELECCIONES");
do{
System.out.println("Elige una opcion (a-e), o teclea 'X' para terminar:");
opcion=tecla.next();
switch (opcion){
case "a":
String nombre=" ";
St... |
5aa3adfc-7fa0-4ff8-89b3-9909ebed6ced | 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... |
b730872f-7d17-4403-b3e7-05958c31c82f | 3 | public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g.create();
int h = getHeight();
int w = getWidth();
int pct=2;
float tran = 0.1f + pct * 0.9f;
GradientPaint GP = new GradientPaint(0, 0, COLOR1, 0, h, COLOR2, true);
g2d.setPaint(GP);
ButtonModel model = getModel();
if (!... |
9c15974c-d862-441f-9d25-af25712284d4 | 9 | private void loadGame(BasicGame rps) {
Util.initialPromtVersion(rps);
// get all the available items for this verison of game
Set<Item> itemSet = rps.getItems();
while (true) {
currentLine = scanner.nextLine();
try {
//your current picked item.... |
baad786e-b9f9-4195-9d53-207c1cf44a61 | 0 | private void jButtonNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNextActionPerformed
ctrlP.suivant();
}//GEN-LAST:event_jButtonNextActionPerformed |
dc429881-c330-4aeb-8008-73547fd55a6b | 8 | public ComparableNode getLeftmostProperDescendant() throws MaltChainedException {
NonTerminalNode node = this;
ComparableNode candidate = null;
while (node != null) {
candidate = node.getLeftChild();
if (candidate == null || candidate instanceof TokenNode) {
break;
}
node = (NonTerminalNode)candid... |
b543d7da-3a19-4fc3-9530-b861ee24558d | 9 | static final public void metodos() throws ParseException {
if (jj_2_4(2147483647)) {
metodos_com_parametros();
} else {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case DOUBLE:
case FLOAT:
case LONG:
case CHAR:
case INT:
case VISIBILITY:
case IDENTIFIER:
... |
4c45aca7-6265-460d-a0d1-b12f7c05a267 | 4 | @Override
public void free_result() throws SQLException {
// no need to close a stmt which doesn't exist
if(this.stmt != null && !this.stmt.isClosed()) {
this.stmt.close();
this.stmt = null;
this.last_prepare = "";
}
if(this.res != null && !this.res.isClosed()) {
this.res.close();
this.res = nul... |
cabc7f0e-6324-4780-9b99-1350d022a2d6 | 5 | private void dissipate() {
float flowRate = Globals.getSetting("Dissipation strength", "Water");
for(int x = 0; x < Globals.width; x++){
for(int y = 0; y < Globals.height; y++){
for(int[] neighbor : HexagonUtils.neighborTiles(x, y, false)){
if(groundWaterLevel[neighbor[0]][neighbor[1]] < groundWaterLeve... |
c6d5df21-1d84-42d4-aabd-6716b1caab47 | 8 | public static void parseArguments(final String[] args) {
for (int i = 0; i < args.length; i++) {
final String element = args[i];
if (element.equalsIgnoreCase("-h") || element.equalsIgnoreCase("--h") || element.equalsIgnoreCase("--help") || element.equalsIgnoreCase("-help") || element.equalsIgnoreCase("hel... |
b81af191-b303-46b3-ad1a-022c136c3b67 | 1 | public static void main(String[] args)
{
HashSet set1 = new HashSet();
set1.add("a");
set1.add("b");
set1.add("c");
set1.add("d");
// Iterator iter = set1.iterator();
// while(iter.hasNext()){
//
// String value = (String)iter.next();
//
// System.out.println(value);
// }
for(Iterator... |
9191e3ec-d745-4a64-8c44-0b4ef1769049 | 5 | private void writeToFile(String strRep, String path) {
FileOutputStream fos = null;
File file;
try {
//Get all current text into temp
String temp = "";
Scanner sc = new Scanner(new File(path));
while(sc.hasNextLine()) {
temp += sc.... |
7ae76b01-ca66-4a3d-87da-b0c2f64b9a20 | 3 | static double[][] multiply(double[][] A, double[][] B){
double[][] AB = new double[A.length][B[0].length];
for(int i = 0; i < A.length; i++){
for(int j = 0; j < B[i].length; j++){
for(int k = 0; k < B.length ; k++){
AB[i][j] += A[i][k]*B[k][j];
}
}
}
return AB;
} |
d0fc548e-db31-4230-b48d-84a2f6626eda | 3 | private void initEnemies() {
for(int i = 0; i < 12; i++) {
Mho newEnemy = initRandMho();
if(!(grid[newEnemy.getX()][newEnemy.getY()] instanceof Fence) && !(grid[newEnemy.getX()][newEnemy.getY()].contains(Mho.class))) {
grid[newEnemy.getX()][newEnemy.getY()].occupy(newEnemy);
}
else i--;
}
} |
5cf24108-9654-473f-b026-ff64ea071233 | 6 | public Double[][] sum(Double[][] a, Double[][] b) {
Double[][] ans = new Double[2][a[0].length+b[0].length];
boolean flag = false;
for(int i=0; i<a[0].length; i++){
ans[0][i] = a[0][i];
ans[1][i] = a[1][i];
}
if(a[0].length < b[0].length){
Doub... |
62707562-8069-4382-819c-7a9074917f9f | 3 | @Override
public void delete(Match obj) {
PreparedStatement pst = null;
try {
pst = this.connect().prepareStatement("DELETE FROM Matches where id=?;");
pst.setInt(1, obj.getId());
pst.executeUpdate();
System.out.println("suppressi... |
27839fa8-8f67-4dad-8fa4-7ac16706bfc3 | 5 | public static void flatten3(TreeNode root) {
if (root == null || (root.left == null && root.right == null)) return;
if (root.left != null) {
TreeNode tmp = root.right;
root.right = root.left;
root.left = null;
TreeNode rightMost = findRightMostNode(root.right);
rightMost.right = tmp;
flatten3(r... |
47086476-2244-43db-b3aa-89b6bee9e076 | 0 | public void clear(){
wrncnt=0;
errcnt=0;
messagequeue.clear();
} |
85085369-e2ce-44db-9c3a-ff39e8b69344 | 1 | @Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((val == null) ? 0 : val.hashCode());
return result;
} |
b6360478-96aa-4d4d-b39e-c49bfe360ed5 | 2 | public void delete(int index){
if(index >= size || index < 0){
System.out.println("Invalid index");
}else{
maxHeap[index] = maxHeap[size - 1];
size --;
MaxHeap.maxHeaplify(maxHeap, index, size);
}
} |
8ec69478-7410-481a-9f16-0baca5ed284d | 4 | private List<Reducer> estimateReducers(List<Mapper> newMapperList) {
int fReducerNum = finishedConf.getMapred_reduce_tasks();
if(fReducerNum == 0)
return null;
ReducerEstimator reducerEstimator = new ReducerEstimator(finishedConf, newConf, newMapperList, false);
List<Reducer> newReducerList = new Arra... |
4598608a-fd30-4f98-8008-fd711ace62c2 | 7 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
final Item target=getTarget(mob,mob.location(),givenTarget,commands,Wearable.FILTER_ANY);
if(target==null)
return false;
if(!(target instanceof Armor))
{
mob.tell(mob,target,null,L("You ca... |
a98c3f28-7235-407c-ba23-0e1e2af28209 | 6 | public boolean canShiftLeft(){
if(loc1.getColumn() == 0 || loc2.getColumn() == 0|| loc3.getColumn() == 0
|| loc4.getColumn() == 0){
return false;
}
//gets all of the rightmost locations of the piece
ArrayList<Location> leftLocs = getLeftLocs();
for(int i = 0; i < leftLocs.size(); i++){
if(board.getV... |
edee296b-b1f2-4565-acac-9acd1aa3147f | 4 | public boolean onCommand(CommandSender cs, Command cmd, String string,
String[] args) {
if(!(cs instanceof Player)){
cs.sendMessage("This is not a console command!");
return false;
}
if(string.equalsIgnoreCase("tp")){
Teleport teleportObj = new Teleport(MainClass);
teleportObj.teleport(cs, cmd, ... |
0909eae2-a304-4dd3-aa53-ba68853f5fb9 | 4 | public void linearInterpolation(){
if(this.nAnalyteConcns<2)throw new IllegalArgumentException("Method cubicInterpolation requres at least 2 data points; only " + this.nAnalyteConcns + " were supplied");
this.methodUsed = 14;
this.sampleErrorFlag = false;
this.titleOne = "Linear interpol... |
386f1a2f-a926-491d-8ca1-56ab6adefc43 | 2 | @Override
@Command
public MessageResponse setUserPublicKey(String userName) throws IOException {
if(initRMI()) {
String pathToPublicKey = keysDir+"/"+userName+".pub.pem";
PEMReader in;
try {
in = new PEMReader(new FileReader(pathToPublicKey));
PublicKey publicKey = (PublicKey) in.readObject();
... |
5d83334b-91fd-4e28-9d13-951bad61ec27 | 7 | public GameData getData() {
// creating a new gamedata object
GameData gd = new GameData();
// setting the MP and gem
gd.setMP(MagicPower.getMP());
gd.setGem(gem);
gd.setCounter(counter);
// adding the enemies
List<Enemy> enemyList = new ArrayList<Enemy>();
for (Tile t : map) {
if (t instanceof ... |
4b54a3c9-6560-46db-96ad-e636385d9e0f | 5 | @Override
public boolean export(final File target, HistorySorter sorter) {
boolean result = false;
if (sorter == null) {
throw new IllegalArgumentException("Null sorter not allowed");
}
try {
final Document doc = prepareDocument();
final Element ... |
78cc8981-a002-44fb-9c15-1c47851d065f | 2 | private void printImplementors(final Type iType, final PrintWriter out,
final boolean recurse, final int indent) {
final Iterator implementors = this.implementors(iType).iterator();
while (implementors.hasNext()) {
final Type implementor = (Type) implementors.next();
indent(out, indent);
out.println(imp... |
374b2104-14cd-4a27-916f-9b2ce0ce76d7 | 3 | @Override
Shape getShape(String shapeName) {
// Java 8 can use Strings in switch.
switch (shapeName) {
case "CIRCLE":
return new Circle();
case "RECTANGLE":
return new Rectangle();
case "SQUARE":
return new Square();
default:
return null;
}
} |
c9cd0d9f-f370-4346-9c35-059473b9772f | 7 | private boolean catchEntryRefs(E entry) {
strongRefs.clear();
if (entry == null) {
return true;
}
final List<? extends Reference<?>> refs = entry.getReferences();
if (refs == null) {
return true;
}
for (... |
64f4bf4e-c631-4193-bcde-884802e13759 | 6 | public void check() throws IllegalStateException {
Run currentRun = getFirst();
int curLength = 0;
int totalLength = width * height;
while(hasNext(currentRun)) {
if((currentRun.getRunType() == currentRun.getNext().getRunType())
&&(currentRun.getHungerVal() == currentRun.getNext().getHungerVal()))... |
3e25fb8b-ffa9-4cdc-b13e-25eaf6dc55f6 | 9 | Object createPrimitiveFor(Class<?> primitiveT) {
if (primitiveT == Boolean.TYPE) {
return arbBoolean();
} else if (primitiveT == Character.TYPE) {
return arbChar();
} else if (primitiveT == Byte.TYPE) {
return arbByte();
} else if (primitiveT == Short.... |
f453be3b-2b2c-4ebe-979a-1da4009e3550 | 5 | final void method1716(boolean bool) {
anInt5931++;
if (bool != false)
aClass351_5929 = null;
if (((Class239) this).aClass348_Sub51_3136.method3422(674)
!= Class10.aClass230_186)
((Class239) this).anInt3138 = 1;
else if (((Class239) this).aClass348_Sub51_3136.method3425(-125))
((Class239) this).a... |
87f6f023-c7f7-41e6-8aa7-affdb7bf701f | 4 | public void drawStringMoveY(int waveSpeed, String string, int waveAmount, int y, int x, int color) {
if (string == null) {
return;
}
double speed = 7D - (double) waveSpeed / 8D;
if (speed < 0.0D) {
speed = 0.0D;
}
x -= getTextWidth(string) / 2;
y -= baseHeight;
for (int index = 0; index < string.l... |
5781cdff-a0c9-4ad0-98f0-ad07f1238d65 | 3 | @Override
public void reset () {
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
if (field[i][j] instanceof EmptyCell) {
field[i][j] = new EmptyCell();
}
}
}
openedCells.clear();
isProce... |
a95f3b4b-aac8-4b09-b93b-a85dd53c981b | 7 | private void hitEnemy(Player player, Enemy[][] enemys){
for(int i = 0; i < enemys.length; i++) {
for(int j = 0; j < enemys[i].length; j++) {
for(int k = 0; k < player.getProjectiles().length; k++) {
if(player.getProjectiles()[k].getCollider() != null) {
if(enemys[i][j].getCollider().overlaps(player.... |
62322b15-103c-473c-89f8-ff573149774b | 7 | private void setUpValueSelection(Instances format) {
if (format.classIndex() < 0 || format.classAttribute().isNumeric()) {
// cant do anything in this case
return;
}
if (m_displayValNames == false) {
remove(m_messageLabel);
}
int existingClassVal = m_classValuePicker.getClassV... |
6b75ee12-d3eb-445a-9434-30d109bca6cd | 3 | @EventHandler
public void onPlayerJoin(PlayerJoinEvent e)
{
IrcClient client = Parent.Manager.getCurrentClient();
for(String s : client.getMcEcho_ActiveChannels())
{
try{ client.PrivMsg(s, IrcColor.formatMCMessage(ChatManagerUtils.ParseDisplayName(e.getPlayer())) + IrcColor.N... |
89cdeaca-8671-4569-a061-131737865798 | 9 | public void createStockArff(String stockName, ArrayList<Integer> years) {
String result = "";
int instances = 0;
result += "@RELATION " + stockName + "\r\n";
result += "@ATTRIBUTE day NUMERIC " + "\r\n";
result += "@ATTRIBUTE price NUMERIC " + "\r\n";
result += "@DATA " ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.