method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
07dd16cb-ff88-4754-b325-5b7e7f5abc3f | 7 | protected Operation [] getOptimalOperations(BayesNet bayesNet, Instances instances, int nrOfLookAheadSteps, int nrOfGoodOperations) throws Exception {
if (nrOfLookAheadSteps == 1) { // Abbruch der Rekursion
Operation [] bestOperation = new Operation [1];
bestOperation [0] = getOptimalOperatio... |
c30c0336-c57b-4852-a7ec-5c1f8a40e2f1 | 3 | public static void main(String[] args) {
String configFile = "snpEff.config";
String genomeToTest = "";
// Parse command line arguments
if (args.length <= 0) {
System.err.println("Usage: TestCaseCompareCds genomeToTest\n");
System.exit(-1);
}
// Command line argument parsing
if (args[0].equals("-c... |
e20dc9d1-412f-4b47-90be-fb09bcb4d062 | 4 | @Override
public void run() {
try {
String line;
while (!isInterrupted()) {
line = in.readLine();
if (line != null)
try {
queue.offer(line);
} catch (NullPointerException npe) {
System.out.println("failed message offer");
}
else
close();
}
} catch (IOException e... |
0113b754-38e0-4632-8750-2c590b889b50 | 9 | public boolean skipPast(String to) throws JSONException {
boolean b;
char c;
int i;
int j;
int offset = 0;
int length = to.length();
char[] circle = new char[length];
/*
* First fill the circle buffer with as many characters as are in the
* to str... |
f7020f1f-74ab-44a2-80da-8226b05173ab | 4 | public Matrix plus(Matrix m)
{
//Once again test the boudns of each matrix.
if(this.numRows != m.numRows || this.numColumns != m.numColumns){
System.out.println("Error: matrix arguments are not compatible for addition!");
return null; // placeholder
}
//Perform normative addition
int[][] result = ne... |
4c892a6f-370d-4e33-bfe9-926e616d0aed | 9 | protected Notification tryRegister(Iterable<? extends Converter> converters) {
Notification notification = new Notification();
if(converters == null)
return notification;
// XXX can't use foreach here, since the hasNext() and next() operations themselves may fail
try {
Map<Converte... |
d53be42c-a76e-45ad-b6af-10d4116af257 | 9 | public Rover(Integer x, Integer y, String direction) {
super();
if (x == null) {
throw new IllegalArgumentException("X co-ordinate can't be NULL");
}
if (x < this.minBorder || x > this.maxBorder) {
throw new IllegalArgumentException("X co-ordinate must be within 0 - 9");
}
if (y... |
e27c3426-0eff-449f-9264-bc406090a019 | 3 | public TextLogger(String filename) {
datestampformat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss");
timestampformat = new SimpleDateFormat("'['H':'mm':'ss'] '");
cal = Calendar.getInstance();
datestamp = datestampformat.format(cal.getTime());
try {
if (writer != null)
writer.close();
file... |
845f92e4-3cd7-431e-a856-218323397dbb | 1 | public static boolean createFile(File file) throws IOException {
if(! file.exists()) {
makeDir(file.getParentFile());
}
return file.createNewFile();
} |
334c9315-69a8-4aac-82d9-1f227367effa | 2 | public double[][] getGridDydx2(){
double[][] ret = new double[this.nPoints][this.mPoints];
for(int i=0; i<this.nPoints; i++){
for(int j=0; j<this.mPoints; j++){
ret[this.x1indices[i]][this.x2indices[j]] = this.dydx2[i][j];
}
}
... |
02786427-e6c4-44cf-ad78-90fbd9ca2d78 | 7 | static double incompleteBetaFraction2( double a, double b, double x ) {
double xk, pk, pkm1, pkm2, qk, qkm1, qkm2;
double k1, k2, k3, k4, k5, k6, k7, k8;
double r, t, ans, z, thresh;
int n;
k1 = a;
k2 = b - 1.0;
k3 = a;
k4 = a + 1.0;
k5 = 1.0;
k6 = a + b;
k7 = a + 1.0;;
... |
680f199c-5411-4f17-b861-75d65a20ecf1 | 1 | public void doTest() {
props.put("newKey1", "newVal1");
props.put("newKey2", "newVal2a=newVal2b");
props.put("newKey3", "items " + String.valueOf(props.size()+1) );
Iterator iter = props.entrySet().iterator();
while(iter.hasNext()) {
Map.Entry entry = (Map.Entry)iter.next();
... |
2987769e-d59a-4d9b-b81c-9864c7589045 | 6 | public static void main(final String[] args) {
final int x = 1000;
for (int i = 1; i < (x + 1); i++)
for (int j = 1; j < (x + 1); j++)
for (int z = 0; z < x; z++) {
final int k = j + z;
if ((((i * i) + (j * j)) == (k * k)) && (i < j))
if ((i + j + k) == x)
// System.out.println("... |
edea74ed-4e69-4ccc-abf3-fd58745e1b81 | 0 | public String toString() {
return this.operatingSystem.toString() + "-" + this.browser.toString();
} |
0e9ae727-4b85-4bef-8617-45b6b27890be | 1 | public void removeKeyListener(KeyListener l) {
if(l == null) {
return;
}
this.keyListener = null;
} |
631b1a7c-e2c8-4785-903b-4c5ee2ea9343 | 9 | Space[] won() {
int n = numToWin - 1;
if (lastSpaceMoved == null)
return null;
int[] pos = lastSpaceMoved.getPos();
for (int i = 0, rowInd = pos[0]; i <= n; i++, rowInd = pos[0] - i)
for (int j = 0, colInd = pos[1]; j <= n; j++, colInd = pos[1] - j) {
boolean outOfBounds = rowInd < 0 || colInd < 0
... |
d28e9706-a333-4f3e-89db-616ca200dab1 | 0 | private String escapeXMLAttribute(String text) {
text = StringTools.replace(text, "&", "&");
text = StringTools.replace(text, "<", "<");
text = StringTools.replace(text, "\"", """);
text = StringTools.replace(text, ">", ">");
return text;
} |
0aed729f-78d9-4767-b755-dd0dfefb22eb | 2 | public static void makeRandomDouble(Matrix matrix) throws MatrixIndexOutOfBoundsException {
int rows = matrix.getRowsCount();
int cols = matrix.getColsCount();
double temp = 0;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
// fill with ran... |
0aab45df-2797-41db-acc4-8de61a47f1c0 | 0 | public int size() {
return this.length;
} |
1556d1b5-ee7b-4bf6-ae71-ff846f1bc0f1 | 0 | @Override
public String getErrorPath() {
System.out.println("getErrorPath");
return super.getErrorPath();
} |
c733d744-66bd-4fed-aa29-1ba9cf275762 | 6 | public void handlePackReply(Node sender, Node receiver, PackReplyOldBetEtx message) {
// o sink nao deve manipular pacotes do tipo Relay
if(this.ID == message.getSinkID()){
return;
}
double etxToNode = getEtxToNode(message.getFwdID());
// necessaria verificacao de que o no ja recebeu menssagem de ... |
b8fa1282-c1ab-452d-8b0f-6074f911a49e | 3 | public DisplayMode findFirstCompatibleMode(DisplayMode modes[]){
DisplayMode goodModes[] = vc.getDisplayModes();
for(int x=0;x<modes.length;x++){
for(int y=0;y<goodModes.length;y++){
if(displayModesMatch(modes[x], goodModes[y])){
return modes[x];
}
}
}
return null;
} |
2d85d51e-e6d9-4e9f-9089-03d9679d2c0b | 0 | @Override
public final boolean isDebug() {
return debug;
} |
2193c569-fcca-45ec-aa32-69de4abbfcde | 8 | private String getPropertyValue(Properties properties, String key) {
String value = properties.getProperty(key);
if (!key.contains("$") && (value == null || !value.contains("$"))) {
return value;
} else {
if (key.contains("$")) {
value = key;
}
String[] array = value.split("\\$");
for (int i = ... |
84c5e0c3-1939-40f1-9766-d8b395754190 | 8 | public void menuAction(JMenu selectMenu) {
MainFrame mainFrame = MainFrame.getInstance();
AttdFrame workingFrame = mainFrame.getCurrentFrame();
workingFrame.setVisible(false);
for (int i = 0; i < menu.length; i++) {
if (menu[i].equals(selectMenu)) {
switch(i) {
case 0:
mainFrame.setCurrentFrameE... |
74c8e05b-41e7-4d25-a3c3-d61b4990fe33 | 0 | public String getUsername()
{
return username;
} |
eacbb2b4-999f-41c1-a412-0151fac98e39 | 7 | public int compare(TradeOrder order1, TradeOrder order2)
{
if ((order1.isMarket()) && (order2.isMarket()))
{
return 0;
}
else if ((order1.isMarket()) && (order2.isLimit()) || (order1.isLimit()) && (order2.isMarket()))
{
return -1 * (int) Math.random() * 99; //Fun random negative value (kind of unnecess... |
5e274ade-06c3-468b-9741-25c0567d3657 | 1 | public void setSalary(double newSalary)
{
if(newSalary >= 0.0)
{
salary = newSalary;
}
} |
27593123-e4f1-428a-8bdc-39e5bf065270 | 4 | @Override
public Map<String, String> getParsedResults() {
if (!resultingMap.isEmpty()) {
return resultingMap;
}
String[] lines = stringBuilder.toString().split("\n");
for (String line : lines) {
line = line.trim();
if (line.startsWith("时间:")) {
parseStartAndEndTime(line.substring("时间:".length()));... |
adb99e54-af3a-4e57-8d06-1e64ad814335 | 9 | private void reduce_0(int reduction) throws IOException, LexerException, ParserException
{
switch(reduction)
{
case 0: /* reduce AFactorExpr */
{
ArrayList<Object> list = new0();
push(goTo(0), list, false);
}
break;
... |
b98a6377-ff7c-4780-8860-a70dfb38c7a3 | 3 | public List<File> filterDirectories() {
List<File> f = new ArrayList<File>();
for (String s : l) {
File sf = new File(s);
if (sf.isDirectory() && sf.exists()) {
f.add(sf);
}
}
return f;
} |
a05c7a4f-7b93-40ce-bba9-4c5f449c3cf8 | 1 | public static boolean isTheft(int s) {
if(s==53185)
return true;
return false;
} |
bf927325-2780-4f03-8054-af980b577277 | 7 | public void clicked() // changes the color of the buttons and if [x][y] is
// "0" set the label to nothing
{
for (int x = 0; x < row; x++) {
for (int y = 0; y < col; y++) {
if (checkwinbool[x][y] == true && flag[x][y] == false && bomb[x][y] == false)
table[x][y].setBackground(Color.darkGray);
... |
bb5a81b0-6075-4c75-abe1-bb81063ff5e2 | 3 | public void draw(Graphics g){
if(kind==1)
g.setColor(new Color(0,255,255,(int)(alpha*255)));
else if(kind==2)
g.setColor(new Color(255,0,255,(int)(alpha*255)));
else if(kind==4)
g.setColor(new Color(0, 255, 0, (int) (alpha * 255)));
else
g.... |
851c3a19-8697-4e50-858f-0dfa64fef13c | 0 | @Override
public void applyTemporaryToCurrent() {cur = tmp;} |
e43399ad-b27d-4848-adaa-0ac4dfbd4bff | 6 | public ArrayList<Node> generateDoubleStart(int k, int type){
ArrayList<Node> nodes = new ArrayList<Node>();
for(int i =0;i<2*k;i++)
{
nodes.add(new Node(i));
}
Link link;
// Create first star with centre node k-1
for(int i=0;i<k-1;i++)
{
... |
35960287-6ae2-4794-9f97-9fef4f82d431 | 0 | public GameCanvas(ProBotGame game) {
this.game = game;
setIgnoreRepaint(true);
setFocusable(false);
} |
736f342b-1f2f-4e68-9c94-37b0b2d12016 | 5 | private void setConfig()
{
HashMap<String,Object> pl = null;
Yaml yamlCfg = new Yaml();
Reader reader = null;
try {
reader = new FileReader("plugins/Clans/Config.yml");
} catch (final FileNotFoundException fnfe) {
System.out.println("Config.YML Not Found!");
try{... |
e2e58aa4-6cb5-4939-8182-40f0bf841069 | 6 | public IncomingPeerListener(int port) {
super("TorrentListener");
log.debug("Binding incoming server socket");
while (port < 65535 && serverSocket == null) {
try {
serverSocket = new ServerSocket(port);
} catch (Exception e) {
log.debug("Ca... |
5d16f186-51b6-4829-a938-3dbb70ba532c | 6 | public void computerTurn()
{
myFrame.getContainerPanel().getButtonPanel().disableButton("s");
myFrame.getContainerPanel().getButtonPanel().disableButton("h");
myFrame.getContainerPanel().getButtonPanel().disableButton("n");
while (cHand.getHandValue() <= pHand.getHandValue() && cHand... |
90e06fa9-b131-40bb-865d-5eb4d4e07278 | 4 | public boolean containsFiveNinesNoMeld() {
int numberOfNines = 0;
for (Card card : currentCards) {
if(card.face.equals(Face.Nine))
numberOfNines++;
}
if(numberOfNines >= 5 && new CalculateMeld(null, currentCards).calculate() == 0)
return true;
return false;
} |
20900098-4985-4499-a2d3-5ff0717606c1 | 7 | @Test
public void placeFiguresKnightAndKing() {
HashMap<String, Integer> figureQuantityMap = new HashMap<>();
figureQuantityMap.put(KNIGHT.toString(), 2);
figureQuantityMap.put(KING.toString(), 2);
FiguresChain figuresChain = new King(figureQuantityMap);
figuresChain.setNext... |
13ebe326-fc34-4670-be65-c904b3b8a127 | 8 | public Node<T> reverse(Node<T> p_linkedList, Node<T> p_linkedList1, Comparator<T> p_comparator) {
if(p_linkedList == null) {
return p_linkedList1;
}
if(p_linkedList1 == null) {
return p_linkedList;
}
Node<T> l_result = null;
Node<T> l_list1 = p_linkedList;
Node<T> l_list2 = p_linkedList1;
Node... |
25c9a726-ac00-44ff-a006-dffc2a4830aa | 1 | private void drawOrbit(Subject subject, Coordinate parentPos) {
double currentScale = radiusScale;
if (subject.depth() > 2) {
currentScale = radiusMoonScale;
}
double radius = subject.p.radius * currentScale;
// g.setStroke(dashed);
g.setColor(PATH_COLOR);
... |
813fae7a-6955-48b0-9bec-3cecb91fbe85 | 1 | public String getColumnName(int col) {
try {
return viewer.getColumnName(col);
} catch (Exception err) {
return err.toString();
}
} |
bc300ba1-74b2-47d2-ae11-f5c4803de8ff | 2 | public void mouseClicked(MouseEvent evt) {
if (evt.getSource()==mapimage || evt.getSource()==newsimage){
display();
}
} |
9b6a31d4-7c30-4bdc-ba25-f52bd8aa46b3 | 6 | private ColumnComparator makeSumColumnComparator(Element elSum) throws Exception
{
String type = elSum.getAttribute("type").toLowerCase();
boolean ascending = !(elSum.getAttribute("order").toLowerCase().equals("descending"));
String defaultString = elSum.getAttribute("default");
ArrayList<NumberN... |
86cf5ddc-134b-40af-b6cd-e2f6b7ca9205 | 8 | public void run(){
Logger.log("IN run");
Comparable<?>[] splits = null;
try {
splits = initTask.execute();
} catch (FileSystemException e) {
//cannot happen checked file in constructor
// TODO delete
e.printStackTrace();
}
int numberOfReducers = splits.length + 1;
reducerTaskArray = new Reduc... |
e0e6f74b-a542-438c-b9c8-0b06596638f9 | 4 | public static List<Sale> formatOutputs(JSONArray results) {
final List<Sale> ret = new ArrayList<Sale>();
for (int i = 0; i < results.length(); i++) {
JSONObject r = null;
if (results.get(i) instanceof JSONObject)
r = (JSONObject) results.get(i);
if (r != null) {
final Sale s = new Sale();
s.s... |
d50c2522-efef-4918-b9bb-b8f7deaecc47 | 9 | public void drawRedraw(Graphics2D graphics) {
if (running) {
this.randomPoint.drawPoint(graphics);
if (this.snake1.isWithinLimits() && this.snake1.canPlay()) {
this.snake1.updateMovement();
this.snake1.drawPoints(graphics);
if (this.snake1.interact(randomPoint)) {
randomPoint.setCenter(Po... |
bf5dbbdf-ceec-45fe-bfaf-288536f9ea1b | 6 | public static boolean wait(LoopCondition condition, int frequency, int tries) {
tries = Math.max(1, tries + org.powerbot.script.Random.nextInt(-1, 2));
for (int i = 0; i < tries; i++) {
try {
Thread.sleep((long) Math.max(5, (int) ((double) frequency * org.powerbot.script.Random.nextDouble(0.85, 1.5))));
}... |
47d68894-a42f-45e0-bec7-c1ecf0b2dd73 | 2 | public static String stripQuotes(String msg)
{
if (msg.startsWith("\""))
msg = msg.substring(1);
if (msg.substring(msg.length() - 1).equals("\""))
msg = msg.substring(0, msg.length() - 1);
return msg;
} |
0d5aab4e-a1dc-4766-8d64-b756979cf7d6 | 7 | private void foundTrips() {
rank = Rank.THREEOFAKIND;
Card.Rank tripRank = null;
// Find the biggest trips
for (int i = 0; i < ranks.length; i++) {
Card[] value = ranks[i];
if (value == null) continue;
if (numRanks[i] == 3) {
tripRank =... |
c2f8b155-ffef-467f-b1c2-900e4fec7152 | 6 | private void createEmptyBoard(int cols, int rows) {
for(int y = 0; y < cols; y++) {
for(int x = 0; x < rows; x++) {
if(y == 0 || x == 0) {
squares[y][x] = SquareType.OUTSIDE;
}else if(y == cols-1 || x == rows-1) {
squares[y][x] = SquareType.OUTSIDE;
}else {
squares[y][x] = SquareType.EMP... |
d6c90cb9-f370-47b6-a624-54f626e39e64 | 5 | public static void testMouFitxa()
{
if ( taulers.size() > 0 )
{
String jugador = llegeixParaula( "Escull un jugador (A, B, cap):" );
EstatCasella fitxa;
if ( jugador.equalsIgnoreCase( "A" ) )
{
fitxa = EstatCasella.JUGADOR_A;
}
else if ( jugador.equalsIgnoreCase( "B" ) )
{
fitxa = Esta... |
dcc47ca6-7984-4e39-9dac-59be31e17bd4 | 6 | public boolean isSameTree(TreeNode p, TreeNode q) {
if (p == null && q == null)
return true;
if (p == null || q == null)
return false;
return (p.val == q.val && isSameTree(p.left,q.left) && isSameTree(p.right, q.right));
} |
e786276a-e99b-4804-8bb5-503f769615ca | 8 | @Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == btnMakeAppointments) {
//GOTO make appointments
ViewAppointmentPanel vap = new ViewAppointmentPanel(parent, username);
parent.getContentPane().add(vap);
CardLayout cl = (CardLayout) parent.getContentPane().getLayout();
c... |
8f21d0e9-e9d0-4a00-85e8-1eed038efd95 | 9 | public void actionPerformed(java.awt.event.ActionEvent arg0){
if (bankMode) // dans le cas d'echange avec la banque
{
if (arg0.getSource()==plusM){
deposit = true;
quantiteM=quantiteM + specialization;}
else if (arg0.getSource()==moinsM){
deposit = false;
quantiteM=quantiteM... |
327a069b-e2c0-4a23-945d-13cf74bbbce2 | 4 | public void communicate() throws IOException {
new Thread(new Runnable() {
public void run() {
try {
String str = sbr.readLine();
while (str != null) {
System.out.println(str);
str = sbr.readLine();
}
System.err.println("Disconnected by server");
} catch (IOException e) {
... |
710c1090-9101-4464-a5bc-ef1c99d800ed | 4 | @Override
public boolean retainAll(Collection<?> arg0) {
boolean changed = false;
for(int i = 1; i < mobs.length; i++) {
if(mobs[i] != null) {
if(!arg0.contains(mobs[i])) {
mobs[i] = null;
size--;
changed = true;
}
}
}
return changed;
} |
028aec88-d031-445c-bd04-ad51c5b05a35 | 1 | @Override
protected void readMessage(InputStream in, int msgLength)
throws IOException {
super.readMessage(in, msgLength);
int pos = 2;
while (pos < msgLength) {
QoS qos = QoS.valueOf(in.read());
addQoS(qos);
pos++;
}
} |
791611a5-eba7-4ab4-873f-fb740685cf39 | 8 | public void setTraversalMap(int locx, int locy, MazeMap mazeMap) {
int frontM, rightM, leftM;
mazeVal = mazeMap.getMazeVal(locx, locy);
//System.out.format("MazeVal(%d, %d): %x\n", locx, locy, mazeVal);
switch (curDirec) {
case 0:
front = 0;
ri... |
8944b7af-4a34-4e72-a10b-509c8547b28f | 9 | private void extractAlignedSeqInfo(java.util.List<CigarElement> cigar, byte[] sequence, byte[] qual, SAMRecord aln) {
// read info
isReadReversed = aln.getReadNegativeStrandFlag();
// aligned seq info
Vector<Byte> as = new Vector<Byte>();
Vector<Byte> aq = new Vector<Byte>();
int pos = 0;
for (CigarEle... |
beecb6c3-e768-4c2b-b8a8-cff38aef3f6b | 1 | public static void run() {
IMediaReader mediaReader = ToolFactory.makeReader(inputFilename);
// stipulate that we want BufferedImages created in BGR 24bit color space
mediaReader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
ScreenShotsManager manager = new ScreenShots... |
557642b2-c578-4acd-b00c-6104ec590048 | 6 | @Override
public void paintComponent(Graphics g) {
GregorianCalendar currentTime = (GregorianCalendar) GregorianCalendar
.getInstance();
hour = currentTime.get(Calendar.HOUR_OF_DAY);
minutes = currentTime.get(Calendar.MINUTE);
seconds = currentTime.get(Calendar.SECOND);
int xcenter = 150, ycenter = 150;
... |
508017d1-09bc-47ae-a0f4-f6ab6a4feee3 | 4 | public static MessageAdaptor wrapMessage(Message message)
throws JMSException {
MessageAdaptor adaptor = null;
if (CameraCaptureRequest.TYPE.equals(message.getJMSType())) {
adaptor = new CameraCaptureRequest();
} else if (CameraCaptureResponse.TYPE.equals(message.getJMSTy... |
f6b3d76e-392a-4ca0-a7a5-57b539a26292 | 1 | public String bytesToHex(byte[] raw)
{
int length = raw.length;
char[] hex = new char[length * 2];
for(int i = 0; i < length; i++)
{
int value = (raw[i] + 256) % 256;
int highIndex = value >> 4;
int lowIndex = value & 0x0f;
hex[i * 2 + ... |
9bb34da8-3e85-4084-926c-b8f43f102862 | 7 | public static void main(String[] args) throws FileNotFoundException, IOException{
Scanner scan = new Scanner(System.in);
String file = "ptb-flat.txt";
WordsTree tree = new WordsTree();
boolean on = true;
while(on) {
System.out.println("BEM-VINDO AO EXTRACTDICTIONARY... |
8dfacb8d-17e8-41b3-88bc-15a04701273a | 5 | public void deleteLayerFile(int selectedLayer) {
File layer = new File(workingDir, "Layer" + selectedLayer + ".dat");
File layerColl = new File(workingDir, "Layer" + selectedLayer + "_Collision.dat");
if(layer.exists()) layer.delete();
if(layerColl.exists()) layerColl.delete();
if(Layers >= selectedLayer) {
... |
f44ec76e-441c-4400-9250-a3dbc1d73e51 | 2 | public void run() {
String importantInfo[] = {
"Mares eat oats",
"Does eat oats",
"Little lambs eat ivy",
"A kid will eat ivy too"
};
try {
for (int i = 0; i < importantInfo.length; i++) {
... |
75dca812-e34b-4bdd-9a21-c33c6978ff0b | 6 | public LinearGradientPaintContext(ColorModel cm,
Rectangle deviceBounds,
Rectangle2D userBounds,
AffineTransform t,
RenderingHints hints,
... |
70a7fc59-6935-4eaa-aea5-8e0de49a5f4c | 5 | public static int[] insertionSort(int[] array, boolean ascendingOrder) {
if (array != null && array.length > 1) {
for (int i = 1; i < array.length; i++) {
for (int j = i; j >= 1; j--) {
if (Utils.compareOrder(array[j], array[j - 1], ascendingOrder)) {
Utils.swap(array, j, j - 1);
} else {
... |
049f0a96-8b59-43a2-9cfc-b6f8454b4570 | 0 | public ClusterNode getLastNode() {
return this.lastNode;
} |
fd74094f-7b75-4eb3-a51d-fffc1bbcc6e5 | 2 | private boolean isEndOfLine(int c) throws IOException {
// check if we have \r\n...
if (c == '\r') {
if (in.lookAhead() == '\n') {
// note: does not change c outside of this method !!
c = in.read();
}
}
return (c == '\n');
} |
854fe807-e630-4e6b-a8ce-4686fcce316e | 6 | public static boolean[][] rectangle() {
boolean patron[][] = new boolean[maxFil][maxCol];
for (int f=0; f<maxFil; f++) {
for (int c=0; c<maxCol; c++) {
if (f >= maxFil/4 && f <= 3*maxFil/4 &&
c >= maxCol/4 && c <= 3*maxCol/4) {
patron[f][c] = true;
} else {
patron[f][c] = false;
... |
30f045b7-c2e3-494f-b50e-5c96a3b1290c | 1 | public void generateUnit(Dimension size) {
unit.value = (size.width < size.height ? size.width / (FIELD_DIMENSION.width + 2) : size.height / (FIELD_DIMENSION.height + 2));
} |
53a051d8-039d-44ab-bea2-059859309868 | 3 | public Type checkType(TypeMap tm)
{
Type t = new Type();
t.typeid = Type.TypeEnum.t_error;
Type tmp = e.checkType(tm);
if(tmp.OK())
{
if(tmp.typeid == Type.TypeEnum.t_pair)
{
t.typeid = tmp.t1.typeid;
}
else
{
if(Type.isDebug)
{
System.out.println("TypeError! fst: "+tmp.typeid... |
63c3d39e-28e7-49ae-8fe5-410a6a39c23d | 9 | static double prim(double[][] mAdy,int n){
boolean[] v=new boolean[n];
double[] a=new double[n];
PriorityQueue<double[]> cola=new PriorityQueue<double[]>(n,new Comparator<double[]>(){
public int compare(double[] o1,double[] o2){
if(o1[0]<o2[0])return -1;
if(o1[0]>o2[0])return 1;
if(o1[1]<o2[1])retu... |
881238f1-9cd7-4ed9-9967-5e55bf15fe35 | 3 | @WebMethod(operationName = "ReadSupplier")
public ArrayList<Supplier> ReadSupplier(@WebParam(name = "sup_id") String sup_id) {
Supplier sup = new Supplier();
ArrayList<Supplier> sups = new ArrayList<Supplier>();
ArrayList<QueryCriteria> qc = new ArrayList<QueryCriteria>();
... |
0433d352-8b41-4b11-b1dd-3b2f59ec2bb2 | 8 | @Override
public SpeedVector getSpeedVector(Movable m) {
SpeedVector currentSpeedVector, possibleSpeedVector;
currentSpeedVector = m.getSpeedVector();
possibleSpeedVector = super.getSpeedVector(m);
int nbTries = 10;
while (true) {
nbTries--;
if ((possibleSpeedVector.getDirection().getX() == currentSp... |
38f2121b-5e67-4dd3-a209-043c6f15bc94 | 8 | public String longestCommonPrefix(String[] strs) {
if (strs == null || strs.length == 0) {
return "";
} else if (strs.length == 1) {
return strs[0];
}
String prefix = "";
int length = Integer.MAX_VALUE;
for (String s : strs) {
length = Math.min(s.length(), length);
}
for (int i = 0; i < length;... |
879798e6-e5f9-4b0c-8779-02777d8a08c4 | 0 | public ArrayList<Day> getDays()
{
return days;
} |
b16dadae-4467-4eed-b48a-29363e3e8449 | 5 | public boolean actionSmelt(Actor actor, Smelter smelter) {
int success = 0 ;
if (actor.traits.test(HARD_LABOUR, 10, 1)) success++ ;
if (! actor.traits.test(CHEMISTRY, 5, 1)) success-- ;
if (actor.traits.test(GEOPHYSICS, 15, 1)) success++ ;
if (success <= 0) return false ;
final Item sample ... |
0a0ba700-99da-45d8-affd-8498159288d6 | 2 | public static void DoTurn(PlanetWars pw) {
//notice that a PlanetWars object called pw is passed as a parameter which you could use
//if you want to know what this object does, then read PlanetWars.java
//create a source planet, if you want to know what this object does, then read Planet.java
Planet... |
a6959620-98a0-44e2-af6c-dda7a96742db | 0 | @XmlElementDecl(namespace = "http://www.w3.org/2001/04/xmlenc#", name = "CipherData")
public JAXBElement<CipherDataType> createCipherData(CipherDataType value) {
return new JAXBElement<CipherDataType>(_CipherData_QNAME, CipherDataType.class, null, value);
} |
280d30a0-6bdf-4d25-820b-0cca50011635 | 0 | public Object getValue(int index) {
return params.get(index);
} |
dac57b41-0d48-49d3-9b96-fd7e080a4540 | 2 | public static double[][] scale( double[][] mat, double fac )
{
int m = mat.length;
int n = mat[0].length;
double[][] res = new double[m][];
for ( int i = 0; i < m; ++i )
{
res[i] = new double[n];
for ( int j = 0; j < n; ++j )
res[i][j] = mat[i][j] * fac;
}
return(res);
} |
20a40354-8f7a-4346-8785-e8d20d730c5a | 4 | public void run()
{
RowDto<PixelDto> pixelRowDto;
RowDto<HeightDto> heightRowDto;
while (running.get() || ImageStorage.pixelRowHasNext())
{
pixelRowDto = ImageStorage.getPixelRow();
if (pixelRowDto != null)
{
heightRowDto = new RowDto<HeightDto>();
while (pixelRowDto.hasMore())
{
pr... |
5e7bd63a-2bff-4060-993d-7bc0aff1aaf5 | 6 | public void actionPerformed(ActionEvent event) {
if (event.getSource() == pTextField) {
String text = String.format("%s", event.getActionCommand());
System.out.println("price == " + text);
p = Double.parseDouble(text);
}
if (event.getSource() == dpTextField) {
String text = event.getActionC... |
190bd018-eb01-41b8-a4b8-a8ee81ffb0ba | 0 | public void update(Point p) {
((GeneralPath) shape).lineTo(p.x, p.y);
dollar.pointerDragged(p.x, p.y);
canvas.repaint();
} |
249ed614-a11b-4670-8a3d-4333fd61ce2e | 5 | @Raw @Model
private void setCurrentHitPoints(int hitPoints) {
int oldHP = this.currentHitPoints;
this.currentHitPoints = (hitPoints <= 0) ? 0 : Math.min(hitPoints, getMaximumHitPoints());
if (hitPoints <= 0 && oldHP > hitPoints && this.getWorld() != null && this.getWorld().getActiveWorm() == this) //so this does... |
b22dc713-d30d-402d-b6d7-7bb6555f7dda | 0 | public String getFeetype() {
return Feetype;
} |
b79b6883-f16c-4511-b714-6bd0e0ce6d90 | 7 | public void renderSprite(int xp, int yp, Sprite sprite, boolean fixed) {
if (fixed) {
xp -= xOffset;
yp -= yOffset;
}
for (int y = 0; y < sprite.getHeight(); y++) {
int ya = y + yp;
for (int x = 0; x < sprite.getWidth(); x++) {
int xa = x + xp;
if (xa < 0 || xa >= width || ya < 0 || ya >= heig... |
176d1f76-4f40-4107-a584-5927b1635852 | 1 | public ThreadPool(int numThreads) {
queue = new LinkedBlockingQueue<Runnable>();
threads = new Thread[numThreads];
int i = 0;
for (Thread t : threads) {
i++;
t = new Worker("Thread "+i);
t.start();
}
} |
9ad820e1-9595-46b6-a3d9-553ad0983cea | 5 | public void putBlock(Block block){
score++;
statusBar.setText("SCORE = " + String.valueOf(score));
RestartButton.setText("Restart");
//int [][] theBlock = block.getBlock();
//int k = (int)(Math.random() * MAX_COL);
BlockPosX = 5;
BlockPosY = 0;
int posX = 5;
int posY = 0;
BlockInControl = block;
int x = 0;... |
4a8a7021-fca4-4546-bd3f-af6f2225313f | 8 | XLightWebResponse(
final HttpClient client,
final BOSHClientConfig cfg,
final CMSessionParams params,
final AbstractBody request) {
super();
IFutureResponse futureVal;
try {
String xml = request.toXML();
byte[] data = xml.g... |
468e3856-4171-4d8c-82d4-ee912b74f8a9 | 1 | public static final Cycle getCycleCorrespondant(String nomCycle) throws Exception {
Cycle cycle = null;
if (nomCycle.equals("2012-2014")) {
cycle = new Cycle2012_2014();
} else {
throw new Exception("Cycle " + nomCycle + " n'est pas supporté.");
}
return c... |
6b0d4fab-51f8-4a44-9047-dde90c6a5581 | 7 | public final int getNextCharWithBoundChecks() {
if (this.currentPosition >= this.eofPosition) {
return -1;
}
this.currentCharacter = this.source[this.currentPosition++];
if (this.currentPosition >= this.eofPosition) {
this.unicodeAsBackSlash = false;
if (this.withoutUnicodePtr != 0) {
unicodeStore();
... |
8bca9657-ebb3-476b-b8be-87a103c7e591 | 2 | public synchronized Entity getEntity(int id) {
for (Entity e : getEntities()) {
if (e.getId() == id)
return e;
}
return null;
} |
1628feba-e385-4bc1-b6e6-978f2481ba75 | 1 | private static final void pad2(int value, StringBuilder buffer) {
if (value < 10) {
buffer.append('0');
}
buffer.append(value);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.