method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
cb7124f8-62af-4a8e-b03f-c46580e1e9ba | 7 | public static void _init(){
try{
String RunId = GlobalProperties.items.getRunID();
String wd = GlobalProperties.items.getWorkingDirectory();
String logFolder = wd+"log", TempFolder = wd+"temp", ResultFolder = wd+"result";
String RunIDinResult = ResultFolder + "/" + RunId + "/";
String LogFile = logFolder + "/Log" + RunId + "_" + Thread.currentThread().getName() + ".txt";
File log = new File(logFolder);
File temp = new File(TempFolder);
File result = new File(ResultFolder);
File runresult = new File(RunIDinResult);
File _logFile = new File(LogFile);
if(!log.exists()){
log.mkdir();
}
if(!temp.exists()){
temp.mkdir();
GlobalProperties.items.setTempFolder(TempFolder+"/");
}else{
File[] tFiles = temp.listFiles();
for(File tf : tFiles){
tf.delete();
}
}
if(!result.exists()){
result.mkdir();
}
if(!runresult.exists()){
runresult.mkdir();
GlobalProperties.items.setRunIDResultFolder(RunIDinResult);
}
if(!_logFile.exists()){
_logFile.createNewFile();
GlobalProperties.items.setLogFileAbsPath(LogFile);
}
}
catch(Exception ex){
System.out.println("Exception in Communique.log._init; Exception message = " + ex.getMessage());
}
} |
3e65bab6-447f-45f5-8818-3097e13f1b03 | 7 | void readZrlePackedRLEPixels(int tw, int th, int[] palette)
throws Exception {
int ptr = 0;
int end = ptr + tw * th;
while (ptr < end) {
int index = zrleInStream.readU8();
int len = 1;
if ((index & 128) != 0) {
int b;
do {
b = zrleInStream.readU8();
len += b;
} while (b == 255);
if (!(len <= end - ptr))
throw new Exception("ZRLE decoder: assertion failed"
+ " (len <= end - ptr)");
}
index &= 127;
int pix = palette[index];
if (bytesPixel == 1) {
while (len-- > 0)
zrleTilePixels8[ptr++] = (byte) pix;
} else {
while (len-- > 0)
zrleTilePixels24[ptr++] = pix;
}
}
} |
42246eeb-dc58-4fc4-9ee6-582c23bf9cc4 | 6 | public boolean move(int newX, int newY) {
boolean movementOK = false;
/*update graphics if wanted*/
if (useGraphics) {
picture.updateGraphics();
}
for (direction d : direction.values()) {
if ((currentCell.locX() + d.xOffset()) == newX
&& (currentCell.locY() + d.yOffset()) == newY
&& currentCell.sI.features[d.index()] == feature.OPEN) {
movementOK = true;
}
}
if (movementOK) {
currentCell.isCurrentCell(false);
currentCell = floorPlan.getCell ( newX, newY );
}
currentCell.isCurrentCell(true);
return movementOK;
} |
857963a0-eb38-4c82-a6f8-4865eb65ad78 | 9 | public static void initCommandLineParameters(String[] args,
LinkedList<Option> specified_options, String[] manditory_args) {
Options options = new Options();
if (specified_options != null)
for (Option option : specified_options)
options.addOption(option);
Option option = null;
OptionBuilder.withArgName("file");
OptionBuilder.hasArg();
OptionBuilder
.withDescription("A file containing command line parameters as a Java properties file.");
option = OptionBuilder.create("parameter_file");
options.addOption(option);
CommandLineParser command_line_parser = new GnuParser();
CommandLineUtilities._properties = new Properties();
try {
CommandLineUtilities._command_line = command_line_parser.parse(
options, args);
} catch (ParseException e) {
System.out.println("***ERROR: " + e.getClass() + ": "
+ e.getMessage());
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("parameters:", options);
System.exit(0);
}
if (CommandLineUtilities.hasArg("parameter_file")) {
String parameter_file = CommandLineUtilities.getOptionValue("parameter_file");
// Read the property file.
try {
_properties.load(new FileInputStream(parameter_file));
} catch (IOException e) {
System.err.println("Problem reading parameter file: " + parameter_file);
}
}
boolean failed = false;
if (manditory_args != null) {
for (String arg : manditory_args) {
if (!CommandLineUtilities.hasArg(arg)) {
failed = true;
System.out.println("Missing argument: " + arg);
}
}
if (failed) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("parameters:", options);
System.exit(0);
}
}
} |
37849dcf-cfb1-4af5-966b-f11930c3e22c | 4 | void mainDiagonal(){
int[][] arrDouble = new int[9][9];
//заполняем массив элементами
for (int i = 0; i < 9; i++){
for (int j = 0; j < 9; j++){
arrDouble[i][j] = (int) (0 + Math.random() * 10);
//System.out.println("Индекс : " + i + " значение :" + arrDouble[i][j] );
}
}
System.out.println("");
//считае сумму элементов до главной диагонали
int x = 0;
for (int i = 1; i < 9; i++){
for (int j = 0 ; j < i; j++){
x += arrDouble[i][j];
System.out.println("Индекс : " + i + " значение :" + arrDouble[i][j] );
}
}
System.out.println("Сумма элементов массива до главной диагонали: " + x);
} |
3752f7b3-4393-4e16-b231-54ab13355315 | 2 | public static boolean isCglibProxyClass(Class<?> clazz) {
return (clazz != null && isCglibProxyClassName(clazz.getName()));
} |
cf63f704-5aeb-4fda-8313-cd5ec007569d | 6 | public void adjustBeginLineColumn(int newLine, int newCol)
{
int start = tokenBegin;
int len;
if (bufpos >= tokenBegin)
{
len = bufpos - tokenBegin + inBuf + 1;
}
else
{
len = bufsize - tokenBegin + bufpos + 1 + inBuf;
}
int i = 0, j = 0, k = 0;
int nextColDiff = 0, columnDiff = 0;
while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
{
bufline[j] = newLine;
nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
bufcolumn[j] = newCol + columnDiff;
columnDiff = nextColDiff;
i++;
}
if (i < len)
{
bufline[j] = newLine++;
bufcolumn[j] = newCol + columnDiff;
while (i++ < len)
{
if (bufline[j = start % bufsize] != bufline[++start % bufsize])
bufline[j] = newLine++;
else
bufline[j] = newLine;
}
}
line = bufline[j];
column = bufcolumn[j];
} |
ef3e7254-f681-47cc-8c6c-6cd53f8f5752 | 9 | public String getNewLine() throws Exception {
String line = cp.getTextField().getText();
String[] split = line.split(" ");
int caretPos = cp.getTextField().getCaretPosition();
String currWord = getWord(line, caretPos, split);
ArrayList<String> names = cp.getUserlist().getList().toArrayList();
String[] ops = {"@", "&", "%", "+", "~"};
for (int i = 0; i < names.size(); i++) {
String s = names.get(i);
if (s.startsWith("+") || s.startsWith("%") || s.startsWith("~")
|| s.startsWith("@")
|| s.startsWith("&")) {
names.set(i, s.substring(1));
}
}
ArrayList<String> matches = new ArrayList<String>();
for (String s : names) {
if (s.toLowerCase().startsWith(currWord.toLowerCase())) {
matches.add(s);
}
}
split[wordNumber] = matches.get(0);
StringBuilder sb = new StringBuilder();
for (String s : split) {
sb.append(s + " ");
}
return sb.toString();
} |
f8dc45e6-55e7-4190-980d-9b936cef13b2 | 1 | public void setVisible(boolean visible) {
if(frame == null) buildGUI();
frame.setVisible(visible);
} |
161080b8-0bf1-456e-b497-b90138c48ac4 | 1 | public Double get_count_sallary(int IdP)
{
Double result = 0.0;
Double wage = 0.0;
Double coeff = 0.0;
wage = t_должностиID_to_t_должностиСтавка( t_должностьId_from_t_людиID(IdP) );
coeff = get_coeffs_expertizes(IdP);
if(wage<0.01) return 0.0;
result = wage + wage*coeff;
return result;
} |
365b890f-480a-4189-acf6-3de2a6075687 | 7 | private final boolean cons(int i)
{ switch (b[i])
{ case 'a': case 'e': case 'i': case 'o': case 'u': return false;
case 'y': return (i==0) ? true : !cons(i-1);
default: return true;
}
} |
799e1d36-9455-41d3-8ed7-244d615397cd | 7 | @Override
public Character[] convertFromString(Class<? extends Character[]> cls, String str) {
if (str.length() == 0) {
return EMPTY;
}
Character[] array = new Character[str.length()];
int arrayPos = 0;
int pos;
while ((pos = str.indexOf('\\')) >= 0) {
for (int i = 0; i < pos; i++) {
array[arrayPos++] = str.charAt(i);
}
if (str.charAt(pos + 1) == '\\') {
array[arrayPos++] = '\\';
} else if (str.charAt(pos + 1) == '-') {
array[arrayPos++] = null;
} else {
throw new IllegalArgumentException("Invalid Character[] string, incorrect escape");
}
str = str.substring(pos + 2);
}
for (int i = 0; i < str.length(); i++) {
array[arrayPos++] = str.charAt(i);
}
return Arrays.copyOf(array, arrayPos);
} |
62b33998-ef95-4ff9-adc1-87643a182987 | 0 | public void setMoveUp(boolean a){
moveUp = a;
} |
aa9c7ba7-49db-405b-a008-384fbea465c4 | 4 | private static void verifyProperty4(RBTreeNode<?, ?> node) {
if (nodeColor(node) == Color.RED) {
assert nodeColor(node.left) == Color.BLACK;
assert nodeColor(node.right) == Color.BLACK;
assert nodeColor(node.parent) == Color.BLACK;
}
if (node == null) return;
verifyProperty4(node.left);
verifyProperty4(node.right);
} |
61b22547-e61d-485c-a2d5-ffdfe5dc8d6a | 4 | private int compareConnectors(Territory a, Territory b, Continent c)
{
Territory[] tA = a.getEnemyConnectors(this);
Territory[] tB = b.getEnemyConnectors(this);
int count = tA.length;
main: for (Territory t : tA)
{
for (Territory tt : tB)
{
if (t == tt || !c.hasTerritory(t))
{
count--;
continue main;
}
}
}
return count;
} |
35ef8b55-1782-4992-806d-821a9be34d32 | 7 | public void keyReleased(KeyEvent keyEvent) {
Iterator<PComponent> it = components.iterator();
while (it.hasNext()) {
PComponent comp = it.next();
if (shouldHandleKeys) {
if (comp.shouldHandleKeys())
comp.keyReleased(keyEvent);
}
else {
if (comp instanceof PFrame) {
for (PComponent component : ((PFrame) comp).getComponents())
if (component.forceKeys())
component.keyReleased(keyEvent);
}
else if (comp.forceKeys())
comp.keyReleased(keyEvent);
}
}
} |
224fcd02-355d-4772-a1de-9d1cbf947ceb | 3 | public void handleAddInputButton() {
if(inputView.getInputList().getSelectedIndex() != -1){
String symbol = (String)inputView.getInputList().getSelectedValue();
if (symbol.equals("Blank Symbol")) symbol = "|_|";
int cell = inputView.getSlider().getValue();
inputView.getInputLabels(cell-1).setText(symbol);
if(cell < 31){
inputView.getSlider().setValue(cell+1);
}
}
} |
d89e0148-c701-46b8-be28-294276beb394 | 7 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof PostID))
return false;
PostID other = (PostID) obj;
if (author == null) {
if (other.author != null)
return false;
} else if (!author.equals(other.author))
return false;
if (timestamp != other.timestamp)
return false;
return true;
} |
594d2052-068b-41ef-8721-2a161a85ca93 | 9 | private void handleKeyPressed(KeyEvent e) {
switch(e.getKeyCode()) {
case KeyEvent.VK_LEFT:
case KeyEvent.VK_KP_LEFT:
handleToStackAction();
break;
case KeyEvent.VK_RIGHT:
case KeyEvent.VK_KP_RIGHT:
//handleHardStackAction();
handleFromStackAction();
break;
case KeyEvent.VK_DOWN:
case KeyEvent.VK_KP_DOWN:
handleFromStackAction();
break;
case KeyEvent.VK_UP:
case KeyEvent.VK_KP_UP:
case KeyEvent.VK_SPACE:
flashCardPanel.flip();
break;
}
} |
e0079a1f-c4dd-4c9b-a311-3fa4c66bdd83 | 8 | public String convert(String s, int nRows) {
if(nRows == 1)
return s;
String resultString = "";
int counter = 0;
boolean reverse = false;
String[] stringsArr = new String[nRows];
for(int i = 0; i < nRows; ++i){
stringsArr[i] = "";
}
for(int i = 0; i < s.length(); ++i){
if(counter == -1){
counter = 1;
reverse = false;
stringsArr[counter] += s.charAt(i);
counter++;
continue;
}
if(counter == nRows){
counter = nRows - 2;
reverse = true;
stringsArr[counter] += s.charAt(i);
counter--;
continue;
}
if(reverse == true){
stringsArr[counter] += s.charAt(i);
counter--;
continue;
}
if(reverse == false){
stringsArr[counter] += s.charAt(i);
counter++;
continue;
}
}
for(int i = 0; i < nRows; ++i){
resultString += stringsArr[i];
}
return resultString;
} |
3c7c983b-46f4-41da-ada8-5d79247d971b | 5 | public void readFile(String imagePath , String imageDescPath) {
BufferedImage image = null;
try {
URL url = AssertManager.class.getClassLoader().getResource(
imagePath);
image = ImageIO.read(url);
} catch (IOException e) {
e.printStackTrace();
System.out.println("读取图片出错");
return;
}
images.add(image);
try {
String encoding = "GBK";
URL url = AssertManager.class.getClassLoader().getResource(
imageDescPath);
File file = new File(url.getPath());
Asset asset = null;
if (file.isFile() && file.exists()) { // 判断文件是否存在
InputStreamReader read = new InputStreamReader(
new FileInputStream(file), encoding);// 考虑到编码格式
BufferedReader bufferedReader = new BufferedReader(read);
String lineTxt = null;
while ((lineTxt = bufferedReader.readLine()) != null) {
asset = new Asset(lineTxt, image);
asserts.put(asset.getName(), asset);
}
read.close();
} else {
System.out.println("找不到指定的文件");
}
} catch (Exception e) {
System.out.println("读取文件内容出错");
e.printStackTrace();
}
} |
d10172b6-8700-40f2-b338-caecba660f25 | 2 | public synchronized void runTask(Runnable task) {
if (!isAlive) {
throw new IllegalStateException();
}
if (task != null) {
taskQueue.add(task);
notify();
}
} |
c40623bd-ec7a-44a7-a07e-ee528744db82 | 4 | public void update()
{
if(requestLoad)
{
mc.setLoading(true,loadSpaces);
if(!mc.isLoading()){requestLoad=false;}
}
else if(requestSave)
{
mc.setSaving(true);
if(!mc.isSaving()){requestSave=false;}
}
else
{
updating=true;
mc.update();
updating=false;
}
} |
10587dc1-27a9-4b5c-a703-6a73f7764774 | 5 | public static void main(String[] args) throws IOException {
HashMap<Integer, BigInteger> hm = new HashMap<Integer, BigInteger>();
BigInteger big = new BigInteger("0");
BigInteger aux = new BigInteger("0");
for (int i = 0; i < 50000; i++) {
big = new BigInteger(String.valueOf(i + 1));
big = big.pow(3);
aux = aux.add(big);
hm.put(i + 1, aux);
}
BufferedReader buf = new BufferedReader(
new InputStreamReader(new FileInputStream("in.in")));
System.setOut(new PrintStream(new File("out.out")));
int f = 0;
String line = "";
StringBuilder sb = new StringBuilder();
d: do {
line = buf.readLine();
if(line==null || line.length()==0)
break d;
int n = Integer.parseInt(line);
System.out.println(hm.get(n));
//sb.append(((f++!=0)?"\n":"")+hm.get(n));
} while (line!=null && line.length()!=0);
//System.out.println(sb);
} |
12ba31f0-6c0e-4312-b3b6-b6be9c16b59d | 9 | @Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof XYLineAnnotation)) {
return false;
}
XYLineAnnotation that = (XYLineAnnotation) obj;
if (this.x1 != that.x1) {
return false;
}
if (this.y1 != that.y1) {
return false;
}
if (this.x2 != that.x2) {
return false;
}
if (this.y2 != that.y2) {
return false;
}
if (!PaintUtilities.equal(this.paint, that.paint)) {
return false;
}
if (!ObjectUtilities.equal(this.stroke, that.stroke)) {
return false;
}
// seems to be the same...
return true;
} |
2a5ab540-64fd-499c-b060-b45eb46d7794 | 8 | private Element createPersonalInfo() throws ProfilerException {
Element personalInfo = doc.createElement("details");
if (request.getParameter("gender") != null && !request.getParameter("gender").isEmpty()) {
personalInfo.appendChild(createSimpleElement(request.getParameter("gender"), "gender"));
} else {
request.setAttribute("error", "Please fill you gender.");
throw new ProfilerException("Fill gender!.");
}
if (request.getParameter("dateofbirth") != null && !request.getParameter("dateofbirth").isEmpty()) {
personalInfo.appendChild(createSimpleElement(request.getParameter("dateofbirth"), "birthDate"));
} else {
request.setAttribute("error", "Please fill you date of birth.");
throw new ProfilerException("Fill date fo brith!.");
}
if (request.getParameter("placeofbirth") != null && !request.getParameter("placeofbirth").isEmpty()) {
personalInfo.appendChild(createSimpleElement(request.getParameter("placeofbirth"), "birthPlace"));
} else {
request.setAttribute("error", "Please fill you place fo birth.");
throw new ProfilerException("Fill place of birth!.");
}
if (request.getParameter("citizenship") != null && !request.getParameter("citizenship").isEmpty()) {
personalInfo.appendChild(createSimpleElement(request.getParameter("citizenship"), "citizenship"));
} else {
request.setAttribute("error", "Please fill you place fo birth.");
throw new ProfilerException("Fill your citizenship!.");
}
return personalInfo;
} |
e8eabf66-35ac-4939-b15b-d6fac3b3ab17 | 0 | public void raiseSalary(double byPercent)
{
double raise = salary * byPercent / 100;
salary += raise;
} |
c9e49a59-5a5c-4fda-b48f-e58e77a58630 | 4 | public static void main(String[] args){
Scanner in = new Scanner(System.in);
int max = 0;
StringBuilder sb = new StringBuilder();
while(in.hasNext()){
String numbers = in.next();
sb.append(numbers);
}
String s = sb.toString();
for(int i=0;i<s.length()-4;i++){
int p = 1;
for (int j=0;j<5;j++) p*=Integer.parseInt(""+s.charAt(i+j));
if (p>max) max = p;
}
System.out.println(max);
} |
4189b989-d82d-42ec-a2ea-16d8787814b9 | 7 | @Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
for (Section s : sections) {
if (s.isOpened()) {
if (s.isBomb()) {
g.setColor(Color.RED);
} else
g.setColor(Color.GREEN);
} else {
g.setColor(Color.LIGHT_GRAY);
}
g.fillRect(s.getX() * 50, s.getY() * 50, 50, 50);
g.setColor(Color.BLACK);
if (s.isOpened()) {
if (s.isBomb()) {
g.drawString("Bomb!", (s.getX()*50) + 5, (s.getY()*50) + 25);
} else {
g.drawString("+" + s.getPoints(), (s.getX()*50) + 5, (s.getY()*50) + 25);
if (s.containsHeart()) {
g.drawImage(heart, (s.getX() * 50) + 5, (s.getY()*50) + 35, null);
}
}
}
g.drawRect(s.getX() * 50, s.getY() * 50, 50, 50);
}
int x = getWidth() - 30;
for (int i = 0; i < GlobalVars.lives; i++) {
g.drawImage(heart, x - (i * 20), 20, null);
}
g.setColor(Color.BLACK);
g.drawString("Points: " + GlobalVars.points, x - 100, 50);
} |
a88728d7-291f-48aa-bce2-75f4403f55df | 6 | @Override
protected void tupleSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
switch (setField_) {
case SHORT_VALUE:
Short short_value = (Short)value_;
oprot.writeI16(short_value);
return;
case INT_VALUE:
Integer int_value = (Integer)value_;
oprot.writeI32(int_value);
return;
case LONG_VALUE:
Long long_value = (Long)value_;
oprot.writeI64(long_value);
return;
case DOUBLE_VALUE:
Double double_value = (Double)value_;
oprot.writeDouble(double_value);
return;
case STRING_VALUE:
String string_value = (String)value_;
oprot.writeString(string_value);
return;
case BYTES_VALUE:
ByteBuffer bytes_value = (ByteBuffer)value_;
oprot.writeBinary(bytes_value);
return;
default:
throw new IllegalStateException("Cannot write union with unknown field " + setField_);
}
} |
5a257968-b518-4c39-b396-a5ccd5d9336c | 2 | private double computeNodeConfidenceScore() {
// this is a simple and unoptimized way of doing this
// basically we construct a BlockChain type from Leaf-to-Root path
// then compute the ConfidenceScore
Node currentNode = this;
BlockChain thisChain = new BlockChain(this.block);
while (currentNode != null) {
// System.out.println(">"+currentNode currentNode.block.id);
currentNode = currentNode.parent;
if (currentNode != null)
thisChain.chain.addFirst(currentNode.block);
}
// thisChain.printChain("chain ");
double score = thisChain.computeConfidenceScore();
return score;
} |
7c8ef7c4-2f3c-4465-98c5-814de1ce6265 | 3 | public static void main(String[] args) {
SomeClassWithData some_object = new SomeClassWithData();
for (int i = 9; i > 0; --i) {
some_object.add(i);
}
// get_data() has been removed.
// Client has to use Iterator.
SomeClassWithData.Iterator it1 = some_object.create_iterator();
SomeClassWithData.Iterator it2 = some_object.create_iterator();
for (it1.first(); !it1.is_done(); it1.next()) {
System.out.print(it1.current_item() + " ");
}
System.out.println();
// Two simultaneous iterations
for (it1.first(), it2.first(); !it1.is_done(); it1.next(), it2.next()) {
System.out.print(it1.current_item() + " " + it2.current_item() + " ");
}
System.out.println();
} |
2fab0023-9380-427e-b78e-d043d38c0eb9 | 3 | public void show(){
for(int i=1; i<=size; i++){
for(int j=1; j<=i; j++){
System.out.print(pascalsTriangle[i][j]);
if(j!=i){
System.out.print(",");
}
}
System.out.println();
}
} |
b6411fb3-5b9c-4068-b750-32a9c574db63 | 2 | public static void createConfig() {
// Audio
setProperty("music", "" + SoundStore.get().getMusicVolume());
setProperty("sfx", "" + SoundStore.get().getSoundVolume());
// Video
setProperty("fullscreen", "" + Camera.get().isFullscreen());
setProperty("vsync", "" + Camera.get().isVSyncEnabled());
// Keybinds
for(Keybind keybind : Keybind.values()) {
setProperty(keybind.name(), "" + keybind.getKeyCode());
}
try {
props.store(new BufferedWriter(new FileWriter(new File("properties/config.properties"))), null);
} catch (IOException e) {
System.out.println("Config file failed to save");
e.printStackTrace();
}
} |
37821983-4438-477d-9d8b-8dc9ba09d472 | 8 | public boolean isOk() {
if(depth<=0.0){
return false;
}
if(time<=0.0){
return false;
}
if(gas.He>1.0||gas.N2>1.0||gas.O2>1.0||gas.He<0||gas.N2<0||gas.O2<0.01){
return false;
}
return true;
} |
7058bf72-3edd-4edc-95d1-be9cb1f8b51e | 9 | public static Ai parse(char c, Board board, int x, int y) {
Ai ai = new Ai(x, y, board);
ai.setIdentity(c);
ai.setInteractionKeys();
switch (c) {
case TileKeys.fireGas:
ai.setBrain(new GasBrain(ai, board));
ai.setColor(TileKeys.lightRed);
ai.decisions = new GasElementDecisions(ai);
//ai.setColor(new Color((int) (Math.random()*255), 0, 0));
break;
case TileKeys.fireLiquid:
ai.setBrain(new LiquidBrain(ai, board));
ai.decisions = new LiquidElementDecisions(ai);
ai.setColor(TileKeys.red);
break;
case TileKeys.fireSolid:
ai.setBrain(new SolidBrain(ai, board));
ai.decisions = new SolidElementDecisions(ai);
ai.setColor(TileKeys.darkRed);
break;
case TileKeys.earthGas:
ai.setBrain(new GasBrain(ai, board));
ai.setColor(TileKeys.lightGreen);
ai.decisions = new GasElementDecisions(ai);
break;
case TileKeys.earthLiquid:
ai.setBrain(new LiquidBrain(ai, board));
ai.decisions = new LiquidElementDecisions(ai);
ai.setColor(TileKeys.green);
break;
case TileKeys.earthSolid:
ai.setBrain(new SolidBrain(ai, board));
ai.decisions = new SolidElementDecisions(ai);
ai.setColor(TileKeys.darkGreen);
break;
case TileKeys.waterGas:
ai.setBrain(new GasBrain(ai, board));
ai.setColor(TileKeys.lightBlue);
ai.decisions = new GasElementDecisions(ai);
break;
case TileKeys.waterLiquid:
ai.setBrain(new LiquidBrain(ai, board));
ai.decisions = new LiquidElementDecisions(ai);
ai.setColor(TileKeys.blue);
break;
case TileKeys.waterSolid:
ai.setBrain(new SolidBrain(ai, board));
ai.decisions = new SolidElementDecisions(ai);
ai.setColor(TileKeys.darkBlue);
break;
}
return ai;
} |
5469953c-77e1-4670-be80-2b06ebd3be9c | 2 | public DefaultResponse deleteAssociation(String asId, String asIdType) {
if (!UtilityMethods.isValidString(asId)) {
throw new IllegalArgumentException("Id parameter is null");
}
Map<String, String> lhtParameters = new HashMap<String, String>();
if (UtilityMethods.isValidString(asIdType)) {
lhtParameters.put(PARAM_ID_TYPE, encode(asIdType));
}
return delete(REST_URL_ASSOCIATIONS + "/" + encode(asId), DefaultResponse.class,
lhtParameters);
} |
a117f482-be2f-49c5-9c8c-d4f2950a769e | 9 | protected void changeNeuronWeight(int neuronNumber, double[] vector, int iteration){
double[] weightList = networkModel.getNeuron(neuronNumber).getWeight();
int weightNumber = weightList.length;
double weight;
if(showComments){
String vectorText="[";
for(int i=0; i<vector.length; i++){
vectorText += vector[i];
if(i < vector.length -1 ){
vectorText += ", ";
}
}
vectorText += "]";
System.out.println("Vector: " + vectorText);
String weightText="[";
for(int i=0; i<weightList.length; i++){
weightText += weightList[i];
if(i < weightList.length -1 ){
weightText += ", ";
}
}
weightText += "]";
System.out.println("Neuron "+ (neuronNumber +1 ) + " weight before change: " + weightText);
}
for (int i=0; i<weightNumber; i++){
weight = weightList[i];
weightList[i] += functionalModel.getValue(iteration) * (vector[i] - weight);
}
if(showComments){
String weightText="[";
for(int i=0; i<weightList.length; i++){
weightText += weightList[i];
if(i < weightList.length -1 ){
weightText += ", ";
}
}
weightText += "]";
System.out.println("Neuron "+ (neuronNumber +1 ) + " weight after change: " + weightText);
}
} |
3f6322dc-d68d-4ea4-a456-fb3a6c5d84ae | 3 | @Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Player)) {
return false;
}
Player player = (Player) o;
if (!name.equals(player.name)) {
return false;
}
return number.equals(player.number);
} |
492d06b7-773d-421e-987e-7c510d1830d4 | 6 | private String get_sub_ct(char[][] pt, int start_col,int end_col,int[][] key_square)
{
int row=pt.length;
char[][] result_ct=new char[row][end_col-start_col];
StringBuilder sb=new StringBuilder();
for(int i=start_col;i<end_col;i++)
{
//find the correct position for each column
for(int j=0;j<row;j++)
{
if(pt[j][i]=='\0')
continue;
result_ct[key_square[j][i-start_col]-1][i-start_col]=pt[j][i];
/*if(pt[j][i]!='\0')
{
sb.append(pt[j][i]);
}*/
}
}
for(int i=0;i<end_col-start_col;i++)
{
for(int j=0;j<row;j++)
{
if(result_ct[j][i]!='\0')
{
sb.append(result_ct[j][i]);
}
}
}
return sb.toString();
} |
7a6a3621-32ae-4b95-8b2f-9eb37ed0463e | 7 | private void checkOSStarted(VirtualMachine virtualMachine)
throws Exception {
String startTimeout = virtualMachine.getProperty(
VirtualMachineConstants.START_TIMEOUT);
boolean checkTimeout = startTimeout != null;
int remainingTries = 0;
if (checkTimeout) {
remainingTries = Integer.parseInt(startTimeout) / START_RECHECK_DELAY;
}
while (true) {
Exception ex = null;
try {
if (HypervisorUtils.isLinuxGuest(virtualMachine)) {
createSSHClient(virtualMachine).disconnect();
break;
} else {
ex = new Exception("Guest OS not supported");
}
} catch (Exception e) {
if (checkTimeout && remainingTries-- == 0) {
ex = new Exception("Virtual Machine OS was not [re]started. " +
"Please check you credentials.");
}
}
if (ex != null) {
throw ex;
}
Thread.sleep(1000 * START_RECHECK_DELAY);
}
} |
0b8e7a18-92c3-47f6-9cbc-189eedb7b9e3 | 0 | public void setUpdatedAt(final Long updatedAt) {
this.updatedAt = updatedAt;
} |
a54346ed-1253-4541-ab69-d00e5cdda3ba | 5 | private static int[] merge(int[] array1, int[] array2) {
int[] result = new int[array1.length + array2.length];
int index = 0;
int index1 = 0;
int index2 = 0;
while(index1 < array1.length && index2 < array2.length) {
if(array1[index1] < array2[index2]) {
result[index] = array1[index1];
index1++;
} else {
result[index] = array2[index2];
index2++;
}
index++;
}
while(index1 < array1.length) {
result[index++] = array1[index1++];
}
while(index2 < array2.length) {
result[index++] = array2[index2++];
}
return result;
} |
281087f0-6f43-42ad-9653-a3d113eb163e | 8 | public void handleExternalPlugins()
{
if (vault != null)
{
loadVault();
isVaultEnabled = true;
pluginsEnabled.add("Vault");
}
if (worldedit != null)
{
isWorldEditEnabled = true;
wep = (WorldEditPlugin) worldedit;
portExecutor.setWorldEditPlugin(wep);
pluginsEnabled.add("WorldEdit");
}
if (worldguard != null)
{
isWorldGuardEnabled = true;
wgp = (WorldGuardPlugin) worldguard;
pluginsEnabled.add("WorldGuard");
}
if (worldguard != null && worldedit != null)
{
portalExecutor.setWorldPlugins(wep, wgp);
}
if (worldguard == null || worldedit == null || vault == null)
{
Log.info(logName
+ " Some features may be disabled because we do not have all the plugins needed!");
}
} |
bb27d2df-0505-4441-8e44-618e17321227 | 2 | public void setAnalyzerActive (GlobalContext context, boolean arg) {
for (IStringAnalyser analyzer : stringAnalysers) {
if (context == analyzer.getGlobalContext()) {
analyzer.setActive(arg);
}
}
} |
1a202fe5-40d0-4b72-93b9-7d673f940d25 | 1 | public CouldNotSendConnectRequestException(CouldNotSendPacketException e) {
super("Could not send connect request" + (e == null ? "." : "--" + e.getMessage()));
wrappedException = e;
} |
e6ace858-9ac1-47d9-92d4-aa9befca1c43 | 5 | @Override
public Boolean[] segment(Utterance utterance, boolean training, boolean trace) {
Boolean[] segmentation = utterance.getBoundariesCopy();
int baseIndex = 0;
while (baseIndex < utterance.length) {
ArrayList<Word> prefixes = lexicon.getPrefixWords(utterance, baseIndex);
if (!prefixes.isEmpty()) {
// Get the highest scoring word
Word word = SegUtil.chooseBestScoreWord(prefixes, lexicon, null);
nSubtractions++;
// Segment the left side of the word if it's not the start of the utterance.
if (baseIndex != 0) {
segmentation[baseIndex - 1] = true;
}
// Segment the right side of the word if it's not the end of the utterance.
int finalBound = baseIndex + word.length - 1;
if (finalBound != segmentation.length) {
segmentation[finalBound] = true;
}
// Move baseIndex by word length
baseIndex += word.length;
}
else {
baseIndex++;
}
}
// Increment the words used in the utterance.
if (training) {
lexicon.incUtteranceWords(utterance.getUnits(), utterance.getStresses(), segmentation,
null);
}
return segmentation;
} |
1277bc8b-c6a4-4041-8513-312700e5ffff | 1 | public boolean isAnyRecordFormatSpecified() {
return xmlRecordElements != null && !xmlRecordElements.isEmpty();
} |
a23569e2-44b8-4c44-a27b-552bfa26170a | 9 | private void ochosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ochosMouseClicked
// TODO add your handling code here:
try {
if (conexion == true && enviando == 0) {
enviando = 1;
int opciones;
if (esinicio != 0 && 8 <= esinicio) {
opciones = c.mensajeconexion("8");
menuopciones = opciones;
if (opciones == 0) {
esfinal = menuopciones = 0;
LeeTexto.Lee("Gracias por utilizar nuestro servicio. ¿Le hemos resuelto su duda?. Si. marque 1. No marque 2");
}
esinicio = 0;
variables.menu = variables.menu + 8;
} else if (esfinal == -1 && 8 <= menuopciones) {
variables.menu = variables.menu + 8;
opciones = c.mensajeconexion(variables.menu);
menuopciones = opciones;
if (opciones == 0) {
esfinal = menuopciones = 0;
LeeTexto.Lee("Gracias por utilizar nuestro servicio. ¿Le hemos resuelto su duda?. Si. marque 1. No marque 2");
}
} else {
LeeTexto.Lee("Opcion no valida.");
}
enviando = 0;
}
} catch (Exception e) {
}
}//GEN-LAST:event_ochosMouseClicked |
c48306ed-9920-425a-ac5f-b5c52b2a89e4 | 3 | protected void initialize()
{
if (GameApplet.thisApplet != null)
{
super.initialize();
this.initialOrientation = 180;
this.newName = "Arachnae Prototype";
this.chassis = "Arachnae";
String[] arrayOfString = { "sensor.VidSensor", "assembly.Launcher" };
this.parts = arrayOfString;
this.clearAnimations = new AnimationComponent[2];
for (int i = 0; i < 2; i++)
{
this.clearAnimations[i] = new AnimationComponent();
Image[] localObject = new Image[6 + i];
int[] arrayOfInt = new int[6 + i];
for (int j = 0; j < 6 + i; j++)
{
localObject[j] = GameApplet.thisApplet.getImage(
"com/templar/games/stormrunner/media/images/robot/buried/buried" + (i + 1) + "_0" + (j + 1) + ".gif");
arrayOfInt[j] = j;
}
this.clearAnimations[i].setCells(localObject);
this.clearAnimations[i].setSequence(arrayOfInt, null, false);
}
ImageComponent[] localObject = new ImageComponent[2];
localObject[1] = new ImageComponent(GameApplet.thisApplet.getImage("com/templar/games/stormrunner/media/images/robot/chassis/Arachnae/walk0_225.gif"), true, false);
localObject[0] = this.clearAnimations[0];
setImages(localObject);
}
} |
715a14c6-e65a-45d5-951f-6ab112ef2c7a | 3 | private static File findFile(String filename, LinkedList files) {
File temp;
int i = 1;
temp = (File) files.get(0);
while ((i < files.size()) && (!filename.equals(temp.getName()))) {
temp = (File) files.get(i);
i++;
}
if (temp.getName().equals(filename)) {
return temp;
} else {
return null;
}
} |
7867f18a-4790-4389-afc1-60cf5204f9bd | 1 | @Override
public final String toString()
{
return "Bencoding Exception:\n"+(this.message == null ? "" : this.message);
} |
81e95619-9f56-4822-a677-05f0e44f7d13 | 8 | private void btn_okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_okActionPerformed
// Initialisation des variables.
String message;
boolean controle = false;
// Controle sur formulaire
if(text_name.getText().isEmpty()
|| text_adr_cp.getText().isEmpty()
|| text_adr_numRue.getText().isEmpty()
|| text_adr_ville.getText().isEmpty()
|| text_mail.getText().isEmpty()
|| text_secteur.getText().isEmpty()
|| text_tel.getText().isEmpty()){
controle = false;
}
else controle = true;
// Resultat du controle sur formulaire.
// Si champs mal renseignés
if(controle==false) message="Il faut bien remplir tout les champs.";
// Sinon.
else{
message="L'entreprise à été ajoutée.";
// Création d'un nouvel objet.
Entreprise e1 = new Entreprise(text_name.getText(), text_adr_ville.getText(),
text_adr_numRue.getText(), text_adr_cp.getText(), text_tel.getText(),
text_mail.getText(), text_secteur.getText());
// Insertion de cet objet dans la collection " lesEntreprises".
MainProjet.lesEntreprises.add(e1);
// Fermeture de la fenetre
this.dispose();
}
JOptionPane.showMessageDialog(null, message, "Information", JOptionPane.INFORMATION_MESSAGE);
}//GEN-LAST:event_btn_okActionPerformed |
e1b24c53-5e85-4926-a0f6-8f133e195088 | 3 | private void deleteCategory(Map<String, Object> jsonrpc2Params) throws Exception {
Map<String, Object> params = getParams(jsonrpc2Params,
Constants.Param.Name.TYPE,
Constants.Param.Name.CATEGORY_ID);
String type = (String) params.get(Constants.Param.Name.TYPE);
int categoryId = (Integer) params.get(Constants.Param.Name.CATEGORY_ID);
Object category = null;
if(type.equals(Constants.Param.Value.PUBLIC)){
category = em.find(Category.class, categoryId);
} else if(type.equals(Constants.Param.Value.PRIVATE)){
category = em.find(PrivateCategory.class, categoryId);
}else{
throwJSONRPC2Error(JSONRPC2Error.INVALID_PARAMS, Constants.Errors.PARAM_VALUE_NOT_ALLOWED, "Type: " + type);
}
if(category == null){
responseParams.put(Constants.Param.Status.STATUS, Constants.Param.Status.OBJECT_NOT_FOUND);
}else{
removeObjects(category);
responseParams.put(Constants.Param.Status.STATUS, Constants.Param.Status.SUCCESS);
}
} |
e940e949-7f5c-4e20-af51-4e3bc8e07cd0 | 0 | public PowerUp(int speed, int xvalue, int yvalue, int dirX, int dirY){
setV(speed);
setX(xvalue);
setY(yvalue);
//setDirectionY(dirY);
//setDirectionX(dirX);
option = (int)(Math.round(Math.random()))+1;
} |
4be32c06-c2c8-4afc-a232-49be3748ca69 | 0 | public Id3v2URLFrame(Property property, PropertyTree parent) {
super(property, parent);
} |
a63a3dbf-96c0-4217-88c1-8c0caa993cfd | 5 | public static void simpleSearch(ArrayList<StringSequence> database,String pattern)
{
for(int sequence = 0;sequence<database.size();sequence++)
{
ArrayList<Integer> foundInCurrent = new ArrayList<Integer>();
database.get(sequence).setPattern(pattern);
String current=database.get(sequence).getSequence();
int counter=0;
for(int offset = 0;offset<(current.length()-pattern.length()+1);offset++)
{
boolean found = true;
for(int j=0;j<pattern.length();j++)
{
counter++;
if(pattern.charAt(j)!=current.charAt(j+offset))
{
found=false;
break;
}
}
if(found)
{
foundInCurrent.add(offset);
}
}
database.get(sequence).setFoundPositionList(foundInCurrent);
System.out.println("Naiv-Vergleiche: "+counter);
}
} |
31b3b997-6daa-449a-993e-683ee7ca26d3 | 9 | public void poistaTaydetRivit() {
int taysiaRiveja = 0;
for (int i = RuudunKorkeus - 1; i >= 0; --i) {
boolean RiviTaysi = true;
for (int j = 0; j < RuudunLeveys; ++j) {
if (tetrominonMuoto(j, i) == Tetrominot.EiMuotoa) {
RiviTaysi = false;
break;
}
}
if (RiviTaysi) {
++taysiaRiveja;
for (int k = i; k < RuudunKorkeus - 1; ++k) {
for (int j = 0; j < RuudunLeveys; ++j) {
muodot[(k * RuudunLeveys) + j] = tetrominonMuoto(j, k + 1);
}
}
}
}
if (taysiaRiveja == 1) {
rivejaPoistettu += taysiaRiveja;
this.pisteet = this.pisteet + 10;
kayttis.getStatusBar().setText("Rivejä poistettu: " + String.valueOf(rivejaPoistettu) + " Pisteet: " + String.valueOf(pisteet));
pala.asetaMuoto(Tetrominot.EiMuotoa);
kayttis.repaint();
} else if (taysiaRiveja == 2) {
rivejaPoistettu += taysiaRiveja;
this.pisteet = this.pisteet + taysiaRiveja * 15;
kayttis.getStatusBar().setText("Rivejä poistettu: " + String.valueOf(rivejaPoistettu) + " Pisteet: " + String.valueOf(pisteet));
pala.asetaMuoto(Tetrominot.EiMuotoa);
kayttis.repaint();
} else if (taysiaRiveja > 2) {
rivejaPoistettu += taysiaRiveja;
this.pisteet = this.pisteet + taysiaRiveja * 20;
kayttis.getStatusBar().setText("Rivejä poistettu: " + String.valueOf(rivejaPoistettu) + " Pisteet: " + String.valueOf(pisteet));
pala.asetaMuoto(Tetrominot.EiMuotoa);
kayttis.repaint();
}
} |
e781422f-0f0f-4b80-9451-47ff2b4c8789 | 8 | @Override
public SourceValue newOperation(final AbstractInsnNode insn) {
int size;
switch (insn.getOpcode()) {
case LCONST_0:
case LCONST_1:
case DCONST_0:
case DCONST_1:
size = 2;
break;
case LDC:
Object cst = ((LdcInsnNode) insn).cst;
size = cst instanceof Long || cst instanceof Double ? 2 : 1;
break;
case GETSTATIC:
size = Type.getType(((FieldInsnNode) insn).desc).getSize();
break;
default:
size = 1;
}
return new SourceValue(size, insn);
} |
8b192e9e-42ba-4e57-b6d4-f1f3491f66e6 | 1 | public void printAttributes() {
System.out.println("###[BLUEPRINT]###");
System.out.println("# BID:" + BlueprintID + "\t BName:" + BlueprintName);
System.out.println("# PID:" + ProductID + "\t PName:" + ProductName);
System.out.println("# PTime:" + ProductionTime + "\t PSize:" + PortionSize);
System.out.println("# RPE:" + ResearchPE + "\t RME:" + ResearchME + "\t RCP:" + ResearchCopy);
System.out.println("# PMod:" + ProductivityModifier + "\t MMod:" + MaterialModifier);
System.out.println("# Waste:" + WasteFactor + "\t PLimit:" + ProductionLimit);
System.out.println("###[MATERIALS]###");
// print Materials
for (int i = 0; i < Materials.size(); i++) {
Materials.get(0).printMaterials();
}
} |
8d969780-6884-4333-b936-479a7f21b700 | 1 | public void setPan(int pan) {
if (clip.isControlSupported(FloatControl.Type.PAN)) {
FloatControl panControl = (FloatControl) clip.getControl(FloatControl.Type.PAN);
panControl.setValue(pan);
}
} |
5ddec557-8016-46b8-9365-f845125a4cff | 2 | public void render(GameContainer gc, Graphics g) throws SlickException {
g.setFont(titleFont);
g.drawString(game.getTitle(), 100, 100);
g.resetFont();
for (int i = 0; i < buttons.size(); i++) {
int x = buttonsX;
int y = buttonsY + i * buttonHeight;
if (i == choice) {
g.setColor(Color.darkGray);
g.fillRect(x - 10, y, buttonWidth, buttonHeight);
g.setColor(Color.white);
}
g.drawString(buttons.get(i).getLabel(), x, y);
}
} |
93f4a7d8-25be-4986-b418-1b2502d3240d | 7 | public final boolean equals(Object par1Obj)
{
if (!(par1Obj instanceof IntHashMapEntry))
{
return false;
}
else
{
IntHashMapEntry var2 = (IntHashMapEntry)par1Obj;
Integer var3 = Integer.valueOf(this.getHash());
Integer var4 = Integer.valueOf(var2.getHash());
if (var3 == var4 || var3 != null && var3.equals(var4))
{
Object var5 = this.getValue();
Object var6 = var2.getValue();
if (var5 == var6 || var5 != null && var5.equals(var6))
{
return true;
}
}
return false;
}
} |
d3c1ec61-be24-41cd-8589-2345122e5078 | 8 | public void mousePressed(MouseEvent e){
Dimension size = fComponent.getSize();
if( e.getX() >= size.width-7 && e.getY() >= size.height-7
&& getSelectionState()==2 ) {
if(DEBUG)System.out.println("ImageView: grow!!! Size="+fWidth+"x"+fHeight);
Point loc = fComponent.getLocationOnScreen();
fGrowBase = new Point(loc.x+e.getX() - fWidth,
loc.y+e.getY() - fHeight);
} else {
fGrowBase = null;
JTextComponent comp = (JTextComponent)fContainer;
int start = fElement.getStartOffset();
int end = fElement.getEndOffset();
int mark = comp.getCaret().getMark();
int dot = comp.getCaret().getDot();
if( e.isShiftDown() ) {
if( mark <= start )
comp.moveCaretPosition(end);
else
comp.moveCaretPosition(start);
} else {
if( mark!=start )
comp.setCaretPosition(start);
if( dot!=end )
comp.moveCaretPosition(end);
}
}
} |
a276e43f-cdf9-4c73-8ba0-4ed70068aa45 | 7 | public void addRecordArray(Object[] aobj) throws JDBFException {
if (aobj.length != fields.length)
throw new JDBFException("Error adding record: Wrong number of values. Expected " +
fields.length + ", got " + aobj.length +
".");
int i = 0;
for (int j = 0; j < fields.length; j++)
i += fields[j].getLength();
byte[] abyte0 = new byte[i];
int k = 0;
for (int l = 0; l < fields.length; l++) {
String s = fields[l].format(aobj[l]);
byte[] abyte1 = null;
if (dbfConfig.getDBFEncoding() != null)
try {
abyte1 = s.getBytes(dbfConfig.getDBFEncoding().name());
} catch (UnsupportedEncodingException ex) {
}
else
abyte1 = s.getBytes();
for (int i1 = 0; i1 < fields[l].getLength(); i1++)
abyte0[k + i1] = abyte1[i1];
k += fields[l].getLength();
}
try {
stream.write(32);
stream.write(abyte0, 0, abyte0.length);
} catch (IOException ioexception) {
throw new JDBFException(ioexception);
}
} |
01c1e89d-8e23-42bf-bb36-1afc9615e662 | 2 | public boolean getBoolean(String key, boolean def) {
if(fconfig.contains(key)) {
return fconfig.getBoolean(key);
}
else {
fconfig.set(key, def);
try { fconfig.save(path); } catch (IOException e) { e.printStackTrace(); }
return def;
}
} |
da92eab7-7aa2-48e8-b6af-27bafb3c1267 | 2 | public static void main(String[] args) {
new Thread(new Runnable() {
@Override
public void run() {
Server.start();
}
}).start();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
Socket socket = new Socket("127.0.0.1", 3333);
Client client = new Client(socket);
System.out.println("[CLIENT] Connected to server");
new Thread(client).start();
} catch (IOException e) {
e.printStackTrace();
}
} |
a44e3780-61c0-4de0-91b6-ed471bb05c05 | 4 | final public CycVariable sentenceDenotingVariable(boolean requireEOF) throws ParseException {
CycVariable val = null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SIMPLE_VARIABLE:
val = sentenceDenotingSimpleVariable(false);
break;
case META_VARIABLE:
val = sentenceDenotingMetaVariable(false);
break;
default:
jj_la1[29] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
eof(requireEOF);
{if (true) return val;}
throw new Error("Missing return statement in function");
} |
f2839322-307e-41fc-b4ad-cb3e51f8fe81 | 0 | GraphPrimitive(int x, int y, int width, int height, int widthDest, int heightDest, String name) {
super(x, y, width, height, widthDest, heightDest);
this.name = name;
} |
a2cc3d66-49f8-470d-bb61-fd178608cc33 | 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://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Configuracion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Configuracion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Configuracion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Configuracion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Configuracion().setVisible(true);
}
});
} |
5276376f-5da1-4ba6-b9cd-4001628b65fd | 8 | public String find(String word) {
for (int i = 1; i < word.length(); i++) {
if (word.charAt(i) == word.charAt(i - 1)) {
return "Dislikes";
}
}
for (int i = 0; i < word.length() - 3; i++) {
for (int j = i + 1; j < word.length() - 2; j++) {
for (int k = j + 1; k < word.length() - 1; k++) {
for (int l = k + 1; l < word.length(); l++) {
if (word.charAt(i) == word.charAt(k) && word.charAt(j) == word.charAt(l)) {
return "Dislikes";
}
}
}
}
}
return "Likes";
} |
bb8d33e5-f540-47a3-960d-1a10cf6a3baa | 2 | private void setTopic(String topic) {
if (topic == null || topic.trim().length() == 0)
topic = HTML.italic("Diskusní téma není nastaveno.");
else
topic = HTML.bold(topic);
topicPanel.setText(topic);
} |
dda5723d-f817-4287-a533-cc5e3aa71837 | 6 | public void playSound(InputStream inputStream) {
InputStream is = inputStream;
try {
audioStream = AudioSystem.getAudioInputStream(is);
} catch (Exception e){
e.printStackTrace();
}
audioFormat = audioStream.getFormat();
DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
try {
sourceLine = (SourceDataLine) AudioSystem.getLine(info);
sourceLine.open(audioFormat);
} catch (LineUnavailableException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
sourceLine.start();
int nBytesRead = 0;
byte[] abData = new byte[BUFFER_SIZE];
while (nBytesRead != -1) {
try {
nBytesRead = audioStream.read(abData, 0, abData.length);
} catch (IOException e) {
e.printStackTrace();
}
if (nBytesRead >= 0) {
@SuppressWarnings("unused")
int nBytesWritten = sourceLine.write(abData, 0, nBytesRead);
}
}
sourceLine.drain();
sourceLine.close();
} |
8c6bf37e-5d36-41e0-9dd0-b944acd7ed97 | 7 | public static void call(final String data) throws Exception {
BufferedReader br = null;
FileReader fr = null;
final File textFile = new File(data);
String line = null;
List elements = null;
try {
fr = new FileReader(textFile);
br = new BufferedReader(fr);
while ((line = br.readLine()) != null) {
if (line.trim().length() == 0) {
continue;
}
// tell the parser to split using a comma delimiter with a "
// text qualifier. The text qualifier is optional, it can be
// null
// or empty
elements = ParserUtils.splitLine(line, ',', '"', 10, false, false);
for (int i = 0; i < elements.size(); i++) {
System.out.println("Column " + i + ": " + (String) elements.get(i));
}
System.out.println("===========================================================================");
}
} catch (final Exception ex) {
ex.printStackTrace();
} finally {
try {
if (br != null) {
br.close();
}
if (fr != null) {
fr.close();
}
} catch (final Exception ignore) {
}
}
} |
c70e384c-dcf0-458e-aaf3-711886e39a07 | 7 | @Override
public void update() {
//assume game is over only if there are walls present and the game is being played
boolean gameOver = walls.size() > 0 && Game.state == State.PLAY_LEVEL;
for(Ball ball : balls){
ball.update();
if(!ball.isAlone())
gameOver = false;
}
if(gameOver && !isAnyWallGrowing()){
if(Game.level.isLast()){
Game.level = null;
Game.state = State.GAME_OVER;
Game.state.start();
return;
}
Game.level = Game.level.next();
Game.state = State.END_LEVEL;
Game.state.start();
}
for(Wall wall : walls){
wall.update();
}
} |
5bd6718d-c453-49f7-9020-142cc268e723 | 6 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Corretor other = (Corretor) obj;
if (codigo == null) {
if (other.codigo != null)
return false;
} else if (!codigo.equals(other.codigo))
return false;
return true;
} |
b2fd4353-86a4-44c2-9c6e-f3dc396302ed | 7 | public void load(String filename) throws Exception
{
BufferedReader reader;
String line = null;
reader =
new BufferedReader(new FileReader(new File(filename)));
while ((line = reader.readLine()) != null)
{
if (line.length() > 0 && line.charAt(0) != '#') // ignores comments
{
String[] input = line.split("=");
input[0] = input[0].trim();
input[0] = input[0].toLowerCase();
String paramval;
int clone = name.indexOf(input[0]);
try {
paramval = input[1].split("#")[0].trim();
} catch (Exception e)
{
paramval = null;
System.err.println("Error reading parameter file " + e.getMessage() + ". Ignoring line:");
System.err.println(" \"" + line + "\"");
}
if (paramval != null)
{
if (clone == -1) // parameter hasn't been specified yet
{
if (paramval != null) // ignore invalid parameters
{
name.add(input[0]);
value.add(paramval);
}
}
else
{
value.set(clone, paramval);
}
}
}
}
reader.close();
} |
8d9d4cfc-811e-411e-b05f-938db796fa0f | 0 | public int getCurconnected() {
return curconnected;
} |
f44eb588-8e10-466f-a21b-ca8aae079015 | 6 | public static <GItem> List<GItem> reverseList(final List<GItem> items) throws NullPointerException {
if (items == null) throw new NullPointerException("items = null");
return new AbstractList<GItem>() {
@Override
protected void removeRange(final int fromIndex, final int toIndex) {
final int size = items.size();
items.subList(size - toIndex, size - fromIndex).clear();
}
@Override
public GItem get(final int index) {
return items.get(items.size() - index - 1);
}
@Override
public GItem set(final int index, final GItem item2) {
return items.set(items.size() - index - 1, item2);
}
@Override
public void add(final int index, final GItem item2) {
items.add(items.size() - index, item2);
}
@Override
public boolean retainAll(final Collection<?> items2) {
return items.retainAll(items2);
}
@Override
public GItem remove(final int index) {
return items.remove(items.size() - index - 1);
}
@Override
public boolean removeAll(final Collection<?> items2) {
return items.removeAll(items2);
}
@Override
public int size() {
return items.size();
}
@Override
public void clear() {
items.clear();
}
@Override
public boolean isEmpty() {
return items.isEmpty();
}
@Override
public int indexOf(final Object item2) {
final int index = items.lastIndexOf(item2);
return index < 0 ? -1 : items.size() - index - 1;
}
@Override
public int lastIndexOf(final Object item2) {
final int index = items.indexOf(item2);
return index < 0 ? -1 : items.size() - index - 1;
}
@Override
public boolean contains(final Object item2) {
return items.contains(item2);
}
@Override
public boolean containsAll(final Collection<?> items2) {
return items.containsAll(items2);
}
@Override
public Iterator<GItem> iterator() {
return this.listIterator(0);
}
@Override
public ListIterator<GItem> listIterator(int index) {
final ListIterator<GItem> iterator = items.listIterator(items.size() - index);
index = 0;
return new ListIterator<GItem>() {
@Override
public boolean hasNext() {
return iterator.hasPrevious();
}
@Override
public boolean hasPrevious() {
return iterator.hasNext();
}
@Override
public void set(final GItem item2) {
iterator.set(item2);
}
@Override
public void add(final GItem item2) {
iterator.add(item2);
iterator.hasPrevious();
iterator.previous();
}
@Override
public GItem next() {
return iterator.previous();
}
@Override
public int nextIndex() {
return items.size() - iterator.previousIndex() - 1;
}
@Override
public GItem previous() {
return iterator.next();
}
@Override
public int previousIndex() {
return items.size() - iterator.nextIndex() - 1;
}
@Override
public void remove() {
iterator.remove();
}
};
}
@Override
public List<GItem> subList(final int fromIndex, final int toIndex) {
return Collections.reverseList(items.subList(items.size() - toIndex - 2, items.size() - fromIndex - 2));
}
};
} |
b0fe9794-d18f-41fa-a11e-3794299266e1 | 1 | protected boolean canChange(int value){
Controller c = gui.getController();
if (centerCause(c.getX1(), c.getX2(), c.getY1(), c.getY2(), c.getR1(), value)){
return true;
}
else{
showCenterWarning();
return false;
}
} |
0b2e98ef-fec1-4ab1-9704-d15394d64a91 | 7 | public ArrayList<OrderDetail> createVerifiedOrderDetails(int resTypeID, int requestedQty, Order o) {
//Hvis der er nok på lager 1:
ArrayList<OrderDetail> odl = new ArrayList<>();
String startDate = o.formatDateToString(o.getStartDate());
String endDate = o.formatDateToString(o.getEndDate());
int storage1QtyInUse = 0; //OPTAGET qty for perioden
int storage2QtyInUse = 0; //OPTAGET qty for perioden
int storage1QtyTotal = 0;
int storage2QtyTotal = 0;
int ressourceID1 = 0;
int ressourceID2 = 0;
int storageID1 = 1;
int storageID2 = 2;
String SQLString1 = "SELECT sum(qty), storageID, ressourceTypeID FROM Orderdetails WHERE OrderID IN ("
+ " SELECT orderID FROM Orders WHERE ("
+ " (startDate>=? AND endDate<=?) or"
+ " (endDate>=? AND endDate>=?) OR"
+ " (startDate>=?) OR"
+ " (startDate<=? AND endDate>=? AND startDate<=? AND endDate>=? )"
+ " ) "
+ " AND confirmed=1)"
+ " AND RessourceTypeID =? GROUP BY StorageID, ressourceTypeID ORDER BY STORAGEID ASC";
//SELECTER qty for en given RESOURCETYPEID i en GIVEN tidsperiode, to datoer, hvor order = confirmed
PreparedStatement statement = null;
try {
statement = DBConnector.getInstance().getConnection().prepareStatement(SQLString1);
statement.setString(1, startDate);
statement.setString(2, endDate);
statement.setString(3, startDate);
statement.setString(4, endDate);
statement.setString(5, endDate);
statement.setString(6, startDate);
statement.setString(7, startDate);
statement.setString(8, endDate);
statement.setString(9, endDate);
statement.setInt(10, resTypeID);
ResultSet rs = statement.executeQuery();
while (rs.next()) {
if (rs.getInt(2) == 1) {//HVIS lagerID=1, sæt variables for storage1, ellers storage2
storage1QtyInUse = rs.getInt(1);
ressourceID1 = rs.getInt(3);
} else {
storage2QtyInUse = rs.getInt(1);
ressourceID2 = rs.getInt(3);
}
}
} catch (Exception e) {
System.out.println("Fail1 " + e.toString());
}
System.out.println("Storage1qtyinuse: " + storage1QtyInUse + " resID1: " + ressourceID1);
System.out.println("Storage2qtyinuse: " + storage2QtyInUse + " resID2: " + ressourceID2);
//Antallet af ressourcer i brug for hvert lager er fundet. Nu skal der findes max antal ressourcer.
SQLString1 = "SELECT QTY, StorageID, RessourceTypeID FROM Ressources Where ressourceTypeID=? GROUP BY StorageID, ressourceTypeID, QTY ORDER BY STORAGEID ASC";
try {
statement = DBConnector.getInstance().getConnection().prepareStatement(SQLString1);
statement.setInt(1, resTypeID);
ResultSet rs = statement.executeQuery();
while(rs.next()){
if(rs.getInt(2)==1){
storage1QtyTotal = rs.getInt(1);
ressourceID1 = rs.getInt(3);
}
else{
storage2QtyTotal = rs.getInt(1);
ressourceID2 = rs.getInt(3);
}
}
} catch (Exception e) {
System.out.println("Fail3 " + e.toString());
}
System.out.println("totalqty1:" + storage1QtyTotal);
System.out.println("totalqty2:" + storage2QtyTotal);
int availableStorage1 = storage1QtyTotal-storage1QtyInUse; //ledige = total-inuse
int availableStorage2 = storage2QtyTotal-storage2QtyInUse; //ledige = total-inuse
if(availableStorage1>=requestedQty){
odl.add(new OrderDetail(o.getOrderID(), ressourceID1, storageID1, requestedQty));
}
else{
odl.add(new OrderDetail(o.getOrderID(), ressourceID1, storageID1, availableStorage1));
odl.add(new OrderDetail(o.getOrderID(), ressourceID2, storageID2, requestedQty-availableStorage1));
}
//Opret orderdetail og add til liste
//Hvis ikke
//opret orderdetail1 og fyld ud
//Opret orderdetil2 og smid resten ind
System.out.println("Size på ODL:" + odl.size());
return odl;
} |
e9fcf219-473d-44b0-bb57-844401c2ac98 | 7 | @Override
public void trainOnInstanceImpl(Instance inst) {
//Init Perceptron
if (this.reset) {
this.reset = false;
this.numberAttributes = inst.numAttributes();
this.numberClasses = inst.numClasses();
this.weightAttribute = new double[inst.numClasses()][inst.numAttributes()];
for (int i = 0; i < inst.numClasses(); i++) {
for (int j = 0; j < inst.numAttributes(); j++) {
weightAttribute[i][j] = 0.2 * Math.random() - 0.1;
}
}
}
double[] preds = new double[inst.numClasses()];
for (int i = 0; i < inst.numClasses(); i++) {
preds[i] = prediction(inst, i);
}
double learningRatio = learningRatioOption.getValue();
int actualClass = (int) inst.classValue();
for (int i = 0; i < inst.numClasses(); i++) {
double actual = (i == actualClass) ? 1.0 : 0.0;
double delta = (actual - preds[i]) * preds[i] * (1 - preds[i]);
for (int j = 0; j < inst.numAttributes() - 1; j++) {
this.weightAttribute[i][j] += learningRatio * delta * inst.value(j);
}
this.weightAttribute[i][inst.numAttributes() - 1] += learningRatio * delta;
}
} |
44fe17af-d251-4369-bd61-a412fde25641 | 9 | public void eventEnd() {
Point check;
LineSegment p1=null, p2=null;
LineSegment tmp;
int i=0;
if(currentEvent.a.start.y == currentEvent.a.end.y){
return;
}
for ( i = 0; i < SweepStatus.size(); i++) {
tmp = SweepStatus.get(i);
if(tmp == currentEvent.a){
SweepStatus.remove(i);
break;
}
}
if(i< SweepStatus.size()){
p1= SweepStatus.get(i);
}
if(i>0){
p2 = SweepStatus.get(i-1);
}
if (p1 != null && p2 != null) {
check = p1.getIntersection(p2);
if (check != null && check.y < lambda) {
EventQueue.add(check);
}
}
} |
34b33ba3-d037-41da-8e91-fa44e98aec7e | 5 | private void displayMonth() {
if(currentMonth< 1){
currentMonth++;
}
if(currentMonth > 3){
currentMonth--;
}
Month tempMonth = months[currentMonth];
displayMonth.setText(tempMonth.getName());
for (int i = 0; i < tempMonth.getStartDay(); i++) {
dayPanel[i].deactivate(months[currentMonth-1].getTotalNumDays());
}
Day[][] days = tempMonth.getDays();
int j = 7 * 5;
for (int i = tempMonth.getStartDay(); i < tempMonth.getStartDay()
+ tempMonth.getTotalNumDays(); i++) {
dayPanel[i].setDate(days[i % 7][i / 7].getDate());
j = i;
}
for (int i = j + 1; i < 7 * 6; i++) {
dayPanel[i].deactivate(i-j);
}
} |
6aae79d7-7c24-495f-ba1c-359b761f3072 | 2 | protected boolean contains(TileObjectDisplayData displayData){
return characterData == displayData ||
itemData.contains(displayData) ||
edgeData.values().contains(displayData);
} |
3a17b326-18f3-40e1-a3e7-fbdd2e2f5c03 | 7 | protected static List<JavaInfo> findMacJavas() {
List<String> javaExecs = Lists.newArrayList();
String javaVersion;
javaVersion = getMacJavaPath("1.6");
if(javaVersion != null)
javaExecs.add(javaVersion + "/bin/java");
javaVersion = getMacJavaPath("1.7");
if(javaVersion != null)
javaExecs.add(javaVersion + "/bin/java");
javaVersion = getMacJavaPath("1.8");
if(javaVersion != null)
javaExecs.add(javaVersion + "/bin/java");
javaExecs.add("/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java");
javaExecs.add(System.getProperty("java.home") + "/bin/java");
List<JavaInfo> result = Lists.newArrayList();
for (String javaPath : javaExecs) {
File javaFile = new File(javaPath);
if (!javaFile.exists() || !javaFile.canExecute())
continue;
try {
result.add(new JavaInfo(javaPath));
} catch (Exception e) {
Logger.logError("Error while creating JavaInfo", e);
}
}
return result;
} |
d3ff8ba3-6e7f-4034-881d-89e88d50af9f | 2 | public Grid nullIfPreviousState(){
String thisState = this.gridToString();
for(Grid g: previousGrids){
if(thisState.equals(g.gridToString())){
return null;
}
}
return this;
} |
86e1312a-8316-48a1-9d95-630b1a5c8f4a | 7 | public static void main(String[] args) throws Exception {
System.setProperty("webdriver.chrome.driver", "D:\\Download\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.manage().window().maximize();
File bankNames = new File("E:\\Ashok\\Dropbox\\MyDetails\\pinfinder\\railwaycodes\\trains.xls");
FileInputStream file = new FileInputStream(bankNames);
// Get the workbook instance for XLS file
HSSFWorkbook bankWorkBook = new HSSFWorkbook(file);
// Get first sheet from the workbook
HSSFSheet banksheet = bankWorkBook.getSheetAt(0);
// Iterate through each rows from first sheet
Iterator<Row> rowIterator = banksheet.iterator();
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Trains");
boolean flag = true;
int i = 0;
int j = 3;
while (rowIterator.hasNext()) {
Row row = rowIterator.next();
if (flag) {
flag = false;
continue;
}
String trainNo = row.getCell(0).getStringCellValue().trim();
System.out.println(row.getRowNum() + "---" + trainNo);
if (row.getCell(4).getStringCellValue().equalsIgnoreCase("N")) {
System.out.println(trainNo + "---" + " Skipped");
continue;
}
driver.get("https://www.cleartrip.com/trains/" + trainNo);
WebElement table = driver.findElements(By.className("results")).get(1);
List<WebElement> trs = table.findElements(By.tagName("tr"));
for (WebElement tr : trs) {
List<WebElement> tds = tr.findElements(By.tagName("td"));
HSSFRow trainRow = sheet.createRow(i);
trainRow.createCell(0).setCellValue(trainNo);
trainRow.createCell(1).setCellValue(tds.get(0).getText());
trainRow.createCell(2).setCellValue(tds.get(1).getText());
trainRow.createCell(3).setCellValue(tds.get(2).getText());
trainRow.createCell(4).setCellValue(tds.get(3).getText());
trainRow.createCell(5).setCellValue(tds.get(4).getText());
trainRow.createCell(6).setCellValue(tds.get(5).getText());
trainRow.createCell(7).setCellValue(tds.get(6).getText());
trainRow.createCell(8).setCellValue(tds.get(7).getText());
i++;
}
if (row.getRowNum() != 0 && row.getRowNum() % 1000 == 0) {
HSSFRow row1 = workbook.getSheetAt(0).getRow(0);
for (int colNum = 0; colNum < row1.getLastCellNum(); colNum++) {
workbook.getSheetAt(0).autoSizeColumn(colNum);
}
FileOutputStream out = new FileOutputStream(
new File("E:\\Ashok\\Dropbox\\MyDetails\\pinfinder\\railwaycodes\\traindetails_" + j + ".xls"));
workbook.write(out);
out.close();
System.out.println(j + " Excel written successfully..");
i = 0;
j++;
workbook = new HSSFWorkbook();
sheet = workbook.createSheet("Trains");
}
}
FileOutputStream out = new FileOutputStream(
new File("E:\\Ashok\\Dropbox\\MyDetails\\pinfinder\\railwaycodes\\traindetails_" + j + ".xls"));
workbook.write(out);
out.close();
} |
cab6fab4-df44-4fcf-b537-5c8eb204a3d1 | 7 | @Override
public Object getValueAt(int indiceLigne, int indiceColonne) {
switch(indiceColonne){
case 0 :
return compteRendus.get(indiceLigne).getNomPraticien() ;
case 1 :
return compteRendus.get(indiceLigne).getPrenomPraticien() ;
case 2 :
return compteRendus.get(indiceLigne).getVillePraticien() ;
case 3 :
return compteRendus.get(indiceLigne).getDateVisite() ;
case 4 :
return compteRendus.get(indiceLigne).getDateRedaction() ;
case 5 :
return compteRendus.get(indiceLigne).getEstLu() ;
case 6 :
return "Consulter" ;
default :
return null ;
}
} |
ca1a2ce0-3089-405f-812e-318cd8075d06 | 5 | @Override
public void parse() {
if (peekTypeMatches("NEQ")) {
matchTerminal("NEQ");
inverseOp = "breq";
op = "neq";
}
else if (peekTypeMatches("EQ")) {
matchTerminal("EQ");
inverseOp = "brneq";
op = "eq";
}
else if (peekTypeMatches("LESSER")) {
matchTerminal("LESSER");
inverseOp = "brgeq";
op = "less";
}
else if (peekTypeMatches("GREATER")) {
matchTerminal("GREATER");
inverseOp = "brleq";
op = "greater";
}
else if (peekTypeMatches("LESSEREQ")) {
matchTerminal("LESSEREQ");
inverseOp = "brgt";
op = "leq";
}
else {
matchTerminal("GREATEREQ");
inverseOp = "brlt";
op = "geq";
}
} |
a8fcad1c-c20e-4275-87f9-65720d1709f4 | 4 | public void blockBreak(List<String> materialList, Boolean mode){
if (materialList != null){
Material materialet;
for (String material : materialList){
materialet = Material.getMaterial(material);
if (materialet != null){
blockBreak.add(materialet);
}
}
}
if (mode != null){
blockBreakMode = mode;
}else{
blockBreakMode = false;
}
} |
01ba872b-8c19-4441-bbd4-974329054ef7 | 2 | public void remove (final Body b) {
runnableManager.add(new Runnable() {
public void run () {
if (b != null) {
if (b.getUserData() != null) {
Objects.world.destroyBody(b);
b.setUserData(null);
}
} else {
System.out.println("Body seems to be null");
}
}
});
} |
d31da5f5-f28d-4a17-95b4-f379be426477 | 0 | public void setFunAaaa(int funAaaa) {
this.funAaaa = funAaaa;
} |
d6c8882d-e042-4a9b-909c-eac6cc05cf6c | 0 | public long getId() {
return id;
} |
d545dac2-9574-41d5-99f0-1c9699476a6e | 9 | static void fill(char[][] A, int i, int j, char toFill){
if(i<0 || i>=n || j<0 || j>=m || A[i][j]!='.') return;
A[i][j]=toFill;
fill(A, i-1, j, toFill=='W'?'B':'W');
fill(A, i, j+1, toFill=='W'?'B':'W');
fill(A, i+1, j, toFill=='W'?'B':'W');
fill(A, i, j-1, toFill=='W'?'B':'W');
} |
1a949d66-cbfa-433c-92c2-39de6292112e | 0 | @Id
@Column(name = "person_id")
public int getPersonId() {
return personId;
} |
cfa393d2-c837-4d87-9c4a-db539915ff26 | 7 | public static AudioPoint simplify(short[] in, double threshold, int begin, int end){
AudioPoint ret = new AudioPoint(-1, 0);
final AudioPoint head = ret;
//find a repeating pattern in the audio sample.
int lastX=-1;
int lastY=0;
double sumOfAngles=0;
Point beginPoint=new Point(-1,0);
Point lastPoint=new Point(-1,0);
double numAngles = 1;
for(int i=1;i<in.length;i++){
lastPoint = new Point(i+begin-1,in[i+begin-1]);
int x=i+begin;
int y=in[i+begin];
if(x>end)break;
if(beginPoint==null){
beginPoint=new Point(x,y);
continue; //go to next point, so that angle is not undefined.
}
double newAngle = Math.toDegrees(Math.atan((double)(y-lastPoint.y)/(double)(x-lastPoint.x))); //angle between start point and this point.
//SpeechSynthesizer.diagPrint(newAngle);
if(newAngle>180)newAngle-=360;
if(newAngle<-180)newAngle+=360;
double averageAngle = (sumOfAngles+newAngle)/(numAngles+1); //get average angle, NOT including this point
if(Math.abs(newAngle - averageAngle)>threshold && Point.distance(x, y, ret.getX(), ret.getY())>100){ //angle difference > threshold && distance from last point is greater than 100.
ret.setNext(new AudioPoint(x, y));
ret=ret.getNext();
sumOfAngles=newAngle; //reset all counts.
beginPoint = new Point(x,y);
numAngles=1;
}else{
numAngles++;
sumOfAngles+=newAngle;
}
}
//SpeechSynthesizer.diagPrint("frames: "+keyFrames);
//write out to file.
return head;
} |
0486853b-9592-44aa-ad5c-cf6bf97cf703 | 2 | private Rectangle union( Rectangle a, Rectangle b ){
if( a == null ){
return b;
}
if( b == null ){
return a;
}
return a.union( b );
} |
bbe1e048-f992-49de-ae34-ccd7b7d510ec | 9 | private List<URL> getRequiredLibsFromHome() {
List<URL> urls = new ArrayList<URL>();
try {
// Make sure Groovy, Gant, Ivy and GPars are on the classpath if we are using "griffonHome".
File[] files = new File(home, "lib").listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.startsWith("gant_") || name.startsWith("groovy-all") ||
name.startsWith("ivy") || name.startsWith("gpars");
}
});
for (File file : files) {
urls.add(file.toURI().toURL());
}
// Also make sure the bootstrap JAR is on the classpath.
files = new File(home, "dist").listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.startsWith("griffon-rt") ||
name.startsWith("griffon-cli") ||
name.startsWith("griffon-scripts") ||
name.startsWith("griffon-resources");
}
});
for (File file : files) {
urls.add(file.toURI().toURL());
}
return urls;
}
catch (MalformedURLException e) {
throw new RuntimeException(e);
}
} |
c0018b9b-b276-443b-8a64-dd4d3c0f14a5 | 3 | public static final void equals(Object obj, Object another, String message) {
isTrue((obj == null && another == null) || (obj != null && obj.equals(another)), message);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.