method_id
stringlengths 36
36
| cyclomatic_complexity
int32 0
9
| method_text
stringlengths 14
410k
|
|---|---|---|
b690f015-fe11-4bfb-8dee-812457af7b65
| 8
|
private void pivot(int p, int q) {
// everything but row p and column q
for (int i = 0; i <= M; i++)
for (int j = 0; j <= M + N; j++)
if (i != p && j != q) a[i][j] -= a[p][j] * a[i][q] / a[p][q];
// zero out column q
for (int i = 0; i <= M; i++)
if (i != p) a[i][q] = 0.0;
// scale row p
for (int j = 0; j <= M + N; j++)
if (j != q) a[p][j] /= a[p][q];
a[p][q] = 1.0;
}
|
2628e7fc-1195-4f67-95d2-61c8b836b4c1
| 4
|
public final void update(double dt) {
if (!isTerminated()) {
elapsedTime += dt;
doUpdate(dt);
if (cancelled) {
afterExecutionCancelled();
} else if (isTerminated()) {
afterExecutionCompleted();
getScreen().updateSprites();
if (getFacade().isGameFinished(getWorld())) {
getScreen().gameFinished();
}
}
}
}
|
46ca69f7-9c09-4a73-8bd8-7e874a4e6790
| 1
|
public InputStream getInputStream(String zipPath) throws IOException
{
Path path = fileSystem.getPath(zipPath);
if(Files.exists(path))
{
return Files.newInputStream(path);
}
return null;
}
|
a68b68a9-24a5-472b-8d98-2d4c49f2f8f1
| 7
|
static final void method1885(int i, int i_0_, int i_1_, int i_2_, int i_3_,
float[] fs, int i_4_, float f, int i_5_,
int i_6_, float f_7_, float[] fs_8_) {
try {
i_4_ -= i_5_;
i_0_ -= i;
anInt3175++;
i_3_ -= i_6_;
float f_9_ = fs_8_[2] * (float) i_0_ + (fs_8_[1] * (float) i_4_
+ (float) i_3_ * fs_8_[0]);
float f_10_
= (fs_8_[5] * (float) i_0_
+ (fs_8_[3] * (float) i_3_ + (float) i_4_ * fs_8_[4]));
float f_11_ = ((float) i_3_ * fs_8_[6] + fs_8_[7] * (float) i_4_
+ (float) i_0_ * fs_8_[i_2_]);
float f_12_
= 0.5F + ((float) Math.atan2((double) f_9_, (double) f_11_)
/ 6.2831855F);
if (f_7_ != 1.0F)
f_12_ *= f_7_;
float f_13_ = 0.5F + f_10_ + f;
if (i_1_ == 1) {
float f_14_ = f_12_;
f_12_ = -f_13_;
f_13_ = f_14_;
} else if (i_1_ != 2) {
if ((i_1_ ^ 0xffffffff) == -4) {
float f_15_ = f_12_;
f_12_ = f_13_;
f_13_ = -f_15_;
}
} else {
f_12_ = -f_12_;
f_13_ = -f_13_;
}
fs[1] = f_13_;
fs[0] = f_12_;
} catch (RuntimeException runtimeexception) {
throw Class348_Sub17.method2929(runtimeexception,
("ca.D(" + i + ',' + i_0_ + ','
+ i_1_ + ',' + i_2_ + ',' + i_3_
+ ','
+ (fs != null ? "{...}" : "null")
+ ',' + i_4_ + ',' + f + ','
+ i_5_ + ',' + i_6_ + ',' + f_7_
+ ','
+ (fs_8_ != null ? "{...}"
: "null")
+ ')'));
}
}
|
cda0fd7b-c3df-4a9f-9378-e14ff78e161d
| 9
|
public static String convert(String fromType, String toType, String num) {
String result = "Error";
int number = 0;
try {
switch (fromType) {
case "-h": // Hexadecimal
number = Integer.parseInt(num, 16);
break;
case "-d": // Decimal
number = Integer.parseInt(num);
break;
case "-o": // Octary
number = Integer.parseInt(num, 8);
break;
case "-b": // Binary
number = Integer.parseInt(num, 2);
break;
}
} catch (NumberFormatException nfe) {
return result;
}
switch (toType) {
case "-h": // Hexadecimal
result = Integer.toHexString(number);
break;
case "-d": // Decimal
result = Integer.toString(number);
break;
case "-o": // Octary
result = Integer.toOctalString(number);
break;
case "-b": // Binary
result = Integer.toBinaryString(number);
break;
}
return result.toUpperCase();
}
|
20438de9-05fe-488d-bc7c-80ea66016039
| 1
|
public OrderByIterator(Iterable<T> source, Comparator<T> comparator)
{
_list = new ArrayList<T>();
for(T item : source)
{
_list.add(item);
}
this._comparer = comparator;
}
|
00f64b29-9186-4244-a703-5566ffe668fc
| 5
|
private void processQueues() throws SectionMapException {
KeyWeakReference ref;
while ((ref = (KeyWeakReference) refQueue.poll()) != null) {
hashMap.remove(ref.getKey());
}
long expiredTime = System.currentTimeMillis() - 30000;
SectionLink link;
while ((link = sectionQueue.peekFirst()) != null && link.getTimestamp() < expiredTime) {
link = sectionQueue.pollFirst();
if (activeSections.containsKey(link.getId())) {
throw new SectionMapTimeoutException("Section " + link.getId() + " was not acknowledged after 30 seconds");
}
}
if (activeSections.size() > 4096) {
throw new SectionMapSizeException("Section map exceeded maximum size " + activeSections.size());
}
}
|
102ac130-39c1-4c06-a4a2-0cf0be83d7ce
| 2
|
public void Action(String destination, String message, boolean autothrow) throws Exception
{
final char actionchar = 0x01;
try
{
Writer.write("PRIVMSG " + destination + " :ACTION" + actionchar + " " + message + " " + actionchar + "\r\n");
Writer.flush();
}
catch(Exception e)
{
if(autothrow) throw e;
Utils.LogException(e, "Sending IRC message");
}
}
|
b5ec5806-94ed-4841-9e30-37b7c221c6ea
| 2
|
public static String fromJulian( long Jd ) // Julian date to string
{
long l = Jd + 68569;
long n = ( 4 * l ) / 146097;
l = l - ( 146097 * n + 3 ) / 4;
long i = ( 4000 * ( l + 1 ) ) / 1461001;
l = l - ( 1461 * i ) / 4 + 31;
long j = ( 80 * l ) / 2447;
int d = (int) (l - ( 2447 * j ) / 80);
l = j / 11;
int m = (int) (j + 2 - ( 12 * l ));
int y = (int) (100 * ( n - 49 ) + i + l);
return String.valueOf(y) +
(m<10 ? "0" : "") + String.valueOf(m) +
(d<10 ? "0" : "") + String.valueOf(d);
}
|
1f720610-2525-4f85-8a92-dd85adb7bf13
| 3
|
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final TSalesman other = (TSalesman) obj;
if (!Objects.equals(this.salesIdScy, other.salesIdScy)) {
return false;
}
return true;
}
|
f1325840-9ffd-49df-abd7-18fe9cb9ccd0
| 9
|
public ChatServer () throws IOException {
server = new Server() {
protected Connection newConnection () {
// By providing our own connection implementation, we can store per
// connection state without a connection ID to state look up.
return new ChatConnection();
}
};
// For consistency, the classes to be sent over the network are
// registered by the same method for both the client and server.
Network.register(server);
server.addListener(new Listener() {
public void received (Connection c, Object object) {
// We know all connections for this server are actually ChatConnections.
ChatConnection connection = (ChatConnection)c;
if (object instanceof RegisterName) {
// Ignore the object if a client has already registered a name. This is
// impossible with our client, but a hacker could send messages at any time.
if (connection.name != null) return;
// Ignore the object if the name is invalid.
String name = ((RegisterName)object).name;
if (name == null) return;
name = name.trim();
if (name.length() == 0) return;
// Store the name on the connection.
connection.name = name;
// Send a "connected" message to everyone except the new client.
ChatMessage chatMessage = new ChatMessage();
chatMessage.text = name + " connected.";
server.sendToAllExceptTCP(connection.getID(), chatMessage);
// Send everyone a new list of connection names.
updateNames();
return;
}
if (object instanceof ChatMessage) {
// Ignore the object if a client tries to chat before registering a name.
if (connection.name == null) return;
ChatMessage chatMessage = (ChatMessage)object;
// Ignore the object if the chat message is invalid.
String message = chatMessage.text;
if (message == null) return;
message = message.trim();
if (message.length() == 0) return;
// Prepend the connection's name and send to everyone.
chatMessage.text = connection.name + ": " + message;
server.sendToAllTCP(chatMessage);
return;
}
}
public void disconnected (Connection c) {
ChatConnection connection = (ChatConnection)c;
if (connection.name != null) {
// Announce to everyone that someone (with a registered name) has left.
ChatMessage chatMessage = new ChatMessage();
chatMessage.text = connection.name + " disconnected.";
server.sendToAllTCP(chatMessage);
updateNames();
}
}
});
server.bind(Network.port);
server.start();
// Open a window to provide an easy way to stop the server.
JFrame frame = new JFrame("Chat Server");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.addWindowListener(new WindowAdapter() {
public void windowClosed (WindowEvent evt) {
server.stop();
}
});
frame.getContentPane().add(new JLabel("Close to stop the chat server."));
frame.setSize(320, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
|
cb426a0c-1f9e-4ce8-b799-1a46edb72c6c
| 1
|
public void onEnable()
{
/* -------------- VARIABLE INITIALIZATION -------------- */
plugin = this;
/* -------------------- LISENERS ----------------------- */
signlisener = new SignLisener(this, log);
/* ------------------- PERMISSIONS --------------------- */
if(this.getServer().getPluginManager().getPlugin("Vault") != null) setupPermissions();
/* ------------------ CONFIGURATION -------------------- */
Config.loadConfig(this);
/* -------------------- COMMANDS ----------------------- */
getCommand("signurls").setExecutor(new MainCommand());
/* -------------------- DATABASE ----------------------- */
log.info("[SignURLs] attempting to open SQLite database.");
db = new SQLite(this.getDataFolder().getPath(), "links");
log.info("[SignURLs] attempting to load links from SQLite database.");
loadlinkDB();
CustomFunction.addLink("Author Site", "http://www.willhastings.net", true);
log.info("[SignURLs] " + this.getDescription().getVersion() + " Has been Loaded!");
}
|
4c61076b-92ad-4b8d-98f3-625b9ea06845
| 2
|
private void stepForward() {
// TODO Auto-generated method stub
treePanel.setAnswer(myCurrentAnswerNode);
treePanel.repaint();
if (myCurrentAnswerNode.getDerivation().equals(myTarget))
{
myStepAction.setEnabled(false);
return;
}
ParseNode node=(ParseNode) myQueue.removeFirst();
String deriv=node.getDerivation();
/* System.out.println("DERIV => "+deriv);
System.out.println("PROD => "+myAnswers[myIndex]);
System.out.println("LHS => "+myAnswers[myIndex].getLHS());
*/
int index=deriv.indexOf(myAnswers[myIndex].getLHS());
if (index==-1)
{
myStepAction.setEnabled(false);
return;
}
deriv=deriv.substring(0,index)+myAnswers[myIndex].getRHS()+deriv.substring(index+1);
int[] temp=new int[1];
temp[0]=index;
Production[] temp1=new Production[1];
temp1[0]=myAnswers[myIndex];
ParseNode pNode=new ParseNode(deriv, temp1, temp);
pNode=new ParseNode(pNode);
node.add(pNode);
myQueue.add(pNode);
myCurrentAnswerNode=pNode;
myIndex++;
}
|
d0eba4e8-a8e7-4a0b-aa96-61789a5c4d27
| 7
|
public void setWinner() throws IOException {
String winner;
if (player1Points > player2Points) {
winner = "1";
} else if (player2Points > player1Points) {
winner = "2";
} else {
winner = "TIE";
}
SocketHandler socketHandler1 = null;
SocketHandler socketHandler2 = null;
iter = clientLists.entrySet().iterator(); // reset iter
while (iter.hasNext()) {
if (playerNum == 1) {
socketHandler1 = iter.next().getKey();
playerNum++;
} else {
socketHandler2 = iter.next().getKey();
}
}
switch (winner) {
case "1":
socketHandler1.sendResultsToClient("winner", player1Points);
socketHandler2.sendResultsToClient("loser", player2Points);
break;
case "2":
socketHandler1.sendResultsToClient("loser", player1Points);
socketHandler2.sendResultsToClient("winner", player2Points);
break;
case "TIE":
socketHandler1.sendResultsToClient("TIE", player1Points);
socketHandler2.sendResultsToClient("TIE", player2Points);
break;
}
}
|
ab1a3ba4-c93b-4798-a73d-dfd96d0dade6
| 0
|
@Test
@SuppressWarnings("unchecked")
public void testAbstractFactory() {
ServiceFactory.putService(PersistenceService.class, new PersistenceServiceImpl<BeerEntity>());
PersistenceService<BeerEntity> retrievedService = ServiceFactory.getService(PersistenceService.class);
assertTrue(retrievedService.getClass().equals(PersistenceServiceImpl.class));
}
|
eaf709c0-55b0-401b-a076-d2b700e6fb23
| 8
|
private static void locateLinuxFonts(File file) {
if (!file.exists()) {
System.err.println("Unable to open: " + file.getAbsolutePath());
return;
}
try {
InputStream in = new FileInputStream(file);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
ByteArrayOutputStream temp = new ByteArrayOutputStream();
PrintStream pout = new PrintStream(temp);
while (reader.ready()) {
String line = reader.readLine();
if (line.indexOf("DOCTYPE") == -1) {
pout.println(line);
}
}
in = new ByteArrayInputStream(temp.toByteArray());
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(in);
NodeList dirs = document.getElementsByTagName("dir");
for (int i = 0; i < dirs.getLength(); i++) {
Element element = (Element) dirs.item(i);
String dir = element.getFirstChild().getNodeValue();
if (dir.startsWith("~")) {
dir = dir.substring(1);
dir = userhome + dir;
}
addFontDirectory(new File(dir));
}
NodeList includes = document.getElementsByTagName("include");
for (int i = 0; i < includes.getLength(); i++) {
Element element = (Element) dirs.item(i);
String inc = element.getFirstChild().getNodeValue();
if (inc.startsWith("~")) {
inc = inc.substring(1);
inc = userhome + inc;
}
locateLinuxFonts(new File(inc));
}
} catch (Exception e) {
e.printStackTrace();
System.err.println("Unable to process: " + file.getAbsolutePath());
}
}
|
5b57313b-bf26-4b3e-9c22-68df10967bc0
| 3
|
public ArrayList<TreeNode> getTips() {
ArrayList<TreeNode> children = new ArrayList<TreeNode>();
Stack<TreeNode> nodes = new Stack<TreeNode>();
nodes.push((TreeNode) this);
while (nodes.isEmpty() == false) {
TreeNode jt = nodes.pop();
for (int i = 0; i < jt.getChildCount(); i++) {
nodes.push(jt.getChild(i));
}
if (jt.isExternal()) {
children.add(jt);
}
}
return children;
}
|
31b20924-db1f-4f01-8a03-7127be2ec7e3
| 9
|
private static void reflectionAppend(
Object lhs,
Object rhs,
Class clazz,
EqualsBuilder builder,
boolean useTransients,
String[] excludeFields) {
Field[] fields = clazz.getDeclaredFields();
List excludedFieldList = excludeFields != null ? Arrays.asList(excludeFields) : Collections.EMPTY_LIST;
AccessibleObject.setAccessible(fields, true);
for (int i = 0; i < fields.length && builder.isEquals; i++) {
Field f = fields[i];
if (!excludedFieldList.contains(f.getName())
&& (f.getName().indexOf('$') == -1)
&& (useTransients || !Modifier.isTransient(f.getModifiers()))
&& (!Modifier.isStatic(f.getModifiers()))) {
try {
builder.append(f.get(lhs), f.get(rhs));
} catch (IllegalAccessException e) {
//this can't happen. Would get a Security exception instead
//throw a runtime exception in case the impossible happens.
throw new InternalError("Unexpected IllegalAccessException");
}
}
}
}
|
40c58b14-3dbf-47ac-bf4b-0a8ed1d954e6
| 4
|
public void handleResetButton(){
if(aTimer.isRunning()){
aTimer.stop();
}
aTuringMachine.getInput().clear();
aTuringMachine.getInput().add("Blank Symbol");
simulationView.getPrintError().setText("");
for(int i = 0; i < 31; i++){
if((inputView.getInputLabels(i).getText().equals("")) || (inputView.getInputLabels(i).getText().equals("|_|"))){
aTuringMachine.getInput().add("Blank Symbol");
}
else{
aTuringMachine.getInput().add(inputView.getInputLabels(i).getText());
}
}
aTuringMachine.getInput().add("Blank Symbol");
simulationView.setInput(aTuringMachine.getInput());
aTuringMachine.setCurrentCell(aTuringMachine.getStartCell());
aTuringMachine.setCurrentState(aTuringMachine.getStartState());
simulationView.getState().setText(aTuringMachine.getCurrentState());
simulationView.getState().setFont(new Font("arial", Font.BOLD,12));
simulationView.getState().setForeground(Color.black);
simulationView.setTapeHeadCell(aTuringMachine.getCurrentCell());
simulationView.getChangeInputButton().setEnabled(true);
simulationView.getSpinner().setEnabled(true);
simulationView.getSlider().setEnabled(true);
simulationView.getRunButton().setText("Start");
simulationView.getRunButton().setEnabled(true);
simulationView.getSaveMachineButton().setEnabled(true);
simulationView.setPrintOrder(-1);
simulationView.repaint();
}
|
04fa541d-73ac-4d15-b88a-cc1fe20533d7
| 8
|
private static void cleanup(List<Difference> diffs) {
Difference last = null;
for (int i = 0; i < diffs.size(); i++) {
Difference diff = diffs.get(i);
if (last != null) {
if (diff.getType() == Difference.ADD && last.getType() == Difference.DELETE ||
diff.getType() == Difference.DELETE && last.getType() == Difference.ADD) {
Difference add;
Difference del;
if (Difference.ADD == diff.getType()) {
add = diff;
del = last;
} else {
add = last;
del = diff;
}
int d1f1l1 = add.getFirstStart() - (del.getFirstEnd() - del.getFirstStart());
int d2f1l1 = del.getFirstStart();
if (d1f1l1 == d2f1l1) {
Difference newDiff = new Difference(Difference.CHANGE,
d1f1l1, del.getFirstEnd(), add.getSecondStart(), add.getSecondEnd(),
del.getFirstText(), add.getSecondText());
diffs.set(i - 1, newDiff);
diffs.remove(i);
i--;
diff = newDiff;
}
}
}
last = diff;
}
}
|
5d530e30-d639-47af-b842-dfa5aed3a7ba
| 4
|
public void calculateUptime(String port) {
if (Functions.isNumeric(port)) {
int portValue = Integer.valueOf(port);
Server s = getServer(portValue);
if (s != null) {
if (portValue >= this.min_port && portValue < this.max_port)
sendMessage(cfg_data.irc_channel, s.port + " has been running for " + Functions.calculateTime(System.currentTimeMillis() - s.time_started));
else
sendMessage(cfg_data.irc_channel, "Port must be between " + this.min_port + " and " + this.max_port);
}
else
sendMessage(cfg_data.irc_channel, "There is no server running on port " + port);
}
else
sendMessage(cfg_data.irc_channel, "Port must be a number (ex: .uptime 15000)");
}
|
43e21a50-2f4f-475f-9a93-da7a407dbb24
| 7
|
public void normalizeSubGoalWeights() {
float sumWeights = 0f;
Iterator<Goal> git = getSubGoalIterator();
while (git!=null && git.hasNext()) {
Goal g = git.next();
sumWeights += g.getWeight();
}
//allow for a small rounding or other error margin before normalizing
if (sumWeights>0f && (sumWeights<0.95f || sumWeights>1.05f)) {
git = getSubGoalIterator();
while (git!=null && git.hasNext()) {
Goal g = git.next();
g.setWeight(g.getWeight()/sumWeights);
}
}
}
|
51d3f515-e4db-443e-98e5-5c3fd37a8df4
| 3
|
@Override
public Intersection findBestMove(Board board) {
GameTreeNode root = GameTreeNode.getInstance(board);
GameTree tree = GameTree.getInstance(root);
for(int iteration = 0; iteration < iterations; iteration++) {
if(invariantChecker != null) {
invariantChecker.treeSize(tree.nodes.size());
}
// Select
GameTreeNode node = tree.select(random);
// Expand
List<Intersection> moves = node.board.getMoves();
if(moves.size() == 0) continue;
Intersection move = moves.get(random.nextInt(moves.size()));
GameTreeNode newNode =
GameTreeNode.getInstance(node.board.makeMove(move.x, move.y), node);
node.children.add(newNode);
tree.nodes.add(newNode);
// Simulate
double score = simulate(newNode.board);
// Backpropagate
newNode.backpropagate(score);
}
return null; // Pass
}
|
c9a42165-a689-419b-ad85-e9cf0a675088
| 0
|
public GetAccountResponse getGetAccountResponse() {
return getAccountResponse;
}
|
df73aa0f-fffd-47b1-bf05-6554cd5a13e1
| 7
|
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
float Gross;
System.out.print("Gross Salary: ");
Gross = keyboard.nextFloat();
int Exemptions;
System.out.print("Number of Exemptions: ");
Exemptions = keyboard.nextInt();
float Interest;
System.out.print("Interest Income: ");
Interest = keyboard.nextFloat();
float Capital;
System.out.print("Capital Gains: ");
Capital = keyboard.nextFloat();
float Total = (Gross + Interest + Capital);
System.out.printf("Total Income: $%.2f\n", Total);
float Adjusted = (float) (Total - (Exemptions * 1800.00));
System.out.printf("Adjusted Income: $%.2f\n", Adjusted);
if ((Adjusted > 0) && (Adjusted <= 10000)) {
System.out.printf("Total Tax: $%.2f\n", ((0.00 * (Adjusted))));
} else if ((Adjusted > 10000) && (Adjusted <= 25000)) {
System.out.printf("Total Tax: $%.2f\n",
((0.15 * (Adjusted - 250000.00))));
} else if ((Adjusted > 25000) && (Adjusted <= 36000)) {
System.out
.printf("Total Tax: $%.2f\n",
(((0.25 * (Adjusted - 25000.00)) + (0.15 * (25000.00 - 10000.00)))));
} else if (Adjusted > 36000) {
System.out
.printf("Total Tax: $%.2f\n",
(((0.28 * (Adjusted - 36000.00))) + ((0.25 * (36000.00 - 25000.00)) + (0.15 * (25000.00 - 10000.00)))));
}
System.out.printf("State Tax: $%.2f\n", (Adjusted * .06));
keyboard.close();
}
|
27744749-63dc-4f19-9d6f-450f72481148
| 7
|
static private double calculatePairwiseDistance(int taxon1, int taxon2) {
double[] total = new double [4];
double[] transversions = new double [4];
for( Pattern pattern : alignment.getPatterns() ) {
State state1 = pattern.getState(taxon1);
State state2 = pattern.getState(taxon2);
double weight = pattern.getWeight();
if (!state1.isAmbiguous() && !state2.isAmbiguous() ) {
total[state1.getIndex()] += weight;
if( Nucleotides.isTransversion(state1, state2) ) {
transversions[state1.getIndex()] += weight;
}
}
}
double totalTransversions = 0.0;
for(int i = 0; i < 4; ++i) {
if( total[i] > 0 ) {
totalTransversions += transversions[i]/total[i];
}
}
double expDist = 1.0 - (totalTransversions / 2.0);
return expDist > 0 ? -Math.log( expDist) : MAX_DISTANCE;
}
|
3e80058c-25ee-42ba-836e-d5a0edf3e7a0
| 2
|
public static void main(String[] args)
{
GraphProperties GP = null;
Graph G = null;
try
{
G = new Graph(new In(args[0]));
GP = new GraphProperties(G);
}
catch (Exception e)
{
System.out.println(e);
System.exit(1);
}
System.out.println(args[0] + "\n" + G.toString());
for (int v = 0; v < G.V(); v++)
System.out.println("Eccentricity of " + v + " = "
+ GP.eccentricity(v));
System.out.println("Diameter = " + GP.diameter());
System.out.println("Radius = " + GP.radius());
System.out.println("Center is " + GP.center());
}
|
dc2e17c7-e738-486d-a94a-0c11eac3491b
| 7
|
public void zoneEventOccurred(String eventZone, int eventType) {
if((eventType == ZoneEvents.MOVEMENT || eventType == ZoneEvents.ENTER )&& eventZone.equals("sectionNav")){
if(Debug.gui)
System.out.println(eventZone);
if(triggerShimmyIn());
else if(triggerShimmyOut());
else{
if(Debug.gui)
System.out.println("SectionNav - do nothing");
}
}
}
|
42943d0f-bc62-4696-b4bd-91f661dfbf24
| 9
|
boolean setField(String fieldName, JsonReader reader) throws IOException {
if (fieldName.equals("Name")) {
name = reader.nextString();
} else if (fieldName.equals("X")) {
x = reader.nextInt();
} else if (fieldName.equals("Y")) {
y = reader.nextInt();
} else if (fieldName.equals("LastX")) {
lastX = reader.nextInt();
} else if (fieldName.equals("LastY")) {
lastY = reader.nextInt();
} else if (fieldName.equals("Bombs")) {
bombsPlaced = reader.nextInt();
} else if (fieldName.equals("MaxBomb")) {
maxBombs = reader.nextInt();
} else if (fieldName.equals("MaxRadius")) {
maxBombRadius = reader.nextInt();
} else if (fieldName.equals("Alive")) {
isAlive = reader.nextBoolean();
} else {
return false;
}
return true;
}
|
7e1b2bc8-6614-45b0-8a87-3b0b9b6a639a
| 8
|
public static void main(String[] args) throws java.io.IOException {
if (args.length != 8) {
System.out.println("Usage: Experiment <instance_list> <num_topics> <num_itns> <print_interval> <save_state_interval> <symmetric> <optimize> <output_dir>");
System.exit(1);
}
int index = 0;
String instanceListFileName = args[index++];
int T = Integer.parseInt(args[index++]); // # of topics
int numIterations = Integer.parseInt(args[index++]); // # Gibbs iterations
int printInterval = Integer.parseInt(args[index++]); // # iterations between printing out topics
int saveStateInterval = Integer.parseInt(args[index++]);
assert args[index].length() == 2;
boolean[] symmetric = new boolean[2];
for (int i=0; i<2; i++)
switch(args[index].charAt(i)) {
case '0': symmetric[i] = false; break;
case '1': symmetric[i] = true; break;
default: System.exit(1);
}
index++;
assert args[index].length() == 2;
boolean[] optimize = new boolean[2]; // whether to optimize hyperparameters
for (int i=0; i<2; i++)
switch(args[index].charAt(i)) {
case '0': optimize[i] = false; break;
case '1': optimize[i] = true; break;
default: System.exit(1);
}
index++;
String outputDir = args[index++]; // output directory
assert index == 8;
// load data
InstanceList docs = InstanceList.load(new File(instanceListFileName));
Alphabet wordDict = docs.getDataAlphabet();
int W = wordDict.size();
double alpha = 0.1 * T;
double beta = 0.01 * W;
// form output filenames
String optionsFileName = outputDir + "/options.txt";
String documentTopicsFileName = outputDir + "/doc_topics.txt.gz";
String topicWordsFileName = outputDir + "/topic_words.txt.gz";
String topicSummaryFileName = outputDir + "/topic_summary.txt.gz";
String stateFileName = outputDir + "/state.txt.gz";
String alphaFileName = outputDir + "/alpha.txt";
String betaFileName = outputDir + "/beta.txt";
String logProbFileName = outputDir + "/log_prob.txt";
PrintWriter pw = new PrintWriter(optionsFileName);
pw.println("Instance list = " + instanceListFileName);
int corpusLength = 0;
for (int d=0; d<docs.size(); d++) {
FeatureSequence fs = (FeatureSequence) docs.get(d).getData();
corpusLength += fs.getLength();
}
pw.println("# tokens = " + corpusLength);
pw.println("T = " + T);
pw.println("# iterations = " + numIterations);
pw.println("Print interval = " + printInterval);
pw.println("Save state interval = " + saveStateInterval);
pw.println("Symmetric alpha = " + symmetric[0]);
pw.println("Symmetric beta = " + symmetric[1]);
pw.println("Optimize alpha = " + optimize[0]);
pw.println("Optimize beta = " + optimize[1]);
pw.println("Date = " + (new Date()));
pw.close();
LDA lda = new LDA();
lda.estimate(docs, null, 0, T, alpha, beta, numIterations, printInterval, saveStateInterval, symmetric, optimize, documentTopicsFileName, topicWordsFileName, topicSummaryFileName, stateFileName, alphaFileName, betaFileName, logProbFileName);
}
|
c1a5e70e-65ea-465a-ba06-3b3ed8d68c64
| 0
|
public float getWeight() {
return weight;
}
|
2cec0303-f7b7-4c19-8b65-1abd62ed4b0a
| 7
|
public void update() {
int xa = 0, ya = 0;
if (anim < 7500) {
anim++;
} else {
anim = 0;
}
if(input.up) ya--;
if(input.down) ya++;
if(input.left) xa--;
if(input.right) xa++;
if(xa != 0 || ya != 0) {
move(xa, ya);
walking = true;
} else {
walking = false;
}
}
|
732b9c59-0e08-462d-aee1-979301a97461
| 2
|
public static FacilityCategoryEnumeration fromValue(String v) {
for (FacilityCategoryEnumeration c: FacilityCategoryEnumeration.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
|
2b48aef8-3865-4360-95c1-5513efb5abfc
| 1
|
public void setAlias(String alias)
{
alias = alias.trim();
if ( alias.isEmpty() ) {
throw new RuntimeException( "'alias' should not be empty" );
}
this.alias = alias;
}
|
4700ef3a-7d06-459d-9c51-b6013904f835
| 0
|
public void setSolUsuario(String solUsuario) {
this.solUsuario = solUsuario;
}
|
6c3fede5-f6fe-401c-a665-f03bac399d4a
| 0
|
private static JavaMailSenderImpl getMailSender() throws MessagingException {
String password = "chao123jing";//PropertyManager.getInstance().getDbProperty(PropertyManager.DB_EMAIL_PASSWORD, true);
String username = "52673406@qq.com";//PropertyManager.getInstance().getDbProperty(PropertyManager.DB_EMAIL_USERNAME, true);
String host = "smtp.qq.com";//PropertyManager.getInstance().getDbProperty(PropertyManager.DB_EMAIL_HOST, true);
String port = "25";//PropertyManager.getInstance().getDbProperty(PropertyManager.DB_EMAIL_PORT, true);
Properties javaMailProperties = new Properties();
javaMailProperties.put("mail.smtp.auth", true);
// if (StringUtil.isBlank(password)) {
// throw new MessagingException("邮件密码为空");
// }
// if (StringUtil.isBlank(username)) {
// throw new MessagingException("邮件用户名为空");
// }
// if (StringUtil.isBlank(host)) {
// throw new MessagingException("主机为空");
// }
// if (StringUtil.isBlank(port)) {
// throw new MessagingException("端口为空");
// }
JavaMailSenderImpl javaMailSenderImpl = new JavaMailSenderImpl();
javaMailSenderImpl.setPassword(password);
javaMailSenderImpl.setUsername(username);
javaMailSenderImpl.setHost(host);
javaMailSenderImpl.setPort(Integer.parseInt(port));
//解决 javax.mail.MessagingException: 501 Syntax: HELO hostname
// String hostIp = PropertyManager.getInstance().getXMLProperty(PropertyManager.XML_HOST);
// javaMailProperties.put("mail.smtp.localhost", hostIp);
javaMailSenderImpl.setJavaMailProperties(javaMailProperties);
return javaMailSenderImpl;
}
|
65bff163-ab99-45dc-a5e0-35838084030d
| 8
|
private void selectOption(int option) {
if (allowClick) {
game.jukeBox.play(game.jukeBox.tracks.buttonClick);
if (option == 0) {
if (Bootstrap.MUTE) {
options[0] = "On";
Bootstrap.MUTE = false;
} else {
options[0] = "Off";
Bootstrap.MUTE = true;
}
Bootstrap.MUTECHANGE = 1;
} else if (option == 1) {
} else if (option == 2) {
} else if (option == 3) {
} else if (option == 4) {
} else if (option == 5) {
game.log.gsm("[OPTIONS] going back to ID:" + lastState);
save();
gsm.setState(lastState);
}
}
}
|
63a12749-49d1-45db-8101-82f2f7e2b7af
| 7
|
public void paint(java.awt.Graphics g) {
java.awt.Graphics2D g2d = (java.awt.Graphics2D) g.create();
String text = getText();
java.awt.Dimension size = getSize();
java.awt.Insets ins = getInsets();
java.awt.FontMetrics fm = g2d.getFontMetrics(getFont());
int h = fm.stringWidth(text), x = ins.right;
switch (getHorizontalAlignment()) {
case SwingConstants.CENTER:
x = (size.height - h + ins.right - ins.left) / 2;
break;
case SwingConstants.TOP:
x = size.height - h - ins.left;
break;
}
int descent = fm.getDescent(), ascent = fm.getAscent(),
y = ins.top + ascent;
switch (getVerticalAlignment()) {
case SwingConstants.CENTER:
y = (size.width + ascent - descent + ins.top - ins.bottom) / 2;
break;
case SwingConstants.RIGHT:
y = size.width - descent - ins.bottom;
break;
}
java.awt.geom.AffineTransform trans;
if (clockwise) {
trans = new java.awt.geom.AffineTransform(0, 1, -1, 0, -size.height, 0);
} else {
trans = new java.awt.geom.AffineTransform(0, -1, 1, 0, 0, size.height);
}
g2d.transform(trans);
g2d.setPaintMode();
if (isOpaque() && (getBackground() != null)) {
g2d.setColor(getBackground());
g2d.fillRect(0, 0, size.height, size.width);
}
g2d.setFont(getFont());
g2d.setColor(getForeground());
g2d.drawString(text, x, y);
trans = null;
g2d = null;
}
|
0c045591-e7fa-4975-b27f-f662c498d95d
| 5
|
private void loadAllProjects(){//requires components and QC stuff
try {
ResultSet dbAllProjects = null;
Statement statement;
statement = connection.createStatement();
dbAllProjects = statement.executeQuery( "SELECT Project.projectID, Project.projectName, Project.rootComponent, Project.teamLeader, "
+ "Project.clientRep, Project.priority FROM Project;");
while(dbAllProjects.next())
{
int tempTeamLeaderID = dbAllProjects.getInt("teamLeader");
int tempClientRepID = dbAllProjects.getInt("clientRep");
User tempTeamLeader = null;
User tempClientRep = null;
for (int i=0; i<allUsers.size();i++){
if(allUsers.get(i).getUserID()==(tempTeamLeaderID))
{
tempTeamLeader = (allUsers.get(i));
}
if(allUsers.get(i).getUserID()==(tempClientRepID))
{
tempClientRep = (allUsers.get(i));
}
}
//project should have correct components and QCReports added
//Project tempProject = new Project(dbAllProjects.getInt("projectID"), null, null, tempTeamLeader, tempClientRep, dbAllProjects.getInt("priority"), null, null);
//allProjects.addProject(tempProject);
}
} catch (SQLException ex) {
Logger.getLogger(testFrame3Tim.class.getName()).log(Level.SEVERE, null, ex);
}
}
|
1207cc99-1a30-41be-a3c1-50d52b324141
| 8
|
public int compareTo(Contact contact) {
if (taxi1 < contact.taxi1) return -1;
if (taxi1 > contact.taxi1) return 1;
if (taxi2 < contact.taxi2) return -1;
if (taxi2 > contact.taxi2) return 1;
if (start < contact.start) return -1;
if (start > contact.start) return 1;
if (stop < contact.stop) return -1;
if (stop > contact.stop) return 1;
return 0;
}
|
93669480-4d04-41aa-a22e-c84b732385f8
| 4
|
private void loadBorrowedBooksTable() {
DefaultTableModel dft = (DefaultTableModel) jTable1.getModel();
dft.setRowCount(0);
try {
ResultSet rs = DB.myConnection().createStatement().executeQuery("select * from borrowedbooks order by BorrowedID ASC");
while (rs.next()) {
Vector borrow_book = new Vector();
borrow_book.add(rs.getString("BorrowedID"));
String memID = rs.getString("MemberID");
int mm = Integer.parseInt(memID);
borrow_book.add(memID);
ResultSet rs1 = DB.myConnection().createStatement().executeQuery("select * from members where MemberID='" + mm + "'");
while (rs1.next()) {
String Fname = (rs1.getString("MemberFirstName"));
String Mname = (rs1.getString("MemberMiddleName"));
String Sname = rs1.getString("MemberSurname");
String full = Fname + " " + Mname + " " + Sname;
borrow_book.add(full);
}
String bookid = rs.getString("BookID");
int bID = Integer.parseInt(bookid);
borrow_book.add(bookid);
ResultSet rs2 = DB.myConnection().createStatement().executeQuery("select * from book where BookID='" + bID + "'");
while (rs2.next()) {
borrow_book.add(rs2.getString("BookName"));
}
borrow_book.add(rs.getString("BurrowedDate"));
borrow_book.add(rs.getString("ReturningDate"));
dft.addRow(borrow_book);
}
} catch (Exception e) {
}
}
|
9d8854da-971e-48f8-90b5-a8670d5220d5
| 6
|
public String[] decompile(int[] data) {
StringBuilder builder = new StringBuilder();
for(int i = 0; i < data.length; i++) {
MCSInstruction cmdInstruction = instructions.get(data[i]);
switch(cmdInstruction.getArgLen()) {
case 0:
builder.append(cmdInstruction.getCommandName()+"\n");
break;
case 1:
builder.append(cmdInstruction.getCommandName().replace("arg", Integer.toHexString(data[i+1]).toUpperCase()+"h")+"\n");
i = i + cmdInstruction.getArgLen();
break;
case 2:
if(cmdInstruction.getMachineCode() == 0x02 || cmdInstruction.getMachineCode() == 0x12){
String argument = Integer.toHexString(data[i+1]).toUpperCase()+Integer.toHexString(data[i+2]).toUpperCase()+"h";
builder.append(cmdInstruction.getCommandName().replace("arg", argument)+"\n");
i = i + cmdInstruction.getArgLen();
break;
}
builder.append(cmdInstruction.getCommandName().replace("arg", Integer.toHexString(data[i+1]).toUpperCase()+"h")
.replace("arg2", Integer.toHexString(data[i+2]).toUpperCase()+"h")+"\n");
i = i + cmdInstruction.getArgLen();
break;
default:
throw new NullPointerException("Invalid Instruction");
}
}
return builder.toString().split("\n");
}
|
e6719e21-6289-4d5d-bcc0-112b0b4f880f
| 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(Window.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Window.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Window.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Window.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 Window().setVisible(true);
}
});
}
|
17813444-a852-4132-8174-3ced09300cd8
| 4
|
public void remove_polypoint(int p) {
if (type!=TYPE_POLY || poly.npoints<=3) return;
Polygon pnew = new Polygon();
for (int i=0; i<poly.npoints; i++)
if (i!=p-1)
pnew.addPoint(poly.xpoints[i], poly.ypoints[i]);
poly=pnew;
}
|
d96a67d5-0812-42dd-8c03-4ac0debf1e5a
| 8
|
* @param filename
* @param ifexists
* @param environment
*/
public static void saveModule(Module module, String filename, String ifexists, Environment environment) {
{ boolean existsP = Stella.probeFileP(filename);
if ((!existsP) ||
Stella.stringEqualP(ifexists, "REPLACE")) {
}
else if (Stella.stringEqualP(ifexists, "ASK")) {
if (!(Stella.yesOrNoP("File `" + filename + "' already exists. Overwrite it? (yes or no) "))) {
Stella.ensureFileDoesNotExist(filename, "save-module");
}
}
else if (Stella.stringEqualP(ifexists, "WARN")) {
Stella.STANDARD_WARNING.nativeStream.println("Warning: File `" + filename + "' already exists, overwriting.");
}
else if (Stella.stringEqualP(ifexists, "ERROR")) {
Stella.ensureFileDoesNotExist(filename, "save-module");
}
else {
{ OutputStringStream stream000 = OutputStringStream.newOutputStringStream();
stream000.nativeStream.print("Unrecognized ifexists option `" + ifexists + "'");
throw ((BadArgumentException)(BadArgumentException.newBadArgumentException(stream000.theStringReader()).fillInStackTrace()));
}
}
{ Module mdl000 = module;
Context cxt000 = mdl000;
if (mdl000 == null) {
mdl000 = ((Module)(Stella.$MODULE$.get()));
cxt000 = ((Context)(Stella.$CONTEXT$.get()));
}
{ Object old$Module$000 = Stella.$MODULE$.get();
Object old$Context$000 = Stella.$CONTEXT$.get();
try {
Native.setSpecial(Stella.$MODULE$, mdl000);
Native.setSpecial(Stella.$CONTEXT$, cxt000);
environment = environment;
synchronized (Logic.$POWERLOOM_LOCK$) {
{ OutputFileStream stream = null;
try {
stream = Stella.openOutputFile(filename, Stella.NIL);
Logic.doSaveModule(((Module)(Stella.$MODULE$.get())), stream);
} finally {
if (stream != null) {
stream.free();
}
}
}
}
} finally {
Stella.$CONTEXT$.set(old$Context$000);
Stella.$MODULE$.set(old$Module$000);
}
}
}
}
}
|
6368748f-55d0-4ae6-8052-8867732a3ee6
| 2
|
private void addSensorEx2(){
Sensor input = new Sensor();
input.setUnity("s");
input.setAddDate(new Date(System.currentTimeMillis()));
input.setLowBattery(false);
input.setStatementFrequency(1322);
input.setSamplingFrequency(1050);
input.setGpsLocation(-0.12712, 2.07222);
input.setName("Sensor_Graph");
input.setSensorType(SensorType.GRAPH);
try {
ClientConfig clientConfig = new DefaultClientConfig();
clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
Client client = Client.create(clientConfig);
WebResource webResource = client.resource(URL_SERVEUR);
ClientResponse response = webResource.path("rest").path("sensor").path("post").accept("application/json").type("application/json").post(ClientResponse.class, input);
if (response.getStatus() != Response.Status.CREATED.getStatusCode()) {
throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
}
String output = response.getEntity(String.class);
System.out.println("Sensor : " + output);
} catch (Exception e) {
e.printStackTrace();
}
}
|
e0bba9a0-3333-4189-9469-8bef3ed8d9de
| 1
|
private void showChange() {
if (bodyPos.getChildren().contains(hboxChange)) {
return;
}
bodyPos.getChildren().add(1, hboxChange);
}
|
b6c67cfb-ddd0-4279-b4e7-1435ff21ceb7
| 0
|
private void addStats() {
this.setAgility(this.agility + 10);
this.setDexterity(this.dexterity + 10);
this.setIntelligence(this.intelligence + 10);
this.setStrength(this.strength + 10);
this.setVitality(this.vitality + 10);
this.setLuck(this.luck + 1);
}
|
8ddb48fc-20dd-4002-9411-160c4661a0f8
| 9
|
private CucaDiagramFileMakerResult createFileInternal(OutputStream os, List<String> dotStrings,
FileFormatOption fileFormatOption) throws IOException, InterruptedException {
if (diagram.getUmlDiagramType() == UmlDiagramType.STATE
|| diagram.getUmlDiagramType() == UmlDiagramType.ACTIVITY) {
new CucaDiagramSimplifier2(diagram, dotStrings);
}
double deltaX = 0;
double deltaY = 0;
final DotData dotData = new DotData(null, diagram.getLinks(), diagram.entities(), diagram.getUmlDiagramType(),
diagram.getSkinParam(), diagram.getRankdir(), diagram, diagram, diagram.getColorMapper());
final CucaDiagramFileMakerSvek2 svek2 = new CucaDiagramFileMakerSvek2(dotData);
IEntityImage result = svek2.createFile(((CucaDiagram) diagram).getDotStringSkek());
result = addTitle(result);
result = addHeaderAndFooter(result);
// final Dimension2D dim =
// Dimension2DDouble.delta(result.getDimension(stringBounder), 10);
final Dimension2D dim = result.getDimension(stringBounder);
final FileFormat fileFormat = fileFormatOption.getFileFormat();
if (fileFormat == FileFormat.PNG) {
createPng(os, fileFormatOption, result, dim);
} else if (fileFormat == FileFormat.SVG) {
createSvg(os, fileFormatOption, result, dim);
} else if (fileFormat == FileFormat.EPS) {
createEps(os, fileFormatOption, result, dim);
} else {
throw new UnsupportedOperationException(fileFormat.toString());
}
if (result instanceof DecorateEntityImage) {
deltaX += ((DecorateEntityImage) result).getDeltaX();
deltaY += ((DecorateEntityImage) result).getDeltaY();
}
final Dimension2D finalDimension = Dimension2DDouble.delta(dim, deltaX, deltaY);
String cmap = null;
if (diagram.hasUrl()) {
cmap = cmapString(svek2, deltaX, deltaY);
}
final String widthwarning = diagram.getSkinParam().getValue("widthwarning");
if (widthwarning != null && widthwarning.matches("\\d+")) {
this.warningOrError = svek2.getWarningOrError(Integer.parseInt(widthwarning));
} else {
this.warningOrError = null;
}
return new CucaDiagramFileMakerResult(cmap, finalDimension.getWidth(), getWarningOrError());
}
|
4f48996c-843a-4bf4-9bf6-b8d4e11cfb29
| 0
|
@Override
public void endSetup(Attributes atts) {
super.endSetup(atts);
}
|
7c0fc1b7-8cc3-4bbd-bbfe-47e4686a736f
| 8
|
public ArrayList<Object> scanInput() {
Scanner scanner = new Scanner(System.in);
input = scanner.nextLine();
scanner.close();
if (input.contains("Neuer K-Raum")) {
ArrayList<Object> liste = new ArrayList<Object>();
liste.add("Add");
liste.add(legeKonferenzRaumAn(input));
return liste;
} else if (input.contains("Neuer A-Raum")) {
ArrayList<Object> liste = new ArrayList<Object>();
liste.add("Add");
liste.add(legeArbeitsRaumAn(input));
return liste;
} else if (input.contains("Neue Kueche")) {
ArrayList<Object> liste = new ArrayList<Object>();
liste.add("Add");
liste.add(legeKuecheAn(input));
return liste;
} else if (input.contains("Neue Toilette")) {
ArrayList<Object> liste = new ArrayList<Object>();
liste.add("Add");
liste.add(legeToiletteAn(input));
return liste;
} else if (input.contains("Zeige Raeume")) {
ArrayList<Object> liste = new ArrayList<Object>();
liste.add("Show");
return liste;
} else if (input.contains("Bearbeite Raum")) {
ArrayList<Object> liste = new ArrayList<Object>();
liste.add("Edit");
liste.add(getNameToEditOrDelete(input));
return liste;
} else if (input.contains("Loesche Raum")) {
ArrayList<Object> liste = new ArrayList<Object>();
liste.add("Del");
liste.add(getNameToEditOrDelete(input));
return liste;
} else if (input.equals("exit")) {
ArrayList<Object> liste = new ArrayList<Object>();
liste.add("exit");
return liste;
} else {
return null;
}
}
|
d1e93be2-0346-4f5b-8477-e43af9eebbfb
| 3
|
public static void closeStatement(Statement stmt) {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException ex) {
LOGGER.trace("关闭JDBC Statement失败", ex);
} catch (Throwable ex) {
// We don't trust the JDBC driver: It might throw
// RuntimeException or Error.
LOGGER.trace("关闭JDBC Statement时发生未知异常", ex);
}
}
}
|
ef07cad7-a25b-44d7-8688-96a5965aec71
| 2
|
public void replace_field_from_memory( int i )
{
if(isReadOnly()) return;
try { fdbf.seek( recordpos() + Field[i].fpos ); } catch (IOException e) {}
replacefielddata(i);
update_key();
getfieldsValues();
}
|
c621f93f-658f-41f2-a61b-a46e1e556012
| 1
|
public String getClassInfo(int index) {
ClassInfo c = (ClassInfo)getItem(index);
if (c == null)
return null;
else
return Descriptor.toJavaName(getUtf8Info(c.name));
}
|
d6aeab08-87c3-4a9b-8640-47b125231339
| 5
|
public void testSaveOsobu() {
Osoba o=new Osoba();
o.setImePrezime("Alen Kopic");
Date datumRodjenja=new Date(1992,10,21);
o.setDatumRodjenja(datumRodjenja);
o.setAdresa("Vitkovac 166");
DBManager.saveOsobu(o);
List<Osoba>osobe=DBManager.dajOsobe();
Boolean tacno=false;
for (Osoba i : osobe) {
if(i.getIme()!=null&&i.getPrezime()!=null)
if( i.getIme().equals(o.getIme())&&i.getPrezime().equals(o.getPrezime()))
tacno=true;
}
Assert.assertTrue(tacno);
Assert.assertFalse(osobe.contains(o));
}
|
91605091-a065-4d2a-ab9d-7f59b25e0bc8
| 5
|
private void setupGui() {
setTitle("Update Available!");
setModal(true);
setSize(451, 87);
setResizable(false);
setUndecorated(true);
close.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
dispose();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
try {
close.setIcon(new ImageIcon(new URL("http://modpacks.minebook.co.uk/images/closeOver.png")));
} catch (MalformedURLException ex) {
Logger.getLogger(MinebookLauncher.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public void mouseExited(MouseEvent e) {
try {
close.setIcon(new ImageIcon(new URL("http://modpacks.minebook.co.uk/images/close.png")));
} catch (MalformedURLException ex) {
Logger.getLogger(MinebookLauncher.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
try {
close.setIcon(new ImageIcon(new URL("http://modpacks.minebook.co.uk/images/close.png")));
} catch (MalformedURLException ex) {
Logger.getLogger(enterCode.class.getName()).log(Level.SEVERE, null, ex);
}
close.setBounds(new Rectangle(20, 20));
Container panel = getContentPane();
SpringLayout layout = new SpringLayout();
panel.setLayout(layout);
passwordLbl = new JLabel("A new version is available for " + packID +", do you want to update it?");
passwordLbl.setForeground(Color.WHITE);
cancel = new JButton("NO");
cancel.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
try {
dispose();
new launchModPack(packID);
} catch (Exception ex) {
Logger.getLogger(updateAvailable.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public void mousePressed(MouseEvent e) {}
@Override
public void mouseReleased(MouseEvent e) {}
@Override
public void mouseEntered(MouseEvent e) {}
@Override
public void mouseExited(MouseEvent e) {}
});
update = new JButton("YES");
update.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
try {
dispose();
new downloadPack(packID, mcver, true);
} catch (Exception ex) {
Logger.getLogger(updateAvailable.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public void mousePressed(MouseEvent e) {}
@Override
public void mouseReleased(MouseEvent e) {}
@Override
public void mouseEntered(MouseEvent e) {}
@Override
public void mouseExited(MouseEvent e) {}
});
panel.add(close);
panel.add(passwordLbl);
panel.add(cancel);
panel.add(update);
Spring hSpring;
hSpring = Spring.constant(0);
layout.putConstraint(SpringLayout.EAST, close, hSpring, SpringLayout.EAST, panel);
hSpring = Spring.constant(0);
layout.putConstraint(SpringLayout.HORIZONTAL_CENTER, passwordLbl, hSpring, SpringLayout.HORIZONTAL_CENTER, panel);
hSpring = Spring.sum(hSpring, Spring.width(passwordLbl));
hSpring = Spring.sum(hSpring, Spring.constant(10));
layout.putConstraint(SpringLayout.WEST, cancel, 150, SpringLayout.WEST, panel);
layout.putConstraint(SpringLayout.EAST, update, -150, SpringLayout.EAST, panel);
hSpring = Spring.sum(hSpring, Spring.width(cancel));
hSpring = Spring.sum(hSpring, Spring.constant(10));
layout.putConstraint(SpringLayout.EAST, panel, hSpring, SpringLayout.WEST, panel);
Spring vSpring;
vSpring = Spring.constant(-5);
layout.putConstraint(SpringLayout.BASELINE, close, vSpring, SpringLayout.BASELINE, panel);
vSpring = Spring.constant(25);
layout.putConstraint(SpringLayout.BASELINE, passwordLbl, vSpring, SpringLayout.BASELINE, panel);
vSpring = Spring.sum(vSpring, Spring.height(passwordLbl));
vSpring = Spring.sum(vSpring, Spring.constant(10));
layout.putConstraint(SpringLayout.NORTH, cancel, vSpring, SpringLayout.NORTH, panel);
layout.putConstraint(SpringLayout.NORTH, update, vSpring, SpringLayout.NORTH, panel);
vSpring = Spring.sum(vSpring, Spring.height(cancel));
vSpring = Spring.sum(vSpring, Spring.constant(10));
layout.putConstraint(SpringLayout.SOUTH, panel, vSpring, SpringLayout.NORTH, panel);
layout.putConstraint(SpringLayout.SOUTH, panel, vSpring, SpringLayout.NORTH, panel);
pack();
getRootPane().setOpaque(false);
getContentPane().setBackground (new Color (0, 0, 0));
setBackground (new Color (0, 0, 0));
getRootPane().setBorder(BorderFactory.createLineBorder(new Color(128, 128, 128)));
setLocationRelativeTo(getOwner());
setVisible(true);
}
|
8be71d53-da16-4894-9169-24aac52e2b62
| 4
|
void constructDefLab(){
defLab = new int[DIM*DIM][4];
for (int i=0;i<DIM*DIM;i++){
defLab[i][NORD] = -1;
defLab[i][SUD] = -1;
defLab[i][EST] = -1;
defLab[i][OUEST] = -1;
}
for (int i=0;i<ouvertures.size();i++){
if (ouvertures.get(i).s2.num-ouvertures.get(i).s1.num==1){
defLab[ouvertures.get(i).s1.num][EST] = ouvertures.get(i).s2.num;
defLab[ouvertures.get(i).s2.num][OUEST] = ouvertures.get(i).s1.num;
}
else if (ouvertures.get(i).s2.num-ouvertures.get(i).s1.num==DIM){
defLab[ouvertures.get(i).s1.num][SUD] = ouvertures.get(i).s2.num;
defLab[ouvertures.get(i).s2.num][NORD] = ouvertures.get(i).s1.num;
}
}
// Sortie random mais toujours cote droit du labyrinthe
defLab[this.sortie - 1][EST] = -2;
}
|
e834168a-e910-48f5-aeda-2f0db93fcf74
| 3
|
public char nextClean() throws JSONException {
for (;;) {
char c = this.next();
if (c == 0 || c > ' ') {
return c;
}
}
}
|
cf8d7240-2e30-4a8b-963e-461d8059d447
| 3
|
public Event(HashMap<String, String> hint) throws IllegalArgumentException {
final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
// Must throw errors if this is not an expected date format
formatter.setLenient(false);
this.eventName = hint.get("eventName");
this.venueId = hint.get("venueId");
this.eventId = hint.get("eventId");
try {
this.startTime =
hint.get("startTime") != null ? formatter
.parse(hint.get("startTime")) : null;
this.endTime =
hint.get("endTime") != null ? formatter.parse(hint.get("endTime"))
: null;
} catch (final ParseException e) {
throw new IllegalArgumentException(e);
}
}
|
91632bd2-afb5-4f94-b44e-62e7ecfa52d5
| 2
|
@Override
public Long validate(String fieldName, String value) throws ValidationException {
if (value == null) {
return null;
}
try {
return Long.parseLong(value);
} catch (NumberFormatException e) {
throw new ValidationException(fieldName, value, "not a valid long", e);
}
}
|
e8b3bf97-4957-4b76-b04f-19dab1652be2
| 2
|
public void singleOut(StringBuilder sb1, StringBuilder sb2)
throws IOException {
tableWrite(Prop.single_Head, sb1, sb2); // レコードはあるのでテーブルを書く
/* レコード出力 */
for (int i = 0; i < record[1][0].length; i++) {
sb2.append("<tr><td class=\"genre\">")
.append(record[1][2][i])
.append("</td><td class=\"year\">")
.append(record[1][3][i])
.append("</td><td>")
.append(record[1][4][i].equals(record[1][5][i]) ? ""
: replaceWithWikiLink(record[1][4][i]))
.append("</td><td class=\"title\">")
.append(replaceWithWikiLink(record[1][5][i]))
.append("</td><td class=\"name\"><span"
+ contentIn(record[1][7][i], record[1][5][i], 1)
+ ">")
.append(cleanCharName(getClearTitle(record[1][5][i]),
replaceWithWikiLink(record[1][6][i])))
.append("</span></td><tr>");
}
/* レコード出力終了 */
tableWrite(Prop.foot, sb1, sb2); // テーブルを完成させてメソッド終了
}
|
deec44d0-3183-40d2-9649-0c39efb99266
| 8
|
public void parse() {
parseIndex = 0;
//Split into words
parsingWords = originalString.split(" ");
//The first word is the first word
boolean firstWordInSentence = true;
//A flag for the ending word in a sentence
boolean endingWord = false;
//Currently building a term
for (; parseIndex < parsingWords.length; parseIndex++) {
//Get the next word to be checked
String s = parsingWords[parseIndex];
//Skip empty words
if (s.length() == 0) {
continue;
}
if (wordEndsSentence(s)) {
System.out.println("DEBUG: \"" + s + "\" is an ending word.");
endingWord = true;
}
//Add the full term if it is a term
if (!firstWordInSentence && wordBeginsWithCapital(s) && isTerm(s)) {
currentTerms.put(buildTerm(), Boolean.TRUE);
currentNonTerms.add(new Word(s, firstWordInSentence, endingWord));
//Otherwise add to the non-terms
} else {
currentNonTerms.add(new Word(s, firstWordInSentence, endingWord));
}
//If this is the first word
if (firstWordInSentence) {
System.out.println("DEBUG: \"" + s + "\" is an starting word.");
//Unless this is a single word sentence, the next word shouldn't
//also be the first word in a sentence
firstWordInSentence = false;
}
//If this is the ending word
if (endingWord) {
//The next word shouldn't default to an end word
endingWord = false;
//The next word is definitely a first word, though
firstWordInSentence = true;
}
}
}
|
aa53692d-18f6-4698-b32e-1af919634676
| 1
|
static void gameloop() {
int i = 1;
do {
round(i);
i++;
} while (askContinue());
}
|
9fb37c72-4873-4c4e-8f15-49a26d59b07d
| 6
|
public Song getLightSong(Song currentSong, String userId) {
Song lightSong = new Song(currentSong.getSongId(),
currentSong.getTitle(), currentSong.getArtist(),
currentSong.getAlbum(),currentSong.getOwnerId(), currentSong.getTags(),
currentSong.getRightsByCategory());
try {
ArrayList<String> categoryList =
ApiProfileImpl.getApiProfile().getCategoriesNameByUserId(userId);
Rights localRights = new Rights(true, true, true, true);
for (String categoryName : categoryList) {
Rights r = currentSong.getRightsByCategory().get(categoryName);
if (!r.getcanComment()) {
r.setcanComment(false);
}
if (!r.getcanPlay()) {
r.setcanPlay(false);
}
if (!r.getcanRate()) {
r.setcanRate(false);
}
if (!r.getcanReadInfo()) {
r.setcanReadInfo(false);
}
}
} catch (ProfileExceptions e) {
System.out.println("Can't get categoryList from UserId");
}
return lightSong;
}
|
cb2f3613-fafd-49f0-925c-9c7581ec4cba
| 5
|
protected boolean isThisKey(String str) {
boolean result = false;
if (str != null) {
int eqIndex = str.indexOf("=");
result = (str.startsWith("-") && str.substring(1, 2).equals(shortKey()))
|| (str.startsWith("--") && str.substring(2, eqIndex == -1?str.length():eqIndex).equals(fullKey()));
}
return result;
}
|
a5a06c57-9428-4309-b8ab-232741a32c71
| 1
|
public byte getByte(Object key) {
Number n = get(key);
if (n == null) {
return (byte) 0;
}
return n.byteValue();
}
|
cbc89e8e-158e-41c8-8802-fe9413c8be78
| 9
|
@Override
public double[] updatePlanes(ArrayList<Plane> planes, int round, double[] bearings) {
logger.info(round + " "+ planes.get(1).getLocation());
for(int i = 0; i < planes.size(); i++) {
if (planes.get(i).getLocation().distance(planes.get(i).getDestination())<=2) {
} else if(dynamicPlanes.contains(i) && round > 0 && bearings[i]!=-2) {
double bear = goGreedy(planes, i, round);
if(bear!=-1)
bearings[i]=bear;
}
else if( bearings[i] == -2) {}
else if (round < offsets[i]+1 ) {} //plane hasn't taken off yet
else if (round >= allPlaneLocs[i].size()+offsets[i]+1) {} //plane has landed
else {
bearings[i] = allPlaneLocs[i].getBearingAt(round-offsets[i]-1);
} //plane is flying
}
return bearings;
}
|
5c2a8252-05df-41da-8243-8f3759e9b0f3
| 3
|
public void tick() {
if (LAND.size()<maxSize) {
population+=1+population*owner.growthRate/100;
if (population>LAND.size()*owner.populationDensity) {
expand();
}
}
if (population>maxPopulation)
population=maxPopulation;
}
|
d78cbec4-3566-4f6e-afff-8eb800025d29
| 8
|
public ClassRegistry(String s, String as[], String s1)
{
super(as.length);
version = s;
classesToRegister = as;
baseClassName = s1;
Class class1 = null;
try
{
class1 = Class.forName(s1);
}
catch(ClassNotFoundException classnotfoundexception)
{
throw new UserError("Could not find base class \"" + s1 + "\"!", classnotfoundexception);
}
for(int i = as.length; --i >= 0;)
{
Class class2;
try
{
class2 = Class.forName(as[i]);
}
catch(ClassNotFoundException classnotfoundexception1)
{
throw new UserError("\"" + as[i] + "\" is missing from your classpath. Cannot initialize registry.", classnotfoundexception1);
}
if(!class1.isAssignableFrom(class2))
throw new DeveloperError("Developer has incorrectly specified \"" + as[i] + "\" as a registrable class.");
Field field = null;
if(class2 != null)
try
{
field = class2.getDeclaredField("label");
}
catch(NoSuchFieldException nosuchfieldexception)
{
throw new DeveloperError("Unlikely error: \"" + as[i] + "\" is missing label field!");
}
else
throw new DeveloperError("Failed to get processor \"" + as[i] + "\"");
String s2 = null;
try
{
s2 = (String)field.get(null);
}
catch(IllegalAccessException illegalaccessexception)
{
throw new DeveloperError("Label field for \"" + as[i] + "\" is not accessible!");
}
if(s2 != null)
put(s2, class2);
else
throw new DeveloperError("Tried to register class with null label!");
}
}
|
a498a417-3eaa-4ef7-91f2-cf4966d6a860
| 0
|
public void go()
{
frame = new Frame("Complex Layout !");
b1 = new Button("b1");
b2 = new Button("b2");
frame.add(b1,BorderLayout.WEST);
frame.add(b2,BorderLayout.CENTER);
panel = new Panel(); //默认为FlowLayout
b3 = new Button("b3");
b4 = new Button("b4");
panel.add(b3);
panel.add(b4);
frame.add(panel,BorderLayout.NORTH);
frame.setSize(200,200);
// frame.pack();
frame.setVisible(true);
}
|
170741d7-c68a-49ca-a7f5-bd9ed2076e5b
| 4
|
public static List<String> expandWithThesaurus(String node)
throws JSONException {
List<String> resultsList = new ArrayList<String>();
List<String> expandedNodes = new ArrayList<String>();
List<String> expandedTerms = new ArrayList<String>();
List<String> narrower = searchNarrower(node);
List<String> toExpand = narrower;
expandedNodes.add(node);
expandedNodes.addAll(toExpand);
List<String> queryList = toExpand;
// List of concept nodes are expanded into their narrower nodes
for (int i = 1; i <= 10; i++) {
if (queryList.size() > 0) {
for (int a = 0; a < queryList.size(); a++) {
resultsList.addAll(searchNarrower(queryList.get(a)));
}
} else {
break;
}
queryList.clear();
queryList.addAll(resultsList);
expandedNodes.addAll(resultsList);
resultsList.clear();
}
AuxiliaryMethods.removeDuplicates(expandedNodes);
// Here we extract the labeled nodes corresponding for each concept
// node and the preferred and alternative terms of the labeled nodes
for (int idx = 0; idx < expandedNodes.size(); idx++) {
List<String> expanded = extractTerms2(getEnglishPreferred(expandedNodes
.get(idx)));
expandedTerms.addAll(expanded);
}
AuxiliaryMethods.removeDuplicates(expandedTerms);
return expandedTerms;
}
|
fbb5419d-700e-4aa0-a0a8-642c0d544548
| 8
|
@EventHandler
public void onPluginMessage(PluginMessageEvent event){
if (event.getTag().equals("BTProxy") && event.getSender() instanceof Server) {
ByteArrayInputStream stream = new ByteArrayInputStream(event.getData());
DataInputStream input = new DataInputStream(stream);
// Important message debugging (can be toggled live)
if (plugin.isDebug()) {
String data = plugin.dumpPacket(event.getData());
plugin.DebugMsg("DEBUG received {BTProxy}: " + data);
}
// Handle the request
String action = "<empty>";
try {
action = input.readUTF();
if (action.equals("TeleportToPlayer")) {
// Parameters: SrcPlayer, DestPlayer
plugin.LogMsg("Processing TeleportToPlayer request...");
String s = input.readUTF();
String d = input.readUTF();
ProxiedPlayer sp = plugin.getProxy().getPlayer(s);
ProxiedPlayer dp = plugin.getProxy().getPlayer(d);
if (sp != null) {
if (dp != null) {
// Recipient is online, commence teleport!
plugin.TeleportPlayerToPlayer(sp, dp);
} else {
// Recipient player is not online
plugin.WarnMsg("Player " + d + " is not online.");
}
} else {
plugin.ErrorMsg(action + " request from unknown player " + d + "!!");
}
}
else if (action.equals("TeleportToLocation")) {
// Parameters: SrcPlayer, Server, World, X, Y, Z, Y, P
String s = input.readUTF();
ProxiedPlayer sp = plugin.getProxy().getPlayer(s);
String server = input.readUTF();
String world = input.readUTF();
Double x = Double.valueOf(input.readUTF());
Double y = Double.valueOf(input.readUTF());
Double z = Double.valueOf(input.readUTF());
Float yaw = Float.valueOf(input.readUTF());
Float pitch = Float.valueOf(input.readUTF());
Location loc = new Location(server, world, x, y, z, yaw, pitch);
plugin.TeleportPlayerToLocation(sp, loc);
}
else {
plugin.WarnMsg("Unknown action received: " + action);
}
}
catch(IOException e) {
plugin.ErrorMsg("Unexpected failure during message read!");
plugin.ErrorMsg("Requested action was: " + action);
e.printStackTrace();
}
}
}
|
480ff27a-801e-4b55-a201-5f131e950b0f
| 2
|
public void printList() {
System.out.println("print adjacency list size here : " + Canvas.coordListSize);
for (int i=0; i<Canvas.coordListSize; i++) {
System.out.print(i + " ");
for (int j=0; j<adj[i].size(); j++) {
System.out.print(adj[i].get(j) + " ");
}
System.out.println();
// System.out.print(adj[i].get(0));
}
}
|
815b68a5-258d-4451-a172-9eecd50cfe86
| 0
|
public int compareTo(Card card) {
return (convertRank() - card.convertRank());
}
|
f523465a-775d-4e9f-ab21-fab8ee490c19
| 5
|
public static TableModel fromCSP(CSProperties p, final int dim) {
List<String> dims = keysByMeta(p, "role", "dimension");
if (dims.isEmpty()) {
return null;
}
for (String d : dims) {
if (Integer.parseInt(p.get(d).toString()) == dim) {
final List<String> bounds = keysByMeta(p, "bound", d);
final List<Object> columns = new ArrayList<Object>(bounds.size());
for (String bound : bounds) {
columns.add(Conversions.convert(p.get(bound), double[].class));
}
return new AbstractTableModel() {
@Override
public int getRowCount() {
return dim;
}
@Override
public int getColumnCount() {
return bounds.size();
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return Array.get(columns.get(columnIndex), rowIndex);
}
@Override
public String getColumnName(int column) {
return bounds.get(column);
}
@Override
public Class<?> getColumnClass(int columnIndex) {
return Double.class;
}
};
}
}
return null;
}
|
9fc62c85-53fd-495d-bc77-4b05c8026325
| 6
|
@RequestMapping(value = "/save", method = RequestMethod.POST)
public ModelAndView save(@ModelAttribute("teamForm") Teams teamForm) {
List<Team> userInfo = teamForm.getTeamsInfo();
String playerInfo;
String userEnteredPlayerName = null;
int startIndex = 0, endIndex = 0;
List<playerUserInformation> playerInformation = new ArrayList<playerUserInformation>();
if (null != userInfo && userInfo.size() > 0) {
for (Team team : userInfo) {
if (team.isPlayingFlag()) {
playerInfo = team.getPlayersInfo();
userEnteredPlayerName = team.getUserInputPlayerName();
if (!playerInfo.contains(","))// only 1 player
{
playerInfo = playerInfo.replace('|', '-');
String[] splits = playerInfo.split("-");
playerInformation.add(new playerUserInformation(
splits[1], splits[2], splits[0]));
multiplePlayer.setPlayerInfo(playerInformation);
} else if (playerInfo.contains(","))// Multiple players
{
playerInfo = playerInfo.replace('|', '-');
playerInfo += ",";
startIndex = playerInfo.indexOf(userEnteredPlayerName);
playerInfo = playerInfo.substring(startIndex);
endIndex = playerInfo.indexOf(",");
playerInfo = playerInfo.substring(0, endIndex);
String[] splits = playerInfo.split("-");
playerInformation.add(new playerUserInformation(
splits[1], splits[2], splits[0]));
multiplePlayer.setPlayerInfo(playerInformation);
}
}
}
}
return new ModelAndView("playerInfo", "multiplePlayer", multiplePlayer);
}
|
efdf7c6b-1bc2-440c-971c-d29d5ff00ff1
| 2
|
public static void main(String[] args) {
char again;
int n;
double determinant;
do{
print("Enter the dimension of the matrix: ");
n = scan.nextInt();
double[][] matrix = new double[n][n];
print("\nEnter the matrix data:\n");
input(matrix);
determinant = det(matrix);
print("\nThe determinant is " + determinant);
print("\nWould you like to continue?(Y/N): ");
again = scan.next().charAt(0);
}while(again == 'y' || again == 'Y');
return;
}
|
a7768c31-578c-4010-bc3d-915dc7ecc96a
| 8
|
private boolean jj_3R_368() {
if (jj_scan_token(LB)) return true;
Token xsp;
xsp = jj_scanpos;
if (jj_3R_460()) {
jj_scanpos = xsp;
if (jj_3R_461()) {
jj_scanpos = xsp;
if (jj_3R_462()) {
jj_scanpos = xsp;
if (jj_3R_463()) return true;
}
}
}
while (true) {
xsp = jj_scanpos;
if (jj_3R_464()) { jj_scanpos = xsp; break; }
}
if (jj_scan_token(RB)) return true;
return false;
}
|
59043ec6-88c3-4b51-b43b-0f371436de18
| 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(SubmitForms.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(SubmitForms.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(SubmitForms.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(SubmitForms.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 SubmitForms().setVisible(true);
}
});
}
|
1660fb6e-99c1-419d-903c-6c48a5f323dc
| 8
|
@Override
public void run() {
try {
InputStream input = clientSocket.getInputStream();
OutputStream output = clientSocket.getOutputStream();
byte[] requestData = new byte[8192];
for (int i = 0; i < 8192; i++) {
int inByte = input.read();
if (inByte == 10) { // LF (ASCII = 10) signifies end of request-line.
break;
}
if (inByte == -1) { // End of stream.
/*
* TODO: Error handling for wrong request, since there was not LF.
*/
break;
}
requestData[i] = (byte) (inByte & 0xFF);
}
// InputStream is now at headers.
RequestLine request;
try {
request = ServerUtil.parseRequest(requestData);
} catch (IllegalArgumentException e) {
closeConnection();
return;
}
if (!request.getURI().exists() || request.getURI().isDirectory()) {
/*
* Return a File not Found error.
*/
closeConnection();
}
if (request.getMethod() == METHOD.GET) {
RequestHandler.handleGet(request, output);
}
closeConnection();
} catch (IOException e) {
e.printStackTrace();
}
}
|
de834e64-57c3-4f20-9ddd-74bcff307794
| 2
|
public byte[] getRange(int from,int to) {
if((from < 0)||(to > this.index))
throw new IndexOutOfBoundsException("AutoAllocatingByteBuffer.get() called for invalid buffer range");
return Arrays.copyOfRange(buf, from, to);
}
|
c2489d79-ddd9-4d04-8d7f-62a86cc69345
| 5
|
@SuppressWarnings({ "unchecked", "unused" })
@ApiMethod(name = "listMessages")
public CollectionResponse<MessageData> listMessages(
@Nullable @Named("cursor") String cursorString,
@Nullable @Named("limit") Integer limit) {
EntityManager mgr = null;
Cursor cursor = null;
List<MessageData> execute = null;
try {
mgr = getEntityManager();
// query for messages, newest message first
Query query = mgr
.createQuery("select from MessageData as MessageData order by timestamp desc");
if (cursorString != null && cursorString != "") {
cursor = Cursor.fromWebSafeString(cursorString);
query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
}
if (limit != null) {
query.setFirstResult(0);
query.setMaxResults(limit);
}
execute = (List<MessageData>) query.getResultList();
cursor = JPACursorHelper.getCursor(execute);
if (cursor != null)
cursorString = cursor.toWebSafeString();
// Tight loop for fetching all entities from datastore and accomodate
// for lazy fetch.
for (MessageData obj : execute) {
;
}
} finally {
mgr.close();
}
return CollectionResponse.<MessageData> builder().setItems(execute)
.setNextPageToken(cursorString).build();
}
|
169e1113-b79e-474a-bd3a-3d7ddfdfd896
| 7
|
public static void connecJambtoDoor(CABot3Net objRec){
int jambOffset = 2;
int doorOffset = 3;
int netSize =objRec.getInputSize();
int cols = objRec.getCols();
int row;
int toRow;
int jambIndex;
int doorIndex;
double weight = 0.9;
for(int neuron=0; neuron<netSize; neuron++){
if(neuron%5!=0){ //skip the inhibitory ones}
row = neuron/cols;
if(row%10>4){//bottom half of assembly
toRow = row;}
else{
toRow= row+5;
}
int col = neuron%cols;
jambIndex=(jambOffset*netSize+neuron);
if(col<20){ //if on LH vis field, add connections to the right
for(int d = col; d<cols; d=d+10){
doorIndex=(doorOffset*netSize+toRow*cols+d);
objRec.neurons[jambIndex].addConnection(objRec.neurons[doorIndex], weight);
}
}
else if(col>30){
for(int d =col; d>0; d=d-10){ //of on RH vis field, add connections to the left
doorIndex=(doorOffset*netSize+toRow*cols+d);
objRec.neurons[jambIndex].addConnection(objRec.neurons[doorIndex], weight);
}
}
}
}
}
|
4345a384-f7cc-48d5-9498-37107aa6c032
| 0
|
public CtrlPraticiens getCtrl() {
return ctrlP;
}
|
ebd134d9-413a-4504-b13e-66cfe8bd5288
| 6
|
public PrimitiveStructure getPrimitiveChild( boolean strict ) {
if( strict && getChildren().isEmpty() ) {
throw new RuntimeException(getType() + " float data not specified.");
}
if( strict && getChildren().size() > 1 ) {
throw new RuntimeException(getType() + " has too many child structures.");
}
for( BaseStructure struct : getChildren() ) {
if( struct instanceof PrimitiveStructure ) {
return (PrimitiveStructure)struct;
}
}
throw new RuntimeException(getType() + " has no primitive children.");
}
|
b966c274-a6c8-4e72-8ce0-baa51847aa91
| 4
|
public void actualiza() {
//Determina el tiempo que ha transcurrido desde que el Applet inicio su ejecución
long tiempoTranscurrido = System.currentTimeMillis() - tiempoActual;
//Guarda el tiempo actual
tiempoActual += tiempoTranscurrido;
if (canasta.getMoveLeft()) {
canasta.setPosX(canasta.getPosX() - 4);
}
if (canasta.getMoveRight()) {
canasta.setPosX(canasta.getPosX() + 4);
}
pelota.avanza();
if (entrando) {
pelota.setPosX(canasta.getPosX() + canasta.getAncho() / 2 - pelota.getAncho() / 2);
}
//Actualiza la animación en base al tiempo transcurrido
canasta.actualiza(tiempoTranscurrido);
if (pelota.getMov()) {
pelota.actualiza(tiempoTranscurrido);
}
}
|
54c165c1-f0aa-4e0a-a870-338504b45201
| 5
|
public int getColumnIndex(String columnVariableName){
for(Class<?> c=classOfData; c!=null ; c=c.getSuperclass()) {
for(Field f : c.getDeclaredFields()) {
f.setAccessible(true);
Column column = f.getAnnotation(Column.class);
if(column!=null && f.getName().equals(columnVariableName)){
return column.index();
}
}
}
return -1;
}
|
77ee1aad-6d7a-42d9-9049-2563c6648898
| 7
|
public void gatherData() {
data = new HashMap<UnitType, Map<Location, Integer>>();
unitCount = new TypeCountMap<UnitType>();
for (Unit unit : getMyPlayer().getUnits()) {
UnitType type = unit.getType();
unitCount.incrementCount(type, 1);
Map<Location, Integer> unitMap = data.get(type);
if (unitMap == null) {
unitMap = new HashMap<Location, Integer>();
data.put(type, unitMap);
}
Location location = unit.getLocation();
if (location == null) {
logger.warning("Unit has null location: " + unit.toString());
} else if (location.getSettlement() != null) {
location = location.getSettlement();
} else if (unit.isInEurope()) {
location = getMyPlayer().getEurope();
} else if (location.getTile() != null) {
location = location.getTile();
}
Integer count = unitMap.get(location);
if (count == null) {
unitMap.put(location, 1);
} else {
unitMap.put(location, count + 1);
}
}
}
|
77b23aa3-b6a1-4998-8999-7f921a858d3a
| 9
|
public void paramFileProcess(){
try {
BufferedReader stream = getFileToRead(fileSet.getParamFile().toString());
String line;
while((line = stream.readLine())!=null){//reading everything line by line
char[] charLine = line.toCharArray();
for(int i =0;i<charLine.length;i++){
if(charLine[i]=='#' && i == 0){//comment
i = charLine.length;
line = "";
//break;
}
else if(charLine[i]=='#' && i!=0){//comment at a point in line kill comment
line = line.substring(0, i);
//processParamBuffer(line);
i = charLine.length;
}
}
if(!(line.length()==0)){
processParamBuffer(line);
}
}
stream.close();
if(!seeded){
System.out.println(String.format("coalescent seed: %d\n", -1 * random.seedRNG()));
}
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Error paramFileProcess" + e.getMessage() );
}
}
|
c939d283-b307-4301-b1c8-d9b0c27e95ae
| 1
|
private void compute_new_v()
{
// p is fully initialized from x1
//float[] p = _p;
// pp is fully initialized from p
//float[] pp = _pp;
//float[] new_v = _new_v;
//float[] new_v = new float[32]; // new V[0-15] and V[33-48] of Figure 3-A.2 in ISO DIS 11172-3
//float[] p = new float[16];
//float[] pp = new float[16];
/*
for (int i=31; i>=0; i--)
{
new_v[i] = 0.0f;
}
*/
float new_v0, new_v1, new_v2, new_v3, new_v4, new_v5, new_v6, new_v7, new_v8, new_v9;
float new_v10, new_v11, new_v12, new_v13, new_v14, new_v15, new_v16, new_v17, new_v18, new_v19;
float new_v20, new_v21, new_v22, new_v23, new_v24, new_v25, new_v26, new_v27, new_v28, new_v29;
float new_v30, new_v31;
new_v0 = new_v1 = new_v2 = new_v3 = new_v4 = new_v5 = new_v6 = new_v7 = new_v8 = new_v9 =
new_v10 = new_v11 = new_v12 = new_v13 = new_v14 = new_v15 = new_v16 = new_v17 = new_v18 = new_v19 =
new_v20 = new_v21 = new_v22 = new_v23 = new_v24 = new_v25 = new_v26 = new_v27 = new_v28 = new_v29 =
new_v30 = new_v31 = 0.0f;
// float[] new_v = new float[32]; // new V[0-15] and V[33-48] of Figure 3-A.2 in ISO DIS 11172-3
// float[] p = new float[16];
// float[] pp = new float[16];
float[] s = samples;
float s0 = s[0];
float s1 = s[1];
float s2 = s[2];
float s3 = s[3];
float s4 = s[4];
float s5 = s[5];
float s6 = s[6];
float s7 = s[7];
float s8 = s[8];
float s9 = s[9];
float s10 = s[10];
float s11 = s[11];
float s12 = s[12];
float s13 = s[13];
float s14 = s[14];
float s15 = s[15];
float s16 = s[16];
float s17 = s[17];
float s18 = s[18];
float s19 = s[19];
float s20 = s[20];
float s21 = s[21];
float s22 = s[22];
float s23 = s[23];
float s24 = s[24];
float s25 = s[25];
float s26 = s[26];
float s27 = s[27];
float s28 = s[28];
float s29 = s[29];
float s30 = s[30];
float s31 = s[31];
float p0 = s0 + s31;
float p1 = s1 + s30;
float p2 = s2 + s29;
float p3 = s3 + s28;
float p4 = s4 + s27;
float p5 = s5 + s26;
float p6 = s6 + s25;
float p7 = s7 + s24;
float p8 = s8 + s23;
float p9 = s9 + s22;
float p10 = s10 + s21;
float p11 = s11 + s20;
float p12 = s12 + s19;
float p13 = s13 + s18;
float p14 = s14 + s17;
float p15 = s15 + s16;
float pp0 = p0 + p15;
float pp1 = p1 + p14;
float pp2 = p2 + p13;
float pp3 = p3 + p12;
float pp4 = p4 + p11;
float pp5 = p5 + p10;
float pp6 = p6 + p9;
float pp7 = p7 + p8;
float pp8 = (p0 - p15) * cos1_32;
float pp9 = (p1 - p14) * cos3_32;
float pp10 = (p2 - p13) * cos5_32;
float pp11 = (p3 - p12) * cos7_32;
float pp12 = (p4 - p11) * cos9_32;
float pp13 = (p5 - p10) * cos11_32;
float pp14 = (p6 - p9) * cos13_32;
float pp15 = (p7 - p8) * cos15_32;
p0 = pp0 + pp7;
p1 = pp1 + pp6;
p2 = pp2 + pp5;
p3 = pp3 + pp4;
p4 = (pp0 - pp7) * cos1_16;
p5 = (pp1 - pp6) * cos3_16;
p6 = (pp2 - pp5) * cos5_16;
p7 = (pp3 - pp4) * cos7_16;
p8 = pp8 + pp15;
p9 = pp9 + pp14;
p10 = pp10 + pp13;
p11 = pp11 + pp12;
p12 = (pp8 - pp15) * cos1_16;
p13 = (pp9 - pp14) * cos3_16;
p14 = (pp10 - pp13) * cos5_16;
p15 = (pp11 - pp12) * cos7_16;
pp0 = p0 + p3;
pp1 = p1 + p2;
pp2 = (p0 - p3) * cos1_8;
pp3 = (p1 - p2) * cos3_8;
pp4 = p4 + p7;
pp5 = p5 + p6;
pp6 = (p4 - p7) * cos1_8;
pp7 = (p5 - p6) * cos3_8;
pp8 = p8 + p11;
pp9 = p9 + p10;
pp10 = (p8 - p11) * cos1_8;
pp11 = (p9 - p10) * cos3_8;
pp12 = p12 + p15;
pp13 = p13 + p14;
pp14 = (p12 - p15) * cos1_8;
pp15 = (p13 - p14) * cos3_8;
p0 = pp0 + pp1;
p1 = (pp0 - pp1) * cos1_4;
p2 = pp2 + pp3;
p3 = (pp2 - pp3) * cos1_4;
p4 = pp4 + pp5;
p5 = (pp4 - pp5) * cos1_4;
p6 = pp6 + pp7;
p7 = (pp6 - pp7) * cos1_4;
p8 = pp8 + pp9;
p9 = (pp8 - pp9) * cos1_4;
p10 = pp10 + pp11;
p11 = (pp10 - pp11) * cos1_4;
p12 = pp12 + pp13;
p13 = (pp12 - pp13) * cos1_4;
p14 = pp14 + pp15;
p15 = (pp14 - pp15) * cos1_4;
// this is pretty insane coding
float tmp1;
new_v19/*36-17*/ = -(new_v4 = (new_v12 = p7) + p5) - p6;
new_v27/*44-17*/ = -p6 - p7 - p4;
new_v6 = (new_v10 = (new_v14 = p15) + p11) + p13;
new_v17/*34-17*/ = -(new_v2 = p15 + p13 + p9) - p14;
new_v21/*38-17*/ = (tmp1 = -p14 - p15 - p10 - p11) - p13;
new_v29/*46-17*/ = -p14 - p15 - p12 - p8;
new_v25/*42-17*/ = tmp1 - p12;
new_v31/*48-17*/ = -p0;
new_v0 = p1;
new_v23/*40-17*/ = -(new_v8 = p3) - p2;
p0 = (s0 - s31) * cos1_64;
p1 = (s1 - s30) * cos3_64;
p2 = (s2 - s29) * cos5_64;
p3 = (s3 - s28) * cos7_64;
p4 = (s4 - s27) * cos9_64;
p5 = (s5 - s26) * cos11_64;
p6 = (s6 - s25) * cos13_64;
p7 = (s7 - s24) * cos15_64;
p8 = (s8 - s23) * cos17_64;
p9 = (s9 - s22) * cos19_64;
p10 = (s10 - s21) * cos21_64;
p11 = (s11 - s20) * cos23_64;
p12 = (s12 - s19) * cos25_64;
p13 = (s13 - s18) * cos27_64;
p14 = (s14 - s17) * cos29_64;
p15 = (s15 - s16) * cos31_64;
pp0 = p0 + p15;
pp1 = p1 + p14;
pp2 = p2 + p13;
pp3 = p3 + p12;
pp4 = p4 + p11;
pp5 = p5 + p10;
pp6 = p6 + p9;
pp7 = p7 + p8;
pp8 = (p0 - p15) * cos1_32;
pp9 = (p1 - p14) * cos3_32;
pp10 = (p2 - p13) * cos5_32;
pp11 = (p3 - p12) * cos7_32;
pp12 = (p4 - p11) * cos9_32;
pp13 = (p5 - p10) * cos11_32;
pp14 = (p6 - p9) * cos13_32;
pp15 = (p7 - p8) * cos15_32;
p0 = pp0 + pp7;
p1 = pp1 + pp6;
p2 = pp2 + pp5;
p3 = pp3 + pp4;
p4 = (pp0 - pp7) * cos1_16;
p5 = (pp1 - pp6) * cos3_16;
p6 = (pp2 - pp5) * cos5_16;
p7 = (pp3 - pp4) * cos7_16;
p8 = pp8 + pp15;
p9 = pp9 + pp14;
p10 = pp10 + pp13;
p11 = pp11 + pp12;
p12 = (pp8 - pp15) * cos1_16;
p13 = (pp9 - pp14) * cos3_16;
p14 = (pp10 - pp13) * cos5_16;
p15 = (pp11 - pp12) * cos7_16;
pp0 = p0 + p3;
pp1 = p1 + p2;
pp2 = (p0 - p3) * cos1_8;
pp3 = (p1 - p2) * cos3_8;
pp4 = p4 + p7;
pp5 = p5 + p6;
pp6 = (p4 - p7) * cos1_8;
pp7 = (p5 - p6) * cos3_8;
pp8 = p8 + p11;
pp9 = p9 + p10;
pp10 = (p8 - p11) * cos1_8;
pp11 = (p9 - p10) * cos3_8;
pp12 = p12 + p15;
pp13 = p13 + p14;
pp14 = (p12 - p15) * cos1_8;
pp15 = (p13 - p14) * cos3_8;
p0 = pp0 + pp1;
p1 = (pp0 - pp1) * cos1_4;
p2 = pp2 + pp3;
p3 = (pp2 - pp3) * cos1_4;
p4 = pp4 + pp5;
p5 = (pp4 - pp5) * cos1_4;
p6 = pp6 + pp7;
p7 = (pp6 - pp7) * cos1_4;
p8 = pp8 + pp9;
p9 = (pp8 - pp9) * cos1_4;
p10 = pp10 + pp11;
p11 = (pp10 - pp11) * cos1_4;
p12 = pp12 + pp13;
p13 = (pp12 - pp13) * cos1_4;
p14 = pp14 + pp15;
p15 = (pp14 - pp15) * cos1_4;
// manually doing something that a compiler should handle sucks
// coding like this is hard to read
float tmp2;
new_v5 = (new_v11 = (new_v13 = (new_v15 = p15) + p7) + p11)
+ p5 + p13;
new_v7 = (new_v9 = p15 + p11 + p3) + p13;
new_v16/*33-17*/ = -(new_v1 = (tmp1 = p13 + p15 + p9) + p1) - p14;
new_v18/*35-17*/ = -(new_v3 = tmp1 + p5 + p7) - p6 - p14;
new_v22/*39-17*/ = (tmp1 = -p10 - p11 - p14 - p15)
- p13 - p2 - p3;
new_v20/*37-17*/ = tmp1 - p13 - p5 - p6 - p7;
new_v24/*41-17*/ = tmp1 - p12 - p2 - p3;
new_v26/*43-17*/ = tmp1 - p12 - (tmp2 = p4 + p6 + p7);
new_v30/*47-17*/ = (tmp1 = -p8 - p12 - p14 - p15) - p0;
new_v28/*45-17*/ = tmp1 - tmp2;
// insert V[0-15] (== new_v[0-15]) into actual v:
// float[] x2 = actual_v + actual_write_pos;
float dest[] = actual_v;
int pos = actual_write_pos;
dest[0 + pos] = new_v0;
dest[16 + pos] = new_v1;
dest[32 + pos] = new_v2;
dest[48 + pos] = new_v3;
dest[64 + pos] = new_v4;
dest[80 + pos] = new_v5;
dest[96 + pos] = new_v6;
dest[112 + pos] = new_v7;
dest[128 + pos] = new_v8;
dest[144 + pos] = new_v9;
dest[160 + pos] = new_v10;
dest[176 + pos] = new_v11;
dest[192 + pos] = new_v12;
dest[208 + pos] = new_v13;
dest[224 + pos] = new_v14;
dest[240 + pos] = new_v15;
// V[16] is always 0.0:
dest[256 + pos] = 0.0f;
// insert V[17-31] (== -new_v[15-1]) into actual v:
dest[272 + pos] = -new_v15;
dest[288 + pos] = -new_v14;
dest[304 + pos] = -new_v13;
dest[320 + pos] = -new_v12;
dest[336 + pos] = -new_v11;
dest[352 + pos] = -new_v10;
dest[368 + pos] = -new_v9;
dest[384 + pos] = -new_v8;
dest[400 + pos] = -new_v7;
dest[416 + pos] = -new_v6;
dest[432 + pos] = -new_v5;
dest[448 + pos] = -new_v4;
dest[464 + pos] = -new_v3;
dest[480 + pos] = -new_v2;
dest[496 + pos] = -new_v1;
// insert V[32] (== -new_v[0]) into other v:
dest = (actual_v==v1) ? v2 : v1;
dest[0 + pos] = -new_v0;
// insert V[33-48] (== new_v[16-31]) into other v:
dest[16 + pos] = new_v16;
dest[32 + pos] = new_v17;
dest[48 + pos] = new_v18;
dest[64 + pos] = new_v19;
dest[80 + pos] = new_v20;
dest[96 + pos] = new_v21;
dest[112 + pos] = new_v22;
dest[128 + pos] = new_v23;
dest[144 + pos] = new_v24;
dest[160 + pos] = new_v25;
dest[176 + pos] = new_v26;
dest[192 + pos] = new_v27;
dest[208 + pos] = new_v28;
dest[224 + pos] = new_v29;
dest[240 + pos] = new_v30;
dest[256 + pos] = new_v31;
// insert V[49-63] (== new_v[30-16]) into other v:
dest[272 + pos] = new_v30;
dest[288 + pos] = new_v29;
dest[304 + pos] = new_v28;
dest[320 + pos] = new_v27;
dest[336 + pos] = new_v26;
dest[352 + pos] = new_v25;
dest[368 + pos] = new_v24;
dest[384 + pos] = new_v23;
dest[400 + pos] = new_v22;
dest[416 + pos] = new_v21;
dest[432 + pos] = new_v20;
dest[448 + pos] = new_v19;
dest[464 + pos] = new_v18;
dest[480 + pos] = new_v17;
dest[496 + pos] = new_v16;
/*
}
else
{
v1[0 + actual_write_pos] = -new_v0;
// insert V[33-48] (== new_v[16-31]) into other v:
v1[16 + actual_write_pos] = new_v16;
v1[32 + actual_write_pos] = new_v17;
v1[48 + actual_write_pos] = new_v18;
v1[64 + actual_write_pos] = new_v19;
v1[80 + actual_write_pos] = new_v20;
v1[96 + actual_write_pos] = new_v21;
v1[112 + actual_write_pos] = new_v22;
v1[128 + actual_write_pos] = new_v23;
v1[144 + actual_write_pos] = new_v24;
v1[160 + actual_write_pos] = new_v25;
v1[176 + actual_write_pos] = new_v26;
v1[192 + actual_write_pos] = new_v27;
v1[208 + actual_write_pos] = new_v28;
v1[224 + actual_write_pos] = new_v29;
v1[240 + actual_write_pos] = new_v30;
v1[256 + actual_write_pos] = new_v31;
// insert V[49-63] (== new_v[30-16]) into other v:
v1[272 + actual_write_pos] = new_v30;
v1[288 + actual_write_pos] = new_v29;
v1[304 + actual_write_pos] = new_v28;
v1[320 + actual_write_pos] = new_v27;
v1[336 + actual_write_pos] = new_v26;
v1[352 + actual_write_pos] = new_v25;
v1[368 + actual_write_pos] = new_v24;
v1[384 + actual_write_pos] = new_v23;
v1[400 + actual_write_pos] = new_v22;
v1[416 + actual_write_pos] = new_v21;
v1[432 + actual_write_pos] = new_v20;
v1[448 + actual_write_pos] = new_v19;
v1[464 + actual_write_pos] = new_v18;
v1[480 + actual_write_pos] = new_v17;
v1[496 + actual_write_pos] = new_v16;
}
*/
}
|
85d0d5a4-4f99-44e7-aee6-89c81e36bfff
| 4
|
List<Integer> getRow1(int rowIndex) {
List<Integer> res = new ArrayList<>();
if(rowIndex<=0){
res.add(1);
return res;
}
Integer[] arr = new Integer[rowIndex+1];
int i, j;
for(i=1, arr[0]=1; i<=rowIndex;++i) {
if(arr[i]==null){
arr[i] = 0;
}
for (j = i; j > 0; --j) {
System.out.println("i "+i+",j "+j);
arr[j] += arr[j - 1];
}
}
return Arrays.asList(arr);
}
|
e28ea7c4-171a-4ad4-b6a2-102e67758a55
| 0
|
private void printTime(double time) {
System.out.println("Average time taken: " + time + " ms");
}
|
2b791c73-59e0-4d80-a4dd-8bb6451b4998
| 1
|
@Override
public Position<T> root() throws EmptyTreeException {
if (root == null)
throw new EmptyTreeException("Empty tree");
return root;
}
|
5d671792-b4f9-4045-a866-7ad39e49e27b
| 0
|
public Query<T> take(int count)
{
return new Query<T>(new TakeIterable(this._source, count));
}
|
f2470f18-2f85-4b6d-8251-e969ad6ad810
| 1
|
public ErrorHandler getErrorHandler() {
if(errorHandler==null)
errorHandler = createErrorHandler();
return errorHandler;
}
|
bbd8438e-f634-460d-9fdc-bd2b88802813
| 6
|
public List<GrupoDTO> getAllGrupos(String semestre){
List<GrupoDTO> grupos = new ArrayList<GrupoDTO>();
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
try {
con = EscolarConnectionFactory
.getInstance().getConnection();
String sql = "select id_grupo, clave, descripcion from grupos where semestre=? order by clave, descripcion";
pst = con.prepareStatement(sql);
pst.setString(1, semestre);
rs = pst.executeQuery();
while (rs.next()) {
GrupoDTO grupo = new GrupoDTO();
grupo.setIdGrupo(rs.getInt("id_grupo"));
grupo.setClave(rs.getString("clave"));
grupo.setDescripcion(rs.getString("descripcion"));
grupos.add(grupo);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (con != null)
con.close();
if (pst != null)
pst.close();
if (rs != null)
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return grupos;
}
|
0464754b-9712-4f77-aedb-6818c9968280
| 8
|
public static boolean isSatisfied(int[][] grid, int i, int j, int threshold)
{
int solidarity = 0;
//Sets Upper and Lower Bounds for the area around our given point
int iLB = i - 1;
int iUB = i + 1;
int jLB = j - 1;
int jUB = j + 1;
//Accounting for open spaces
//Taking border cases into account for i-coord
if (i == 0)
{
iLB = i;
}
if (i == grid.length - 1)
{
iUB = i;
}
//Border cases for j-coord
if (j == 0)
{
jLB = j;
}
if (j == grid[0].length - 1)
{
jUB = j;
}
for(int x = iLB; x <= iUB; x++)
{
for(int y = jLB; y <= jUB; y++)
{
if(grid[i][j] == grid[x][y])
{
solidarity++;
}
}
}
//Determining satisfaction
if(solidarity <= threshold)
{
return false;
}
return true;
}
|
6543afaf-7621-44c7-8e52-995b7e3b49e4
| 3
|
public boolean interact(Level level, int xt, int yt, Player player, Item item, int attackDir) {
if (item instanceof ToolItem) {
ToolItem tool = (ToolItem) item;
if (tool.type == ToolType.shovel) {
if (player.payStamina(4 - tool.level)) {
level.setTile(xt, yt, Tile.dirt, 0);
return true;
}
}
}
return false;
}
|
4a86b2b4-95db-49f6-84aa-9008b7e4aa1a
| 4
|
@Override
public void actionPerformed(ActionEvent e) {
Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard()
.getContents(null);
String text = new String();
if ((t != null) && (t.isDataFlavorSupported(DataFlavor.stringFlavor))) {
try {
text = (String) t.getTransferData(DataFlavor.stringFlavor);
} catch (UnsupportedFlavorException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
}
tabManager.InsertText(text);
}
|
82651eed-2fe7-4ed5-93d0-33667008402e
| 5
|
public static void main(String[] args){
Scanner keyboard = new Scanner(System.in);
int button;
button = keyboard.nextInt();
switch(button){
case 1: System.out.println("cola is served");
break;
case 2: System.out.println("lemonade is served"+',');
break;
case 3: System.out.println("water is served"+',');
break;
case 6: System.out.println("cola and lemonade is served"+',');
break;
case 9: System.out.println("refund");
break;
default:System.out.println("No such beverage");
break;
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.