method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
7098478a-dab9-4713-97ae-8e5e63c2d696 | 9 | protected void loadInputProperties() {
if (VERBOSE)
System.out.println("Loading '" + getInputFilename() + "'...");
m_InputProperties = new Properties();
try {
File f = new File(getInputFilename());
if (getExplicitPropsFile() && f.exists())
m_InputProperties.load(new FileInputStrea... |
d634efb2-6b20-49cf-8512-e9b76a9e7654 | 6 | protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession();
request.setCharacterEncoding("UTF-8");
User loggedIn = (User) session.getAttribute("loggedIn");
String g... |
870a1b54-34f7-4721-a3da-70fc8656c7ec | 3 | public void RenderAll(Graphics g) {
for (int i = 0; i < tiles.length; i++) { // cols
for (int j = 0; j < tiles[0].length; j++) { // rows
int xt;
int yt;
if (tiles[i][j].getTileID() != 0) {
xt = tiles[i][j].getTileID() % 16 - 1;
yt = (int) Math.floor(tiles[i][j].getTileID() / 16);
sprit... |
eaf7110b-1007-4093-8c86-63d4bd4db9bf | 2 | public static String generateKey(String lockString){
int i = 0;
byte[] lock = null;
byte[] key = null;
lockString = lockString.substring(0,lockString.indexOf(' '));
lockString.trim();
lock = lockString.getBytes();
key = new byte[lock.length];
for(i=1;i<l... |
12564c69-0c7c-4a35-b72b-04643e6ceaed | 6 | public void printMiddle(Node root) {
if (root == null) {
return;
}
System.out.println("Linked list is ");
print(root);
Node hare = null;
Node tortoise = null;
boolean temp = false;
if (size(root) % 2 == 0)
temp = true;
if (temp) {
hare = root.getLink();
tortoise = root;
} else {
ha... |
c6a97400-9f21-4392-8f23-fc487faa3653 | 5 | static final void method2811(boolean bool) {
anInt6777++;
if ((InterfaceScript.anInt6992 ^ 0xffffffff) > -1) {
InterfaceScript.anInt6992 = 0;
TextureLoader.anInt4609 = -1;
Class48.anInt859 = -1;
}
if (InterfaceScript.anInt6992 > Class75.anInt1259) {
InterfaceScript.anInt6992 = Class75.anInt1259;... |
9f383509-5c19-446e-b46b-3aa466644fca | 6 | public void train(StringWrapperIterator i)
{
Set seenTokens = new HashSet();
while (i.hasNext()) {
BagOfTokens bag = asBagOfTokens(i.nextStringWrapper());
seenTokens.clear();
for (Iterator j=bag.tokenIterator(); j.hasNext(); ) {
totalTokenCount++;
Token tokj = (Token)j.next();
if (!seenTokens... |
e69e86da-a03c-4700-a84d-c719f3cde064 | 0 | public int getLength() {
return this.length;
} |
43a9b142-3450-42c4-818e-66c1fb5cd077 | 8 | public Unit getOccupyingUnit() {
Unit unit = getFirstUnit();
Player owner = null;
if (getOwningSettlement() != null) {
owner = getOwningSettlement().getOwner();
}
if (owner != null && unit != null && unit.getOwner() != owner
&& owner.getStance(unit.getOwne... |
4073805d-aa25-4101-a431-0c3b95b335ca | 6 | public void inject(T csvBean, Map<Field, String> values) throws CsvReadException {
if (csvBean == null || values == null || values.isEmpty())
return;
for (Map.Entry<Field, String> entry : values.entrySet()) {
Field field = entry.getKey();
String content = entry.getValue();
Object value... |
c4294edb-1276-4bb1-93e1-3f19fe9733d3 | 5 | public BoardPiece getPlayerKing(String playerColor) throws Exception{
for (int i=0; i<boardSquares.length; i++){
for (int j=0; j<boardSquares[i].length; j++){
BoardPiece boardPiece = boardSquares[i][j].getBoardPiece();
if (boardPiece != null){
if (boardPiece.pieceColor.equals(playerColor) && boardP... |
dcaaea5e-1764-4c0e-8764-606bac51d453 | 4 | public void loadAttributes(BufferedReader reader) {
try {
String line;
while((line = reader.readLine()) != null && !line.matches("<END>")) {
this.attributes += line + "\n";
}
if(attributes.endsWith("\n"))
attributes = attributes.substring(0, attributes.length() - 1);
} catch (IOException e) {
... |
9084ac42-26ce-4172-a98b-644d01748cba | 1 | private void closeConnection() {
// remove from the selector.
_skey.cancel();
try {
_sChannel.close();
} catch (IOException ignored) {
ignored = null;
}
} |
7111a2bc-6750-4b1b-ad29-5225aae620df | 9 | public static boolean isMyPlant(Item I, MOB mob)
{
if((I!=null)
&&(I.rawSecretIdentity().equals(mob.Name()))
&&(I.owner()!=null)
&&(I.owner() instanceof Room))
{
for(final Enumeration<Ability> a=I.effects();a.hasMoreElements();)
{
final Ability A=a.nextElement();
if((A!=null)
&&((A.invoker(... |
10b2ff70-4252-424e-8d94-475c92a17c4d | 4 | public boolean equals(PERangeList other) {
if(this == other) {
return true;
} else if(getNumPE() != other.getNumPE()) {
return false;
}
PERangeList list = intersection(other);
if(list.getNumPE() == getNumPE() && list.getNumPE() == other.getNumPE()) {
return true;
}
... |
4b5a858b-b3e8-4d71-8fd4-6d7a48e824af | 7 | public void paint(GC gc, int width, int height) {
if (!example.checkAdvancedGraphics()) return;
Device device = gc.getDevice();
if (alphaImg1 == null) {
alphaImg1 = GraphicsExample.loadImage(device, GraphicsExample.class, "alpha_img1.png");
alphaImg2 = GraphicsExample.loadImage(device, GraphicsExample.clas... |
b418b33d-4662-4d75-ad4c-61789bfef29b | 3 | public static int min3(int a, int b, int c) {
if( a > b )
return (( c > b) ? b : c);
else
return (( c > a) ? a : c);
} |
b6a55f7b-4e99-4e2e-b5b3-7903e4cc41fe | 2 | private void btnGuardarClaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarClaveActionPerformed
String p = JOptionPane.showInputDialog("Introduce la clave a guardar");
if (Obj.principal.claves.get(p) != null) {
int g = JOptionPane.showConfirmDialog(null,
... |
c2b2a582-f3f0-48c9-9bec-f02eea65eeac | 2 | public void init ()
{
if (initted)
return;
try {
getContentPane ().add ("Center",
new DisplayPanel ());
initted = true;
} catch (IOException e) {
e.printStackTrace ();
throw new RuntimeException (e.getMessage ());
}
} |
db464160-b5fe-4f89-93f9-03220af04c4b | 4 | public static void applyGear(Background v, Actor actor) {
int BQ = v.standing ;
for (Service gear : v.gear) {
if (gear instanceof DeviceType) {
actor.gear.equipDevice(Item.withQuality(gear, BQ + Rand.index(3))) ;
}
else if (gear instanceof OutfitType) {
actor.gear.equipOutfit(I... |
05322076-d6f3-4dbc-8553-0f13aad4bb1c | 4 | public int[] getLongestCommonSequence(int[] x, int[] y) {
int[][] c = new int[x.length + 1][y.length + 1];
// start from c[1][1], since row 0 and column 0 should all be 0
// if either one string is 0, then LCS is also 0
for (int i = 1; i <= x.length; i++) {
for (int j = 1; j <= y.length; j++) {
// thre... |
9a6091c2-ca47-44b0-bb8a-5d5fe77ac1cc | 2 | boolean checkValidCode(String code, int maxDigit){
try {
for (char c : code.toCharArray()){
check(c >= '0');
check(c <= '0'+maxDigit);
};
} catch (Exception e) {
return false;
}
return true;
} |
3c8dc8de-fb12-455c-8b8a-8591ebb03cdf | 0 | public static int getCount() {
return addresses.size();
} |
3646680e-cdad-436f-9331-e08881ba14a9 | 5 | public static String formatOutput(String str)
{
//处理边界的分隔符
int index = str.length()-1;
int start = str.charAt(0) == split_char ? 1 : 0;
int length = str.charAt(index) == split_char ? index : index + 1;
if(start == 0 || length == index)
{
str = str.substrin... |
db9c3dbb-a891-4f64-a350-84354c05134f | 3 | public FileItemList(String workingDirectory) {
super(workingDirectory);
directory = new File(workingDirectory);
if (directory.exists() && directory.isDirectory()) {
items.addAll(Arrays.asList(directory.list(new FilenameFilter() {
@Override
public boole... |
d1052217-4b4e-49e0-92f5-cdab27dfe657 | 0 | public String toString() {
return super.toString();
} |
144556cf-ea40-4439-be62-c521d48c5124 | 0 | public StringDataType createStringDataType() {
return new StringDataType();
} |
b2dc2a0e-5d45-4357-8531-fe6965ec7638 | 4 | public static void greyWriteImage(double[][] data){
BufferedImage image = new BufferedImage(data.length, data[0].length, BufferedImage.TYPE_INT_RGB);
for(int x = 0; x < data.length; x++){
for(int y = 0; y < data[0].length; y++){
if(data[x][y] > 1){
data[x][y] = 1;
}
Color color = new Color((floa... |
974282a9-08fb-4a68-9895-b0c397ac1281 | 2 | public static ArrayList<String> parseInputFile(String filename) {
ArrayList<String> commands = new ArrayList<String>();
File input = new File(filename);
try {
Scanner scanner = new Scanner(input);
while (scanner.hasNextLine()) {
commands.add(scanner.nextL... |
ce899d6b-92d1-454b-ad29-abcec7a0bfa5 | 4 | private void loadDatabase() {
// Declare a few local variables for later use
ClassLoader currentClassLoader = null;
Field cacheField = null;
boolean cacheValue = true;
try {
// Store the current ClassLoader, so it can be reverted later
currentClassLoader = Thread.currentThread().getContextClassLoader... |
24460c8f-7e2f-45c6-a13e-392b5b9cedc6 | 1 | public void print(){
ListNode<T> currentNode=head;
while(currentNode!=null){
System.out.println(currentNode.getData());
currentNode=currentNode.getNext();
}
} |
1c1ebadb-09bb-45f9-a602-270ef82197ed | 1 | private static String resolveEnvVariables(String path) {
for (String i : env.keySet()) {
String p = i.replace("(", "\\(").replace(")", "\\)");
String r = env.get(i).replace("\\", "\\\\");
path = Pattern.compile("%"+p+"%", Pattern.CASE_INSENSITIVE).matcher(path).replaceAll(r);
}
return path;
} |
bb7b0aff-720e-450d-80b2-2e0917e06180 | 6 | public synchronized List<Product> addPreferencesClient(Client client,
Product product) {
if (client != null && product!=null && listOfAllPreferences.get(client) != null) {//if there is already a list
List<Product> listAux = listOfAllPreferences.get(client);
listAux.add(product);
listOfAllPreferences.p... |
b5432323-c1c3-4b38-9f95-1af837b03edc | 1 | public void addVariablesWithLambdaProductions(Grammar grammar, Set lambdaSet) {
while (areMoreVariablesWithLambdaProductions(grammar, lambdaSet)) {
String variable = getNewVariableWithLambdaProduction(grammar,
lambdaSet);
addVariableToLambdaSet(variable, lambdaSet);
}
} |
1f7ea984-6e42-45a9-b8f6-242d6c05ade7 | 4 | BetLine(TeamType type, int moneyLine, String strTot) {
if (type.equals(TeamType.HOME)) {
home = getDecC(moneyLine);
away = getAnotherC(home);
} else {
away = getDecC(moneyLine);
home = getAnotherC(away);
}
Pattern p = Pattern.compile("([0-9... |
bc3f68a9-9217-4752-b9a1-c64c2de866ed | 8 | public List<String> DBExpiredCharNameSearch(Set<String> skipNames)
{
DBConnection D=null;
String buf=null;
final List<String> expiredPlayers = new ArrayList<String>();
final long now=System.currentTimeMillis();
try
{
D=DB.DBFetch();
final ResultSet R=D.query("SELECT * FROM CMCHAR");
if(R!=null) wh... |
3dc2f28c-8e47-48bf-990d-f13a51afd04c | 2 | public void updateElementPosition(Element element, Position newPosition) {
if (element == null || newPosition == null)
throw new IllegalArgumentException("The given parameters are invalid!");
getSquare(getElementPosition(element)).removeElement(element);
getSquare(newPosition).addElement(element);
} |
eb99455b-ddd0-4b2c-b92d-fe5bd03814ff | 8 | @Override
public void affectPhyStats(Physical affected, PhyStats affectableStats)
{
super.affectPhyStats(affected,affectableStats);
if(affected!=null)
{
if(affected instanceof Room)
{
final Room R=(Room)affected;
for(int i=0;i<R.numItems();i++)
{
final Item I=R.getItem(i);
if(I!=null... |
3fe00004-fdd6-4bd9-9cdc-448f6a9dd934 | 4 | private JMenuBar makeMenus() {
ActionListener listener = new ActionListener() {
// An object that will serve as listener for menu items.
public void actionPerformed(ActionEvent evt) {
// This will be called when the user makes a selection
// from the File menu. ... |
b7f389d7-c9d2-4fc9-9081-eaa960d087c5 | 8 | public void quantizeImage(ImageBean img)
{
int[][] newPix = new int[img.getWidth()][img.getHeight()];
for (int x = img.getWidth(); x-- > 0; )
for (int y = img.getHeight(); y-- > 0; )
newPix[x][y] = img.getPixels()[(y * img.getWidth() + x)];
int[] newColMap = Quantize.quantizeImage(newPix, 254);
for (int... |
70d98747-ba0f-4ae8-a459-edcadf8d583b | 2 | public boolean canPlayCard(Card card) {
return Game.linkedGet().isCardPlayable(card) && (turnPlays < 1 || card.value == Game.linkedGet().getPlayPile().peek().value);
} |
18b6ff4f-54be-4dd4-b191-501e2afbb0ff | 5 | public ArrayList<ITask> CSVLoad(String fileName) throws IOException {
File csvFile = new File(fileName);
if (!csvFile.exists())
throw new FileNotFoundException("Le fichier n'existe pas");
if (csvFile.isDirectory())
throw new FileNotFoundException("Le chemin designe un repertoire et non un fichier");
... |
dc3b4d9d-e05b-4ad0-9385-c4934619c95e | 1 | public String toString() {
if (instance == null)
return "new " + type;
else
return instance.toString();
} |
3dfe3b23-95b7-445b-a12a-6b9ac94184ae | 2 | @POST
@Path("/create/multiple/")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response createNewMultipleAccount(Account[] accounts){
Response.ResponseBuilder builder = null;
try {
for(Account account : accounts){
registry.register(account);
}
... |
d745153d-28df-43a1-8108-ccb6d19af2fd | 3 | public void insererClef(E clef, double priorite) throws Exercice1Exception {
if (clef == null) {
throw new Exercice1Exception("La clef ne peut être null");
}
if (rechercheClef(clef, SEARCH_TREE) != NIL) { // SEARCH_LIST marche nickel
throw new Exercice1Exception("La clef... |
54b2273d-fff9-4b07-ac6a-237998ca9229 | 7 | @EventHandler
public void punchWool(PlayerInteractEvent event) {
CTFTeam team = null;
TeamPlayer player = null;
for (CTFTeam t: Teams){
for (TeamPlayer p: t.getTeamPlayers()){
if (p.getPlayer().equals(event.getPlayer())){
player = p;
team = t;
}
}
}
if (player == null){
... |
957394c6-0aa9-4f97-bc85-9f95c23667e2 | 3 | public boolean isOutsideBounds(Bullet b){
if( b.pointY > 640 || b.pointX > 480 || b.pointY < 0 ){
return true;
}
else return false;
} |
0f0302b2-7016-4425-9932-a6c004b29eec | 2 | private DataContainer getFromAllTablesInDB() {
DataContainer allData = new DataContainer();
Set<String> tableNames = balancer.getAllAvailableTableNames();
Map<String, TableDescription> tableDescriptions = balancer.getTablesInDataBaseDescription();
for (String tableName : tableNames) {
... |
cae9cf54-124f-4aea-a38c-b8f55a5667b6 | 2 | public MainWindow()
{
super("简易词法&语法分析器");
this.setBounds(0, 0, 500, 260);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.getContentPane().setLayout(null);
this.setLocationRelativeTo(null);
//初始化控件
buttons.add(btnAnalysisDefault);
buttons.add(btnAnalysisCustom);
b... |
48ccbf1e-f8ce-48f9-b8e5-27362fb818f1 | 8 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
//GEN-FIRST:event_jButton1ActionPerformed
list = new BreakfastDao();
} catch (SAXException ex) {
Logger.getLogger(addItemToBreakfastMenu.class.getName()).log(Level.SEVERE, null, ex);
} catch (ParserC... |
6c6676a2-292c-4dc5-923e-0809c13020e6 | 5 | private void insertSplayTree(SplayTreeNode currentNode, SplayTreeNode newNode) {
if (currentNode == null) {
this.root = newNode;
} else {
if (newNode.value.compareTo(currentNode.value) < 0) {
if (currentNode.left == null) {
currentNode.left = ... |
1d18ab63-9cf2-4c26-a435-582981995c21 | 1 | public List<Integer> genNormal(int len, int range) {
List<Integer> list = new ArrayList<>();
for (int idx = 0; idx < len; ++idx)
list.add(RAND_.nextInt(range));
return list;
} |
3f8656bf-56ce-40ea-85a0-2746e7756ed9 | 2 | public void completeSchedule(Match[] schedule) {
jPanel1.setLayout(new BoxLayout(jPanel1, BoxLayout.Y_AXIS));
jPanel1.add(Box.createRigidArea(new Dimension(0, 6)));
for (Match match : schedule) {
if (!match.searchFor(2771)) {
continue;
}
MatchB... |
c945c370-b04e-4bb6-b6b4-c7f709713509 | 9 | private static void handleDecipherment() {
BigInteger exponent=null, module=null, cypher=null;
try {
exponent = new BigInteger(DeciphermentFrame.getInstance().tfExponent.getText());
if(exponent==null || exponent.compareTo(new BigInteger("0"))<=0) throw new IllegalStateException();
} catch(Exception e) {
... |
973ae22a-3103-4045-b996-24ca340554ca | 7 | @Override
public void actionPerformed(ActionEvent e) {
//System.out.println("ToggleExpansionAction");
OutlinerCellRendererImpl textArea = null;
boolean isIconFocused = true;
Component c = (Component) e.getSource();
if (c instanceof OutlineButton) {
textArea = ((OutlineButton) c).renderer;
} else if ... |
1737624e-cffc-43dd-95c9-46419eb5e306 | 3 | public static void ex3() throws NumberFormatException, IOException{
System.out.print("Valor del array => ");
int valor=Integer.parseInt(stdin.readLine());
double [] array=new double[valor];
for(int i=0; i<valor; i++){
array[i]=Math.random()*100;
System.out.print(array[i]+"\t");
}
System.out.print("\nColumna d... |
d446002f-a1ba-491c-8689-9ccf90586b21 | 8 | public int[] plusOne(int[] digits) {
int i = digits.length;
if(i==0){
return digits;
}
boolean inc =true;
for (;i>0;i--){
if (digits[i-1]==9&&inc){
digits[i-1] = 0;
}
else if (inc){
digits[i-1]++;
... |
9505323d-f640-4357-b67d-3f5d63a57a5d | 0 | public Object getDefault() {
return this.def;
} |
e057e764-fe75-4ab6-bfc8-9bdacd2d8ba1 | 8 | public void move(){
if (x<0 || x > 1450 || y < 0 || y >1000) {
this.switchDirection();
}
if(direction=='u'){y-=5;}
else if(direction=='d'){y+=5;}
else if(direction=='l'){x-=5;}
else if(direction=='r'){x+=5;}
} |
af74a9c1-7fae-4dcc-abba-50cbef4e7ac7 | 2 | private void printStringsFromSetHelper(char[] n, int k, StringBuilder s){
if(s.length() == k){
System.out.println(s.toString());
return;
}
for(int i=0; i<n.length; i++){
StringBuilder builder = new StringBuilder(s);
builder.append(n[i]);
printStringsFromSetHelper(n, k, builder);
}
} |
108fab79-59a7-4f71-81b5-d298220a3338 | 9 | public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
sc.nextLine();
System.out.println("Lumberjacks:");
while(T>0)
{
T--;
String line = sc.nextLine();
StringTokenizer tokens = new Strin... |
f6ab641d-4b91-4f51-a509-8d99d8a35491 | 7 | private static String[] _processAnnotation(String s, StreamTokenizer st)
throws IOException {
s = s.trim();
List<String> tokens = new ArrayList<String>();
Matcher annotationNameMatcher = _ANNOTATION_NAME_REGEXP.matcher(s);
Matcher annotationParametersMatcher =
_ANNOTATION_PARAMETERS_REGEXP.matcher(s);
... |
cc8033f0-2abb-45bc-84da-0671a584f9f6 | 6 | public Game(final int typeFirst, String firstName, final int typeSecond, String secondName) {
// TODO: Use enum!!!!
if ((typeFirst >= PLAYER_TYPE_AMOUNT) || (typeSecond >= PLAYER_TYPE_AMOUNT)) {
// return
} else {
pack = new Pack();
switch (typeFirst) {
... |
6c7d2f76-5d19-4692-bb07-e2eb60ab496a | 8 | public boolean containsValue( Object val ) {
byte[] states = _states;
V[] vals = _values;
// special case null values so that we don't have to
// perform null checks before every call to equals()
if ( null == val ) {
for ( int i = vals.length; i-- > 0; ) {
... |
54f3f196-3a0b-4741-ae70-64fdb6b9e41c | 0 | @Override
public void setSex(String sex) {
super.setSex(sex);
} |
17ff72f5-0196-4036-992b-2916b9b0f9c7 | 2 | @Override
public void drawImage(Function f, MyPanel image, double x, double y) {
Graphics g = image.getGraphics();
Graphics2D g2 = (Graphics2D) g;
g2.translate(150, 150);
g2.scale(x, y);
for (Line l : lines) {
Complex tmp1 = f.evaluate(l.c1);
int p = ... |
1b6c3a62-e293-4a51-9446-1c8c4e604990 | 3 | public Integer getLimit(Object[] args) {
if (limitIndex == -1) {
return limit;
}
Object arg = args[limitIndex];
if (arg == null) {
return null;
} else if (arg instanceof Integer) {
return (Integer) arg;
} else {
return null;
}
} |
4fd69e6b-1a3c-4c87-992b-b97868072760 | 1 | public Object next() {
int pos = rand.nextInt(pool.size());
Iterator i = pool.iterator();
while (pos > 0)
i.next();
return (String) i.next();
} |
b4dbd3f5-764e-4637-916d-e9fc321cce5e | 9 | @Override
public boolean okMessage(Environmental host, CMMsg msg)
{
if(((msg.sourceMinor()==CMMsg.TYP_QUIT)
||(msg.sourceMinor()==CMMsg.TYP_SHUTDOWN)
||((msg.targetMinor()==CMMsg.TYP_EXPIRE)&&(msg.target()==oldRoom))
||(msg.sourceMinor()==CMMsg.TYP_ROOMRESET))
&&(msg.source().location()!=null)
&&(msg.s... |
dfafbbff-f43f-475b-a0dd-6a9cb9a28bbc | 6 | public void remove(String[] command) {
int id = Integer.parseInt(command[0]);
for (int i = 0; i < compuertas.getLength(); i++) {
if (compuertas.get(i).equals(id)) compuertas.remove(i);
}
for (int i = 0; i < salidas.getLength(); i++) {
if (salidas.get(i).equals(id)... |
1b2a488f-6eeb-4508-a2bf-9c4e4674f137 | 9 | public void feed(Object obj) {
synchronized(BalancedPoolStageDriver.this) {
if ( !isInState(RUNNING, STOP_REQUESTED)
|| workers.size() > 1
|| (workers.size() == 1 && workers.peek().runnability == Runnability.RUNNABLE)) {
... |
89e3c963-5a34-4863-b442-f8611120b5bd | 8 | public void diceRolled(int roll) {
int ainum = _ais.size();
int rest = _players.size() - ainum;
synchronized(_players) {
for (Hex h : _hexes) {
if (h.getRollNum() == roll) {
for (Vertex vertex : h.getVertices()) {
int p = vertex.getOwner();
if (p != -1) {
_players.get(p).addCard(h.g... |
edac1fc6-969c-48ef-9492-b3b3b494f5c9 | 6 | private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
if (a.length != o.length)
return false;
for (int i = 0; i < a.length; i++)
if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i]))
return false;
return true;
} |
1b2e9584-7dc2-4af7-bb4b-b015dcf2c488 | 7 | public void generate() {
MapArray = new Tile[size][size];
// System.out.println("passed ");
// assign grass
for (int j = 0; j < size; j++) {
for (int k = 0; k < size; k++) {
MapArray[j][k] = new Tile();
}
}
// System.out.println("passed 1 ");
int TreasureX = (int) (Math.random() * size);
i... |
75eab825-055d-42c9-9037-82cad305a09b | 2 | @Override
public boolean createWhen() {
return stage.count%15==0 && (6<stage.second() && stage.second()<8);
} |
d9b6f177-c38a-4deb-93ac-ccaa323e9d4f | 6 | public static double atanh(double a) {
boolean negative = false;
if (a < 0) {
negative = true;
a = -a;
}
double absAtanh;
if (a > 0.15) {
absAtanh = 0.5 * FastMath.log((1 + a) / (1 - a));
} else {
final double a2 = a * a;
if (a > 0.087) {
absAtanh = a
* (1 + a2
* (F_1_3 + a... |
96cde0fe-aea3-49a8-8884-5909e3c21c89 | 7 | public static int[] getPlayersCountInPositions(int range, L2Character npc, boolean invisible)
{
int frontCount = 0;
int backCount = 0;
int sideCount = 0;
for (L2PcInstance player : npc.getKnownList().getKnownType(L2PcInstance.class))
{
if (player.isDead())
continue;
if (!invisible && player.... |
0d3d1430-9616-4318-bbe8-ccba4ad30c6b | 5 | public double rate(EnhancedMove move) {
int dropHeight = move.getBoard().dropHeight(move.getPiece(), move.getX());
Point[] pos = move.getPiece().getBody();
Board board = move.getBoard();
int neighbors = 0;
for(int i = 0; i < 4; i ++){
int tarX = pos[i].x + move.getX();
int tarY = pos[1].y + dropHe... |
9171a672-e7de-430f-9745-6e3c497f9829 | 3 | static public void main(String args[]) {
double x, y;
OSGB osgb = new OSGB();
if (args.length < 2) {
/*
* Caister Water Tower
*/
x = 651409.903;
y = 313177.271;
} else {
Double d;
d = new Double(args[0]);
x = d.doubleValue();
d = new Double(args[1]);
y = d.doubleValue();
}
... |
b56836a4-be5d-4538-a9ea-1a4f563985a5 | 3 | public void fish(Item rod)
{
switch(rod.type)
{
case OLD_ROD:
enemy[0]=Mechanics.randomEncounter(Pokemon.Species.MAGIKARP,20,5,Pokemon.Species.PSYDUCK,20,10,Pokemon.Species.GOLDEEN,20,10,
Pokemon.Species.TENTACOOL,30,5,Pokemon.Species.KRABBY,10,10);
break;
case GOOD_ROD:
enemy[0]=Mechanics.ra... |
2e1e7593-a6fc-45ea-9c34-9b86f13b7333 | 5 | public static List UniteList(List x,List y){
if ((x == null) || (x.size() == 0) || (y == null) || (y.size() == 0)) {
return new ArrayList();
}
if(x.size()>y.size()){
x.retainAll(y);
return x;
}else{
y.retainAll(x);
return y;
}
} |
51f1df49-5915-4c0c-84e8-1362cb9a60c4 | 0 | public TransformsType createTransformsType() {
return new TransformsType();
} |
e66759bf-7363-4688-9cf4-f6c1d2d425c9 | 3 | public static List<Oppilas> haeOppilaatByName(String etunimi, String sukunimi) {
Connection c = connect();
if (c == null) return null;
try {
List<Oppilas> oppilaat = new ArrayList<Oppilas>();
PreparedStatement ps = c.prepareStatement("SELECT * FROM oppilas " + "JOIN ryhma ON oppilas.ryhma = ryhma.ryhmaID " ... |
3495e517-0d4b-4f20-ad76-98fada91c2bb | 3 | @Override
public int countZero() {
int count = 0;
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
if (Double.compare(matrix.get(i, j), 0.0) == 0) {
count += 1;
}
}
}
return count;
} |
467e24f1-b4d4-4902-8972-cbd346f3b796 | 5 | private String getCorrectWorldFileName(File folder, String text)
{
int i = 1;
for(int ii = 0;ii<ILLEGAL_WORLD_NAMES.length;ii++)
{
if(text.equalsIgnoreCase(ILLEGAL_WORLD_NAMES[ii]))
text = "_"+text+"_";
}
for(int ii =0;ii<ILLEGAL_WORLD_NAME_COMPONE... |
f9b77eab-8f85-4a45-b8e7-e73a8fbf3f21 | 7 | private void initForClass(Map<Class<?>, S> context, S system, Class<? extends Object> systemClass) {
for (Field field : systemClass.getDeclaredFields()) {
final Inject inject = field.getAnnotation(Inject.class);
if (inject != null) {
final Object value = context.get(field... |
fe76d65e-705d-4750-8460-ce93470e23b1 | 2 | private void ejecutarQuery() {
if (txtDB.getText().equals("") || txtQuery.getText().equals("")) {
lblResultado.setText("Falta rellenar alguno de los campos...");
} else {
lblResultado.setText("Enviando consulta...");
lblEstado.setText("Iniciando conexion...");
controlador.enviarDatos(txtDB.getText(), tx... |
f49602e4-bd63-48df-b974-222b383a26e5 | 4 | private static byte encodeConnectionId(int connectionId) throws ConnectionIdOutOfRangeException {
if(connectionId != Packet.ANONYMOUS_CONNECTION_ID && (connectionId < Packet.MINIMUM_CONNECTION_ID || connectionId > Packet.MAXIMUM_CONNECTION_ID))
throw new ConnectionIdOutOfRangeException(connectionId);
return (byt... |
3311cf8c-9134-436f-bd9f-7eb5199fa85e | 7 | public void read() {
try {
if (this.in == null) {
this.in =
new InputStreamReader(new FileInputStream(this.curFile));
}
while (this.in.ready()) {
this.inputInt = this.in.read();
try {
if (this.textArea == null) {
return;
}
if (!this.running) {
this.textArea.getDoc... |
e3c2d167-07cd-4385-98ed-d6eba54cd582 | 4 | private TheaterSeats loadSeatsFromDisk(File name){
FileInputStream fis;
ObjectInputStream ois;
TheaterSeats theaterSeats = null;
try {
fis = new FileInputStream(name);
ois = new ObjectInputStream(fis);
try{
theaterSeats = (TheaterSeats) ois.readObject();
}catch (EOFException e) {
//carry o... |
410f8ad7-ede3-4f0e-850b-13eb0d0528c6 | 3 | public List<Keyword> findKeywords(List<String> kwInput) {
ArrayList<Keyword> res = new ArrayList<Keyword>();
for (String s: kwInput) {
for (Keyword kw: keywordList) {
if (kw.getWord().equals(s)) {
res.add(kw);
}
}
}
return res;
} |
8ccdb5f6-acf7-4ba6-9ed0-e963a66ce713 | 0 | public static String nowString(){
String dateString = "";
Calendar cal = Calendar.getInstance();
dateString += String.valueOf( cal.get(Calendar.YEAR)) + "年" ;
dateString += String.valueOf( cal.get(Calendar.MONTH) + 1) + "月";
dateString += String.valueOf( cal.get(Calendar.DATE)) +... |
caab5c63-997b-4b71-8a9b-0e6b0d245940 | 9 | public void enterCommand(String command, Player player) {
try {
String[] commandString = command.split(" ");
if (SubCommand.isHelpCommand(commandString[0]) || commandString[0].equals("")) {
help(commandString);
} else if (SubCommand.isBackCommand(commandString... |
7cc041d1-3113-4d1d-84f6-23b5232e525b | 0 | public int from() { return v; } |
8c438c55-a073-4dfe-8143-cf9f62202ed5 | 7 | public LegendEntry(PlotData2D data, int dataIndex) {
javax.swing.ToolTipManager.sharedInstance().setDismissDelay(5000);
m_plotData = data;
m_dataIndex = dataIndex;
// this.setBackground(Color.black);
/* this.setPreferredSize(new Dimension(0, 20));
this.setMinimumSize(new D... |
d66464f7-7151-4251-8416-115fa846dd93 | 5 | public void move() { //la miscarea automobilului, distanta creste, drumul de misca proportional distantei;
distance += speed;
speed += acceleration;
if (speed > MAX_SPEED) speed = MAX_SPEED;
if (speed <= MIN_SPEED) speed = MIN_SPEED;
pozY += deltaY;
if (pozY <= MAX_TOP)... |
f1d9248a-ecca-4767-825a-2bda89ae5888 | 8 | public static void main(String[] args) {
int i = 0;
outer:
for(; true; ) {
inner:
for(; i<10; i++) {
System.out.println("i = "+i);
if(i == 2) {
System.out.println("continue;");
continue;
}
if(i == 3) {
System.out.println("break;");
i++;
break;
... |
caa90d24-54ca-4c37-80b2-46815686f72d | 3 | public byte[] coding(byte[] data) {
int bufLen = data.length + (data.length + 6 ) / 7 ;
ByteBuffer buf = ByteBuffer.allocate(bufLen);
for(int i = 0; i != data.length; i++) {
int right = (i % 7) + 1;
int left = 7 - right;
byte value = (byte)((data[i] & 0xFF) ... |
75382119-9c28-4fe1-a9dc-8266104e2b49 | 2 | @Override
public synchronized Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (flavor.equals(flavors[STRING])) {
return nodeSet.toString();
} else if (flavor.equals(flavors[NODESET])) {
return nodeSet.clone();
} else {
throw new UnsupportedFlavorExce... |
1d83915f-9b78-45aa-82b3-a9041929f190 | 9 | private void asetaViereiset(Ruutu ruutu, int x, int y) {
int miinat = 0;
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
//tarkistetaan ettei ruutun omaa pommia lasketa
if ((i == 0 && j == 0)) {
//tarkistetaan että ruutu on ke... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.