method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
51802de9-bb2b-4fb7-82a7-e1203861f6e9 | 3 | public void drawCenteredStringMoveXY(String string, int x, int y, int color, int waveAmount) {
if (string == null) {
return;
}
x -= getTextWidth(string) / 2;
y -= baseHeight;
for (int index = 0; index < string.length(); index++) {
char c = string.charAt(index);
if (c != ' ') {
drawCharacter(chara... |
5f5a213a-7627-4fff-a6cb-9acb6287196a | 5 | private boolean checkRows()
{
boolean deleteThisRow;
boolean retval = false;
for(int i = 0; i < rows; i++)
{
deleteThisRow = false;
for(int h = 0; h < columns; h++)
{
if(bricks[i][h] == null)
... |
fc2a7f4a-9322-4569-a437-69058dcfd101 | 3 | private void geocentreToTopocentre(double time, Vector position,
Vector velocity) {
final double FL = 1.0 / 298.257; /* Flattening of the earth */
final double RE = 6378.14; /* Radius of Earth in km. */
final double OMEGA = 7.2921151467e-5; /*
* Earth's rotation in
* radians/second
... |
1b48d485-cece-4019-8812-64a8e65db2ef | 1 | public ArrayList<Integer> traversal(ListNode head){
ArrayList<Integer> res = new ArrayList<Integer>();
ListNode p = head;
while(p != null){
res.add(p.val);
p = p.next;
}
return res;
} |
26c819ef-a638-4bb6-8401-bfc294de4652 | 2 | public static void printPattern(boolean[] pattern){
System.out.print("|");
for (int i = 0; i < pattern.length; i++){
if (pattern[i]) System.out.print(""+1);
else System.out.print(""+0);
System.out.print("|");
}
} |
d1ee1439-8b8a-4e2f-9c5b-37064157a1fa | 0 | @Basic
@Column(name = "PRP_ID_FUNCIONARIO")
public Integer getPrpIdFuncionario() {
return prpIdFuncionario;
} |
6477d207-a764-48af-8df1-4d59886b5596 | 4 | private void backward(int[] sequence, double[][] bwd, double[] scaling) {
int T = sequence.length;
int S = this.getNumberOfStates();
double[] pi = this.pi;
double[][] a = this.a;
double[][] b = this.b;
// 1. Initialization
double sc = 1.0d / scaling[T - 1];
... |
27891058-ec87-4a0d-b9ad-f63e27ff2c49 | 2 | public boolean equals (Time t) {
this.format();
t.format();
return this.day == t.day && this.hour == t.hour && this.min == t.min;
} |
30c7aede-8b95-41ff-a381-ee60e77c3ffc | 6 | @Override
public Piece createPiece(Position pos, PieceType pieceType,
final ChessColor color, ChessCoord initialCoord) {
Piece result;
switch (pieceType) {
case PAWN:
result = new Pawn(pos, color, initialCoord);
break;
case ROOK:
/*
* At the moment we assign kingside rooks to be the on... |
9a299b04-3488-4e36-b95f-f20e4c1f2edd | 4 | @Override
public void deserialize(Buffer buf) {
questId = buf.readUShort();
if (questId < 0 || questId > 65535)
throw new RuntimeException("Forbidden value on questId = " + questId + ", it doesn't respect the following condition : questId < 0 || questId > 65535");
stepId = buf.re... |
ae932082-66ff-4f1d-bc90-434c710b7d24 | 9 | public String[] listClasses(String packageName, boolean recurse) {
List<String> ret = new LinkedList<String>();
// scan dirs
final String fileSystemPackagePath = packageName.replace('.', File.separatorChar);
for (File dir : dirs) {
File subfolder = new File(dir, fileSystemPackagePath);
if (subfolder.ex... |
f9365a04-cd0d-400f-92d7-5449c6a2ea92 | 9 | Vector<Integer> crossCheck(Vector<Integer> possibilities, Vector<Integer> confirmations) {
Vector<Integer> result = new Vector<>(6);
if (possibilities.size() == 0) {
for (int cellId : confirmations) {
if (cellId >= 0) {
result.add(cellId);
... |
f54cf161-590e-45a2-b8ae-697d74cd5eae | 4 | protected Behaviour getNextStep() {
if (beginTime == -1) beginTime = actor.world().currentTime() ;
final float elapsed = actor.world().currentTime() - beginTime ;
if (elapsed > WAIT_TIME / 2) {
final Behaviour nextJob = venue.jobFor(actor) ;
if (elapsed > WAIT_TIME || ! (nextJob instanceof Super... |
9bc4d530-13af-41e8-8250-da77ad192940 | 7 | public void propertyChange(PropertyChangeEvent e) {
String prop = e.getPropertyName();
if (isVisible()
&& (e.getSource() == optionPane)
&& (JOptionPane.VALUE_PROPERTY.equals(prop)
|| JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
Object val... |
c0564db0-7ed2-435e-b317-52d2bc7645ef | 4 | private boolean valid(int x, int y, int width, int height) {
if(x < 0 || width <= x) { return false; }
if(y < 0 || height <= y) { return false; }
return true;
} |
64d94b9a-2015-45fe-bc09-3579160d75f1 | 8 | public void checkPurchase()
{
if(BackerGS.storeVisible)
{
if(CurrencyCounter.currencyCollected < 100)
{
if(Greenfoot.mouseClicked(this))
{
NotEnoughMoney.fade = 200;
boop.play();
}
... |
9c5c181f-485f-42de-867a-f9f01c98acfe | 6 | static final public void paramForms() throws ParseException {
jj_consume_token(52);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case BOOLEEN:
case ENTIER:
paramForm();
label_4:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 53:
;
break;
... |
c971fece-ee9e-483c-93c5-224036950e2b | 0 | public String getFormattedDatetime() {
return formattedDatetime;
} |
63eeb0cc-d7a4-450a-8dc2-8f40fb43a09b | 9 | public String toString() {
// TODO: move strings to Strings
String str = "Select ";
if (exactly) str += "exactly ";
else str += "up to ";
str += count + " ";
str += "cards ";
switch (from) {
case HAND:
str += Strings.fromHand;
break;
case VILLAGE:
str += Strings.fromVillage;
b... |
572fbad5-2973-4752-b2b9-c362bafb2fc6 | 7 | @Override
public boolean tick(Tickable ticking, int tickID)
{
if(!super.tick(ticking, tickID))
return false;
if((affected instanceof MOB)&&(invoker()!=null))
{
final MOB mob=(MOB)affected;
if((mob!=null)
&&(!mob.amDead())
&&(CMath.div(mob.curState().getHitPoints(), mob.maxState().getHitPoints())<... |
83f90b47-3124-4dca-be55-2568754af398 | 9 | public static void merge(int startIndex, int endIndex){
System.out.println("startj: "+startIndex+" endj:"+ endIndex);
Long[] arr = new Long[endIndex-startIndex+1];
int i=startIndex;
int j=((endIndex+startIndex)/2)+1;
int k=0;
for(k=0; k<arr.length; k++){
if (i == ((endIndex+startIndex)/2)+1 || j> endInde... |
733551c9-0b6e-4ff5-99f6-fd63bca8d502 | 4 | private void calculateRoughPageSize(Rectangle pageSize) {
// use a ratio to figure out what the dimension should be a after
// a specific scale.
float width = defaultPageSize.width;
float height = defaultPageSize.height;
float totalRotation = documentViewModel.getViewRotation();... |
6e4653cf-46ec-4ce5-9ce5-90dae29667aa | 9 | protected void optimize2() throws Exception {
//% main routine for modification 2 procedure main
int nNumChanged = 0;
boolean bExamineAll = true;
// while (numChanged > 0 || examineAll)
// numChanged = 0;
while (nNumChanged > 0 || bExamineAll) {
nNumChanged = 0;
// if (examin... |
ea7cce1e-7d11-4692-8ecd-937d24c303ab | 2 | @Override
public boolean isSameElementAs(Element<?> element) {
NoteElement other = element.adaptTo(NoteElement.class);
if(other==null) {
return false;
}
return other.getText().equals(other);
} |
30d4e08d-194e-48dd-8052-9bc188c9379d | 7 | public void updateStudents() throws ClientException{
if (logger.isDebugEnabled()){
logger.debug("Called updating student");
}
String firstName = tb.getModel().getValueAt(tb.getSelectedRow(), 0).toString();
String lastName = tb.getModel().getValueAt(tb.getSelectedRow(), 1).to... |
08267625-814f-4548-9215-6331e5d61f1d | 1 | private static void printPersons(List<Person> persons) {
for (Person person : persons) {
System.out.println("Name :" + person.getName());
System.out.println("Gender :" + person.getGender());
System.out.println("Marital Status :" + person.getMaritalStatus());
System.out.println();
}
} |
03015a8c-6110-4b35-ac89-cb17ded25393 | 3 | public Chest(PlaceableManager pm, Registry rg, String sm, String am, int x, int y, Placeable.State cs) {
super(pm, rg, sm, am, x, y, cs, 8);
type = "Chest";
totalBuildTime = 1;
totalHitPoints = 625;
powerRequired = 0;
powerGenerated = 0;
hitPoints = totalHitPoi... |
d21a57cf-12a2-4efc-8291-7c8ed26c8efb | 8 | private static String initialise(Token currentToken,
int[][] expectedTokenSequences,
String[] tokenImage) {
String eol = System.getProperty("line.separator", "\n");
StringBuffer expected = new StringBuffer();
int maxSize = 0;
for (int i = 0; i < expe... |
75d2053e-d8d5-4f2e-ad24-cd99107a031b | 4 | private void connectTo(String name, String password, String server) throws ConnectionFailure, ClassNotFoundException {
try {
GameNetworkInterface gnet = Guice.createInjector(new GuiceConfig()).getInstance(GameNetworkInterface.class);
gnet.connectTo(server);
pfactory.sendJoinG... |
dd56060f-e6e0-42ef-a5e8-5aeba8bead2f | 6 | public static Keyword meanOfNumbersSpecialist(ControlFrame frame, Keyword lastmove) {
{ Proposition proposition = frame.proposition;
Stella_Object listarg = (proposition.arguments.theArray)[0];
Stella_Object listskolem = Logic.argumentBoundTo(listarg);
Stella_Object meanarg = (proposition.argument... |
0a418aaa-9caa-424e-baf9-836872f5ddff | 1 | public void setAllParticipantsOffline() {
Iterator<String> participantsIter = participants.keySet().iterator();
Participant partp;
while(participantsIter.hasNext()) {
partp = participants.get(participantsIter.next());
partp.setOffline();
}
setChanged();
notifyObservers(ModelNotification.LIST_OF_PARTIC... |
88e0342c-3bec-4630-8bf1-48fb05288dd1 | 8 | static int maxFlow(int[][] cap,int[][] cost,int[][] r,int s,int t,int C) {
Arrays.fill(ants, -1);
Arrays.fill(vals, MAX);
Arrays.fill(visitados, false);
visitados[s]=true;
int c=0,p=0;
cola[c++]=s;
for(int u;p<c;) {
u=cola[p++];
for(int v=0;v<cap.length;v++)
if(!visitados[v]&&cost[u][v]<=C&&cap[... |
e5c9ba50-8cf1-4be2-b40a-883b4f8c1989 | 1 | public void mouseClicked(MouseEvent e) {
setState(getState() == ENABLED ? DISABLED : ENABLED);
InputBox.this.fireEvent(new ActionEvent());
} |
51b51c54-6f7e-4ab7-a4f0-8f5020690bc3 | 2 | public Molecule getFromMoleculeID(int[] MoleculeID, int size, int val){
if(this.getID()==0){
return this;
}
if (size!=0){
//System.out.printf(""+this.toStringf()+"\t\t\t");
val = MoleculeID[MoleculeID.length-size];
//System.out.printf("%d\t%d\t%d\n", val, MoleculeID.length,... |
2a16347a-daec-400a-b5ad-7abc1d79b860 | 6 | private Token nextSymbol() throws IOException {
StringBuilder builder = new StringBuilder();
int ich = this.reader.read();
int nchars = 0;
while (ich != -1) {
char ch = (char)ich;
if (Character.isSpaceChar(ch) || Character.isISOControl(ch))
break;
// Case #(
if (ch == '(' && nchars ==... |
7f2da936-045f-45cf-afd5-a3ab13a8dccb | 4 | public static float pcaAngle(Collection<Vector2f> points) {
//
final float size = points.size();
if (size < 2) return 0.0f;
//
// determin mean vector.
//
final Vector2f mean = mean(points);
//
double cov00 = 0.0;
double cov01 = 0.0;
... |
9b0a0171-5d98-4e6b-a490-2490a8bc813c | 4 | public static boolean estPositionValide(Position position){
if(position.travee >= 0 && position.travee < Parametres.NB_TRAVEES && position.rangee >= 0 && position.rangee < Parametres.NB_RANGEES){
return true ;
}
else {
return false ;
}
} |
30db81bc-0653-4aab-900f-36d244d44daf | 7 | private ArrayList<TunnusPari> kokoaParit(ArrayList<ArrayList<String>> tunnusParit, ArrayList<Tunnus> tunnukset) {
ArrayList<TunnusPari> parit = new ArrayList<TunnusPari>();
for (ArrayList<String> lista : tunnusParit) {
if (lista.size() < 9) {
continue;
}
... |
cf8a639a-3a8e-4abd-a570-654b5ac6999b | 8 | public <V> Adapter.Getter<V> makeGetter(String methodName, Class<V> _class) {
try {
T version = (T) start.get().newVersion;
final Method method = version.getClass().getMethod(methodName);
return new Adapter.Getter<V>() {
public V call() {
try {
Transaction me = Thre... |
5ae8621c-976b-4170-83ec-f48db6b23f23 | 7 | public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting() == false && solvingList.getSelectedIndex() > -1) {
int wordIndex = solvingList.getSelectedIndex();
// Compute the grid state at that letter
Grid tempGrid = solvingGrid.clone();
for (int i = 0; i < wordIndex; i++) {
tempGrid.r... |
5bef1a9c-752a-4000-99b4-03284b5476b2 | 1 | public static String formatFilePath(String realpath) {
if (StringUtil.isEmpty(realpath))
return null;
realpath = realpath.replace('\\', '/');
return realpath;
} |
171ab007-9743-4b2c-8281-5d8413f03cf3 | 0 | @Basic
@Column(name = "PCA_ID_ELEMENTO")
public Integer getPcaIdElemento() {
return pcaIdElemento;
} |
7f704008-62b1-4928-909c-9ae2c9f730dc | 7 | public String ask(String sentence) {
String response = defaultResponses[(int) (Math.random() * defaultResponses.length)];
if (sentence == null || sentence.length() == 0)
return response;
// Removing the punctuation if it is there.
char punctuation = sentence.charAt(sentence.length() - 1);
if (punctuation =... |
9ad1647e-14a3-4023-b00f-75233e901eea | 0 | public String parentRow(){
return "<tr class=\"parent\" data-level=\"0\">"+
"<td>"+this.instance_id+"</td>"+
"<td>"+this.txid+"</td>"+
"<td>"+this.BPEL+"</td>"+
"<td>"+this.course_id+"</td>"+
"<td>"+this.course_provider+"</td>"+
... |
04bff872-2a06-4eb5-9fc7-d628a0645fe2 | 2 | public void setHealth(int newHealth) {
if (newHealth < health) {
int scaleX = Level.getScaledX(level.getXPosition(), x);
int width = Level.getScaledX(level.getXPosition(), x + 1) - scaleX;
float scale = 1.0f / Constants.TILE_WIDTH * width;
addEffect(new PlayerDamageEffect(getRenderCentreX(),
getRend... |
98498a19-524c-4691-99fa-0370494ec247 | 0 | public void setName(String name) {
this.name = name;
} |
782a551f-8b92-4c15-85c9-22d1008aef31 | 5 | public Class getTypeClass() {
switch (((IntegerType) getHint()).possTypes) {
case IT_Z:
return Boolean.TYPE;
case IT_C:
return Character.TYPE;
case IT_B:
return Byte.TYPE;
case IT_S:
return Short.TYPE;
case IT_I:
default:
return Integer.TYPE;
}
} |
0e51f8cc-aa34-428d-96f6-308c732a5dc5 | 8 | private void deletePair(Person man, Person woman) {
//System.out.println("deleting: " + man.getName() + "," + woman.getName());
for(List<Person> list : man.getPreferences()) {
List<Person> listAux = list;
if(listAux.contains(woman)) {
listAux.remove(woman);
... |
1af1b6e6-00a0-4b9d-808e-82d092c41b54 | 7 | @EventHandler(priority = EventPriority.NORMAL)
public void onBlockBreak(BlockBreakEvent event) {
if (event.getBlock() != null) { //Will prevent an NPE if the user right-clicks air.
if (event.getBlock().getState() != null) {
if (event.getBlock().getState() instanceof Sign) {
Sign sign = (Sign) event.getBl... |
aa76e83d-9c23-4e58-9442-18ba6b5d323a | 7 | private static boolean rulesEq(boolean[] r1, boolean[] r2) {
if(r1 != null && r2 != null) {
if(r1.length == r2.length) {
for(int i = 0; i < r1.length; i++) {
if(r1[i] != r2[i]) {
return false;
}
}
... |
e658cd43-2a11-4f2d-8652-b4f4961a46f3 | 8 | public static void main(String[] argv) {
try {
File index = new File("index");
boolean create = false;
File root = null;
String usage = "IndexHTML [-create] [-index <index>] <root_directory>";
if (argv.length == 0) {
System.err.println("Usage: " + usage);
return;
... |
cd56f467-0c9e-42a7-b439-f9d8459bb1a5 | 0 | String entrance(List<Milk> milks){
Collections.sort(milks);
return milks.get(0).brand;
} |
74db739c-5fe5-43f6-a511-3d99ac01eeff | 4 | public float getValueAt(int row, int column) throws
ElementOutOfRangeException{
if(row<0 || column<0){
throw new ElementOutOfRangeException(" The vlaues provided for row or " +
" column are negative");
}
if(row > this.rows || column > this.columns){
throw new ElementOutOfR... |
98678840-b053-43e6-9921-1af70c277b8d | 0 | private void init() {
dialog.setSize(WIDTH, HEIGHT);
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
button = new JButton("Cancel");
progressBar = new JProgressBar();
textArea = new JLabel("Calculating");
progressBar.setStringPainted(true);
progres... |
94110f8b-5989-4fa3-be20-95408169710d | 0 | public AncestorIterator(T child, Selector<T, T> selector)
{
this._next = child;
this._selector = selector;
} |
24385b59-7e7a-4166-b54c-c391c6d86cce | 8 | public int reverse(int x) {
if (x == 0) {
return 0;
}
boolean isNegative = x < 0;
x = x > 0 ? x : -x;
long i = 0;
while (x > 0) {
i = i * 10 + (x % 10);
x = x / 10;
}
if ((!isNegative && i > Integer.MAX_VALUE) || (isNeg... |
df711ef3-6a97-4123-806d-d79d2729c1f7 | 6 | private void CheckIfAllPlayerHaveOneCountry(List<MapChange> map, Player player1, Player player2) {
boolean error = false;
if (map.size() != 2)
error = true;
if (map.get(0).OwnedByPlayerId == player1.ID && map.get(1).OwnedByPlayerId == player1.ID)
error = true;
if... |
03d203fe-467c-4b0d-9b88-11f9cdb203b5 | 7 | public void addCountry(Country cnt) {
int id;
Connection con = null;
PreparedStatement pstmt = null;
Statement idstmt = null;
try {
DBconnection dbCon = new DBconnection();
Class.forName(dbCon.getJDBC_DRIVER());
con = DriverManager.getConnec... |
80c21356-1953-4aff-9817-e4792b906a08 | 8 | public void cmdCollect(CommandSender sender, String[] args) {
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
List<EEItemStack> stacks = getDeliveries(player.getName());
double revenue = getRevenue(player.getName());
if(stacks.size() == 0 && revenue == 0 ) {
se... |
48a8942a-7c6c-4408-88d8-c4e1bcf7765e | 3 | private Byte[] buildPacket() {
ArrayList<Byte> p = new ArrayList<Byte>();
// Add timestamp to the first 8 bits.
long timestamp = new Date().getTime();
lastSentPacketTimestamp = timestamp;
byte[] timestampBytes = ByteBuffer.allocate(8).putLong(timestamp).array();
for(byte b : timestampBytes) {
p.add((B... |
7641e52e-f14c-4fd7-b779-79f3862073a8 | 8 | public CustomTemplate getCopy()
{
try {
CustomTemplate template = (CustomTemplate) clone();
List<CustomElement> elements = new ArrayList<CustomElement>();
for (CustomElement e : template.elements)
{
elements.add(e.getCopy());
}
for (CustomElement e : elements)
{
if (e.childElements != nu... |
0614cccf-a0cb-4af2-aca7-0f6aedb49d66 | 1 | public void TimeStep() {
if (turnsRemaining > 0) {
--turnsRemaining;
} else {
turnsRemaining = 0;
}
} |
1f365c2a-232b-498b-ba33-a6264149831b | 7 | private void paintAntsB(Graphics2D g2d, int id, Map<Integer, Ant> ants, Color b, Color f) {
for (int i : ants.keySet()) {
Ant a = ants.get(i);
g2d.setColor(b);
if (a.isSweet()) {
g2d.setColor(Color.white);
g2d.drawOval(a.getX()-5, a.getY()-5, 10, 10);
}
g2d.setColor(b);
if (id == w.getId()) ... |
201afa40-02e8-45c1-8632-eb60e6f694b7 | 4 | public void copyBlock(int distance, int len) throws IOException {
int pos = _pos - distance - 1;
if (pos < 0) {
pos += _windowSize;
}
for (; len != 0; len--) {
if (pos >= _windowSize) {
pos = 0;
}
_buffer[_pos++] = _buffer[p... |
f8837328-2cff-49e1-944d-799e1f1d98df | 4 | @Override
public boolean activate() {
return (Game.getClientState() != Game.INDEX_MAP_LOADED
|| (Game.getClientState() != Game.INDEX_MAP_LOADED && ItemCombiner.stop == 1000)
|| ItemCombiner.client != Bot.client()
|| Widgets.get(640, 30).isOnScreen()
);
} |
f08e166b-44af-40f9-a5bc-ea57d44c5d6f | 8 | private Map<Integer, Double> getLastUsages(List<Bookmark> bookmarks, double timestamp, boolean categories) {
Map<Integer, Double> usageMap = new LinkedHashMap<Integer, Double>();
for (Bookmark data : bookmarks) {
List<Integer> keys = (categories ? data.getCategories() : data.getTags());
double targetTimestamp... |
ff078f92-928d-4b11-a1db-091a0158ee2d | 4 | private static double getMeanPixel(Image image, ChannelType color, int x,
int y, int maskWidth, int maskHeight) {
List<Double> pixelsAffected = new ArrayList<Double>();
for (int i = -maskWidth / 2; i <= maskWidth / 2; i++) {
for (int j = -maskHeight / 2; j <= maskHeight / 2; j++) {
if (image.validPixel(x ... |
0a43d6ae-29ef-43a8-a1fb-8a3adac38400 | 9 | public ArrayList<AnyType> Merge(ArrayList<AnyType> list1, ArrayList<AnyType> list2)
{
int i=0;
int j=0;
ArrayList<AnyType> merged = new ArrayList<AnyType>();
while(i<list1.size() || j<list2.size())
{
if(i<list1.size() && j<list2.size())
{
if(list1.get(i).compareTo(list2.get(j))<=0)
{
me... |
03aca12b-a3bf-49a5-915d-1267fc162ccf | 1 | public static void sort(SimpleTrain train,
Comparator<AbstractCarriage> comparator) {
if(train == null){
LOG.error("Train is null");
throw new IllegalArgumentException("Train is null");
}
Collections.sort(train, comparator);
} |
c7b7b9ac-7018-4992-964c-3ea9790cc210 | 8 | private Component cycle(Component currentComponent, int delta) {
int index = -1;
loop : for (int i = 0; i < m_Components.length; i++) {
Component component = m_Components[i];
for (Component c = currentComponent; c != null; c = c.getParent()) {
if (component == c) {
index = i;
break loop;
}
... |
af02ce00-9408-41d5-98b3-59e39d702276 | 7 | public void randomFillMap() {
int mapmiddle = 0;
for (int row = 0; row < mapheight; row++) {
for (int col = 0; col < mapwidth; col++) {
if (col == 0)
{
map[col][row] = 1;
}
else if (row == 0)
{
map[col][row] = 1;
}
else if (col == mapwidth -1){
map[col][row] = 1... |
4727287c-e88d-46ad-ba6b-9ee45eeb0614 | 3 | private void btn_ContinueActionPerformed(java.awt.event.ActionEvent evt) {
System.out.println("Iniciando configuraciones");
sys_productores = (Integer) jSpinnerProductores.getValue();
System.out.print(sys_productores+" sys_productores");
... |
5c1b38be-3159-4801-880d-2f4a59f736a1 | 0 | public void addOsoba(Osoba osoba) {
data.addElement(osoba);
int updatedRow = data.indexOf(data.lastElement());
fireTableRowsInserted(updatedRow, updatedRow);
} |
9cff5adf-60ec-4ebd-bf24-eff4ce458025 | 9 | public String[] getOptions() {
Vector<String> options = new Vector<String>();
if ( (getUrl() != null) && (getUrl().length() != 0) ) {
options.add("-url");
options.add(getUrl());
}
if ( (getUser() != null) && (getUser().length() != 0) ) {
options.add("-user");
options... |
eb49318b-6564-4d5e-9699-1e47eaf96242 | 5 | static private String toString(Class type) {
if (type == Dictionary.class) {
return "dictionary";
} else if (type == ZemArray.class) {
return "array";
} else if (type == ZemBoolean.class) {
return "boolean";
} else if (type == ZemNumber.class) {
... |
66582b39-5741-44a9-86b4-18e0699b2591 | 0 | public void setDepotlegal(String oui) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
} |
d25d5b95-ed0a-422a-9802-b8a031029e6e | 2 | public static void main(String[] args) {
//TODO interpret arguments, for example random seed and number of cities, and brute force or genetic algorithm could be
TravelingSalesman salesman = new TravelingSalesman(10, random);
salesman.printCosts();
//uncomment for brute force:
if(RUN_BRUTE_FORCE){
S... |
9a039942-be00-4e1a-8a46-b2bf77f0ccbf | 7 | public static void testValidity(Object o) throws JSONException {
if (o != null) {
if (o instanceof Double) {
if (((Double) o).isInfinite() || ((Double) o).isNaN()) {
throw new JSONException(
"JSON does not allow non-finite numbers.");
... |
be23df63-a267-4904-a3a0-bf40b4600cd8 | 9 | public static int[][] replaceMatrixElements(int a[][]) {
int rows[] = new int[a.length];
int columns[] = new int [a[0].length];
for (int i=0; i<a.length; i++) {
for(int j=0; j<a[i].length; j++) {
if(a[i][j] == 0) {
rows[i] = 1;
... |
3a25cdf6-e6d3-4d66-ae81-58786faab80d | 2 | public boolean isTileAlreadyOccupied(PieceCoordinate coordinate) {
Iterator<Entry<PieceCoordinate, HantoPiece>> pieces = board.entrySet().iterator();
PieceCoordinate next;
while(pieces.hasNext()) {
Entry<PieceCoordinate, HantoPiece> entry = pieces.next();
next = entry.getKey();
// if there is already a p... |
25504b9a-0d23-4ced-be0f-f9e9f7676827 | 1 | public void visitAttribute(final Attribute attr) {
super.visitAttribute(attr);
if (fv != null) {
fv.visitAttribute(attr);
}
} |
39c12065-45e9-4bec-b1b5-26a23c4a60b2 | 1 | public void makeShake() {
if (this.calculateChances(10))
{
this.setEffMult(1);
}
else
{
this.addEffMult(0.1);
}
} |
dbadf3a2-1ca2-4ca5-9043-503c8e04ff77 | 8 | public void renderSprite(int xPos, int yPos, Sprite sprite) {
int spriteWidth = sprite.getWidth();
int spriteHeight = sprite.getHeight();
if (sprite.isFixed()) {
xPos -= xOffset;
yPos -= yOffset;
}
for (int y = 0; y < spriteHeight; y++) {
int y... |
814f5f0d-846b-4342-8aaa-dece38cd1543 | 1 | public Value naryOperation(final AbstractInsnNode insn, final List values) {
int size;
if (insn.getOpcode() == MULTIANEWARRAY) {
size = 1;
} else {
size = Type.getReturnType(((MethodInsnNode) insn).desc).getSize();
}
return new SourceValue(size, insn);
} |
af16a284-7664-4e63-96e1-80a79b0809aa | 9 | @Override
public Object getValueAt(Object object, int row, int col) {
Usuario u = (Usuario) object;
try {
if (col == 0) {
return u.getDNI();
} else if (col == 1) {
return u.getNombre();
} else if (col... |
c43549d1-918a-48af-ba9b-3e4de62cf933 | 7 | private static void contraction(Map<Integer, List<Integer>> expData, Integer key1, Integer key2) {
List<Integer> adj1 = expData.get(key1);
List<Integer> adj2 = expData.get(key2);
for (Iterator<Integer> it = adj2.iterator(); it.hasNext();) {
Integer current = it.next();
if... |
84f0e69b-edf4-4369-b5c0-c8c7e7b44a7c | 7 | private boolean availableArea(int southWestRowID,
int southWestColID, int span) {
int rowCount = this.realMap.getRowCount();
int colCount = this.realMap.getColumnCount();
for(int rowID = 0;rowID < span;rowID++){
if(!(0 <= rowID && rowID < rowCount)){
return false;
}
for(int colID = 0;colID < s... |
2ad3f723-400a-422e-bacc-a349c3d54ec9 | 1 | @Test
public void opiskelunLisaaminenToimiiKunEriKuinEnnen(){
//kirjoitaOikeanmuotoinenSyote();
tiedot.LueTiedotTiedostosta();
tiedot.lisaaUusiOpiskelu("uusiopiskelu", 5);
String mappiinTallennetutTiedot = "";
HashMap<String, Integer> kartta = tiedot.getOpiskelut();
f... |
2e086af1-9312-443b-9606-d94cd364055c | 9 | public static void getDifficultyVariables() {
if(isEasy && !isMedium && !isHard){
mobWalkSpeeds[0] = 30;
mobWalkSpeeds[1] = 20;
mobWalkSpeeds[2] = 60;
killReward[0] = 5;
killReward[1] = 2;
killReward[2] = 20;
}
if(!isEasy && isMedium && !isHard){
mobWalkSpeeds[0] =... |
055c131b-95ab-4121-bc4e-d96a42a7684e | 8 | public void splitNode(BallNode node, int numNodesCreated) throws Exception {
correctlyInitialized();
double maxDist = Double.NEGATIVE_INFINITY, dist = 0.0;
Instance furthest1=null, furthest2=null, pivot=node.getPivot(), temp;
double distList[] = new double[node.m_NumInstances];
for(int i=node.m... |
17a138a7-3ecf-4276-b392-42e4ea3ef024 | 6 | public static void main(String args[]) {
Cue bigQ = new Cue(100);
Cue smallQ = new Cue(4);
char ch;
int i;
System.out.println("Using bigQ to store the alphabet.");
for(i=0; i<26;i++)
bigQ.put((char) ('A' + i ));
System.out.println("Contents of bigQ: ")... |
e3464e74-8c89-402f-8020-86ab53371346 | 6 | public static void modifyNames(ArrayList<Journal> journalList, Journals journals) {
for(Journal journal : journalList){
String oldName = journal.getName();
boolean retry = true;
while(retry){
String newName = JOptionPane.showInputDialog(getBundle("BusinessActi... |
ff058450-89c1-4767-8015-d376dfebed0b | 9 | private void printLinks(StringBuilder sb, List<Link> links) throws IOException {
for (Link link : appendPhantomLink(links)) {
final IEntity entity1 = link.getEntity1();
final IEntity entity2 = link.getEntity2();
if (entity1 == entity2 && entity1.getType() == EntityType.GROUP) {
continue;
}
if (enti... |
fb0d9dde-fa09-4676-9ff6-53f78c8ca4be | 7 | public void initiate() {
System.out.println("\u001b[1;44m *** INITIATED *** \u001b[m");
/* Identify to server */
connection.sendln("NICK " + botN);
// connection.sendln("PASS " + botP);
connection.sendln("USER RTFM 0 * :Microsoft Exterminator!");
// /*
// * Give the server 4 seconds to ident... |
a0fd47b1-1e9a-41e5-a1dc-2f6c3c02de23 | 7 | public static void main(String[] args) {
// create the object
DB db = new DB();
// open the database
if (!db.open("casket.kch", DB.OWRITER | DB.OCREATE)){
System.err.println("open error: " + db.error());
}
// store records
if (!db.set("foo", "hop") ||
!db.set("bar", "step") ... |
f66f37fd-59a8-4034-9988-2bc3eb945419 | 9 | void compress( int init_bits, OutputStream outs ) throws IOException
{
int fcode;
int i /* = 0 */;
int c;
int ent;
int disp;
int hsize_reg;
int hshift;
// Set up the globals: g_init_bits - initial number of bits
g_... |
ad8df32f-f88e-4581-b934-a079a9d9f475 | 0 | @Test
public void testPeekAndPopOperand(){
calculator.pushOperand(4.0);
calculator.pushOperand(7.0);
calculator.pushPlusOperator();
calculator.evaluateStack();
assertEquals(11.0, calculator.peekOperand(), 0);
assertFalse(calculator.isStackEmpty());
calculator.pushOperand(3.0);
calculator.pushTime... |
ad014ea9-95d4-4dbe-8416-0163743b9f58 | 2 | private void siftUp(int start, int end ) {
int child = end;
while (child > start) {
int parent = (int) Math.floor((child-1)/2);
if(array.get(parent).compareTo(array.get(child)) > 0 ) {
return;
}
T t = array.get(parent);
array.set(parent, array.get(child));
array.set(child, t);
}
} |
e7a69f7e-4c70-45c4-b9c8-7e4f3862d977 | 3 | public void merge(Player.Ids rhs) throws IdConflictException {
ObjectNode root = (ObjectNode) id;
for(String key : rhs.all()) {
JsonNode lhs = root.path(key);
if (lhs.isMissingNode()) {
root.put(key, rhs.get(key));
} else {
... |
b12db946-7e77-475b-a929-de65f2d6c2da | 6 | public static String reverseWords(char[] s) {
reverseSentence(s, 0, s.length - 1);
int start = 0;
int end = 0;
while(start <s.length && end < s.length) {
while(start < s.length && s[start] == ' ') {
start ++;
}
end = start;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.