method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
0b78f613-ea7e-4f73-b12e-3f30e36bd1dc | 7 | private JSONWriter append(String string) throws JSONException {
if (string == null) {
throw new JSONException("Null pointer");
}
if (this.mode == 'o' || this.mode == 'a') {
try {
if (this.comma && this.mode == 'a') {
this.writer.write('... |
f70ca28f-4e68-4ef0-b6e5-128d94301be6 | 8 | protected void TrusteeMF() {
for (int iter = 1; iter <= numIters; iter++) {
loss = 0;
errs = 0;
// gradients of B, V, W
DenseMatrix BS = new DenseMatrix(numUsers, numFactors);
DenseMatrix WS = new DenseMatrix(numUsers, numFactors);
DenseMatrix VS = new DenseMatrix(numItems, numFactors);
// rate... |
f488772e-ce2c-4e83-bac0-70c5e8e53312 | 2 | public void union(int x, int y) {
if (x == y) {
return;
}
x = find(x);
y = find(y);
if (rank[x] < rank[y]) {
root[x] = y;
rank[y]++;
} else {
root[y] = x;
rank[x]++;
}
} |
985f12e1-a0cb-43c9-bf94-a92774ad781d | 3 | @Override
public boolean equals(Object o) {
if (this == o) { return true; }
if (o == null || this.getClass() != o.getClass()) { return false; }
Dictionary n = (Dictionary) o;
return dictionary.equals(n.dictionary);
} |
2a660d25-5b1b-4dee-9a21-b0f0508e1f70 | 4 | private void harvest(Level level, int x, int y) {
int age = level.getData(x, y);
int count = random.nextInt(2);
for (int i = 0; i < count; i++) {
level.add(new ItemEntity(new ResourceItem(Resource.seeds), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
}
count = 0;
if (age == 50) {
... |
79106aee-ba8b-4356-9528-1628bdd131ce | 2 | public void init(String url, String saveTo, boolean logging, boolean allowReadCache, boolean forceTagging) {
state = UIState.START;
textFieldDirectory.setText(saveTo);
chckbxLog.setSelected(logging);
chckbxUseCache.setSelected(allowReadCache);
chckbxForceTag.setSelected(forceTagging);
try {
rootPage = Ab... |
4babb697-782d-42a2-b309-5b518cc35979 | 3 | public static String toString(JSONObject jo) throws JSONException {
boolean b = false;
Iterator keys = jo.keys();
String string;
StringBuffer sb = new StringBuffer();
while (keys.hasNext()) {
string = keys.next().toString();
if (!jo.isNull(s... |
aab1920d-a157-4b53-abc6-6f828637784e | 3 | private static String join(final String[] args, final String delim) {
if (args == null || args.length == 0) return "";
final StringBuilder sb = new StringBuilder();
for (final String s : args) sb.append(s + delim);
sb.delete(sb.length() - delim.length(), sb.length());
return sb.... |
80fe0a8c-35d0-4f56-80af-dee9596cad7a | 2 | public Module getModuleByChain(List<String> chain) {
int index = 0, size = chain.size();
Module module = getRootModule();
while(null != module && index < size) {
module = module.getSubModule(chain.get(index++));
}
return module;
} |
96df5349-af45-4d9f-a600-bee9fbd078f4 | 6 | private Opcode toOpcode( byte opcode ) throws InvalidFrameException {
switch ( opcode ) {
case 0:
return Opcode.CONTINUOUS;
case 1:
return Opcode.TEXT;
case 2:
return Opcode.BINARY;
// 3-7 are not yet defined
case 8:
return Opcode.CLOSING;
case 9:
return Opcode.PING;
case 10:... |
ba513b11-5588-4211-be67-aabe93668322 | 6 | private void printSeries (int fizzNumber, int buzzNumber, int limit) {
for (int i = 1; i <= limit; i++) {
if (i % fizzNumber == 0 && i % buzzNumber == 0) {
System.out.print("FB");
} else if (i % fizzNumber == 0) {
System.out.print("F");
} else if (i % buzzNumber == 0) {
System.out.print("B");
... |
9caf38c0-1290-4928-8c64-e867003bcb01 | 3 | private boolean checkDuplicate(int vx, int vy){
for(int i=0; i<_X.size(); i++){
if(_X.get(i)==vx){
if(_Y.get(i)==vy){
return false;
}
}
}
return true;
} |
3c5c4b82-5378-4840-91bb-0339b684dd80 | 9 | private int readInteger(SeekableStream in) throws IOException {
int ret = 0;
boolean foundDigit = false;
int b;
while ((b = in.read()) != -1) {
char c = (char)b;
if (Character.isDigit(c)) {
ret = ret * 10 + Character.digit(c, 10);
... |
925efba6-e0b7-4a0c-9343-c5df90d13725 | 2 | RedisConstants()
{
String env = System.getenv(this.name());
if (env == null)
{
env = System.getProperty(this.name());
if (env == null)
{
throw new RuntimeException("Property:" + this.name() + " is not an env or property");
}
}
value = env;
} |
43618624-0a3e-418e-a76c-0100ea5c616a | 2 | private void advance() {
while (delegate.hasNext()) {
T element = delegate.next();
if (filter.accept(element)) {
next = element;
return;
}
}
next = null;
} |
97d96c48-6bf4-42ae-aaa1-b37e5dcf1f60 | 3 | public void removeDeadFlyUps() {
List<FlyUp> toDelete = new ArrayList<FlyUp>();
for(FlyUp fly:flyups) {
if(fly.timeSinceCreation() >= 3300) toDelete.add(fly);
}
for(FlyUp fly:toDelete) {
flyups.remove(fly);
}
} |
d763884b-a94e-455b-8d0c-c172e73d0962 | 8 | public void moveAll(String name, GameObject object) {
Chest c = null;
Avatar a = null;
String loc = null;
ArrayList<GameObject> shadowChest = new ArrayList<GameObject>();
for (Avatar v : avatarLocations.keySet()) {
if (v.getName().equals(name)) {
a = v;
loc = v.getLocationName();
}
}
for (G... |
802c09ab-4115-4f07-9f19-344fd4eb04c4 | 2 | protected ArrayList<Location> getMoveLocations()
{
ArrayList<Location> moveLocs = new ArrayList<Location>();
int facingDirection = getDirection();
Location loc = getLocation();
//Find and test all locations half left, in front, and half right of location of this
for(... |
7058118d-021d-4509-b0d8-73f27c243da0 | 7 | @Override
public void setEnvFlags(Environmental E, int f)
{
if(E instanceof Item)
{
final Item item=(Item)E;
// deprecated, but unfortunately, its here to stay.
CMLib.flags().setDroppable(item,CMath.bset(f,1));
CMLib.flags().setGettable(item,CMath.bset(f,2));
CMLib.flags().setReadable(item,CMath.bs... |
36796d68-452b-4ade-afe5-4dfdc1aa55a7 | 0 | public Unmark(int marker, int state) {
this.state = state;
this.marker = marker;
} |
9f77cec3-7f9f-45f7-a44c-5f7a0bb18b10 | 6 | public void dessineTousNoeud(Graphics g) {
// Si il n'y a pas d'itineraire d�fini, alors
// il n'y a pas de noeud
if (itineraire == null)
return;// ...donc on quitte
/*
* Cette liste contient toutes les adresse de livraison deja livre qui
* ne doivent pas etre redessine car leur couleur doit rester ce... |
59254dcc-957b-421f-a2e2-23b8287d184b | 7 | public List<Graph> getErrorToProgressGraph() {
Map<Integer, Double> timeProgress = new HashMap<Integer, Double>();
Map<Integer, Integer> timeCount = new HashMap<Integer, Integer>();
Map<Integer, Double> stepsProgress = new HashMap<Integer, Double>();
Map<Integer, Integer> stepsCount = new HashMap<Integer, Integ... |
a4aa1227-a236-460d-be3f-94fa8847eb77 | 5 | private void doHearbeats() {
new Timer().schedule(new TimerTask() {
@Override
public void run() {
// this code will be executed after 5 seconds
masterLogger.logMessage("===>> Heartbeats @ sec = "
+ executionTime);
for (Iterator<Entry<Integer, ReplicaLoc>> iterator = replicaPaths
.entrySe... |
048e6ceb-85c3-4638-9f92-21c2b1b2caf6 | 1 | @Override
public String toString() {
StringBuffer s = new StringBuffer();
for (Student student : students) {
s = s.append(student).append(System.lineSeparator());
}
return s.toString();
} |
f73eceba-417e-4070-826b-176b23a9df7e | 1 | public ImageIcon loadIcon(String image){
try {
return new ImageIcon(ImageIO.read(new File(image)));
} catch (Exception e) {
e.printStackTrace();
}
return null;
} |
df6c4f59-39f2-4972-b23e-089c119c5432 | 2 | public Admin lookup(String username) throws DAOPoikkeus {
Admin admin;
Connection connection = avaaYhteys();
String sql = "select id, username, password_hash, salt from Admin where username = ?";
try {
PreparedStatement usernameLookup = connection.prepareStatement(sql);
usernameLookup.setString(1, usernam... |
c2bd4ff6-1c03-4000-a22a-0b5f3c1e477d | 1 | public void rewindNbytes(int N)
{
int bits = (N << 3);
totbit -= bits;
buf_byte_idx -= bits;
if (buf_byte_idx<0)
buf_byte_idx += BUFSIZE;
} |
e06b8510-5eb5-4ec2-acad-e7c7f25d6726 | 9 | public List<Double> decode(Chromosome chromosome) {
if (chromosome.size() % 2 != 0)
throw new IllegalArgumentException(
"Chromosomze length must be an even number.");
if (decimalPlaces < 0)
throw new IllegalArgumentException("decimalPlaces must be >= 0");
List... |
c5f1a5e3-233b-44bf-ab05-a716848aca0a | 8 | public static void main(String[] args)
{
/***
* Dear TA's,
*
* There are certainly better ways of doing unit testing...
* I know this isn't software practices so I won't complain. However
* it may be advisable in the future to allow JUnit or frameworks of
* our own creation.
*
* <... |
5d036c99-d0a0-44c5-b939-e81797579f68 | 6 | private void updatePistonState(World par1World, int par2, int par3, int par4)
{
int var5 = par1World.getBlockMetadata(par2, par3, par4);
int var6 = getOrientation(var5);
boolean var7 = this.isIndirectlyPowered(par1World, par2, par3, par4, var6);
if (var5 != 7)
{
... |
b86eef2d-1ac7-495f-9973-9c782c1fe895 | 6 | private List<Issue> searchIssues(User visitor, Long creator, Long assignee, String title, String priority, String status) {
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Issue> criteriaQuery = criteriaBuilder.createQuery(Issue.class);
Root<Issue> fr... |
09be0025-3707-4ef6-92d9-163bf4dddde5 | 5 | public final void initUI() {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.setBorder(BorderFactory.createEmptyBorder(40, 40, 40, 40));
setLayout(new BorderLayout());
panel.add(Box.createHorizontalGlue());
slider = new JSlider(0, 150, 0);
slider.setPreferred... |
9da4289e-acb3-4c9b-96d3-0d48cf10fc4c | 9 | public static void bellmanFord(int s) {
dist[s] = 0;
for (int k = 0; k < V - 1; k++)
for (int i = 0; i < V; i++)
for (int j = 0; j < adj[i].size(); j++) {
Edge neigh = adj[i].get(j);
int v = neigh.v, p = neigh.p;
if (dist[i] != INF && dist[i] + p < dist[v])
dist[v] = dist[i] + p;
}
... |
1feba3ac-20e0-420b-9f20-b4fa3e7f700d | 5 | private void idct_direct(double F[][], double f[][]) {
double a[] = new double[N];
a[0] = sqrt(1. / N);
for (int i = 1; i < N; i++) {
a[i] = sqrt(2. / N);
}
double summ = 0;
double koeff = 0;
for (short i = 0; i < N; i++) {
for (short j =... |
b76e0113-58bf-466a-baf6-c25fcfcdabac | 9 | public static void editEmployee() {
System.out.print("Pick employee number: ");
int choice = scInt.nextInt();
Prototype temp;
if ((choice > employeeList.size()) || (choice < 1)) {
System.err.println("Fatal Error! Number not on list!");
System.exit(1);
}
temp = employeeList.get(choice - 1);
employeeL... |
e76c7bc7-56b0-4046-abce-f429b40fb827 | 1 | private void pause() throws InterruptedException {
if (ponderFactor == 0) return;
TimeUnit.MILLISECONDS.sleep(rand.nextInt(ponderFactor * 250));
} |
985b3b3f-c29d-4b24-9256-7fc9fd8b9fc2 | 9 | public static int parseTime(final String time) {
int sum = 0;
String buffer = "";
for (int i = 0; i < time.length(); i++) {
final char c = time.charAt(i);
if (Character.isDigit(c)) {
buffer += c;
} else {
int amount = Integer.... |
aca61929-0c97-4876-978e-e50594e6faf8 | 6 | @Override
public boolean onCommand(CommandSender sender, Command command,
String label, String[] args) {
if(!sender.hasPermission(pluginMain.pluginManager.getPermission("thf.trains"))){
sender.sendMessage("");
... |
c81f741d-90b3-4b4d-b2b8-7f7d74847c37 | 0 | private void initSymbolTable()
{
symbolTable = new SymbolTable();
symbolTable.setParent(null);
symbolTable.setDepth(0);
symbolTable.insert("readInt");
symbolTable.insert("readFloat");
symbolTable.insert("printBool");
symbolTable.insert("printInt");
symbolTable.insert("printFloat");
symbolTable.inser... |
67cc158c-f07e-4b10-9d0f-0926797aa1dc | 2 | public ArrayList<Player> getPlayersInRadius(Entity e, int radius){
ArrayList<Player> result = new ArrayList<Player>();
float ex = e.getX();
float ey = e.getY();
for(int i = 0; i < players.size(); i++){
Player entity = players.get(i);
float x = entity.getX();
float y = entity.getY();
float dx = Math.... |
c4d38f46-bb1a-4102-ac70-00aab374747f | 7 | private void jButtonChangeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonChangeActionPerformed
try {
// TODO add your handling code here:
char[] mdp = jPasswordFieldOldPass.getPassword();
StringBuilder sb = new StringBuilder();
for (int ... |
2d7867ab-c2c0-4673-b155-e69d60fd18a2 | 7 | public void genNotes(double c) {
double totalProb = 0;
// randomly generate Note length
for (int i = 0; i < prob.length; i++) {
if (possibleCount[i] <= c) {
totalProb += prob[i];
}
}
double randGen = Math.random() * totalProb;
int counter = -1;
while (randGen > 0) {
counter++;
if (possibl... |
7dc3a0a4-299d-4cb7-aef6-3dbf2d61388e | 0 | public void setProblemList(ProblemList problemList) {
this.problemList = problemList;
} |
01bc46d2-97d3-424e-b10b-812e1c2173bc | 9 | public void run(int gen, ArrayList<Section> current, int semlen) {
randomize(current); //randomize the order that the sections are in
establish(current, semlen); //establish the population to chromosome length of semlen
//Population is now set up, time to select for breeding
int i = 0;
ArrayList<... |
de5821f7-899e-4b2e-8529-0f93d4b4ad4e | 1 | public void affichageTableur(String pretexte, ArrayList<ArrayList<Integer>> al)
{
System.out.println(pretexte);
System.out.println("[");
for(ArrayList<Integer> mot : al)
System.out.println("\tPosition : " + al.indexOf(mot) +"(" + tableurNonTrie.indexOf(mot) + ")\t" + mot);
... |
3705bd2f-708f-42a9-ba5f-88c71eeb833d | 9 | protected void paintTabs(Graphics g, Rectangle clip, Insets insets) {
int xOffset = getXOffset();
TabSet tabs = getTabSet();
int lastX = clip.x - 10;
int maxX = clip.x + clip.width + 10;
int maxY = getUnitsFontHeight() + TabHeight;
double zoom=1.0f;
if (getTextPane()... |
9693d616-7e36-452f-a539-183f26e25936 | 5 | public boolean createWhen(){
if(grade=='c' || grade=='b')
return stage.count%(50*stage.fps/frequency+1)==0 && stage.second()>=startTime;
else
return stage.count%(300*stage.fps/frequency+1)==0 && stage.second()<=16 && stage.second()>=startTime;
} |
9010cdcb-8f79-4936-a8e9-27b2062b6190 | 6 | public static void cssDetails(File fileName, DetailObject detailObject) {
detailObject.updateNumberOfFiles();
DetailObject.updateTOTAL_NUMBER_OF_FILES();
try {
BufferedReader bufferedReader = new BufferedReader(new FileReader(fileName));
String line;
while ((line = bufferedReader.readLine()) != null) {
... |
b1fd232f-c5ba-4a34-9f13-4cc0b7fcce80 | 5 | public void broadcastMessage(String message, Client client, boolean fromGame) {
if (!fromGame && game != null
&& !game.parsePublicMessage(message, client)) {
return;
}
message = KCodeParser.parse(message, !client.isModerator(), 5, 10, 20);
message = Server.get().parseSmileys(message);
if (message.isE... |
9196e13d-4ff4-4a6b-a4e8-4e5ba1bbaa20 | 2 | public static boolean isTypeArray(Class<?> type) {
return (type != null && type.isArray());
} |
c3b485f1-f446-4e03-a46c-5c14ec84274c | 3 | public static final List<Integer> getEnabledSecTypes() {
List<Integer> result = new ArrayList<Integer>();
result.add(secTypeVeNCrypt);
result.add(secTypeTight);
for (Iterator<Integer> i = enabledSecTypes.iterator(); i.hasNext();) {
int refType = (Integer)i.next();
if (refType < 0x100 && ref... |
f17c7d11-ccfd-487a-a150-39db1f3b980f | 2 | public static <K, V extends Comparable<? super V>> Map<K, V>
sortByValue( Map<K, V> map )
{
List<Map.Entry<K, V>> list =
new LinkedList<Map.Entry<K, V>>( map.entrySet() );
Collections.sort( list, new Comparator<Map.Entry<K, V>>()
{
public int compare( Map.Ent... |
57da64b4-a4a7-4ebf-b805-0f6636f80837 | 1 | public static Collection<Roll> getInstance(){
if(roll_list==null){
roll_list=new ArrayList<Roll>();
}
return roll_list;
} |
de416ba5-2040-4447-bf94-494cd35ed0de | 1 | protected BoundMethod match(PathPattern<Method> pattern, PathInput input, Object self) {
Method method = pattern.getTarget();
if (method != null) {
input.bind(method);
pattern.match(input);
return new BoundMethod(self, method, input.getParameters());
} else {... |
9e420256-afb9-4349-b228-6490e56c1178 | 0 | public HTTPRequestHandler()
{
} |
e61cfc52-1ff3-4e68-8482-5b67b8782a46 | 0 | public Object remove(Object key) {
accessTimes.remove(key);
return map.remove(key);
}//remove |
f99e22fa-5f0f-4c25-a395-7a5455a55fcc | 1 | @PUT
@Path("/{id}")
@Consumes(MediaType.APPLICATION_JSON)
public Response updateCustomer(final @PathParam("id") int id, Customer cust) {
if (id != cust.getId()) {
throw new WebApplicationException(Response.status(Status.CONFLICT)
.entity("Cannot change id of existing customer.").build());
}
validateCus... |
de541490-206c-4dbd-95cb-b4fcb3efc156 | 2 | public void addBall()
{
try
{
Ball ball = new Ball();
comp.add(ball);
for (int i = 1; i <= STEPS; i++)
{
ball.move(comp.getBounds());
comp.paint(comp.getGraphics());
Thread.sleep(DELAY);
}
}
catch (InterruptedEx... |
3fe12aef-44f2-4b08-ab9c-c395f0e1cdfc | 4 | public void createItem(int newItemID) {
int Maxi = server.itemHandler.DropItemCount;
for (int i = 0; i <= Maxi; i++) {
if (server.itemHandler.DroppedItemsID[i] < 1) {
server.itemHandler.DroppedItemsID[i] = newItemID;
server.itemHandler.DroppedItemsX[i] = (absX);
server.itemHandler.DroppedItemsY[i] = ... |
8bd6c320-2e71-46b0-8a88-eb99afdc9888 | 6 | static public void adjustBeginLineColumn(int newLine, int newCol)
{
int start = tokenBegin;
int len;
if (bufpos >= tokenBegin)
{
len = bufpos - tokenBegin + inBuf + 1;
}
else
{
len = bufsize - tokenBegin + bufpos + 1 + inBuf;
}
int i = 0, j = 0, k = 0;
... |
3b69fcf6-ea8c-430a-99a8-b25a927594a5 | 7 | public void disconnect() {
ClientDisconnectMessage cdm = new ClientDisconnectMessage(username);
try {
output.writeObject(cdm);
} catch (IOException e) {
System.out.println("Exception with sending disconnect message " + e);
}
try {
if(input != null) input.close();
}
catch(Exception e) {}
... |
0dab483a-fb79-49eb-b10b-8448d0826738 | 1 | public void concatenar(Lista<E> pLista){
if(talla == 0){
cabeza = pLista.getHead();
talla = pLista.getTalla();
cola = pLista.getTail();
return;
}
cola.siguiente = pLista.getHead();
pLista.getHead().previo = cola;
cola = pLista.getTa... |
de60c3aa-ef2e-4a92-ac3d-429239968b2f | 3 | public GameBoard() {
board = new Piece[8][8];
hcolor = new Color(1.0f, 1.0f, 0, 0.5f);
bBlack = new Color(80, 48, 18);
bWhite = new Color(193, 144, 97);
try {
Image spritesheet = new Image("data/pieces.png");
pieces = new Image[6][2];
for (int ... |
7f84bf06-d4e6-4afe-b8fa-95b30dea7abb | 2 | public static Quiz getQuizByQuizID(int quizID) {
String statement = new String("SELECT * FROM " + DBTable + " WHERE qid = ?");
PreparedStatement stmt;
try {
stmt = DBConnection.con.prepareStatement(statement);
stmt.setInt(1, quizID);
ResultSet rs = stmt.executeQuery();
if (!rs.next()) {
System.out... |
4c485f3e-c37b-4e66-bb80-501bb11de763 | 5 | public boolean validatePayment(Transaction transaction) {
String paymentType = transaction.getPayment().toString();
boolean paid = false;
switch (paymentType) {
case "CashPayment":
registerUI.setCashPayment();
break;
case "CreditPayment":
registerUI.setCreditPayment();
paid = transaction.get... |
e6200d4c-e6fa-4624-a5b0-6015c9c54e95 | 5 | private void ensureSubItemsLoaded() {
if (loadedSubItems)
return;
loadedSubItems = true;
if (getFirst() != null) {
// get first child
Reference nextReference = getFirst();
Reference oldNextReference;
OutlineItem outLineItem;
... |
9df37de3-19b6-4e5f-9849-9c201db1bf1c | 3 | @Override
public boolean init(List<String> argumentList, DebuggerVirtualMachine dvm) {
if (argumentList.size() > 0) {
UserInterface.println("This command takes no arguments.");
HelpCommand.displayHelp(this);
return false;
}
breakpoints = new ArrayList<Str... |
74a0cb0a-741a-4df6-990a-e2522a718d56 | 8 | private void setObstacleVelocity(float[][] u, float[][] v) {
int count = 0;
float uw, vw;
for (int i = 1; i < nx1; i++) {
for (int j = 1; j < ny1; j++) {
if (!fluidity[i][j]) {
uw = uWind[i][j];
vw = vWind[i][j];
count = 0;
if (fluidity[i - 1][j]) {
count++;
u[i][j] = uw - u... |
7bfbe33c-5643-421d-b103-a23748f707d7 | 3 | @Override
public void focusLost(FocusEvent arg0) {
try {
String Str = _view.edt_ID.getText();
if (!Str.isEmpty()) {
search(Integer.parseInt (Str));
}
} catch (NullPointerException E){
Er... |
666d0622-617a-446b-b282-6ba691a7259a | 3 | @Override
public void close() throws AudioDeviceException {
boolean failed = false;
for ( AudioDevice dev : this.mDevices ) {
try {
dev.close();
}
catch (AudioDeviceException e) {
failed = true;
}
}
if ( failed ) {
throw new AudioDeviceException( "couldn't close all of the underlying Aud... |
56009d4d-68c8-4825-b130-217568f2c1a8 | 2 | public int compareTo(Object o)
{
Location l = (Location)o;
if (l.prio < prio) return 1;
if (l.prio > prio) return -1;
return 0;
} |
094abd85-c77d-48a7-8541-bf527055b721 | 6 | public void updateLongestRoad(int p) {
if (_numRoads[p] > _longestRd) {
if (_longestRd_Owner != -1) {
_points[_longestRd_Owner] -= 2;
}
_points[p] += 2;
_longestRd = _numRoads[p];
if (p == _playerNum && p != _longestRd_Owner) {
_chatBar.addLine("9" + "You have the Largest Road Network! You n... |
2bd7e902-bcf3-4153-9713-41d4c18ec588 | 8 | @Override
public void onMessage(String channel, String sender, String message) {
String filter = MdBtConstants.BOTNAME + ": ";
boolean toMe = false;
boolean shouldLearn = !sender.equals("habbes")
&& !sender.equals("mlvn");
if (message.startsWith(filter)) {
toMe = true;
message = message.replaceFir... |
5f5caeea-8214-48c8-b91d-252b02dd4354 | 1 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
if (!this.pretarate()) {
this.msg("Campos incompletos o erróneos.");
}
}//GEN-LAST:event_jButton1ActionPerformed |
58651b80-b05f-4c66-a037-3f3b1ca0ccd8 | 0 | public boolean isVariable(String variable) {
return myVariables.contains(variable);
} |
28258455-5563-4b53-af36-351f2f680e69 | 4 | public T[] getBFS() {
Queue<Node<T>> queue = new ArrayDeque<Node<T>>();
T[] values = (T[]) new Comparable[size];
int count = 0;
Node<T> node = root;
while (node != null) {
values[count++] = node.id;
if (node.lesser != null)
queue.add(node.l... |
facde1f5-cf15-4b10-8c4e-d13954b92e29 | 2 | private CtField getDeclaredField2(String name) {
CtMember.Cache memCache = getMembers();
CtMember field = memCache.fieldHead();
CtMember tail = memCache.lastField();
while (field != tail) {
field = field.next();
if (field.getName().equals(name))
re... |
f0e44a9e-f1bd-4fc6-a7c4-c0178e650e0d | 6 | static void DVP()
{
Scanner in = new Scanner(System.in);
final Board b = Board.readBoard(in);
ArrayList<Integer> nextPiece = new ArrayList<Integer>();
while(in.hasNextInt())
nextPiece.add(in.nextInt());
Searcher s;
for (int i = 2; i < 7; i++){
s = new DLDFS(new LinearWeightedSum(new double[] {... |
463bbfa4-db49-42eb-a699-5f9c4dce3518 | 2 | public float[][] getM()
{
float[][] res = new float[4][4];
for(int i = 0; i < 4; i++)
for(int j = 0; j < 4; j++)
res[i][j] = m[i][j];
return res;
} |
66cbfab3-fd0e-454e-ae89-b2614032573e | 4 | public void consolidate(){
// add feedback boxes to forward path boxes
this.closedPath = this.forwardPath.copy();
for(int i=0; i<this.nFeedbackBoxes; i++){
this.closedPath.addBoxToPath(this.feedbackPath.get(i));
}
// combine forward path boxes
this.forwardPa... |
6cb6499d-d52e-4b61-82f0-b9d44108650f | 4 | public void processImage() throws Exception {
byte[] originalImageBytes = baseImageProvider.getImage();
byte[] watermarkImageBytes = watermarkImageProvider.getImage();
if (originalImageBytes == null) {
throw new Exception("Original Image is not loaded");
}
if (water... |
71480fa3-077c-4931-b730-184b77b0832c | 4 | public static void main(String [] args){
ExecutorService executor= Executors.newFixedThreadPool(numThreads);
List<Future<Long>> list=new ArrayList<Future<Long>>();
for(int i=0; i<20000; i++){
Callable<Long> worker=new MyCallable();
Future<Long> submit=executor.submit(wor... |
c2117e8a-38e0-4eaf-817f-6988bf062a46 | 1 | public void removePush() {
if (exprStack != null)
instr = exprStack.mergeIntoExpression(instr);
super.removePush();
} |
89fdba19-1035-426e-980e-3373576ff5f8 | 4 | public String createMaskFromDatePattern(String datePattern) {
String symbols = "GyMdkHmsSEDFwWahKzZ";
String mask = "";
for (int i = 0; i < datePattern.length(); i++) {
char ch = datePattern.charAt(i);
boolean symbolFound = false;
for (int n = 0; n < symbols.l... |
58926fdd-8249-44d4-abf7-33056915815f | 8 | public static boolean fileprocess(String downloadpath, String filepath, String []paras, String sn){
int errorcode=0;// print error code in the final output file;
int errornum = 14;
String result="";
File downloadfile = new File(downloadpath+"\\temp_test.txt");
File outputfile = new File(filepath);
doub... |
1434bc65-232c-413a-ac47-d6eae7a19249 | 4 | @Override
public void applyAllChanges() throws ApplyChangesException {
// Make a "backup" first
Document backup = null;
try {
TransformerFactory tfactory = TransformerFactory.newInstance();
Transformer tx = tfactory.newTransformer();
DOMSource source = n... |
a0d09129-3127-4122-ac4d-4b119f5d7ac0 | 3 | @Override
public synchronized Voiture circule() {
Voiture v;
int length = vehicules.length;
for (int i = length - 1; i >= 0; i = i - 1) {
v = vehicules[i];
if (v != null) {
v.avancer();
}
}
if (waittingForInsertion == null) {
return null;
}
v = waittingForInsertion;
waittingForInsert... |
278d4beb-5c85-4786-99e9-b69383cead59 | 6 | public static String getID(ProjectileType type){
switch(type){
case BOULDER:
return "boulder";
case FIREBALL:
return "fireball";
case ICE_SPIKE:
return "icespike";
case ITEM:
return "item";
case SPELL:
return "greenfire";
case ELECTRO_BALL:
return "electroball";
default:
return "";
... |
e01bb235-2fa2-4bb4-8c08-76332098b784 | 3 | public static File moveFile(File sourceFile, File destinationDir)
{
if (destinationDir == null || !destinationDir.isDirectory ())
return null;
File movedFile = new File (destinationDir.getAbsolutePath () + File.separator
+ sourceFile.getName ());
if (sourceFile.renameTo (movedFile))
return movedF... |
a039f094-090d-42fc-98f0-d58bb07ccd9a | 6 | public static Contributor findContributor(String domain) {
loadContributors();
Contributor contributor = Contributor.contributors.get(domain);
if(contributor == null) {
for(Contributor cont : Contributor.contributors.values()) {
if(cont.getDomain().equalsIgnoreCase(domain) ||
cont.getName().equ... |
eea4d4b6-b053-4567-b747-23e63bf31b08 | 5 | public void run(){
while(this.status == Bullet.ALIVE){
try {
Thread.sleep(Constant.bullet_sleep_time);
} catch (InterruptedException e) {
e.printStackTrace();
}
if( Game.status == Game.STATUS_ON){//judge the status
if(judgeIfIn()){
if( this.status == Bullet.ALIVE){
this.m... |
019bef7e-14dd-409e-883f-25f04c9ca145 | 1 | public void stop()
{
if ( !isRunning )
return;
isRunning = false;
} |
18a320f9-ff90-4f64-968d-b3c0fc0a2812 | 9 | public boolean codopValido(String cod){
int punto=0, tam=cod.length();
boolean flag=false;
if(tam > 5){
return false;
}
else
if(!Character.isLetter(cod.charAt(0))){
return false;
}
else{
for(int i=1;i<tam && !flag;i++){
if(!(Character.isLetter(cod.c... |
922f646a-e38d-49e6-93f0-1967caa475ca | 8 | public void vecinos_apartir_inicio(Casilla nodopadre){
//verificar que no esten en lista cerrada
if(nofin==0){
int tamCerrado=listas.tamañoL_Cerrados();
Casilla temp =new Casilla();
Casilla ini =new Casilla();
int xi=nodopadre.getcordena... |
78e77f89-bf75-4d35-9be4-b4793bad69db | 4 | @Override
Color getColor(String color) {
if (color == null) {
return null;
}
if (color.equalsIgnoreCase("RED")) {
return new Red();
} else if (color.equalsIgnoreCase("GREEN")) {
return new Green();
} else if (color.equalsIgnoreCase("BLUE")) {
return new Blue();
}
return null;
} |
855816d4-43b5-4e14-8c8c-7e41bc2e5db4 | 7 | public static ColorRGBA getColor(int type) {
switch(type) {
case GRASS:
return new ColorRGBA(0.2f, 0.8f, 0.2f, 1.0f);
case DIRT:
return new ColorRGBA(0.3f, 0.3f, 0f, 1.0f);
case STONE:
return new ColorRGBA(0.6f, 0.6f, 0.6f, 1.0f... |
bacfb08e-91d5-46ed-bc21-4a5885191dd0 | 6 | public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://down... |
84b31424-86f7-4029-a104-5b24d7764517 | 7 | public boolean isPermutation_Hashtable(String s1, String s2){
if(s1.length() != s2.length())
return false;
Hashtable<Character,Integer> ht = new Hashtable<Character,Integer>();
//put all characters in s1 to the hash table
for(int i=0;i<s1.length();i++){
char k = s1.charAt(i);
if(!ht.containsKey(k))... |
111eb534-28e3-4216-ad18-94f8b984c721 | 8 | private void updateLocations(GameContainer gc, StateBasedGame sbg)
throws SlickException {
//Update the bullet's position.
for(int i = 0;i<bulletList.size();i++){
Bullet bullet = bulletList.get(i);
bullet.move();
// Removes bullets that go off screen.
if ((bullet.returnX() > 639 || bullet.returnX() ... |
5b2d7197-f3ac-44c3-a83c-ffc446874078 | 0 | public void setIdPos(int idPosLogEnt) {
this.idPosLogEnt = idPosLogEnt;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.