method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
3bc078f9-225c-4388-b9f9-6b1ef4f7df7e | 8 | public void render(float partialTick)
{
int mt = (int)(this.world.player.maxMoveTime/this.world.getTileAt(this.world.player.x, this.world.player.y).getWalkSpeed());
this.px = this.world.player.x*this.world.TILE_SIZE+(int)((this.world.player.nx-this.world.player.x)*(mt-this.world.player.moveTime+partialTick)*this.world.TILE_SIZE/mt)-Game.instance.getWidth()/2;
this.py = this.world.player.y*this.world.TILE_SIZE+(int)((this.world.player.ny-this.world.player.y)*(mt-this.world.player.moveTime+partialTick)*this.world.TILE_SIZE/mt)-Game.instance.getHeight()/2;
int rx = Game.instance.applet.getWidth()/this.world.TILE_SIZE/2;
int ry = Game.instance.applet.getHeight()/this.world.TILE_SIZE/2;
for(int i = this.world.player.x-rx-1; i <= this.world.player.x+rx+1; i++)
for(int j = this.world.player.y-ry-1; j <= this.world.player.y+ry+1; j++)
if(0 <= i && i < World.SIZE && 0 <= j && j < World.SIZE)
Tile.tiles.get(this.world.getTileIdAt(i, j)).renderAt(this, this.world, partialTick, i, j);
for(Entity entity : this.world.entities)
if(Math.abs(entity.x-this.world.player.x)+Math.abs(entity.y-this.world.player.y) < rx+ry)
entity.render(this, partialTick);
} |
4abfa1a3-6f71-467a-b93d-813cfbd6a2cb | 1 | private Integer parent(int pos) {
if(pos == 0) return null;
return pos /2;
} |
9df1df45-6013-4cef-b3bc-7761181b2f8f | 1 | public boolean passable() {
return type.passable() && bomb == null;
} |
95c221e2-ab6d-46c6-bbd7-ee46e1e5ff72 | 5 | @Override
public void render(float interpolation)
{
super.render(interpolation);
if(anim == null)
return;
anim[getDirectionID(d)].render(playerPos, playerDim);
if(animationStart == -1)
animationStart = System.currentTimeMillis();
if(!turned)
Fonts.get("Jungle").drawCenteredString("Lives: "+GameStatistics.lives, 70, 70, 0xffffff);
else
{
Fonts.get("Pixel_Arial").drawCenteredString("You lost a life! Continue?", 20, 25, 0xffffff);
Fonts.get("Jungle").drawCenteredString("Lives: "+(GameStatistics.lives-1), 100, 100, 0xff0000);
}
if(System.currentTimeMillis()-animationStart > 2000 && !turned)
{
AudioHandler.playSound("res/sound/fx/player/falling_male.wav", true, false);
turned = true;
}
} |
487c7294-c685-40c8-bc52-c404f7452087 | 3 | public JSONWriter array() throws JSONException {
if (this.mode == 'i' || this.mode == 'o' || this.mode == 'a') {
this.push(null);
this.append("[");
this.comma = false;
return this;
}
throw new JSONException("Misplaced array.");
} |
9047b3e4-b48a-4696-9742-abdbd7c8225e | 1 | public void unPauseGame() {
board.unpause();
if (pauseMenu != null) {
removeChild(pauseMenu);
}
pauseMenu = null;
} |
fd2d348f-bc01-458e-88e6-8396809382e3 | 6 | public static boolean cambiarStatusPaquete(Paquete paquete, String status)
{
Document doc;
Long identificadorPaquete;
Element root,child;
List <Element> rootChildrens;
boolean found = false;
int pos = 0;
SAXBuilder builder = new SAXBuilder();
try
{
doc = builder.build(Util.PAQUETE_XML_PATH);
root = doc.getRootElement();
rootChildrens = root.getChildren();
while (!found && pos < rootChildrens.size())
{
child = rootChildrens.get(pos);
identificadorPaquete = Long.parseLong(child.getAttributeValue(Util.PAQUETE_IDENTIFICADOR_TAG));
if(identificadorPaquete == paquete.getIdentificador()) {
rootChildrens.get(pos).setAttribute(Util.PAQUETE_STATUS_TAG, status);
found = true;
}
pos++;
}
if(found) {
try
{
Format format = Format.getPrettyFormat();
XMLOutputter out = new XMLOutputter(format);
FileOutputStream file = new FileOutputStream(Util.PAQUETE_XML_PATH);
out.output(doc,file);
file.flush();
file.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
return found;
} |
62468e6a-a773-4ae0-837d-10fd2eb78dbe | 6 | public void paintHex( Point aHexIx, Color aColor, boolean aToggle)
{
if (0 <= aHexIx.x && aHexIx.x < myHexGrid.getNumHorizHexes()
&& 0 <= aHexIx.y && aHexIx.y < myHexGrid.getNumVertHexes())
{
Hex hex = myHexGrid.getHexes()[ aHexIx.x][ aHexIx.y];
if (aToggle)
{
if (hex.getBackgroundColor() == null)
hex.setBackgroundColor( aColor);
else
hex.setBackgroundColor( null);
}
else
hex.setBackgroundColor( aColor);
Rectangle2D.Double hexBox = hex.getBounds2D();
Point2D.Double lower = new Point2D.Double( hexBox.x, hexBox.y);
Point2D.Double upper = new Point2D.Double( hexBox.x + hexBox.width,
hexBox.y + hexBox.height);
Point2D.Double[] xformedPts = new Point2D.Double[2];
getLastTransform().transform( new Point2D.Double[] { lower, upper },
0, xformedPts, 0, 2);
int x, y, width, height;
x = (int) Math.floor( xformedPts[ 0].x);
y = (int) Math.floor( xformedPts[ 0].y);
width = (int) (Math.ceil( xformedPts[ 1].x) - x);
height = (int) (Math.ceil( xformedPts[ 1].y) - y);
repaint( x, y, width, height);
}
} |
9f583bf0-7aea-4ac5-8054-0b4c90c13354 | 2 | public void setLabel(String label)
{
for(int i=0;i<markers;i++)
{
if(marker[i].isSelected())
{
marker[i].setLabel(label);
//break;
}
}
} |
2cd85b9d-c883-4079-ab2e-511bf7b66a77 | 3 | public void sortByLevel() {
Collections.sort(
images,
new Comparator<Card>() {
public int compare(Card a, Card b) {
if (a instanceof Climax) { //climaxes should sort to be after all level cards
if (b instanceof Climax) {
return 0;
}
return 1;
}
if (b instanceof Climax) {
return -1;
}
return Integer.compare(a.getLevel(), b.getLevel());
}
});
} |
fe897c20-ad36-442b-8677-2860364d5496 | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
FractalColourScheme other = (FractalColourScheme) obj;
if (colours == null) {
if (other.colours != null)
return false;
} else if (!colours.equals(other.colours))
return false;
if (gridline == null) {
if (other.gridline != null)
return false;
} else if (!gridline.equals(other.gridline))
return false;
return true;
} |
74d11489-e98f-402a-be6d-9847180dba7f | 7 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
Physical target=mob;
if((auto)&&(givenTarget!=null))
target=givenTarget;
if(target.fetchEffect(this.ID())!=null)
{
mob.tell(mob,target,null,L("<T-NAME> <T-IS-ARE> already affected by @x1.",name()));
return false;
}
if(!super.invoke(mob,commands,givenTarget,auto,asLevel))
return false;
final boolean success=proficiencyCheck(mob,0,auto);
if(success)
{
final CMMsg msg=CMClass.getMsg(mob,target,this,verbalCastCode(mob,target,auto),auto?L("<T-NAME> become(s) divinely lucky."):L("^S<S-NAME> @x1 for divine luck.^?",prayWord(mob)));
if(mob.location().okMessage(mob,msg))
{
mob.location().send(mob,msg);
beneficialAffect(mob,target,asLevel,0);
}
}
else
return beneficialWordsFizzle(mob,null,L("<S-NAME> @x1, but as luck would have it, there's no answer.",prayWord(mob)));
// return whether it worked
return success;
} |
9b392e11-d0fb-4348-af49-9770ef3e7c56 | 4 | private void cargaNAS(BufferedReader bf) throws IOException
{
String linea;
int indice;
double x,y,z,w;
Nodo nodo;
Elemento elemento;
do
{
linea = bf.readLine();
if(linea.startsWith("GRID"))
{
indice = Integer.parseInt(linea.substring(19, 24));
x = Double.parseDouble(linea.substring(41,56));
y = Double.parseDouble(linea.substring(56,72));
linea = bf.readLine();
z = Double.parseDouble(linea.substring(9,24));
nodo = new Nodo(new double[]{x,y,z});
nodos.put(new Integer(indice), nodo);
}
else
if(linea.startsWith("CQUAD4"))
{
indice = Integer.parseInt(linea.substring(11, 16));
x = Double.parseDouble(linea.substring(27,32));
y = Double.parseDouble(linea.substring(35,40));
z = Double.parseDouble(linea.substring(43,48));
w = Double.parseDouble(linea.substring(51));
elemento = new Elemento(new int[]{(int)x,(int)y,(int)z,(int)w});
elementos.put(new Integer(indice), elemento);
}
else
if(linea.startsWith("CTRIA3"))
{
indice = Integer.parseInt(linea.substring(9, 14));
x = Double.parseDouble(linea.substring(25,32));
y = Double.parseDouble(linea.substring(33,40));
z = Double.parseDouble(linea.substring(41));
elemento = new Elemento(new int[]{(int)x,(int)y,(int)z});
elementos.put(new Integer(indice), elemento);
}
}while(!linea.startsWith("ENDDATA"));
} |
15994752-ef03-40bc-8fb7-248f2b52d0a5 | 0 | public synchronized Object inspectNext() {
return queue.firstElement();
} |
95d8d58c-19bd-4a1b-9086-bfb52cadc2c6 | 3 | public void monitorFileCreate(Path file) {
try {
if(file.startsWith(sourceDir)){
Path subPath = sourceDir.relativize(file);
for(Path targetDir : targetDirs){
Path newPath = targetDir.resolve(subPath);
Files.createDirectories(newPath.getParent());
logger.info("cp "+file.toString()+" "+newPath.toString());
Files.copy(file, newPath);
}
}
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage());
}
} |
586cd7d5-eecb-4098-8f75-01e686255023 | 5 | @Override
public void run() {
byte[] buffer;
do {
try {
if (!active)
break;
int packageLength = input.readInt();
ByteBuffer wrapped = ByteBuffer.allocate(packageLength);
while (packageLength > 0) {
if (packageLength >= 1024) {
buffer = new byte[1024];
input.read(buffer, 0, 1024);
packageLength -= 1024;
} else {
buffer = new byte[packageLength];
input.read(buffer);
packageLength = 0;
}
wrapped.put(buffer);
}
handlePackage(wrapped);
} catch (IOException | BufferOverflowException e) {
active = false;
}
} while (active);
close();
} |
154f9230-76d6-4abd-b81f-073e7bb38ed2 | 3 | public XEquation(String equation){
equ = new Equation(equation);
Vector<Variable> variables = equ.getVariables();
if(variables.size()==0){
x = new Variable("x");
}
else{
if(variables.size()!=1)
throw new EquationException("Invalid X Equation: " + equation);
x = variables.firstElement();
if(!x.getName().equals("x"))
throw new EquationException("Invalid X Equation: " + equation);
}
} |
813c3a1e-52e9-4079-ae31-3f576bae8721 | 5 | @Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (!super.equals(obj))
{
return false;
}
if (!(obj instanceof BigVersion))
{
return false;
}
BigVersion other = (BigVersion) obj;
if (build != other.build)
{
return false;
}
if (patch != other.patch)
{
return false;
}
return true;
} |
8bca5fd7-f108-458e-931c-251b3bf585f9 | 0 | @Override
public ArrayList<String> getLastErrors() {
return this.lastErrors;
} |
5e3b3e4b-7527-49e8-a907-8b84e46ea221 | 3 | public static Map<String, String> parseMetadata(File metadataFile) {
HashMap<String, String> result = new HashMap<>();
try (FileInputStream in = new FileInputStream(metadataFile)) {
List<String> lines = IOUtils.readLines(in);
for (String line : lines) {
String[] arr = line.split(":");
result.put(arr[0].trim(), arr[1].trim());
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
} |
69a52de8-34dd-4d52-81de-68bd53e248c3 | 5 | public void getList(int rep)
{
String tempQuery = "";
if(rep == 0) {
tempQuery = "SELECT memberid,lastname,firstname,midinit from member order by lastname";
}
else if(rep == 1) {
String searchText = searchBox.getText().toUpperCase();
tempQuery = "select * from member where lastname like '"+searchText+"'";
}
listModel.clear();
arrayLastName.clear();
arrayFirstName.clear();
arrayMidName.clear();
arrayMemberid.clear();
Statement stmt = null;
this.connect();
conn = this.getConnection();
try
{
stmt = conn.createStatement();
}
catch (SQLException e)
{
e.printStackTrace();
}
ResultSet rs;
try
{
String firstname = "";
String lastname = "";
String midinit = "";
rs = stmt.executeQuery(tempQuery);
while(rs.next())
{
nameTemp += rs.getString("lastname");
nameTemp += ", " + rs.getString("firstname");
nameTemp += " " + rs.getString("midinit");
firstname = rs.getString("firstname");
lastname = rs.getString("lastname");
midinit = rs.getString("midinit");
arrayFirstName.add(firstname);
arrayLastName.add(lastname);
arrayMidName.add(midinit);
arrayMemberid .add(rs.getString("memberid"));
listModel.addElement(nameTemp);
nameTemp = "";
//System.out.println(nameTemp);
}
this.disconnect();
}
catch (SQLException e)
{
}
} |
a0cdfec1-2701-4a26-aa87-e302a23c4bf4 | 6 | private static Event nextEvent() {
Event e = null;
if (Keyboard.next()) {
if (Keyboard.getEventKeyState()) {
e = new Event(EventType.KEY_PRESSED, Keyboard.getEventKey());
} else {
e = new Event(EventType.KEY_RELEASED, Keyboard.getEventKey());
}
}
if (Mouse.next()) {
if (Mouse.getEventDX() != 0 || Mouse.getEventDY() != 0)
e = new Event(EventType.MOUSE_MOVE, 0);
else if (Mouse.getEventButtonState())
e = new Event(EventType.MOUSE_PRESSED, Mouse.getEventButton());
else
e = new Event(EventType.MOUSE_RELEASED, Mouse.getEventButton());
}
return e;
} |
c48f1626-93a3-49c7-8954-e888834865b0 | 5 | private static void openConnection() {
try
{
System.out.println("Loading the driver...");
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Loading successed ---------------");
String jsonEnvVars = java.lang.System.getenv("VCAP_SERVICES");
if (jsonEnvVars != null) {
// Runs on cloud
} else {
// Runs locally - only for maintenance
// Create database if non exists
Connection tempConn = null;
System.out.println("Creating database `reddit` if non exists");
try {
String url = "jdbc:mysql://localhost/";
tempConn = DriverManager.getConnection(url, USER_NAME, PASSWORD);
Statement stmt = tempConn.createStatement();
String sql = "CREATE DATABASE IF NOT EXISTS reddit;";
stmt.executeUpdate(sql);
System.out.println("Creating database successed");
} finally {
if (tempConn != null) {
tempConn.close();
}
}
String url = "jdbc:mysql://localhost/reddit?useUnicode=yes&characterEncoding=UTF-8";
System.out.println("Connected local host url=" + url);
conn= DriverManager.getConnection(url, USER_NAME, PASSWORD);
try (Statement statement = conn.createStatement()) {
String sql = "SET character_set_client = utf8";
sql = "SET character_set_results = utf8";
sql = "SET character_set_connection = utf8";
statement.executeUpdate(sql);
} catch (SQLException ex) {
System.err.println(ex.getMessage());
throw ex;
}
}
System.out.println((new StringBuilder("conn successed. conn=")).append(conn).toString());
}
catch(ClassNotFoundException ex)
{
System.err.println((new StringBuilder("error loading:")).append(ex.getMessage()).toString());
}
catch(SQLException ex)
{
System.err.println((new StringBuilder("error loading:")).append(ex.getMessage()).toString());
}
} |
f0a1f1be-8a90-4f7b-8203-9788595be88f | 5 | public static void merge(Comparable[] a, int lo, int mid, int hi) {
int i = lo, j = mid + 1;
for (int k = lo; k <= hi; k++) {
aux[k] = a[k];
}
for (int k = lo; k <= hi; k++) {
// ߵԪþȡұߵԪ
if (i > mid) {
a[k] = aux[j++];
}
// ұߵԪþȡߵԪ
else if (j > hi) {
a[k] = aux[i++];
}
// ҰߵĵǰԪСߵĵǰԪأȡҰԪ
else if (less(aux[j], aux[i])) {
a[k] = aux[j++];
}
// ҰߵĵǰԪشڵߵĵǰԪأȡԪ
else {
a[k] = aux[i++];
}
}
} |
51da68c5-9c60-4fdf-b3fa-aba841c67b28 | 3 | public Group setClasses(HashMap<Field, Time> aClasses) {
//System.out.println("Group.setClasses() : " + this + " " + aClasses);
if (aClasses != null)
this.classes = aClasses;
for (Field f : this.classes.keySet())
if (!this.done.containsKey(f))
this.done.put(f, false);
return this;
} |
9a0d6353-1ad9-4dcd-a3ae-fcaa86e285fa | 2 | public ArrayList<String> initialize(ArrayList<String> subordinatingConjunctions){
Scanner scanner = null;
try {
scanner = new Scanner(new File("subordinating conjunctions")).useDelimiter(",");
} catch (FileNotFoundException e) {
}
while (scanner.hasNextLine()) {
subordinatingConjunctions.add(scanner.nextLine());
}
return subordinatingConjunctions;
} |
8fb76c3d-36de-4a33-802a-a4810041acf2 | 0 | public SortMode(boolean sortUp, int sortMode) {
this.sortUp = sortUp;
this.sortMode = sortMode;
} |
1071da35-553f-4230-82f9-3e3ce7106fe8 | 4 | public MowerCommandListStringAdapter(final String mowercommandList) throws UnrecognizedCommandException {
super(null);
LinkedList<MowerCommand> mowerCommands = new LinkedList<MowerCommand>();
for (int i =0;i<mowercommandList.length();i++){
char command = mowercommandList.charAt(i);
switch(command){
case 'G':
mowerCommands.add(new MowerCommandLeft());
break;
case 'D':
mowerCommands.add(new MowerCommandRight());
break;
case 'A' :
mowerCommands.add(new MowerCommandForward());
break;
default:
throw new UnrecognizedCommandException();
}
}
this.commandList = mowerCommands;
} |
f8ccbcd8-d55e-4b60-95e5-56f6f99c45f8 | 2 | @Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == configButton || e.getSource() == okButton) {
// hides the config dialog
parent.configAction.tap();
}
} |
34870c11-d320-4183-88d8-78c88372783f | 4 | public static List<ContainerData> parseXmlFile(String path) {
try {
// Create a DocumentBuilderFactory
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
// Create a list to store the container data
List<ContainerData> containers = new ArrayList<>();
//Using factory get an instance of document builder
DocumentBuilder db = dbf.newDocumentBuilder();
//parse using builder to get DOM representation of the XML file
Document doc = db.parse(path);
// Get the root element
Element root = doc.getDocumentElement();
// Get the element count
int lenght = root.getChildNodes().getLength();
// Loop though the elements, parse them and add them to the list
for(int i = 0; i < lenght; i++) {
// Check the element type
if(root.getChildNodes().item(i).getNodeName().equals("record")) {
// Try to parse the container
ContainerData container = ContainerData.fromXml(root.getChildNodes().item(i));
// Add the container if the parsing succeeded
if (container != null) {
containers.add(container);
}
}
}
// Return the list
return containers;
}
catch(Exception ex) {
print("Parsing error: " + ex.getMessage());
return null;
}
} |
68134d72-8441-4f58-aabe-210169b614a0 | 9 | public int[] search (ASEvaluation ASEval, Instances data)
throws Exception {
double best_merit = -Double.MAX_VALUE;
double temp_merit;
BitSet temp_group, best_group=null;
if (!(ASEval instanceof SubsetEvaluator)) {
throw new Exception(ASEval.getClass().getName()
+ " is not a "
+ "Subset evaluator!");
}
m_SubsetEval = ASEval;
m_Instances = data;
m_numAttribs = m_Instances.numAttributes();
/* if (m_ASEval instanceof AttributeTransformer) {
throw new Exception("Can't use an attribute transformer "
+"with RankSearch");
} */
if (m_ASEval instanceof UnsupervisedAttributeEvaluator ||
m_ASEval instanceof UnsupervisedSubsetEvaluator) {
m_hasClass = false;
/* if (!(m_SubsetEval instanceof UnsupervisedSubsetEvaluator)) {
throw new Exception("Must use an unsupervised subset evaluator.");
} */
}
else {
m_hasClass = true;
m_classIndex = m_Instances.classIndex();
}
if (m_ASEval instanceof AttributeEvaluator) {
// generate the attribute ranking first
Ranker ranker = new Ranker();
m_ASEval.buildEvaluator(m_Instances);
if (m_ASEval instanceof AttributeTransformer) {
// get the transformed data a rebuild the subset evaluator
m_Instances = ((AttributeTransformer)m_ASEval).
transformedData(m_Instances);
((ASEvaluation)m_SubsetEval).buildEvaluator(m_Instances);
}
m_Ranking = ranker.search(m_ASEval, m_Instances);
} else {
GreedyStepwise fs = new GreedyStepwise();
double [][]rankres;
fs.setGenerateRanking(true);
((ASEvaluation)m_ASEval).buildEvaluator(m_Instances);
fs.search(m_ASEval, m_Instances);
rankres = fs.rankedAttributes();
m_Ranking = new int[rankres.length];
for (int i=0;i<rankres.length;i++) {
m_Ranking[i] = (int)rankres[i][0];
}
}
// now evaluate the attribute ranking
for (int i=m_startPoint;i<m_Ranking.length;i+=m_add) {
temp_group = new BitSet(m_numAttribs);
for (int j=0;j<=i;j++) {
temp_group.set(m_Ranking[j]);
}
temp_merit = ((SubsetEvaluator)m_SubsetEval).evaluateSubset(temp_group);
if (temp_merit > best_merit) {
best_merit = temp_merit;;
best_group = temp_group;
}
}
m_bestMerit = best_merit;
return attributeList(best_group);
} |
aaff9c9a-9e18-4337-90b9-b97a75e1f4d7 | 8 | public static void main(String args[]) throws Exception
{
final int TOP = 200;
String outputPath = "C:/z-ling/task/HEY/ResultTest/AccuracyResult_"+TOP+".txt";
FileOutputStream fos=new FileOutputStream(outputPath);
OutputStreamWriter osw=new OutputStreamWriter(fos);
BufferedWriter bw=new BufferedWriter(osw);
//Cosine Similarity
String fileName1 = "C:/z-ling/task/HEY/ResultTest/TopSim_"+TOP+".txt";
File file1 = new File(fileName1);
BufferedReader reader1 = null;
reader1 = new BufferedReader(new FileReader(file1));
String tempString1 = null;
HashMap<String,Float> map1 = new HashMap<String,Float>();
final int consineSimTop = 200;
int i = 0;
while ((tempString1 = reader1.readLine()) != null && i<consineSimTop) {
i++;
String[] s = tempString1.split("\t",3);
String key = null;
if(Long.valueOf(s[0])<Long.valueOf(s[1]))
key = s[0]+"\t"+s[1];
else
key = s[1]+"\t"+s[0];
float value = Float.valueOf(s[2]);
map1.put(key, value);
// System.out.println(s[0]+"\t"+s[1]+value);
}
System.out.println("map1 size: "+map1.size());
bw.write("using cosine similarity: "+map1.size());
bw.newLine();
reader1.close();
//HSEM
String fileName2 = "C:/z-ling/task/HEY/ResultTest/HamTopSim_"+TOP+"2.txt";
File file2 = new File(fileName2);
BufferedReader reader2 = null;
reader2 = new BufferedReader(new FileReader(file2));
String tempString2 = null;
HashMap<String,Float> map2 = new HashMap<String,Float>();
final int hammingTop = 200;
int j = 0;
while ((tempString2 = reader2.readLine()) != null&& j<hammingTop) {
j++;
String[] s = tempString2.split("\t",3);
String key = null;
if(Long.valueOf(s[0])<Long.valueOf(s[1]))
key = s[0]+"\t"+s[1];
else
key = s[1]+"\t"+s[0];
float value = Float.valueOf(s[2]);
map2.put(key, value);
// System.out.println(s[0]+"\t"+s[1]+value);
}
System.out.println("map2 size: "+map2.size());
bw.write("using hamming distance: "+map2.size());
bw.newLine();
reader2.close();
int match = 0;
Iterator iter = map2.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
Object key = entry.getKey();
// Object val = entry.getValue();
if(map1.containsKey(key))
match++;
}
double rate = ((double)match)/((double)map2.size());
System.out.println("Match Rate: "+rate);
bw.write("Match Rate: "+rate);
bw.newLine();
bw.close();
} |
416498c5-8dc1-4b00-9138-412f6bdcb9b5 | 3 | public void updateMobs(){
for(int i = 0; i < items.size(); i++){
items.get(i).update();
}
for(int i = 0; i < mobs.size(); i++){
mobs.get(i).update();
}
for(Player e : players){
e.update();
}
} |
cfb50397-a1f5-4990-9790-4f3db290860c | 0 | public int getValue() {
return value;
} |
e5524145-e781-4b53-87b7-cd5832bc359a | 9 | protected boolean checkYObstacle(CommonObject so, double time, int halfOfWidth) {
if ((this.currentCoord.getY() + this.currentHeight + currentVerticalSpeed * time >= so.getCurrentCoordinates().getY())
&& (this.currentCoord.getY() + this.currentHeight <= so.getCurrentCoordinates().getY())
&& ((this.currentCoord.getX() + halfOfWidth >= so.getCurrentCoordinates().getX())
&& (this.currentCoord.getX() + halfOfWidth <= so.getCurrentCoordinates().getX() + so.getLength()))) {
changeWidthAndHeight();
this.currentCoord.setY(so.getCurrentCoordinates().getY() - this.currentHeight);
//currentVerticalSpeed = 0;
return true;
}
if (this.currentCoord.getY() + currentVerticalSpeed * time < so.getCurrentCoordinates().getY() + so.getHeight()
&& this.currentCoord.getY() > so.getCurrentCoordinates().getY()
&& (this.currentVerticalSpeed < 0)
&& ((this.currentCoord.getX() + halfOfWidth >= so.getCurrentCoordinates().getX())
&& (this.currentCoord.getX() + halfOfWidth <= so.getCurrentCoordinates().getX() + so.getLength()))) {
this.currentCoord.setY(so.getCurrentCoordinates().getY() + so.getHeight());
//currentVerticalSpeed = 0;
return true;
}
return false;
} |
6e1f8b5d-5473-4cf7-9922-05f913df9a6d | 9 | public static boolean kickClient(Player player, Client adminClient, boolean banUser, boolean banUserAndMac) {
boolean kik = GameManager.kickClient(player.getName(), adminClient);
if (kik == false) {
Client kickedClient = null;
synchronized(clients) {
for (Client client : clients) {
if (client.getPlayerModel().getName().equalsIgnoreCase(player.getName())) {
kickedClient = client;
break;
}
}
}
if (kickedClient != null) {
logger.info("Kick Player inLobby: " + kickedClient);
sendAll(new MessageMessage("System",
"<span style=\"color:red;\">"
+ kickedClient.getPlayerModel().getName()
+ " was kicked by <b>"
+ adminClient.getPlayerModel().getName() + "</b></span>"));
kickedClient.disconnect();
kik = true;
}
}
if (kik == false) {
adminClient.send(new MessageMessage("System",
"<span style=\"color:red;\"> " + player.getName()
+ " User is not Online!</span>"));
}
if (banUser == true) {
player.setBlocked(true);
try {
EntityManager entityManager =
PersistenceManager.getInstance().getEntityManager();
EntityTransaction entityTransaction = entityManager
.getTransaction();
entityTransaction.begin();
entityManager.merge(player);
entityManager.flush();
entityTransaction.commit();
adminClient.send(new MessageMessage("System","<span style=\"color:red;\">"
+ player.getName()
+ " (Account) has been banned!</span>"));
logger.debug("Block for User " + player.getName() + " / "
+ player.getMac() + " saved.");
} catch (Throwable t) {
logger.error("error while saving block for User "
+ player.getName() + " / " + player.getMac() + " ", t);
}
}
if (banUserAndMac == true) {
adminClient.send(new MessageMessage("System","<span style=\"color:red;\">"
+ player.getName()
+ " (Mac) has been blacklisted!</span>"));
try {
EntityManager entityManager = PersistenceManager
.getInstance().getEntityManager();
EntityTransaction entityTransaction = entityManager
.getTransaction();
entityTransaction.begin();
BlackList blacklist = new BlackList();
blacklist.setData(player.getMac());
entityManager.persist(blacklist);
entityManager.flush();
entityTransaction.commit();
logger.debug("Block for MAC " + player.getName() + " / "
+ player.getMac() + " saved.");
} catch (Throwable t) {
logger.error("error while saving block for MAC "
+ player.getName() + " / " + player.getMac() + " ", t);
}
}
return kik;
} |
613c26ce-8d0b-4626-9daf-863cbc232a6f | 4 | public static void main( String args[] ){
MiniDB db = new MiniDB( "minidb" );
BufMgr bm = db.getBufMgr();
int size = 8;
BPlusTree bpt = null;
try{
bpt = db.createNewBPlusTreeIndex( "table", "val", 8 );
int iters = 50;
MiniDB_Record insertedRecords[] = new MiniDB_Record[iters];
// Add some records. It will require splits of leaf nodes but not internal nodes
for (int i=0; i<iters; i++){
long value = ((int)Math.pow(-1, i))*i*2;
int blockID = (i+1)*100;
bpt.insertRecord(value, blockID);
MiniDB_Record rec = new MiniDB_Record(blockID,value);
insertedRecords[i] = rec;
System.out.println( "Inserted " + rec );
}
System.out.println( "\nB+Tree after all values inserted: " );
System.out.println( bpt.allTreeValuesToString() );
System.out.println( "\n BPlusTree.getAll() \n" );
// get all values
Arrays.sort( insertedRecords );
Vector vValues = new Vector();
Vector vBlkIDs = new Vector();
bpt.getAll( vValues, vBlkIDs );
for (int i=0; i<iters; i++){
Long lVal = (Long)vValues.get(i);
Integer iblockID = (Integer)vBlkIDs.get(i);
MiniDB_Record recGot = new MiniDB_Record( iblockID, lVal );
MiniDB_Record recExp = insertedRecords[i];
System.out.println( "expected " + recExp + ", got " + recGot );
if( !recGot.equals( recExp ) ){
MiniDB_Util.waitHere( "Error" );
}
}
}
catch( Exception e ){
System.out.println( "Exception " + e );
e.printStackTrace();
System.exit(0);
}
} |
9f9d7c3c-2043-45f1-9836-6e84d3d5e8d4 | 4 | private void loadLandPolygons(String file, final HashMap<Integer, GMTShape> landPolygons) {
GMTParser gmtpLandPolygons = new GMTParser() {
@Override
public void processShape(GMTShape shape) {
if (shape.getxPoly().length > 0) {
landPolygons.put(shape.getID(), shape);
}
}
};
try {
gmtpLandPolygons.load(file);
} catch (FileNotFoundException ex) {
Logger.getLogger(DataLoader.class.getName()).log(Level.SEVERE, null, ex);
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(DataLoader.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(DataLoader.class.getName()).log(Level.SEVERE, null, ex);
}
} |
83e4a6ae-a088-4db9-b3d2-48d02eec7515 | 3 | public void setLineWidth(float lineWidth) {
// Automatic Stroke Adjustment
if (lineWidth <= Float.MIN_VALUE || lineWidth >= Float.MAX_VALUE ||
lineWidth == 0) {
// set line width to a very small none zero number.
this.lineWidth = 0.001f;
} else {
this.lineWidth = lineWidth;
}
} |
aca90103-1a91-491a-8939-5e166ec7ef9c | 4 | public void loadRawData() {
File f = window.showOpenDialog(new FileNameExtensionFilter("Text files", "txt"));
if (f == null) return;
StringBuilder fileStringBuilder = new StringBuilder();
try {
BufferedReader fr = new BufferedReader(new FileReader(f));
String line;
while ((line = fr.readLine()) != null) {
fileStringBuilder.append(line);
fileStringBuilder.append("\n");
}
} catch (IOException e) {
log("Unable to open file. Please check file is not open elsewhere and try again.", "error");
}
FlightLog fl = new FlightLog();
try {
fl.fromRawData(fileStringBuilder.toString());
} catch (IOException e) {
log("Unable to parse file. Are you sure that this is a raw data file?", "error");
}
setFlightLog(fl);
window.setDataState(DataState.HAVE_DATA);
} |
2b61ddb3-da8e-4054-bd49-b9f87b41028a | 9 | static public BigDecimal atan(final BigDecimal x)
{
if ( x.compareTo(BigDecimal.ZERO) < 0 )
{
return atan(x.negate()).negate() ;
}
else if ( x.compareTo(BigDecimal.ZERO) == 0 )
return BigDecimal.ZERO ;
else if ( x.doubleValue() >0.7 && x.doubleValue() <3.0)
{
/* Abramowitz-Stegun 4.4.34 convergence acceleration
* 2*arctan(x) = arctan(2x/(1-x^2)) = arctan(y). x=(sqrt(1+y^2)-1)/y
* This maps 0<=y<=3 to 0<=x<=0.73 roughly. Temporarily with 2 protectionist digits.
*/
BigDecimal y = scalePrec(x,2) ;
BigDecimal newx = divideRound( hypot(1,y).subtract(BigDecimal.ONE) , y);
/* intermediate result with too optimistic error estimate*/
BigDecimal resul = multiplyRound( atan(newx), 2) ;
/* absolute error in the result is errx/(1+x^2), where errx = half of the ulp. */
double eps = x.ulp().doubleValue()/( 2.0* Math.hypot(1.0, x.doubleValue()) ) ;
MathContext mc = new MathContext( err2prec(resul.doubleValue(),eps) ) ;
return resul.round(mc) ;
}
else if ( x.doubleValue() < 0.71 )
{
/* Taylor expansion around x=0; Abramowitz-Stegun 4.4.42 */
final BigDecimal xhighpr = scalePrec(x,2) ;
final BigDecimal xhighprSq = multiplyRound(xhighpr,xhighpr).negate() ;
BigDecimal resul = xhighpr.plus() ;
/* signed x^(2i+1) */
BigDecimal xpowi = xhighpr ;
/* absolute error in the result is errx/(1+x^2), where errx = half of the ulp.
*/
double eps = x.ulp().doubleValue()/( 2.0* Math.hypot(1.0, x.doubleValue()) ) ;
for(int i= 1 ; ; i++)
{
xpowi = multiplyRound(xpowi,xhighprSq) ;
BigDecimal c = divideRound(xpowi,2*i+1) ;
resul = resul.add(c) ;
if ( Math.abs(c.doubleValue()) < 0.1*eps)
break;
}
MathContext mc = new MathContext( err2prec(resul.doubleValue(),eps) ) ;
return resul.round(mc) ;
}
else
{
/* Taylor expansion around x=infinity; Abramowitz-Stegun 4.4.42 */
/* absolute error in the result is errx/(1+x^2), where errx = half of the ulp.
*/
double eps = x.ulp().doubleValue()/( 2.0* Math.hypot(1.0, x.doubleValue()) ) ;
/* start with the term pi/2; gather its precision relative to the expected result
*/
MathContext mc = new MathContext( 2+err2prec(3.1416,eps) ) ;
BigDecimal onepi= pi(mc) ;
BigDecimal resul = onepi.divide(new BigDecimal(2)) ;
final BigDecimal xhighpr = divideRound(-1,scalePrec(x,2)) ;
final BigDecimal xhighprSq = multiplyRound(xhighpr,xhighpr).negate() ;
/* signed x^(2i+1) */
BigDecimal xpowi = xhighpr ;
for(int i= 0 ; ; i++)
{
BigDecimal c = divideRound(xpowi,2*i+1) ;
resul = resul.add(c) ;
if ( Math.abs(c.doubleValue()) < 0.1*eps)
break;
xpowi = multiplyRound(xpowi,xhighprSq) ;
}
mc = new MathContext( err2prec(resul.doubleValue(),eps) ) ;
return resul.round(mc) ;
}
} /* BigDecimalMath.atan */ |
eae2707e-4e53-45af-98fc-937feac19e70 | 7 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Movie other = (Movie) obj;
if (movieId != other.movieId)
return false;
if (title == null) {
if (other.title != null)
return false;
} else if (!title.equals(other.title))
return false;
return true;
} |
363fae5a-f6ac-4d48-8264-33999df46dc6 | 9 | public static Vector xmlRead(String fileName)
{
SAXBuilder builder = new SAXBuilder();
Vector pointsList = new Vector();
try
{
Document doc = builder.build( fileName ); // parse XML tags
Element root = doc.getRootElement(); // get root of XML tree
List <Element>children = root.getChildren();
Iterator iterator = children.iterator();
List <Element> subChildren = null;
List <Element> points = null;
String value = null;
float x1, y1, x2, y2;
int a;
for(int i=0; i<children.size(); i++)
{
if (children.get(i).getName().equals("shape"))
subChildren = children.get(i).getChildren();
}
Vector xymin = new Vector();
Vector xymax = new Vector();
// loop across subchildren of shape level
for(int i=0; i<subChildren.size(); i++)
{
if (subChildren.get(i).getName().equals("polyline"))
{
points = subChildren.get(i).getChildren();
Vector point = new Vector();
for(int j=0; j<points.size(); j++)
{
value = points.get(j).getValue();
a = value.indexOf(" ", 1);
point.add(Double.parseDouble(value.substring(0, a)));
point.add(Double.parseDouble(value.substring(a, value.length())));
}
pointsList.add(point);
}
else if (subChildren.get(i).getName().equals("xymin"))
{
Element point = subChildren.get(i);//.getChildren();
value = point.getValue();
a = value.indexOf(" ", 1);
xymin.add(Double.parseDouble(value.substring(0, a)));
xymin.add(Double.parseDouble(value.substring(a, value.length())));
}
else if (subChildren.get(i).getName().equals("xymax"))
{
Vector xyrange = new Vector();
Element point = subChildren.get(i);//.getChildren();
value = point.getValue();
a = value.indexOf(" ", 1);
xymax.add(Double.parseDouble(value.substring(0, a)));
xymax.add(Double.parseDouble(value.substring(a, value.length())));
xyrange.add((double)xymax.get(0)-(double)xymin.get(0));
xyrange.add((double)xymax.get(1)-(double)xymin.get(1));
pointsList.add(xyrange);
}
}
}
// JDOMException indicates a well-formedness error
catch ( JDOMException e )
{
System.out.println( "walkway.xml" + " is not well-formed." );
System.out.println( e.getMessage() );
}
catch ( IOException e )
{
System.out.println( e );
}
return pointsList;
//
} |
32a8eeca-48b3-424e-8eb6-1133c5c90b94 | 1 | private void loadInfo(ResultSet result){
try{
result.next();
start = result.getString("cas_startu");
end = result.getString("cas_konce");
}catch(SQLException se){
//Handle errors for JDBC
se.printStackTrace();
}
} |
4f73f0f1-e76d-4b53-9ac8-94bb84ed76f9 | 7 | public JSONObject createDomain(
String mode,
String domain,
String group,
String rname,
String[] ns,
String primary_wildcard,
String primary_wildcard_qtype,
String default_mx) {
StringBuilder uriBuilder = new StringBuilder("/api/createDomain/?") ;
uriBuilder.append("AUTH_TOKEN="+apiToken) ;
uriBuilder.append("&domain="+domain) ;
uriBuilder.append("&mode="+mode) ;
if (group!=null) {
uriBuilder.append("&group="+group) ;
}
if (rname!=null) {
uriBuilder.append("&rname="+rname) ;
}
if (ns!=null) {
for (int x=0; x<ns.length;x++) {
uriBuilder.append("&ns="+ns[x]) ;
}
}
if (primary_wildcard!=null) {
uriBuilder.append("&primary_wildcard="+primary_wildcard) ;
}
if (primary_wildcard_qtype!=null) {
uriBuilder.append("&primary_wildcard_qtype="+primary_wildcard_qtype) ;
}
if (default_mx!=null) {
uriBuilder.append("&default_mx="+default_mx) ;
}
return makeHttpRequest(uriBuilder.toString()) ;
} |
4ed9e5ff-56fa-42a5-91a2-55c4fe1f7c55 | 8 | void output(int code, OutputStream outs) throws IOException {
cur_accum &= masks[cur_bits];
if (cur_bits > 0)
cur_accum |= (code << cur_bits);
else
cur_accum = code;
cur_bits += n_bits;
while (cur_bits >= 8) {
char_out((byte) (cur_accum & 0xff), outs);
cur_accum >>= 8;
cur_bits -= 8;
}
// If the next entry is going to be too big for the code size,
// then increase it, if possible.
if (free_ent > maxcode || clear_flg) {
if (clear_flg) {
maxcode = MAXCODE(n_bits = g_init_bits);
clear_flg = false;
} else {
++n_bits;
if (n_bits == maxbits)
maxcode = maxmaxcode;
else
maxcode = MAXCODE(n_bits);
}
}
if (code == EOFCode) {
// At EOF, write the rest of the buffer.
while (cur_bits > 0) {
char_out((byte) (cur_accum & 0xff), outs);
cur_accum >>= 8;
cur_bits -= 8;
}
flush_char(outs);
}
} |
6c2228b7-8b6e-4186-9703-b2d5ac5cd415 | 7 | private void LoadSavedBill(){
if(ComboBox_SaveBill.getItemCount() > 0){
int idxFile = ComboBox_SaveBill.getSelectedIndex();
String loadFile = saveBillFile + idxFile;
int count = 1;
clear_Paid_list();
clear_table(dm_hoa_don);
try{
FileInputStream in = new FileInputStream(loadFile);
thongbao_text(loadFile, Color.blue);
try (BufferedReader bufffile = new BufferedReader(new InputStreamReader(in, "UTF8"))){
String strLine;
strLine = bufffile.readLine();
while (strLine != null) {
if(strLine.substring(0, 3).equals("==+")){
ten_khach_hang.setText(strLine.substring(3));
}else if(strLine.substring(0, 3).equals("===")){
String sdata[] = strLine.substring(3).split("<>");
Vector sVector = new Vector();
sVector.add(count++);
sVector.add(sdata[0]); //ma sp
sVector.add(sdata[1]); //ten sp
sVector.add(sdata[2]); //gia s
sVector.add(sdata[3]); //gia l
sVector.add(sdata[4]); //so luong
sVector.add(sdata[5]); // tien
sVector.add(Boolean.TRUE);
dm_hoa_don.addRow(sVector);
dm_hoa_don.fireTableDataChanged();
Paid_MaSP.add(sdata[0]);
Paid_TenSP.add(sdata[1]);
Paid_GiaSSP.add(Double.parseDouble(sdata[2]));
Paid_GiaLSP.add(Double.parseDouble(sdata[3]));
Paid_SoLuongSP.add(Double.parseDouble(sdata[4]));
Paid_TongGiaSP.add(Double.parseDouble(sdata[5]));
//
}else if(strLine.substring(0, 3).equals("==-")){
No_cu.setText(strLine.substring(3));
}
strLine = bufffile.readLine();
}
if(dm_hoa_don.getRowCount() > 0){
add_Paid_row();
}else{
clear_Paid_list();
clear_table(dm_hoa_don);
thongbao_text("[Lỗi] refresh để làm lại", Color.RED);
}
}
in.close();
}catch (Exception e){//Catch exception if any
thongbao_text("Lỗi" + e.getMessage(), Color.RED);
}
}else{
thongbao_text("Chưa có hóa đơn nào được lựu", Color.blue);
}
} |
45c760d6-a67d-47fa-85f2-b5aa045afd19 | 4 | private boolean abortRequest(Request request) {
// Presumption : transaction exists
transactionEntity tempT = this.transInfo.get(request.transaction);
// remove all transaction requests in the waiting list.
Set<Request> removing = new HashSet<Request>();
for (Request wait : this.waitingList) {
if (wait.transaction.equals(request.transaction))
removing.add(wait);
}
this.waitingList.removeAll(removing);
// clear site visiting record
// clear site lock and buffer data
for (Site site : tempT.visitedSites) {
if (!site.isRunning())
continue;
site.exeRequest(request);
this.visitingTrans.get(site).remove(tempT.name);
}
tempT.status = tranStatus.Aborted;
tempT.visitedSites = Collections.unmodifiableSet(tempT.visitedSites);
System.out
.println("transaction [" + tempT.name + "] have been aborted");
return true;
} |
54e8db38-f4f2-4b6e-b074-b75ec9e9d342 | 0 | public void setDepartmentId(int departmentId) {
this.departmentId = departmentId;
} |
29f76aad-704a-4aee-a44f-0ac0784cda75 | 6 | public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof TalenPerLandPK)) {
return false;
}
TalenPerLandPK other = (TalenPerLandPK) o;
return true
&& (getLandCode() == null ? other.getLandCode() == null : getLandCode().equals(other.getLandCode()))
&& (getTaalCode() == null ? other.getTaalCode() == null : getTaalCode().equals(other.getTaalCode()));
} |
64f5a6de-8c17-4b4f-a436-114fc56ef3cb | 4 | static double dot(svm_node[] x, svm_node[] y)
{
double sum = 0;
int xlen = x.length;
int ylen = y.length;
int i = 0;
int j = 0;
while(i < xlen && j < ylen)
{
if(x[i].index == y[j].index)
sum += x[i++].value * y[j++].value;
else
{
if(x[i].index > y[j].index)
++j;
else
++i;
}
}
return sum;
} |
972daf0b-7479-41b6-b1f9-41ebb115a19f | 6 | public String strStr(String haystack, String needle) {
if (needle.isEmpty())
return haystack;
if (haystack.isEmpty())
return null;
int m = 0; // the beginning of the current match in haystack
int i = 0; // the position of the current character in needle
int[] T = kmpTable(needle);
while (m + i < haystack.length()) {
if (needle.charAt(i) == haystack.charAt(m + i)) {
if (i == needle.length() - 1)
return haystack.substring(m);
else
i++;
} else {
m = m + i - T[i]; // it is good to set T[0] = -1;
if (T[i] > -1)
i = T[i];
else
i = 0;
}
}
return null;
} |
52b54b00-c26d-4e37-b833-d2b84eb3012e | 3 | public void resetDemo()
{
entities.removeAll(Entity.class);
createBorders();
for (int i = 0; i < 10; i++)
createAndPositionToFreeSpot(new Ball());
for (int i = 0; i < Const.cheeseamount; i++)
createAndPositionToFreeSpot(new Cheese());
if (menu != null) menu.popMenu(true);
} |
2cf77880-2d8a-46ec-a36b-44970c35fec1 | 7 | public static boolean isReservedOr(String candidate) {
int START_STATE = 0;
int TERMINAL_STATE = 2;
char next;
if (candidate.length()!=2){
return false;
}
int state = START_STATE;
for (int i = 0; i < candidate.length(); i++)
{
next = candidate.charAt(i);
switch (state)
{
case 0:
switch ( next )
{
case 'o': state++; break;
default : state = -1;
}
break;
case 1:
switch ( next )
{
case 'r': state++; break;
default : state = -1;
}
break;
}
}
if ( state == TERMINAL_STATE )
return true;
else
return false;
} |
48efe2a7-f429-46cb-8847-25f72aa229b6 | 9 | static final void method129(int i, int i_0_, long[] ls, int i_1_,
int[] is) {
do {
try {
anInt89++;
if ((i ^ 0xffffffff) > (i_1_ ^ 0xffffffff)) {
int i_2_ = (i_1_ + i) / 2;
int i_3_ = i;
long l = ls[i_2_];
ls[i_2_] = ls[i_1_];
ls[i_1_] = l;
int i_4_ = is[i_2_];
is[i_2_] = is[i_1_];
is[i_1_] = i_4_;
int i_5_ = l == 9223372036854775807L ? 0 : 1;
for (int i_6_ = i;
(i_6_ ^ 0xffffffff) > (i_1_ ^ 0xffffffff); i_6_++) {
if ((ls[i_6_] ^ 0xffffffffffffffffL)
> (l - -(long) (i_5_ & i_6_)
^ 0xffffffffffffffffL)) {
long l_7_ = ls[i_6_];
ls[i_6_] = ls[i_3_];
ls[i_3_] = l_7_;
int i_8_ = is[i_6_];
is[i_6_] = is[i_3_];
is[i_3_++] = i_8_;
}
}
ls[i_1_] = ls[i_3_];
ls[i_3_] = l;
is[i_1_] = is[i_3_];
is[i_3_] = i_4_;
method129(i, -126, ls, -1 + i_3_, is);
method129(1 + i_3_, -81, ls, i_1_, is);
}
if (i_0_ < -72)
break;
method130(99);
} catch (RuntimeException runtimeexception) {
throw Class348_Sub17.method2929(runtimeexception,
("gv.A(" + i + ',' + i_0_ + ','
+ (ls != null ? "{...}"
: "null")
+ ',' + i_1_ + ','
+ (is != null ? "{...}"
: "null")
+ ')'));
}
break;
} while (false);
} |
6563f490-2a7c-412b-a81f-1a8b6ed429fa | 4 | private void addDeclination( String root, Properties props, int count ) {
for( int i = 1; i <= count; i++ ) {
String declination = props.getProperty( String.valueOf( i ) );
if( declination == null ) {
return;
}
declination = declination.replace( "{{pn}}", root );
declination = declination.replace( "<br>", " " );
declination = declination.replaceAll( "<br\\s*?/>", " " );
declination = declination.replace( "<small>", "" );
declination = declination.replace( "</small>", "" );
declination = declination.replace( ",", " " );
declination = declination.replace( "/", " " );
declination = removeQuotes( declination );
String[] words = declination.split( "\\s+" );
for( String word : words ) {
word = removeQuotes( word );
if( super.isValidWord( word ) ) {
addWord( word );
// } else {
// if( word.length() > 0 && !word.equals( "-" ) && !word.equals( "[1]" ) && !word.equals( "[2]" )
// && !word.equals( "1" ) && !word.equals( "2" ) && !word.equals( "3" ) ) {
// System.err.println( word );
// }
}
}
}
} |
3d1993f3-dfe5-441a-90fc-f74f5eaf48d9 | 7 | private void checkAndUpdateWeapon() {
TouchableRectangle.direction dir;
for (int i = 0; i < bricks.size() && weapon != null; i++) {
Brick br = bricks.get(i);
if ((dir = br.touches(weapon)) != Brick.direction.NONE) {
Dropping temp = br.dropping;
if (temp != null) {
droppings.add(br.dropping);
}
if(!br.stone){
bricks.remove(br);
scoreCount+=BRICK_SCORE;
i--;
}
weapon = null;
break;
}
}
if (weapon != null) {
if (weapon.y < 0) {
weapon = null;
} else {
weapon.move();
}
}
} |
54528e21-c75a-4477-8437-5b5bc1974112 | 4 | @Override
public void run() {
//Go on while run is true
while(run.get()) {
try {
TFTPPacket packet = packetQueue.take();
if(packet instanceof WRQPacket){
sendFile((WRQPacket) packet);
}else if(packet instanceof RRQPacket){
receiveFile((RRQPacket) packet);
}
} catch (Exception e) {
fireExceptionOccurred(TFTPClient.this, e);
}
}
socket.close();
} |
ecb7a88e-3f61-414c-9ea4-cf88fdbd3380 | 2 | public SkiPass getSecondHalfDaySkiPass(Date currentDate) {
if (currentDate == null) {
throw new IllegalArgumentException("Current date is null");
}
Calendar calendar = new GregorianCalendar();
calendar.setTime(currentDate);
calendar.set(Calendar.HOUR_OF_DAY, 13);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
Date activationDate = calendar.getTime();
calendar.add(Calendar.HOUR_OF_DAY, 4);
Date expirationDate = calendar.getTime();
if (expirationDate.before(currentDate)) {
return null;
} else {
return system.createSkiPass("HOURLY", activationDate,
expirationDate, 0);
}
} |
1aa998e2-f2e8-4d19-b6ab-d764d57a70ab | 5 | private void analyzeImage(BufferedImage image) {
setProgress("Analyzing...");
worker = new PatchFinder(
image,
controller.getParametersBean().getTolerance(),
40 // TODO parameter
);
worker.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if ( evt.getPropertyName().equals("progress") ) {
setProgress(
"Analyzing: "+(double)Math.round((double)evt.getNewValue()*10000)/100+"%",
(double)evt.getNewValue()
);
}
if ( evt.getPropertyName().equals("done") && (boolean)evt.getNewValue() ) {
try {
sortPatches(worker.get());
} catch (InterruptedException e) {
controller.getImageBean().setStatus(ImageBean.LOADED);
} catch (ExecutionException e) {
e.printStackTrace();
}
}
}
});
worker.execute();
} |
fd730c45-b7dc-4acc-b179-efa6f92ec88f | 5 | public String getAnswer(){
for(int a = 1; a < 1000; a++)
for(int b = 1; b < 1000; b++)
for(int c = 1; c < 1000; c++)
if(a + b + c == 1000 && Math.pow(a, 2) + Math.pow(b, 2) == Math.pow(c, 2))
return String.valueOf(a * b * c);
return null;
} |
075451c7-d022-4807-a060-08ddb2337c02 | 7 | private void initComponents() {
//Components
menuBar1 = new JMenuBar();
mFile = new JMenu();
mF1 = new JMenuItem();
mF2 = new JMenuItem();
mF3 = new JMenuItem();
mF4 = new JMenuItem();
mF5 = new JMenuItem();
mEdit = new JMenu();
mE1 = new JMenuItem();
mView = new JMenu();
mV1 = new JMenuItem();
mV2 = new JMenuItem();
mComp = new JMenu();
mC1 = new JMenuItem();
mC2 = new JMenuItem();
mMsds = new JMenu();
mM1 = new JMenuItem();
mM2 = new JMenuItem();
mHelp = new JMenu();
mH1 = new JMenuItem();
mH2 = new JMenuItem();
gPane = new JTabbedPane();
panel4 = new JPanel();
mLab1 = new JLabel();
sComp1 = new JTextField();
gLab1 = new JLabel();
cLab1 = new JLabel();
cScroll = new JScrollPane();
cList = new JList();
mScroll = new JScrollPane();
mText = new JTextArea();
gScroll = new JScrollPane();
gList = new JList();
gAdd = new JButton();
cAdd = new JButton();
mEdit1 = new JButton();
cPane = new JPanel();
mLab2 = new JLabel();
sComp2 = new JTextField();
mScroll2 = new JScrollPane();
mText2 = new JTextArea();
cAdd2 = new JButton();
mEdit2 = new JButton();
prevComp = new JButton();
nextComp = new JButton();
//======== this ========
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
Container contentPane = getContentPane();
contentPane.setLayout(new GridLayout());
//======== menuBar1 ========
{
//======== mFile ========
{
mFile.setText("File");
//---- mF1 ----
mF1.setText("Open...");
mF1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mF1ActionPerformed(e);
}
});
mFile.add(mF1);
//---- mF2 ----
mF2.setText("Save As...");
mF2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mF2ActionPerformed(e);
}
});
mFile.add(mF2);
//---- mF3 ----
mF3.setText("Save");
mF3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mF3ActionPerformed(e);
}
});
mFile.add(mF3);
//---- mF4 ----
mF4.setText("Close");
mF4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mF4ActionPerformed(e);
}
});
mFile.add(mF4);
//---- mF5 ----
mF5.setText("Exit");
mF5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mF5ActionPerformed(e);
}
});
mFile.add(mF5);
}
menuBar1.add(mFile);
//======== mEdit ========
{
mEdit.setText("Edit");
//---- mE1 ----
mE1.setText("Edit Compound...");
mE1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mE1ActionPerformed(e);
}
});
mEdit.add(mE1);
}
menuBar1.add(mEdit);
//======== mView ========
{
mView.setText("View");
//---- mV1 ----
mV1.setText("Group View");
mV1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mV1ActionPerformed(e);
}
});
mView.add(mV1);
//---- mV2 ----
mV2.setText("Compound View");
mV2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mV2ActionPerformed(e);
}
});
mView.add(mV2);
}
menuBar1.add(mView);
//======== mComp ========
{
mComp.setText("Compound");
//---- mC1 ----
mC1.setText("Previous");
mC1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mC1ActionPerformed(e);
}
});
mComp.add(mC1);
//---- mC2 ----
mC2.setText("Next");
mC2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mC2ActionPerformed(e);
}
});
mComp.add(mC2);
}
menuBar1.add(mComp);
//======== mMsds ========
{
mMsds.setText("MSDS");
//---- mM1 ----
mM1.setText("Look up compound...");
mM1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mM1ActionPerformed(e);
}
});
mMsds.add(mM1);
//---- mM2 ----
mM2.setText("View Repository");
mM2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mM2ActionPerformed(e);
}
});
mMsds.add(mM2);
}
menuBar1.add(mMsds);
//======== mHelp ========
{
mHelp.setText("Help");
//---- mH1 ----
mH1.setText("Help");
mH1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mH1ActionPerformed(e);
}
});
mHelp.add(mH1);
//---- mH2 ----
mH2.setText("About...");
mH2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mH2ActionPerformed(e);
}
});
mHelp.add(mH2);
}
menuBar1.add(mHelp);
}
setJMenuBar(menuBar1);
//======== gPane ========
{
//======== panel4 ========
{
panel4.setLayout(new GridBagLayout());
((GridBagLayout) panel4.getLayout()).columnWidths = new int[]{41, 190, 6, 179, 0, 224, 153};
((GridBagLayout) panel4.getLayout()).rowHeights = new int[]{0, 0, 450, 0, 0};
((GridBagLayout) panel4.getLayout()).rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 1.0E-4};
//---- mLab1 ----
mLab1.setText("MSDS");
panel4.add(mLab1, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
panel4.add(sComp1, new GridBagConstraints(6, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 0), 0, 0));
//---- gLab1 ----
gLab1.setText("Group");
gLab1.setBackground(Color.white);
panel4.add(gLab1, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
//---- cLab1 ----
cLab1.setText("Compound");
cLab1.setBackground(Color.white);
panel4.add(cLab1, new GridBagConstraints(2, 1, 2, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
//======== gScroll ========
{
//---- gList ----
//sample data
setGroupList();
//set the list
gList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent event) {
if (!event.getValueIsAdjusting()) {//check if the value is adjusted
int size = xlsBook.get(gList.getSelectedIndex()).getBook().size();//get the size (number of coumpoud) of the selected Compoundbook int the xlsBook
String[] comps = new String[size];// array of commpounds set to the size (number of element) of the compoundBook
for (int i = 0; i < size; i++) {// this loop is addind coupound names in the array comps
comps[i] = xlsBook.get(gList.getSelectedIndex()).getBook().get(i).get(0).getContents();
}
String[] name = {"compoud name", "Manufacturer", "Catalog #", "Location", "Size", "Quantity", "Amount Remaining", "Date Received", "CAS #"};
mText2.setText(CompoundBook.displayRows(xlsBook.get(gList.getSelectedIndex()).getBook(), name));
//mText2.setText((xlsBook.get(gList.getSelectedIndex()).displayRows(xlsBook.get(gList.getSelectedIndex()).getBook())));
cList.setListData(comps);// setting the compound list in the gui
}
gListValueChanged(event);
}
});
gScroll.setViewportView(gList);
}
panel4.add(gScroll, new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
//======== cScroll ========
{
//---- cList ----
//final CompoundBook xlfile = new CompoundBook("/Users/bbuildman/Desktop/java/assignments/igpProject/src/AllCompounds.xls");
//String[] comps = new String[xlfile.getBook().size()];
cList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {// check if the value of the cList selection has been changed
String[] name = {"compoud name", "Manufacturer", "Catalog #", "Location", "Size", "Quantity", "Amount Remaining", "Date Received", "CAS #"};
if (!cList.isSelectionEmpty()) {// in the case that the user selects another group, to avoid cList to be empty
mText.setText(CompoundBook.displayRow(cList.getSelectedIndex(), xlsBook.get(gList.getSelectedIndex()).getBook(), name));
cListValueChanged(e);
} else {
mText.setText("");
}
}
}
});
cScroll.setViewportView(cList);
}
panel4.add(cScroll, new GridBagConstraints(2, 2, 2, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
//======== mScroll ========
{
mScroll.setViewportView(mText);
}
panel4.add(mScroll, new GridBagConstraints(4, 1, 3, 2, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 0), 0, 0));
//---- gAdd ---- adding a new group
gAdd.setText("+");
gAdd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// I used the dialog box to get input
String filename = JOptionPane.showInputDialog(null, "Create a new group : ", "Add a new coumpond", 1);
if (filename != null) {
JOptionPane.showMessageDialog(null, "You created the group : " + filename, "File created", 1);
//Create a new .xls file
File file = new File(filename + ".xls");
CompoundBook.initEmptySheet(filename+".xls", 9);
CompoundBook book = new CompoundBook(filename+".xls");
//add the new group our xlsBook (objec) and the group list
xlsBook.add(book);
groups.add(filename);
gList.setListData(groups);
/*
* To actually create a file specified by a
* pathname, use boolean createNewFile() method of
* Java File class.
*
* This method creates a new empty file specified if
* the file with same name does not exists.
*
* This method returns true if the file with the
* same name did not exist and it was created
* successfully, false otherwise.
*/
boolean blnCreated = false;
try {
blnCreated = file.createNewFile();
} catch (IOException ioe) {
System.out.println("Error while creating a new empty file :" + ioe);
}
if (blnCreated) {
JOptionPane.showMessageDialog(null, "You created the file: " + filename+".xls",
"Roseindia.net", 1);
}
/*
* If you run the same program 2 times, first time
* it should return true. But when we run it second
* time, it returns false because file was already
* exist.
*/
//System.out.println("Was file " + file.getPath() + " created ? : " + blnCreated);
}
gAddActionPerformed(e);
}
});
panel4.add(gAdd, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 5), 0, 0));
//---- cAdd ----
cAdd.setText("+");
cAdd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
cAddActionPerformed(e);
}
});
panel4.add(cAdd, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 5), 0, 0));
//---- mEdit1 ----
mEdit1.setText("Edit");
mEdit1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mE1ActionPerformed(e);
}
});
panel4.add(mEdit1, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 5), 0, 0));
}
gPane.addTab("Groups", panel4);
//======== cPane ========
{
cPane.setLayout(new GridBagLayout());
((GridBagLayout) cPane.getLayout()).columnWidths = new int[]{28, 29, 751, 70, 67};
((GridBagLayout) cPane.getLayout()).rowHeights = new int[]{0, 475, 0, 0};
((GridBagLayout) cPane.getLayout()).rowWeights = new double[]{0.0, 0.0, 0.0, 1.0E-4};
//---- mLab2 ----
mLab2.setText("MSDS");
cPane.add(mLab2, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
cPane.add(sComp2, new GridBagConstraints(3, 0, 2, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 0), 0, 0));
//======== mScroll2 ========
{
mScroll2.setViewportView(mText2);
}
cPane.add(mScroll2, new GridBagConstraints(0, 1, 5, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 0), 0, 0));
//---- cAdd2 ----
cAdd2.setText("+");
cAdd2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
cAddActionPerformed(e);
}
});
cPane.add(cAdd2, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 5), 0, 0));
//---- mEdit2 ----
mEdit2.setText("Edit");
mEdit2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mE1ActionPerformed(e);
}
});
cPane.add(mEdit2, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 5), 0, 0));
//---- prevComp ----
prevComp.setText("<");
prevComp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mC1ActionPerformed(e);
}
});
cPane.add(prevComp, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 5), 0, 0));
//---- nextComp ----
nextComp.setText(">");
nextComp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mC2ActionPerformed(e);
}
});
cPane.add(nextComp, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 0), 0, 0));
}
gPane.addTab("Compound", cPane);
}
contentPane.add(gPane);
pack();
setLocationRelativeTo(getOwner());
setVisible(true);
// JFormDesigner - End of component initialization //GEN-END:initComponents
} |
03f991ab-fe28-4747-a246-a761751fa4fa | 8 | public void merge(int[] A, int m, int[] B, int n) {
int countA = m - 1;
int countB = n - 1;
for(int i = n + m - 1; i >= 0; --i){
if(countA >= 0 && countB >= 0 && A[countA] > B[countB]){
A[i] = A[countA];
countA--;
continue;
}
if(countA >= 0 && countB >= 0 && A[countA] <= B[countB]){
A[i] = B[countB];
countB--;
continue;
}
}
//still have B
while(countB >= 0){
A[countB] = B[countB];
countB--;
}
} |
8f971665-d200-488e-8a09-ecd0471cdacc | 9 | public void onDeath(DamageSource par1DamageSource)
{
Entity var2 = par1DamageSource.getEntity();
if (this.scoreValue >= 0 && var2 != null)
{
var2.addToPlayerScore(this, this.scoreValue);
}
if (var2 != null)
{
var2.onKillEntity(this);
}
this.dead = true;
if (!this.worldObj.isRemote)
{
int var3 = 0;
if (var2 instanceof EntityPlayer)
{
var3 = EnchantmentHelper.getLootingModifier(((EntityPlayer)var2).inventory);
}
if (!this.isChild())
{
this.dropFewItems(this.recentlyHit > 0, var3);
if (this.recentlyHit > 0)
{
int var4 = this.rand.nextInt(200) - var3;
if (var4 < 5)
{
this.dropRareDrop(var4 <= 0 ? 1 : 0);
}
}
}
}
this.worldObj.setEntityState(this, (byte)3);
} |
8af59a62-cfd8-4a08-8879-56a3a5d2be20 | 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(TurneringsGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TurneringsGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TurneringsGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TurneringsGUI.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 TurneringsGUI().setVisible(true);
}
});
} |
22c7f1ac-c301-46df-94c5-7af295502a3c | 6 | private void generateRoom()
{
int regionHeight = y2 - y1 - 2;
int regionWidth = x2 - x1 - 2;
// Muodostetaan huoneen mitat siten, että mitat ovat vähintään ROOM_MIN_SIZE tai satunnaisesti niin isot kuin mahtuu
int roomWidth = (regionWidth == ROOM_MIN_SIZE) ? ROOM_MIN_SIZE : Main.rand.nextInt(regionWidth - ROOM_MIN_SIZE) + ROOM_MIN_SIZE;
int roomHeight = (regionHeight == ROOM_MIN_SIZE) ? ROOM_MIN_SIZE : Main.rand.nextInt(regionHeight - ROOM_MIN_SIZE) + ROOM_MIN_SIZE;
// Varmistetaan, että tuleva huone ei ole liian pieni verrattuna alueeseen, jossa se sijaitsee
roomWidth = ((float)roomWidth / regionWidth >= ROOM_REGION_MIN_RATIO) ? roomWidth : Math.round(regionWidth * ROOM_REGION_MIN_RATIO);
roomHeight = ((float)roomHeight / regionHeight >= ROOM_REGION_MIN_RATIO) ? roomHeight : Math.round(regionHeight * ROOM_REGION_MIN_RATIO);
// Jos huone ei ole niin iso, että täyttäisi koko alueen, voidaan siirtää huoneen sijaintia satunnaisesti alueen rajojen sisällä
int roomXOffset = (roomWidth == regionWidth) ? 0 : Main.rand.nextInt(regionWidth - roomWidth);
int roomYOffset = (roomHeight == regionHeight) ? 0 : Main.rand.nextInt(regionHeight - roomHeight);
// Luodaan huone siten, että se ei ole koskaan alueen reunoilla(eli huoneiden välillä aina vähintään yksi seinä)
room = new MapRegion(x1 + 1 + roomXOffset, x1 + roomXOffset + roomWidth, y1 + 1 + roomYOffset, y1 + roomYOffset + roomHeight);
} |
e83b4cae-58d6-4cd5-b8d5-e0f57dd78279 | 6 | public void run() {
Process p = null;
try {
if(game.GetOS.isWindows())
p = Runtime.getRuntime().exec("XboxControllerInputConsole.exe");
if(game.GetOS.isUnix() || game.GetOS.isMac())
p = Runtime.getRuntime().exec("./xboxdrv.sh");
} catch (IOException e) {
System.err.println("Couldn't start Xbox Controller Drivers");
e.printStackTrace();
}
input =new BufferedReader(new InputStreamReader(p.getInputStream()));
try {
while ((line = input.readLine()) != null)
{
tokenizer = new StringTokenizer(line, ",");
button_string = tokenizer.nextToken();
leftStick_string = tokenizer.nextToken();
rightStick_string = tokenizer.nextToken();
leftTrigger_string = tokenizer.nextToken();
rightTrigger_string = tokenizer.nextToken();
update(true);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} |
34e7bcc6-9249-4340-8360-2ea68bd0f0cc | 1 | public void setMinBill(double minBill) {
if(minBill < 0) {
throw new IllegalArgumentException(
"error: bill minimum must be greater than or equal to zero");
}
this.minBill = minBill;
} |
28d316c5-8198-42c7-8e5b-b1678fb85160 | 7 | private void addTextContent(Element parent, TextObject textObj) /*throws XMLStreamException*/ {
if ( (textObj.getText() == null || textObj.getText().isEmpty())
&& (textObj.getPlainText() == null || textObj.getPlainText().isEmpty()))
return;
Element textEquiv = doc.createElementNS(getNamespace(), DefaultXmlNames.ELEMENT_TextEquiv);
parent.appendChild(textEquiv);
//OCR Confidence
Double confidence = textObj.getConfidence();
if (confidence != null) {
DoubleValue dv = new DoubleValue(confidence);
addAttribute(textEquiv, DefaultXmlNames.ATTR_conf, dv.toString());
}
//Plain text
if (textObj.getPlainText() != null && !textObj.getPlainText().isEmpty())
addTextElement(textEquiv, DefaultXmlNames.ELEMENT_PlainText, textObj.getPlainText());
//Unicode text
addTextElement(textEquiv, DefaultXmlNames.ELEMENT_Unicode, textObj.getText());
} |
dcabcf56-17a2-41da-a2db-1c4f7e6c97d7 | 6 | private void sortForward(int par1)
{
PathPoint var2 = this.pathPoints[par1];
float var3 = var2.distanceToTarget;
while (true)
{
int var4 = 1 + (par1 << 1);
int var5 = var4 + 1;
if (var4 >= this.count)
{
break;
}
PathPoint var6 = this.pathPoints[var4];
float var7 = var6.distanceToTarget;
PathPoint var8;
float var9;
if (var5 >= this.count)
{
var8 = null;
var9 = Float.POSITIVE_INFINITY;
}
else
{
var8 = this.pathPoints[var5];
var9 = var8.distanceToTarget;
}
if (var7 < var9)
{
if (var7 >= var3)
{
break;
}
this.pathPoints[par1] = var6;
var6.index = par1;
par1 = var4;
}
else
{
if (var9 >= var3)
{
break;
}
this.pathPoints[par1] = var8;
var8.index = par1;
par1 = var5;
}
}
this.pathPoints[par1] = var2;
var2.index = par1;
} |
34ec36dc-9e64-406b-b43e-5ca8c7ac4f3c | 5 | protected void doMove(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Map<String, Action> actions = getActions();
if (request.getParameter("action") != null){
if(actions.containsKey(request.getParameter("action"))){
if (actions.get(request.getParameter("action")).beforeAction(request, response))
actions.get(request.getParameter("action")).doAction(request, response);
}else{
doError(request, response, new WebError(404, "aradığınız sayfaya ulaşılamıyor lütfen daha sonra tekrar deneyin"));
}
}else{
if(actions.containsKey(DEFAULT)){
if (actions.get(DEFAULT).beforeAction(request, response))
actions.get("default").doAction(request, response);
}else{
doError(request, response, new WebError(404, "aradığınız sayfaya ulaşılamıyor lütfen daha sonra tekrar deneyin"));
}
}
} |
9d9b1883-7d6e-47d2-bec1-43f6ebfef84e | 4 | public boolean simulateInput(String input) {
/** clear the configurations to begin new simulation. */
myConfigurations.clear();
Configuration[] initialConfigs = getInitialConfigurations(input);
for (int k = 0; k < initialConfigs.length; k++) {
FSAConfiguration initialConfiguration = (FSAConfiguration) initialConfigs[k];
myConfigurations.add(initialConfiguration);
}
while (!myConfigurations.isEmpty()) {
if (isAccepted())
return true;
ArrayList configurationsToAdd = new ArrayList();
Iterator it = myConfigurations.iterator();
while (it.hasNext()) {
FSAConfiguration configuration = (FSAConfiguration) it.next();
ArrayList configsToAdd = stepConfiguration(configuration);
configurationsToAdd.addAll(configsToAdd);
/**
* Remove configuration since just stepped from that
* configuration to all reachable configurations.
*/
it.remove();
}
myConfigurations.addAll(configurationsToAdd);
}
return false;
} |
edd67bbb-189e-4fcd-958f-905f096fd8f9 | 3 | @SuppressWarnings("deprecation")
public static boolean UserInputs() {
user = new JTextField(15);
pass = new JPasswordField(15);
JPanel myPanel = new JPanel();
myPanel.add(new JLabel("Username:"));
myPanel.add(user);
myPanel.add(Box.createHorizontalStrut(15)); // a spacer
myPanel.add(new JLabel("Password:"));
myPanel.add(pass);
int result = JOptionPane.showConfirmDialog(null, myPanel,
"Restricted Access: credential verification", JOptionPane.OK_CANCEL_OPTION);
if (result == JOptionPane.OK_OPTION && !user.getText().equals("")&&pass.getText()!=null) {
return true;
}else
return false;
} |
0df44683-0f23-4290-89c6-0b7d2ee18451 | 1 | @Override
protected Budget createBudget(String budget_choice) throws Exception {
validateBudgetChoice(budget_choice);
return (budget_choice.equals(ANNUAL_BUDGET)) ?
new AnnualBudget("Annual budget", new BigDecimal(BigInteger.ZERO), new Date()) :
new MonthlyBudget("Monthly budget", new BigDecimal(BigInteger.ZERO), new Date());
} |
a19fb452-f1a5-4800-a408-a63077be5ea9 | 5 | public static String[][] translator(String textmap) {
int xSize;
int ySize;
String[][] stringMapArray = null;
//first we need to check that the map is legitimate by calling mapchecker.
if (mapchecker(textmap)) {
try {
//Initiate a buffered reader to read form the file
BufferedReader reader = new BufferedReader(new FileReader(
textmap));
//takes the size of the map from the first two lines the first line being the xsize and the second line being the ysize. also removing spaces
xSize = Integer.parseInt(reader.readLine().replaceAll("\\s",""));
ySize = Integer.parseInt(reader.readLine().replaceAll("\\s",""));
// now we know the size of the map we can set up the 2d array of strings.
stringMapArray = new String[xSize][ySize];
// the following for loop finds reads each line and adds each character as to the array
for (int y = 0; y < (ySize); y++) {
String lineinput = reader.readLine().replaceAll("\\s","");
for (int x = 0; x < (xSize); x++) {
stringMapArray[x][y] = String.valueOf(lineinput
.charAt(x));
}
}
//closes the reader
reader.close();
}
catch (FileNotFoundException e) {
System.err.println("unable to open");
} catch (IOException e) {
System.err.println("a problem was encountered reading");
}
}
//if the checker does not accept the map then it prints "map not acceptable".
else {
System.err.println("Map not accectable");
}
return stringMapArray;
} |
b9954591-508b-4a38-ab98-f552e7d37069 | 0 | public PhpposItemsEntity getItemPos(int idItemPos){
return (PhpposItemsEntity) getHibernateTemplate().get(PhpposItemsEntity.class, idItemPos);
} |
3dac1481-5663-47c6-9052-abc973d9410b | 5 | public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(genPoints)) {
int w = graphPanel.getWidth();
int h = graphPanel.getHeight();
pRadius = Utils.scaledPointSize(numPoints, w, h);
myGraph.reset();
resetPath();
myGraph.addNodes(Utils.genPoints(numPoints, w, h), w, h);
repaint();
}
else if (e.getSource().equals(genMstSlow)) {
myGraph.genMSTSlow();
repaint();
}
else if (e.getSource().equals(genMstFast)) {
myGraph.genMSTFast();
repaint();
}
else if (e.getSource().equals(pointsField)) {
String new_points = pointsField.getText();
try {
int num = Integer.parseInt(new_points);
genPoints.setText("Generate " + num + " random nodes");
numPoints = num;
} catch (Exception exc) {
System.out.println("Please enter a positive integer!");
}
}
} |
43015011-4999-4246-9a58-9e9c01227045 | 6 | private final void method2849(int i, int i_39_, byte i_40_, int i_41_) {
anInt8941++;
Class348_Sub43 class348_sub43
= aClass348_Sub43ArrayArray8928[i_41_][i_39_];
if (class348_sub43 != null) {
int i_42_ = -123 % ((i_40_ - 24) / 42);
aClass348_Sub43ArrayArray8928[i_41_][i_39_] = null;
if ((((Class348_Sub16_Sub3) this).anIntArray8895[i_41_] & 0x2
^ 0xffffffff)
!= -1) {
for (Class348_Sub43 class348_sub43_43_
= ((Class348_Sub43)
((Class348_Sub16_Sub1) aClass348_Sub16_Sub1_8958)
.aClass262_8848.getFirst(4));
class348_sub43_43_ != null;
class348_sub43_43_
= ((Class348_Sub43)
((Class348_Sub16_Sub1) aClass348_Sub16_Sub1_8958)
.aClass262_8848.nextForward((byte) 36))) {
if ((((Class348_Sub43) class348_sub43_43_).anInt7067
== ((Class348_Sub43) class348_sub43).anInt7067)
&& (((Class348_Sub43) class348_sub43_43_).anInt7087
^ 0xffffffff) > -1
&& class348_sub43 != class348_sub43_43_) {
((Class348_Sub43) class348_sub43).anInt7087 = 0;
break;
}
}
} else
((Class348_Sub43) class348_sub43).anInt7087 = 0;
}
} |
7c441542-9b58-4e7e-b653-159ce1e08304 | 0 | public void setSucc(DoublyLinkedNode succ) {
this.succ = succ;
} |
b2fc428c-d02d-4a54-954e-1eac511b190f | 6 | public int next_note( int data_offset, int[] note ) {
int bitmask, field;
if( data_offset < 0 ) {
data_offset = pattern_data.length;
}
bitmask = 0x80;
if( data_offset < pattern_data.length ) {
bitmask = pattern_data[ data_offset ] & 0xFF;
}
if( ( bitmask & 0x80 ) == 0x80 ) {
data_offset += 1;
} else {
bitmask = 0x1F;
}
for( field = 0; field < 5; field++ ) {
note[ field ] = 0;
if( ( bitmask & 0x01 ) == 0x01 ) {
if( data_offset < pattern_data.length ) {
note[ field ] = pattern_data[ data_offset ] & 0xFF;
data_offset += 1;
}
}
bitmask = bitmask >> 1;
}
return data_offset;
} |
cefa43cb-2134-469f-8295-67562fc62655 | 7 | public void reconnectRejectPart() {
for (Transition t : rejectPartBridges) {
boolean add = false;
if (t.getType() == Derive.class) {
if (items.contains(t.source)) {
add = true;
t.source.derives.add(t);
}
} else { // t is a Reduce
if (items.contains(t.target)) {
add = true;
t.source.reduces.add(t);
for (Transition s : t.shifts) {
if (!s.source.shifts.contains(s)) {
s.source.shifts.add(s);
}
}
}
}
if (add) {
transitions.add(t);
}
}
items.addAll(rejectPartItems);
transitions.addAll(rejectPartTransitions);
optimize(true); // some items might not be reachable anymore
} |
5e87c625-d11b-4900-925f-a4afabc0b30b | 9 | protected boolean balancedJSToken() {
Deque<Character> stack = new ArrayDeque<Character>();
while (true) {
int c = input.read();
if (stack.isEmpty() && c == '`') {
return true;
}
if (!stack.isEmpty() && stack.element() == c) {
stack.poll();
} else if (c == '"' || c == '\'') {
stack.push((char) c);
} else if (c == '\\') {
c = input.read();
} else if (c == CoffeeScriptLexerInput.EOF) {
return false;
}
}
} |
01e6e76f-a413-456d-8f3c-9768fb292469 | 7 | int pack_books(Buffer opb){
opb.write(0x05, 8);
opb.write(_vorbis);
// books
opb.write(books-1, 8);
for(int i=0; i<books; i++){
if(book_param[i].pack(opb)!=0){
//goto err_out;
return (-1);
}
}
// times
opb.write(times-1, 6);
for(int i=0; i<times; i++){
opb.write(time_type[i], 16);
FuncTime.time_P[time_type[i]].pack(this.time_param[i], opb);
}
// floors
opb.write(floors-1, 6);
for(int i=0; i<floors; i++){
opb.write(floor_type[i], 16);
FuncFloor.floor_P[floor_type[i]].pack(floor_param[i], opb);
}
// residues
opb.write(residues-1, 6);
for(int i=0; i<residues; i++){
opb.write(residue_type[i], 16);
FuncResidue.residue_P[residue_type[i]].pack(residue_param[i], opb);
}
// maps
opb.write(maps-1, 6);
for(int i=0; i<maps; i++){
opb.write(map_type[i], 16);
FuncMapping.mapping_P[map_type[i]].pack(this, map_param[i], opb);
}
// modes
opb.write(modes-1, 6);
for(int i=0; i<modes; i++){
opb.write(mode_param[i].blockflag, 1);
opb.write(mode_param[i].windowtype, 16);
opb.write(mode_param[i].transformtype, 16);
opb.write(mode_param[i].mapping, 8);
}
opb.write(1, 1);
return (0);
} |
836cf9f3-4d40-412d-bd56-d27e23aa00b3 | 0 | @After
public void tearDown() {
} |
24a1d8de-fff8-4163-8499-142dca3817f2 | 0 | public void setNumUndo(int nn){
numUndo = nn;
} |
be658b87-b0cf-4085-b82d-4d00f3026061 | 9 | public String longestCommonPrefix(String[] strs) {
int n = strs.length;
if(n==0){
return "";
}
if(n==1){
return strs[0];
}
if(strs[0] == ""){
return "";
}
int i;
for (i = 0;i<strs[0].length();i++){
for (int j = 1;j<n;j++){
if(strs[j]==""){
return "";
}
if(i>=strs[j].length()){
return strs[0].substring(0,i);
}
if (strs[j].charAt(i)!=strs[0].charAt(i)){
if (i==0)
return "";
return strs[0].substring(0,i);
}
}
}
return strs[0].substring(0,i);
} |
e34fbf88-ea15-4209-95c4-4a384129e83e | 0 | public Context(State state) {
this.state = state;
} |
12e784f1-cf83-4762-bc54-6403884c5fc8 | 7 | private Tuple<Float, HeuristicData> max(LongBoard state, HeuristicData data, float alpha,
float beta, int action, int depth) {
Winner win = gameFinished(state);
statesChecked++;
Tuple<Float, HeuristicData> y = new Tuple<>((float) Integer.MIN_VALUE, null);
Float cached = cacheGet(state);
if (null != cached) {
return new Tuple<>(cached,null);
}
if(win != Winner.NOT_FINISHED) {
float value = utility(win, depth);
cache(state, value);
return new Tuple<>(value, null);
}
if (depth == 0) {
hasReachedMaxDepth = true;
HeuristicData newData = H.moveHeuristic(data, action, opponentID);
Tuple<Float, HeuristicData> value = h(state, newData);
cache(state, value._1);
return value;
}
for (int newaction : generateActions(state)) {
// Stop if time's up
if (isTimeUp()) break;
HeuristicData newData = H.moveHeuristic(data, newaction, opponentID);
Tuple<Float, HeuristicData> min = min(result(state, newaction), newData, alpha, beta,newaction, depth - 1);
if (min._1 > y._1) {
y = min;
}
// tests for possible beta cut
if (y._1 >= beta) {
cutoffs++;
cache(state, y._1);
return y;
}
alpha = Math.max(alpha, y._1);
}
cache(state, y._1);
return y;
} |
8d4a1989-2f08-49c7-bd30-fc69cf386bfd | 0 | public void harvest(int quantity, Villager villager)
{
resources -= quantity;
villager.getProffession().setRsrceQuantity(villager.getProffession().getRsrceQuantity() + quantity);
} |
87c9abbc-e68b-4445-be77-0dc740059e67 | 5 | public void reduceAP(MapleClient c, byte stat, short amount) {
MapleCharacter player = c.getPlayer();
switch (stat) {
case 1: // STR
player.getStat().setStr(player.getStat().getStr() - amount);
player.updateSingleStat(MapleStat.STR, player.getStat().getStr());
break;
case 2: // DEX
player.getStat().setDex(player.getStat().getDex() - amount);
player.updateSingleStat(MapleStat.DEX, player.getStat().getDex());
break;
case 3: // INT
player.getStat().setInt(player.getStat().getInt() - amount);
player.updateSingleStat(MapleStat.INT, player.getStat().getInt());
break;
case 4: // LUK
player.getStat().setLuk(player.getStat().getLuk() - amount);
player.updateSingleStat(MapleStat.LUK, player.getStat().getLuk());
break;
case 5:
player.setStorageAp(player.getStorageAp() - amount);
break;
}
player.setRemainingAp(player.getRemainingAp() + amount);
player.updateSingleStat(MapleStat.AVAILABLEAP, player.getRemainingAp());
} |
43e73baa-1de0-4da5-95fb-9a705f425c8a | 5 | public static void main(String[] args)
{
//Symmetric case
sc = new Scanner(System.in);
System.out.println("enter the number of Channels");
m = sc.nextInt();
System.out.println("m is " + m + " and 2m-1 is " + (2 * m - 1));
// forming array with channels starting from 1 to c
arr = new int[2 * m - 1];
for (int i = 0; i < arr.length; i++)
{
if (i < m)
{
arr[i] = i + 1;
} else
{
arr[i] = arr[2 * (m - 1) - i];
}
}
System.out.println("Displaying");
disp();
System.out.println("Enter the shift!!!");
k = sc.nextInt();
boolean ren = false;
int i1 = 0;
int i2=0;
int time=0;
System.out.println("Started\n\n");
while(!ren)
{
time++;
i1++;
int res1=arr[(i1 - 1) % (2 * m - 1)];
System.out.print(res1);
if (i1 > k)
{
int round_no=i2/(2*m-1);
int res2=arr[round_no%m];
System.out.println(" User2 is at " + res2);
if(res1==res2){
ren=true;
System.out.println("Got rendezvous!!!! at time= "+time+"\nExited!!");
System.exit(0);
}
i2 ++;
} else
{
System.out.println(" other has not started!!!");
}
}
} |
213814d9-4613-4f83-838d-115e07ab1032 | 2 | public static void readAppletParams(java.applet.Applet applet) {
VoidParameter current = head;
while (current != null) {
String str = applet.getParameter(current.getName());
if (str != null)
current.setParam(str);
current = current.next;
}
} |
4bb7d3c7-d213-4a77-bdd7-2ecca183d341 | 0 | @Override
public void addNews(News news) {
allNews.add(news);
updateAll();
} |
fe3138dd-9a3d-495c-82eb-444fddb2bcf4 | 4 | private int getAdjacentTracks() {
int var1 = 0;
if (this.isMinecartTrack(this.trackX, this.trackY, this.trackZ - 1)) {
++var1;
}
if (this.isMinecartTrack(this.trackX, this.trackY, this.trackZ + 1)) {
++var1;
}
if (this.isMinecartTrack(this.trackX - 1, this.trackY, this.trackZ)) {
++var1;
}
if (this.isMinecartTrack(this.trackX + 1, this.trackY, this.trackZ)) {
++var1;
}
return var1;
} |
79cc8278-5128-4d4e-96b7-00db0367030d | 2 | public boolean equals(Object toCompare)
{
if(toCompare instanceof Quantity)
{
if(this.toString().equals(toCompare.toString()))
return true;
}
return false;
} |
99125536-a7fd-4fc5-94a2-20b9f498fc7c | 4 | @Override
public Object[] getData()
{
if (ptr != 0) {
return null;
} else {
if (isConstant()) {
if (length > getMaxSizeOf32bitArray()) return null;
Object[] out = new Object[(int) length];
for (int i = 0; i < length; i++) {
out[i] = data[0];
}
return out;
} else {
return data;
}
}
} |
effef3d3-531e-4358-b8e4-2e5b7dc159b0 | 4 | public static <T> ArrayList<T> array_values(Map<?, T> m) {
// OK
ArrayList<T> output = new ArrayList<T>();
if (m == null) return output;
int i = 0;
synchronized(m) {
for (Map.Entry<?,T> entry : m.entrySet()) {
T value = entry.getValue();
output.add(i,value);
i++;
}
}
return output;
} |
8264430c-bca6-4c71-bccd-d73ffe3cd2e7 | 4 | private void CreateKeyButtons(Keyboard keyboard) {
KeysPanel.removeAll();
KeysPanel.setLayout(new FlowLayout());
if (!keyboard.getMapOfKeys().isEmpty()) {
for (char key : keyboard.getMapOfKeys().keySet()) {
// "" + key
final JToggleButton keyButton = new javax.swing.JToggleButton();
keyButton.setText(key + "");
// int[] RGB = selectColourForButton(keyboard, key);
// Color color = new Color(RGB[0], RGB[1], RGB[2]);
Color color = selectColourForButton(keyboard, key);
if (color.getBlue() > 1 && color.getGreen() == 1) {
keyButton.setForeground(Color.WHITE);
}
keyButton.setBackground(color);
keyButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
OneOfTheKeyButtonsPressed(evt, keyButton.isSelected());
}
});
KeysPanel.add(keyButton);
KeysPanel.validate();
}
}
KeysPanel.repaint();
} |
67db0354-c9d4-407c-8e14-fba50c1bdd18 | 2 | public void send(String groupName, Message message) {
message.setSeqNum(this.groupSpg.get(groupName));
this.groupRpg.groups.get(groupName).put(this.localHostName, this.groupSpg.get(groupName));
this.groupSpg.put(groupName, this.groupSpg.get(groupName) + 1);
//this.messagePasser.getTimeStamp().addClock();
// update local group vector clock
this.groupRpg.getClockGroup().get(groupName).addClock();
// get local group vector clock's copy
Clock clockForThisGroup = this.groupRpg.getClockGroup().get(groupName).deepCopy();
for(String mem : this.groupRpg.groups.get(groupName).keySet()){
if(!mem.equals(this.localHostName)){
message.setDest(mem);
MulticastMessage multicastMsg = new MulticastMessage(message, groupName, this.messagePasser.getTimeStamp(),
new Hashtable<String, Integer>(this.groupRpg.groups.get(groupName)),
clockForThisGroup);
this.sentQueue.get(groupName).put(multicastMsg.getSeqNum(), multicastMsg);
this.messagePasser.send(multicastMsg);
}
}
} |
c10c34d5-9029-47d5-86a1-81bceb46a543 | 9 | public Model method209(int arg0, int arg1, boolean flag) {
Model model;
if (flag) {
model = getModel(anInt255, anInt256);
} else {
model = getModel(anInt233, mediaId);
}
if (model == null) {
return null;
}
if (arg1 == -1 && arg0 == -1 && model.triangleColors == null) {
return model;
}
Model transformedModel = new Model(true, Animation.isNullFrame(arg1)
& Animation.isNullFrame(arg0), false, model);
if (arg1 != -1 || arg0 != -1) {
transformedModel.skin();
}
if (arg1 != -1) {
transformedModel.transform(arg1);
}
if (arg0 != -1) {
transformedModel.transform(arg0);
}
transformedModel.processLighting(64, 768, -50, -10, -50, true);
return transformedModel;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.