method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
10a9e79c-109e-42d1-8c1e-b89a0e94430b | 1 | public ArrayList<Team> CreateTeams() {
for (int i = 0; i < NumOfTeams; i++) {
Team t = new Team();
teams.add(t);
}
return teams;
} |
d970bcb8-0755-4660-9765-21bad5145aeb | 4 | @Override
public void update() {
// Consider player input and create more ribbons if requested
if( inputEvent.keyTyped( KeyEvent.VK_1 ) )
createRibbons( 1 );
else if( inputEvent.keyTyped( KeyEvent.VK_2 ) )
createRibbons( 10 );
else if( inputEvent.keyTyped( Key... |
7f259521-ed3a-4ccd-8566-05ced447e719 | 2 | public AutomatonGraph(Automaton automaton) {
super();
State[] states = automaton.getStates();
Transition[] transitions = automaton.getTransitions();
for (int i = 0; i < states.length; i++)
addVertex(states[i], states[i].getPoint());
for (int i = 0; i < transitions.length; i++)
addEdge(transitions[i].get... |
0ea602ab-1ca3-4327-a763-fb59e3df3ead | 5 | @Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj == null || obj.getClass() != getClass()) return false;
Vector3 other = (Vector3) obj;
return x == other.x && y == other.y && z == other.z;
} |
d0b0b27b-13b1-4ce5-9c07-683b6833c5b5 | 8 | private void BtGravarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtGravarActionPerformed
if (camposobrigatoriospreenchidos()) {
if (JOptionPane.showConfirmDialog(null, "Tem certeza que deseja Gravar esta compra e de que todas as informações estão corretas?", "Deseja gravar?", ... |
3c88c7a7-f3ea-4008-8ab2-d97c81367c6f | 9 | public Document modifyDocumentFrom(InstanceCheckerEngine logic, Document document, InstanceCheckerParser problem) {
Element functionsElement = XMLManager.getElementByTagNameFrom(document.getDocumentElement(), InstanceTokens.FUNCTIONS, 0);
if (functionsElement != null)
document.getDocumentElement().removeChild(fu... |
dc0445e4-843b-4665-8f4c-a2ed0f17d329 | 2 | private void dfs(Digraph G, int v) {
count++;
marked[v] = true;
for (int w : G.adj(v)) {
if (!marked[w]) dfs(G, w);
}
} |
661db7c0-4023-4679-9094-1a9b59ccfdf6 | 7 | public String getDescriptor(int r, int c) {
switch (currentTurn) {
case 1:
if (c < unitsP1.length )
return unitsP1[r][c].getDescriptor();
else
return terrainP1[r][c - unitsP1.length].getDescriptor();
case 2:
if (c < unitsP2.length )
return unitsP2[r][c].getDescriptor();
else
return ter... |
6dfa526b-91a9-4f9e-8c1e-9fb05303e159 | 8 | @Override
public boolean execute(MOB mob, List<String> commands, int metaFlags)
throws java.io.IOException
{
String parm = (commands.size() > 1) ? CMParms.combine(commands,1) : "";
if((mob.isAttributeSet(MOB.Attrib.AUTOASSIST) && (parm.length()==0))||(parm.equalsIgnoreCase("ON")))
{
mob.setAttribute(MOB.At... |
3f240627-1587-4e0b-9994-f8d6c7ca6f15 | 6 | public void startgame() {
if (running)
return;
h = new HavenPanel(800, 600);
add(h);
h.init();
try {
p = new haven.error.ErrorHandler(new ErrorPanel(), new URL("http", getCodeBase().getHost(), 80, "/java/error"));
} catch (java.net.MalformedURLExce... |
4490ae48-df4c-40c3-90ee-710e948a1de9 | 0 | public void setTrain(Train value) {
this._train = value;
} |
5a7d9f2f-6aa2-49fa-beff-19eb192c838b | 0 | public void setAccount(String account) {
this.account = account;
} |
f75a8d75-c012-4a5b-9960-7450f0f53e6e | 6 | public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_A) { degrees--; }
if (e.getKeyCode() == KeyEvent.VK_O) { degrees++; }
if (e.getKeyCode() == KeyEvent.VK_RIGHT) { x++; }
if (e.getKeyCode() == KeyEvent.VK_LEFT) { x--; }
if (e.getKeyCode() == KeyEvent.VK_DOWN) { y++; }
if (e.getKeyCode... |
8f294dab-12be-4a81-9877-b11c633e6011 | 3 | public boolean retirar(double cantidad){
if(cantidad > saldo){
if(cuentaAhorro == null)
return false;
else if((cantidad-saldo) > cuentaAhorro.getSaldo() )
return false;
else{
cantidad-=saldo;
saldo=0;
cuentaAhorro.retirar(cantidad);
return true;
}
}
else{
saldo... |
4572cdf6-4736-41d3-b049-9623e4c89131 | 7 | public static String getFileNameByFilePathJudgeSuffix(String filePath,boolean flag){
String name = null;
if(null != filePath && filePath.length() > 0){
String temp[] = filePath.replaceAll("\\\\","/").split("/");
if (temp.length >= 1) {
name = temp[temp.length - 1];
}
}
if(null != name && na... |
67b274f9-ef79-43e1-bd46-4868fe9ba094 | 5 | void keepAlive () {
if (!isConnected) return;
long time = System.currentTimeMillis();
if (tcp.needsKeepAlive(time)) sendTCP(FrameworkMessage.keepAlive);
if (udp != null && udpRegistered && udp.needsKeepAlive(time)) sendUDP(FrameworkMessage.keepAlive);
} |
7f226165-bcc9-4bc3-902d-a3554e52b2ff | 7 | public Behaviour jobFor(Actor actor) {
//if ((! structure.intact()) || (! personnel.onShift(actor))) return null ;
final Choice choice = new Choice(actor) ;
//
// See if any new datalinks need to be installed or manufactured-
final Delivery baseC = Deliveries.nextCollectionFor(
actor, this, n... |
ec6973dc-2d6e-4edd-9fbb-ced4022ee12a | 8 | @Override
public void propertyChange(PropertyChangeEvent e) {
JTable table = (JTable)e.getSource();
if (table == null) {
return;
}
String propertyName = e.getPropertyName();
if (propertyName.equals("enabled")) {
boolean ... |
292e64b2-a1ac-4415-ba97-91d5558e5ab0 | 2 | public void AddStopMenuElement() {
if (elementStop != null)
return;
elementStop = APXUtils.addResource("stop_" + scrUniq, scrName,
scrTooltip, scrHotkey, APXUtils.resScript4, APXUtils.scriptRootRem,
new MenuElemetUseListener(new String(filename)) {
@Override
public void use(int button) {
... |
0b5e58c4-1760-4bd5-a803-c78cb27aa8c9 | 6 | public TreeContainerRow overDisclosureControl(int x, int y) {
if (mShowDisclosureControls && !mColumns.isEmpty()) {
if (x < mColumns.get(0).getWidth() + getColumnDividerWidth()) {
TreeRow row = overRow(y);
if (row instanceof TreeContainerRow) {
int right = INDENT * row.getDepth();
if (x <= right ... |
53783100-7c9e-4b69-8a5b-9718e613e1cb | 4 | @Test
public void testJoinGame() {
// valid join
try {
games.joinGame(new JoinGameRequest(0, "blue"), "TestUser", 999);
assertEquals("Failed to add player name to empty game in games list.", "TestUser", games.listGames().get(0).getPlayerDescriptions().get(0).getName());
} catch (InvalidGamesRequest e) {
... |
be2fa1af-5e02-41bc-b7bf-0f634fc8ca4a | 9 | public StringBuffer format(double number, StringBuffer toAppendTo,
FieldPosition pos) {
StringBuffer s = new StringBuffer( nf.format(number) );
if( s.length() > width ) {
if( s.charAt(0) == ' ' && s.length() == width + 1 ) {
s.deleteCharAt(0);
}
else {
s.setLength( width );
for( in... |
f533473a-3584-4219-a8e3-0f8576628d4c | 1 | public void updateAll( float delta )
{
update( delta );
for ( GameObject child : children )
child.updateAll( delta );
} |
fca470fa-9736-4136-a1d5-27973609d0f5 | 2 | private Expression cons( List<Expression> args, String caller ) {
if ( args.size() != 2 ) {
System.err.println("cons expected exactly two argument and got " + args.size() );
return new Void();
}
Expression evaledArg = args.get(0).eval(defSubst, caller);
Expression... |
556b85c0-1bf8-4867-985e-19069d1cd7db | 7 | public EvolscriptView(SingleFrameApplication app) {
super(app);
initComponents();
// status bar initialization - message timeout, idle icon and busy animation, etc
ResourceMap resourceMap = getResourceMap();
int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout"... |
a3d819f5-c3b8-4a26-b526-c69646c85438 | 6 | @Override
public void actionPerformed(ActionEvent e) {
if( e.getSource() == boton_alta_departamento ){
Controlador.getInstance().accion(EventoNegocio.GUI_ALTA_DEPARTAMENTO,GUIPrincipal_Departamento.this);
}
else if( e.getSource() == boton_baja_departament... |
c4def7a1-52c3-4e32-af1c-7ba9c89dd4a4 | 8 | private static int pivot(int[] a, int low, int high) {
int i1 = low, i2 = high - 1, i3 = (low + high) / 2;
int a1 = a[i1], a2 = a[i2], a3 = a[i3];
int n = (a1 > a2) ? a1 : a2;
int m = (a2 > a3) ? a2 : a3;
if (m > n) {
return (a1 > a2) ? i1 : i2;
} else if (n... |
852bb981-2051-4a44-a244-952697b6c764 | 2 | @ChattingAnnotation(feature="Attachment", type="method")
@Override
public void fileSent(String sender, String fileName, byte[] fileData) {
if (!sender.equals(this.getTitle())) {
tvTranscript.setText("Recived a file " + fileName + "\n");
try {
saveFile(filePath + fileName, fileData);
} catch (Exception ... |
bab5cf95-4e89-4873-8d08-12970b3731fd | 3 | public boolean isEvenlyDivisible(int num) {
boolean isIt = true;
for (int i = 2; i <= 20 && isIt; i++) {
if (!(num % i == 0)) {
isIt = false;
}
}
return isIt;
} |
b896cd7f-f112-4f9b-a42b-2e37ac906861 | 3 | public void dispose() {
if (edgeListLeftNeighbor != null || edgeListRightNeighbor != null) {
// still in EdgeList
return;
}
if (nextInPriorityQueue != null) {
// still in PriorityQueue
return;
}
edge = null;
leftRight = null... |
df4b8dd6-b584-4343-b159-2c9cb4aa8499 | 5 | private Square[][] createArrayBoard()
{
int height, width;
height = inputBoard.size();
width = 0;
for(int x = 0; x < height; x++)
{
if(width < inputBoard.get(x).size())
{
width = inputBoard.get(x).size();
}
}
Square[][] board = new Square[height][width];
for(int x = 0; x < height; x++)
{... |
115a9e81-67b6-4fa4-97d0-c4c83f142c8a | 3 | private static String getAllowedCharacters() {
StringBuilder sb;
InputStreamReader isr = new InputStreamReader(ChatAllowedCharacters.class.getResourceAsStream("/font.txt"), Charset.forName("UTF-8"));
try (BufferedReader var1 = new BufferedReader(isr)) {
String tmp;
sb = n... |
8bb12384-6bc5-4b69-8fe6-421023285b30 | 6 | public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String line = "";
StringBuilder out = new StringBuilder();
while ((line = in.readLine()) != null && line.length() != 0) {
long n = Long.parseLong(line.trim()), ans[] = new lon... |
a8a5a9ab-f77c-4224-a499-85b62fe43207 | 8 | public static void main(final String[] args) {
boolean displayConsole = true;
if (args.length > 0) {
// it has arguments
if (args.length == 1 && args[0].equalsIgnoreCase(Main.help)) {
System.out.println("Starts the KOI server");
System.out.println("\nArguments:");
System.out.println(Main.noConsol... |
8d67740d-1dd3-4a39-b9df-c76ab256f465 | 8 | public ListNode rotateRight(ListNode head, int n) {
if (head == null || head.next == null || n == 0) {
return head;
}
int length = 0;
int steps = 0;
ListNode first = head;
ListNode second = head;
while (first != null) {
first = first.next... |
92a521d3-3e4b-4705-9161-ac568c91bee7 | 7 | public LinkedList<Field> getAttackBorder() {
LinkedList<Field> fields = this.field.getAttackBorder();
if (fields == null) {
fields = new LinkedList<Field>();
for (Offset offset : Ant.attackBorder) {
boolean found = false;
if (!offset.getField(this.field).hasWater()) {
for (Offset o : Ant.attackOf... |
323298b1-8f3f-41b1-8226-ccae13825266 | 7 | public boolean nextTo( Point p ){
if( equals(p) ){
return true;
}
if( _x == p._x ){
if( _y == p._y+1 || _y == p._y-1 ){
return true;
}
}
if( _y == p._y ){
if( _x == p._x+1 || _x == p._x-1 ){
return true;
}
}
return false;
} |
9bc1964a-0b85-4876-be0c-ebf69c708be8 | 2 | public static Action create(String action){
Action actionObject = null;
String nomeClasse = "br.com.implementacaoObserverWeb.action." + action + "Action";
Class classe = null;
Object object = null;
try{
classe = Class.forName(nomeClasse);
object = classe.n... |
729c3a3f-27ce-4573-bcf2-d9d612fa1516 | 3 | public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
//Position de la souris
int posX = Mouse.getX();
int posY = Mouse.getY();
//background
bg.draw();
//positions et mouvements des projectiles
for (int i = 0; i < listAn... |
1bfe1415-841f-4db3-ab6e-e727dfbc20e2 | 8 | @Test
public void testCheckLabChoices(){
//Initialize a boolean saying there are no students who have no first choices and aren't flagged.
boolean startEmptyFirstChoices = true;
//For each student
for(Student s: students){
//If a student has no first choices and isn't flagged
if(s.getFirstChoiceLabs().is... |
c92f63c5-3e6c-4234-8578-1e1670cd3e32 | 5 | @Override
public void actionPerformed(ActionEvent e) {
if (held) {
if (this.pressed) {
heldStatus.put(this.name, true);
} else {
heldStatus.put(this.name, false);
}
} else {
if (this.pressed && !toggleStatus.get(this.name)) {
toggleStatus.put(this.name, true);
action();
}... |
2312faf9-7c45-44ed-86e8-e289288fd1b0 | 3 | private void pullStack(){
NetworkMessage m = messageQueue.poll();
if(m == null)
return;
try
{
Socket client = new Socket(m.getReceiver() , m.getPort() );
OutputStream outToServer = client.getOutputStream();
DataOutputStream out = new DataOutputStream(... |
b01e027d-d97c-4eac-ad46-1f8adc8ca6ce | 0 | public CtrlVisiteurs getCtrl() {
return ctrlV;
} |
71f6a7ab-01f9-4b61-aaf5-139550efdf62 | 5 | public ContentResponse send() throws InterruptedException, ExecutionException, TimeoutException, IOException {
String urlRequest = baseUri + resource;
Request httpRequest = httpClient
.newRequest(urlRequest)
.param("access_token", token);
for (String key : headers... |
4cd39d8c-dfe7-4a1a-be67-57bb5ce984d2 | 1 | private static void traverseTree(Tree tree) {
TreeItem[] treeItems = tree.getItems();
for (TreeItem treeItem : treeItems) {
traverseNode(treeItem);
}
} |
e4ff99d3-263e-460e-b9b9-c28dbffc3322 | 9 | public Move move(boolean[] foodpresent, int[] neighbors, int foodleft, int energyleft) throws Exception {
Move m = null; // placeholder for return value
// this player selects randomly
int direction = rand.nextInt(6);
switch (direction) {
case 0: m = new Move(STAYPUT); break;
case 1: m = new Move(WES... |
40776a24-a514-4e4d-a559-ac2bacee78dd | 0 | public Proffession getProffession() {return proffession;} |
a45e49ca-4f66-4ea0-aa82-b1b38b28dc91 | 9 | public String encodeValues() throws EncodeException {
StringBuilder res = new StringBuilder();
if (this.values != null && this.values.length > 0) {
for (Object value : this.values) {
if (value instanceof Integer) {
res.append("int:");
} els... |
212ae235-9d46-4ede-b91a-02812e34c287 | 2 | @Override
public void run() {
do{
field.repaint();
try {
Thread.sleep(TimeUnit.SECONDS.toMillis(1/ticks));
} catch (InterruptedException e) {
e.printStackTrace();
}
}while(running);
} |
cb6b3cc2-70ca-4d6f-a52b-05d449d40b33 | 4 | @Override
protected boolean judgeResult(CardGroup cardGroup) {
cardGroup.doSort(CardGroupSortType.DECREASE);
boolean result = true;
int score = cardGroup.getCard(0).getType();
for(int i = 0; i <cardGroup.size()-1 ; i += 2 , score --) {
if( score != cardGroup.getCard(i+1).getType() || ((i + 2)<cardGroup.size... |
5ce9690a-1432-4f21-84da-a11260b582cc | 5 | private void createInverter(String in, String out)
{
Inverter inverter = new Inverter();
// Connect the input
// Check if the in wire is an input
if (stringToInput.containsKey(in))
{
Wire inWire = new Wire();
stringToInput.get(in).connectOutput(inWire);
inverter.connectInput(inWire);
}
// Check... |
32760eca-a6a0-4d18-9511-53ea62f1b2b2 | 7 | private void updateGcCapacity(GcCapacity gcCapacity) {
if(gcCap == null)
this.gcCap = gcCapacity;
else {
if(gcCap.getEC() > gcCapacity.getEC())
gcCap.setEC(gcCapacity.getEC());
if(gcCap.getNGC() > gcCapacity.getNGC())
gcCap.setNGC(gcCapacity.getNGC());
if(gcCap.getOGC() > gcCapacity.getOGC(... |
d6982c0e-d994-49bd-8c6c-04f7043599c5 | 5 | private int getControlPosition(int controlType) throws Exception{
ArrayList<Integer> controls = new ArrayList<Integer>();
for(Surface surface: this.getSurfaces()){
for(Section section: surface.getSections()){
for(Control control: section.getControls()){
if... |
ba29ce27-0247-42c7-ad9e-23591a160196 | 8 | public void update(GameContainer gc, int delta) {
Input input = gc.getInput();
if (input.isKeyDown(Input.KEY_W))
{
position.add(new Vector2f(0,-MOTION_SPEED*delta));
body.setPosition(position.getX(),position.getY());
if (sprites.get("reverse") != null)
curImage = sprites.get("reverse");
}
if (i... |
2c65c214-ac5d-4a52-be15-07ee44a935b6 | 5 | public void replacePast() {
DatastoreService datastore = DatastoreServiceFactory
.getDatastoreService();
Entity past_string = null;
try {
past_string = datastore.get(KeyFactory.createKey("past_string",
"onlyOne"));
} catch (EntityNotFoundException e) {
}
String[] string_box = ((Text) past_string... |
2f610a67-eb98-42b2-a900-617043ede12e | 2 | public void collisionUpdate(int i, int j, int k, int l) {
Obstacle[][] obs = level.getObstacles();
boolean collideBad = true;
if (i+(height/Obstacle.getHeight())+ 1>=obs.length) { // Out of the drawing.
dead = true;
System.out.println("Below the box");
} else {
collisionSide(obs,i,j,k,l);
collideBad... |
bad95f85-00a9-46bc-80a4-dc03f0dfc95d | 8 | public Frame parse(ByteBuffer downloadBuffer) throws WebSocketException {
ByteBuffer buffer = null;
try {
if (State.DONE.equals(state)) {
transitionTo(State.HEADER);
buffer = downloadBuffer;
} else {
buffer = bufferManager.getBuffer(downloadBuffer);
}
if (State.HEADER.equals(state)) {
i... |
9e43efee-2f8c-4f46-bfa4-41d6e015e439 | 0 | public void setSolEstado(String solEstado) {
this.solEstado = solEstado;
} |
9923362f-d14a-4f12-9db8-cd59a71115d3 | 4 | @Override
public boolean equals(Object obj)
{
if(this == obj)
{
return true;
}
if(obj == null)
{
return false;
}
if(!(obj instanceof TSLObject))
{
return false;
}
TSLObject other = (TSLObject) obj;
return objects_map.equals(other.objects_map) && strings_... |
a2aa06d8-f821-4fa7-bb44-ed8eb4418db2 | 9 | private void popWall(MansionArea room, boolean isRoom){
//each wall can contain only one item, and must contain one item
if (isRoom){
if (room.getNorth() == null){
room.addItem(wallItems.getItem(Face.NORTHERN));
}
if (room.getEast() == null){
room.addItem(wallItems.getItem(Face.EASTERN));
}
i... |
da763cc1-18ce-46b7-b19f-27b18d186afb | 6 | public static SampleSet generateData(final int bits, final Random rnd) {
//
final SampleSet result = new SampleSet();
//
final double[] input = new double[bits];
final double[] output = new double[2];
//
final int samples = 1 << bits;
//
for (int ... |
eaa1050b-2f3e-4f77-afee-e1fa687a9f21 | 4 | public Map<Long, Link> getLinks(AreaBox box) {
String queryString;
ResultSet resultSet = null;
HashMap<Long, Link> links;
links = new HashMap<Long, Link>();
queryString = String.format("SELECT id, crossing_id_from, crossing_id_to, meters, lsiclass, tag, maxspeed, long_from, lat_... |
c8c6ed9f-b18a-46c1-8c82-b51eb4f41e2f | 7 | public void onEnable() {
//Basic plugin setup
Server = getServer();
log = Server.getLogger();
setPdfFile(this.getDescription());
//load up our files if they don't exist
moveFiles();
setupPermissions();
//Load our flat file player DB
questPlayerStorage = new iProperty("plugins/uQuest/uQuest_Play... |
a3662c87-4f6c-4e94-a283-33aae22d79e5 | 3 | public void create(Cliente cliente) throws PreexistingEntityException, Exception {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
em.persist(cliente);
em.getTransaction().commit();
} catch (Exception ex) {
... |
c79e9dca-56c6-4655-9326-5fcec1956023 | 9 | public static DataSource inputDataFrom(final Object object) throws IOException {
if (object instanceof DataSource) return (DataSource)object;
if (object instanceof File) return IO._inputDataFrom_((File)object);
if (object instanceof RandomAccessFile) return IO._inputDataFrom_((RandomAccessFile)object);
if (obje... |
8c74c7eb-9fb7-4ed5-8108-cd2d49998fdc | 7 | private void createOutput(){
double maxLog2Score = 0;
double minLog2Score = 0;
//Determine maximum and minimum score
for(BedLine bl: bedLines){
if(bl.getLog2() > maxLog2Score){
maxLog2Score = bl.getLog2();
}
if(bl.getLog2() < minLog2Score){
minLog2Score = bl.getLog2();
}
}
//Set each l... |
8d24ccb5-229f-42c2-bcb0-491c887d871c | 7 | public synchronized void add(Range r) {
Set<Range> toDelete = new HashSet<Range>();
boolean span = false;
for(Range currentRange: this.ranges) {
if (r.getLow() <= currentRange.getHigh() + 1 && r.getLow() >= currentRange.getLow()) {
// if the current range will merge with the low-end of r, se... |
2ceccde9-458f-4f9c-9b5d-deeedd2a808e | 8 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
MethodParamBinding other = (MethodParamBinding) obj;
if (argumentCount != other.argumentCount)
return false;
if (message != other... |
c2f912c2-afb1-48d6-aaa7-15c066f15743 | 0 | public double getGeneration() {
return generation;
} |
da1de5af-2d12-4594-a15a-1dd39ba842d1 | 7 | @Override
public boolean click(int mx, int my, boolean click)
{
if (mouseIn(mx, my) && click)
{
if (!clicked)
{
formDown=!formDown;
clicked = true;
return true;
}
clicked = true;
return false;
}
if(formDown)
{
mouseOver(mx,my);
if(click==true&&overSel>=0)
... |
4663a2cb-5fb4-42f9-b20d-740d250a0f2d | 4 | public void delete(Juego juego){
Partida partida = selectPartida(juego);
List<Nave> naves = partida.getNaves();
List<Escudo> escudos = partida.getEscudos();
List<Invasor> invasores = partida.getInvasores();
try {
label.setText(format("Borrando juego ..."));
... |
bf964a34-61aa-4b22-8792-f51b4846a855 | 6 | private void createDB() {
Connection connection = null;
PreparedStatement statement = null;
try{
Class.forName("org.gjt.mm.mysql.Driver");
connection = DriverManager.getConnection("jdbc:mysql://127.0.0.1/xmltojdbc", "root", "root");
statement = (PreparedStatem... |
1c626ee5-ffd7-44ca-896a-27f38262ab14 | 9 | @Override
public boolean equals(Object obj){
if (obj instanceof Circle){
Circle o = (Circle)obj;
if (pnt.x-rad/2<o.pnt.x && pnt.x+rad/2>o.pnt.x && pnt.y-rad/2<o.pnt.y && pnt.y+rad/2>o.pnt.y ||
pnt.x-rad/2>o.pnt.x && pnt.x+rad/2<o.pnt.x && pnt.y-rad/2>o.pnt.y && p... |
d49d4b52-76c7-4baf-9cc9-36553eaf6b54 | 7 | private void runStatement(Map<Point, Set<Integer>> geoTags, Map<GeoTag, PointTag> tagMap){
GeospatialData [] data = null;
// get multi-data from DB:
if (loader.loadingFeatures){
data = db.getMultiHorizons(geoTags, loader.srdsSource.srdsSrcID);
... |
5032a0f5-3010-4f3d-8347-8c58d40db827 | 4 | private static ArrayList<Integer> getPredictor(int windowLen, int[] finalCluster, int VERBOSE) {
int logFlag = Constants.LOG_PREDICTOR;
// get the last W
int[] keySequence = new int[windowLen];
for (int i=finalCluster.length-windowLen; i<finalCluster.length; i++) {
keySequence[i-finalCluster.length+windowLen... |
d976f9f0-7296-4a6f-807d-011e0a5b342f | 1 | private void compute_pcm_samples5(Obuffer buffer)
{
final float[] vp = actual_v;
//int inc = v_inc;
final float[] tmpOut = _tmpOut;
int dvp =0;
// fat chance of having this loop unroll
for( int i=0; i<32; i++)
{
final float[] dp = d16[i];
float pcm_sample;
pcm_sample = (float)(((vp[5 + ... |
eaf8bc1b-2363-4898-adeb-0c44dee5d7ea | 2 | public double getDouble(int index) throws JSONException {
Object object = this.get(index);
try {
return object instanceof Number ? ((Number) object).doubleValue()
: Double.parseDouble((String) object);
} catch (Exception e) {
throw new JSONException("J... |
e82cd84d-8651-416c-8f62-570eefe25fb6 | 6 | public static void main(String args []){
Board b = new Board();
Move m = new Move();
boolean player1 = true;
//A loop that runs until the board is full or someone has won.
//In each iteration we print the board, call insertMove and change whos turn it is.
whil... |
4f5aff20-b45b-4aae-bb2a-73abd0306096 | 4 | public void popularCmbDepartamentoBuscar() {
ArrayList<String> Departamentos = new ArrayList<>();
DepartamentoBO departamentoBO = new DepartamentoBO();
if (userLogado.getTipo().equals("Diretor")) {
try {
Departamentos = departamentoBO.ComboBoxDepartamentos();
... |
8c8b449d-57d7-47fa-8559-50431f0ed405 | 7 | public Point[] fast (Point[] ptArr, int numPoints, int pointer){
Point origin = ptArr[0];
ptArr[0] = null;
int slope;
Hashtable<Integer, ArrayList<Point>> table = new Hashtable<Integer, ArrayList<Point>>();
for( int i = 1; i < numPoints; i++ ){
if(ptArr[i] == null) continue;
slope = (int) (100.0 * or... |
be151fa8-ad32-4800-8d6f-bae9af74e914 | 8 | public static int findMin(int[] num) {
if (null == num || 0 == num.length) return -1;
int low = 0, high = num.length - 1;
if (1 == num.length) return num[0];
if (num[low] < num[high]) return num[low];
while (low <= high) {
if (low + 1 == high)
return num[low] ... |
3f5747c6-3e24-478f-9bc9-729b98852447 | 9 | private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed
int confirmar = JOptionPane.showConfirmDialog(null, "Deseja Salvar?","Deseja Salvar?", JOptionPane.OK_CANCEL_OPTION);
if (JOptionPane.OK_OPTION == confirmar){
if(txtD... |
27d78cdf-d52c-483e-b37b-31e2cdad69c4 | 5 | private int handleR(String value,
DoubleMetaphoneResult result,
int index,
boolean slavoGermanic) {
if (index == value.length() - 1 && !slavoGermanic &&
contains(value, index - 2, 2, "IE") &&
!contains(value, in... |
bef01fef-d2aa-4137-abe6-6f9a44ff98d5 | 4 | public boolean sendData(Object data) {
boolean status = true;
TCPServer tcpServer;
for (int i = 0; i < tcpServers.size(); i++) {
tcpServer = tcpServers.get(i);
if (tcpServer != null) {
if (tcpServer.readyForUpdates) {
if (!tcpServer.s... |
438b19a3-bd79-4f10-9fd2-6c454611e9cd | 5 | public boolean permGen(int[] array) {
// Find longest non-increasing suffix
int i = array.length - 1;
while (i > 0 && array[i - 1] >= array[i])
i--;
// Now i is the head index of the suffix
// Are we at the last permutation already?
if (i <= 0)
return false;
... |
dd894ee7-390f-433e-8f88-43402e08b696 | 3 | public void checkGroup(GroupSettings settings, CheckReport report)
{
EntityConcentrationMap map = new EntityConcentrationMap(settings, this);
report.waitForGroup(settings);
for(World world : Bukkit.getWorlds())
{
if(allowWorldGlobal(world) && settings.allowWorld(world))
map.queueWorld(world);
}
... |
4be3527f-788b-4149-b9b1-913c41c5ec52 | 6 | @Override
protected boolean finishTask() throws Throwable
{
URL url = ParseHelper.asURL(this.getAddress());
if (url == null)
{
this.response = 404;
return true;
}
URLConnection con = url.openConnection();
HttpURLConnection http = (con instanceof HttpURLConnection) ? (HttpURLConnection)con ... |
e8744452-9a0c-4708-b7d9-ba961581ff6d | 7 | public ListadoPartidosPosibles(ArrayList<Jugador> jugadores, boolean idaV){
listado = new ArrayList<Partido>();
marcador = new HashMap<Partido, Boolean>();
Partido p, pAux;
total = 0;
idaVuelta = idaV;
boolean anadir = false;
for (Jugador j1: jugadores)
for (Jugador j2: jugadores)
if (!j1.equ... |
83b74da1-a767-4660-9a17-2015016cbd5e | 9 | public void lossyFilterTriple(int lim) {
System.out.println("Determinating filters and applying lossy filter...");
long initTime = System.currentTimeMillis();
lossy = lim;
if (lineFilter == null) { filterDeterminate(); }
int slim = 1 << (lim - 1);
int mod = (1 << lim) + 1;
int exL = mod - 1;... |
01a9a3e4-11a7-4e7c-a7d6-cfdff184d553 | 7 | @Override
public void deserialize(Buffer buf) {
lifePoints = buf.readInt();
if (lifePoints < 0)
throw new RuntimeException("Forbidden value on lifePoints = " + lifePoints + ", it doesn't respect the following condition : lifePoints < 0");
maxLifePoints = buf.readInt();
if... |
14038acd-fff1-41aa-8980-66e4b5a870f7 | 6 | private int newHole(int hole, T element){
int left = (hole * 2) +1; //left child
int right = (hole * 2) +2; //right child
if(left > lastIndex)
//hole has no childern
return hole;
else
if(left == lastIndex)
//left child only
... |
9850231e-fa4c-4d45-a4cc-77b0182e8b82 | 7 | @Override
public MapConnector<String, Integer> putAll(final Map<? extends String, ? extends Integer> map) throws Exception {
super.addSQLJob(new SQLJob<String, Integer>() {
@Override
public void executeJob(Connection con, Map<String, Integer> internalMap) throws SQLException {
... |
c96fd604-cb8d-46df-a4af-706eef722add | 7 | public static ArrayList<ArrayList<String>> createListFromSameLetterString(
String s, ArrayList<ArrayList<String>> allLists, int length) {
if (length == 0) {
return new ArrayList<ArrayList<String>>();
}
String letter = s.substring(0, 1);
allLists = createListFromSameLetterString(s, allLists, length - 1);
... |
4090bf20-0d45-4e3b-bbed-00ad4d8aba0e | 7 | @Test
public void ifSpotNotFreePlaceNearBy()
{
Positioned p = new Positioned(64,64,1,1);
list.addEntity(p);
list.addEntity(new Positioned(64,64,1,1));
p.findNearestFreeSpot();
assertTrue( (p.X() == 66 && p.Y() == 64) ||
(p.X() == 64 && p.Y() == 66) ||
... |
7220d07e-27bd-4174-9841-78905fd9cccf | 9 | @Override
public void mouseMoved(MouseEvent e) {
for(CButton btn : buttons){
if(btn.isEnabled() && isBetween(btn.getX(), e.getX(), btn.x1) && isBetween(btn.getY(), e.getY(), btn.y1)){
btn.showHover = true;
}else
btn.showHover = false;
}for(CTextBox txt : textboxes){
if(txt.isEnabled() && ((txt.has... |
cb0a9bcc-ca86-43fe-aade-7c1bd20014c0 | 9 | private static void reverse(String player, int row, int col, int[][] revList, int countRev) {
for (int i=0; i<countRev; i++) {
switch (revList[i][2]) {
case 0: reverse0(revList, row, col, player, i); break;
case 1: reverse1(revList, row, col, player, i); break;
case 2: reverse2(revList, row, col, p... |
90d0ed60-931d-4e10-ba11-d9aa53a5231d | 8 | public void testBean(Object instance) throws Exception {
List<Field> fields = getFields(instance);
StringBuilder message = new StringBuilder();
boolean alert = false;
message.append("Testing " + instance.getClass().getSimpleName() + "\n");
for (Field field : fields) {
field.setAccessible(true);
Meth... |
e9a6ae6b-769d-4f67-a69b-fa1c96337fbf | 6 | public static String getIpInfo(String ip) {
if (ip.equals("本地")) {
ip = "127.0.0.1";
}
String info = "";
try {
URL url = new URL("http://ip.taobao.com/service/getIpInfo.php?ip=" + ip);
HttpURLConnection htpcon = (HttpURLConnection) url.openConnection();
htpcon.setRequestMethod("GET");
htpcon.setD... |
7a0c66d6-2503-45fb-82de-b4445b4086d2 | 0 | @Override
public void setDbDriverNname(String dbdrivername) {
this.dbdrivername = dbdrivername;
} |
3438bd16-9cc6-4dd7-810e-2215b884bd79 | 2 | private byte[] encodeBase64 (File file, boolean isChunked)
throws IOException {
byte[] buf = null;
if (!file.isFile())
throw new IOException(file.getAbsolutePath() + ": is not a file.");
buf = new byte[(int) file.length()];
FileInputStream in = new FileInputStre... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.