method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
0d8086dd-3216-4434-9ee9-d82dd6be01d9 | 0 | public String getXKey(){
return getAxisKey(Axis.X);
} |
d85a3ae4-ce22-47f9-a5e3-d4287db338f0 | 0 | public TagFormatException (String message){
super (message);
} |
3bdbf3ff-13ae-4cc0-9b49-a93cd807ff1c | 9 | public ArrayList<Integer> generate(int rowIndex) {
ArrayList<Integer> list = new ArrayList<Integer>(rowIndex + 1);
list.add(1);
if (rowIndex == 0) {
return list;
} else if (rowIndex == 1) {
list.add(1);
return list;
}
int[] array = new int[rowIndex / 2 + 1];
... |
cbb4b178-384f-4b6e-9935-80e202b363b9 | 1 | public void removePush() {
StructuredBlock[] subBlocks = getSubBlocks();
for (int i = 0; i < subBlocks.length; i++)
subBlocks[i].removePush();
} |
ef3e4dc8-4597-484e-95b5-6d4733fced43 | 0 | public void addData(String[] data) {
this.data.add(data);
} |
78517719-81ea-4d40-a0af-f9b5934f6035 | 7 | public void buttonClicked(WizardButtonEvent wbe) {
if( wbe.getButtonType() == WizardButtonListener.NEXT && wbe.getCard() == eoo ){
options = new EmbedExtractOptions();
options.setInputFile( sif.getSelectedFile() );
options.setOutputDirectory( sof.getOutputDirectory() );
... |
cb4537bd-ee5f-4ebe-ad18-306dd7a4b35d | 0 | public SimpleVector getPosition() {
return cam.getPosition();
} |
54fa1432-9c93-485d-b613-bf2d8a80c71c | 7 | @Override
public void unInvoke()
{
final MOB mob=(affected instanceof MOB)?(MOB)affected:null;
super.unInvoke();
if((mob!=null)
&&(!mob.amDead())
&&(mob.isMonster())
&&(!CMLib.flags().isMobile(mob))
&&(mob.getStartRoom()!=null)
&&(mob.location()!=mob.getStartRoom()))
CMLib.tracking().wanderAway(mob... |
f28e6baa-c045-499a-a5d7-f2114c1f868e | 3 | @Override
public void execute(CommandSender sender, String[] arg1) {
if (!CommandUtil.hasPermission(sender, PERMISSION_NODES)) {
sender.sendMessage(plugin.NO_PERMISSION);
return;
}
String message = ChatColor.DARK_AQUA + "Portals: " + ChatColor.WHITE;
try {
for (String data : plugin.getUtilities(... |
4c5e36a4-0010-476c-b749-3068a05d992c | 4 | public boolean isOptOut() {
synchronized (optOutLock) {
try {
// Reload the metrics file
configuration.load(getConfigFile());
} catch (IOException ex) {
if (debug) {
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.g... |
884bd195-12a6-466d-91a0-42fb9e6f1ba7 | 9 | @SuppressWarnings("unchecked")
private void getDebateList() {
debateList = debate.getDebateList();
topicDBDLM.removeAllElements();
numberTurnDBDLM.removeAllElements();
statusDBDLM.removeAllElements();
winnerDBDLM.removeAllElements();
int activeTopic = 0, completedTopic = 0, pendingTopic = 0;
for (int i =... |
aae83827-eaeb-457f-89b2-121c87fa478e | 5 | static ClassInterfacesType create(ClassInfo clazz, ClassInfo[] ifaces) {
/* Make sure that every {java.lang.Object} equals tObject */
if (ifaces.length == 0 && clazz == null)
return tObject;
if (ifaces.length == 0)
return tClass(clazz);
if (ifaces.length == 1 && clazz == null)
return tClass(ifaces[0]);... |
fe95e030-805d-4d84-a8c4-14ecc41c0758 | 2 | public static String checkLevels(double level) {
String message = "";
if (level < 0.0) {
message = " below acceptable range.";
}
if (level > 1.0) {
message = " above acceptable range.";
}
return message;
} |
179411a3-64ff-4359-8533-d0a40995bedb | 1 | public InnerClassInfo[] getInnerClasses() {
if ((status & INNERCLASSES) == 0)
loadInfo(INNERCLASSES);
return innerClasses;
} |
baa2aab9-6d50-4dd2-9710-06d87b2d6302 | 4 | Catalog(final Plugin plugin, final Repository repository, final ConfigurationSection options) {
this.plugin = plugin;
this.repository = repository;
this.serverDefault = repository.loadDefault(null);
if (options != null)
for (final String key : options.getKeys(false)) {
... |
58ccbcfc-cf98-411b-9ea9-deacc96283e3 | 1 | private boolean differByOneVerticalAndTwoHorizontal(Field from, Field to) {
return Math.abs(from.distanceBetweenRank(to)) == 2 && Math.abs(from.distanceBetweenFile(to)) == 1;
} |
6fb31002-a300-422f-9981-7eaada902bfa | 7 | private int insertKeyForNull() {
int index = 0;
int firstRemoved = -1;
// Look for a slot containing the 'null' value as key
for (Object o : _set) {
// Locate first removed
if (o == REMOVED && firstRemoved == -1)
firstRemoved = index;
... |
94e26f58-53af-42ec-87d3-7a26969e8b8b | 8 | private boolean check(Gridspot from, Gridspot to)
{
if( a.getGridSpot(from.getXIndex()-1, from.getYIndex()) != null && a.getGridSpot(from.getXIndex()-1, from.getYIndex()) == to)
{
return true;
}
else if( a.getGridSpot(from.getXIndex()+1, from.getYIndex()) != null && a.getGridSpot(from.getXIndex()+1, from.ge... |
8f621511-73ac-4bfc-9e2b-68dc88ca9f6e | 1 | public CacheKey(String service, long lastModified) {
if (service == null) {
throw new IllegalArgumentException("Parameter 'service' must not be null");
}
this.service = service;
this.lastModified = lastModified;
} |
23bc852e-d76a-4cc3-a996-e23d258cb5fc | 1 | @Test
public void WhenRemovingReference_ExpectRemoved()
throws UnknownHostException {
localhost_.setHostPath("0000");
int level = localhost_.getHostPath().length();
RoutingTable table = new RoutingTable();
table.setLocalhost(localhost_);
Host host = new PGridHost... |
7db3cd33-eb8a-409c-b86a-2076f28e3f3e | 0 | public LinkPost(String username, String message, String url){
super(username, message);
this.url = url;
} |
29caf9e2-f539-4102-8d07-2c51fec6b2f5 | 4 | public void updateStats(int[] bowl, int round)
{
// Once you receive the first bowl, calculate the size of a bowl
if (!firstBowlReceived) {
for (int i = 0; i < bowl.length; i++) {
this.bowlSize += bowl[i];
}
firstBowlReceived = true;
}
... |
89f441e9-8854-4703-b2bf-28665996b830 | 9 | public final GalaxyXPreprocessorParser.modifier_return modifier() throws RecognitionException {
GalaxyXPreprocessorParser.modifier_return retval = new GalaxyXPreprocessorParser.modifier_return();
retval.start = input.LT(1);
int modifier_StartIndex = input.index();
Object root_0 = null;
... |
893ca747-c617-43a4-b360-8413ce0da8fb | 5 | public void lancerSort(Personnage p){
if(p.ptVie>0)
{
if(this.ptMana>= this.sort.getCoutMana()) // Si assez de point de mana -> sort
{
if(this.sort.getCoutMana() == 50) // sort = vampirisme
{
if(this.ptVie + p.getPDV()/2 <= this.ptVieMax)
this.ptVie += p.getPDV()/2;
else
this.p... |
5277617c-62da-4953-beb1-0706942168b4 | 5 | public void setAttackScript(String ID){
if(ID==null)return;
if(ID.equals("none") || ID.equals("null") || ID.equals("empty")){
attackScript = null;
} else {
attackScript = new Script(ID, ScriptType.ATTACKED, main, this);
if(supAttackScript==null)
supAttackScript = new Script(ID, ScriptType.ATTACKED,... |
b516bacb-83fa-4a8c-8174-0b2c5b45a76a | 2 | public static List<ChatUser> getUsers(String response) {
List<ChatUser> users = new ArrayList<ChatUser>();
String[] modifiedResponse;
int maxUserIndex; // Index of the last Hostname (Hostname-n) within the
// Stringarray "modifiedResponse".
// Since the last Hostname is followed by the
// corresponding chat... |
04e33d14-c9a3-497b-975d-8e0655a40d37 | 5 | private void lifeCycle() {
String s = "";
while (isInputActive) {
try {
s = readInput();
if (s.length()==0) {
this.isInputActive = false;
break;
}
if (this.isValidInput(s)) {
action(s);
} else {
System.out.println(MSG_WELCOME);
}
} catch (IOException... |
b503638d-1ea7-4aec-aef0-d66ac4821603 | 0 | public List findByModifyAuther(Object modifyAuther) {
return findByProperty(MODIFY_AUTHER, modifyAuther);
} |
298770db-e4e3-4001-912b-9fb1ad093fd2 | 3 | private void write_file(final File file, final String content) throws IOException
{
if (file.exists()) file.delete();
BufferedWriter w = null;
try
{
w = new BufferedWriter(new FileWriter(file));
w.write(content);
}
finally
{
try
{
if (w != null) w.flush();
}
finally
{
if (w != null) w.close();... |
40a27e4c-5299-4104-bb39-3bc63ff768f1 | 3 | public String soundex(String s){
String code, previous, soundex;
code = s.toUpperCase().charAt(0) + "";
previous = "7";
for(int i = 1;i < s.length();i++){
String current = getCode(s.toUpperCase().charAt(i));
if(current.length() > 0 && !current.equals(previous)){
code = code + current;
}
pr... |
a59c5224-19cb-481d-a874-b881ebb5f606 | 3 | @Override
public String execute() throws Exception {
try {
Date date = new Date();
Map session = ActionContext.getContext().getSession();
User user = (User) session.get("User");
Campaign camp = new Campaign(user, campaignname);
camp.setStartDate... |
46d846bf-45bc-4ab9-bbe6-2d2268befad4 | 3 | protected void createTradingInventories()
{
int rows = 4;
int rowsP1 = getAllowedGuiRows(p1);
int rowsP2 = getAllowedGuiRows(p2);
if (rowsP2 > rowsP1) {
if (plugin.yamlHandler.configYaml.getBoolean("use_biggest", true))
rows = rowsP2;
else {
rows = rowsP1;
}
}
... |
20a9a399-d809-4d15-b013-ada9c5467ee7 | 0 | public Head(int upgradeCount, String name) {
super(upgradeCount, UpgradeType.Head, name);
} |
bc0bae25-652e-490e-9a7e-898e08b120b8 | 4 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
IntNode other = (IntNode) obj;
if (intVal != other.intVal)
return false;
... |
f13975ca-17c1-45ac-835a-ebcda525eee8 | 2 | private void jTablePesquisaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTablePesquisaMouseClicked
if(flag == 1){
conecta.conexao();
String nome = "" + jTablePesquisa.getValueAt(jTablePesquisa.getSelectedRow(), 1);
jTextFieldNomeCliente.setText(nome);
... |
ad5c148b-59a0-46d1-ade3-625dc7af3f5d | 8 | @Override
public Expression evaluate(Expression leftSideOperand, Expression rightSideOperand)
{
if (Operator.outputMode == Calculate.OUTPUT_EXACT_MODE)
{
//try to use operands as fractions. if they are not fractions, then try to
//use them as numbers. if still can't use them as numbers, then use them as
... |
51ea2f12-fa08-4f6d-8401-6688a11b3b84 | 7 | public void add(ArrayList<Predicate> pl){
for(int i = 0; i < pl.size(); i++){ // for each predicate
Predicate p = pl.get(i);
// If the predicate is USED-RAILWAYS
if(p.getName().equals("USED-RAILWAYS")){
// We increment or decrement the number of occupied spaces.
String varName = p.getVariables().... |
edeb2a5f-7ce1-4905-8f35-cda9c8190a4d | 1 | public int get_quality() {
return (q2 > 0) ? q2 : quality;
} |
521aecfd-fa53-45dd-b8dc-831478d5e45f | 6 | public void updateAdd(E e) {
ArrayList<Vec2i> vec2iArr = entities.get(e);
if(vec2iArr == null)
{
// Это новый элемент, вызываем add
this.add(e);
return;
}
Rect rect = e.getAABB();
int beginx = (int) (rect.x - rect.w2) / width;
i... |
1e5a005b-8a9c-4ade-bffa-9d2a32a8b9a5 | 3 | private boolean insideMatrix(int row, int col) {
return row >= 0 && row < getHeight() && col >= 0 && col < getWidth();
} |
0e41ee95-3cee-4d03-87b4-e3cbe33bcb76 | 3 | public ArrayList<LineData> linesForCategory(MealCategoryData category) {
ArrayList<LineData> lines = new ArrayList<LineData>();
for (LineData canteenLine : canteenData.getLines()) {
for (MealData meal : canteenLine.getTodayMeals()) {
if (meal.getMealCategory().equals(category)) {
lines.add(canteenLine);
}... |
0e36532a-5a3f-4193-ac08-cdbf228071df | 8 | public void run() {
while (!stop) {
Random generator = new Random();
double pty = generator.nextDouble();
// declare an emergency
if (!getIsEmergency() && pty < .02){
this.setEmergency();
currentStreet.ambulanceAlert();
currentStreet.moveVehicleToFront(this);
}
//System.out.println(... |
54c67f43-439c-4f18-afee-3886704d39d0 | 4 | private void checkForInput() {
float screenX = Gdx.input.getX();
float screenY = Gdx.input.getY();
for (GameButton gameButton : buttons) {
boolean inputIsInside = gameButton.getBoundingRectangle().contains(screenX,
Gdx.graphics.getHeight() - screenY);
// System.out.println(inputIsInside +
// ","+ga... |
6b83cc3d-d4be-4db8-b3a4-dab3d5ace76d | 1 | @Override
public int getPreferredWidth(Row row, Column column) {
int width = super.getPreferredWidth(row, column);
if (mAllowSort) {
width += SORTER_WIDTH + 4;
}
return width;
} |
2db86437-7cb1-4913-8584-c65af02ba091 | 2 | private static boolean isMatingSuccessful(ArrayList<ParkerPaulChicken> chickens) {
ArrayList<ParkerPaulChicken> secondList; // list for selecting second chicken from
Random chickenSelector = new Random(); // random number generator for selecting chickens
ParkerPaulChicken initialChicken = chicke... |
0a8c55aa-a4fa-497e-8177-5d466dcf29af | 8 | private Long getMaskOrNull(char c)
{
if( c == 'T' || c =='t' )
return T_LONG;
if( c == 'G' || c =='g' )
return G_LONG;
if( c == 'C' || c =='c' )
return C_LONG;
if( c == 'A' || c == 'a')
return A_LONG;
return null;
} |
ea173a67-6b4b-4c90-8fd4-e4e88bc9c2f5 | 4 | @Override
protected Void doInBackground() throws Exception {
List<String> notUpToDate = new ArrayList<String>();
for (String url : toDownload.keySet()) {
if (!checkJenkinsVersion(url, toDownload.get(url))) {
notUpToDate.add(url);
}
}
for (String url : notUpToDate) {
if (url.contains("Spout")) {... |
05d71c5f-02bc-4884-ba83-66c4cffab7d4 | 7 | public TreePath getPath(String fullName) {
if (fullName == null || fullName.length() == 0)
return new TreePath(root);
int length = 2;
ClassInfo ci = ClassInfo.forName(fullName);
while (ci.getSuperclass() != null) {
length++;
ci = ci.getSuperclass();
}
TreeElement[] path = new TreeElement[length];... |
d41b2a94-52d7-44c9-a604-488c9a5fb270 | 2 | public Teacher getTeacher(int id)
{
Teacher teacher = null;
try {
PreparedStatement ps = con.prepareStatement("SELECT * FROM teacher WHERE id=?");
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
if(rs.next())
{
teacher = getTeacherFromRS(rs);
}
ps.close();
} catch (SQLExceptio... |
d57a7f23-9a17-40ab-aea4-71b5a200354a | 0 | public String toString() {
return new Gson().toJson(this);
} |
a168b03e-8c39-4432-bafc-62c821f5fb76 | 8 | public void nextPermutation(int[] num) {
int j = -1;
for (int i = 0; i < num.length - 1; i++) {
if (num[i] < num[i + 1])
j = i;
}
if (j == -1) {
for (int i = 0; i < num.length / 2; i++) {
int k = num[i];
num[i] = num[num.length - i - 1];
num[num.length - i - 1] = k;
}
} else {
int ... |
2c946b93-c6e7-463e-85b1-4b00881599e0 | 7 | @Override
public void initialize(URL arg0, ResourceBundle arg1) {
firstNameTxtLbl.setText(Util.getModelResourceBundle().getString("L_LBL_FIRSTNAME"));
lastNameTxtLbl.setText(Util.getModelResourceBundle().getString("L_LBL_LASTNAME"));
birthdayTxtLbl.setText(Util.getModelResourceBundle().getString("L_LBL_BIRTHDAY"... |
a6b75d60-b723-4c96-be32-6f2789cdcc4b | 6 | public static String numberToString(Number number)
throws JSONException {
if (number == null) {
throw new JSONException("Null pointer");
}
testValidity(number);
// Shave off trailing zeros and decimal point, if possible.
String string = number.toString();
... |
482133dc-c1ef-41ca-835b-ef7da4fb054f | 3 | public void run() {
while (true) {
int from = randomFloor();
int to = randomFloor();
while (from == to) {
to = randomFloor();
}
try { Thread.sleep((int) (46000 * Math.random())); }
catch (InterruptedException e) { e.printS... |
ff28805f-4fb7-438b-8846-6a73c2e8e2ad | 3 | private void flowIntoBlock(World var1, int var2, int var3, int var4, int var5) {
if (this.liquidCanDisplaceBlock(var1, var2, var3, var4)) {
int var6 = var1.getBlockId(var2, var3, var4);
if (var6 > 0) {
if (this.blockMaterial == Material.lava) {
this.tr... |
624b4ea4-c63c-4312-9ece-52ac68274a4d | 8 | public static void main(String[] args) throws IOException,
InterruptedException {
if (args.length == 1 && args[0].equals("-i")) {
// started with command line argument -i
// read the input
//String input = readStandardInput();
String input = Utf8IO.readStdin();
/*
* Parse the Input LTS and G... |
d26592ac-b0ff-4e16-b7d9-0269aa7da80a | 9 | @Override
public String toString()
{
String s = (ownerRead ? "r" : "-") + (ownerWrite ? "w" : "-") + (ownerExecute ? "x" : "-") + (groupRead ? "r" : "-") + (groupWrite ? "w" : "-") + (groupExecute ? "x" : "-") + (othersRead ? "r" : "-") + (othersWrite ? "w" : "-") + (othersExecute ? "x" : "-");
s += " set UID: " ... |
88b4f405-45b9-4be5-b093-0ac759a5d204 | 5 | private void checkInputArguments(String[] args) {
int i = 0;
while (i < args.length) {
switch (args[i]) {
case "-i":
handleInputFile(args, i);
i+=2;
break;
case "-o":
handleOutputDirectory(args, i);
i+=2;
break;
case "-os":
handleOS(args, i);
i+=2;
break;
defau... |
dc06d3c5-7fb1-4f99-8917-de83ba710f26 | 8 | public Map<PII,StateBuffer> executeSingleAttack(StateBuffer in, Segment moveSegment, EflAttackActionSegment actionSegment, int goalValue, int minValue, boolean noBins, boolean isB) {
EflAttackActionSegment dummyActionSegment = null;
EflAttackActionSegment aActionSegment = isB ? dummyActionSegment : actionSegment;... |
7b4a5427-1e29-4980-ba96-9af37f43a1b7 | 3 | static double[][] multiply(double[][] A, double[][] B){
double[][] AB = new double[A.length][B[0].length];
for(int i = 0; i < A.length; i++){
for(int j = 0; j < B[i].length; j++){
for(int k = 0; k < B.length ; k++){
AB[i][j] += A[i][k]*B[k][j];
}
}
}
return AB;
} |
6a359847-1b37-40d5-8270-47bcf41d7151 | 5 | public static void main(String[] args) throws Exception {
Options options = new Options();
options.addOption("h", false, "Display list of vBatch commands.");
options.addOption("test_create", false, "Create a sample WMOS source database.");
options.addOption("j", true, "Specify one or more jobs... |
b60020a5-6ede-480b-948a-7f7349fea004 | 4 | public String getAnswer(){
Long answer = 20L;
while(true){
for(Long i = 20L; i > 0L; i--){
if(i == 1)
return String.valueOf(answer);
else if( answer % i != 0 )
break;
}
answer += 20;
}
} |
4840ecd5-6439-4e80-9062-4cc8456e1a83 | 8 | private void readP56(int type, FileInputStream reader, int width, int height) throws IOException, MyExceptions {
int currentRow = 0;
int currentColumn = 0;
int currentColor = 0;
int octet = readByte(reader);
while(octet != -1) {
switch(type) {
case 5 :
portableMap.setData(currentRow, currentColumn, ... |
e1d5fe70-f401-48d0-9e9d-52696f835aed | 3 | public boolean contains(int xLoc, int yLoc) {
return xLoc >= locX &&
yLoc >= locY &&
xLoc < locX + width &&
yLoc < locY + height;
} |
e0f60094-b13c-4589-93a7-2941127bd0c8 | 8 | @Override
public boolean okMessage(final Environmental myHost, final CMMsg msg)
{
if(((msg.targetMajor()&CMMsg.MASK_MALICIOUS)>0)
&&(!CMath.bset(msg.sourceMajor(),CMMsg.MASK_ALWAYS))
&&((msg.amITarget(affected))))
{
final MOB target=(MOB)msg.target();
if((!target.isInCombat())
&&(msg.source().locatio... |
823f05f6-02f2-4da8-aaac-2aa4129dd3a9 | 4 | public void createAllFiles(){
if(!dir.exists()){
dir.mkdir();
}
if(!optionsFile.exists()){
try {
optionsFile.createNewFile();
setupOptionsConfig();
} catch (IOException e) {
e.printStackTrace();
}
}
if(!saveFile.exists()){
saveFile.mkdir();
}
} |
8ebba508-d3b1-4b2e-a863-18bb9136a037 | 2 | public static Connection creerConnexion() {
if (connexion == null) {
try {
Properties props = new Properties();
FileInputStream fichier = new FileInputStream("build/classes/connexion/connexion.properties");
props.load(fichier);
OracleDa... |
319b7afb-ff7d-4736-9ad4-c0392c554fba | 3 | @Override
public List<Rule> getRulesInvolvingSpecie(Specie specie) {
List<Rule> affectingRules = new ArrayList<Rule>();
for (Rule rule : rules) {
if (rule.getLhs().contains(specie))
affectingRules.add(rule);
if (rule.getRhs().contains(specie)) {
affectingRules.add(rule);
}
}
return affectingRu... |
f0b514ae-f460-4542-a581-9ed5787a91e3 | 9 | private void loadStopWordDict(){
//建立一个主词典实例
_StopWordDict = new DictSegment((char)0);
//加载扩展停止词典
List<String> extStopWordDictFiles = cfg.getExtStopWordDictionarys();
if(extStopWordDictFiles != null){
InputStream is = null;
for(String extStopWordDictName : extStopWordDictFiles){
System.out.println(... |
81eb3135-36f4-4895-a21d-123ad49cb2b7 | 0 | public List<Film> getDostepneFilmy() {
return ow.getDostepneFilmy();
} |
31ba9d5e-48e1-41b1-aec2-337ed194b2f4 | 8 | private void btnSalvarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSalvarMouseClicked
String comp = txtNome.getText();
int est = Integer.parseInt(txtEstoque.getText());
double vc = Double.parseDouble(txtValorCompra.getText());
double vv = Double.parseDouble(txtValorV... |
cf2c919a-0eca-4bdb-aec4-e4416b6b41ec | 4 | @Override
public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(btnConnect)) {
try {
guiInter.connect(getTxtEnterName().getText() ,getServerField().getText(), Integer.valueOf(getPortField().getText()));
txtEnterName.setEnabled(false);
serverField.setEnabled(false);
portField.set... |
bd8e0d54-a5fb-47e0-8526-d5aec823e146 | 6 | public static int countPrimes(int n) {
if (n < 3) return 0;
boolean[] isPrimes = new boolean[n];
for (int i = 0; i < n; i++) isPrimes[i] = true;
isPrimes[0] = false;
isPrimes[1] = false;
isPrimes[2] = true;
int count = 0;
int k = (int) Math.sqrt(n);
for (int i = 2; i < n; i++) {
... |
70fd8346-9387-4265-9c62-fc5df9161d01 | 2 | private void enterCompositeState(CompositeState<TransitionInput> composite) {
for(StateMachineEventListener<TransitionInput> eventListener : eventListeners) {
eventListener.beforeCompositeStateEntered(composite, this);
}
composite.onEnter();
for(StateMachineEventListener<TransitionInput> eventListener : ev... |
c9f64e80-3a90-431a-99e8-33b171006532 | 2 | @Override
public boolean canMove(Board board, Field currentField, Field emptyField) {
return this.validSetupForMove(currentField, emptyField) && (this.differByOneVerticalAndTwoHorizontal(currentField, emptyField) || this.differByTwoVerticalAndOneHorizontal(currentField, emptyField));
} |
e09fc1cb-acbd-42ed-bdea-28377f67c676 | 8 | public static void main(String[] args) {
final int s=75000001;
short[] l=new short[s];
short n=0;
for(int i=1;i<=s;i*=2){
n++;
l[i]=n;
}
n=0;
for(int i=5;i<=s;i*=2){
n++;
l[i]=(short) (l[16]+n);
}
n=0;
for(int i=3;i<=s;i*=2){
n++;
l[i]=(short) (l[10]+n);
}
n=0;
for(int i=13;i... |
ca34c92b-5a26-4396-8535-a78ee890f415 | 1 | public static void asm_btfsc(Integer akt_Befehl, Prozessor cpu) {
Integer f = getOpcodeFromToBit(akt_Befehl, 0, 6);
Integer bitNr = getOpcodeFromToBit(akt_Befehl, 7, 9);
Integer k = cpu.getSpeicherzellenWert(f);
boolean bitIsSet = getBit(k, bitNr);
// Bit is set
if(bitIsSet) {
}
// Bit not set
els... |
5341ee9c-cf5a-4870-ab3b-a605527e8731 | 1 | @Override
public synchronized void registerEventListener(EventListener<? extends Event> listener) {
listeners.add(listener);
} |
f4a35c1f-7805-4c32-9eb4-5fcaca04e666 | 9 | private void updateSpecialPagePopupMenu() {
Short special = (Short)popupRow[config.specialcol];
String article = popupRow[config.articlecol] + "#"
+ popupRow[config.projectcol];
specialPageNamePopupLabel.setText(article);
if (special == Edit.SPECIAL_BLOCK || special == Edit.SPECIAL_UNBLOCK
... |
e148f5af-4f1a-4a9c-a823-ca2da1f61488 | 0 | public static boolean isOdd(int i) {
return i % 2 != 0;
} |
4e359fd3-949e-4811-bd7f-cef20c19d7ff | 2 | void add(Regulation r) {
if (consensus == null) {
consensus = r;
count = 1;
} else {
if (consensus.intersects(r)) {
consensus.setStart(Math.max(consensus.getStart(), r.getStart()));
consensus.setEnd(Math.max(consensus.getEnd(), r.getEnd()));
count++;
} else {
flush();
cons... |
1147af8f-cacb-405a-92b6-549b7a1ea8cb | 1 | public static boolean isArray(Object obj) {
return (obj != null && obj.getClass().isArray());
} |
76a44527-cdd3-49d7-8b51-a6b92f55e10b | 9 | public byte[] calc_pmk(byte[] key) throws NoSuchAlgorithmException, InvalidKeyException {
try {
MessageDigest ipad = MessageDigest.getInstance("SHA-1");
MessageDigest opad = MessageDigest.getInstance("SHA-1");
int keyCutoff = Math.min(key.length, 64);
for (int i = 0; i < keyCutoff; i++) {
ipad.updat... |
18346478-4d90-4ca9-a244-c1870c2b10fd | 1 | public void updatePerm(double newPerm)
{
// adjust the permeability based on the temperature and pressure
// double BP = getBPPres();
// perm = ((pres-BP)/(maxPres-BP))*100/2; // old, less realistic method
perm = ((((maxPres-pres)/maxPres)+(temp/maxTemp))/2.0)*100;
fixOutOfBounds();
for(Molecule mole : g... |
483990a0-97f7-4d81-97e3-2b69ab900ce5 | 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://down... |
b8084532-fd09-4da5-ac00-2c86118dfb60 | 9 | private LinkedList<Diff> diff_lineMode(String text1, String text2,
long deadline) {
// Scan the text on a line-by-line basis first.
LinesToCharsResult b = diff_linesToChars(text1, text2);
text1 = b.chars1;
text2 = b.chars2;
List<String> linearray = b.lineArra... |
3e912e1b-9410-4051-ac2d-36615a1855bf | 8 | private void colourProgressBarRedToGreen(JProgressBar pb)
{
int pbv = pb.getValue();
int r=255,g=0,b=0;
if(pbv>0 && pbv<=20)
{
r=255; g=0; b=0;
}
else if(pbv>20 && pbv<=60)
{
r=255;g = (int) ((pbv-20)*6.375);
}
... |
f8f67c14-0239-4be6-9f75-a2a3c612a5fb | 6 | public void computeNewPosition(int verb) {
// As a starting point, the new position is the same as the old
newPiece = currentPiece;
newX = currentX;
newY = currentY;
// Make changes based on the verb
switch (verb) {
case LEFT: newX--; break;
case RIGHT: newX++; break;
case ROTATE:
ne... |
257cb71f-ac53-4ac1-a9ad-5303106da70b | 2 | public static void main(String... args) throws Exception {
CuratorFramework client = null;
PathChildrenCache cache = null;
client = CuratorFrameworkFactory.newClient("localhost:2181", new ExponentialBackoffRetry(1000, 3));
client.start();
// in this example we will cache data. ... |
c4ffbddd-28b5-4784-988c-bb790f833028 | 7 | private void paintRightBorder(Graphics g, int x, int y, int width, int height, Color color) {
g.setColor(color);
// Top Line
if (!afterHighlighted || tabSpacing)
g.drawLine(x, y, x + width - 1, y);
// Right Line
if (drawTopLine)
g.drawLine(x + width - 1, y, x + width - 1,... |
f1cd65cf-a0a6-490a-aa30-5281504124a6 | 4 | private String podeliNaSlogovePoSamoglasnicima() {
/*
prvobitna podela reci na slogove gde se rec
na slogove deli samo po samoglasnicima
*/
//ukoliko je rec od 3 slova ili manje nemoj je rastavljati vrati celu rec
if (this.rec.length() <= 3) {
return this.rec;
... |
eccfaa6c-be73-45d3-8796-0991cc4b8708 | 6 | public void kill() {
try {
if (process == null)
return;
// Kill and wait for the process to be really killed
process.destroy();
process.waitFor();
// Close the associated streams
if (process.getInputStream() != null)
process.getInputStream().close();
if (process.getOutputStream() != nul... |
b159817a-880d-4551-ba58-95abb232c6d0 | 7 | public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
{
if (par1World.getBlockMaterial(par3, par4, par5) != Material.water)
{
return false;
}
int i = par2Random.nextInt(radius - 2) + 2;
byte byte0 = 2;
for (int j = par... |
c669395c-d297-4e32-8d38-21c30b056198 | 8 | public void setLeadingTabIndex(int tabPlacement, int index) {
leadingTabIndex = index;
Dimension viewSize = viewport.getViewSize();
Rectangle viewRect = viewport.getViewRect();
switch (tabPlacement) {
case TOP:
case BOTTOM:
... |
7d66e7d8-b0cb-4a99-a615-c19d097b2b63 | 7 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BoundingBox that = (BoundingBox) o;
if (Double.compare(that.maxX, maxX) != 0) return false;
if (Double.compare(that.maxY, maxY) != 0) return fa... |
e4e84f1c-fd84-453f-bc7a-b0b42d34e644 | 9 | private static Response _AjaxSaveAlarm(String id, String name, String validfrom, String validthru, String alarmtime, String enabled, String weekdays, String imusic) {
try {
AlarmSchedule s = new AlarmSchedule();
if(!id.equals("0") && !id.equals(""))
s.i_alarm = Integer.parseInt(id);
s.alarmhour =... |
ec6a74ce-0ec9-4cd5-b881-f09e75f96798 | 9 | private CommunityDAO() {
// Create the Derby DB
try
{
Class.forName(DRIVER);
}
catch( ClassNotFoundException e )
{
logger.severe(e.toString());
}
try
{
StringBuilder connect = new StringBuilder();
connect.append("jdbc:mysql://");
connect.append(System.getProperty("db.host"));
co... |
9a72e2c0-adb5-4853-a5bb-2d3eaa223755 | 8 | private boolean pInstruction(String instruction) {
if(instruction.length() <= 2) return false;
String spec = instruction.substring(2);
int loc = 0;
boolean isInt = true;
try{
loc = Integer.parseInt(spec);
} catch (NumberFormatException e) {
isInt = false;
}
if (spec.equals("all"))
reg.printAll(... |
9743d960-4541-4d11-b6e2-831fc17af98d | 5 | Cursor cursorFromIcon(SysIcon icon,HotSpotPos spot){
Cursor cur = null;
Toolkit tk = Toolkit.getDefaultToolkit();
try{
if(icon.Icon != null){
Image img = icon.Icon.getImage();
Point hotSpot = spot.getPoint(img,tk);
String name = icon.toString()+count;
cur ... |
03c069f1-b181-43d4-a86f-bd2925d70293 | 6 | private void createTaskListEntries() {
List<TaskList> lists = taskListService.getAll();
System.out.println(lists.size() + " Listen gefunden");
List<Priority> priorities = priorityService.getAll();
List<State> stati = statusService.getAll();
if(priorities == null || priorities.size() == 0) {
System.out... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.