method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
6b3eb4a0-9d3c-4ea4-baa9-1d4cb6f071d5 | 8 | public void drawABox(int width, int height)
{
LayoutNode n = new DefaultLayoutNode(new long[]{0,0});
n.flag(LayoutFlags.corner);
for(int y=0;y<height-1;y++)
{
use(n,LayoutTypes.surround);
LayoutNode nn = getNextNode(n, Directions.NORTH);
if(nn==null)
nn=makeNextNode(n, Directions.NORTH);
n.cros... |
724fba3c-c055-4785-b51f-f13caf975047 | 8 | public static String numToWords(long num) {
String[] ones = new String[] {
"one", "two", "three", "four", "five", "six",
"seven", "eight", "nine"
};
int[] onesLen = new int[] {
3, 3, 5, 4, 5, 3, 5, 5, 4
};
String[] teens = new Str... |
2259fb01-efcf-4a11-8746-603e8bda11d5 | 2 | private void addListener() {
beginBussinessButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
if (!isBusiness) {
isBusiness = true;
beginBussinessButton.setText("停止营业");
DoBusiness doBusiness = new DoBusiness();
new Thread(doB... |
951c75fc-1c11-4e98-8bbe-4d94a92305fc | 0 | @Override
public int fight() {
return super.fight();
} |
5ee5ded3-edc3-4be8-af38-f092448a120b | 0 | public PBES2ParameterType createPBES2ParameterType() {
return new PBES2ParameterType();
} |
f13e6fd8-6d1d-428f-8a12-1f7026c8b08b | 8 | private LogItemParser parseComplexParser() throws XMLStreamException{
int event = reader.next();
LogItemParser parser = null;
LogParserBuilder builder = new LogParserBuilder();
while (!foundItemEnd(event, "complex")){
if (event == XMLStreamConstants.START_ELEMENT){
... |
1d35d63f-a8c9-4e8b-b21e-43b1e87fb907 | 0 | public Piece[] getSuivantes() {
return plateau.getSuivantes();
} |
09569006-e54b-4c71-a021-a269dc5b4489 | 8 | public void close()
{
shutdownRequested=true;
executor.shutdown();
try
{
servSelector.close();
}catch(final Exception e){} // ugh, why can't there be an "i don't care" exception syntax in java
for(final ServerSocketChannel servChan : servChannels.keySet())
{
try
{
servChan.close();
}ca... |
0b1f0870-edec-40ad-b3dc-d052078290f6 | 1 | private boolean isAccountedFor(State state) {
if (STATES_IN_A_SET.contains(state))
return true;
return false;
} |
3524b154-4ebe-422a-b4aa-9f0d7038fe65 | 2 | @Override
public void keyPressed(int key, char character, GUIComponent component) {
switch (key) {
case (Keyboard.KEY_RETURN) : {
this.deactivate();
actionPerformed();
break;
}
case (Keyboard.KEY_ESCAPE) : {
... |
fb6c828a-27fb-4eb8-9063-e20b358264e4 | 0 | public String getName() {
return name;
} |
7c25ed65-e7e6-4110-bfe4-8df55b3442f5 | 1 | public <T> boolean contains(Class<T> c) {
if (c.isInstance(this.occupant)) return true;
return false;
} |
dd3d3303-f4c3-4212-8a79-62e6957102ba | 1 | private static String getFileContents(String filename)
throws IOException, FileNotFoundException
{
File file = new File(filename);
StringBuilder contents = new StringBuilder();
BufferedReader input = new BufferedReader(new FileReader(file));
try {
String line = ... |
b1eb2eb7-c259-4ae4-bd39-059c26231b8d | 0 | @Override
public String toString() {return String.valueOf(cur);} |
ddfc1b85-bf21-4053-994f-48fa82bc856a | 0 | public static List<Offrir> SelectAll(EntityManager em) throws PersistenceException {
List<Offrir> desOffrirs=null;
Query query = em.createQuery("select v from Offrir v");
desOffrirs=query.getResultList();
return desOffrirs;
} |
0f8413bb-f372-4a3d-839a-e1414e055e9a | 3 | public void addNaicsCode(String code) throws Exception {
if (null == Naics) {
Naics = new ArrayList<String>();
} else if (1000 == Naics.size()) {
throw new Exception("Maxiumum of 1000 NAICS codes are allowed for Search");
}
if (!Naics.contains(code)) {
Naics.add(code);
}
} |
b372d771-24e7-47da-b3a8-a10ef2f320fb | 3 | public Launcher() {
try {
server = new Server("Pluton", "localhost", 1234);
} catch (RemoteException e1) {
e1.printStackTrace();
}
try {
if (OS.indexOf("win") >= 0)
BroadcastUpdates.init("192.168.0.255", 1234);
else
BroadcastUpdates.init("239.0.0.1", 1234);
} catch (RemoteException... |
34419af8-d99b-4461-81df-38dbae9902ab | 9 | * @param tile The <code>Tile</code> contact is made at.
* @param cs A <code>ChangeSet</code> to update.
* @return The other nation if it is welcoming this nation on first landing.
*/
public ServerPlayer csContact(ServerPlayer other, Tile tile, ChangeSet cs) {
if (hasContacted(other)) return n... |
d0e5155f-5708-4147-aeb6-ab75f5388f0f | 7 | private boolean DeeperLoop(LinkedHashMap<String,List<String>> secondlevelborrowlist,List<String> tempList){
boolean comparedname=false;
boolean comparedbirthday=false;
for(Entry<String, List<String>> entry : secondlevelborrowlist.entrySet()){
String key = entry.getKey();
List<String> value = entry.... |
f41da3ce-c312-4836-b551-650bf62377c6 | 6 | private void seePlayerParse(String[] splitName, String[] splitInfo, ObjPlayer newPlayer) {
if(splitName.length == 2) {
newPlayer.setTeam(splitName[1]);
}
else if(splitName.length == 3) {
newPlayer.setTeam(splitName[1]);
newPlayer.setuNum(Integer.parseInt(splitName[2]));
}
else if(splitName.length ... |
31310854-a20e-43e7-b27c-5121609135c6 | 3 | public double sampleMean(int nt) {
if( (nt < 1) || (nt > n) ) return 0;
double mean = 0;
for( int ns = 0; ns < numberOfSamples; ns++ )
mean += rankSum[ns][nt - 1];
mean /= numberOfSamples;
return mean;
} |
9d39a5fd-3e8f-44c3-a787-80387fa4682f | 7 | private void testChiasma13(int a) {
//NOTE: must be called after generateChiasma;
//there side, sideFact, pos, mindist are calculated
//first: check if rejected because of opposing chiasma
//(possibly with interference):
if (!Double.isNaN(mindist) && rejectDist(mindist)) {
... |
e68434de-c62a-4853-8a9e-2c1c21e4ca3e | 4 | private void dbgPathWeights(Graphics g){
double max = level.getMaxPathingWeight();
dbgString("maxPathingWeight=" + max, g);
if(max <= 0) return;
g.setColor(Color.red);
for(int y=0; y<level.h; y++){
for(int x=0; x<level.w; x++){
PointI p = new PointI(x, y);
double rad = level.getPathingWeightAt(p) /... |
c2b5464e-2eeb-4f63-ac48-7fb07c308172 | 2 | private FloatBuffer uniformf(int loc) {
if (fbuf16 == null)
fbuf16 = BufferUtils.createFloatBuffer(16);
fbuf16.clear();
if (loc == -1)
return fbuf16;
getUniform(loc, fbuf16);
return fbuf16;
} |
e1abdbf9-b1e2-4b68-a4f4-6c4926f4dc7c | 2 | public void collectUnfreshPeers() {
for (TrackedPeer peer : this.peers.values()) {
if (!peer.isFresh()) {
this.peers.remove(peer);
}
}
} |
6ac5b9ee-0812-43ab-809c-595ebb656946 | 1 | protected void addGlied() {
if (nextGlied == null) {
//create/add new glied
Rectangle newMasse = (Rectangle) getBounds().clone();
newMasse.x -= getDirection().x * width;
newMasse.y -= getDirection().y * height;
SchlangenGlied newGlied = new SchlangenGlied(newMasse, unit, Zufallsgenerator.zufallsFar... |
5cfa7050-175d-4689-a67e-32dfdd1d1488 | 9 | public void setData(String key, Object value) {
Assert.isNotNull(key);
/* Remove the key/value pair */
if (value == null) {
if (keys == null) {
return;
}
int index = 0;
while (index < keys.length && !keys[index].equals(key)) {
index++;
}
... |
8952a7c2-3d32-4313-bb27-b4ac529f4270 | 9 | static boolean isStandardProperty(Class clazz) {
return clazz.isPrimitive() ||
clazz.isAssignableFrom(Byte.class) ||
clazz.isAssignableFrom(Short.class) ||
clazz.isAssignableFrom(Integer.class) ||
clazz.isAssignableFrom(Long.class) ... |
5cfaad19-965e-47c8-9504-8fbc0054ec8f | 4 | * @return true if it is general punctuation, else false
*/
boolean isPunctuation( char datum )
{
int type = Character.getType(datum);
return type == Character.END_PUNCTUATION
|| type==Character.DASH_PUNCTUATION
|| type==Character.FINAL_QUOTE_PUNCTUATION
... |
3c952efa-b8b8-402b-af21-b23e55982be0 | 9 | public void code(String s) {
if(s==null){throw new IllegalArgumentException();}
int alpha = 0;
int i = 0;
int j = 1;
int len = s.length();
while (i < s.length() && j <= s.length()) {
String sub = s.substring(i, j);
String sub2 = s.substring(i, j - ... |
7e725f16-e357-4302-985e-3348c6cd8d5e | 3 | public static void main(String[] args) {
Building building = new Building();
//Human sanya = new Human("Sanya");
//Human slava = new Human("Slava");
//
// building.addHuman(sanya);
// building.addHuman(slava);
//
// for (Human human:building) {
// System.out.p... |
791c9aa4-4597-4e88-818c-871626cc57e9 | 7 | private static void pruneOldWindowPreferences(Preferences prefs) {
// 45 days ago, in milliseconds
long cutoff = System.currentTimeMillis() - 1000L * 60L * 60L * 24L * 45L;
List<String> keys = prefs.getModuleKeys(WINDOW_PREFERENCES);
ArrayList<String> list = new ArrayList<>();
for (String key : keys) {
if ... |
de10bc62-3fdb-40bd-91c9-579a770b8d2d | 7 | public static void load() {
try {
File f = new File("./Data/world/map_index");
byte[] buffer = new byte[(int) f.length()];
DataInputStream dis = new DataInputStream(new FileInputStream(f));
dis.readFully(buffer);
dis.close();
ByteStream in = new ByteStream(buffer);
int size = in.length() ... |
d73f954b-2ae8-4805-9a68-fa320d1c5d58 | 6 | private void openAddMediaDialog(Node node, ArrayList<Link> prevLinks, final int startOrLink, Link currentLink) {
if (startOrLink != 1 || !node.getStart()) {
// Create startLink
if (currentLink == null) {
currentLink = new Link(null, null, node, map.getStory().getLinkCount... |
da8fe08b-335a-4257-870f-eb5752562e19 | 8 | public DetailsFrame(CourseModel model, final Settings settings) {
super("Details", model);
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
this.setContentPane(split);
model.addListener(this);
Dimension dim = new Dimension(400, 200);
this.setMinimumSize(dim);
this.setSize(dim);
tableModel... |
f79eb2ca-6be6-45d5-98af-5f0431645727 | 8 | private static void step1window() throws ExitInputedException, RestartInputedException, FinishInputedException {
sysline();
sysout("STEP 1");
sysline();
sysout("Please specify what is the most important criterion for you: * ");
tab();
for (CarCriterion carCriterion : CarCriterion.values()) {
if (!carCrit... |
3185643d-4e0b-4b9c-9ee1-105b740dd0b3 | 9 | * @param cs A <code>ChangeSet</code> to update.
*/
private void csBombardEnemyShips(Random random, ChangeSet cs) {
for (Colony colony : getColonies()) {
if (colony.canBombardEnemyShip()) {
for (Tile tile : colony.getTile().getSurroundingTiles(1)) {
if (!t... |
89f22466-4b66-4022-b90e-6112dbfa1020 | 6 | private Move findBest(ArrayList<GameTree> genOneChildren) {
// TODO Auto-generated method stub
ArrayList<GameTree> theBest = new ArrayList<GameTree>();
theBest.add(genOneChildren.get(0));
for(int i = 1 ; i < genOneChildren.size();i++)
{
GameTree theNode = genOneChildren.get(i);
if(myColor==Game.WHI... |
7868aa43-b0fb-4977-840b-3ae5637039cb | 1 | public Iterator iterator() {
return new Iterator() {
int pos = 0;
public boolean hasNext() {
return pos < count;
}
public Object next() {
return locals[pos++];
}
public void remove() {
if (pos < count)
System.arraycopy(locals, pos, locals, pos - 1, count - pos);
count--;
... |
ebee0ac5-2dc5-4efa-b8f8-f534099b5478 | 0 | public void setNumUndo(int nn){
undo_num = nn;
} |
65a141ce-455f-4642-b748-164d87246349 | 4 | public QueueSysResult calculate(int servicePointNumber){
double p0 = 0;
double ro = lambda/mu;
for(int i = 0; i <= servicePointNumber ; i++){
p0 += (Math.pow(ro, i))/(factorial(N-i)*factorial(i));
}
for(int i = servicePointNumber+1; i <= N ; i++){
p0 += (M... |
828f52b4-8741-4b74-81a2-0bdd518087b4 | 6 | public Brick(int brickNum)
{
// brick 1 (easy)
if (brickNum == 1)
{
setImage(brick1);
hit = 1;
}
// brick 2 (easy)
if (brickNum == 2)
{
setImage(brick2);
hit = 2;
}
// brick 3 (medium)
if... |
454f3020-6817-42ed-9f3a-d7b46bb60c16 | 7 | public static Optional<AttributePath> determineCommonAttributePath(final ContentSchema contentSchema) {
if (contentSchema.getKeyAttributePaths() == null && contentSchema.getValueAttributePath() == null) {
return Optional.empty();
}
final Map<String, AttributePath> attributePaths = new HashMap<>();
final M... |
34cf85ee-35bf-474e-a10e-2626e42396ee | 8 | public double getInitialHoldings() {
Connection conn = null;
ResultSet rs = null;
PreparedStatement ps = null;
double initial = Constants.BankHoldings;
try
{
conn = iConomy.getiCoDatabase().getConnection();
ps = conn.prepareStatement("SELECT initial FROM " + Constants.SQLTable + "_Ba... |
badb235a-49a5-404f-a406-db68f83a95cb | 0 | @Override
public String toString()
{
String message;
message = this.numTaken() + " seats are already reserved";
return message;
} |
7b13096a-57eb-4bdf-816d-057f8cb48a7e | 8 | private Icon paintIcon(Graphics g, BIOSwitch c, boolean selected,
int x_start, int x_end, int x_end2, int y_start, int y_end) {
Icon ico = getIcon(
(selected) ? c.getSelectedIcon() : c.getDisabledSelectedIcon(),
c);
if (ico == null) {
return null;
}
String text = ((selected) ? c.getOnString() :... |
0901433e-8225-45c6-8525-5f008e3e5e29 | 6 | final synchronized void method2093(boolean bool) {
anInt3609++;
if (Class183.aClass250_2462 != null) {
boolean bool_35_ = true;
for (int i = 0; (i ^ 0xffffffff) > -3; i++) {
if (((Class250) Class183.aClass250_2462).aClass279Array3218[i]
== this)
((Class250) Class183.aClass250_2462).aClass279Ar... |
879512e8-94fd-4de2-a9be-a2c42bb3d7d2 | 7 | private static int reg2bins(final int beg, final int _end, final int[] list) {
int i = 0, k, end = _end;
if (beg >= end) return 0;
if (end >= 1 << 29) end = 1 << 29;
--end;
list[i++] = 0;
for (k = 1 + (beg >> 26); k <= 1 + (end >> 26); ++k)
list[i++] = k;
for (k = 9 + (beg >> 23); k <= 9 + (end >> 23);... |
7efa2226-f4b0-4b43-98e7-8290a550f74f | 7 | public void intersectIn(PostingsList other) {
Node<Posting> meCur = this.getHeadNode(), meNext = meCur.next;
Node<Posting> them = other.getHeadNode().next;
// Note that we can terminate when *either* pointer reaches the end
while (them != null && meNext != null) {
if (meNext.value.equals(them.value)) {
... |
da5fd636-f055-4ccd-ac65-33637aefce79 | 4 | public boolean revisarEntradasYSalidas(){//cada nodo debe estar declarado como salida o entrada en los extremos del arbol
boolean resp = true;
for(Nodo<Rama_Hoja> iterador = _salidasDelArbol.getHead(); iterador != null; iterador = iterador.getSiguiente()){
if(iterador.getDato().getI... |
6aeb0f96-70ee-4d97-a827-c7dd93d10e2c | 9 | void iterateSeqChange(String inputFile, OutputFormatter outputFormatter) {
SnpEffectPredictor snpEffectPredictor = config.getSnpEffectPredictor();
// Create an input file iterator
VariantFileIterator seqChangeFileIterator;
if (inputFormat == InputFormat.BED) seqChangeFileIterator = new BedFileIterator(inputFil... |
4309a733-1dee-4dad-ac94-39989ea0a501 | 0 | public double convertTo(double size, Unit otherUnits) {
return size * conversionFactor / otherUnits.conversionFactor;
} |
91ca6c11-262d-4628-b0e4-7841b670d3e7 | 0 | public UUID getOrignalId() {
return this._orignalId;
} |
774e8f01-640f-4d39-8f3e-8922c27e7c47 | 5 | private static void enforceDensity(double density,
IntArrayInputVector mutatedVector) {
// Find set positions.
IntList filledPositions = new IntArrayList();
int[] components = mutatedVector.values;
for (int i = 0; i < components.length; i++) {
if (components[i] == 0) {
filledPositions.add(i);
}
}... |
dbf95a12-b4c6-45f0-9e7d-8874235e233c | 8 | private void broadcast( String alias, String result ){
String register; // the register to update
//remove the mapping from the memory buffer
if( memory_buffer.containsKey( result ) ){
memory_buffer.remove( result );
}
//broadcast to... |
da60c6ea-f4ab-4c37-9689-8fa21d18069a | 2 | public static String getConcatedDisplayString(ArrayList<String> strings) {
String retString = new String();
for (int i = 0; i < strings.size(); i++) {
if (i > 0)
retString = retString + "\n";
retString = retString + strings.get(i);
}
return retString;
} |
1b18bfaa-1bdf-42cb-906b-62f46272ec5f | 9 | @Override
public void onServerUpdate(Server handle) {
if (HP<=0)
{
handle.sendMessage(Server.DESTROY, ByteBuffer.allocate(30).putInt(MYID));
this.setAlive(false);
if (Server.gameMode==Server.DEFENDER)
{
PlayerOnline P = handle.getPlayer... |
4ceb8831-3cc0-4c4c-8b1c-15909c9cd6ad | 4 | public Boat askPorpertyInput (String name, int length) {
boolean placingError = false;
int direction = 0;
Boat b = null;
System.out.println(String.format(CURRENTSITUATION, length));
do {
if (placingError) {
System.out.println(PLACEERROR);
}
System.out.println(ASKBEGINFIELD);
Point p = InputMan... |
75ba29c5-6f06-4317-9af0-c857a0de7429 | 3 | static void addSorted(Cards cards, Cards hand) {
OUTER:
for (Card card : cards) {
int handSize = hand.size();
for (int i = 0; i < handSize; i++) {
if (hand.get(i).compareTo(card) < 0) {
hand.add(i, card);
continue OUTER;
... |
e8741436-448a-4491-8d08-0d58f7907384 | 9 | @Override
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
switch (cmd) {
case ACTUALIZAR_DUENIO:
ctrlContratos.cargarDialogoCambiarDuenio();
break;
case ACTUALIZAR_ESTACIONAMIENTOS:
ctrlContratos... |
08e4d21a-ff5e-4673-91a0-aff54173f3f4 | 2 | public void loadPreferences( String directory ){
BufferedReader r;
try {
File f = new File(directory + USER_PREFERENCES_FILE);
if( f.exists() ){
r = new BufferedReader(
new FileReader(f));
Gson g = new Gson();
g.fromJson(r, Sprinkles.class);
} else {
createDefaultSettings();
... |
da89fdda-a431-47ec-b6a5-6a08ea03a0f7 | 0 | public void mouseExited(MouseEvent e) {
} |
1f259da5-8012-4ae4-91db-3f17aafd47c7 | 2 | public void initialiser() {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
matrix[i][j] = new Ball(this, j * v, i * v, size, ezm.getXY(i,
j) - 1, j, i);
addMouseMotionListener(matrix[i][j]);
addMouseListener(matrix[i][j]);
}
}
} |
01e9322c-391b-4719-a3ba-b19c33964566 | 5 | public static void drawHorizontalAlphaLine(int x, int y, int length, int color, int alphaValue) {
if (y < startY || y >= endY)
return;
if (x < startX) {
length -= startX - x;
x = startX;
}
if (x + length > endX)
length = endX - x;
int alpha = 256 - alphaValue;
int red = (color >> 16 & 0xff) * al... |
6f4c2455-e249-40c0-854f-75062c7ebb76 | 6 | public static boolean isValidTile(int x, int y, int zoomLevel, TileFactoryInfo info)
{
// int x = (int)coord.getX();
// int y = (int)coord.getY();
// if off the map to the top or left
if (x < 0 || y < 0)
{
return false;
}
// if of the map to the right
if (info.getMapCenterInPixelsAtZoom(zoomLevel).g... |
01ae048a-e9c3-4020-a478-db0f9f086301 | 8 | public void mouseMotion(Point p){
if(headingLbl.getBounds() == null
|| helpBtn.getLabel().getBounds() == null){
return;
}
if(prevGame){
if(loadGameBtn.getLabel().getBounds().contains(p)){
loadGameBtn.changeTextTo(btnFontMotion, btnColorMotion);
}else{
loadGameBtn.revert();
}
}else{
... |
738660ba-9022-4f6e-bad1-650099172057 | 3 | int []insertionSort2(int arr[]){
int key;
for(int j=1;j<arr.length;j++){
key=arr[j];
int i;
i=j-1;
while(i>0 && arr[i]>key){
arr[i+1]=arr[i];
i=i-1;
arr[i+1]=key;
//swap(arr,j,i);
}
}
return arr;
} |
5e917361-8226-4f04-b143-89dab40b27c7 | 1 | @Override
public void mouseClicked(MouseEvent e) {
try {
MapObject obj = new MapObject();
obj.sprite = ImageIO.read(this.getClass().getResource(filepath.getText()));
obj.x = (int) xCell.getValue();
obj.y = (int) yCell.getValue();
panel.objects.add(obj);
panel.repaint();
} catch (IOExcept... |
813c0b0f-9c21-45b7-b978-7b794d75ac97 | 4 | @Override
public void paint(Graphics g){
this.requestFocus();
Graphics2D tileGraphics = (Graphics2D) g;
//bottom white rectangle
tileGraphics.setColor(Color.BLACK);
tileGraphics.drawRect(0, 400, 600, 200);
tileGraphics.setColor(Color.WHITE);
tileGraphics.fillRect(0, 400,... |
24f6e531-1ec2-4335-94d5-605efd1576f3 | 2 | public void getDataForSet(String[] tickers) {
// (" 2 36 44 9 9 9 9 9 9 9 9 9 9 1 1 1");
for (String tk : tickers) {
StringBuilder saveAsText = new StringBuilder();
saveAsText.append(ShortDataCollectorUtil.cnnForecast(tk).trim());
saveAsText.append(" ");
saveAsText.append(ShortDataCollectorUtil.analyst... |
0c814a3d-4bd7-49e4-b6cb-49b881dcacda | 2 | public long add(long millis, long value) {
int newYear = iChronology.year().get(millis)
+ (int)TestGJChronology.div(value, 12);
int newMonth = get(millis) + (int)TestGJChronology.mod(value, 12);
if (newMonth > 12) {
newYear++;
newMonth -= 12;
}
... |
742f8e1a-7e6c-4440-a2af-4578faa4c05f | 1 | private CallType getCallType() {
return isAdminConnection() ? CallType.SERVER : CallType.CLIENT;
} |
d7ddeeee-acde-4078-a66b-4b423ef27359 | 7 | public static Balloon getRandomBalloon(double minRadius, double maxRadius,
double minFullness, double maxFullness) {
if (minRadius > maxRadius) {
throw new IllegalArgumentException(
"minRadius must be lesser than maxRadius");
} e... |
3f01c44e-91e5-4241-9cc0-843ac3e96673 | 5 | public boolean setValue(Object obj, String propName, Object value){
boolean done = false;
PropInfo propInfo = propInfoByPropName.get(propName);
Method writeMethod = (propInfo != null)?propInfo.getWriteMethod():null;
if (writeMethod != null){
try {
if (value == null){
writeMethod.invoke(obj,new Objec... |
8c2ce947-7e47-4cc8-ba7e-d45f3a7d3bd7 | 8 | public int getPointingDirectionToString(){
int quadrant;
if(x > 0 && y > 0)
quadrant = 1;
else if(x < 0 && y > 0)
quadrant = 2;
else if(x < 0 && y < 0)
quadrant = 3;
else if(x > 0 && y < 0)
quadrant = 4;
else
quadrant = 0;
return quadrant;
} |
d010e40f-6c6c-4cd1-a44f-9641ac78e19b | 0 | @Override
public void keyReleased(KeyEvent e) {
unprocessedEvents.add(e);
} |
d96e6b7b-79cf-4905-ab9a-66ca66c4ea98 | 6 | public static List<String> getLocalIPAddresses() {
List<String> addresses = new ArrayList<String>();
List<NetworkInterface> nifs = null;
try {
nifs = Collections.list(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface nif : nifs) {
// Bug fix: do not keep addresses for pseudo-devices like v... |
ebaeb120-1dd4-4192-932f-57e01d113c15 | 9 | public static boolean isBefore(Date date1, Date date2) {
int[] dIng1 = getDateIngredients(date1);
int day1 = dIng1[0];
int month1 = dIng1[1];
int year1 = dIng1[2];
int[] dIng2 = getDateIngredients(date2);
int day2 = dIng2[0];
int month2 = dIng2[1];
int year2 = dIng2[2];
if (year1 < year2) {
retur... |
d83036d3-7ed5-4a83-8670-fc9650350d25 | 3 | private int indexOf(byte[] pattern) {
int count = virtualSize - (pattern.length - 1);
for (int i = 0; i < count; i++) {
for (int j = 0; getByte(i + j) == pattern[j]; j++) {
if (j == pattern.length - 1) {
return i;
}
}
}
... |
13fbab0c-2ca0-434d-a7e3-fb5bda05a9dd | 1 | @Override
public double getDiscountAmt(double productPrice, int qty) {
if (qty >= minQty) {
return (productPrice * qty) * per;
} else {
return noDiscount;
}
} |
de80ae04-dd43-418d-892d-cbc9d574c0b3 | 6 | private ScoreObject subop(ScoreObject a, ScoreObject b) {
if (a.isNumeric() && b.isNumeric()) {
if (a.isFloat() || b.isFloat())
return new ScoreObject(a.getAsFloat() - b.getAsFloat());
// one is an int?
else if (a.isInt() || b.isInt())
return new ScoreObject(a.getAsInt() - b.getAsInt());
// must b... |
e1af0273-3c94-4b8f-8975-3793be0fe670 | 2 | @SuppressWarnings("static-access")
public boolean PasswordCheck(String email, String password)
throws Exception {
email = email.toLowerCase();
boolean answer = false;
try {
// This will load the MySQL driver, each DB has its own driver
Class.forName("com.mysql.jdbc.Driver");
// Setup the connection w... |
db50d405-9889-4f45-aafb-ef76dda78f07 | 2 | public static void main(String[] args) {
try {
Registry reg = LocateRegistry.getRegistry();
MasterServerClientInterface masterServer = (MasterServerClientInterface) reg
.lookup("masterServer");
ReplicaLoc loc = masterServer.read("file2.txt")[0];
ReplicaServerClientInterface repServer = (ReplicaServer... |
6003f9d3-7505-4613-877c-ed8cf445bd15 | 4 | private void lengthLCS()
{
// Subproblems are encountered in the increasing order of their size if
// we proceed in the row major order or in column major order
for (int i = 1; i < X.length(); i++)
for (int j = 1; j < Y.length(); j++)
if (X.charAt(i) == Y.charAt(j))
len[i][j] = len[i - 1][j - 1] + 1;... |
b1f7f33d-0648-420b-b4a8-c8b59f4746e8 | 3 | public void tick() {
w.tick();
c.tick(p);
p.tick();
for (int i = 0; i < missiles.size(); i++) {
missiles.get(i).tick();
}
for (int i = 0; i < particles.size(); i++) {
particles.get(i).tick();
}
for (int i = 0; i < ent.size(); i++) {
ent.get(i).tick();
}
} |
1d8b3e93-f4d3-4f61-b120-ab86df1ab787 | 5 | private static void qsort3way(String[] a, int l, int h, int d) {
if (h <= l) return;
int lt = l, gt = h;
int v = charAt(a[l], d);
int i = l + 1;
// partition
while (i <= gt) {
int t = charAt(a[i], d);
if (t < v) swap(a, lt++, i++);
else if (t > v) swap(a, i, gt--);
else ... |
2da3dfa1-3ef7-4ec7-911b-37e570d396a8 | 6 | public void setProperties(int houseNumber, int houseWidth, int houseLength, String exitWall)
{
//set globals
this.houseNumber = houseNumber;
this.houseWidth = houseWidth;
this.houseLength = houseLength;
this.exitWall = exitWall;
//fill the floor and walls
for (int y = 0; y < houseLength; y++)
for (in... |
195dc326-ad12-40d9-a200-f14dd6d408d4 | 7 | public static String generate(boolean caps, boolean numbers, boolean symbols, int length) {
Random number = new Random();
String password = "";
int stringpos;
for(int count = 0; count < length; count++) {
int q = number.nextInt(3);
q++;
switch(q) {
case 1:
if(caps == true) {
stringpos = ... |
35454c36-2557-4913-889d-6b9fae07fadc | 3 | public void writeYeast() {
//No need to do this now
Debug.print("Write yeast called");
try {
PreparedStatement pStatement = conn.prepareStatement("SELECT COUNT(*) FROM Yeast WHERE name = ?;");
String sql = "insert into yeast (Name,Cost,Descr) " +
"values(?, ?, ? )";
PreparedStat... |
2c066459-4259-44f3-8e35-89806669a2a1 | 1 | public void addRoom(Room room){
if (room instanceof Cine){
Cine tmp = new Cine((Cine) room);
rooms.add(tmp);
}else{
Theatre tmp = new Theatre((Theatre) room);
rooms.add(tmp);
}
} |
35791ef7-8d28-455a-8bfd-fc746c75bbbb | 8 | static final public String Type() throws ParseException {
String s; Token t1;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case DOUBLE:
case FLOAT:
case LONG:
case CHAR:
case INT:
s = TypeSpecifier();
break;
case IDENTIFIER:
t1 = jj_consume_token(IDENTIFIER);
... |
046fd320-179a-4fdc-8593-f7511de83fe4 | 4 | @Override
public void prepareInternal(int skips, boolean assumeOnSkip) {
if(!assumeOnSkip)
if (metric != null)
Util.runToFirstDifference(waitKeys, moves, metric);
else
Util.runToNextInputFrame(waitKeys, waitKeys);
while(skips-- > 0) {
curGb.step(waitKeys);
if (metric != null)
Util.runToFir... |
0d2fb0fa-ae79-40b0-b8eb-46b941aa93bd | 7 | private static List<Ordenador> getOrdenadores(NodeList ordenadoresList) throws Exception {
List<Ordenador> ordenadores = new ArrayList<Ordenador>();
for (int i = 0; i < ordenadoresList.getLength(); i++) {
if (ordenadoresList.item(i) instanceof Element) {
Element ordenadorElement = (Element) ordenadoresLis... |
73b0c832-383e-4d73-9c21-569f0d66dc5a | 7 | @Override
public boolean checkMouseClick(Vector2f v, int button) {
if (this.contains(v.x,v.y)){
state = select;
clicked = true;
}
else{
state = normal;
clicked = false;
}
if (clicked && button == 0){
return true;
}
else if (clicked && button == 1 && hasItem){
item.use(parent);
if ... |
84d4c247-293d-4c3e-9040-c19689fe17d7 | 2 | public OrdenCliente deserializar(DatagramPacket paquete) {
ByteArrayInputStream bytesDelPaquete = new ByteArrayInputStream(paquete.getData()); // bytes es el byte[]
try {
ObjectInputStream is = new ObjectInputStream(bytesDelPaquete);
OrdenCliente objetoAuxiliar = (OrdenC... |
0d73ebfe-a587-4ee8-969b-137f580c2610 | 5 | */
public void draw(Graphics g){
if(!animate){
g.drawImage(img, 0, 0,jPanel);
}else if(animationCountdown > 0){
if(animation != null){
g.drawImage(animation, 0, 0,jPanel);
}else if(gifAnimation!=null){
g.drawImage(gifAnimation, 0, 0,jPanel);
}else{
g.drawImage(img, 0, 0,jPanel);
}
... |
5c30890c-534d-40af-b007-f30a593e9c5d | 5 | public boolean solved(){
boolean flag = true;
for( int i=0; i<DIGITS && flag; i++ ){
for( int j=0; j<DIGITS && flag; j++ ){
flag = (board[i][j]>0);
}
}
return flag && valid();
} |
5a14674b-14b8-4739-ae9e-cb5941af49ff | 7 | @Override
public boolean okMessage(final Environmental myHost, final CMMsg msg)
{
final MOB invoker=this.invoker;
final Physical affected=this.affected;
if((affected==null)||(!(affected instanceof MOB))||(invoker==null))
return true;
final MOB mob=(MOB)affected;
if(invoker.location()!=mob.location())
... |
c057f3c1-82ae-40c1-bb4a-0306113eaee1 | 3 | public int[] sort(int[] tmpArray){
// the c[] is defined by the maximum number among tmpArray
int[] count = new int[10];
int[] sortArray = new int[tmpArray.length];
// count
for(int i=0; i<tmpArray.length; i++){
count[tmpArray[i]]+=1;
}
// accumulate
for(int i=0; i<count.length-1; i++){
count[i+1]... |
1e3fe85c-ff59-4af3-a30b-491d8152c640 | 4 | public boolean createSignalBlock(SignalBlock other) {
if (other == this) {
printDebugPair("Signal Block creation was aborted, cannot pair with self.", other.tile);
return false;
}
printDebugPair("Signal Block creation being attempted.", other.tile);
Status myTrack... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.