method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
600eaeed-f4bc-4a35-9129-498f44ae036d | 0 | @Override
public void mousePressed(MouseEvent e)
{
this.requestFocusInWindow();//request focus when the user clicks on a date
clicked(e.getX(),e.getY(), e.getClickCount());
} |
66f99d2f-6d18-40f7-93cf-67456537841a | 9 | public void node_free(int fidx, int size)
{
int idx, pidx = 0;
FREE start;
if (size <= 0 || fidx <= FREE_NODE) {
System.err.println("node_free: wrong parameter");
System.exit(0);
}
idx = free_head.next_idx;
if (idx == FREE_NODE) {
// if there was no free nodes, simply updates the header pointer ... |
a97e1a84-029b-4247-b4ec-6957166ee363 | 8 | public void update(){
if(JudokaComponent.input.up) selectedItem --;
if(JudokaComponent.input.down) selectedItem ++;
if(selectedItem > items.length - 1) selectedItem = items.length - 1;
if(selectedItem < 0) selectedItem = 0;
if(JudokaComponent.input.enter && selectedItem == 0) JudokaComponent.stop();
else if... |
b8ab1000-184a-430f-b73b-17cf30931d7c | 8 | @Override
public void mouseReleased(MouseEvent e)
{
JButton sourceButton = (JButton) e.getSource();
switch (sourceButton.getName())
{
case "Start":
start = mPlayer.getTime();
sourceButton.setText("Sequence Start: " + start);
parent.repaint();
br... |
9063b78e-9716-485c-bede-e65aa5111bfd | 7 | private static void getParametersFromFile(modelparameters ldaparameters,
String parameterFile) {
// TODO Auto-generated method stub
ArrayList<String> paramLines = new ArrayList<String>();
FileUtil.readLines(parameterFile, paramLines);
for(String line : paramLines){
String[] lineParts = line.split("\t");
... |
4e3176d6-37fb-4552-ac29-47d8cdaf6c5c | 4 | public static Vector2D getLineIntersect(Line2D line, Line2D other) {
float m1 = line.getGradient();
float m2 = other.getGradient();
//gradient inf and nan tests
////////////////////
boolean m1NaN = Float.isNaN(m1);
boolean m1Inf = Float.isInfinite(m1);
boolean m... |
aad64475-e8c8-4eb8-9634-c2af1685c90b | 1 | public NodeList getData(String resource) {
if(!data.containsKey(resource)) {
loadData(resource);
}
return data.get(resource);
} |
a7c0b984-03a7-4994-a324-2dea99d695c7 | 0 | private void registerService() throws Exception {
ServiceManager
.getServices()
.initializeServices(new Object[] {
new TestRailwayRepository(),
new TestTicketPoolManager()});
} |
14e27e09-209a-437f-9232-7d71739fbb8a | 2 | public void newGame() {
// Set the label's text that represent the player names
P1_Name.setText(Game.getThis().Player1.getName());
P2_Name.setText(Game.getThis().Player2.getName());
// Clear the Cards JPanel
this.clearBoard();
// Add the new buttons to the Cards JPanel
final int SIZE = Game.getThis(... |
c0bb2a19-842e-42f2-8c74-d536df7ece58 | 9 | private void performRebalance(Stack nodeTrace) {
Node n = (Node) nodeTrace.pop();
Node parent;
do {
if (nodeTrace.size() == 0) {
parent = null;
} else {
parent = (Node) nodeTrace.pop();
}
//RebalanceIndex berechnen... |
090c509f-8a36-4906-89c4-db819d05e281 | 9 | @Override
public void keyPressed(KeyEvent e) {
int code = e.getKeyCode();
switch (code) {
// case KeyEvent.VK_Z: H -= 10; paintComponent(getGraphics()); break;
case KeyEvent.VK_Z: H -= 10; getW(); break;
case KeyEvent.VK_S: H += 10; repaint(); getW(); break;
case KeyEvent.VK_Q: W -= 10; invalidate()... |
2f164f67-4a2a-45fe-9044-aff49bf2ad5f | 7 | public String paint()
{
if (done) repaint();
g.fillRect(0, 0, width, height); // Fill the picture with white
long startTime = new Date().getTime();
if (words.size() == 0)
{
return "No Keywords Found!";
}
int drawn = 0;
setSize(); // Reset make is the size of the font
if (update) observer.imageUp... |
4d825f05-381b-44a2-81f4-c7ecb4ed1269 | 8 | public void sendToChannel(String message, int roomnumber, String currentname, Socket socket, String roomname){
if((rooms.get(roomnumber-1)).containsKey(currentname) || currentname.startsWith("tempcheck")){
synchronized(rooms.get(roomnumber-1)){
//Get all streams and write to them
for(Enumeration e = getChanne... |
df4551d3-d400-4ca0-87d8-d6ac43b0847c | 4 | public void tick()
{
if(value > dValue) {
dValue = increase ? dValue + 0.01f : value;
}
else if(value + 0.01 < dValue) {
dValue = !increase ? dValue - 0.01f : value;
}
} |
9a6633b6-04ca-49bf-9819-c3c1d3b7580c | 3 | public static Properties createDefault(Object comp) {
Properties p = new Properties();
ComponentAccess ca = new ComponentAccess(comp);
// over all input slots.
for (Access in : ca.inputs()) {
try {
String name = in.getField().getName();
Object ... |
c6bac6eb-2854-47fd-8b46-fb62f744b3c4 | 5 | public CycList treeGather(Class cls) {
final CycList result = new CycList();
final Stack stack = new Stack();
stack.push(this);
while (!stack.empty()) {
final Object obj = stack.pop();
if (cls.isInstance(obj)) {
result.add(obj);
} else if (obj instanceof CycList) {
CycL... |
9bb49391-ceb2-4186-ae38-7d9d4ebc258c | 4 | private void gameRender() throws CanvasException {
if (oImg == null) {
if (VectorWorld.DEBUG_GFX) {
System.err.println("oImg is null");
}
throw new CanvasException("oImg is null");
}
oImg.flush();
offscreen = oImg.createGraphics();
... |
67d53bb6-2494-4706-9135-444a81e15ead | 5 | private String[] grabLines(Integer[] lines, InputStreamReader reader)
{
BufferedReader br = new BufferedReader(reader);
List<Integer> lineList = Arrays.asList(lines);
Collections.sort(lineList);
int currentLine = 1;
String line;
int selectIndex = 0;
String[] selectedLines = new String[lines.length];
... |
629a4248-62bb-4e2f-8b13-ddb4a545d0fc | 2 | public void squish() {
// Fill in your solution here. (Ours is eleven lines long.)
SListNode currentNode;
int count=0;
currentNode=head;
while (currentNode.next != null) {
if(nth(count).equals(nth(count+1))){
currentNode.next.next=currentNode.next;
}
count++;
... |
1effd9df-8fe0-43b3-a450-4d871b3a7938 | 6 | public void end(){
if(GlobalController.aiRun&&ann!=null){
System.out.println("This AI's score was "+xOffset);
new CMDTester(ann.getNet());
}
if(GlobalController.evolving&&ann!=null){
if(ann==null)
System.out.println("ERROR 1");
else... |
cdc43e44-2839-42c5-b2c5-4aeb8f1d9a0a | 4 | public static void main(String[] args) {
String s = "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233... |
d813e148-2f85-4f2a-99ae-85d1d602f34b | 1 | public boolean equals(Object o) {
return o instanceof Individual &&
id == ((Individual)o).id;
} |
ce6019c0-308d-4d1a-864d-18d1694d9653 | 7 | private static void test1_2() throws FileNotFoundException {
String test1 = "quit\n"+"no\n"+"quit\n"+"yes\n";
HashMap<Integer, String> output = new HashMap<Integer, String>();
boolean passed = true;
try {
in = new ByteArrayInputStream(test1.getBytes());
System.setIn(in);
out = new PrintStream("tes... |
5c930a8d-d65e-4a4e-868d-13dd7a742dd6 | 0 | public static String webPageTail(){
return "</page_html_code>" + ln;
} |
d4d31bda-ea89-4acc-aae0-3b6b629c7dea | 4 | @Override
public int observed(String sequence) {
int count = 0;
// Count CHH in this sequence
char bases[] = sequence.toUpperCase().toCharArray();
for( int i = 0; i < bases.length - 2; i++ )
if( (bases[i] == 'C') && (bases[i + 1] != 'G') && (bases[i + 2] == 'G') ) count++;
return count;
} |
88e2cd3b-b6bf-4ccb-8387-73a259dc64d4 | 9 | public List getBoardCommentaryList(int idx) throws Exception{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
List commList = null;
String sql = "";
BoardDataBean comm = null;
try{
conn = getConnection();
sql = "select * from boardcommentary where idx=? order by num des... |
288a8a17-92e3-4024-804c-4551d9b927da | 2 | public BigWigDataBlock(SeekableStream fis, RPTreeLeafNodeItem leafHitItem,
HashMap<Integer, String> chromosomeMap, boolean isLowToHigh, int uncompressBufSize){
this.leafHitItem = leafHitItem;
this.chromosomeMap = chromosomeMap;
this.isLowToHigh = isLowToHigh;
fileOffset = th... |
3b2e3104-c07f-45cc-8a8f-3f502c18ebf2 | 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... |
37f137e8-e813-4d99-b623-68b42e04ace5 | 6 | public boolean moveRook(int[][]board, int[]locations, int sx, int sy, int x, int y) {
if (checks.onBoard(x, y) && checks.empty(locations, x, y)) {
if (sx == x && checks.rookCheckVertical(board, sx, sy, x, y)) {
return true;
}
if (sy =... |
a87783dd-2717-4823-81fd-a54b052861b4 | 3 | public MainGui() {
setLayout(new BorderLayout(9, 4));
Panel optionPanel = new Panel(new GridLayout(4, 5, 4, 4));
int length = ESARuleSet.basicWordPairs.length;
checkBoxs = new JCheckBox[length];
for (int i = 0; i < length; i++) {
checkBoxs[i] = new JCheckBox(ESARuleSet.basicWordPairs[i].word);
opti... |
1dcfc1dd-e468-4b1e-95a5-dd535d32479c | 5 | private int[][] addMatrix(final int[][] X, final int[][] Y) {
try {
int[][] addition = new int[X.length][X[0].length];
if (X.length == Y.length) {
for (int i = 0; i < X.length; ++i) {
if (X[i].length == Y[i].length) {
for (int j... |
81e0afdd-1aab-42f7-899a-360ce2b5a2df | 2 | private int findMonth (String input) { // method to extract month # information
Scanner s = new Scanner (input);
int[] date = new int[3];
s.useDelimiter("/");
while(s.hasNext()) {
for (int i = 0; i < date.length; i++) {
date[i] = s.nextInt();
}
}
s.close();
return date[0];
} |
b539abff-0421-4066-87b9-f1862aaa1dba | 8 | public boolean getIsAnyLiquid(AxisAlignedBB var1) {
int var2 = MathHelper.floor_double(var1.minX);
int var3 = MathHelper.floor_double(var1.maxX + 1.0D);
int var4 = MathHelper.floor_double(var1.minY);
int var5 = MathHelper.floor_double(var1.maxY + 1.0D);
int var6 = MathHelper.floo... |
ee9d4007-5e88-4457-8dcb-3d2692e514f5 | 1 | public static void processRedirectRequest(String redirectedUrl) {
if (!urlMap.containsKey(redirectedUrl)) {
urlMap.put(redirectedUrl, 1);
} else {
urlMap.put(redirectedUrl, urlMap.get(redirectedUrl) + 1);
}
} |
6720fa35-edcd-4ce7-b327-b5f294a98e02 | 7 | void split(int splitNumber, long start, long end) {
// Split file name
String splitFileName = String.format("%s/%s.%03d.%s", dirName, baseName, splitNumber, ext);
if ((dirName == null) || dirName.isEmpty()) splitFileName = String.format("%s.%03d.%s", baseName, splitNumber, ext);
if (verbose) Timer.showStdErr("S... |
2b7ac130-5be3-40db-8eda-3e1d85c46234 | 7 | @Override
public void processEventCoalecent(LineageState state) {
// we need to move linages from deme to demeLabel with
// probablity q=1-p.
assert demeLabel == state.getDemeCount() || demeLabel + 1 == state.getDemeCount();
// need to do this for the rather odd case where we use this in the
// first model. ... |
0044880a-c966-4261-ac08-a4b2ae94d5cc | 3 | public UnigramCountsModel<String> getWordToState(String s,String rawS) {
if (s==null)
{ return null; }
UnigramCountsModel<String> stateModel=UnigramTokenToEntityCounts.get(s);
if (stateModel==null) {
stateModel=UnigramTokenToEntityCounts.get(getMysteryString(rawS));
}
if (stateModel==null) {
state... |
534e9e01-5af3-4696-88d4-91b5c35b5964 | 1 | public void testRowCount() {
DataSet ds = null;
try {
final TabDelimited testTab = new TabDelimited();
ds = testTab.getDsForTest();
// check that we parsed in the right amount of rows
assertEquals(2, ds.getRowCount());
} catch (final Exception ... |
c6d9816e-0eb6-467c-89a2-d95b1f400b79 | 1 | public static void addErrorMessages(List<String> messages) {
for (String message : messages) {
addErrorMessage(message);
}
} |
9d5c53aa-4444-446d-836d-67f875196205 | 2 | public boolean equalsExpr(final Expr other) {
return (other instanceof StackExpr)
&& ((StackExpr) other).type.simple().equals(type.simple())
&& (((StackExpr) other).index == index);
} |
2c93ea6f-fccf-4a3f-9bfb-801584a2f03a | 4 | @Test
public void testBuscarProduto(){
Produto produto = null;
try {
produto = facade.buscarProduto(5);
Assert.fail("deveria ter lanÁado uma exceÁ„o");
} catch (FacadeException e) {
Assert.assertNull(produto);
}
try {
produto = facade.buscarProduto(1);
Assert.assertEquals(899.00f, produto.getV... |
8399d8ec-a915-4a56-ab4d-d75314a23d74 | 9 | public boolean insert(Key k, int altId) throws InterruptedException {
if (transId != Thread.currentThread().getId()) {
String s = "";
s = "";
}
Globals.lockManager.exclusiveLock("n" + id(), Thread.currentThread()
.getId());
Node alNode = null;
if (altId != -1) {
Globals.lockManager.sharedLock("n... |
53bfc0af-b442-465f-861c-58c6fd229f02 | 5 | public void run() {
long lastTime = System.nanoTime();
double nsPerTick = 1000000000D/60D;
int ticks = 0;
int frames = 0;
long lastTimer = System.currentTimeMillis();
double delta = 0;
init();
while(running){
long now = System.nanoTime();
delta += (now-lastTime)/nsPerTick;
lastTime ... |
3acb741d-5a22-4006-a337-4fb48439f07a | 4 | @SuppressWarnings("resource")
public int getTestName(DataSource ds) {
int type_id = 0;
while (true) {
try {
System.out.print("Back = 0. Enter test name: ");
Scanner s = new Scanner(System.in);
String test_name = s.nextLine();
if (test_name.equals("0")) {
return 0;
}
int test_id = ds... |
e8844976-121d-4a7e-b797-3620bdbe689b | 8 | private void loadImgLevel(BufferedImage img) {
int w = img.getWidth();
int h = img.getHeight();
for (int stepX = 0; stepX < w; stepX++) {
for (int stepY = 0; stepY < h; stepY++) {
int pixel = img.getRGB(stepX, stepY);
int red = (pixel >> 16) & 0xff;
int green = (pixel >> 8) & 0xff;
int blue = (pixel) ... |
0e20e79f-6c3e-4198-9479-944735d23106 | 5 | public static Map<OPTCODE,String> scanConfiguration(String s[])
{
Map<OPTCODE,String> cmdmap = new HashMap<OPTCODE,String>();
int i=0;
while (i<s.length-1)
{
String opt = s[i];
if (opt.startsWith("-") && (opt.length()>0))
{
try
{
opt = opt.substring(1).toLow... |
438234c0-0fe3-4fc0-a1e8-ed9b44782da7 | 5 | public void eot()
{
if ( getReadyState() == READYSTATE.NOT_YET_CONNECTED )
{
closeConnection( CloseFrame.NEVER_CONNECTED, true );
}
else if ( flushandclosestate )
{
closeConnection( closecode, closemessage, closedremotely );
}
else if ( draft.getCloseHandshakeType() == CloseHandshakeType.NONE )
{... |
4f08a8a3-5266-4b78-8038-6eef40ae83a9 | 3 | public static boolean substringMatch(CharSequence str, int index, CharSequence substring) {
for (int j = 0; j < substring.length(); j++) {
int i = index + j;
if (i >= str.length() || str.charAt(i) != substring.charAt(j)) {
return false;
}
}
return true;
} |
97dedd06-16c5-44e2-8b58-33235db937c0 | 2 | public static void test(GameBoard board, Color[] boardArrangement) {
board.clear();
board.draw();
for (int r = 0; r < 6; ++r) {
for (int c = 0; c < 7; ++c) {
board.setColor(r, c, boardArrangement[(r*7)+c]);
}
}
System.out.println("The winner is "+board.hasWon());
} |
72a32cad-6d14-47ef-9e6f-1f2e1d022dbb | 2 | private boolean isValidDirectory(File dir) {
if (!dir.exists()) {
System.err.println("Directory doesn't exist: " + dir.getAbsolutePath());
return false;
} else if (!dir.isDirectory()) {
System.err.println(dir.getAbsolutePath() + " is not a directory");
ret... |
9b491730-893a-43e7-adc5-7bb2a23e4ae6 | 3 | public void method456(int timePassed) {
aBoolean1579 = true;
aDouble1585 += aDouble1574 * timePassed;
aDouble1586 += aDouble1575 * timePassed;
aDouble1587 += aDouble1577 * timePassed + 0.5D * aDouble1578 * timePassed * timePassed;
aDouble1577 += aDouble1578 * timePassed;
... |
9f12ec1b-588c-433b-bb77-da00d1fd6649 | 3 | public void collision(CollisionEvent e) {
if (e.getType()==CollisionEvent.TYPE_TARGET && e.getSource()!=null) {
if (e.getSource() instanceof Bullet) {
// The collision has really been caused by a bullet!
Bullet bullet=(Bullet) e.getSource();
Plant plant=(Plant) e.getOb... |
ea7673b2-df4f-47cf-9acb-7ac1ce3c5de7 | 5 | private void listar_Impresoras (){
String [] separada;
separada = jComboBox1.getSelectedItem().toString().split("-");
int modulo = Integer.parseInt(separada[0].trim());
r_con.Connection();
Vector<Vector<String>>v = r_con.getContenidoTabla("SELECT * FROM impresoras WHERE imp_id_modulo = "+modulo);
... |
dac63c1e-dcfb-4b9a-811d-da45eb1cce5f | 9 | public DataTypeInfo getDataTypeInfo(String dataSectionName)
{
if (dataSectionName == DATA_SECTION_VERTEXES) { return vertexDataTypeInfo; }
else if (dataSectionName == DATA_SECTION_FACETS) { return facetDataTypeInfo; }
else if (dataSectionName == DATA_SECTION_FACET_DATA_EXTRA) { return facetD... |
b46919c3-baf0-492a-a7cb-1b30d091abf1 | 2 | public void immediateAction(Action action) {
switch (state) {
case IN_OVERWORLD:
applyAction(game.player.world_position, action);
break;
case IN_DUNGEON:
applyAction(game.dungeonHandler.getActiveDungeon().getActiveFloor().getPlayerPosition... |
539d55c7-9f42-4599-89df-e82a9c4a00df | 9 | public void buildClassifier(Instances insts) throws Exception {
// can classifier handle the data?
getCapabilities().testWithFail(insts);
// remove instances with missing class
insts = new Instances(insts);
insts.deleteWithMissingClass();
// Compute mean of target value
double yMean =... |
4b4de449-c227-4041-a462-a7d000cffb64 | 1 | private static String getStringFromDocument(Document doc) {
try {
DOMSource domSource = new DOMSource(doc);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
... |
43034aee-bf33-497b-ac69-06558968cc55 | 8 | @Override
public void handleRecall(CMMsg msg)
{
final MOB recallingMob=msg.source();
final Room recallingRoom=recallingMob.location();
if((msg.target() instanceof Room)
&&(recallingRoom!=null)
&&(recallingRoom != msg.target()))
{
final Room recallToRoom=(Room)msg.target();
recallingMob.tell(msg.sour... |
849a89ec-f8da-4315-b89e-64a9decb6546 | 0 | @Override
public void run() {
//TODO: Loop through Console commands
// - print all commands user can use
} |
f30d49de-9d47-47ea-b83e-7833f1d7359e | 6 | public static void main(String[] args) {
FileParser fileParser = FileParser.getInstance();
while(true){
BufferedReader bufferRead = new BufferedReader(new InputStreamReader(System.in));
try {
System.out.println("Geef path van bestand"... |
594b8abe-200f-481e-9d3d-8a634fe002d4 | 2 | @Override
public FractalValue add(FractalValue val) throws FractalException {
if (! val.isNumber()) {
throw new FractalTypeException(FractalTypes.REAL, val.getType());
} else if (val.isInt()) {
return new FractalInt(intValue() + val.intValue());
} else {
r... |
d0ca24aa-a6cd-46dd-916d-512718132bf7 | 0 | @Override
public void execute(VirtualMachine vm) {
vm.setPc(address - 1);
} |
80396125-8ac0-44f8-8189-465d8c54da32 | 3 | public String read(String filename) {
if (true == namenode.exits(filename)) {
String data = new String();
List<String> chunk_uuids = (List<String> ) namenode.filetable.get(filename);
for (Object chunk_uuid : chunk_uuids) {
int chunkloc = (Integer) namenode.chunktable.get(chunk_uuid);
String data_temp... |
71efc5b8-cb63-484c-8945-bde21bd1bce4 | 1 | @Override
public T next() {
if(_index < this._source.length)
{
T rs = this._source[this._index];
this._index ++;
return rs;
}
else
{
throw new NoSuchElementException();
}
} |
835058ae-7ba0-454a-b5ac-0722199cbfea | 8 | protected void encodeValue(mxCodec enc, Object obj, String fieldname,
Object value, Node node)
{
if (value != null && !isExcluded(obj, fieldname, value, true))
{
if (isReference(obj, fieldname, value, true))
{
Object tmp = enc.getId(value);
if (tmp == null)
{
System.err.println("mxObject... |
81246a23-11d2-44cf-bf3f-bb3c1710689b | 1 | public void displayBook()
{
System.out.println("ISBN -->> BOOK NAME -->> AUTHOR NAME -->> RESERVATION STATUS\n");
for(int i=1;i<=5;i++)
B[i].display();
} |
6978237b-273f-469a-9003-653df28ed9b5 | 0 | public void method4() {
System.out.println("ClassB method4()");
} |
35450079-a711-4688-afdc-dfa96db2fadc | 3 | private boolean within(int[] area)
{
return area[2] <= y && area[3] >= y && area[0] <= x && area[1] >= x;
} |
8dcc0f6e-015c-43ab-853d-968564a5f9f1 | 1 | public ArrayList<Integer> getPars() {
ArrayList<Integer> pars = new ArrayList<Integer>();
for (int i = 0; i < getNumberOfHoles(); i++) {
pars.add(holes.get(i).getPar());
}
return pars;
} |
ad308c0b-2a4b-47b7-9196-480349f5dfaa | 2 | private static void createMonitoringAgents(ContainerController mc) {
System.out.println("Launching the rma agent on the main container ...");
AgentController rma;
try {
rma = mc.createNewAgent("rma", "jade.tools.rma.rma", new Object[0]);
rma.start();
} catch (StaleProxyException e) {
e.printStackTrac... |
3dec5805-c9a4-4b69-b919-35fc940db512 | 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... |
69d44304-f5a8-42b1-a44d-78f4d3debf6d | 1 | public Double getMod() {
Double sum = 0D;
for (Double element : components) {
sum += Math.pow(element, 2);
}
return Math.sqrt(sum);
} |
d273a21e-6a9f-4883-9cdb-207e1becbed0 | 2 | public Panel()
{
//tile = new Tile(250,200);
setPreferredSize(fieldDim);
setBackground(Color.WHITE);
setFocusable(true);
requestFocus();
tiles = new Tile[64][64];
Scheme.getInitData();
//here we initialize every tile
for (int i = 0; i ... |
badd43ea-c5f0-4d21-a692-dc92fa493ef6 | 4 | public static int getPartsHp(List<Partition> lop) {
int ret;
if (lop.size() == 1)
ret = lop.get(0).getHyperPeriod();
if (lop.size() == 2)
ret = MathUtils.lcm(lop.get(0).getHyperPeriod(), lop.get(1)
.getHyperPeriod());
ret = MathUtils.lcm(lop.get(0).getHyperPeriod(), lop.get(1)
.getHyperPeriod(... |
3b1f5584-fea2-49f1-9276-75931ca16102 | 9 | private void findNext() {
if (iter1 == null || iter2 == null) {
next0 = null;
return;
}
T next1 = null;
T next2 = null;
while (true) {
if (next1 == null) {
if (! iter1.hasNext()) {
iter1 = null;
next0 = null;
return;
}
next1 = i... |
97cf1f8f-022c-495c-82eb-14df1e930e7c | 2 | protected String joinLines(final String line1, final String line2) {
if (line1 == null) {
throw new IllegalArgumentException("parameter string1 may not be null");
}
final StringBuilder result = new StringBuilder(line1);
result.append(lineSeparator);
if (line2 != null... |
5b9f8f15-0426-4b2b-82ae-28cc567c1bb5 | 6 | public static Map export(Element element) throws Exception {
if (element == null || !element.active) {
return null;
}
Map data = new HashMap();
if (element instanceof Wall) {
data.put("type", "wall");
} else if (element instanceof Bomb) {
data... |
96050e91-8957-4334-b440-88100302995b | 1 | public InputStream getRawID3v2()
{
if (rawid3v2 == null) return null;
else
{
ByteArrayInputStream bain = new ByteArrayInputStream(rawid3v2);
return bain;
}
} |
be673c2d-1e3d-4b86-9853-c0984ca86eda | 8 | @Override
public double convertTo(int type) {
switch (type) {
case UnitConstants.FEET_SECOND:
return getValue() * 0.9113444;
case UnitConstants.FEET_MINUTE:
return getValue() * 54.68066;
case UnitConstants.MILES_MINUTE:
ret... |
daac04c7-fc09-45e0-93f4-82ce679fb5ec | 6 | public static void main(String args[]) {
/* Set the Windows 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://dow... |
12c9be51-970b-4494-8503-e1013fb5e37e | 4 | private void doMousePressed(MouseEvent event) {
scrollbar.setValueIsAdjusting(true);
captureCurrentMousePosition(event);
if (getThumbBounds().contains(iMousePoint)) {
doMousePressedOnThumb();
} else if (getSupportsAbsolutePositioning() && SwingUtilities.i... |
ff5a4b12-1f3e-4ad4-835b-2b854361840f | 7 | private boolean fill() throws IOException {
int r;
if (bStart < bEnd || empty && bStart == bEnd) {
if (empty) {
bStart = 0;
bEnd = 0;
}
r = in.read(buffer, bEnd, BUFFER_SIZE - bEnd);
} else if (bS... |
3fbd9be0-134a-4fc4-b347-59413729ec6b | 3 | public static void checkForUpdates() {
long now = new Date().getTime();
if (lastUpdateCheck + 3600000 > now) {
return;
}
lastUpdateCheck = now;
new Thread(new Runnable() {
@Override
public void run() {
BmTestManager bmTestManag... |
58f1c64b-2595-4ca6-a500-849ae6160c18 | 7 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Product product = (Product) o;
if (name != null ? !name.equals(product.name) : product.name != null) return false;
if (sku != null ? !sku.equal... |
2540cc7a-c8c6-4acf-b277-244edb6b743a | 3 | public void readMagicItem() {
// creating the list manager, classified as listMan1
ListMan listMan1 = new ListMan();
listMan1.setName("Magic Items");
listMan1.setDesc("Enchanted Items that seem both cool and scary.");
final String fileName = "magicItems.txt";
readmagicItemsFromFileToList(fileName, listM... |
7073a790-7bea-48e7-828a-656e6af2cb95 | 7 | protected void randomizeFolders(String romId, ByteStream rom,
ChipLibrary library) {
// Randomize Folder
ItemProducer chipProducer
= new BN456RewardProducer(library);
FolderProducer producer
= new FolderProducer(chipProducer);
FolderProvider provider
= new FolderProvider(this, producer);
Repeat... |
8fb8c59a-f977-4fec-b06c-5efde4c25cae | 1 | public void sqlUpdate(String sql) {
try {
Statement stat = (Statement) conn.createStatement();
stat.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} |
1354d00a-2de3-4d43-b88f-aef3671cd663 | 7 | protected void processMinMaxRecordTime() {
if (this.javaDate == null) {
return;
}
final Calendar cal = GregorianCalendar.getInstance();
cal.setTime(this.javaDate);
if (this.minRecordTime == null) {
this.minRecordTime = this.javaDate;
} else {
final Calendar calchk2 = GregorianC... |
c19da1a7-3509-4cc7-abee-49913c193309 | 4 | @Override
public void display(Boolean showCorrect) {
System.out.println(prompt);
int count = 1;
for (int key: items.keySet()){
System.out.println("\t" + count + "). " + items.get(key));
++count;
}
if (hasAnswer && showCorrect){
System.out.println("The correct ranking is:");
for (int key=1; key <=... |
8bb000a4-5c86-4e71-8a20-e5d5d3464125 | 6 | public static BeanInfo get(Class<?> cls) {
synchronized(cache) {
BeanInfo info = null;
Map<Class<?>, BeanInfo> map = cache.get(cls.getClassLoader());
if (map == null) {
map = new LinkedHashMap<Class<?>, BeanInfo>(16, 0.75f, true) {
protected boolean removeEldestEntry(Map.Entry<Class<?>, BeanInfo> el... |
86bc8f4d-0454-43fd-9a69-8362716b052a | 2 | public static Production[] getProductionsWithVariableOnRHS(String variable,
Grammar grammar) {
ProductionChecker pc = new ProductionChecker();
ArrayList list = new ArrayList();
Production[] productions = grammar.getProductions();
for (int k = 0; k < productions.length; k++) {
if (ProductionChecker.isVaria... |
3e429c16-de7a-4a6d-8ddc-96185a2830e0 | 0 | public LogFileMessageFormatter getLogFileMessageFormatter() {return this.msgFormatter;} |
17d380f0-64de-468f-b3aa-cfba026be2be | 0 | @Override
public Socket getSocket() {
return socket;
} |
69714311-8cf1-4903-941b-33927eec820c | 5 | private static boolean isIntegral(JsonPrimitive primitive) {
if (primitive.value instanceof Number) {
Number number = (Number) primitive.value;
return number instanceof BigInteger || number instanceof Long || number instanceof Integer
|| number instanceof Short || number instanceof Byte;
}... |
668fe2e3-7eb3-4829-9053-60c20330faa7 | 6 | protected FileBlob findLatest(String dirName) throws FileNotFoundException {
long latestNumber = -1;
FileBlob latest = null;
Matcher intMatcher = INTPAT.matcher("");
for( File headRoot : headRoots ) {
File dir = new File(headRoot, dirName);
String[] entries = dir.list();
if( entries == null ) continue;... |
3123ba01-7d8a-4f0d-ac59-afa512fbc3e1 | 9 | @Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
Edge other = (Edge) obj;
if (from == null) {
if (other.from != null) return false;
} else if (!(from=... |
a94e5b0a-3605-42b3-b5cf-84f9d58151e0 | 1 | @Test
public void ensureCoreBudgetItemsInBudgetContainsDifferentFormObjectTestOne() {
List<CoreBudgetItem> coreBudgetItemList = new ArrayList<CoreBudgetItem>();
coreBudgetItemList.add(new CoreBudgetItem("Test Description", new BigDecimal("100")));
when(budgetFormData.getCoreBudgetItemsList... |
dc871078-8d52-4fdb-ab6c-bc1ce5902c70 | 9 | public static int firstMissingPositive(int[] A) {
int missPositive = 1;
int minValue = Integer.MAX_VALUE;
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
if (A.length == 0) {
return missPositive;
}
if (A.length == 1 && A[0] == 0) {
return missPositive;
}
for (int i = 0; i < A.le... |
c2c85382-a7a7-4190-becb-df6a92c7e646 | 7 | public void run() {
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String result;
while (true) {
try {
//Reading data from client
String userLogin = br.readLine();
String userPassword = br.readLine();
... |
298f9d01-d0fc-42f5-a910-59613ba4c242 | 4 | public boolean isBothClassesContainFields(Class<?> input, Class<?> output) {
Field[] srcFields = input.getDeclaredFields();
Field[] destiFields = output.getDeclaredFields();
if (srcFields.length > 0 && destiFields.length > 0) {
return true;
}
return false;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.