method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
11951823-31c1-4680-b306-536a30365193 | 9 | public int hashCode() {
int h = instanceOrClass.hashCode();
h += method.hashCode();
if (n > 0) {
h += (arg1 == null ? 0 : arg1.hashCode());
if (n > 1) {
h += (arg2 == null ? 0 : arg2.hashCode());
if (n > 2) {
h += (arg3 == null ? 0 : arg3.hashCode());
if (n > ... |
ad3b1891-642a-4e96-aa1f-bda9aab196b1 | 2 | public static String getString(String domain, String key, String fallback)
{
if ( !config.containsKey(domain) )
config.put(domain, new HashMap<String,String>());
if ( !config.get(domain).containsKey(key) )
config.get(domain).put(key, fallback);
return config.get(domain).get(key);
} |
67244626-0d1e-4196-9f2c-dd0effe4f53b | 4 | @Override
public void deserialize(Buffer buf) {
super.deserialize(buf);
targetId = buf.readInt();
casterCellId = buf.readShort();
if (casterCellId < -1 || casterCellId > 559)
throw new RuntimeException("Forbidden value on casterCellId = " + casterCellId + ", it doesn't re... |
d87a5364-32fe-4286-abb6-3b09cae60ddb | 5 | @Override
protected boolean executeGameEvents(Integer[] events) {
if(events == null){
events = new Integer[0];
}
for(Integer event : events){
switch (event) {
case EVENT_START_GAME:{
break;
}
case EVENT_SHOW_COUNTDOWN:{
break;
}
case EVENT_MATCH_OVER:{
endMatch();
break;
}... |
3952abe9-db63-4bc9-b3f0-acb558d477c5 | 8 | protected List<Node> generateSuccessors(Node node) {
List<Node> ret = new LinkedList<Node>();
int x = node.x;
int y = node.y;
if (y < map.length - 1 && map[y + 1][x] == 1) {
ret.add(new Node(x, y + 1));
}
if (x < map[0].length - 1 && map[y][x + 1] == 1) {
... |
767706b6-741a-48cc-b984-7403097755b7 | 2 | void syncToDB() {
Map<K, Modification> toMods = mods;
mods = new ConcurrentHashMap<>();
new Thread(() -> {
for (Map.Entry<K, Modification> entry : toMods.entrySet()) {
K k = entry.getKey();
Modification modification = entry.getValue();
if (modification.isPut) {
synchronizer.put(k, modi... |
871328ed-5d63-4169-b5ae-905d15dbed39 | 1 | public void actionPerformed(ActionEvent e) {
SelectionDrawer drawer = new SelectionDrawer(automaton);
NondeterminismDetector d = NondeterminismDetectorFactory
.getDetector(automaton);
State[] nd = d.getNondeterministicStates(automaton);
for (int i = 0; i < nd.length; i++)
drawer.addSelected(nd[i]);
Aut... |
25e74ff0-f49e-4279-8ad7-2e6da312c5d6 | 9 | public static boolean handleSurvivalExceptions(ArrayList<String[]> clinicalValues){
boolean valid = true;
HashSet<String> vitals = new HashSet<String>();
for (int i=0; i<clinicalValues.size(); i++){
if (clinicalValues.get(i).length<3){
System.err.println("Please enter 3 columns for log rank");
return f... |
ea79c75c-e16b-4fd2-9064-ea23844d4dbe | 5 | public static String reverseComlement(String str){
char[] dna = str.toCharArray();
char[] dnaReverseComplement = new char[dna.length];
int j = 0;
for (int i = dna.length-1; i >=0 ; i--) {
switch (dna[i]) {
case 'A' : dnaReverseComplement[j] = 'T';break;
case 'T' : dnaReverseComplement[j] = 'A';break;
... |
7b964a6f-031a-414e-8ef6-2036ecd99cad | 5 | public void hyperMutate(int mutations, Random rand) {
int mutationsDone = 0;
while (mutationsDone < mutations) {
int indexA = rand.nextInt(projectSize);
int indexB = rand.nextInt(projectSize);
if (indexA == indexB) {
if (indexB == projectSize-1)
indexB--;
else
indexB++;
... |
da9a660b-e394-4f2d-ab9d-06d4dfa0e664 | 3 | public void binaryFilter(double cutOff, double value) {
for(int i=0; i < data.length; i++) {
double[] block = data[i];
for(int j=0; j < block.length; j++) {
block[j] = (block[j] >= cutOff ? 1.0 : 0.0) * value;
}
}
} |
d4089f49-8453-42dc-a96c-ff6e0030558c | 5 | @Override
public void toFtanML(Writer writer) {
try {
//Calculate count of double quotation marks (") and single quotation marks (') in the string
int numberDQuotes = 0;
int numberSQuotes = 0;
for (int i=0;i<value.length();++i) {
switch (value.charAt(i)) {
case '"':
++numberDQuotes;
bre... |
1772ae1c-8ad5-4024-a73e-634c339a5ef6 | 2 | static LookAndFeel getFactory(CHOICE choice) {
switch (choice) {
case WINDOWS:
lookAndFeel = new WindowsLookAndFeel();
break;
case MOTIF:
lookAndFeel = new MotifLookAndFeel();
break;
}
return lookAndFeel;
... |
6b198d0b-61f3-4e40-b64e-b9081c366a16 | 2 | public static void expand() {
boolean bit = false;
while (!BinaryStdIn.isEmpty()) {
int run = BinaryStdIn.readInt(lgR); // read lgR bit
for (int i = 0; i < run; i ++)
BinaryStdOut.write(bit);
bit = !bit;
}
BinaryStdOut.close();
} |
e62bfb63-0f71-4215-906c-012ccf1def70 | 8 | private static void exerciseList(List<MutableTypes> list, long length, Runnable setSize) {
assertEquals(length, list.size());
gcPrintUsed();
long start = System.currentTimeMillis();
do {
System.out.println("Updating");
long startWrite = System.nanoTime();
setSize.run();
populate... |
5038fe93-0fbb-4e81-8f5c-24e9e837926a | 0 | protected void interrupted() {
end();
} |
0ddcbd54-0697-40cc-b7fa-1a7f6c1997b6 | 2 | public static JTableRenderer getVertex(Component component)
{
while (component != null)
{
if (component instanceof JTableRenderer)
{
return (JTableRenderer) component;
}
component = component.getParent();
}
return null;
} |
9d99da18-3f83-4fe2-9011-e3df2d3f5d22 | 3 | public static final void exampleContantsManipulations() {
System.out.println("Starting Cyc constant manipulation examples.");
try {
CycConstant cycAdministrator = access.getKnownConstantByName("CycAdministrator");
CycConstant generalCycKE = access.getKnownConstantByName("GeneralCycKE");
access... |
79ee4ef6-aaca-47dc-8a26-86a71da3be25 | 1 | public void run() {
for(int i = 1 ; i < 100 ; i ++)
{
System.out.println("Runnable implements Thread " + i + " !");
}
} |
977666e6-b8ba-42d1-8428-6b5733be1091 | 4 | public static String camel4underline(String param) {
Pattern p = Pattern.compile("[A-Z]");
if (param == null || param.equals("")) {
return "";
}
StringBuilder builder = new StringBuilder(param);
Matcher mc = p.matcher(param);
int i = 0;
while (mc.find()) {
builder.replace(mc.start() + i, mc.end() + ... |
5805a416-73a4-4e66-a5ab-e4ebe2cdccb5 | 5 | public static boolean BookingCollides(int cabin_id, Date from_date, Date to_date) {
Database db = new Database();
ArrayList<Booking> bookings = db.getBooking(cabin_id);
db.close();
for(Booking b : bookings) {
if(to_date.compareTo(b.getDate_To()) <= 0 && to_date.compareTo(b.getDate_From()) >= 0)
return tr... |
2c94dab6-5288-48fa-84da-a35a13526381 | 0 | public void setParams(Object params) {
this.params = params;
} |
3b535f41-c9fc-44fe-8be8-334b38d3e31b | 7 | protected void generateMetaLevel(Instances newData, Random random)
throws Exception {
m_MetaFormat = metaFormat(newData);
Instances [] metaData = new Instances[m_Classifiers.length];
for (int i = 0; i < m_Classifiers.length; i++) {
metaData[i] = metaFormat(newData);
}
for (int j = 0; j <... |
72728f4e-1baf-4f5d-8054-a3540a51f6b2 | 2 | public static void appendHostAddress(StringBuilder sbuf, InetAddress addr) {
if (addr == null) {
throw new IllegalArgumentException("addr must not be null");
}
if (!(addr instanceof Inet4Address)) {
throw new IllegalArgumentException("addr must be an instance of Inet4Addr... |
cf77275d-f2e4-4c49-bd38-582019cfd792 | 2 | private void appendDigits(String digits,int digitIndex,List<String> list,StringBuffer letter){
if(digitIndex == digits.length()){
list.add(letter.toString());
return;
}
int index= digits.charAt(digitIndex)-48;
String buttonString = board[index];
System.out... |
eddfea4f-7a6c-4d96-98a7-a709cd25ad7b | 8 | protected void initRunnableTask() {
if(taskThread != null) {
new IllegalStateException("The Task Thread has already been created");
}
//Create the Thread but don't start it
if(progressDescriptor.getRunnableTask() != null) {
taskThread = new Thread(progressDescript... |
a66e7244-141f-4bf9-8f76-6602733ebb81 | 6 | static int entrance() {
int x = 0, y = 0;
for (int i = 0; i < layout.length; ++i)
for (int j = 0; j < layout[i].length; ++j) {
if (layout[i][j] == 2) {
x = i;
y = j;
break;
}
}
lea... |
5df48a0d-2b1b-44a5-8b96-86abc9b0b1d2 | 5 | public boolean play(Player player) {
System.out.println("Welcome to Sudoku!\nYour goal is to fill your board up with numbers 1-9 while abiding by the following rules: in each row there can be no repeated numbers, in each column there can be no repeated numbers, and in each square (3x3 space alloted) there can be no r... |
dfdeb4f3-2e59-41a9-bdf6-a5033ec367d3 | 3 | public static long inet_pton(String ip) {
if (ip == null) return -1;
long f1, f2, f3, f4;
String tokens[] = ip.split("\\.");
if (tokens.length != 4) return -1;
try {
f1 = Long.parseLong(tokens[0]) << 24;
f2 = Long.parseLong(tokens[1]) << 16;
f3 = Long.parseLong(tokens[2]) << 8;
f4 = Long.parseLong... |
6480a1de-c7ea-41f0-82d3-426cffbd1f63 | 4 | public void startElement(String uri, String localName, String qName, Attributes attributes){
if(qName.equals("objects")){
uiElements = new LinkedList<UIElement>();
}
else if(qName.equals("label")){
element = new Label();
element.setType("label");
}
... |
326fb1f6-bbd3-4fd8-9c18-0788840c3af8 | 6 | public static boolean handlePawnJump(){
boolean shouldCallContinue = false; // Returns whether the while loop should skip the current iteration
if (target == null && chosen.getType().equals("PAWN") && !chosen.hasMoved() && Math.abs(myYCoor - targYCoor) == 2 && chosen.validMovement(myXCoor, myYCoor, targXCoor, targY... |
4b2af492-fbfd-4da9-893c-ffe2e3a5f4be | 2 | public void testMonthNames_monthMiddle() {
DateTimeFormatter printer = DateTimeFormat.forPattern("MMMM");
for (int i=0; i<ZONES.length; i++) {
for (int month=1; month<=12; month++) {
DateTime dt = new DateTime(2004, month, 15, 12, 20, 30, 40, ZONES[i]);
String... |
59e504de-2c6f-45b8-9ce0-86e2e91b08f5 | 0 | public void setPrice(int price)
{
this.price = price;
notifyListeners();
} |
7ec0fcea-e1a1-4ff4-91cc-bd375fbe1898 | 5 | public User authenticate(String login, String password, HttpServletRequest request) throws BusinessException {
// TODO ver um padrõa de projeto para isso tipo fabrica.
User user = null;
user = userDAO.findOneByField("login", "=", login);
try {
// Usuário informou um login valido
if(user != null) {
... |
54fe1e89-4d24-454a-b4b3-1de24bf7f2b9 | 1 | @Override
public boolean allowSource( ConnectionableCapability item, ConnectionFlavor flavor ) {
return item != this || allowSelfReference( flavor );
} |
6b220920-8f98-47ba-ae1b-8bd3d3cb9f55 | 5 | public int getAddiction(String player, Column column) {
String query = "SELECT * FROM nosecandy WHERE playername='" + player + "';";
ResultSet result = null;
result = this.sqlite.query(query);
try {
if (result != null && result.next()) {
String name = result.getString("playername");
int addiction = ... |
e967e680-7d49-44b1-a3dc-817a41af9880 | 2 | public boolean playerIsAffected(Player player) // returns whether or not a player is currently affected by Arctica
{
boolean affected = false;
if((null != player ) &&
(playersToAffect.contains(player.getName())))
{
affected = true;
}
return (affected);
} |
6c1edecf-cb5d-4f0a-b4f2-5ee951f8ea1c | 4 | public final TLParser.andExpr_return andExpr() throws RecognitionException {
TLParser.andExpr_return retval = new TLParser.andExpr_return();
retval.start = input.LT(1);
Object root_0 = null;
Token string_literal112=null;
TLParser.equExpr_return equExpr111 = null;
TLPar... |
3629ea43-6ef6-4207-b0a7-b2bb99c037fb | 9 | public boolean isInterleave(String s1, String s2, String s3) {
if (s1.length() + s2.length() != s3.length()) {
return false;
}
boolean[] m = new boolean[s1.length() + 1];
m[0] = true;
for (int i = 1; i <= s1.length(); i++) {
m[i] = m[i - 1] && s3.charAt(i... |
6badf669-af81-4343-b5cc-da067c692b7d | 2 | public void leave(String address) {
for (int i = 0; i < size(); i++) {
if (getNode(i).getAddress().equals(address)) {
notifySuccessor(getSuccessor(getNode(i)), getNode(i).getKeys());
nodeList.remove(i);
}
}
} |
e47818ad-89f0-4a63-9451-8009a05ccf54 | 5 | public void unpackBuild() throws Throwable
{
File configBackupDir = new File("config_backup");
File modsBackupDir = new File("mods_backup");
if (configBackupDir.exists())
FileUtils.deleteDirectory(configBackupDir);
if (modsBackupDir.exists())
FileUtils.deleteDirectory(modsBackupDir);
File configD... |
d02ffe6c-ddc4-4bf6-9b5b-77f1af4b4290 | 5 | private void assertMe() {
assert x != 0 || y != 0;
assert x == 0 || x == 1 || x== -1;
assert y == 0 || y == 1 || y == -1;
} |
25159075-f334-4388-8186-31e1ed6c9656 | 8 | public SubsetSum(int[] arr) {
int sum = Comparison.SUM(arr);
System.out.println("Sum "+sum);
int m[][] = new int[arr.length][sum+1];
for(int i=0;i<arr.length;i++)
m[i][arr[i]] = 1;
for(int j = 0;j<=sum;j++){
for(int i=1;i<arr.length;i++){
if(j == arr[i]){
m[i][j]=1;
continue;
}
... |
486a8487-940d-4976-befc-992d8d4b9056 | 9 | private void descargaProcedimiento(String nombre) {
int procACargar = 0;
while (!procedimientos.get(procACargar).getNombre().equals(nombre))
procACargar++;
for (int i = 0; i < procedimientos.get(procACargar).getvariablesEnterasL(); i++) {
contEntLoc.remove(contEntLoc.size()-1);
}
for (int i = 0; ... |
d66969cf-113c-4bfe-b104-eac6e57b86a5 | 4 | public void mostraDialegVictoria( String missatge )
{
boolean te_situacio_inicial = PresentacioCtrl.getInstancia().esPartidaAmbSituacioInicial();
try
{
PresentacioCtrl.getInstancia().finalitzaPartida();
}
catch ( Exception excepcio )
{
VistaDialeg dialeg_error = new VistaDialeg();
String[] botons_... |
45d4017c-85f2-4d8b-a302-3c98e122a2ac | 7 | public void printBoard() {
for (int row = 0; row < board.getN(); row++) {
for (int col = 0; col < board.getN(); col++) {
if (board.get(row,col) == PLAYER1_VAL)
System.out.print(PLAYER1_CELL);
else if (board.get(row,col) == PLAYER2_VAL)
System.out.print (PLAYER2_CELL);
else
System.out.pri... |
b9dadfd6-9d90-4153-b853-792a90be5cb4 | 7 | public Object make(HGPersistentHandle handle,
LazyRef<HGHandle[]> targetSet, IncidenceSetRef incidenceSet)
{
HGPersistentHandle[] layout = graph.getStore().getLink(handle);
Pair<?,?> result = (Pair<?,?>)TypeUtils.getValueFor(graph, handle);
if (result != null)
return result;
Object first = null, second... |
8087c653-efc7-4bf9-b527-590da9a8767c | 8 | @SuppressWarnings("deprecation")
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String input;
//INITIALIZE THE PARAMETERS
initParams();
int listenerPort= 9898;
//ASSIGN MACHINE IDs
String fullMachineID = getFullMac... |
2be8e0e6-026c-4a86-b80d-6b015922b6bf | 0 | public void reportException(IllegalArgumentException e) {
JOptionPane.showMessageDialog(getParent(), "Bad format!\n"
+ e.getMessage(), "Bad Format", JOptionPane.ERROR_MESSAGE);
} |
1dde3cde-72fd-4f7e-88c3-3775643c0306 | 7 | public static String removeContraction(String s){
String[] words = s.split("\\s+");
String output = "";
for (int i=0; i<words.length; i++){
String current = words[i];
if (current.contains("'")){
int index = current.indexOf("'");
if (current.charAt(index+1) == 's'){
output += current.substring(0... |
194d9c25-117b-4acc-8542-73d8f3bf8386 | 7 | public void execute() throws Exception {
int keuze = menu.getMenuKeuze();
quizCatalogus = new QuizCatalogus();
opdrachtCatalogus = new OpdrachtCatalogus();
quizCatalogus.lezen();
//De code die hier stond om enkele opdrachten en quizzen aan te maken staat onderaan buiten de klasse in commentaar
switch (... |
b0e50240-27d4-4baa-80db-0bdf9aa77c49 | 1 | @Transactional
public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException{
try {
Person p = personModelDao.getPersonByLogin(username);
boolean enabled = true;
boolean accountNonExpired = true;
boolean credentialsNonExpired = true;
boolean accountNonLocke... |
32abc1f2-4d42-4872-b196-96e1c035c1ad | 6 | private void parseTranscripts() {
logger.info("Parsing gene model file...");
long tstart = System.currentTimeMillis();
this.transcripts = new ArrayList<TranscriptRecord>();
try {
BufferedReader reader = IOUtils.toBufferedReader(new InputStreamReader(new FileInputStre... |
20347936-845e-45d4-94a9-9d3b271327c1 | 4 | private final String decode(final String val) throws SAXException {
StringBuffer sb = new StringBuffer(val.length());
try {
int n = 0;
while (n < val.length()) {
char c = val.charAt(n);
if (c == '\\') {
n++;
c = val.charAt(n);
if (c == '\\') {
sb.append('\\');
} el... |
048414a2-d0b0-487b-95a4-a3537a83998f | 8 | public Hand[] deel(int aantalHanden, String algorythm) {
if (aantalHanden * Vars.handGrote > Vars.SET_GROTE)
new IndexOutOfBoundsException("Alle kaarten zijn op! Sorry :( Volgende potje mag je meespelen.");
if(algorythm.equals("fikius")){
Hand[] out = new Hand[aantalHanden];
for(int i = 0; i < out.lengt... |
ccdb9a2a-2b74-488e-8f0b-77784798b9f7 | 7 | private ArrayList<Profile.Entry> toArrayList(int partId,
double startTime, double finishTime) {
if(partId >= partitions.length || partId < 0) {
throw new IndexOutOfBoundsException("It is not possible to " +
"add a partition with index: " + partId + ".");
}
ArrayList<Entry> subProfile = new ArrayL... |
195f09b3-d79d-428b-b9d0-1886426e8953 | 0 | public String getKeyName() {
return this.name;
} |
5fab6952-5172-48ed-b83d-828f4973822b | 2 | public Mapper(Board board, int whatGameType, int useZones) {
game = board;
gameType = whatGameType;
if(gameType == 0) tileWidth = 64;
gameZones = useZones;
if(gameZones == NO_ZONES) {
zoneArray = new Tiles[1][1];
zoneCountX = 1;
... |
464f7e77-60c8-41a5-aec6-0c6bd4c024ba | 4 | public static boolean isSyntax (char c) {
return c == ')' || c == '(' || c == ';' || c == '[' || c == ']';
} |
7022b737-1821-4a29-96d2-fe325accd39d | 1 | public void moveAutomatonStates() {
Object[] vertices = vertices();
for (int i = 0; i < vertices.length; i++) {
State state = (State) vertices[i];
Point2D point = pointForVertex(state);
state.setPoint(new Point((int) point.getX(), (int) point.getY()));
}
} |
b72d8911-5b13-46f3-a021-4f31c0d869d5 | 4 | public boolean isSymmetric(){
boolean test = true;
if(this.numberOfRows==this.numberOfColumns){
for(int i=0; i<this.numberOfRows; i++){
for(int j=i+1; j<this.numberOfColumns; j++){
if(this.matrix[i][j]!=this.matrix[j][i])test = false;
... |
0d2e9029-8c34-4e03-9232-fe9e969216f0 | 1 | private String viewTempDigit(final int td) {
String s = "";
StringBuilder sb = new StringBuilder();
for (int i = 1;i<=td-1;i++) {
sb.append(i).append(" ");
}
sb.append(td);
return sb.toString();
} |
7e0d7051-d3d3-4ab6-9d55-42f880e75fa9 | 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... |
7db8495b-5e0c-460a-b58c-81581f7ab4b8 | 9 | public int uniquePathsWithObstacles(int[][] obstacleGrid) {
if (obstacleGrid == null || obstacleGrid.length == 0
|| obstacleGrid[0].length == 0)
return 0;
int row = obstacleGrid.length;
int col = obstacleGrid[0].length;
int[] path = new int[col];
... |
688587b0-c4af-4916-9a61-db68c6a4e2f6 | 4 | protected void AdjustBuffSize()
{
if (available == bufsize)
{
if (tokenBegin > 2048)
{
bufpos = 0;
available = tokenBegin;
}
else
ExpandBuff(false);
}
else if (available > tokenBegin)
available = bufsize;
else if ((tokenBegin - available) < 204... |
ee85b600-a232-4bc9-8dcc-3af664729dd7 | 6 | public static List<String> generateAddress(String[] nums, int position, List<String> addressList, String tmp) {
String[] parts = tmp.split("\\.");
if(parts.length == 5) {
return addressList;
}
if(position == nums.length) {
if(parts.length == 4) {
addressList.add(tmp);
return addressList;
}else ... |
2216c6a1-e1cb-477a-bdbd-9a1e08abee81 | 2 | private void inorderRec(List<Integer> list, TreeNode lastroot) {
if(lastroot.left != null)
inorderRec(list,lastroot.left);
list.add(lastroot.val);
if(lastroot.right != null)
inorderRec(list,lastroot.right);
} |
4c2cdfde-58c4-4209-ba9c-395c0601b7f9 | 3 | private int calcDmg() {
if (leadership > 92) { // For high Leadership commanders
return Math.round(leadership + intelligence * 2 / 10);
} else if (combatPower > 92) { // For high combatPower commanders
return Math.round(combatPower * 8 / 10 + leadership ... |
538e1943-7b3e-4a93-94d3-e050d4eaea95 | 4 | @Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if ((index % 2) == 0) {
if (!isSelected) {
... |
13a185b4-a29e-47cc-b2bc-e19b04250b49 | 8 | Set<Position> getDiagNeighbors(Position p) {
Set<Position> neighbors = new HashSet<Position>();
if (p.i+1 < n && p.j+1 < m) neighbors.add(board[p.i+1][p.j+1]);
if (p.i-1 >= 0 && p.j+1 < m) neighbors.add(board[p.i-1][p.j+1]);
if (p.i+1 < n && p.j-1 >= 0) neighbors.add(board[p.i+1][p.j-1]);
if (p.i-1 >=0 && p... |
1969fb51-601d-458c-bc12-fb3ace9b3ffb | 8 | public void RandomizeNodeConnections(int X0, int Y0, int XLoc, int YLoc, int X1, int Y1) {// Sparsely connect a node with its neighbors.
double Azar;
Node ctr = GetNodeFromXY(XLoc, YLoc);// get this from xloc and yloc
ctr.CleanEverything();// clean out all dead neighbor links and routes that refer to them
... |
7d139e75-4c6f-441a-a01b-ab051b32f0cb | 8 | protected void drawBase(Graphics2D g2d, int x, int y, int colWidth, int rowHeight, int row, int site, Sequence seq) {
if (translate) {
throw new IllegalStateException("Not sure drawBase is supposed to get called for a translated sequence..?");
}
if (site>=seq.length())
base[0] = ' ';
else
base[0] = ... |
9d396492-9181-4c60-b269-fa840e907ca1 | 8 | public Annotation addAnnotation(Annotation newAnnotation) {
// make sure the page annotations have been initialized.
if (!isInited) {
try {
initPageAnnotations();
} catch (InterruptedException e) {
logger.warning("Annotation Initialization interup... |
21e2c639-276e-4144-8312-cc8cccab41d4 | 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... |
bd35a569-05b4-4a4d-93ba-485a26faea0b | 2 | private void finish() {
if (restricted == null) {
JOptionPane.showMessageDialog(parent,
"There is no one right answer in this case.", "Ambiguity",
JOptionPane.ERROR_MESSAGE);
return;
}
HashSet toAdd = new HashSet(restricted);
toAdd.removeAll(alreadyChosen);
Iterator it = toAdd.iterator();
wh... |
f5f7870a-ba57-4ade-b073-a5bfb48e2bb7 | 5 | public void addContact
(
InetAddress iaIn
, int iPort
, String strName
, int iSysState
, int iState
, String strStatus
)
{
InetAddress iaTmp = this.normalizeAddressIfLocal(iaIn);
if (this.idxContact(iaTmp) == -1)
{
synchronized(this.list)
{
try
{
EzimContact ecTmp = null;
... |
f18be58b-fc89-4e11-9358-938da39a86f1 | 8 | public static void main(String[] args) throws RemoteException {
/*
try {
java.rmi.registry.LocateRegistry.createRegistry(1099);
} catch (RemoteException e) {
e.printStackTrace();
}
*/
if (args.length < 1) {
System.err.println("Please specify the registry of this Scheduler!");
return;
}
//... |
75425b9c-bc77-4a9e-a2e2-2da7312f7830 | 0 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
} |
71fbe3dc-35e7-4d09-97f1-921318576a06 | 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;
} |
701c642a-def7-4dbb-b3bb-f25b2ba0d57a | 7 | public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5)
{
if (par5 == 2 && par1World.isBlockNormalCube(par2, par3, par4 + 1))
{
return true;
}
if (par5 == 3 && par1World.isBlockNormalCube(par2, par3, par4 - 1))
{
re... |
c27b4fa8-3a95-42d6-800f-a4889fe66737 | 4 | public Class<?> loadClass(String url, String name) throws ClassNotFoundException {
try {
URL myUrl = new URL(url);
URLConnection connection = myUrl.openConnection();
InputStream input = connection.getInputStream();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int d... |
fc7c1d89-bbbd-4a74-86b4-16dcbbd3982b | 4 | public AST rBlock() throws SyntaxError {
expect(Tokens.LeftBrace);
AST t = new BlockTree();
while (true) { // get decls
try {
t.addKid(rDecl());
} catch (SyntaxError e) { break; }
}
while (true) { // get statements
try {
... |
7cbc11bc-9095-4c2d-b0e5-fdc40932f934 | 5 | public Option<Zipper<A>> deleteRight() {
return left.isEmpty() && right.isEmpty()
? Option.<Zipper<A>>none()
: some(zipper(right.isEmpty() ? left.tail()._1() : left,
right.isEmpty() ? left.head() : right.head(),
right.isEmpty() ? right : right.... |
84d49e4b-9d2e-44ea-9f97-9b0d2d6d2403 | 5 | public boolean copierFichier(ObjectInputStream input, ObjectOutputStream output) throws ClassNotFoundException { //Methode permettant la copie d'un fichier
boolean resultat = false;
File source = null;
File destination = null;
// Declaration des flux
FileInputStr... |
58164cab-9e65-4170-b332-6928b4df5be1 | 4 | StringBuffer generateCode () {
/* Make sure all information being entered is stored in the table */
resetEditors ();
/* Get names for controls in the layout */
names = new String [children.length];
for (int i = 0; i < children.length; i++) {
TableItem myItem = table.getItem(i);
String name = myItem.g... |
cb4f6b08-5e5a-4e7e-a12f-b986e56b8888 | 2 | private static byte[] insertGap(byte[] info, int where, int gap) {
int len = info.length;
byte[] newinfo = new byte[len + gap];
for (int i = 0; i < len; i++)
newinfo[i + (i < where ? 0 : gap)] = info[i];
return newinfo;
} |
9ec5ce10-18a3-4e40-a4d0-c844ad4bcf6c | 9 | public static String extractFileNameFromUrl(String url) {
HashMap<Integer, String> map = new HashMap<Integer, String>();
map.put(4, "html,aspx");
map.put(3, "jsp,php");
StringBuilder fileName = null;
StringBuilder builder = new StringBuilder(url);
boolean found = false;
for (int i = builder.lastIndexOf(".... |
b629022e-079d-4194-a491-f344aec4f8ce | 2 | @Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
if ((columnIndex == 0) || (columnIndex == 5)) {
return true;
}
return false;
} |
c387dfad-44ff-4a94-9be2-7463f07ed953 | 1 | @Override
public Converter put(String key, Converter value) {
Converter v = super.put(key, value);
if (v != null) {
throw new IllegalArgumentException("Duplicate Converter for "
+ key);
}
return v;
} |
ee424df1-468e-4c2a-9afa-6f50936114fb | 0 | @Override
public String toString() {
return "Action("+b+" goes to " + p + ")";
} |
566f190a-0462-4034-9676-2452351da5b1 | 4 | public void deleteMealById(long id) {
Session session = null;
Transaction tx = null;
SimpleMealDaoImpl dao = getSimpleMealDaoImpl();
try {
session = HbUtil.getSession();
//TRANSACTION START
tx = session.beginTransaction();
SimpleMeal meal... |
c7aec927-8eb0-405d-a575-c74e578d4f3b | 9 | public static AbstractUIItem createItem(FeatureType t, Panel panel)
{
switch(t) {
case Constant:
return new ConstantUIItem(panel);
case Sink:
return new SinkUIItem(panel);
case Source:
return new SourceUIItem(panel);
case Saddle:
return new SaddleUIItem(panel);
case Center:
return new Center... |
5ca21d01-ec5d-4df0-b182-b5e96300a3ac | 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... |
dc71b6c6-b662-4558-9749-13f1959ef32f | 7 | public static void addAbilities(LivingEntity entity, SpawnReason spawnReason)
{
// Fetch the mob config for this entity
MobAbilityConfig ma, rateMa;
rateMa = ma = AbilityConfig.i().getMobConfig(entity.getWorld().getName(), ExtendedEntityType.valueOf(entity), spawnReason);
// If there is not config for the e... |
a5142eec-5399-4697-9dec-e25ba17b6890 | 7 | public void collision() {
for (int i = 0; i < mobs.size(); i++) {
Mob m = mobs.get(i);
if (m instanceof Projectile) {
for (int c = 0; c < mobs.size(); c++) {
Mob a = mobs.get(c);
if (!(a instanceof Projectile)) {
if (m.getBounds().intersects(a.getBounds())) {
System... |
b4f13d3c-6d78-44bf-b0de-7feafc5d41cb | 4 | public static void rectangle(double x, double y, double halfWidth, double halfHeight) {
if (halfWidth < 0) throw new RuntimeException("half width can't be negative");
if (halfHeight < 0) throw new RuntimeException("half height can't be negative");
double xs = scaleX(x);
double ys = scal... |
db5442b0-d9ec-4a2c-91ab-424fb29d8192 | 6 | private String stringify(final InputStream inputStream) {
if (inputStream == null) {
return "";
}
try {
int ichar;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (;;) {
ichar = inputStream.read();
if (ichar < 0) {
break;
}
baos.write(ichar);
}
return baos.toSt... |
e19369a4-1d97-4f1f-8b69-8c62ad3a5954 | 3 | public Set<Long> getListIDs() {
if (toListIDs == null || toListIDs.length() == 0)
return null;
HashSet<Long> listIDs = new HashSet<Long>();
for (String listID : toListIDs.split(","))
listIDs.add(Long.parseLong(listID));
return listIDs;
} |
223245c2-d68e-4411-9257-fc567fc970e9 | 4 | public static void insertAlerts(EventsBean event) {
PreparedStatement pst = null;
Connection conn=null;
String str = "There is an event "+event.getEventName() +" added for category ";
try {
conn=ConnectionPool.getConnectionFromPool();
pst = conn
.prepareStatement("INSERT INTO STUDENT_ALERTS (PE... |
63886753-d937-479b-afbb-daeeeccf1a70 | 5 | @Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Usuario)) {
return false;
}
Usuario other = (Usuario) object;
if ((this.login == null && other.login != null) |... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.