method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
0aee48a3-8a3d-4417-ad63-0f8c555c2740 | 3 | public static int gcd(int number1, int number2) {
if (number1 < 0 || number2 < 0) {
throw new IllegalArgumentException("Error: int cannot be < 0!");
}
if (number2 == 0) {
return number1;
}
return gcd(number2, number1 % number2);
} |
d2b2ac22-54ff-48b8-a772-b135c4dd8d2e | 6 | @Override
public void endElement(String uri, String localName, String qName) throws SAXException {
super.endElement(uri, localName, qName);
tag = Tags.fromString(qName);
if (tag == null) {
return;
}
switch (tag) {
case ADDEDBY:
id = Integer.parseInt(valueTag);
try {
message.setUser(DaoFactory... |
136fb179-f90b-4573-8ed2-57322e894a99 | 9 | public List getHotIssu() throws Exception{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
List issueList = null;
DataBean bean = null;
try{
sql="select ROWNUM, b.* from (select * from (select * from board union all select * from food union all select * fro... |
e8824363-701f-4d6f-babd-def0bee29a89 | 0 | public void setBlogId(long blogId) {
this.blogId = blogId;
} |
dec763c6-30e5-4c79-8277-806cf37866c1 | 0 | @Override
public void windowOpened(WindowEvent arg0)
{
} |
7d3321a8-fc08-4c3d-a133-9265106820b1 | 4 | public static void readInDictionaryWordsAndSort() {
File dictWords = new File("dictWords.txt");
// Instantiate the arrays to add words too
WordManager.easy = new ArrayList<String>();
WordManager.medium = new ArrayList<String>();
WordManager.hard = new ArrayList<String>();
try {
Scanner readInput =... |
3f7759dd-dabf-4ed6-b490-a7d6db584183 | 7 | private int[] getClassIndices() {
// Create an index of where each class value starts
int [] classIndices = new int [getInputFormat().numClasses() + 1];
int currentClass = 0;
classIndices[currentClass] = 0;
for (int i = 0; i < getInputFormat().numInstances(); i++) {
Instance current = getInpu... |
000df3b6-8d26-4d90-819f-97bc87e97c93 | 7 | public boolean usuario(String us, String con){
ResultSet resultado = null;
boolean res = false;
String sql = "select * from usuario";
try {
resultado = consultar(sql);
if(resultado != null){
while(resultado.next()){
usu = resultad... |
629898bf-4fcc-4e91-9ef7-985e72f83a65 | 5 | static void encrypt(){
endText = new String[startText.length];
endText[0] = "ENCRYPTED";
for(int i=1; i < startText.length; i++){
String[] temp = startText[i].split("");
for(int j=0; j < temp.length; j++){
try{
Integer.parseInt(temp[j]);
temp[j] = encrypter.encryptNumber(temp[j])... |
4319231b-33be-4b23-a8cf-193ed3cfd9a4 | 1 | public void testSeDurationAfterStart_long2() {
MutableInterval test = new MutableInterval(TEST_TIME1, TEST_TIME2);
try {
test.setDurationAfterStart(-1);
fail();
} catch (IllegalArgumentException ex) {}
} |
1dd464c8-4a18-4c89-af37-0737b12e6ce5 | 3 | public boolean isHeld(){
if (KeyMapping.xboxController.isAttached() && button!=null) {
if(button.isHeld()){
return true;
}
}
isPressed();
return keyHeld;
} |
c564a36a-0a38-4fd5-92ad-e75c794de9ae | 2 | private void npTreeValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_npTreeValueChanged
DefaultMutableTreeNode node = (DefaultMutableTreeNode) npTree.getLastSelectedPathComponent();
if (node == null || node.getUserObject().equals("root")) {
this.selectedNp = null;
... |
ab0e4476-6fb4-4d5a-a3c0-0a9ae930c778 | 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... |
94d04c78-15a3-4a73-ae80-0209e46d19dc | 5 | public void messageReceived(HostedConnection source, Message m) {
if (m instanceof PositionMessage) {
PositionMessage pm = (PositionMessage) m;
if (pm.subject != null) {
server.broadcast(pm);
}
} else if (m in... |
85f6ffb1-0555-44b3-90a5-291b70cee9bb | 3 | @Test
public void testGetMessageMultipleSubscribers() {
try {
int noOfSubscribers = 2;
final AtomicInteger msgCount = new AtomicInteger(0);
final String message = "TestMessage-testGetMessage_MultipleSubscribers";
final CountDownLatch gate = new CountDownLatch(noOfSubscribers);
final Message expected =... |
cd25bd51-3f2e-48a2-ade2-4660bf378ccc | 1 | public Time add (Time t) {
//System.out.println("Time.add() : " + this + " " + t);
Time temp = new Time((byte)(this.day + t.getDay()), (byte)(this.hour + t.hour), (byte)(this.min + t.getMin()));
temp.format();
if (temp.day > 6)
System.out.println("Time.add() : changed week" + temp + " " + t);
... |
5d6f093a-a759-4a54-b88a-087b702b6dd1 | 1 | public void play(String path) {//throws LineUnavailableException, UnsupportedAudioFileException, IOException
try{
File f = new File(path);
Clip clip=AudioSystem.getClip();
AudioInputStream ais=AudioSystem.getAudioInputStream(f);
clip.open(ais);... |
a3312649-554a-475a-9fe5-7e9199032651 | 7 | private void findStartTime() {
// at the beginning maximum is 0
minStartTime = 0;
// go through all files with BGP updates
for (int i = 0; i < inputUpdatesFilenames.size(); i++) {
try {
FileReader fr = new FileReader(inputUpdatesFilenames.get(i));
BufferedReader br = new BufferedReader(fr);
// ... |
2bd3c179-c767-46fc-9abe-bcd5ed040ffd | 4 | public List<ICreature> createCreatures(IEnvironment env, int number) {
List<ICreature> list = new ArrayList<ICreature>();
Random rand = new Random();
Dimension s = env.getSize();
// view the color space as a cube and then iterate over it using a small
// steps
float creaturesCountCubeRoot = (float) Math.po... |
bb50336d-bc51-4624-9f3d-3de0547a4d12 | 8 | private void readFields(IndexInput meta, FieldInfos infos) throws IOException {
int fieldNumber = meta.readVInt();
while (fieldNumber != -1) {
FieldInfo info = infos.fieldInfo(fieldNumber);
if (info == null) {
throw new CorruptIndexException("Invalid field number: " + fieldNumber, meta);
... |
19f47bc8-7ef2-4017-ade8-0b3bb67b3a82 | 1 | public static boolean ToggleQuizQuestionLink(int QuizId, int QuestionId, boolean Link)
{
String statement;
if (Link)
{
statement = String.format("Insert into quizquestion values (%d, %d)", QuizId, QuestionId);
}
else
{
statement = String.format... |
f3151288-3c8d-4882-9d4f-a5dbd5edf49e | 0 | public void setDigestValue(byte[] value) {
this.digestValue = value;
} |
61f28636-f924-4885-ae4f-cc06422c0934 | 3 | private static boolean inRange(int x, int y)
{
return (x>=0&&x<mapHeight&&y>=0&&y<mapWidth);
} |
a86a3ed1-28b6-4580-b458-cc0bd3124a3d | 6 | public de.unihannover.sim.labysim.model.bmp.Labyrinth getBMPLabyrinth(){
IBmpIO _bmpIO = new BmpIO();
_bmpIO.load(this._filename + ".bmp");
int _sizeX, _sizeY;
_sizeX = _bmpIO.getSizeX();
_sizeY = _bmpIO.getSizeY();
LinkedList<de.unihannover.sim.labysim.model.bmp.Node> _nodes = new LinkedList<de.... |
f6348a6c-4f62-47c6-ba92-6eea59a6d05a | 4 | @RequestMapping("/login")
public String login(String username, String password, HttpServletRequest request){
String error = "";
if(MeiJiaUtils.isEmpty(username) || MeiJiaUtils.isEmpty(password)){
error = "用户名或密码不能为空!";
request.setAttribute("error", error);
return "login";
}
Map<Object, Object> map = n... |
4ad3f090-0e89-40d0-b08c-3babed42338d | 1 | private void writeEdges(int pixels[]) {
if (edgesImage == null) {
edgesImage = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
}
edgesImage.getWritableTile(0, 0).setDataElements(0, 0, width, height,
pixels);
} |
183e4ed5-00fc-4c3e-930a-8e8c56d40f4d | 4 | private Weapon count(int[] occurrences) {
int result = 0;
for (int i = 1; i < occurrences.length; i++) {
if (occurrences[i] > occurrences[result]) {
result = i;
}
}
if (result == 0) {
return Weapon.PAPER;
} else if (result == 1)... |
624d3447-f44c-4141-b4fd-14239c4c01e7 | 8 | @Override
protected void connected(Socket socket) {
sock = socket;
try {
sock.setTcpNoDelay(true);
try {
sock.setTrafficClass(0x10);
} catch(SocketException e) {
System.out.println("Connection Error! >> " + e.getMessage());
}
... |
90a4158e-c750-496d-93f3-b8bfca860ad3 | 5 | private void updateTable() {
int update_count = 0;
int table_length = model.getRowCount();
//Check all groups
for (ThreadGroup g: group) {
Thread[] tmp = new Thread[g.activeCount()];
g.enumerate(tmp);
//Check all threads
for (Thread t : tmp) {
//If that thread is not in our list ... |
390705be-e17a-4dd3-b2da-2d59ed64d527 | 3 | @Override
public Class getColumnClass(int column) {
Class returnValue;
if ((column >= 0) && (column < getColumnCount())) {
if(getValueAt(0, column)==null)
return String.class;
returnValue = getValueAt(0, column).getClass();
... |
4c02e1ed-1511-448a-8148-dda93d57b62f | 2 | public String getDescription()
{
if(getLabel() == null || getLabel().length() == 0)
return Universe.curProfile.getEmptyString();
else
return getLabel();
} |
6d7b28f8-aeff-4640-889e-0d215bc09428 | 9 | private static boolean isString(String x)
{
if(x.length()<2) return false;
char[] input=x.toCharArray();
if(input[0]=='\"'&&input[x.length()-1]=='\"')
{
for(int i=1;i<x.length()-1;++i)
if(input[i]=='\"') return false;
return true;
}
if(input[0]=='\''&&input[x.length()-1]=='\'')
{
for(int i=1... |
6285517c-e475-4a73-b262-32d7c238742a | 1 | public void close() {
System.out.println("Closing connection");
try {
conn.close();
conn = null;
} catch (Exception e) {
}
} |
e3e60c9a-202e-49be-8073-5419c89691db | 1 | public boolean isRunning() {
return isStarted() && !terminated.get();
} |
7938ecb0-14c8-4654-9afd-f3e7aae0f550 | 0 | public String getPlainValue() {
return plainValue;
} |
62450879-3fe4-4750-8cab-b6f1a5cd6d43 | 7 | protected void handlePacketReceived(PacketReceivedMessage msg) {
if (!(msg.source instanceof ServerClientConnection)) return;
ServerClientConnection connection = (ServerClientConnection)msg.source;
if (connections.containsValue(connection)) {
plugi... |
a616dc38-9479-4831-834c-0dcbd79142c5 | 0 | private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
execCommand = (String)stream.readObject();
remoteCallObjectType = (RemoteCallObjectType)stream.readObject();
} |
38b41c1f-3045-410f-9512-f8aea11efe4b | 7 | * @param unit The <code>Unit</code> that is learning.
* @param settlement The <code>Settlement</code> to learn from.
* @return An <code>Element</code> encapsulating this action.
*/
public Element learnFromIndianSettlement(ServerPlayer serverPlayer,
Unit un... |
5db73be9-8925-4b27-9ba5-b610e56a7cbc | 7 | protected static Ptg calcLeft( Ptg[] operands )
{
int numchars = 1;
if( operands.length < 1 )
{
return new PtgErr( PtgErr.ERROR_VALUE );
}
if( operands[0] instanceof PtgErr )
{
return new PtgErr( PtgErr.ERROR_NA ); // 'tis what excel does
}
if( operands.length == 2 )
{
if( operands[1] ins... |
ee103d29-c055-4cac-a0d7-e1fe34871df1 | 3 | @Override
public SoSimProcess getNextProcessForPriority(int priority) {
try{
if( priority == 1 && this.nextProcess != null ){
return this.processQueue.get( this.nextProcess );
}else{
return null;
}
}catch ( IndexOutOfBoundsException ex ){
return null;
}
} |
1c8f1ab3-8e45-4743-a6f7-e9ef331556b3 | 8 | protected OgexGeometryNode toGeometryNode( DataStructure ds, Map<BaseStructure, Object> index ) {
OgexGeometryNode geom = new OgexGeometryNode();
configureNode(geom, ds, index, false);
if( "false".equals(ds.getProperty("visible")) ) {
geom.setVisible(false);
... |
85851375-a7dc-4e9f-8ba9-f698a3187a21 | 5 | HelpDialog(JFrame parent) { // is private, use showHelp() to create it in a new thread
this.setTitle("SINALGO Help (source: http://dcg.ethz.ch/projects/sinalgo)");
GuiHelper.setWindowIcon(this);
this.addWindowListener(this);
restoreWindowState();
this.setLayout(new BorderLayout());
this.setResizable(tru... |
52e6af0a-9c24-4ffa-8790-afb64cf0a780 | 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... |
a5d272ae-727e-4873-a699-8753aec0bab4 | 0 | public List<String> getWordList() {
return wordList;
} |
fd82007c-e19f-4f9f-bece-7ee3918c5eb9 | 1 | private static int min(int a, int b) {
if (a < b) {
return a;
}
return b;
} |
83c0d7e8-c86f-4dd4-aaa7-e5a0ff108e90 | 3 | public void run(){
// Start all the end points, and let them start their providers
for(Actor actor : actors){
if(! actor.hasConsumers()){
actor.run();
}
}
for(Actor actor : actors){
actor.finalize();
}
} |
86362f1c-afc2-4aea-816a-ff9c7089a2bc | 5 | public boolean check() {
Object o = null;
try {
o = out.getFieldValue();
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
if (o == null) {
return false;
}
if ... |
e954ab13-625f-444e-82cb-185729448d88 | 3 | public static String downloadPage(String address) {
URL url;
try {
url = new URL(address);
} catch (MalformedURLException ex) {
ex.printStackTrace();
return null;
}
try {
BufferedReader reader = new BufferedReader(new InputStreamRe... |
3cabfbaf-d9c0-4c53-bde2-989d31d41a68 | 8 | public boolean checkSolved(){
boolean bo=false;
boolean check;
Vector <Tile> line = new Vector<Tile>(0);
check=compareTiles((Vector<Tile>) matrix.getRow(0));
if(check)
bo=true;
check=compa... |
4752214b-b65b-4076-8ecc-894eede5a4dc | 4 | public ArrayList<Libros> getByTitulo(Libros l){
PreparedStatement ps;
ArrayList<Libros> libros = new ArrayList<>();
try {
ps = mycon.prepareStatement("SELECT * FROM Libros WHERE titulo LIKE ?");
ps.setString(1, "%"+l.getTitulolibro()+"%");
ResultSet rs = ps.ex... |
a4ae3382-af3a-4b19-85f4-cf7d2e2425c9 | 8 | void hookCustomListener (final String eventName) {
if (browser == null) return;
if (eventName == "CloseWindowListener") {
browser.addCloseWindowListener (new CloseWindowListener () {
public void close(WindowEvent event) {
log (eventName, event);
}
});
}
if (eventName == "LocationListener") {
... |
73b25978-41d2-457d-9214-531fc519a8b6 | 9 | public void drawModel(Graphics2D graphics, GameObject obj, Color color) {
Model model = obj.getModel();
if (model == null || !model.isValid()) {
return;
}
Vec3[][] vectors = model.getVectors();
if (obj.getType() == Type.BOUNDARY) {
graphics.setColor(color);
} else if (obj.getType() == Type.FLOOR_DEC... |
8a788d09-8932-4971-912b-57fc9010031d | 5 | public static void reload()
{
if(!playerDir.exists())
{
try
{
if(playerDir.mkdir())
{
Message.log(Level.INFO, "Try to create folder: " + playerDir.getName());
} else
{
Message.log(Level.WARNING, "Failed to create folder: " + playerDir.getName());
... |
dd0c5580-eefe-4ce0-8319-01cca7bbc373 | 4 | private void calcLabeledSimilarities() {
System.out.println("Creating cache for labeled documents...");
int L = m_trainSet.size(), size = L*(L-1)/2;//no need to compute diagonal
if (m_LabeledCache==null || m_LabeledCache.length<size)
m_LabeledCache = new double[size];
//using Collection<_Doc> trainSet ... |
6e3e9269-a635-4601-8ccd-d54e47df6ab3 | 5 | private void calcAC() {
int abs = 0, def = 0;
for (Item itm : equed) {
if (itm != null) {
String t = itm.tooltip;
if (t != null) {
try {
Matcher m = patt.matcher(t);
if (m.find()) {
... |
208fea82-3522-4aba-a1f1-9468adb8f3ed | 7 | public void populate(String schemaName, String tableName, int rows) throws SQLException {
List<Column> columns = metaDataDao.tableColumns(schemaName, tableName);
this.addForeignKeyGenerators(columns, schemaName, tableName);
String prefixedTableName = schemaName + "." + tableName;
row: fo... |
83263b1a-7c47-4d80-8eaf-3b3d45948897 | 5 | public final Buffer method24(boolean bool, boolean bool_3_) {
if (null == ((Class142) this).anIDirect3DIndexBuffer8517)
return null;
if (bool_3_)
method23(-111, 54);
bool &= aBoolean8519;
if (!aBoolean8520
&& ue.a((((Class142) this).anIDirect3DIndexBuffer8517.Lock
(0, anInt8521, !bool ? 0 : 81... |
a2b8e878-8892-474d-a968-5be9cfb96f54 | 0 | public KeyStroke getKey() {
return KeyStroke.getKeyStroke('o');
} |
eaf92ba6-bbe4-40ae-bde1-9ddbd43dcb84 | 5 | public static String errorOf(Clause c) {
String error = "subject and verb agreement error";
ArrayList<String> subjects = c.getSubjects();
ArrayList<String> subjectIdentifiers = c.getSubjectIdentifiers();
ArrayList<String> actionIdentifiers = c.getActionIdentifiers();
for (int j... |
83fdd91e-ce1b-4cfb-a343-115274f8b730 | 6 | public void drawSprite1(int i, int j)
{
int k = 128;//was parameter
i += anInt1442;
j += anInt1443;
int i1 = i + j * DrawingArea.width;
int j1 = 0;
int k1 = myHeight;
int l1 = myWidth;
int i2 = DrawingArea.width - l1;
int j2 = 0;
if(j < DrawingArea.topY)
{
int k2 = DrawingArea.topY - j;
k1 ... |
5397ec11-3d04-473f-afd7-92d387366e78 | 2 | private void createWeightFft(int numFftPoints, boolean invert) {
// weightFFT will have numberFftPoints/2 complex elements.
this.weightFft = new double[numFftPoints];
// For the inverse FFT, w = 2 * PI / numberFftPoints;
double w = -2.0 * Math.PI / numFftPoints;
if (invert... |
a93e22ef-9752-4db6-aacc-9d072dedfe17 | 2 | public void visitShiftExpr(final ShiftExpr expr) {
if (isLeaf(expr.expr()) && isLeaf(expr.bits())) {
firstOrder = true;
}
} |
8404d5ee-d59c-4546-95f5-f66cb5d32567 | 1 | public FieldVisitor visitField(
int access,
String name,
String desc,
String signature,
Object value)
{
FieldVisitor fv = super.visitField(access,
remapper.mapFieldName(className, name, desc),
remapper.mapDesc(desc),
rem... |
05c5d5b1-a830-4e48-8ccc-db98984cdc5d | 2 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
String file_name = "storage.txt";
try {
ReadFile file = new ReadFile(file_name);
String[] aryLines = file.OpenFile(... |
fa2341a1-b64f-4c4e-994d-d0b624d7915b | 2 | private AcctsRecTransRec parseAddTransaction() {
String mastID;
AcctsRecTransRec result;
if (tokens.length > 1) {
mastID = tokens[1];
if (tokens.length == 2)
{ result = new AcctsRecAddTransRec(mastID); }
else {
result = new AcctsRecIllFormedTransRe... |
17294cc0-a2dc-491e-9e38-a886ca0f0a69 | 9 | void FindMaxMin(Integer[] array) {
if (array == null || array.length == 0)
return;
if (array.length % 2 == 1) {
max = array[0];
min = max;
} else {
max = Math.max(array[0], array[1]);
min = Math.min(array[0], array[1]);
}
for (int i = 0; i < (array.length - 1) % 2; i ++) {
int tmp1 = ... |
8aa1687a-0b6d-48a9-96f0-b236b0ec8c3f | 3 | public static void updateExtendedNetwork(ExtendedNetwork eNet){
ExtendedNetworkData extData = eNet.getNetwork();
//Recover the network object (from the Rest Interface) attributes (extended attributes only if they are present)
String name=extData.getName();
String n=extData.getId();
String shared=extDat... |
4d3921dd-db24-443c-a865-f4335016841f | 2 | public static void main(String[] args)
{
// Please do not modify this line.
int numberOfRows = 5;
// YOUR CODE HERE
// Use nested for loops to print the triangle pattern.
// Please use the variable numberOfRows to control how many
// rows you print.
// Note: the desired numbe... |
fbddc486-67ac-4911-9be8-0274945ec10e | 2 | public static int partition(int[] array, int start, int end){
int key = array[start]; // choose the first element as the prvit
int i = end;
for(int j = end; j > start;j--){ // from the end to the first find the element biger than the privt
if(array[j] > key){
exchange(array,i,j); ... |
2e9bd430-7cc4-47dc-9b73-4c144b6213c6 | 1 | public void testPlaySound() throws Exception {
System.out.println("playSound");
String path = "H:/seng271/pro1/aCiv/src/Game/music/20th_century_fox.au";
MusicController instance = new MusicController();
instance.playSound(path);
//path = "H:/seng271/pro1/aCiv/src/Game/music/Battl... |
6b1971cc-7027-4cf7-a29d-5f0a8af1a7b8 | 1 | public void loadRanking(){
try {
resultSetToTableModel(tableModelRankings, dbCon.getRanking());
} catch (Exception e) {
e.printStackTrace();
}
} |
c6bf7bd4-1ab8-449b-baca-08cbd918de77 | 1 | public static boolean close(Window window) {
if (window == null) {
return true;
}
window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSING));
return !window.isShowing();
} |
ad994f6d-dbc4-47dd-9737-60e50a3c46e8 | 6 | @Override
public List<? extends LaidOutComponent> layout(TerminalSize layoutArea) {
int availableHorizontalSpace = layoutArea.getColumns();
int availableVerticalSpace = layoutArea.getRows();
List<LaidOutComponent> finalLayout = new ArrayList<LaidOutComponent>();
synchronized... |
f4994d54-798a-45ef-8fc3-68c953ad9efc | 8 | static void bg_dopalette() {
int offs;
int color, code, i;
int[] colmask = new int[32];
int pal_base;
pal_base = Machine.drv.gfxdecodeinfo[0].color_codes_start;
for (color = 0; color < 32; color++) {
colmask[color] = 0;
}
for (offs = aerofgt... |
42555f16-14c5-449d-914a-e1aeeec906fd | 0 | public String getApplicationKey() {
return applicationKey;
} |
88280d1d-ecbd-4000-95ec-8ef846167e7a | 7 | public void generateFood() {
Meat buf;
int xBuf;
int yBuf;
boolean right = false;
while (meats.size() < n) {
xBuf = ((random.nextInt(500)/10))*10;
yBuf = ((random.nextInt(500))/10)*10;
buf = new Meat(xBuf, yBuf);
right = true;
... |
a0eceefa-6580-4e4b-855c-2d28d0fe4d3b | 1 | public static List<Paragraph> parseParagraph(String text) {
List<Paragraph> paragraphs = new ArrayList<>();
String[] strings = text.split("\\n+");
for (String string : strings) {
paragraphs.add(new Paragraph(string));
}
return paragraphs;
} |
44a18f39-eae4-4981-a5d9-13e8868939e5 | 1 | private void missileKillsPlayer(Avatar player, Missile missile) {
Rectangle2D rectPlayer = new Rectangle2D.Float(player.getX(),
player.getY(), 18, 18);
Rectangle2D rectMissile = new Rectangle2D.Float(missile.getX(),
missile.getY(), 9, 9);
if (rectPlayer.intersects(rectMissile)) {
Avatar.isDead = true;... |
51c3741a-2640-4027-aa19-001d593cb67f | 6 | public static void now(){
ArrayList<Entity> collideList = new ArrayList<Entity>();
for(Entity en : entityList){
if(en.getCollidablity())
collideList.add(en);
}
for(Entity en : entityList){
en.draw();
if(en.getCollidablity()){
Rectangle enRect = new Rectangle(en.getX(),en.getY(),en.getW(),en.get... |
a4d02980-1238-4447-ae6a-9758ef63baab | 5 | private void search(Node root, AdjacencyList list, boolean forward){
root.visited = forward;
if(list.getAdjacent(root) == null){
if(forward) stack.add(0, root);
return;
}
for(Edge e : list.getAdjacent(root)){
if(e.to.visited != forward){
... |
c605cc86-eff6-4069-b179-721db6ed97d0 | 6 | public void render(Graphics g)
{
g.drawImage(img,Panel.x, Panel.y, Panel.width, Panel.height, null);
g.setFont(new Font(Font.SANS_SERIF, 0, Main.size.height/12));
g.drawString(Page + "", Panel.x + Panel.width/2, Main.size.height/8);
if(Page < Pages)
{
if(BRight.contains(Main.mse))
{
renderRight(... |
806209c1-248d-4112-9b08-1366c5789aad | 6 | private static void msdSort(String[] a, String[] aux, int l, int h, int d) {
int CUTOFF = 15;
if (h <= l + CUTOFF) {
isort(a, aux, l, h, d);
return;
}
int R = 256;
int[] count = new int[R + 2];
// count frequencies
for (int i = l; i <= h; i++) {
int c = charAt(a[i], d);
count[c + 2]++... |
688f54e2-ce51-4f81-8939-d55fc15e0080 | 9 | public FESimpleResponse generarFESimple(
Long cuitFacturador,
TipoComprobante cbte,
Integer ptoVta,
TipoConcepto cpto,
TipoDocumento doc,
long nroDoc, long nroCbte,
Importe importe
) throws EsphoraInternalException{
if(ptoVta == null){
throw new EsphoraInternalException("El punto de ve... |
195a750d-1df8-49c2-bc57-c5a155253352 | 6 | private boolean splitMatch() {
if (ptnLength > matchStrLength || patternParts.length
!= matchStrParts.length) {
return false;
}
for (int i = 0; i < matchStrParts.length; i++) {
if (matchStrParts[i].length() == 0 && patternParts[i].length() == 0) {
... |
7eea5ccd-3d53-47d3-b0d3-513c4dd2f45a | 3 | public static BufferedImage blackWhite(BufferedImage input, int threshold) {
double RED_FACTOR = 0.299;
double BLUE_FACTOR = 0.114;
double GREEN_FACTOR = 0.587;
BufferedImage result = new BufferedImage(input.getWidth(), input.getHeight(), input.getType());
for (int i = 0; i < ... |
2b850b6b-fca3-41cb-88a0-a7851864ea7a | 2 | public GraphNode searchNode(GraphNode<T> pgraphNode) {//returns the specified node, if not is null.
for (int i = 0; i < graph_nodes.getLength(); i++) {
if (pgraphNode.equals(graph_nodes.get(i))) {//if param is equal to node in list.
return (GraphNode) graph_nodes.get(i);
... |
8761fbe1-b600-4482-9808-6198e62f2283 | 3 | private Image createThumbnail(Image image) {
int sourceWidth = image.getWidth();
int sourceHeight = image.getHeight();
int thumbWidth = 200;
int thumbHeight = -1;
if (thumbHeight == -1) {
thumbHeight = thumbWidth * sourceHeight / sourceWidth;
}
Imag... |
0def16da-91ca-474a-812f-83bf6f5974ca | 0 | protected void onNickChange(String oldNick, String login, String hostname, String newNick) {} |
3fafde5d-1db2-4c58-b0e6-c891dea703a5 | 6 | @Override
public String toString()
{
String bs = "";
if (hasTopBorder()) bs += "^";
if (hasLeftBorder()) bs += "<";
if (hasRightBorder()) bs += ">";
if (hasBottomBorder()) bs += "_";
if (isBackgroundSeparated()) bs += "*";
if (name != null)
... |
03641131-b0f7-4f79-8b83-dc45151002df | 8 | protected static Ptg calcDays360( Ptg[] operands )
{
if( operands.length < 2 )
{
return new PtgErr( PtgErr.ERROR_VALUE );
}
try
{
Object o1 = operands[0].getValue();
Object o2 = operands[1].getValue();
GregorianCalendar dt1 = (GregorianCalendar) DateConverter.getCalendarFromNumber( o1 );
Grego... |
d1f8a7be-d8f4-49ec-b9e5-f67e2ad45f7e | 4 | private void addButtonsListeners()
{
btnAddAnswer.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String answ = JOptionPane.showInputDialog("Podaj odpowiedź");
String answTest = answ;
if (answ.tri... |
052e09e5-a341-4f95-8a1c-e5780e73be7d | 4 | public static String getUserInfo(String username) throws SQLException {
Statement statement = mysqlDB.createStatement();
ResultSet result = statement
.executeQuery("select * from v_user_info where Username = '"
+ username + "'");
String[] columns = new String[] { "Username", "Display", "Token",
"Sta... |
afcf67ed-6739-4118-a097-eefbf3b290e3 | 9 | private static ThreadGroup startMethodThreads(final MultithreadedTestCase test, ThreadedMethod[] threadMethods,
final LinkedList<java.lang.Thread> threads, final Throwable[] error) {
ThreadGroup threadGroup = new ThreadGroup("MTC-Threads");
final CountDownLatch latch = new CountDownLatch(threadMethods.length);
... |
40d4d693-d878-4f57-9eab-084ec5ea7003 | 9 | public void outline() {
if (this.rowsAll == null) {
return; // early return
}
List<EditorRow> list = new ArrayList<EditorRow>();
for (EditorRow er : this.rowsAll) {
if (er instanceof PackageDefRow) {
list.add(er);
} else if (er instanceof ClassDefRow) {
ClassDefRow cdr = (ClassDefRow) er;
... |
568246c2-a5b1-4235-88f3-529970906105 | 3 | static private Map<String, CoreMetaData> getTaFuncMetaInfoMap() {
Map<String, CoreMetaData> result = new TreeMap<String, CoreMetaData>();
Method[] ms = coreClass.getDeclaredMethods();
Map<String, Method> lookbackMap = getLookbackMethodMap();
for (Method funcMethod : ms) {
Str... |
5470600a-f322-4bf6-a1c3-eba4caf3933c | 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... |
0fa58948-454e-4cbb-b6c0-e7ba7250924f | 4 | private void checkProbabilties(double carProb, double smallCarProb,
double mcProb) throws SimulationException {
String msg = "";
boolean throwExcept = false;
if (invalidProbability(carProb)) {
msg += " carProb ";
throwExcept = true;
}
if (invalidProbability(smallCarProb)) {
msg += " smallCarProb... |
237edb0b-1b45-4f4f-87e4-6832073a96c7 | 0 | public void addClassPath(String path) {
paths.add(path);
} |
59fec0a5-4785-470c-9c8e-5a36160bad98 | 2 | private void removeAttribute(String attribute){
int i = 0;
for(JLabel l : _ranks){
if( l.getText().equals(attribute) ){
l.setText("");
shrink(i);
}
i++;
}
} |
5842d7c9-2a8f-4f44-a745-55530920f424 | 4 | public void updateAll(Globalprice gp) {
for (MarketSign sign : sellsigns) {
if (sign.getGp().equals(gp)) {
this.update(sign);
}
}
for (MarketSign sign : rentsigns) {
if (sign.getGp().equals(gp)) {
this.update(sign);
}
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.