method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
5355217e-e1ab-464b-b786-b743c072d401 | 6 | @Override
public void mouseClicked(MouseEvent e)
{
JButton clicked = (JButton)e.getComponent();
if (clicked.equals(this.addButton))
{
List<Object> rowColumns = this.controlsController.addCurrentElement();
this.builtController.addRow(rowColumns);
if (!... |
89c7767c-9c3f-40d6-99ef-70333fff98bb | 7 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
final MOB target=this.getTarget(mob,commands,givenTarget);
if(target==null)
return false;
if(!super.invoke(mob,commands,givenTarget,auto,asLevel))
return false;
boolean success=proficienc... |
c1e45f8f-efb1-429b-8771-dd8d354be740 | 9 | * @param gId the id of the group whose contents are desired
* @return the contents of the group in XML
* @throws MVDException if the group was not found
*/
public String getContentsForGroup( int indent, short gId )
throws MVDException
{
StringBuffer sb = new StringBuffer();
// write group start tag
for... |
e2e70f4d-f116-43bc-b05d-a013e571bad7 | 9 | @Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{
if (this.actionOnUpgrade != null)
{
try
{
/*
* Use reflection to get and instantiate the SQLite Database, the old verion number, and the new
* version number, as defined by the user in the Runnable pa... |
7488afb9-0510-447b-95bb-5bc0b319d2c0 | 2 | RoomScheme generateRandomScheme(int days, int classTimes, Subject[] s){
Subject[][] sub = new Subject[days][classTimes];
RoomScheme r;
for(int i=0; i<days; i++){
for(int j=0; j<classTimes; j++){
sub[i][j] = s[(int)(Math.random()*(s.length))];
}
... |
f2c1c1e9-711c-441a-a004-9665bad99436 | 4 | public static List<Paiva> haePaivat() throws NamingException, SQLException {
Yhteys tietokanta = new Yhteys();
Connection yhteys = tietokanta.getYhteys();
String sql = "SELECT * FROM Paiva";
PreparedStatement kysely = yhteys.prepareStatement(sql);
ResultSet rs = kysely.executeQue... |
f7280c52-d55b-49b4-9fac-a0ba9be4d9fc | 5 | public void onClose(int round){
boolean stop = false;
synchronized (syncIncr) {
if (!shouldDecrease || round == super.getNumberOfRounds()) {
stop = true;
} else {
shouldDecrease = false;
double decrease = ((super.getMaxPrice() - super.getMinPrice())
/ (super.getNumberOfRounds() - 1));
s... |
cbbaa3b2-14cb-416c-b87d-a608ea54f519 | 1 | public TreeNode reValClone(TreeNode node,int offset){
if(node == null)
return null;
TreeNode newNode = new TreeNode(node.val + offset);
newNode.left = reValClone(node.left,offset);
newNode.right = reValClone(node.right,offset);
return newNode;
} |
4d62150d-0c63-4fd8-92f3-3e35fff935c1 | 1 | public void lower(int x, int y) {
_map[y][x] -= 256;
if (_map[y][x] < 0) _map[y][x] = 0;
} |
2a989edb-6f20-4245-b953-87448e2239b3 | 4 | @Override
public boolean move(int row, int col) {
if (Math.abs(this.row - row) == 1 && Math.abs(this.col - col) == 2
|| Math.abs(this.col - col) == 1
&& Math.abs(this.row - row) == 2) {
this.col = col;
this.row = row;
return true;
}
return false;
} |
d08ff1cf-a7b1-4a2b-ab3d-05ab38abb17d | 3 | public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
File file = new File("C:/1.txt");
BufferedReader in = new BufferedReader(new FileReader(file));
String line;
while ((line = in.readLine()) != null) {
if (line.length() <= 55)
System.out.p... |
353a6c2f-1588-4bb1-bb84-087e26dc3e43 | 0 | public int[] toArray() {
int[] result = new int[size];
System.arraycopy(data, 0, result, 0, size);
return result;
} |
7cdad1b7-e4dd-4622-8bda-7cd195433574 | 0 | @Override
public void applyTemporaryToCurrent() {cur = tmp;} |
517ca19c-5906-4d09-9f46-415eb70999a1 | 7 | public boolean canGoto(float posX, float posY)
{
if(!noclip)
for(int x1 = 0;x1<w;x1++)
{
for(int y1 = 0;y1<h;y1++)
{
float px = ((float)x1+posX)/Block.BLOCK_WIDTH;
float py = ((float)y1+posY)/Block.BLOCK_HEIGHT;
int gridX = (int) (px >= 0 ? Math.floor(px) : Math.floor(px... |
f730a94e-26dc-463c-9f6f-4f8396ec14b8 | 7 | private void updatePosteriorDistribution() {
for (int d = 0; d < param.D; ++d) {
for (int t = 0; t < param.T; ++t) {
thetasum[d][t] += (ndt[d][t] + param.alpha)
/ (ndsum[d] + tAlpha);
}
}
for (int t = 0; t < param.T; ++t) {
for (int ms = 0; ms < MS; ++ms) {
phisum[t][ms] += (nts[t][ms] + p... |
0adb4952-0e25-47c3-b6be-f1a7ed67304a | 8 | public static void main(String[] args) {
DocumentBuilderFactory builderFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = null;
try {
builder = builderFactory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
Document docume... |
1158840f-4297-4605-a586-26a13774ff63 | 1 | private void setAngle(double angle) {
this.angle = angle % 360.0;
if (this.angle < 0)
this.angle += 360.0;
} |
799746f6-5f04-4be7-a572-e7a4abd5bb91 | 3 | @Override
public void run() {
String msg;
try {
while ((msg = in.readLine()) != null) {
if(!msg.equals("")){
this.respuesta=msg;
}
}
} catch (IOException e) {
... |
4361664e-ca95-4c35-a1b0-0e09648f8b1e | 8 | public static ServerPerformanceData instanceFromResultSet(ResultSet rs, MineJMX plugin) throws SQLException {
ServerPerformanceData sd = new ServerPerformanceData(plugin) ;
String data = rs.getString("data") ;
if(data.length() <=0 ) {
return sd ;
}
String[] datas = data.split(",") ;
for(String s : dat... |
1111a193-d4b7-43b1-b6c5-f4a4bdfb77b9 | 8 | public void read() {
StringBuilder builder;
int read;
builder = new StringBuilder();
do {
try {
read = System.in.read();
} catch (IOException e) {
read = 0;
}
if (read >= 0 && read != '\r' && read != '\n') {
builder.append((char) read);
}
} while (read != '\r' && read != '\n' && rea... |
546bc1f0-6ab2-415c-839d-cc46410c6853 | 3 | public List<Field> findAllAnnotatedFields(Class<? extends Annotation> annotationClass) {
List<Field> annotatedFields = new LinkedList<Field>();
for(Field field : getFields()) {
if(field.isAnnotationPresent(annotationClass)) {
annotatedFields.add(field);
}
}
getFieldDetailStore().addAllFields(ann... |
efe11e41-9c5e-4730-87a3-ef93f364e9c9 | 2 | public void initTable(ITable table) {
if(_table != null) {
_table.removeTableListener(_listener);
}
super.initTable(table);
_table = table;
if(_table != null) {
table.addTableListener(_listener);
}
} |
1fd1ad78-1223-438d-add2-ec390b06e602 | 6 | public static int dehexchar(char c) {
if (c >= '0' && c <= '9') {
return c - '0';
}
if (c >= 'A' && c <= 'F') {
return c - ('A' - 10);
}
if (c >= 'a' && c <= 'f') {
return c - ('a' - 10);
}
return -1;
} |
d4766a74-33a9-4c23-a318-07824658860c | 4 | public void checkType(Symtab st) {
exp1.setScope(scope);
exp1.checkType(st);
exp2.setScope(scope);
exp2.checkType(st);
if (!exp1.getType(st).equals("int")
&& !exp1.getType(st).equals("decimal")) {
Main.error("type error in div!");
}
if (!exp2.getType(st).equals("int")
&& !exp2.getType(st).equal... |
42214cba-6a56-43fa-a7aa-e1cdad71219b | 7 | @Override
public void onPrivateMessage(PrivateMessageEvent e) {
final String command = RUtils.getFirstWord(e.getMessage());
if (!command.equalsIgnoreCase("part")) return;
final User u = e.getUser();
if (!PermissionHandler.isAuthedOrAdmin(u.getNick(), u.getServer())) {
e.r... |
1fcb8163-c021-4e5d-8046-cedbc71f711f | 9 | private int validateInsert()
{
try
{
String cid;
String cpassword;
String cname;
String caddr;
String cphone;
if (custID.getText().trim().length() != 0)
{
cid = custID.getText().trim();
}
else
{
return VALIDATIONERROR;
}
if (String.valueOf(password.getPassword())... |
c52c3da0-925f-44bb-9283-a5acb030fafe | 6 | public static HashMap<String, Integer> getCountMap(List<File> fastaFiles) throws Exception
{
HashMap<String, Integer> map = new HashMap<String, Integer>();
for( File f : fastaFiles)
{
BufferedReader reader = new BufferedReader(new FileReader(f));
String nextLine = reader.readLine();
while ( n... |
ee2cda51-a91f-4a81-abdf-0eb717a05b4f | 1 | private static byte[] toCstr(String str) {
int length = str.length();
byte[] result = new byte[length + 1];
for (int i = 0; i < length; i++) {
result[i] = (byte) str.charAt(i);
}
result[length] = 0;
return result;
} |
cd03593d-cab7-45b9-b9db-c7f8be92d536 | 9 | @Override
public boolean processButtonClick(int interfaceId, int componentId,
int slotId, int packetId) {
if (interfaceId == 374) {
switch (componentId) {
case 5:
resetOrb();
player.setNextWorldTile(new WorldTile(LOBBY_TELEPORT));
break;
case 11:
case 12:
case 13:
case 14:
case 15... |
3fee4a9a-aae4-46f6-9af8-dad7e2d79944 | 0 | public int GetOutputBuffer()
{
return outputBuffer;
} |
d63f92eb-0faa-4062-9862-928842d52646 | 8 | public node[] recombExecute(double gen,int popIndex, doublePointer location){
/* pick location */
double loc;
double temp;
double temp1;
recombStructure temprecomb = recombs;
double rr = 0;
double end;
/* choosing location.. */
temp1 = random.randomDouble();
temp = (... |
aabdf08b-ed51-4031-8c51-d4809cc9e7a8 | 3 | public byte [] get_frame_data(int n){
byte [] frame_info = mpf[n].get_info();
byte [] frame_data = mpf[n].get_main_data();
byte [] anc_data = mpf[n].get_anc_data();
byte [] reserve = mpf[n].get_reserve();
int len = mpf[n].get_framesize();
b... |
3a911220-c87d-4281-ad3d-7d395c07e581 | 3 | private void getLatestThreads(Map<String, Object> jsonrpc2Params) throws Exception {
Map<String, Object> params = getParams(jsonrpc2Params,
new NullableExtendedParam(Constants.Param.Name.LIMIT, true));
Integer limit = (Integer) params.get(Constants.Param.Name.LIMIT);
if(limit ==... |
45e66183-124c-4e92-940d-26b063bf79b9 | 3 | public boolean matchesAddress(String address, int port) {
if(address == null)
return (clientAddress == null && port == clientPort);
return (address.equals(clientAddress) && port == clientPort);
} |
3caf5969-9f15-4a1d-8f6b-c40a3d189c2f | 2 | public void startAlarms() throws InterruptedException {
a.setHigh(Integer.parseInt(maxValue.getSelectedItem().toString()));
a.setLow(Integer.parseInt(minValue.getSelectedItem().toString()));
dataShare.setAlarm(a);
int temp = dataShare.getBPM();
if (temp > 0) {
a.check... |
7985c4d8-fbda-47a7-ae7d-1115cc015db7 | 9 | @Override
public String execute(String s) {
if (s.matches("PRENDRE.* (ROCHE|CLIFF)") && utiliserLampe && !pritRoche) {
pritRoche = true;
InventoryManager.getInstance().addItem("Cliff");
return "Vous prenez la roche.";
} else if (s.matches("(UTILISER|ALLUMER).* LAMPE DE POCHE")) {
utiliserLampe = true;
... |
be81fa83-3f70-45d1-aa3d-54f7f2df73bb | 5 | private void consumeFutureUninterruptible( Future<?> f ) {
try {
boolean interrupted = false;
while ( true ) {
try {
f.get();
break;
} catch ( InterruptedException e ) {
interrupted = true;
}
}
if( interrupted )
Thread.currentThread().interrupt();
} catch ( ExecutionExcept... |
f77a531a-afda-42c3-9658-097d29dab6d9 | 2 | @Override
public boolean isObstacle(Element e) {
if (isActive() && e instanceof Player)
return true;
return false;
} |
fab48eed-38ed-4ea8-a339-b07ab5b0e408 | 2 | @RequestMapping(method = RequestMethod.GET, value = "login")
private String showLoginPage(@RequestParam(value = "error", required = false) String error, Model model) {
if (model.containsAttribute("loggedUser")) {
return REDIRECT_PREFIX + "/";
} else if (error == null) {
retur... |
aeea0a0b-e942-42dc-826c-0b7088a5bd57 | 5 | public static List<String> getLocalIPs() {
Enumeration<NetworkInterface> interfaces;
try {
interfaces = NetworkInterface.getNetworkInterfaces();
} catch (SocketException e) {
return null;
}
List<String> ips = new ArrayList<String>();
while(interfaces.hasMoreElements()) {
NetworkInterface curren... |
4d33b9c6-42b7-4f24-b1e1-3479701d2f5d | 5 | public boolean checkMapRectCollision(Shape collisionShape){
int collWidth;
int collHeight;
int rectX;
int rectY;
boolean testBoolean = false;
for(int i = 0; i <= tileMap[0].length-1; i++){
for(int c = 0; c <= tileMap.length-1; c++){
if(tileMap[c][i] != null){
if(tileMap[c][i].hasCollision){
... |
28b94ab5-e854-4f01-b7f9-b3e5d9914242 | 9 | public String format(Double number) {
int sign = 1;
if (number < 0) {
sign = -1;
}
number = Math.abs(number);
String fractionalPart = ":";
int integerPart;
integerPart = ((int)Math.floor(number));
double fractional = Math.abs(number - integerPart);
if (fractionLength < 6)... |
c9d7930c-56e4-4dc8-810a-7d56dd608abc | 8 | private void drawTitlebox(boolean loggedIn) { // drawLoginScreen
resetImageProducers();
leftCanvas.initDrawingArea();
titleBox.drawIndexedSprite(0, 0);
if (loginScreenState == 0) { // Default
smallFont.drawCenteredText(0x75a9a9, 180, onDemandFetcher.statusString, 180, true);
... |
8ab36d9b-0301-49b1-8f96-353f866a9cb5 | 5 | public void resetDirection(Direction d){
if (d == null){
return;
}
switch(d){
case EAST:
moveRight = true;
break;
case NORTH:
moveUp = true;
break;
case SOUTH:
moveUp = false;
break;
case WEST:
moveRight = false;
break;
}
} |
166aa436-b9ef-4a32-ae96-753ad564ead5 | 8 | private void processGridlet(Sim_event ev, int type)
{
int gridletId = 0;
int userId = 0;
try
{
// if a sender using gridletXXX() methods
int data[] = (int[]) ev.get_data();
gridletId = data[0];
userId = data[1];
}
// i... |
fd397812-35e7-4b90-9a05-ee5fe0cdd789 | 4 | public static void searchForWord(String text, JLabel jlbempty) {
InputStream stream = HangManCore.class.getResourceAsStream(text);
int lines = 0;
Random lineGen = new Random();
try {
lines = countLines(stream);
} catch (IOException e1) {
logger.log(Level.WARNING,
"Could not count lines in file: wo... |
5951b355-f162-441b-8764-6b3c152ec9a6 | 6 | public static void Command(CommandSender sender)
{
if(sender.hasPermission("gm.creative.all"))
{
for(Player player : Bukkit.getServer().getOnlinePlayers())
{
if (player.getGameMode() != GameMode.CREATIVE)
{
player.setGameMode(GameMode.CREATIVE);
if(sender instanceof Player)
{
me.... |
b1fef191-65bd-41f2-a511-3f6c91919840 | 0 | public SetModeFiring(){
super(Color.FIRING);
} |
1fe71096-6d2f-48be-88dc-d6adb629abd9 | 3 | @Override
protected double calcFitness()
{
double invalidColoredEdges = 0;
for(int i = 0; i<this.getGenotype().length; i++ )
{
int fromNode = phenotype.getEdges()[0][i] - 1;
int toNode = phenotype.getEdges()[1][i] - 1;
if( (this.getGenotype()[ fromNode ]).getValue() % this.maxColor == (this.getGenot... |
3c19507c-9e7a-4dd1-8be7-9bd90ea79c8b | 3 | public static boolean isRectangleDimension(boolean[][] matrix) {
if(matrix == null)
return false;
int width = matrix[0].length;
for(int row = 0; row < matrix.length; row++) {
if(width != matrix[row].length)
return false;
}
return true;
} |
aa8484c3-3ef0-4835-884f-0a7973c4e58b | 5 | public boolean ChangeState()
{
if ((this.GetBaseItem().Interaction.equals("default") || this.GetBaseItem().Interaction.equals("gate")) && (this.GetBaseItem().InteractionModesCount > 1))
{
if (ExtraData.isEmpty())
{
ExtraData = "0";
}
Integer Temp = Integer.parseInt(ExtraData) + 1;
... |
84279553-9343-4a20-b36c-46123c028d07 | 6 | private void roundToHtml(StringBuffer buf, int round) {
// array of results below buttons
buf.append("<div>");
buf.append("<div style=\"width: 200px; height: 40px; text-align: center;font-size: 25px; font-weight: bold; font-family: 'Comic Sans MS', cursive, sans-serif\">" + "Round #" + round + "</div... |
102e26a6-c407-4726-8a02-3ca55b87e060 | 6 | public void setRankcap(String cap) {
if (cap.compareTo("12")==0)
this.LevelUnlocked = 0;
else if (cap.compareTo("11")==0)
this.LevelUnlocked = 0;
else if (cap.compareTo("10")==0)
this.LevelUnlocked = 1;
else if (cap.compareTo("9")==0)
this.LevelUnlocked = 2;
else if (cap.compareTo("6")==0)
this... |
8387cacb-e853-4375-8e30-872fa34411ec | 8 | static boolean isPrime(long n) {
if (n < 2)
return false;
if (n == 2 || n == 3)
return true;
if (n % 2 == 0 || n % 3 == 0)
return false;
long sqrtN = (long) Math.sqrt(n) + 1;
for (long i = 6L; i <= sqrtN; i += 6) {
if (n % (i - 1) == 0 || n % (i + 1) == 0)
return false;
}
return true;
} |
1009272a-7622-44fd-a7f3-50facfe12c59 | 2 | protected void setModelProperty(String propertyName, Object newValue) {
for (AbstractModel model : registeredModels) {
try {
Method method = model.getClass().getMethod(
"set" + propertyName,
new Class[] { newValue.getClass() });
method.invoke(model, newValue);
} catch (Exception ex) {
L... |
c7445417-9124-4007-820e-7e185985cc9c | 0 | @Test
public void testResetWorld() {
System.out.println("resetWorld");
World instance = new World();
instance.generateRandomContestWorld();
instance.resetWorld();
} |
a029c4d5-cb22-403e-934d-e3ac17234f07 | 9 | public synchronized void close() {
try {
if (!isInterrupted())
interrupt();
} catch (Exception exc) {
exc.printStackTrace();
}
try {
if (socket != null)
socket.close();
} catch (Exception exc) {
exc.printStackTrace();
}
try {
if (out != null)
out.close();
} catch (Exception ex... |
40ec8332-dc48-48aa-b92a-9d26e0d34e45 | 2 | @Override
public void onEnable() {
instance = this;
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
ConfigurationSerialization.registerClass(PlayerConfiguration.class, "PlayerConfig");
//noinspection unchecked
censorWords = (List<String>) getConfig().... |
0e95f36b-7f9c-4106-ac2d-7f703cfe8b91 | 1 | public ResultSet listeMetaDonneesParTitre(String titre) {
Connection connexion;
java.sql.Statement requete;
ResultSet resultat = null;
try {
Class.forName("org.sqlite.JDBC");
connexion = DriverManager.getConnection("jdbc:sqlite:dbged");
requete = connexion.createStatement();
resultat = requete.execu... |
a8976080-54a0-4475-a57f-184dd80f7dd5 | 5 | private List<RelationInstance> run(String normalizedSentence) throws FileNotFoundException, UnsupportedEncodingException {
List<RelationInstance> instances = null;
try {
instances = relationExtraction.extractRelations(normalizedSentence);
} catch(Exception e){
e.printStackTrace();
System.out.println("R... |
c2a389c8-a582-450e-8595-4d7c08f9f475 | 9 | private Vehicle createRandomVehicle(List<Cell> possibleLocations, Direction dir, int length) {
int numIterations = 0;
// limit iterations to prevent infinite loop if conditions cannot possibly be met
while (numIterations < 1000) {
// generate random r,g,b values for vehicle color
int red = rand.nextInt(256... |
7b32cfa3-5ed7-42bc-852d-94396a0cb137 | 7 | public void move(int xa, int ya) {
if (xa != 0 && ya != 0) {
move(xa, 0);
move(0, ya);
return;
}
if (xa > 0)
dir = 1;
if (xa < 0)
dir = 3;
if (ya > 0)
dir = 2;
if (ya < 0)
dir = 0;
if (!collision(xa, ya)) {
// System.out.println("collision not detected!");
x += xa;
y += ya;... |
b3d0bc59-eb59-4a87-a93e-cbf91b95d10e | 5 | @Override
public void start(Stage primaryStage)
{
//eigen getter & setter
DoubleProperty a = new SimpleDoubleProperty(5);
System.out.println("De waarde van a is :" + a.get());
a.set(2);
System.out.println("De waarde van a is nu : " + a.get());
System.out.println(... |
a3340d83-1ba8-4cdf-bbd7-e2a84d021e07 | 2 | public ArrayList<Planet>getPlanets() {
ArrayList<Planet>p = new ArrayList<Planet>();
for(int i = 0; i < sprites.size(); i++){
if(sprites.get(i) instanceof Planet)p.add((Planet) sprites.get(i));
}
return p;
} |
0743ad13-092b-4bf8-b2c0-4e9ac0fc94c5 | 6 | private static void compareMatches( byte[] matchData, Match[] matches )
throws MVDTestException
{
int pos = 0;
while ( pos < matchData.length )
{
Match match = new Match( matchData, pos );
System.out.println(match);
for ( int i=0;i<matches.length;i++ )
{
if ( !matches[i].isFound() )
{
... |
a07361e8-a490-4cba-9b33-d1451cb57a3d | 8 | DeviceImpl (USB bus, String drivername, int a)
throws IOException, SecurityException
{
super (null, bus, a);
usb = bus;
path = drivername;//f.getPath ();
// should only fail if the device unplugged before
// we opened it, or permissions were bogus, or ...
if ((fd = openNative (path)) < 0) {
String ... |
c47ac016-4419-4a98-965c-28d1ffa9367e | 6 | public void visit(final int version, final int access, final String name,
final String signature, final String superName,
final String[] interfaces) {
StringBuffer sb = new StringBuffer();
appendAccess(access | ACCESS_CLASS, sb);
AttributesImpl att = new AttributesImpl();
att.addAttribute("", "access", "... |
a7fc4d45-a57f-48cd-9ef8-f902f159aeb8 | 9 | private void readLuminance() {
int type = sourceImage.getType();
if (type == BufferedImage.TYPE_INT_RGB || type == BufferedImage.TYPE_INT_ARGB) {
int[] pixels = (int[]) sourceImage.getData().getDataElements(0, 0, width, height, null);
for (int i = 0; i < picsize; i++) {
int p = pixels[i];
int r = (p &... |
e5284807-0abe-41ae-9083-bec55fa22c1f | 9 | public static StackEntry of(String descriptor, ConstPool pool) {
if(!DescriptorUtils.isPrimitive(descriptor)) {
return new StackEntry(StackEntryType.OBJECT, descriptor, pool);
}else {
char ret = descriptor.charAt(0);
switch (ret) {
case 'I':
... |
60280581-3691-4355-808b-00699b401ffe | 6 | private void go(){
int[] p = new int[N];
for(int i=2;i<N;i++) p[i]=1;
sieve(p);
int count =0;
int sum=0;
for(int i=10;i<N;i++){
if(p[i] == 1 && trunLeft(i, p) && trunRight(i, p)){
count++;
sum+=i;
System.out.println(i);
}
if(count>=11) break;
}
System.out.println(sum);
} |
8f371b55-f72d-4c02-8ed1-6661220a3f61 | 8 | public static /*unsigned*/ char OPLRead(FM_OPL OPL, int a) {
if ((a & 1) == 0) { /* status port */
return (char) ((OPL.status & (OPL.statusmask | 0x80)) & 0xFF);
}
/* data port */
switch (OPL.address) {
case 0x05: /* KeyBoard IN */
if((OPL.type&OPL_TYPE_... |
e46f1898-37ea-4bad-8b8f-e50f1cd0de8f | 2 | private static ConsumerManager getConsumerManager() {
try {
if (consumerManager == null) {
consumerManager = new ConsumerManager();
consumerManager.setAssociations(new InMemoryConsumerAssociationStore());
consumerManager.setNonceVerifier(new InMemoryNonceVerifier(10000));
}
} catch (Exception e) {... |
a2dbdead-1863-4469-bb24-b5b42c3d3ea7 | 2 | public static int addContestant(Contestant c) {
if (NUM_TEST_CONTESTANTS > list.size()) {
if (isIDValid(c.getID()))
list.add(c);
else
return -1;
} else {
return -2;
}
return 0;
} |
dfdfe5ee-5750-415e-b326-2cf19669e389 | 1 | @RequestMapping(value = "/before-event-comment-list/{hallEventId}", method = RequestMethod.GET)
@ResponseBody
public EventCommentListResponse beforeEventCommentList(
@PathVariable(value = "hallEventId") final String hallEventIdStr
) {
Boolean success = true;
String errorMessage =... |
d1c6f545-72f9-4bbc-8872-a1b9c5192ae3 | 2 | private String Complement(String binaryString)
{
StringBuilder complementBuilder = new StringBuilder(binaryString);
for(int i = 0; i < binaryString.length(); ++i)
{
char flip = binaryString.charAt(i) == '0' ? '1' : '0';
complementBuilder.setCharAt(i, flip);
}
return complementBuilder.toString();
... |
5f2e662e-4f5d-4073-835b-98fe5d5151d3 | 1 | public static double[][] rotation3D(double[] axis, double angle) {
double[][] res = new double[3][3];
if (axis.length == 3) {
double nx = axis[0];
double ny = axis[1];
double nz = axis[2];
double cos = Math.cos(angle);
double sin = Math.sin(angle);
res[0][0] = nx*nx*(1 - cos) + cos;
res[1][0] =... |
6e45bc65-ddb4-422e-9cae-0a240c87b5e5 | 9 | @Override
protected Class<?> findClass(final String name)
throws ClassNotFoundException {
final java.io.InputStream in;
final int size;
final JarFile jarFile;
assert this.cp.length >= 1;
final Lookup found = find(name.split("\\."), ".class");
if (found == null) {
return null;
}
in = found.in;
... |
026674c3-c8ac-4a16-a111-470f3776329f | 5 | @Override
public boolean preLoadBuffers( LinkedList<byte[]> bufferList )
{
// Stream buffers can only be queued for streaming sources:
if( errorCheck( channelType != SoundSystemConfig.TYPE_STREAMING,
"Buffers may only be queued for streaming sources." ) )
retu... |
45306031-a226-491d-92e3-885b89b26054 | 5 | protected static Ptg calcMode( Ptg[] operands )
{
Ptg[] alloperands = PtgCalculator.getAllComponents( operands );
Vector vals = new Vector();
Vector occurences = new Vector();
double retval = 0;
for( Ptg p : alloperands )
{
try
{
Double d = new Double( String.valueOf( p.getValue() ) );
if( va... |
e437dd42-a39e-4821-ac01-fcfab8266a99 | 7 | @SuppressWarnings("unchecked")
private <S> ServiceProviderInfo<S> findProviderInfo(Class<S> serviceClass) {
ServiceProviderInfo<S> result;
// Try to avoid synchronization by looking in our thread-local cache,
// which is just a (potential) subset of the global service provider
// class cache. If not found he... |
e3430307-648b-4f8f-88f4-3d803c30f2ef | 2 | @Override
public void start(Stage stage) throws Exception {
buildComponents();
stage.setScene(scene);
stage.show();
animate();
explodeAnimate();
Task<Object> t = new Task<Object>() {
@Override
protected Object call() throws Exception {
double i = 0.0;
while (i < 1) {
try {
Threa... |
3420f1d2-3c79-4ab0-b370-4c6d8f12fbe8 | 8 | public void handleSeeds(int seedId, WorldObject object) {
/*if (!canPlantSeeds(player, object)) {
player.getPackets().sendGameMessage("You must clear the weeds before you may plant some seeds here.");
return;
}*/
for (PatchStatus patch : player.getFarmingPatches()) {
if (patch.getObjectId() == object.get... |
dbcda9bb-e9ff-4609-a094-1a16005d1622 | 5 | @Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
Map<String, String[]> requestParameters = req.getParameterMap();
String uri = url.toString();
Query query = null;
PostMethod proxyMethod = new PostMethod(uri);
for (String name : reque... |
1d8af17a-bc2b-40a4-93a3-1d41cb6ae719 | 8 | protected void readLines(String fileText) {
rows.clear();
try {
CsvReader csvReader = initializeReader(new StringReader(fileText));
// case when the first line is the encoding
if (!displayFirstLine) {
csvReader.skipLine();
}
b... |
e4b2bbb1-e55c-47ba-8ceb-a12cdcd8cb20 | 8 | private boolean saveStory() {
boolean XMLProject = true; // make a proj file
JFileChooser j = new JFileChooser();
j.setSelectedFile(new File(map.getStory().getName()));
j.setDialogTitle("Select a location to save the project");
j.setAcceptAllFileFilterUsed(false);
j.set... |
ce313d32-b9b2-48b7-be4d-7534b7ffe42e | 0 | public SimpleStringProperty titleProperty() {
return title;
} |
861314ff-85b4-45bf-9de1-dfd1d11433de | 0 | public Node getParent() {
return this.parent;
} |
5bed8d1b-fdfc-45be-adac-01ac4bf19b9a | 7 | public final LatticeIF getImplementation(final LatticeType type)
{
switch(type)
{
case SHORT_RATE:
{
this.implementation = new ShortRateLatticeImpl();
break;
}
case ZERO_COUPON_BOND:
{
this.i... |
02ccf15d-b0fc-461c-874a-5fd7116a655f | 4 | @Override
public void run() {
try {
for (int i = 0; i < 1; ++i) {
Integer number = new Integer(rand.nextInt(20));
// System.out.println("probuje wstawic liczbe " + number);
lista.add(number);
}
for (int i = 0; i < 1; ++i) {
Integer number = new Integer(rand.nextInt(20));
// System.out.pr... |
aa5a2b92-5b1a-4470-930c-2d70b30d4476 | 8 | public Meter(HtmlMidNode parent, HtmlAttributeToken[] attrs){
super(parent, attrs);
for(HtmlAttributeToken attr:attrs){
String v = attr.getAttrValue();
switch(attr.getAttrName()){
case "form":
form = Form.parse(this, v);
break;
case "high":
high = High.parse(this, v);
break;
c... |
cc57b9df-bf7f-4aca-b895-92803d636539 | 7 | @Override
protected void paintLevel() {
super.paintLevel();
Level level = getState().getLevel();
World world = getState().getWorld();
if (passableImage == null) {
BufferedImage image = new BufferedImage(getScreen()
.getScreenWidth(), getScreen().getScreenHeight(),
BufferedImage.TYPE_4BYTE_ABGR);
... |
718c5dbb-f45c-4e64-a196-35ea92b74dce | 9 | private void filtrarMedio(String texto, DefaultMutableTreeNode raizArbol,
DefaultMutableTreeNode raizNegativa, boolean filtrar) {
int artista, albumes, canciones;
artista = albumes = canciones = 0;
DefaultMutableTreeNode nodoArtista, nodoAlbum, nodoCancion;
DefaultMutableTreeNode nodoArtistaClon, nodoAlbumCl... |
8504933b-47c6-4f79-af37-b14fdc73e62a | 6 | private void setupHandListener() {
textbBranchListener = new MouseAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
Cursor handCursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
Cursor defaultCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
JTextPane textPane = (JTe... |
caa40fb2-dd4c-4e1c-97a2-96a1b44f055e | 8 | private void renderElement(XmlElement element) {
if (element instanceof XmlTextElement) {
System.out.println(String.format("RENDERING '%s' with formats %s", element.getText(), formatStack));
} else if (element instanceof XmlTagElement) {
XmlTagElement tag = (XmlTagElement)element;
switch(tag.getLabel()) {
... |
2cf91a00-c06a-4b04-8054-bd341c82317d | 6 | private void drop(Point p) {
if (b != null && player != null) {
int zx = 0, zy = 0, px = 0;
for (Item i : b.getItems()) {
if (px > b.getTotal()) {
return;
}
Rectangle r = new Rectangle(x + (zx * nWidth), y
+ (zy * nHeight), nWidth, nHeight);
if (r.contains(p)) {
player.getContain... |
5c4a12f9-47d7-47d7-a14e-89d4c613d019 | 0 | public Person4(String pname) {
name = pname;
} |
02ec07ca-5c61-409a-8483-9ff854176abd | 5 | public static AgentController createClientAgent() {
try {
ConditionalVariable startUpLatch = new ConditionalVariable();
Method m = ClientMainFrame.class.getMethod("onContainerFromAgent", Object.class);
m.invoke(null, "s");
AgentController ac = containerController.... |
e6042bc5-e5bd-4c86-97fe-5ceff878678f | 0 | public Station getStation() {
return this._station;
} |
8d2a4dec-2f96-4409-96f9-d4a9405c3577 | 3 | public static Map<String, Object> get(String filePath) {
if (! filePath.endsWith(".json")) {
filePath += ".json";
}
if (jsonMap.containsKey(filePath)) { // Check if the file is cached.
// If so, return the cached version of the file.
return jsonMap.get(filePath);
} else {
try {
@SuppressWarni... |
a2bf5ef8-3550-49c2-98c4-e87548ab3289 | 4 | private static void translate(int tx, int ty) {
ImageData imageData = original.getImageData();
int[][] two1 = new int[imageData.height][imageData.width];
for (int i = 0; i < imageData.height; i++) {
for (int j = 0; j < imageData.width; j++) {
two1[i][j] = imageData.getPixel(j, i);
}
}
int w = imag... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.