method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
392698a4-730f-41e7-8203-fb4a848a9525 | 4 | public static <T extends DC> Set<Pair<Pair<T,PT<Integer>>,
Pair<T,PT<Integer>>>> getPhiMax(Set<Set<Pair<Pair<T,PT<Integer>>,Pair<T,PT<Integer>>>>> allPhis)
{ if(allPhis!=null)
{ Set<Pair<Pair<T,PT<Integer>>,Pair<T,PT<Integer>>>> phiMax=allPhis.getFst();
Similarity simMax=g... |
9620a4f0-28eb-4027-9e4b-3dfacd12ed47 | 9 | public synchronized void run() {
running = true;
while (running) {
while (paused && !resetReq) {
try {
Thread.sleep(50);
} catch (Exception e) {
}
startTime += 50;
}
try {
readFrame();
list... |
483131d3-07d7-4abb-9a14-8c4159a124f5 | 1 | public static AbstractModel getRandomSet(int min, int max, int size,AbstractModel result) {
// AbstractModel result = new ModelParallel();
Random r = new Random(1);
for (int i = 0; i < size; i++) {
result.p.add(new Particle(0.5, 0, 0, min + r.nextInt(max - min)
+ 0.5 - r.nextDouble(), min + r.nextInt(max -... |
a4f752bd-35de-41b8-bbee-a24973d04082 | 5 | private void getThreadContent(Map<String, Object> jsonrpc2Params) throws Exception {
Map<String, Object> params = getParams(jsonrpc2Params,
new NullableExtendedParam(Constants.Param.Name.THREAD_ID, false),
new NullableExtendedParam(Constants.Param.Name.SORT_TYPE, true));
... |
7e722d2a-0c69-4647-abb0-b3e509b99ce8 | 5 | public void closeInventory(){
HUD.dispInv = false;
if(HUD.inMouse != HUD.empty){
//if bag is closed with object in hand then put it in first open one
for(int i = 1; i < HUD.inventory.length; i++){
if(HUD.inventory[i].getItemNum() == HUD.empty.getItemNum()){
HUD.inventory[i] = HUD.inMouse;
HUD.in... |
00377baa-8407-4fad-8ff5-378989f94d8c | 9 | public void run() throws IOException {
//通过输入流接收客户端信息
Map<String,String> map = new HashMap<String,String>();
int receivelength = 0;
while (true) {
String line = in.readLine();
if (line == null || "".equals(line.trim()) || receivelength>2000) { // 是否终止会话
break;... |
a39078d3-754e-410b-b235-a897445f71c0 | 5 | protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
RequestDispatcher rd = null;
Enumeration<String> enumeratie = req.getParameterNames();
while(enumeratie.hasMoreElements()) {
String name = enumeratie.nextElement();
if (name.startsWit... |
1bd176d2-71b7-4f2e-86ed-5ba4f7b1f5a4 | 2 | private void syncDictFromList() {
if(dictionary == null) {
dictionary = new DictMap();
}
// clear existing elements
dictionary.clear();
String word = "";
for (int i = 0; i < wordList.size(); i++) {
word = wordList.get(i);
dictionary.put(PhonewordFinder.word2num(word), word);
}
} |
09710353-69aa-445a-a8b0-8ee0c830d9cf | 3 | @Override
public boolean equals(Object o) {
if (o == null) return false;
if (!(o instanceof Pair)) return false;
Pair pairo = (Pair) o;
return this.left.equals(pairo.getLeft()) &&
this.right.equals(pairo.getRight());
} |
1667e951-43c5-42c3-81d9-254606a65397 | 7 | public boolean canPlayerMove(boolean team) {
//player: true -> white false -> black
int x = team ? 0 : 1;
for (int i = 0; i < tabellone.length; i++) {
for (int j = 0; j < tabellone[i].length; j++) {
if (tabellone[j][i] != VUOTO && ((tabellone[j][i] % 2) == x) && (c... |
e6183425-ff31-40d8-9f84-6503c672e2cc | 9 | @Override
public SourceValue unaryOperation(final AbstractInsnNode insn,
final SourceValue value) {
int size;
switch (insn.getOpcode()) {
case LNEG:
case DNEG:
case I2L:
case I2D:
case L2D:
case F2L:
case F2D:
case D2L:
... |
0d343c5e-25ca-46de-9cec-bfac7d386a41 | 8 | @Override
public String toString()
{
switch(this)
{
case CRN:
return "CRN";
case INSTRUCTOR:
return "Instructor";
case TIME:
return "Time"; // TimePeriod object
case DAY:
return "Day"... |
e35c5585-67c8-4195-befe-c78a7d4eed06 | 4 | @Override
public void run() {
/*String line;
Scanner s = new Scanner(System.in);
while (true) {
try {
line = s.nextLine();
if (line.equals("")) {
break;
}
} catch (NoSuchElementException e) {
... |
b8f24950-a16f-4c02-bee0-845daf9f86e2 | 4 | public String translate(){
fillData();
String error = validate();
if (error != null){
tulip.Tulip.mainFrame.writeConsole(error);
return null;
}
String result = "program "+ name.substring(0, (name.indexOf(".") > 0)?name.indexOf("."):name.l... |
33a386c4-f31c-47cb-af88-ba5880de3f6f | 8 | private void addToGroup(String groupName, IContributionItem item,
boolean append) {
int i;
Iterator items = contributions.iterator();
for (i = 0; items.hasNext(); i++) {
IContributionItem o = (IContributionItem) items.next();
if (o.isGroupMarker()) {
String id = o.getId();
if (id != null && id.eq... |
e22d6b9c-d445-4f8f-8781-82650048152f | 0 | @BeforeClass
public static void setUpClass() {
} |
3d2aeb0a-adbf-4485-b499-64f3a4730cd4 | 4 | public void renderCamera(Camera c) {
c.setColor(Color.black);
world.renderCamera(c);
c.setColor(Color.black);
village.renderCamera(c);
c.setColor(Color.black);
if(drawGrid) {
c.setColor(new Color(0,0,0,25));
for(int x = 0; x < world.width; x++) {
c.drawLine(x * World.scale, 0, x * World.... |
57626c6b-bb7a-416d-beb8-e26da5c3033b | 9 | private JSONObject postEvent(String request_type, JSONObject jsonIn) throws java.net.SocketTimeoutException, MessageTypeException,
java.net.MalformedURLException, IOException, ParkingException {
formatUrl(request_type, jsonIn);
url = Config.url;
if (request_type.equals("event")) {
... |
bcf12967-0303-415a-b349-1a19a00f86d4 | 0 | public ArrayList<Auction> getAuctionsList(){ return auctionsCatalog; } |
99f77329-68a0-46bd-9cb2-35bb5d527efc | 3 | public ConfigurationSection getDefaultSection() {
Configuration root = getRoot();
Configuration defaults = root == null ? null : root.getDefaults();
if (defaults != null) {
if (defaults.isConfigurationSection(getCurrentPath())) {
return defaults.getConfigurationSecti... |
8afc77be-b081-412d-a79d-6bf6a089ff27 | 2 | public final static ArtistBiography getInstance() {
if(ArtistBiography.instance == null)
synchronized(ArtistBiography.class) {
if(ArtistBiography.instance == null)
ArtistBiography.instance= new ArtistBiography();
}
return ArtistBiography.instance;
} |
194a3ac0-ffac-4155-b091-5409aecc19aa | 1 | @Test
public void testInfiniteRecursion() throws Exception {
// father_of(GP, C) :- father_of(GP, P), father_of(P, C).
KnowledgeBase knowledgeBase = new KnowledgeBase();
knowledgeBase.registerRule(new Rule(new Predicate("father_of", new Variable("GP"), new Variable("C")),
new... |
3362db4f-0109-4b7e-8eaa-73c6e17ab211 | 1 | public int constantValue() {
if (constantValue != null) {
return constantValue.constantValueIndex();
}
return 0;
} |
fe4df873-0f00-48d9-81de-230768b47678 | 6 | public Booking(JSONObject json) throws JSONException {
if (json.has(ID)) {
this.setId(json.getString(ID));
}
if (json.has(CANCELED)) {
this.setCanceled(json.getBoolean(CANCELED));
}
if (json.has(BOOKTIME)) {
this.setBooktime(StringUtil.parseDate(json.getString(BOOKTIME)));
}
if (json.has(STATUS))... |
aec84cb4-4e60-4e53-aa8c-d03fcbb6a1a5 | 0 | @Override
public IReceiveMessage getReceiveMessage() {
return receiveMessage;
} |
e171f778-69ef-458c-b37b-4a0395032e48 | 9 | public Location getAdjacentLocation(int direction)
{
// reduce mod 360 and round to closest multiple of 45
int adjustedDirection = (direction + HALF_RIGHT / 2) % FULL_CIRCLE;
if (adjustedDirection < 0)
adjustedDirection += FULL_CIRCLE;
adjustedDirection = (adjustedDirect... |
a878b19d-18fc-4837-8cd5-022d62ffcab4 | 7 | public void setInstances(Instances ins) throws Exception {
if (ins.numAttributes() > 512) {
throw new Exception("Can't display more than 512 attributes!");
}
if (m_span == null) {
m_span = new JPanel() {
private static final long serialVersionUID = 7107576557995451922L;
public void pa... |
93a8cec5-a3fd-4888-a254-3f36516a4e4c | 5 | public static boolean saveCommits(Map<String, LinkedList<Commit>> map) {
try {
for(String fullName : map.keySet()) {
JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
for(Commit commit : map.get(fullName)) {
arrayBuilder.add(commit.toJsonObject());
}
String content = arrayBuilder.bu... |
8adc7dcb-df62-467b-9f07-c2633c2ef984 | 7 | public Integer costFrom(Node from, ElementPanel panel, Point target) {
for (Component c : panel.getElements())
if (c.intersects(p, from.p))
return null;
if (panel.getHvLines() != null && Node.dist(p, from.p) > 20)
for (HVLine hvl : panel.getHvLines())
if (hvl.contains(p, from.p))
return null;
... |
80c8ff72-466e-44cc-8943-2849be4f7329 | 5 | @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0 && !config.getString("Config.Presets.Default").isEmpty()) {
return viewFactoid(sender, config.getString("Config.Presets.Default"));
} else if (args.length == 1) {... |
c1e30413-9777-4b81-9345-c41dd03859d3 | 4 | private static int findSmallestPath(int I1, int J1, int I2, int J2) {
q.add(new Node(I1, J1, array[I1][J1]));
while (!q.isEmpty()) {
Node current = q.poll();
if (current.i == I2 && current.j == J2) {
return current.distance;
}
... |
da3d0125-87b2-446a-8662-4eee3dd0a841 | 2 | @Override
public Object promptForAnswer() {
String input = InputHandler.getString("");
if (input.contains(" ") || input.contains(",")){
String[] choices = input.split(",|\\s");
return choices;
}
return new String[]{input};
} |
34b40879-26b5-4b48-9687-04e8f5edb378 | 9 | public static int eval(double d)
{
if(d<=1.2)
return 0;
if(d<=1.8)
return 1;
if(d<=2.3)
return 2;
if(d<=2.6)
return 3;
if(d<=2.7)
return 4;
if(d<=2.8)
return 5;
if(d<=2.9)
... |
b785048b-d248-4607-8e2a-68667004ad1e | 7 | public void constructInvertedIndexFromFile(String indexDirectory)
{
try
{
if (!indexDirectory.substring(indexDirectory.length() - 1).equals("/"))
{
indexDirectory = indexDirectory+"/";
}
FileReader fr = new FileReader(indexDirectory+indexFileName);
try
... |
5a9c039e-c505-4118-aa59-9ac59d193f73 | 3 | private void buyOrSell() {
if (typeOfTrade.equalsIgnoreCase("buy")) {
EarningsTest.programSettings.myPortfolio.put(ticker, timeOf);
} else if (typeOfTrade.equalsIgnoreCase("sell")) {
if (EarningsTest.programSettings.myPortfolio.containsKey(ticker)) {
EarningsTest.programSettings.myPortfolio.remove(ticker... |
2eaf656a-1809-48e6-96a6-0649bd3e5d76 | 3 | public void Position (double value){
double forward = 2.1;
double center = 1.50;
double reverse = 1.00;
double ms;
lastPosition = value;
value = (value > 1) ? 1 : value;
value = (value < -1) ? -1 : value;... |
c0a55156-78bd-4cbc-a499-519cd854a9fc | 1 | @Override
public final void paint(Graphics g) {
if (graphics == null) {
graphics = g;
}
shouldClearScreen = true;
raiseWelcomeScreen();
} |
46a5bd72-b634-4ec5-942e-3103e2a70656 | 1 | private Rectangle transposeRectangle(Rectangle from, Rectangle to) {
if (to == null) {
to = new Rectangle();
}
to.x = from.y;
to.y = from.x;
to.width = from.height;
to.height = from.width;
return to;
} |
eb00d0a5-b917-4d5b-933d-e4e0d1daeb07 | 4 | public static <T extends Comparable<? super T>> T min(T[] a) {
if (a.length == 0)
return null;
T min = a[0];
for (int i = 1; i < a.length; i ++) {
if (min.compareTo(a[i]) < 0) {
min = a[i];
}
}
return min;
} |
2c1b43b2-7fa7-44b9-9701-3b7145f601e5 | 9 | public boolean similar(Object other) {
try {
if (!(other instanceof JSONObject)) {
return false;
}
Set<String> set = this.keySet();
if (!set.equals(((JSONObject)other).keySet())) {
return false;
}
Iterator<St... |
7123139c-bcf5-4fd0-9574-4635961d2557 | 4 | public void patch() throws AlreadyModdedException {
Date start = new Date();
createBackup();
// Patchlogic
try {
for (File soundPackFile : pack.getSoundpackFiles()) {
logger.debug("Gonna patch " + soundPackFile.getName());
for (File archiveFile : files) {
if (soundPackFile.getName().equals(archi... |
1a2f1787-5c86-454a-8d58-d0474c3eeb60 | 7 | private String checkIncreaseEvent(int ie) {
switch (ie) {
case 0:
return "DROUGHT";
case 1:
return "COLD";
case 2:
return "CROPFAIL";
case 3:
return "WAR";
case 4:
return "... |
8d69877a-72b9-47a1-af0f-d5f011a80958 | 3 | public void playCard(Card card, Side side) {
Game.handPanel.removeCard(card);
Game.handPanel.repaint();
Game.handPanel.revalidate();
switch (card.getType()) {
case MANA:
Game.gameBoard.localSide.manaBoard.addCard(card);
break;
case ENCHANTMENT:
Game.gameBoard.localSide.creatureBoard.attachEntchan... |
3b3bb527-2ba6-4ee5-a7cf-be6a3072d8bf | 7 | public void run() {
seconds = 0;
while (thread != null) {
if ((apuLine != null) && (apuLine.isOpen())) {
long milliseconds = (long) (apuLine.getMicrosecondPosition() / 1000);
seconds = milliseconds / 1000.0;
}
try {
Thre... |
c750a7a6-2614-4db5-a188-492c83dce751 | 2 | public Texture get(String fileName, int filter) throws IOException {
fileName = filePath + fileName;
SoftReference<Texture> ref = loadedBitmaps.get(fileName);
Texture current = ref == null ? null : ref.get();
if (current != null) {
return current;
} else {
loadedBitmaps.remove(fileName);
Texture resu... |
0ebb7e69-44f7-4404-b9d6-c20b32793804 | 4 | @Override
public int[] select(Population pop, int toSelect) {
double minimal = pop.people[0].fitness();
// if population is not ordered, search the worst one.
if (minimal * pop.getBest().fitness() >= 0) minimal = 0;
// only necessary if fitness of pop has both symbols (+/-)
double tot_acc = Math.abs(pop.av... |
fdd2f974-669d-4cf0-a8ad-ab494b39ddcf | 7 | public int getParticleCount(byte type, Shape shape) {
int n = 0;
for (int i = 0; i < numberOfAtoms; i++) {
if (type == -1) {
if (shape == null || atom[i].isCenterOfMassContained(shape)) {
n++;
}
} else {
if (atom[i].id == type) {
if (shape == null || atom[i].isCenterOfMassContained(shape... |
fdc23689-7f63-4539-b321-14c9e9aad18a | 9 | public static <T> Object defaultPrimitive(Class<T> type) {
if (type.equals(byte.class)) {
return (byte) Math.random();
} else if (type.equals(int.class)) {
return (int) Math.random();
} else if (type.equals(double.class)) {
return Math.random();
} else if (type.equals(char.class)) {
... |
29f9afc2-6283-448b-8bee-6ab9a90a98dc | 8 | public void calculateRecordForArticleStat(DateTime aDay) {
List<SiteModel> siteModelList = siteDao.findAllSite();
for (SiteModel siteModel : siteModelList) {
//for(int i=0;i<=3; i++){
//SiteModel siteModel = siteModelList.get(i);
ArticleStatModel uniqueVisitorModel = ... |
26a7a65e-2c2f-4c17-9c5b-df89cdc73023 | 8 | public void render(PixelCanvas pCanvas, Projection pProjection) {
final Point3D lPos = pProjection.rotate(fCoordinate.getPoint3D());
if ((pProjection instanceof ProjectionOrtho) && (lPos.getZ() <= 0)) {
// Back side of the Earth.
// Insight: We don't need to check if the marker is visible in other
// proj... |
d92b352d-d649-46f5-abc9-956ec7a1db19 | 6 | private static Map readSettings() throws Exception {
final Map result = new HashMap();
FileReader fr = null;
BufferedReader br = null;
String line = null;
try {
fr = new FileReader("settings.properties");
br = new BufferedReader(fr);
while ((... |
7554e58e-67d9-4140-b201-7f0fe99843ea | 6 | public ListNode removeNthFromEnd(ListNode head, int n) {
if(head == null) {
return head;
}
if(n == 0) {
return head;
}
ListNode end = head;
for(int i=0;i<n-1;i++) {
end = end.next;
}
ListNode fast = head;
ListNod... |
32475089-fb29-4330-b639-fa765225454d | 6 | public boolean isMirror(TreeNode root1,TreeNode root2){
if (root1 ==null &&root2==null){
return true;
}
if (root1 ==null ||root2==null){
return false;
}
return (root1.val== root2.val&&isMirror(root1.left,root2.right)
&&isMirror(root1.right,root... |
4899c463-da04-439e-aaa2-f4f75d2c9d96 | 5 | final boolean method1066(boolean bool, String string) {
anInt1776++;
if (((Class117) this).aClass356_1767 == null)
return false;
if (bool != false)
aClass356_1770 = null;
if (aClass356_1770 == null)
method1071(true);
for (Class348_Sub46 class348_sub46
= ((Class348_Sub46)
aClass356_1770.get(... |
9e1b835d-b378-4ec2-add7-a8b7907e181d | 2 | private void evaluateRegex() {
String regex = input.getText();
Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
Matcher matcher = pattern.matcher(editor.getText());
clearHighlights();
numMatches = 0;
currentMatch = 0... |
8377be66-0af1-416f-bd5a-cf894c41b758 | 5 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ChangeIn other = (ChangeIn) obj;
if (Double.doubleToLongBits(dx) != Double.doubleToLongBits(other.dx))
return false;
if (Double.doubleToLong... |
4011cb97-8a8d-4581-8356-65e861d36e7f | 5 | public void logear(){
AbstractRol coman;
String nick = null;
boolean seguir = true;
do{
try{
System.out.print("\nNick>");
nick = Ingresar.leerString();
if(nick.equals("exit")){
seguir = false;
}else{
String password = getPasswordOculta();
System.out.println(" ");
... |
d07f141a-66ff-429a-ba78-c0f3c517fe34 | 9 | private int score(Hand h) {
if(isRoyalFlush(h)) {
return 10;
}
if(isStraightFlush(h)) {
return 9;
}
if(is4ofaKind(h)) {
return 8;
}
if(isFullHouse(h)) {
return 7;
}
if(isFlush(h)) {
return... |
5049ab8a-26b8-4bd1-86df-ccc9e21db580 | 2 | public SubCommand getCommand(String label)
{
if (label == null)
{
return null;
}
label = label.toLowerCase();
String name = this.aliases.get(label);
if (name != null)
{
return this.getCommandByName(name);
}
else
... |
bcb807fa-b2c4-4a61-be69-532164ff5804 | 8 | protected boolean isLofDeletion(ChangeEffect changeEffect) {
Transcript tr = changeEffect.getTranscript();
if (tr == null) throw new RuntimeException("Transcript not found for change:\n\t" + changeEffect);
//---
// Criteria:
// 1) First (coding) exon deleted
//---
if (changeEffect.getEffectType() == Ef... |
24e76c51-6361-4ed4-9af4-4756b1f69f29 | 8 | private void setKey(KeyEvent e)
{
boolean ctrl = false;
boolean alt = false;
if(e.isControlDown())
{
ctrl = true;
}
else if(e.isAltDown())
{
alt = true;
}
int a = e.getKeyCode();
String key = KeyEvent.getKeyText(a);
if(key.substring(0,1).equals("N"))
{
key = key.subs... |
6f3bfcdf-4e3c-461b-b00f-5eb76209cb97 | 6 | public static void printIndex() {
if (indexSetList == null || indexSetList.size() <= 0) {
return;
}
for (Integer[] array : indexSetList) {
if (array != null && array.length > 0) {
StringBuffer sbBuffer = new StringBuffer();
for (Integer itemInteger : array) {
sbBuffer.append(itemInteger + " ")... |
fe5297f6-a502-4c44-9a40-18f3df264b9d | 7 | public void drawEquation(DrawableEquation equation, Graphics g){
Iterable<GraphPoint> points = equation.getPoints(dimensions);
GraphPoint last = null;
for(GraphPoint p:points){
if(Double.isInfinite(p.x) || Double.isInfinite(p.y) || Double.isNaN(p.x) || Double.isNaN(p.y))
p = null;
if(last!=null && p!=nu... |
6e6854e3-98fc-42b5-9533-dea226d82a5c | 3 | public Environment<K,V> removeChild( String name ) {
// First: locate the container
List<Environment<K,V>> tmpList = this.children.get( name );
// Container exists?
if( tmpList == null ) {
return null;
} else if( tmpList.size() != 0 ) {
// Container exists and has elements
// --> remove first... |
ec406fad-5e49-466e-8d81-2307846ff205 | 6 | private static void addSettersClass(Class<?> cls) {
List<Method> setters = new ArrayList<Method>();
classToSetters.put(cls, setters);
while (cls != null) {
for (Method method : cls.getDeclaredMethods()) {
int modifiers = method.getModifiers();
if (Modi... |
718b53e5-1630-4ec8-9b1c-ac51170cfff3 | 9 | private boolean r_Step_4() {
int among_var;
int v_1;
// (, line 140
// [, line 141
ket = cursor;
// substring, line 141
among_var = find_among_b(a_7, 18);
if (among_var == 0)
... |
b8ef180b-7e36-4f0e-aa8b-37aa51f3c72c | 2 | public boolean removeFromKit(int index){
try{
kit.remove(index);
return true;
}catch(UnsupportedOperationException e){
return false;
}catch (IndexOutOfBoundsException e){
return false;
}
} |
1ad25b23-6cf0-4a0b-bba8-696cbdb7f029 | 7 | private ArrayList<String> dfs(String s, int n) {
ArrayList<String> result = new ArrayList<String>(), tmpList, key;
if( n == 0 ) return result;
for( int i = 0; i < s.length(); i++ ) {
String head = s.substring(0, i+1);
String tail = s.substring(i+1);
key = new... |
60b8a58e-175a-439f-b59d-18541e161d05 | 8 | @SuppressWarnings({ "unchecked", "rawtypes" })
public void initalizeFromEnvironment() throws Exception {
ObjectMapper mapper = new ObjectMapper();
String vcapServices = System.getenv("VCAP_SERVICES");
if (vcapServices != null) {
Map<String, List<Map>> svcMap = mapper.readValue(vcapServices,
Map.class)... |
6ec048e6-ef12-4fce-8b1c-8c097fb9a1e5 | 0 | public void setX(float x) {
this.x = x;
} |
405dad47-737a-4094-884d-77ee5aa5282e | 0 | public Pair(K key, V value) {
this.key = key;
this.value = value;
} |
2aa090d5-f1d9-4677-b5f4-a3aa5a2bc392 | 9 | @Override
public String toString() {
String s = "";
for(int j=0; j<gridSize[1]; j++) {
for(int i=0; i<gridSize[0]*2; i++) {
if(i%2==1-j%2) {
s+=" ";
} else {
Hexagon h = grid[(i-j%2)/2][j];
int food = h.getFood();
if(food>0) {
if(food>9) {
s+="f";
} else {
s... |
fce342d7-2321-42bc-9cb0-2a7cebc530c4 | 3 | public void propertyChange(PropertyChangeEvent evt) {
int newId = ((Integer)evt.getNewValue()).intValue();
boolean hasPrev = false;
Enumeration<Node> nodesEnumer = Runtime.nodes.getNodeEnumeration();
while(nodesEnumer.hasMoreElements()){
Node nd = nodesEnumer.nextElement();
if(nd.ID == newId){
b... |
dcb73cae-ee92-47fb-9321-c3b8e9cd1daf | 3 | private int draw(Graphics2D g2, int width)
{
int y = 0;
FontMetrics fontMetrics = this.getFontMetrics(font);
FontRenderContext fontContext = fontMetrics.getFontRenderContext();
g2.setFont(font);
for (CommsLogEntry entry : entries)
{
List<String> lines = wrapText(fontContext, entry.getMessag... |
91c19f9c-7b7f-4698-8a75-cc0a21470435 | 4 | protected void refreshStatus() {
if (rollStatus == RollStatus.ROLL_TWICE) {
status = FrameStatus.FINISHED;
scoreStatus = ScoreStatus.FINAL;
}
if (score != IConstants.PIN_PER_FRAME) {
return;
}
if (rollStatus == RollStatus.ROLL_ONCE) {
status = FrameStatus.STRIKE;
scoreStatus = ScoreStatus.NEX... |
6432424f-957e-4f10-ab84-1401acb1f21c | 3 | @Override
public String toString() {
String result = "\n\t\t\t\t\t\t<fe name=\""+ StringEscapeUtils.escapeXml(getName())+"\">";
for(String idref: getIdrefs()){
result += "\n\t\t\t\t\t\t\t<fenode idref=\""+idref+"\"";
if(probabilities.containsKey(idref)){
result += " probability=\""+probabilities.get(idre... |
ef71c2f4-034b-44ca-960f-fc4c6737e179 | 2 | public char getEpochType() {
switch (cbxEpoch.getSelectedIndex()) {
case 0:
return 'J';
case 1:
return 'B';
default:
return '?';
}
} |
e188c07b-28ca-4373-a83f-6297244dcc4d | 8 | public void add(Force f){
double myX = this.getX();
double hisX = f.getX();
double myY = this.getY();
double hisY = f.getY();
double newX = myX + hisX;
double newY = myY + hisY;
this.magnitude = Math.pow(Math.pow(newX, 2) + Math.pow(newY, 2), 0.5);
if(newX==0){
if(newY>0){
direction = ... |
d816fce8-d556-434b-a0f4-9baa60d35804 | 8 | private void wakeupParallel(List<RobotPeer> robotsAtRandom) {
for (RobotPeer robotPeer : robotsAtRandom) {
if (robotPeer.isRunning()) {
// This call blocks until the robot's thread actually wakes up.
robotPeer.waitWakeup();
}
}
for (RobotPeer robotPeer : robotsAtRandom) {
if (robotPeer.isRunning(... |
09084dbc-6756-4019-bae8-796eaeaf367f | 2 | public static void main(String[] args) {
Random rand = new Random(47);
float f[] = new float[10];
for(int i = 0; i < 10; i++)
f[i] = rand.nextFloat();
for(float x : f)
System.out.println(x);
} |
41085355-1dd6-41c7-99a5-e72b4f2ee828 | 3 | private void addConsoleAppender(String appenderName, String level) {
if ((config.getLoggerName() == null) || (config.getLoggerName().equals("log4j"))) {
ConsoleAppender consoleAppndr = (ConsoleAppender)Logger.getRootLogger().getAppender(appenderName);
if (consoleAppndr == null) {
consoleAppndr =... |
aae54bbe-94bc-4824-9e26-34af750ed1e8 | 1 | private boolean isBecomeReady() {
boolean wasReady = ready;
ready = isReady();
return (!wasReady && ready);
} |
0b5f865c-46b6-4562-9084-1fa9416399b8 | 1 | public Textures() {
try {
slate = ImageIO.read(this.getClass().getResource("textures/slate.png"));
java = ImageIO.read(this.getClass().getResource("textures/java.png"));
pane = ImageIO.read(this.getClass().getResource("textures/pane.png"));
} catch (IOException e) {
... |
d0a20750-d1f1-4f57-abd2-b5b4d7bcd266 | 8 | private void generateWall() {
int wallX = (minX + maxX) / 2;
Location wallStart = new Location(spawnWorld, wallX, 0, minZ);
Location wallEnd = new Location(spawnWorld, wallX, spawnWorld.getMaxHeight(), maxZ);
int startX = wallStart.getBlockX();
int endX = wallEnd.getBlockX();
int startZ = wallStart.getBlock... |
4d9e35fb-6492-48ec-96ef-7bc7173f3b53 | 5 | @Override
public final void run() {
final List<MidiInstrumentDropTarget> targetList = new ArrayList<>();
class LoadedMapEntry implements DndPluginCaller.LoadedMapEntry {
private boolean error;
private MidiInstrumentDropTarget activeInstrument;
@Override
public final void addEntry(final String strin... |
7e49a91f-50af-4aa1-a71a-de4775d340e1 | 7 | public void dumpRegion() {
File result = new File(GeoGonv.OUT_DIR, region.toString() + ".l2j");
try {
result.createNewFile();
} catch (IOException e) {
e.printStackTrace();
System.out.println("Can't create file: " + result.getAbsoluteFile());
return;
}
FileOutputStream outputStream;
try {
... |
2569e846-90c7-415e-9b48-50af3f7fe4a7 | 5 | @Override
public Widget asWidget() {
if (fp == null) {
final Storage storage = Storage.getLocalStorageIfSupported();
if (storage == null) {
new MessageBox("Not Supported", "Your browser doesn't appear to supprt HTML5 localStorage").show();
return new ... |
c6060f2e-cf2d-4587-b6c5-9e0f5d7dd10c | 7 | public void drawWindow() {
parent.stroke(0);
parent.fill(100);
parent.rect(posX, posY, 540.0f, (float) (screenHeight - posY));
/*
* Draws the transition from no settings menu to fully up Logic for
* transition is in this first if the else handles drawing everything
* post animation
*/
if (posY >=... |
cd7447ce-6276-4650-af32-72b850de9c58 | 2 | public boolean executeMove(Board board) {
boolean success = false;
int h = Util.firstEmptyPosition(board, this.getCol());
//Check whether column is valid
if (!Util.isColumnValid(board, this.getCol())) {
success = false;
}
else {
if (h < Util.ERRORTHRESHOLD) { // if the column is full I move all the ... |
0253ab02-b286-4484-bc98-e52c6527c4ea | 4 | public boolean addNode(int destval,ArrayList<Edge> edges){
Node dest=new Node(destval);
boolean result=false;
if(edges!=null){
java.util.Iterator<Edge> it=edges.iterator();
while(it.hasNext()){
boolean temp=nodes.contains(it.next());
if(temp){
result=true;
break;
... |
f7ab69a1-ad16-4978-b133-51d4bc96dcf9 | 3 | private static String getFormattedValueName(int value) { // intToKOrMilLongName
String dest = String.valueOf(value);
for (int i = dest.length() - 3; i > 0; i -= 3) {
dest = dest.substring(0, i) + "," + dest.substring(i);
}
if (dest.length() > 8) {
dest = "@gre@" +... |
af04f9f1-80a7-4a55-bfee-de0f18614e88 | 6 | private boolean checkLine(List<TreeNode> line, TreeNode root) {
int low = 0;
int high = line.size() - 1;
if(high == 0 && line.get(0) != root) {
return false;
}
if(high > 0 && high % 2 == 0) return false; //odd nodes can not be symmetric in tree
while(low < hig... |
69c32162-0a87-4fc2-b608-bf3d6db18502 | 0 | public static byte[] convertUnsignedIntTo32bits(long i) {
byte[] b=new byte[4];
b[0]=(byte)(((int)(i>>24))&0xFF);
b[1]=(byte)(((int)(i>>16))&0xFF);
b[2]=(byte)(((int)(i>>8))&0xFF);
b[3]=(byte)(((int)(i))&0xFF);
return b;
} |
36e77a66-bf5f-4b2e-8307-13b2d30a376f | 1 | public V put(K key, V value) {
V oldvalue = get(key);
if (oldvalue != null) {
values[currentIndex] = value;
return oldvalue;
}
checkEnoughCapacity(1);
keys[currentSize] = key;
values[currentSize] = value;
currentSize++;
return null;... |
4f05964c-9e0d-4005-9301-14d406fe9cd5 | 0 | public void setUsername(String username) {
this.username = username;
} |
9403be7c-5730-409a-b3a1-3566e564bc64 | 5 | public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page ... |
a149c313-f89b-4c53-8897-7082d811389e | 3 | public void setExp(PExp node)
{
if(this._exp_ != null)
{
this._exp_.parent(null);
}
if(node != null)
{
if(node.parent() != null)
{
node.parent().removeChild(node);
}
node.parent(this);
}
... |
98b8bcd0-24dc-466f-8160-d44126a8e4b8 | 9 | public static String makeRuleOriginExplanationPhrase(Justification self) {
{ Proposition satellite = self.proposition;
Proposition master = ((Proposition)(KeyValueList.dynamicSlotValue(satellite.dynamicSlots, Logic.SYM_LOGIC_MASTER_PROPOSITION, null)));
Description head = ((Description)((satellite.argum... |
1edf1077-6b0b-4068-819b-7c38bdf1c586 | 6 | public final void handleSentence(String sender, Sentence s) {
String subject = null;
String[] sList = s.getText().split("[\\.\\?\\!\\(\\)\\:]");
List<Sentence> dummy = new ArrayList<Sentence>();
boolean sent = false;
for(String sl : sList) {
if(sl.startsW... |
b64549d7-a267-4f21-813a-3014863fd501 | 5 | private void fillOrders(List<Order> orders, AbstractDao dao) throws DaoException {
if (orders != null) {
for (Order order : orders) {
Criteria tourCrit = new Criteria();
tourCrit.addParam(DAO_ID_TOUR, order.getTour().getIdTour());
tourCrit.addParam(DAO... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.