method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
fcd5a592-986c-4c53-96c2-7af092988965 | 8 | public void removeOrganization(String key)
{
try
{
Organization org = organizations.get(key);
// Delete all subOrganizations
if ( !org.getAllSubOrganizations().isEmpty() && org.getAllSubOrganizations().size() > 0 )
{
Enumeration<String> subOrgs = org.getAllSubOrganizations().keys();
whil... |
2bf9942a-9495-4d0f-999d-2eb0c163d7fd | 5 | public ArrayList<TreeNode> generateTrees(int n) {
ArrayList<TreeNode>[] trees = new ArrayList[n +1];
trees[0] = new ArrayList<TreeNode>();
trees[0].add(null);
if (n == 0) return trees[0];
trees[1] = new ArrayList<TreeNode>();
TreeNode node = new TreeNode(1);
node.left = node.right =... |
a518d278-0bf1-4da9-92ce-04ed6d588087 | 9 | public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int N;
while(true)
{
N = sc.nextInt();
if(N==0)
break;
String str = sc.next();
boolean zFound = false;
if(str.contains("Z"))
... |
ae8ca4e3-d804-42fa-84ca-3def1ac1d2c3 | 4 | public PropertyHandler(File propertyFile) {
this.file = propertyFile;
if (propertyFile.exists()) {
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(propertyFile);
this.properties.load(inputStream);
} catch (... |
78ab5b68-d154-4253-a120-78d13f8b4275 | 5 | public static List<Episode> getAllEpisodes(String urlString, int season) throws TvDbException {
List<Episode> episodeList = new ArrayList<>();
Episode episode;
NodeList nlEpisode;
Node nEpisode;
Element eEpisode;
Document doc = DOMHelper.getEventDocFromUrl(urlString);
... |
74a7c623-b9d0-4872-9536-75411b2416ef | 8 | public static boolean mapAndEnqueueVariableP(Stella_Object variable, Stella_Object localvalue, KeyValueMap mapping) {
if (Surrogate.subtypeOfP(Stella_Object.safePrimaryType(variable), Logic.SGT_LOGIC_PATTERN_VARIABLE)) {
{ PatternVariable variable000 = ((PatternVariable)(variable));
{ Stella_Object m... |
676cd448-bae8-40c5-9bde-581446e34d2e | 9 | public CASResponse cas(String key, Object value, int ttlSec, long cas, long timeoutMiliSec)
throws TimeoutException, com.quickserverlab.quickcached.client.MemcachedException{
try{
Future <net.spy.memcached.CASResponse> f = getCache().
asyncCAS(key, cas, ttlSec, value, getCache().getTranscoder());
try {... |
f367579d-1089-47e0-a201-218094acae9e | 3 | @Override
public String execute(SessionRequestContent request) throws ServletLogicException {
String page = (String) request.getSessionAttribute(JSP_PAGE);
resaveParamsCitySelected(request);
request.setAttribute(JSP_CURR_ID_HOTEL, "0");
String currCity = request.getParameter(JSP_CUR... |
c6fc174e-94b9-4ae4-967f-f5731c68ff2f | 1 | private JFileChooser getJFileChooser(){
if (this.jFileChooser == null){
this.jFileChooser = new JFileChooser();
}
return this.jFileChooser;
} |
3c23a161-9523-4b05-93d4-d67a05ce3cff | 2 | @Test
public void testOutputFutureMeetings() throws IOException {
Calendar thisDate = new GregorianCalendar(2015,3,2);
cm.addFutureMeeting(contacts, thisDate);
cm.addNewPastMeeting(contacts, new GregorianCalendar(2013,5,3), "meeting");
cm.flush();
ObjectInputStream ois = new ObjectInputStream(new FileInputSt... |
b1b81530-2124-4fc0-b173-af285c30d2d3 | 9 | @Override
public boolean equals(Object other) {
if ((other == null) || !(other instanceof Pair<?,?>)) {
return false;
}
return ((Pair<?, ?>)other).first.equals(first) && ((Pair<?, ?>)other).second.equals(second);
} |
3eaf3eb6-dff2-47db-bf06-64be49a370e7 | 9 | public boolean upload(String sourceFile, String destFile, String group, UserToken token) {
if (destFile.charAt(0) != '/') {
destFile = "/" + destFile;
}
try {
Envelope message = null, response = null;
message = new Envelope("UPLOADF");
message.addObject(destFile);
message.addObject(group);
mes... |
85af3bcd-caea-4afa-a9e7-d091388a0169 | 0 | @Override
public void method3() {
System.out.println("ClassA method3()");
} |
085c6e79-8d9e-4f3c-b6eb-b3137e36740a | 2 | private ArrayList<Edge> getCoast() {
try {
//Get time, Connection and ResultSet
Long time = System.currentTimeMillis();
Edge edge = null;
String sql = "SELECT * FROM [jonovic_dk_db].[dbo].[correctedCoastLine];";
Connection con = cpds.getConnection();
... |
4402052b-e209-4a14-9ba9-9120af35e57b | 4 | private void printDirectReplies( Long parentId ) throws IOException {
convFileWriter.write(parentId.toString());
if( !adjacencyList.containsKey(parentId))
return;
long numOfReplies = adjacencyList.get(parentId).size();
if(numOfReplies == 0)
return;
co... |
99536ea2-f205-4613-9425-024dce9aea8b | 4 | private boolean checkPath(String path) {
String[] parts = path.split("/");
if(parts.length != this.path.size())
return false;
for(int i = 0; i < parts.length; i++) {
PathPart pathPart = this.path.get(i);
if(!pathPart.isVariable && !pathPart.name.equals(parts[i]))
return false;
}
return true;
} |
8a40ec02-0b37-4e91-a670-6f4d0dcaed3c | 1 | public static double[] convert(List<Double> l) {
double[] d = new double[l.size()];
for (int i = 0; i < d.length; i++) {
d[i] = l.get(i);
}
return d;
} |
cd4c01e6-ac30-433f-bda2-f6eeaa13f1e3 | 4 | public int evalMove(Move m, State s, int depth) {
if (depth == 0) { // cutting off search -> evaluate resulting state
return evalState(s.tryMove(m), s);
} else { // minimax-search
// update the state
State newstate = s.tryMove(m);
// get a list of possible moves from newstate
MyList moves =... |
1454f7f7-10fb-48c5-bacf-32bddd9a24cc | 9 | @SuppressWarnings("unchecked")
public Action<Class<?>, Member> findAction(Action<Class<?>, Member> action) {
try {
VisitorAdapter<Class<?>, Member> v = new VisitorAdapter.ActionVisitor<Class<?>, Member>() {
private String peek = getCommandLine().peek();
@Override
public void visit(Action<C... |
9bb16903-669e-4c9c-9428-fa510c030873 | 7 | public mxICell decodeCell(Node node, boolean restoreStructures)
{
mxICell cell = null;
if (node != null && node.getNodeType() == Node.ELEMENT_NODE)
{
// Tries to find a codec for the given node name. If that does
// not return a codec then the node is the user object (an XML node
// that contains the m... |
fe4a3bbf-bc10-4d99-9e4c-7786954ba813 | 8 | private boolean fileToPjt(int dId, FileType fileTyp) throws InvalidFormatException, OpenXML4JException, XmlException, IOException, SAXException, ParserConfigurationException
{
boolean result = false;
String strText = "";
// Auswahl Methode je nach Dateityp
switch (fileTyp)
{
case DOC:
{
strText =... |
4b17e0c8-0368-4ea6-a138-211e7615d66b | 7 | public static <F,T> Adapter<F,T> getAdapter(Class<F> fromType,
Class<T> toType) throws AdapterNotFoundException {
if(fromType == null || toType == null) {
throw getException(fromType, toType);
}
//If the types passed in are primitive, convert to wrapped types to find
//the app... |
6b841b41-27a8-4e01-9d52-a23099544727 | 2 | public static boolean isSkeletonWarriorDiamond (
SkeletonWarriorDiamond MMSkeletonWarriorDiamond) {
if (MMSkeletonWarriorDiamond instanceof Skeleton) {
Skeleton SkeletonWarriorDiamond = (Skeleton) MMSkeletonWarriorDiamond;
if (SkeletonWarriorDiamond.getEquipment().getChestpla... |
6b1912cc-8a8b-43a1-8a0c-d2f421c98d42 | 7 | private void jComboBoxTipoClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxTipoClienteActionPerformed
try{
if(jComboBoxTipoCuenta.getSelectedIndex()==0 && jComboBoxTipoCliente.getSelectedIndex()==0){
tipoCuenta=1;
tipoCliente=1;
... |
b9778593-bfb3-4ad1-8d61-253a0f757cf1 | 3 | public void printIO(){
String s = "I:";
for(int i=0; i<inputNo; i++)
s+=" "+inputNodes[i].getActivation();
s+="\nO:";
for(int i=0; i<outputNo; i++)
s+=" "+outputNodes[i].getYAccuali()*scale;
s+="\nH:";
for(int i=0; i<outputNo; i++){
s+=" "+outputNodes[i].getActivation()*scale;
}
System.out.prin... |
9ff47c3f-65ec-46e8-9da9-b1e7c147bac7 | 5 | @Test
public void testArrayOfArrays() throws Exception
{
PersistenceManager persist = new PersistenceManager(driver, database, login, password);
persist.dropTable(Object.class);
int arraySize = 5;
ComplexObject co = new ComplexObject();
SimplestObject[][][] array = new SimplestObject[arraySize][arraySize]... |
1432cac5-644a-47ed-aaf8-504e0c8b1e43 | 5 | public boolean isInArea(Location l) {
double x = l.getX();
double y = l.getY();
double z = l.getZ();
return x > minPoint.x && x < maxPoint.x && z > minPoint.z && z < maxPoint.z && y > minPoint.y
&& y < maxPoint.y;
} |
e9d1eefc-3260-4c67-8311-62a38bb2214a | 6 | private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed
try {
messageLabel.setText("");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "oracle");
Statement s = con.createStatement();
... |
5fcfd913-af0c-42fb-ac27-2f255e814a8f | 9 | private static void combine(int a[], int low, int mid, int high){
int lowPointer = low;
int highPointer = high;
int [] lower = new int[mid-low+1];
int [] higher = new int[high - mid-1 +1];
System.out.println("High : " + high + " Mid : " + mid + " Low : " + low);
int count = 0;
for(int i =low ... |
87bcf560-95e3-4339-ab31-965ab466b5f8 | 7 | private void destroyWall(EnvironmentWall wall, Line2D destroyedPart) {
boolean originalWallUsed;
double cellWidth, cellHeight, oldWallX2, oldWallY2, newWallX1, newWallY1, newWallX2, newWallY2;
Vector2D wallDirection;
EnvironmentWall newWall;
wallDirection = wall.getWa... |
aa403cf2-4257-47f3-9542-d9aeab674a59 | 7 | public boolean shouldTurnOn(int x, int y) {
for (ShapeWithRelativeCoordinates component : shapes) {
int relativeX = x - component.topX;
int relativeY = y - component.topY;
if (component.shape instanceof Circle) {
if (((Circle) component.shape).isPixelActivate... |
a50b7dd2-fa1d-46fd-9d5c-84147979477f | 2 | public void writeWord(int word)
throws IOException {
if((word & 0xffff) != word) {
throw new IllegalArgumentException("Argument is not a 16 bit word: "+word);
}
if(littleEndian) {
out.write(word & 0x00ff);
out.write((word & 0xff00) >> 8);
} el... |
ee62ef86-e593-43f1-83e2-594f2ddceeb2 | 8 | public Trivia() {
System.out.println("> loading challenges...");
easyTrivia = new ArrayList<Challenge>();
mediumTrivia = new ArrayList<Challenge>();
hardTrivia = new ArrayList<Challenge>();
gameChallenges = new ArrayList<Challenge>();
randy = new Random();
// read in each file, every odd line is a que... |
38f24293-537d-4cd4-9c09-9ff084682147 | 5 | private Object binarySearchNames(int firstIndex, int lastIndex, String name) {
if (firstIndex > lastIndex)
return NOT_FOUND;
int pivot = firstIndex + ((lastIndex - firstIndex) / 2);
pivot &= 0xFFFFFFFE; // Clear LSB to ensure even index
//System.out.print("binarySearchNames [ " + fi... |
843ca63e-bad6-448f-9dc0-4399d3c99f5c | 1 | public Contact(String firstName, String lastName, PhoneNumber... phoneNumbers) {
super(NextIdGenerator.getNextId(Contact.class));
this.firstName = firstName;
this.lastName = lastName;
this.phoneNumbers = hasPhoneNumbers(phoneNumbers) ? null : Lists.newArrayList(Arrays.asList(phoneNumbers));
ensureRequiredFiel... |
fb95e396-a29c-4310-afc1-5060c8f12794 | 8 | private String[] getCaps(final Plugin plugin) {
final Class<? extends Plugin> spawnClass = plugin.getClass();
final Method[] methods = spawnClass.getMethods();
// Search for proper method
for (final Method method : methods) {
// Init methods will be marked by the correspon... |
a084b96c-73a1-4109-b45b-dd7d1d44205a | 9 | public void render(Screen screen) {
Entity.sortMobsList();
for(int i = 0; i < Entity.getMobSize(); i++) {
if(!(Entity.getIndexedMob(i).getIsOnStage()) &&
Entity.getIndexedMob(i).getYCoord() < SpriteSheets.mainStage.getYSheetSize() / 2) {
Entity.getIndexedMob(i).render(screen);
}
}
screen.... |
52bfbc83-ca99-4c32-a260-18b0536c94ec | 6 | private void loadWordList( DefaultListModel data ){
UserDictionaryProvider provider = SpellChecker.getUserDictionaryProvider();
if( provider != null ) {
Iterator<String> userWords = provider.getWords( SpellChecker.getCurrentLocale() );
if( userWords != null ) {
Ar... |
93b8f38e-065a-4ced-aeb3-d1c7ea7a9faa | 0 | public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
} |
65bebfb6-8a2a-4462-8e9a-188eea82730b | 8 | private Method findMethodByPrefix(Class<?> sourceClass, String prefix,
String postfix) {
String shortName = listenerType.getName();
if (listenerType.getPackage() != null) {
shortName = shortName.substring(listenerType.getPackage().getName()
.length() + 1);
... |
0dde84f2-abf3-4238-9209-5a4629fb163b | 9 | public final boolean method66(int i, Interface18 interface18) {
anInt5438++;
if (!(interface18 instanceof Class296)) {
return false;
}
Class296 class296_3_ = (Class296) interface18;
if (anInt5431 != class296_3_.anInt5431) {
return false;
}
if (class296_3_.anInt5432 != anInt5432) {
return false;
... |
75a8d148-e619-487b-adc2-8f3e556a9f6f | 2 | public void processBet(PackReplyOldBetHop message) { // faz o cal. do Sbet
// faz a adicao do par <chave, valor>
// chave = num de caminhos, valor = numero de nodos
// descendentes com 'aquela' quantidade de caminho
if(sonsPathMap.containsKey(message.getPath())){
sonsPathMap.put(message.getPath(), sonsPathM... |
1569b5f7-27f7-4e96-a73c-ba7de97aad88 | 5 | public void attPrepEnd(){
battle.setState(Battle.BATTLE_SUPPORT_PHASE);
//we check if the player can add an influence token
if (territory1.getTroup().getEffectif()>0 || territory1.getInfluenceToken() || (territory1 instanceof HomeLand && ((HomeLand) territory1).originalOwner(territory1.getFamily()))){
if(battl... |
98cfffaf-a855-4822-bae7-460785ccba7f | 4 | public int sandinate(int X, int Y, int R)
{
int toReturn = 0;
// long time = System.nanoTime();
for (int i1 = Math.max(X-(R+1),0); i1 < Math.min(X+(R+1),w); i1 ++)
{
for (int i2 = Math.max(Y-(R+1),0); i2 < Math.min(Y+(R+1),h); i2 ++)
... |
0753b77f-8ad9-4b59-b708-d0b0360c7aa1 | 6 | @Override
public SondageReponse find(int id) {
SondageReponse found = null;
PreparedStatement pst = null;
ResultSet rs = null;
try {
pst=this.connect().prepareStatement("select * from SondageReponse where id= ?");
pst.setInt(1, id);
... |
855b83a5-0347-4d82-a12f-574a525d8427 | 0 | public Period(int year, int month)
{
this.year = year;
this.month = month;
this.locations = new ArrayList<DataPoint>();
} |
ad9a9933-60a7-49f4-937d-2a328856ca1b | 5 | private void acquiereLock(Lock fistLock, Lock seconlock)
throws InterruptedException {
boolean gotFirstLock = false;
boolean gotSecondLock = false;
while (true) {
try {
gotFirstLock = fistLock.tryLock();
gotSecondLock = seconlock.tryLock();
} finally {
if (gotFirstLock && gotSecondLock) {
... |
b6330466-f46b-4c64-8dfb-38c8234aea2e | 2 | private void receive() {
receiver = new Thread() {
@Override
public void run() {
while (true) {
try {
byte[] data = new byte[1024];
DatagramPacket packet = new DatagramPacket(data, data.length);
... |
63c1c9b8-da7f-4fb6-9bb6-76c7be6fc7e7 | 3 | public void LueTiedotTiedostosta(){
String menossaMappiin = "";
try {
menossaMappiin = kasittelija.lueTiedostoSanaKerrallaan();
} catch (NullPointerException e){
System.out.println("Nyt tapahtui jotain kummallista ja tiedostoa ei löydy"); //tähän jotain fiksua joskus
... |
0ab08d44-4462-4bdb-bcf6-80c163a56614 | 9 | public static void main(String[] args) {
// default values
int portNumber = 1500;
String serverAddress = "localhost";
String userName = "Anonymous";
// depending of the number of arguments provided we fall through
switch(args.length) {
// > javac Client username portNumber serverAddr
case 3:
serv... |
ea1fbe4e-5890-4dd9-aab9-382d84492098 | 3 | private void jbtnClose_ActionPerformed()
{
if (this.socket != null && ! this.socket.isClosed())
{
try
{
this.socket.close();
}
catch(Exception e)
{
EzimMain.showError(e.getMessage());
EzimLogger.getInstance().warning(e.getMessage(), e);
}
}
this.saveConf();
this.unregDispose();... |
2dc7b064-339a-4398-a5b1-d785a7f5233a | 8 | private void handleKeyPress(final int key) {
switch (key) {
case KeyEvent.VK_LEFT:
player.setDirection(Player.Directions.WEST);
break;
case KeyEvent.VK_UP:
player.setDirection(Player.Directions.NORTH);
break;
cas... |
c653af34-5315-4a0d-a532-8d93197f526c | 9 | public static void generateCaseRuleWoSlot(Vector cases, Symbol className, Symbol slotName) {
{ int numCases = cases.length();
Surrogate kind = Logic.getDescription(className).surrogateValueInverse;
List caseNames = List.newList();
Surrogate slot = Logic.getDescription(slotName).surrogateValueInver... |
65990000-16fa-44bf-b9da-6004855aace7 | 5 | public synchronized boolean commitReservation(ReservationMessage message) {
int resId = message.getReservationID();
ServerReservation sRes = null;
String msg = "Reservation # " + resId + " cannot be committed because it ";
// Tries to find the reservation in the lists
if(reservTable.conta... |
2171594a-2d7c-4cf1-b7a1-9419d46ea7f5 | 7 | public Card.Suit chooseSuit(Deck deck,
Card.Suit prevSuit,
PlayerHuman playerHuman) {
boolean shouldAvoid = false;
for (Card i : playerHuman.lastCards) {
if (playerHuman.cards.size() == 1
&& i != null && i.num() == 1)
shouldAvoid = true;
}
if (! shouldAvoid... |
f43b4628-18e6-41a0-9556-f315fe8dad80 | 1 | @Override
public int attack(double agility, double luck) {
if(random.nextInt(100) < luck)
{
System.out.println("I just rained hell fire!");
return random.nextInt((int) agility) * 2;
}
return 0;
} |
8716f617-358e-42d9-9e3a-eb1a34e0aa4a | 3 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Ship other = (Ship) obj;
// just use the type so that you can have only one type
// in a hash s... |
b4bb7f97-066f-4ed4-9939-d501e4bf4e5d | 0 | public void dispose() {
colorManager.dispose();
super.dispose();
} |
85e668d5-2b96-456d-95d1-5b59a5646473 | 7 | @Override
public void onUpdate(World apples) {
if (radius>=maxradius)
{
alive = false;
}
switch (apples.random.nextInt(5))
{
default:
case 0:
c = Color.red;
break;
case 1:
c = Color.orange;
... |
3788f587-7c26-4ec3-95fe-65ecbdfcaafd | 7 | private void LoadDocuments(String str, String filepath) throws IOException
{
str = str.replace("\n", " ");
str = str.replace("\r", " ");
String[] docs = str.split("</DOC>");
for (int i = 0; i < docs.length; i++)
{
String s = docs[i].trim();
if (s.length() > 0)
{
try
{
Document d = ... |
9f925e39-b27d-482b-bef9-273532e2fce8 | 1 | public void doGet(HttpServletRequest req,
HttpServletResponse res)
throws IOException, ServletException {
//first goal is to be able to receive and process
//a well formatted XML moveTwo piggybacked on a POST
//this gives me a raw stream to payload of Post requ... |
d5244920-50e8-4c84-bc97-df3e4d642515 | 3 | private void sendeAenderungenAnAlle() throws RemoteException
{
ArrayList<ClientPaket> paketListe = new ArrayList<ClientPaket>();
for(String name : _connectedClients.keySet())
{
paketListe.add(_spiel.packePaket(name));
}
for(ClientPaket paket : paketListe)
{
ClientInterface client = _connectedClients... |
716e281e-e1c4-4290-94d0-ec54bbafb37e | 1 | public String searchByName(final String name) throws IOException {
if (!notebookCache.containsKey(name)) {
return null;
}
return notebookCache.get(name).toString();
} |
b210bab1-d649-4e85-b6a5-31f5e6abb290 | 6 | private boolean method320(int i, int j, int k)
{
int l = anIntArrayArrayArray445[i][j][k];
if(l == -anInt448)
return false;
if(l == anInt448)
return true;
int i1 = j << 7;
int j1 = k << 7;
if(method324(i1 + 1, anIntArrayArrayArray440[i][j][k], j1 + 1) && method324((i1 + 128) - 1, anIntArrayArrayArray... |
3cbab25b-9f1e-4450-bd07-d918931bd7c4 | 1 | public static void startLoadingDataBase() {
Thread loadDB = new Thread(new Runnable() {
@Override
public void run() {
if (!Database.loaded)
EarningsTest.db = new Database(
EarningsTest.PATH_SOURCE.getText());
JComponentFactory.addReportsTab();
}
});
loadDB.start();
} |
c73c5d6e-ff37-4bbe-bebb-73a33d9a9b9b | 9 | private static XMPNode followXPathStep(
XMPNode parentNode,
XMPPathSegment nextStep,
boolean createNodes) throws XMPException
{
XMPNode nextNode = null;
int index = 0;
int stepKind = nextStep.getKind();
if (stepKind == XMPPath.STRUCT_FIELD_STEP)
{
nextNode = findChildNode(parentNode, nextS... |
65f768ad-60fc-48e4-ab5e-c0c27f9a5262 | 0 | public String getCp() {
return cp;
} |
ebea48ca-3862-4226-a387-e6bc5b6b50ab | 7 | public synchronized void handleEachAndClassAbility(Map<String, AbilityMapping> ableMap, Map<String,Map<String,AbilityMapping>> allQualMap, String ID)
{
if(eachClassSet == null)
{
eachClassSet = new SLinkedList<AbilityMapping>();
final Map<String,AbilityMapping> eachMap=allQualMap.get("EACH");
final Map<St... |
7669df28-d906-4df2-a39d-0785b03b6055 | 8 | void moveinterpret (String s, boolean fromhere)
{
StringParser p = new StringParser(s);
String c = p.parseword();
int p1 = p.parseint();
int p2 = p.parseint();
int p3 = p.parseint();
int p4 = p.parseint();
int p5 = p.parseint();
int p6 = p.parseint();
if (c.equals("board"))
{
PGF = new PartnerGo... |
fe6b16e7-ac18-445e-9bdb-3beab1fc9adf | 3 | public static void smoosh(int[] ints) {
// Fill in your solution here. (Ours is fourteen lines long, not counting
// blank lines or lines already present in this file.)
int inputlen=0;
if(ints!=null)
inputlen=ints.length;
int i;
for(i=(inputlen-1);i>0;i--){
if(ints[i]==ints[i-1]... |
76ed9296-c71e-4041-aacb-f84b39fc96ff | 7 | @Override
public void execute(HttpServletRequest request, HttpServletResponse response) {
String xmlPath = ResourceManager.INSTANCE
.getPropertyRealPath("xml_path");
String categoriesXsltPath = ResourceManager.INSTANCE
.getPropertyRealPath("categories_xslt");
String subcategoriesXsltPath = ResourceManage... |
d3374549-e247-42e7-b25d-9ce381eaaa27 | 7 | @Override
public void run() {
if (isFiltered) {
return;
}
StringBuilder builder = new StringBuilder();
builder.append(visitTime);
if (status == 200) {
builder.append(",").append("ok");
builder.append(",").append(requestUrl);
builder.append(",").append(requestMethod);
builder.append(",").app... |
802a3728-e087-400b-9048-fac3c42b0215 | 1 | public void usingKeySetAndIterator(Map<Integer, String> map){
Iterator<Integer> itr = map.keySet().iterator();
while(itr.hasNext()){
Integer intgr = itr.next();
System.out.println("Key: "+intgr);
}
} |
7ff8398c-2f3c-4f81-822a-ef45f0fe3ac8 | 6 | public static ArrayList<Planet> forPlanet(PlanetWars pw){
// Tested
ArrayList<Planet> asw = new ArrayList<Planet>(2);
asw.add(null);
asw.add(null);
// Find the biggest fleet to attack with
int maxShips = 0;
for (Planet p : pw.MyPlanets()){
if (p.NumShips() > maxShips){
maxShips = p.NumShips();
... |
007bbc84-af7d-438b-8c53-1fcb3d2cad29 | 1 | public boolean setSpeed(double vX, double vY) {
if (Buffer.findSprite(this) != null) {
Buffer.findSprite(this).setSpeed(vX, vY);
return true;
} else {
return false;
}
} |
72cd7143-d114-4bd6-92e4-65b075ac051b | 5 | public void run() {
if(isMaster) {
//wait for all participants, then initialize all files
loadConfig();
System.out.println("Waiting on all participants...");
int participants = Integer.parseInt(filesystem_config.get("participants"));
while (cServer.connections.size() < participants) {
try {
Th... |
3ed3ea1d-398c-45e5-9f0c-601329b8acc2 | 6 | public static void main(String args[]) {
List_Homework_database MList = new List_Homework_database();
/* 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... |
babc5c82-cdf2-495d-87e3-1a4540151177 | 9 | public int evalRPN(String[] tokens) {
Stack<Integer> ops = new Stack<>();
int eval = 0, op1 = 0, op2 = 0;
for(String token : tokens) {
if(token.equals("+") || token.equals("-") || token.equals("*") || token.equals("/")) {
op2 = ops.pop();
op1 = ops.pop... |
74712abd-5533-46bf-a6f3-8cf62de96d54 | 7 | public static void Command(CommandSender sender, String[] args)
{
if(sender.hasPermission("gm.creative.others"))
{
Player target = Bukkit.getPlayer(args[1]);
if(target != null)
{
if (target.getGameMode() != GameMode.CREATIVE)
{
target.setGameMode(GameMode.CREATIVE);
if(sender instanceof ... |
29008716-8e23-4965-8404-bccde2b45e1a | 8 | public void createChart()
{
pieChartModel=new PieChartModel();
setPriority("emerg");
Long emerg= getFacilityCount();
if(emerg!=0)
pieChartModel.set("Emergency", emerg);
setPriority("Alert");
Long alert= getFacilityCount();
if(alert!=0)
pieChartModel.set("Alert",alert);
setPriority("crit")... |
7187ce54-3720-4c7f-90c8-ff1cbc7bb88e | 4 | @BeforeClass
public static void init() {
snzipExecutable = TestUtil.findSnzipExecutable();
if(snzipExecutable == null) {
throw new IllegalStateException("No executable snzip file found in bin directory");
}
testdataDirectory = TestUtil.directoriesToFile("resources", "testdata");
if(!testdataDirectory... |
2b63c460-9ba5-464b-8f30-bba9636d016a | 7 | public void run() {
while(true){
try{
Thread.sleep(200);
}
catch(InterruptedException e){
}
Displayable curr = display.current;
if(curr instanceof Screen) {
Screen scr = (Screen) curr;
if(scr.ticker != null){
String t = scr.ticker.getString();
t = t.substring(ste... |
a4b0a4d2-26e3-4cf5-b1db-47439b5da39b | 9 | public boolean testReverse() throws PersistitException {
setPhase("b");
_ex.clear().append(Key.AFTER);
int index1 = _total - 1;
int index2;
while (_ex.previous() && !isStopped()) {
index2 = (int) (_ex.getKey().decodeLong());
for (int i = index1; i > index... |
855debb3-ca87-4524-97ae-5ea11ab2f35b | 4 | public static boolean insertar(Recurso r) throws SQLException {
// Deshabilitamos el autocommit para poder hacer rollback en caso de
// error en alguna inserción (tocamos varias tablas)
// ConnectionManager.connection.setAutoCommit(false);
// Al insertar un nuevo recurso este se marca ... |
2e1076f5-4f7a-4ed6-9099-491db689745e | 5 | private double run_model(Model model, List<Output> out, File folder, String simName, double[] x) throws Exception {
Map<String, Object> parameter = model.getParameter();
Object comp = model.getComponent();
// spatial params
ParameterData[] pd = Step.create(params, parameter);
f... |
ec9e3387-17be-4144-9f78-c83088827eab | 3 | static void setPlayerSelecting(String name, boolean b)
{
if(b){
if(!playersSelect.containsKey(name))
{
Location[] locarray = new Location[2];
playersSelect.put(name, locarray);
}
}
else
{
Protect.log.info("No more sel");
if(playersSelect.containsKey(name))
{
playersSelect.remove(name);
}
}
} |
f349b6a3-66d4-4093-bd1b-88ce54fadcbd | 5 | synchronized void backward(float[] in, float[] out){
if(_x.length<n/2){
_x=new float[n/2];
}
if(_w.length<n/2){
_w=new float[n/2];
}
float[] x=_x;
float[] w=_w;
int n2=n>>>1;
int n4=n>>>2;
int n8=n>>>3;
// rotate + step 1
{
int inO=1;
int xO=0;
... |
4a98abd4-7fda-4711-82fc-60aff4a20312 | 7 | public String[] Myself(boolean place)
{
try{
driver.get(baseUrl + "/content/lto/2013.html");
//global landing page
driver.findElement(By.xpath("/html/body/div[2]/div/div/div/div/div/div/div[3]/ul/li[10]/a")).click();
//Singapore landing page - Order Now button
driver.findElement(By.xpath("/... |
48c20600-075b-45be-b6d0-c1b24ee36b08 | 4 | private void initNetwork(String name, double baudRate, Link link)
{
// Every GridSim entity with network has its own input/output channels.
// Connect this entity "input" port to its input buffer "in_port"
NetIO in = null;
// Packet Level networking
if (GridSimCore.NETWORK_T... |
101a6b71-3844-4e9c-9da1-2cbfc794f192 | 8 | public void updateStaff(){
Scanner sc = new Scanner(System.in);
boolean bol = false;
do{
System.out.println("Enter the ID of the staff who need to be update:");
int employee_id = inputInteger();
Staff toUpdateStaff = staffManager.getStaffbyID(employee_id);
System.out.println("Choose which one to updat... |
fd031b9a-5f58-4f0d-be05-d73486bb84ec | 8 | @Override
@SuppressWarnings("unchecked")
public Object read(Class type, CommandInvocation invocation) throws ReaderException
{
if (invocation.getManager().hasReader(type))
{
return invocation.getManager().read(type, type, invocation);
}
if (Enum.class.isAssignable... |
1988905a-b21e-4bf1-9382-cd64b7501dad | 5 | public void resumeGame() throws InterruptedException {
boolean test = false;
if (test || m_test) {
System.out.println("Game :: resumeGame() BEGIN");
}
setWindow(new GameWindow(this));
setScores();
getWindow().displayPlayerTurn(m_playerTurn);
getWindow().updateScore(m_pl... |
e14dd774-c2aa-4351-9eee-82a6d15f3f62 | 7 | @Override
public boolean move(int x, int y, int xf, int yf) {
if (canMove(x, y)) {
for (int[] hint : getHints(x, y)) {
if ((xf == hint[0]) && (yf == hint[1])) {
//se arrivo in fondo, devo creare un damone
if (((xf == 0) || (xf == 8 - 1)) &&... |
ffa82405-813b-4b1e-8c3d-e4d0a4d50edc | 2 | private List<Position> getAdjacentPositions(Position pos, int width, int height) {
ArrayList<Position> neighbours = new ArrayList<Position>();
for (Direction mov : Direction.values()) {
Position newPos = mov.newPosition(pos);
if (isValidPosition(newPos, width, height)) {
neighbours.add(newPos);
}
}
... |
270dd70a-81cb-4300-9753-a622effee77c | 3 | private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
Transferable clipboardContent = getToolkit().getSystemClipboard().getContents(this);
if ((clipboardContent != null)
&& (clipboardContent.isDataFlavorSupported(DataFlavor.stri... |
1344b116-fe0c-448b-ae59-17faee649bdd | 2 | private void log(String prefix, String message)
{
String log = buildMessage(prefix, message);
System.out.println(log);
if (outputStream != null)
{
try
{
outputStream.write((log + "\r\n").getBytes());
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace... |
3b784ad7-a17f-4f98-b3e0-f70a20bb6884 | 2 | public Object trapMethodcall(int identifier, Object[] args)
throws Throwable
{
try {
Method[] m = getReflectiveMethods();
return m[identifier].invoke(null, args);
}
catch (java.lang.reflect.InvocationTargetException e) {
throw e.getTargetException... |
8f43bf6d-0077-496a-a788-992d62042b41 | 2 | @Override
protected void finalize() {
if (resource.removeReference() && !fileName.isEmpty()) {
loadedTextures.remove(fileName);
}
} |
123f48ea-d1cd-48a4-9637-0d98e82e3c3a | 0 | public String getKeyName() {
return this.value;
} |
06ecb430-f0bc-4c14-9c31-a978ad09dac8 | 7 | public void populateLibrary(int numSpecies, int numNodes, int numBondingSites){
Molecule nullMolecule = new Molecule();
if(!reuse){
library.add(new Network(0));
for(int i=1; i<numSpecies; i++){
library.add(new Network(numNodes, i, numBondingSites));
library.get(i).setMol(ne... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.