method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
eb9a5f93-6156-44f4-bc29-135f1a1ee7b5 | 6 | public void addSelectedRecipesToPanel(ArrayList<Recipe> selectedRecipes) {
if(currentRecipes.size() > 0) {
currentRecipes.clear();
currentLabels.clear();
}
for(int i = 0; i < selectedRecipes.size(); i++) {
currentRecipes.add(selectedRecipes.get(i));
}
for(int i = 0; i <currentRecipes.size();i++) {... |
a2aee02b-191c-4f7d-8796-8162a6386c5d | 2 | public static void main(String[] args) {
String[] array = new String[10];
for (int i = 0; i < array.length; i++) {
array[i] = "In Array";
}
Scanner in = new Scanner(System.in);
int index = in.nextInt();
try {
System.out.println(array[index]);
} catch (ArrayIndexOutOfB... |
1d4ac4b1-33ad-4afe-919e-9f85b0efcafa | 3 | public URI build(Object ...objs) throws UriBuilderException {
String raw = uriBuilder.toString();
for (Object obj : objs) {
raw = raw.replaceFirst("\\{[\\w]+}",
(obj == null) ? "" : obj.toString());
}
String uri = raw + queryParamsBuilder.toString();
... |
f481b2ef-56b5-4c6d-9b80-3fed85501506 | 6 | public float stressPenalty() {
if (stressCache != -1) return stressCache ;
if (! organic()) return stressCache = 0 ;
float sumDisease = 0 ;
for (Trait t : Abilities.TREATABLE_CONDITIONS) {
sumDisease += ((Condition) t).virulence * actor.traits.traitLevel(t) ;
}
float sum = Visit.clamp... |
b5875443-ec58-4a79-9495-d3865838a0f8 | 9 | public byte[] getCoverData() throws JmdbException {
// parse cover URI
this.getCover();
// no cover awaillable
if (this.cover == null) {
return null;
}
// Cover data already awaillable
if (this.coverData != null) {
return (byte[]) this.co... |
c5a32774-b6e1-4091-b061-1b3ea901dcec | 1 | private double bowl_expectation() {
// calculate the expectation for the remaining bowls
double ret = 0;
double sum = 0;
for (int i = 0; i < pref.length; i++) {
ret += (double)(pref[i]) * estimated_remainging_distribution[i];
sum += estimated_remainging_distributi... |
a935e765-fd6a-42e0-82d1-a2ff3ccd70c2 | 0 | public Piece getPiece()
{
return piece;
} |
a55e8ccd-7318-4fa9-9633-400cc8a88014 | 7 | private void move() {
if (!arrived) {
if (Point2D.distance(tileX, tileY, path.peek().getX(), path.peek().getY()) < speed) {
nextTile();
if (arrived) {
return;
}
}
if (angle != targetAngle) {
t... |
daaaa110-1ea7-4b87-a307-adf4ed017a74 | 8 | public String convert(String s, int numRows) {
if(s.isEmpty()) {
return "";
}
if(s.length() <= numRows) {
return s;
}
if(numRows == 1) {
return s;
}
StringBuilder sb = new StringBuilder(s.length());
for(int i = 0; i < ... |
1393ccc2-92ee-4f4f-9556-bd4b90c20e36 | 6 | public void collision(CollisionEvent e) {
/**
* Make sure that something collided with the ground and that this
* was an actual entity (and not the camera or whatever).
*/
if (e.getType()==CollisionEvent.TYPE_TARGET && e.getSource()!=null) {
Object obj=e.getSource();
/... |
76f899a2-44ce-47bd-84c8-2cf73984a5df | 5 | private static LinkedList createResources(BufferedReader buf,
LinkedList routerList, LinkedList files) throws Exception {
String line;
String routerName;
String resourceName;
String regionalRC;
double storage_size;
double bandwidth;
DataGridResource r1;
... |
4d7c7947-e8e2-4ce8-9c6e-bfaa2c2cefa6 | 2 | public void enqueue(Item item) {
if (item == null)
throw new NullPointerException();
if (isEmpty())
addFirst(item);
else {
Node<Item> node = new Node<Item>();
node.item = item;
node.prev = last;
last.next = node;
... |
ca669b2a-95f0-47a3-bc55-bf457e4bbfb4 | 4 | public void start() {
GUI.controls.refresh();
startingTime = System.currentTimeMillis();
boolean start = false;
if (state == RunState.stopped) {
if (model.program.none()) {
Dialog.showMessage("No program to run");
return;
}
... |
f6f3e71f-3c35-435b-9df0-eb1c654bd21d | 6 | public int loadStream(InputStream is) throws IOException {
int entries = 0;
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line, last = " ";
LinkedList<String> resp = new LinkedList<String>();
while ((line = br.readLine()) != null) {
if (line.isEmpty())
continue;
if (line... |
fd6eab14-34fb-4e8a-81bf-58e4cd3d5fc7 | 7 | private static boolean matchesAttributeValue(
final MarkupSelectorItem.AttributeCondition.Operator attrOperator,
final String attrValue,
final char[] elementAttrValueBuffer, final int elementAttrValueOffset, final int elementAttrValueLen) {
switch (attrOperator) {
... |
251b3834-b27f-4510-833c-aeb812e50ac6 | 4 | @Override
public boolean containsDoubleArray(String name) {
JOSObject<? , ?> raw = this.getObject(name);
if(raw == null) return false;
if(raw.getName().equalsIgnoreCase(DOUBLE_ARRAY_NAME)) return true;
return false;
} |
3fa50efd-0da0-4829-b713-a861ca2576cb | 9 | private boolean merge(int[] line) {
int n = line.length;
int cur = 0;
int hand = -1;
int zeroTail = 0;
for (int i = n - 1; i >= 0; i--) {
if (line[i] == 0)
zeroTail++;
else
break;
}
... |
06900491-1dd5-4cd9-bec5-792819db4e8c | 9 | public static void main(String[] args){
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int [] a = new int[7];
for(int i = 0 ; i < 7 ; i++)
a[i]=in.nextByte();
if (!((a[4]==(a[1]+a[2]+a[3])%2)&&(a[5]==(a[0]+a[2]+a[3])%2)&&(a[6]==(a[... |
07604f90-eeda-4834-9535-6ef57c6e0d36 | 1 | public final Image image(JPanel panel) {
Image image = panel.getToolkit().createImage(ClassLoader.getSystemResource(url));
MediaTracker tracker = new MediaTracker(panel);
tracker.addImage(image, 1, width, height);
try {
tracker.waitForAll();
} catch (InterruptedException e) {
throw new RuntimeException(... |
f02956bd-92e2-4e43-857a-ed45e017884e | 2 | @Override
public boolean addAll(Collection<? extends E> c)
{
boolean added = false;
for (E e : c) {
added |= add(e);
}
return added;
} |
348e0c02-d644-43a0-a23e-9f02e4a2731b | 3 | public void upload() throws Exception {
ArrayList<File> files = FileFinder.find(localDir);
Logger.printf("===== [%d] files foud ========\n", files.size());
Collection<Task> tasks = new ArrayList<Task>();
int index = 1;
for(File file :files) {
tasks.add(new Task(new... |
dd590d67-be2b-4110-afa2-986ea78cecbb | 3 | public static void main(String[] args) {
Move black[] = new Move[10];
Move white[] = new Move[10];
Move[] wPoss;
Move[] bPoss;
black[0] = new Move(1, 0);
black[1] = new Move(3, 0);
black[2] = new Move(5, 2);
black[3] = new Move(6, 2);
black[4] = new Move(3, 3);
black[5] = new Move(3, 4);
... |
70079c36-2cca-47be-aaa5-6dae8b38f8a9 | 9 | public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_LEFT) {
leftPressed = true;
}if (e.getKeyCode() == KeyEvent.VK_A) {
leftPressed = true;
}
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
rightPressed = true;
}if (e.getKeyCode() == KeyEvent.VK_D) {
rightPressed = true;
}
if (e.... |
11a9b421-85ea-4eb8-9d77-b5cc2947fdbe | 3 | @Override
public JsonElement serialize(RoleSchool t, Type type, JsonSerializationContext jsc) {
final JsonObject jsonObject = new JsonObject();
if(t instanceof Student){
Student student = (Student) t;
jsonObject.addProperty("semester", student.getSemester());
... |
7768365b-f48e-4f6d-bf38-ce6c5844faf4 | 0 | public ArrayList<String> getEspTitle() {
return espTitle;
} |
8703c809-ce16-41c1-b4ad-adc0bce7575f | 2 | public Display getDisplayFromString(String name)
{
for (Display display : displays)
{
if(display.getLabel() == name)
{
return display;
}
}
Log.warn("No display matched given string!");
return null;
} |
9667db93-a623-4c09-bb19-ab8499a113fb | 4 | public static boolean printPos(String name) {
if(name == null) {
JFileChooser fc = new JFileChooser(AppConfig.getAppConfig().getLastSelectedFileDirectory());
fc.setDialogTitle("Select destination file");
SingleFileFilter posFf = new PositionFileFilter();
fc.setFileFilter(posFf);
if(fc.showSaveDialog(To... |
3521c530-dc96-4e26-a4c5-21ac4295eb6c | 7 | public void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
String error = "";
// See if the category exists in the database
try {
String query;
int i = 0;
if ((query = (String)req.getParameter("id")) != null) {
i = Integer.parseInt(query);
}
if (... |
475e6018-6332-4700-8f0d-8bd6e0170b8b | 1 | public static double[] getVecOfRow( double[][] mat, int i )
{
int n = mat[0].length;
double[] res = new double[n];
for ( int j = 0; j < n; ++j )
res[j] = mat[i][j];
return(res);
} |
be171585-dc81-4928-b5ed-fcdb31143cc0 | 8 | public void traverse(ObjectVisitor visitor, Object root) {
Stack stack = new Stack();
stack.put(root);
shouldFollow(root);
while (!stack.empty()) {
Object obj = stack.pop();
ClassInfo info = getClassInfo(obj);
if (visitor.visit(info, obj)) {
if (info.isArray) {
int le... |
4340d352-a240-4fa5-99da-fe74de81ad36 | 7 | @Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
{
if(label.equalsIgnoreCase("entitykill") && sender.isOp())
{
if(args.length == 3)
{
World world = Bukkit.getServer().getWorld(args[0]);
if(world == null)
{
sender.sendMessage("That world do... |
78e0c2fe-bd82-4967-b17f-9f26553afc5a | 4 | @Override
protected List<Item> get() {
List<Item> items = new LinkedList<Item>();
final Component[] children = ctx.widgets.component(WIDGET_INTERFACE_MAIN, WIDGET_INTERFACE_MAIN_ITEMS).components();
if (children != null && children.length > 0) {
for (Component child : children) {
if (child.itemId() != -1... |
b687ed9f-a5f7-4b3e-a6f9-efcde043d79e | 6 | public void resetGame() {
for (int p = 0; p < 2; p++) {
for (int i = 0; i < 11; i++) {
this.game.players[p].hand.cards()[i] = new Card(true);
if (p == 0 && i < this.game.dcindex) {
dp.remove(this.game.dealercards[i]);
} else if(p == 1 && i < this.game.pcindex) {
hp.remove(this.game.playercard... |
9f58ad07-a3ae-49c1-86ee-31d4197e7a97 | 2 | private static void encodeHandShakeStart (ByteBuffer buffer, HandShakeStart msg) {
// Protocol
buffer.put((byte) msg.getProtocolName().length());
buffer.put(msg.getProtocolName().getBytes(ISO_8859_1));
// Reserved Bits
byte[] bits = new byte[8];
BitSet flags = msg.getFla... |
fb754178-d188-4183-9869-2b90dd025ba6 | 8 | private DefaultMutableTreeNode listaSentencias(DefaultMutableTreeNode padre) {
DefaultMutableTreeNode nuevoHijo;
while (!(match (Token.TipoToken.RIGHT_CURLY) || match (Token.TipoToken.END)
|| match (Token.TipoToken.UNTIL) || match (Token.TipoToken.ELSE)
|| match ... |
b8007933-8cd9-48ca-88c9-650e3cfbd27f | 3 | private static void calcNoOfNodes(Node node) {
if (node instanceof Parent) {
if (((Parent) node).getChildrenUnmodifiable().size() != 0) {
ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable();
noOfNodes += tempChildren.size();
f... |
c5af1e81-2bed-4f94-93e8-f45506a8b48a | 4 | private void findConnection(int from, int curr, int []conds){
List<Connection> connections = Application.mediator.automatonTable.connections;
int [][] trans = Application.mediator.matrix.transitions;
for (int i = 0; i < trans[curr].length; i++) {
if(trans[curr][i] > 0){
... |
568f67c5-7296-447b-bfd9-ac63b9505b2b | 4 | int divideHelper(int a, int b) {
int base = 1;
while (a <= b << 1 && b << 1 < 0) {
b <<= 1;
base <<= 1;
}
int result = 0;
while (base != 0) {
if (a <= b) {
a = a - b;
result += base;
}
b... |
3bd520a0-9f0a-4958-91e7-7501fdb75a49 | 4 | private String descDuty(Actor a) {
final Background v = a.vocation() ;
final String VN = v == null ? a.species().toString() : v.nameFor(a) ;
if (a.mind.home() == this) return "(Resident "+VN+")" ;
if (a.mind.work() != this) return "(Visiting "+VN+")" ;
final String duty = personnel.onShift(a) ? "On-... |
3e3fddf9-6826-41fc-932f-683462cf345b | 2 | private int getColumnHeaderWidth(int column)
{
if (! isColumnHeaderIncluded) return 0;
TableColumn tableColumn = table.getColumnModel().getColumn(column);
Object value = tableColumn.getHeaderValue();
TableCellRenderer renderer = tableColumn.getHeaderRenderer();
if (renderer == null)
{
renderer = table... |
09f169d9-ac7c-4fd3-9ae1-79514a1bb2dc | 6 | public int compareTo(ReinforcementKey rk2) {
ReinforcementKey rk1 = this;
if( rk1.x < rk2.x ){
return -1;
}else if( rk1.x > rk2.x ){
return 1;
}else if( rk1.y < rk2.y ){
return -1;
}else if( rk1.y > rk2.y ){
return 1;
}else if( rk1.z < rk2.z ){
return -1... |
90066d5f-e28b-46d7-94dc-53c29a02a73f | 6 | final boolean containsChild(String archiveName, String childName) {
try {
anInt668++;
if (!isInitialized())
return false;
archiveName = archiveName.toLowerCase();
childName = childName.toLowerCase();
int archiveId = indexTable.archiveHashTable.get(Class281.getArchiveHash(archiveName));
... |
f668094d-54ba-4392-a371-c811017ea276 | 1 | public boolean EliminarPunto(Punto p){
if (p!=null) {
cx.Eliminar(p);
return true;
}else {
return false;
}
} |
24638379-ed62-4553-8be8-cdd5ec3e37c8 | 3 | public void setNotConstant() {
if (notConstant)
return;
notConstant = true;
if (fieldListeners == null)
return;
for (Iterator i = fieldListeners.iterator(); i.hasNext();)
Main.getClassBundle().analyzeIdentifier((Identifier) i.next());
fieldListeners = null;
} |
b4e18266-b9c6-480b-a58d-96bd04687752 | 9 | @Override
public boolean validMove(int x, int y) {
//can only move one in each direction
if(!inBounds(x, y)){
return false;
}
//also need to look for check or check mate...
if(this.x+1 == x && this.y+1 == y){
return true;
}
if(this.x+1 == x && this.y-1 == y){
return true;
}
if(this.x-1 == x ... |
ff6ee004-f05c-469c-8515-0d8df5466687 | 7 | public GrafoTabla AnalisarArchivo(){
numRequisitos=0;
GrafoTabla Grafo = new GrafoTabla();
ArrayList<Requerimiento> LReqAux = new ArrayList();
ArrayList<Camion> LCamAux = new ArrayList();
String Line = this.readLine();
Line = Line.replaceAll(" ", " ");
Line = Line... |
6c4a17cc-e387-4541-a164-290fa5d4ceba | 1 | public NotEnoughBytesException(int numBytes) {
super("Packet construction requires minimum of " + Packet.HEADER_SIZE + " bytes. Only " + numBytes + (numBytes == 1 ? " byte" : " bytes") + " given.");
} |
6f013425-1db9-40c9-8842-c8873439b085 | 0 | public int getResourceID() {
return this.resourceID;
} |
e6cb7455-b511-4426-805a-23db7b24af33 | 8 | public static <E> E updateExposed(E original, E updated)
{
// Check for annotation
if(original.getClass().getAnnotation(Updatable.class) == null)
return original;
// Iterate through parental structure
Class<?> clazz = original.getClass();
do
{
// Iterate through fields
for(Field field : clazz.g... |
2a1a2975-1ccd-428a-97dc-03d1c40b2d39 | 9 | public static boolean checkLength(long length, WSDLColType colType) {
switch (colType) {
case DESCRIPTION:
if (length < 10000) {
return true;
} else {
return false;
}
case TITLE:
if (l... |
36d7b10d-8c8c-4731-a4ed-83d4da94a828 | 9 | public void loadBoardConfig(){
try{
FileReader reader = new FileReader(layout);
Scanner scn = new Scanner(reader);
while(scn.hasNextLine()) {
String line[] = scn.nextLine().split(",");
int columnCount = 0;
for(String cell : line) {
if(cell.equalsIgnoreCase("f")) {
cells.add(new Fi... |
23c59862-e569-494f-a39e-1a77b0100a48 | 8 | public int longestConsecutive(int[] num) {
HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
for (int i = 0; i < num.length; i++) {
if (map.containsKey(num[i]))
continue;
map.put(num[i], 1);
if (map.containsKey(num[i] + 1) && map.containsKey(num[i] - 1)) {
int longest = map.get(num... |
0013b127-91e4-4b9d-ad3c-7797a2dd47d5 | 5 | public void Eat(BaseObject target)
{
if ( job_time_sec == 0 )
{
int woter = target.GetMatCountByType(Enums.GMaterials.Woter);
if (woter > 0)
{
target.RemoveMaterial(Enums.GMaterials.Woter, woter);
if (woter + GetMatCountByType(En... |
59bab613-b5b4-4531-a0f3-067f66d5db38 | 4 | private void init() {
for(int i = 0; i < 20; i++) {
double x = (random.nextDouble() * 256 + 20) * 5;
double y = (random.nextDouble() * 256 - 10) * 5;
addMines(x,y);
}
for(int i = 0; i < 140; i++) {
double x = (random.nextDouble() * 256 + 20) * 5;
double y = (random.nextDouble() * 256 - 10) * 5;
... |
017f5f05-ec11-42c1-842e-ddb5880f9ad7 | 0 | public void done()
{
updateUploadInfo("done");
} |
1a0b4403-f668-4b4f-8add-98a5e5befa5b | 9 | public String command(CommandSender sender, Command command, String[] args) {
if (args.length < 1)
return plugin.getString(Language.PARDON_ARGUMENTS);
String admin = Ultrabans.DEFAULT_ADMIN;
if (sender instanceof Player)
admin = sender.getName();
String name = For... |
1ca32b81-5f21-4c2b-a663-6133632adc7a | 6 | @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Dependency)) {
return false;
}
Dependency other = (Dependency) obj;
if (groupId.equals(other.getGroupId())
&& (artifactId.equals(other.getArtifactId()))
&& (version.equals(other.getVersion()... |
a285dbf1-0644-4a41-b1b0-367921302f5a | 0 | @Basic
@Column(name = "PCA_CANTIDAD")
public Integer getPcaCantidad() {
return pcaCantidad;
} |
0e7f17cb-52c9-4fc3-8d82-7158caed0741 | 1 | public void update(GameContainer gc, StateBasedGame arg1, int delta)
throws SlickException {
super.update(gc, arg1, delta);
controlledBird.update(gc, delta);
for(Bird bird : birds) {
bird.getBehavior().target = controlledBird.position;
bird.update(gc, delta);
}
} |
068664b7-e88b-46bb-a058-ea357236f11d | 6 | static String filterGetallenReeks(String reeks) {
for(int i = 0; i < reeks.length(); i++) {
char temp = reeks.charAt(i);
String temp2 = Character.toString(temp);
if(reeks.charAt(i) > 31 && reeks.charAt(i) < 48)
reeks = reeks.replace(temp2," ");
else if(reeks.charAt(i) > 57 && reeks.charAt(i) < 127)
... |
75f89753-8a9b-434b-b127-3b2d8591d1d4 | 1 | private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
if(tabla.getSelectedRow()==-1){
JOptionPane.showMessageDialog(null, "No hay cliente seleccionado.");
}else{
this.verDatos();
ver.setVisible(true);
... |
dad66769-ce5d-481e-9a8d-8e6467f38d91 | 0 | public int size() {
return size;
} |
d8c9e0eb-27cf-4aae-9886-7b12a05ebb85 | 6 | public boolean hasUpdate(PluginUpdateInfo pui) throws IOException, MalformedURLException {
if (pattenComparerSystem == Comparer.VERSION_WEBSITE_COMPARE) {
DevBukkitSite dbs = new DevBukkitSite(pui, pui.URL);
dbs.download();
DevBukkitFile[] files = dbs.getFileTargets();
Pattern verParser = Pattern.compile(... |
8a003f2c-522a-4151-ab02-377ce4192775 | 2 | public static BufferedImage getSingleImage(String path) {
try{
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream input = classLoader.getResourceAsStream(path);
BufferedImage image = ImageIO.read(input);
if(image != null) {
return image;
}
}catch (IOException e)... |
40267fd9-428a-4252-9ed2-c6b22cb22567 | 4 | public void addImageAssets(
String baseAssetName, URL imageName, int numAssetsWide, int numAssetsHigh) {
BufferedImage baseImage = assetLoader.loadImage(imageName);
double imageWidth = (double) baseImage.getWidth() / (double) numAssetsWide;
double imageHeight = (double) baseI... |
27a8d44a-9170-432e-9c80-f44e5e1525fa | 3 | public static ShortImageBuffer threshold(ShortImageBuffer input, int threshold)
{
ShortImageBuffer after = input.copyShape();
for(int y=0;y<input.getHeight();y++)
{
for(int x=0;x<input.getWidth();x++)
{
int v = input.get(y, x) & 0xFFFF;
... |
2597cf1b-9e64-4e01-815a-c9b53ec9b0d7 | 2 | private String initSet(String line){
Matcher m = P.matcher(line);
if (m.find()) {
do{
String key = m.group(1);
set.add(key);
line = m.replaceFirst(key);
engine.put(key, null);
} while (m.reset(line).find());
... |
139942fe-dc03-4d1d-bb90-49e7508deeb9 | 0 | public void set(K key, V value) {
List<V> values = new LinkedList<V>();
values.add(value);
this.map.put(key, values);
} |
1440d776-eb8a-4af8-9b50-a3b6030c0573 | 5 | @Override
public void doAction(Model model) {
if(model instanceof HyeneModel){
HyeneModel hmod = (HyeneModel) model;
HyenePlayer p = (HyenePlayer) hmod.m_current_player;
int PlayerPosition = -1;
int k = -1;
while(PlayerPosition == -1){
k++;
PlayerPosition = hmod.findElement(k,p.token);
}
... |
c3e6cc43-c22c-4c07-b255-3b3d3a3ffc94 | 1 | public static Clip loadAudio(String fileName)
{
Clip clip = null;
try
{
AudioInputStream stream = AudioSystem.getAudioInputStream(new File("./res/audio/" + fileName));
clip = (Clip) AudioSystem.getLine(new DataLine.Info(Clip.class, stream.getFormat()));
clip.open(stream);
return clip;... |
0d7a2ab0-62cb-4c26-9d62-387e9fc87917 | 1 | private static String extractPlayerInformation(String playerId) {
String playerInfo = "";
String playerDisplayName[] = null, siteUrl[] = null, userEmail[] = null, pointsAll[] = null;
String storingPlayerJson = null;
try {
JSONObject json = readJsonFromUrl("http://sandbox.badgeville.com/api/berlin/17744f9bf6f... |
82a3a046-a4ef-4e48-800f-c57b506ed9d1 | 5 | public static void getFilmeFuerSaalMitZeiten(Saal k) {
int zaehler1 = 0;
for (int j = 0; j < filme.length; j++) {
if ((filme[j].getSaal()).equals(k.getName())) {
zaehler1++;
}
}
Film[] tmp = new Film[zaehler1];
int zaehler2 = 0;
for (int i = 0; i < filme.length; i++) {
if (filme[i].getSaal().eq... |
fe28b8cc-4b59-4353-b9c5-45bbaadcb9a4 | 5 | int next(int[] num, int l, int r, boolean isLeft) { // 找到不重复的下一个数
if (isLeft) {
int i = l + 1;
while (i < r && num[i] == num[l]) {
i++;
}
return i;
} else {
int i = r - 1;
while (i > l && num[i] == num[r]) {
i--;
}
return i;
}
} |
08acf52d-efd5-4414-908e-ca2e4f3ed498 | 1 | public static boolean isPrime(int n) {
if (n > max) {
genPrime(n);
}
return bitmap[n];
} |
5d4c13d1-b532-4426-bab6-2b18d75f6833 | 3 | public synchronized Message getMostRecentMessage() {
Message res = null;
for(Message it : waitQueue) {
if (res == null || it.getSendTime() < res.getSendTime())
res = it;
}
return res;
} |
1b55e568-e634-43ef-ac17-f539fe425388 | 0 | @Override
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
return new MyWorkerThread(pool);
} |
de899227-f796-4988-9b63-ecd17f0c4725 | 6 | private static Image getImage(String filename) {
// to read from file
ImageIcon icon = new ImageIcon(filename);
// try to read from URL
if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) {
try {
URL url = new URL(filename);
... |
0316c413-7c0f-43be-8d2e-9f2b5cacc715 | 7 | @Override
public void write(File file, List<ComicImage> images) throws IOException {
PDDocument document = new PDDocument();
for (ComicImage image : images) {
//Make each page exactly the same size as the image
PDPage page = new PDPage(new PDRectangle(image.getWidth(), image.getHeight()));
document.addPa... |
7cd2afb0-cd15-4c85-878d-ff8fd79a96f9 | 9 | public static int getExpressionLocByLocation( String loc, Stack expression ) throws FormulaNotFoundException
{
for( int i = 0; i < expression.size(); i++ )
{
Object o = expression.elementAt( i );
if( o == null )
{
throw new FormulaNotFoundException( "Couldn't get Ptg at: " + loc );
}
if( o inst... |
7fbec902-dd98-4f28-8cc1-c8713cfbb359 | 0 | public void test(final int idPeople, final String email){
getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query query = session.createQuery(
"update PhpposPeopleEnt... |
360a23a6-33b8-41da-b31d-6ef6319f6bac | 6 | public void loadPreferences() {
if (!lastUserFile.exists()) {
// Prompt for a username
String message = "It looks like it's the first time this program has been used.\nEnter your user name:";
String username = JOptionPane.showInputDialog(message);
try {
... |
04a1d14e-4252-4c66-bdc0-3b81a2c5b8ca | 7 | public static final void load_config(String path) {
Properties config = new Properties();
FileInputStream fis = null;
try {
fis = new FileInputStream(path);
config.load(fis);
} catch (Exception e ) {
System.err.println("Error loading configuration file: " + path + "\n" + e.toString());
System.exit(-... |
805c66ee-91c3-4952-8b98-b76b7b191ebd | 1 | public void setAngle( TextAngleStrategy angle ) {
if( angle == null ) {
throw new IllegalArgumentException( "angle must not be null" );
}
this.angle = angle;
regraph();
} |
63b5382e-16b4-4f85-9e44-fe691749e939 | 1 | public void register(Class<?> packetClass,PacketHandler handler){
registered.add(packetClass);
handlers.add(handler);
} |
850a2c0c-843d-4c2a-b4fa-b6ed5a202742 | 0 | @Override
public int compare(T o1, T o2) {
TKey k1 = keySelector.select(o1);
TKey k2 = keySelector.select(o2);
return innerComparator.compare(k1, k2);
} |
c1eaf622-98d6-4c1a-90bd-48efa4064d8a | 4 | private void sink(int k) {
while (2*k <= N) {
int j = 2*k;
if (j < N && greater(j, j+1)) j++;
if (!greater(k, j)) break;
exch(k, j);
k = j;
}
} |
29c10663-3976-444c-83f4-10b687d3810e | 9 | private void firstInsertion(int ndj,VertexPulse v){
int key = keyCalculator(ndj);
if(baseAproxBucket!=null){
int pos = posCalculator(key, baseAproxBucket.getKey());
if(highLevelBuckets[pos] != null){
highLevelBuckets[pos].insertVertexTime(v);
}
else{
AproxBucket theNewBucket = new AproxBucket(v,... |
54c260bb-e422-4de1-b97e-7db7017881ef | 4 | public static void main(String[] args) {
System.out.println("Question 4: Concordia");
for (int i = 1; i < 101; i++) {
boolean printI = true;
if (i % 3 == 0) {
System.out.print("Con");
printI = false;
}
if (i % 5 == 0) {
System.out.print("cordia");
printI = false;
}
if (printI)
... |
e58be507-1094-494a-b446-dceb383bd869 | 3 | public void writeFileContent(File file, long offset, VDK1FilePattern pattern) {
BufferedInputStream bis = null;
byte[] buffer = new byte[1024];
long shiftOffset = 0;
int i;
try {
bis = new BufferedInputStream(new FileInputStream(file));
while((i = bis.read(buffer)) != -1) {
seek(offse... |
0e3f4093-4de0-438c-bca1-9654ebac9a1f | 2 | @Override
public String execute() {
try {
if (databaseContext.provider.createTable(arguments.get(1), MySignature.getTypes(types)) != null) {
return "created";
} else {
error = "Table " + arguments.get(1) + " exists";
}
} catch (IOEx... |
8b81a807-37d6-47c4-989d-5fdab0c08501 | 0 | public void setjLabelPraticien(JLabel jLabelPraticien) {
this.jLabelPraticien = jLabelPraticien;
} |
9c522b1d-6449-411e-a480-1b20f3e111d6 | 2 | public void addHand(Hand hand, int MAX_HANDS) {
int empty = 0;
int i=0;
do {
if (this.hand[i].isEmpty()) {
empty = i;
log.debug("There's the hand that it was added in as" +i);
}
i++;
} while (!this.hand[i].isEmpty());
log.debug(hand+ "With the hand number at "+empty);
this.hand[empty] = han... |
ce285caf-3230-47a6-a176-07fdb2e736a9 | 6 | public void destroy(Integer id) throws IllegalOrphanException, NonexistentEntityException {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
AccessConfigUser accessConfigUser;
try {
accessConfigUser = em.... |
167a83fe-1ab8-4d61-9950-8125209ab54d | 6 | public List<HorseRaceStatus> results() {
if (lanesStatus == null || lanesStatus.isEmpty()) {
throw new IllegalStateException("Lanes should be configured, race should be initialized!");
}
List<HorseRaceStatus> lanes = new ArrayList<>();
lanes.addAll(lanesStatus.values());
... |
28048e42-e106-4f0f-b046-a77f98f66cda | 1 | private static void test2(){
Dealer dealer = new Dealer(17);
Player p = new Player(17);
System.out.println("Test 2");
System.out.println("Deals random cards to a player's hand and then shows the hand");
for (int i=10;i<16;i++)
{
p.addCardtoHand(dealer.DealCard());
}
System.out.println(p.stringHan... |
1ad2fe25-8d1b-4040-b8cf-3e2d1dfc592d | 9 | public boolean run() {
PrintStream original = System.out;
PrintStream noPrint = new PrintStream(new OutputStream() {
public void write(int b) {}
});
try {
Method m[] = this.getClass().getDeclaredMethods(); // Get all methods
for( Method i : m ) {
if( i.getName().startsWith("test... |
3da298f1-329e-4096-95cd-0f493d0bbe3c | 0 | public void setAcademicLevel(String academicLevel) {
AcademicLevel = academicLevel;
} |
6d91fd59-e0b6-434c-a85b-01442a5b32d2 | 3 | public UpdateFinDB(String Mode) throws IOException {
if (Mode.equals("Finviz")){
UpdateFinvizDB();
}else if(Mode.equals("Yahoo")){
UpdateYahooDB();
}else if(Mode.equals("All")){
UpdateFinvizDB();
UpdateYahooDB();
}
} |
8de2f3b5-bedf-4b03-afc7-7791fcd37350 | 1 | public void render() {
Renderer renderer = Renderer.instance();
renderer.clear();
renderer.pushMatrix();
camera.rotate();
camera.translate();
renderer.pushMatrix();
terrain.render(renderer);
for(int i = 0; i < decs.size(); i++) {
renderer.pushMatrix();
decs.get(i).render(renderer);
re... |
d8c6a3e0-a720-41a2-af60-e46cc2e2fd1f | 5 | protected boolean doStep() {
double minF2 = Double.MAX_VALUE;
Move10 bestMove = null;
boolean moveFound = false;
/* find the best move (lowest f2) */
Set<Move10> moves = generator.getMoves();
for (Move10 move : moves) {
double tmpF2 = f2ForMove(move);
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.