method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
f2d6dacb-382f-4e0f-bba5-d1b4bcbe9f60 | 8 | public int findNearestBondIndex(int x, int y) {
if (modelManager.frame == null)
return -1;
Bond[] bonds = modelManager.frame.bonds;
if (bonds == null)
return -1;
int bondCount = modelManager.frame.bondCount;
if (bondCount <= 0)
return -1;
int xA, yA, zA, xB, yB, zB;
double distSq;
float width;
... |
1503bf27-52ce-4dca-90ec-d292986dde39 | 0 | public int getEventId() {
return eventId;
} |
2535d539-8561-4c56-8046-bc640941b92d | 0 | public void setCurrentMap(int map){
this.currentMap = map;
} |
c6bd3d6d-099f-49d8-bbb8-f1a5125a2dd9 | 1 | public double getUserBalance(String uid) {
Node userNode = getUserNode(uid);
if (userNode != null) {
NamedNodeMap attr = userNode.getAttributes();
Node nodeAttr = attr.getNamedItem("balance");
return Double.parseDouble(nodeAttr.getTextContent());
} else {
... |
eba9990d-f90c-4ded-8aa9-2f53bad707f5 | 8 | public static void main(String[] args) throws Exception {
br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
int T = readInt();
while (T-- > 0) {
N = readInt();
int M = readInt();
map = new boolean[... |
14f036f0-c8a6-49c0-a594-82c58937eaf5 | 4 | public static Pokemon useTMHM(Pokemon selectedPokemon, Item item)
{
if (!hasItem(item))
return selectedPokemon;
if (item.effect1 == Item.Effect.TM || item.effect1 == Item.Effect.HM)
{
selectedPokemon = Mechanics.teachMove(selectedPokemon,item,moveNo);
if (!itemCancel)
decrementItem(item);
else
... |
44ac1e40-64f7-4c5e-84d6-8c25b28290a3 | 8 | public boolean removePop(StructuredBlock last) {
/*
* There are three possibilities:
*
* PUSH method_invocation() POP[sizeof PUSH] to: method_invocation()
*
* With java1.3 due to access$ methods the method_invocation can already
* be a non void store instruction.
*
* PUSH arg1 PUSH arg2 PO... |
d6016dcb-5e95-41d2-ae75-af9dc18710ff | 7 | private String readUTF(int index, final int utfLen, final char[] buf) {
int endIndex = index + utfLen;
byte[] b = this.b;
int strLen = 0;
int c;
int st = 0;
char cc = 0;
while (index < endIndex) {
c = b[index++];
switch (st) {
c... |
c750e69b-d2d0-401a-a77d-4765fc089000 | 1 | public void store() {
String content = HTML.formatXML(XML_HEADER + rootElement);
Path path = FileSystems.getDefault().getPath(".", FILENAME);
try {
Files.write(path, content.getBytes(), StandardOpenOption.CREATE,
StandardOpenOption.TR... |
d74aa437-6860-4c2a-a3f1-8819e6fba658 | 6 | @Override
public void onEndPage(PdfWriter writer, Document document) {
boolean HeaderEnable = false;
boolean FooterEnable = false;
//Controllo se devo impostare l'header
for (int i = 0; i < this._MyHeaderItemList.size(); i++) {
HeaderEnable = ((HeaderEnable) || (this._M... |
fe87b922-979b-4ef5-bd52-fca32f224774 | 5 | public static List<Laureate> filterByLivingYearRange(
List<Laureate> inputList, String startYear, String endYear) {
List<Laureate> outputList = new ArrayList<Laureate>();
int sYear = Integer.getInteger(startYear);
int eYear = Integer.getInteger(endYear);
// parse input, kee... |
339eccc5-6656-494e-97ca-70627c63b7ba | 9 | public int maximalRectangle(char[][] matrix) {
int rows = matrix.length;
if (rows == 0) {
return 0;
}
int cols = matrix[0].length;
//create histogram matrix
int[][] histogram = new int[rows][cols];
int max = 0;
for (int i = 0; i < rows... |
3cf69b1f-21ab-4cbb-9d7b-ac6bf4a0f159 | 3 | @Override
public Status execute(String command) throws MenuException {
switch (command) {
case "E":
difficulty = "E";
break;
case "M":
difficulty = "M";
break;
case "H":
difficulty = "H";
... |
fce14c12-98ee-4e67-93b9-c1b3b62166c9 | 2 | @Override
public Object getAsObject(FacesContext fc, UIComponent uic, String value) {
if(value != null && value.trim().length() > 0) {
Long id = Long.parseLong(value);
return dao.Abrir(id) ;
}
else {
return null;
}
} |
bcff6783-3b43-4d2c-86fd-3d012303bb74 | 9 | public static String getMouseName(int mouseCode) {
switch (mouseCode) {
case MOUSE_MOVE_LEFT: return "Mouse Left";
case MOUSE_MOVE_RIGHT: return "Mouse Right";
case MOUSE_MOVE_UP: return "Mouse Up";
case MOUSE_MOVE_DOWN: return "Mouse Down";
case MOUSE... |
4d0deb86-6486-4adb-8d01-abb9dacf19bd | 2 | public void setMinCount(int newMin) {
if (headCount < newMin) {
GlobalOptions.err
.println("WARNING: something got wrong with scoped class "
+ clazzAnalyzer.getClazz() + ": " + newMin + ","
+ headCount);
new Throwable().printStackTrace(GlobalOptions.err);
headMinCount = headCount;
} else... |
7b7d2f27-371a-4d80-b1c5-7c3ae4736a1d | 4 | private void placeLives(int count) {
Random rand = new Random();
while (count > 0) {
int pos = rand.nextInt(WIDTH_FIELDS * HEIGHT_FIELDS);
IField field = fieldsMatrix[pos / WIDTH_FIELDS][pos % WIDTH_FIELDS];
if (field.getType().equals("building") && !field.hasLife()
&& !field.hasAmmo()) {
field.... |
bafc1679-0be6-4b29-b963-538f7b576e62 | 6 | public void performAction() {
if (isConnected()) {
boolean first = getOutput()[0].getStatus();
if (this.isTurnedOn() && inputAction==1) {
if (getInput()[0].getStatus()) {getOutput()[0].setStatus(true);}
else {getOutput()[0].setStatus(false);}
}
else {
... |
832b5547-a5b3-4f6c-aa44-6dcfa6f2e45b | 0 | @Override
public void setValue(Object o) {
// property of this frame must have data type Long
this.playCounter=(Long)this.convertObject(o);
} |
b219011e-d4a2-482a-bf17-1716f074c169 | 8 | final void method3643(Canvas canvas, int i, int i_177_) {
do {
try {
anInt7544++;
if (aCanvas7626 == canvas)
throw new RuntimeException();
if (aHashtable7577.containsKey(canvas))
break;
if (!canvas.isShowing())
throw new RuntimeException();
try {
Class var_class = Class.forName("... |
807a8a32-14e8-41ac-bcd9-6666920abe62 | 2 | public void sendMessage(String message) {
try {
_remoteObj.sendMessage(_username, _receiver, message, ServerInterface.CLIENT);
} catch (RemoteException e) {
if(connect()) {
sendMessage(message);
return;
}
System.out.println("Error while sending message");
}
} |
f737157f-0a40-4005-9f42-409bfd436a02 | 9 | public final void atributos() throws RecognitionException {
try {
// fontes/g/CanecaSemantico.g:228:2: ( ^( ATRIBUTOS_ ( atributo )* ) )
// fontes/g/CanecaSemantico.g:228:4: ^( ATRIBUTOS_ ( atributo )* )
{
match(input,ATRIBUTOS_,FOLLOW_ATRIBUTOS__in_atributos690);... |
d2e82352-0871-4a88-a45b-2f33018fc685 | 3 | public AnimMissile(float width, float height, float size) {
anim_missile = new Animation();
SpriteSheet sp_fire = null;
try {
sp_fire = new SpriteSheet("resources/blue_fire_ball.png", 81, 46,
new Color(0, 0, 0), 1);
} catch (SlickException e1) {
e1.printStackTrace();
}
in... |
6f3d5a19-244f-4700-9fa8-17b4fce1ea34 | 5 | public <T> T connect(Class<T> serviceInterface) throws IOException {
if (!serviceInterface.isInterface()) {
throw new IllegalArgumentException("serviceInterface must be of interface type!");
}
try {
socket = new Socket(this.serverHost, this.serverPort);
output... |
1c27342d-7d9e-4474-a95f-e81b1270f6c6 | 4 | protected void fixBlock( Point pos, short[][] block, byte imageNo ) {
for ( int y = 0; y < Block.MAX_Y; y++ ) {
for ( int x = 0; x < Block.MAX_X; x++ ) {
if ( block[ y ][ x ] == 1 ) {
if ( pos.y + y < 0 ) {
continue;
}
_grid[ pos.y + y ][ pos.x + x ] = 1;
_grid... |
c812d54f-c16e-4c79-830b-db01f59effaf | 6 | public static void GetFieldValue(Persistent obj, Field field, Object nodeValue, String subscript, NodeReference node)
{
Object fieldAsObj = null;
try {
fieldAsObj = field.get(obj);
if (Persistent.class.isAssignableFrom(field.getType()))
{
Persistent fieldAsPersistentObject;
try {
... |
6ca7ee0a-1e65-4b6f-b93f-c31edf0702fb | 6 | public void breadthFirstTraversal(){
LinkedQueueClass<Integer> queue =
new LinkedQueueClass<Integer>();
boolean[] visited;
visited = new boolean[gSize];
for (int ind = 0; ind < gSize; ind++)
visited[ind] = false; //initialize the array
... |
63672dc7-be57-429b-9721-fc1cc57a35aa | 8 | public Problem(DataBean newDB) {
startTime = System.currentTimeMillis();
switch (newDB.alg) {//determine algorithm to run
case 1:
reachedGoal = DepthFirstSearch(newDB.initState);
break;
case 2:
reachedGoal = BreadthFirstSearch(newD... |
7e0ca8b5-498e-4cdc-8318-18b06919774f | 7 | public static void main (String args[]) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String line = reader.readLine();
int number = Integer.parseInt(line);
line = reader.readLine();
StringTokenizer st = new StringTokenizer(line);
Queue<String>[] queueNumb... |
27024ad7-0dd3-4f2f-a84e-a530106e1c87 | 6 | public static void main(String[] args)
{
CrazyProblem problem = new CrazyProblem();
// 1) Change default settings as needed
Genejector.getSettings().setScoreLimit(2);
Genejector.getSettings().setPopulationSize(500);
// [ListingStart][L1]
Genejector.getSettings().addClass("genejector.examples.CrazyKeyring"... |
dfa9965d-ca8f-4919-8532-7ad1863ed18a | 6 | public void checkCollision(GameObject object) {
// check with other game objects
if (!object.dead) {
for (GameObject otherObject : objects) {
if (!(object instanceof Asteroid && otherObject instanceof EnergyShield)) {
if (object.hittable(otherObject)
... |
989857cf-9516-4d97-8df1-f25b3512eda7 | 1 | private int score(int[] bowl){
int sum=0;
for(int i=0;i<12;i++){
sum+=pref[i]*bowl[i];
}
return sum;
} |
e454a6a6-4e1f-4fbd-833a-59fce0bfb4cc | 3 | public static void main(String[] args) {
SendPromotionMail sendPromotionMail = new SendPromotionMail();
Facade facade = Facade.getInstance();
Client client1 = new Client("Diego", "111", "diego.so@dce.ufpb.br", 28,
10, 1988);
Client client2 = new Client("Diego2", "222", "diego.sou@dce.ufpb.br",
29, 10,... |
f34b77b7-3194-4612-9575-80b305370358 | 7 | public void keyTyped(KeyEvent keyEvent) {
Iterator<PComponent> it = components.iterator();
while (it.hasNext()) {
PComponent comp = it.next();
if (shouldHandleKeys) {
if (comp.shouldHandleKeys())
comp.keyTyped(keyEvent);
}
... |
9fee9d6d-c167-452f-8b49-d6addc5373a9 | 1 | private boolean jj_3R_29() {
if (jj_3R_77()) return true;
return false;
} |
f1988c89-a887-439c-b618-f90c0b7b8b1e | 7 | public void updateZoomMap(int zoomCell){
BufferedImage[] images = new BufferedImage[19];
images[0] = determineImage(zoomCell);
for (int k = 0; k < 6; k++){
images[k+1] = determineImage(match.getWorld().getNeighborCell(match.getWorld().getCell(zoomCell), k).getCellID());
Cell interCell;
switch(k){
... |
2eaaa352-f5fd-4e54-a098-9f591cff0365 | 1 | public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
try {
Crossfire window = new Crossfire();
window.frmCrossfire.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
} |
ab4452da-1884-4a31-9a70-c45dd7d86182 | 3 | @Override
public void update(GameContainer container, int delta) throws SlickException
{
Input input = container.getInput();
player1.move(input, walls, delta);
if (input.isKeyDown(Input.KEY_ENTER))
{
SendText();
}
send(player1.getUpdate());
... |
35c1ca97-f0d4-42ed-99b4-3d48b1a165c6 | 5 | public String getLastSheetName()
{
String sheetname = this.sheetname; // 20100217 KSC: default to 1st sheet
if( parent_rec != null )
{
WorkBook wb = parent_rec.getWorkBook();
if( (wb != null) && (wb.getExternSheet() != null) )
{
String[] sheets = wb.getExternSheet().getBoundSheetNames( ixti );
... |
4f27990f-e1cb-4e62-808e-946e7e459c09 | 5 | private void collectNumbers()
{
mNumbers.clear();
mNumberId = 0;
TileValue value;
final int size = mField.getWidth() * mField.getHeight();
for (int tile = 0; tile < size; tile++ )
if (mField.getMaskValue(tile).isOpen())
{
value = mField.getTileValue(tile);
if ( !value.isBomb() && !value.isEmpty... |
59af061c-da70-4e3e-83b6-f35377f26b57 | 1 | public Mysql(){
/*
* kanei thn sundesh me thn vash sthn dimiourgia tou antikeimenou
*/
try{
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/askisi9?useUnicode=true&characterEncoding=UTF-8&";
conn = DriverManager
.getConnection(url
+ "use... |
bc0d2713-6e9a-4908-afd2-17d4f96b36f7 | 4 | private static String getSetString(String s) {
if (s == null)
return "{ }";
StringBuffer sb = new StringBuffer("{ ");
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '!')
c = Universe.curProfile.getEmptyString().charAt(0);
sb.append(c);
if (i != s.length() - 1)
sb.appe... |
f6cfcf45-8637-4698-951d-a8deb3db4062 | 0 | private boolean isBundle() {
// only need the first 7 to check if it is a bundle
String bytesAsString = new String(bytes, 0, 7);
return bytesAsString.startsWith("#bundle");
} |
c422818f-0d4a-43d6-b083-2bbf88402479 | 5 | public String submit() {
// Calculate and save the ship date
int days = Integer.valueOf(shippingOption).intValue();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_MONTH, days);
setShipDate(cal.getTime());
if ((cart.getTotal() > 100.00) && !specialOffer.is... |
ef7206ea-cb0b-4ffc-bca3-5024e2d75cb7 | 6 | @Override
public String[] extend(String basePreAlign, String basePostAlign, String extend, String[] table) {
ArrayList<Integer> inserts = new ArrayList<Integer>();
char[] basePost = basePostAlign.toCharArray();
char[] basePre = basePreAlign.toCharArray();
int j = 0;
for(int i... |
198c1c3c-2fd7-4509-aad6-121ded4b4287 | 6 | public static void cleanUp() throws InterruptedException
{
boolean success = false;
int loop = 0;
traceln(STDOUT, DEBUG, "Cleaning...");
if( DOWNLOADS_TMP_DIRECTORY.exists() )
{
do {
success = FileUtils.recursiveDelete(Settings.DOWNLOADS_TMP_DIRECTORY);
Thread.sleep(50);
} while( success ... |
7d850462-2861-4cc4-9041-6acf92f30f5c | 9 | @Override
public void run() {
boolean done = false;
int waitTime = 500;
try {
Packet pack = new Packet("GETCHUNK", "1.0", fileID, chunkNo, 0, null, null);
DistributedBackupSystem.cManager.sendPacket(pack, CommunicationManager.Channels.MC);
do {
try {
Thread.sleep(waitTime);
} catch (In... |
bdd1c3bc-95ab-4f1f-9397-68485ebda8d9 | 1 | @Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
} |
71d5a2a8-8ded-4636-9d5b-5fdb0586e6ab | 0 | public Iterator getLoopedOpenDocumentIterator() {
return getOpenDocumentIterator(indexOfOpenDocument(mostRecentDocumentTouched));
} |
e52c5b6f-34df-4294-980c-df87e4eb5366 | 8 | private static String getStep(PathCell start, PathCell end,boolean isPushingBox){
if(end.getRow()-start.getRow()<0){
return isPushingBox?"N":"n";
}else if(end.getRow()-start.getRow()>0){
return isPushingBox?"S":"s";
}
if(end.getColumn()-start.getColumn()<0){
return isPushingBox?"E":"e";
}else i... |
d7baf6b0-dbf1-4db8-8144-3e1a49ee0856 | 5 | public ArrayList<String> get_result_statement(StringBuilder sb) {
// Get Result From Each Block And Add Into An ArrayList, Update DB
Pattern p4 = Pattern
.compile(
"(/750)|((RESULT:)(.*?)\\.\\s\\.\\s\\.)|((RESULT: )((.*?)ORDN))|(/700)|((Result : )((.*?)\\s{5}))",
Pattern.DOTALL);
Matcher m4 = p4.m... |
f8189655-cc3b-42f4-982a-589d1c462ef8 | 7 | @Test
public void testCalculateSunVector() {
final TLE tle = new TLE(LEO_TLE);
Assert.assertFalse(tle.isDeepspace());
final Satellite satellite = SatelliteFactory.createSatellite(tle);
DateTime timeNow = new DateTime("2009-06-01T00:00:00Z");
for (int day = 0; day < 30; day++) {
final SatPos satPos = ... |
866b4176-8a0c-4be7-84f4-d956d39be834 | 7 | public void waitUntil(boolean v) throws InterruptedException{
// wait only if the value is not already v
if (value != v){
// set the until value (field) to v
until_value = v;
// mark waiting
waiting = true;
// recheck the condition
if (value != v){
// wait while the wait flag is true... |
c888c6ea-fb7b-4c09-8e7d-a2b2863679ca | 0 | public void setPrpFecmod(Date prpFecmod) {
this.prpFecmod = prpFecmod;
} |
5376e0e3-2303-4e52-b0f8-96b6d0ed7ce4 | 4 | public static void insertSort(int[] array) {
for (int j = 1; j < array.length; j++) {
int key = array[j];
int i = j - 1;
while (i >= 0 && array[i] > key) {
array[i + 1] = array[i];
i--;
}
if (i != j - 1) {
array[i + 1] = key;
}
}
} |
0a71ec02-6830-4b1d-93f4-f4e5b95043f3 | 9 | public boolean effectiveBooleanValue(XPathContext context) throws XPathException {
int count = 0;
SequenceIterator iter = operand.iterate(context);
while (true) {
Item item = iter.next();
if (item == null) {
break;
}
if (item instan... |
0e45ccb3-a772-4c90-a33e-5dfb754509d5 | 3 | public void visitInnerClass(final String name, final String outerName,
final String innerName, final int access) {
cp.newUTF8("InnerClasses");
if (name != null) {
cp.newClass(name);
}
if (outerName != null) {
cp.newClass(outerName);
}
if (innerName != null) {
cp.newUTF8(innerName);
}
cv.visi... |
67e5f834-1b67-492e-b890-b3379fb5d18b | 2 | public void solve() {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
BigInteger[] a = new BigInteger[50];
a[0] = BigInteger.ZERO;
a[1] = BigInteger.ONE;
for (int i = 2; i < a.length; i++) {
a[i] = a[i - 1].add(a[i - 2]);
}
BigInteger res = BigInteger.ZERO;
for (int ... |
db100761-523c-468e-b4d1-b29bc4ad1aed | 8 | public void initEngineAndBuffers() throws NoSuchAlgorithmException,
KeyStoreException, KeyManagementException, SSLException,
IOException {
if (mode == FTPConnection.AUTH_SSL_FTP_CONNECTION
|| mode == FTPConnection.IMPLICIT_SSL_FTP_CONNECTION)
context = SSLCont... |
bf2e5f43-8384-4a7b-ad8c-35d878679e1e | 8 | public double[] getMinMax(){
double min = Double.MAX_VALUE;
double max = -Double.MAX_VALUE;
if(multiTrace)
{
for(int i = 0;i<multiColumnData.length;i++)
{
ArrayList<Double> l = (ArrayList<Double>)multiColumnData[i];
for(double d : l... |
526da88c-9004-4e00-89c7-6483793ca3ca | 3 | private int select( int maxEingabe )
{
int eingabe = -1;
while ( eingabe < 0 || eingabe > maxEingabe )
{
Anzeige.zeigeStringAn( "Auswahl eingeben:" );
try
{
eingabe = Integer.parseInt( getEingabe() );
}
catch ( NumberFormatException nfEx )
{
System.out.println( "Es wurde keine Zahl eing... |
3636cc22-6225-476c-8fdc-96c8387f6d9e | 7 | public Instances[] getEnsembleTrainingData(Instances classInstances, int noOfClasses) {
DoubleVector weights = new DoubleVector();
Instances[] resultData = new Instances[NoOfClusters];
ArrayList attList = Collections.list(classInstances.enumerateAttributes());
attList.add(classInstances.... |
6e92ccd2-c25b-4e91-89be-fcfac1d6c9dd | 1 | public int getLeftmostData( )
{
if (left == null)
return data;
else
return left.getLeftmostData( );
} |
335cd776-303e-4c23-bb22-451893a7b7f9 | 2 | public static boolean deleteInfo(String title){
boolean flag=false;
try{
contct=connector.getConnection();
Sttt=contct.prepareStatement("delete from bk where title ='"+title+"'");
if(Sttt.executeUpdate()==1)flag=true;
}catch(SQLException e){
System.out.println(e.getMessage());
}
connector... |
d6f39ae2-ef9f-4da1-807d-51232d931c14 | 7 | private static HashMap<Integer, Holder> getMap(File file, int dataColNum) throws Exception
{
HashMap<Integer, Holder> map = new HashMap<Integer, Holder>();
BufferedReader reader = new BufferedReader(new FileReader(file));
reader.readLine();
for(String s = reader.readLine(); s != null && s.trim().length()... |
c703224f-9c04-4f41-aacd-ed47f784370c | 0 | @Override
public void componentMoved(ComponentEvent arg0) {
// TODO Auto-generated method stub
} |
cc12de6f-a33f-4e9a-9887-15ffcddd5e82 | 2 | @Override
public void onMessage( String message )
{
System.out.println( "SERVER: " + message );
ServerUser u = currentClient.attachment();
if (u == null)
{
currentClient.close();
}
else
{
for (ServerUser otherUser : userMap.values(... |
4d66bff9-8e9c-4217-bbb8-90f0a89a14b9 | 0 | public ConsoleTools() {} |
0c31657e-64e6-4641-949c-4fe87902932d | 8 | private int determineSquareKey(final int xPosition, final int yPosition) {
final List<Vehicle> groundVehicles = map.getGroundlevelVehicles(xPosition, yPosition);
final List<Vehicle> skyVehicles = map.getSkylevelVehicles(xPosition, yPosition);
switch (map.getType(xPosition, yPosition)) {
case SEA:
if (grou... |
59d051e9-cfb8-4b69-aa7f-783b88c0669c | 9 | @Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) {
// We're not interested in the postprocessing round.
return false;
}
Set<? extends Element> rootElements = roundEnv
.getElementsAnnotatedWith(Serializ... |
4d138c4d-b1f4-4c78-8954-b2b008267754 | 3 | public ArrayList<String> letterCombinations2(String digits) {
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
HashMap<Integer, ArrayList<String>> map = new HashMap<Integer, ArrayList<String>>();
for (int i = 2; i <= 6; ++i) {
char b... |
b71638b2-6211-48f7-b4d8-f5330846ff34 | 1 | public void update(long deltaMs) {
onCurrentFrame += deltaMs;
if(onCurrentFrame >= frameDelay) {
currentFrame++;
currentFrame %= frames.size();
onCurrentFrame = 0;
}
} |
f69df213-1f49-4ffe-ab85-d0490765c4f1 | 0 | @Test
public void testGetRad() {
System.out.println("getSumm");
assertEquals(1.0, new Cylinder(3,1,2.8).getRad(), 0.00001);
} |
fc1df4ba-575b-418d-a3a4-7cb48bde1786 | 6 | public static Serializable getObject(byte[] data) {
if (data == null) {
return null;
}
ObjectInputStream readS;
Serializable c;
try {
readS = new ObjectInputStream(new ByteArrayInputStream(data));
c = (Serializable) readS.readObject();
... |
36b4acc9-fe13-49ec-b700-72dedb4235bb | 0 | @Override
@XmlElement(name="vorname")
public String getVorname() {
return this.vorname;
} |
035aa669-e23e-4d7d-b29f-63cd5eebd3fc | 5 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if (obj.getClass() == ProductoCantidad.class) {
ProductoCantidad p = (ProductoCantidad) obj;
if (codigo == p.getProduct... |
ef83e72f-a4fd-4cc5-b169-cece1fb7b7f5 | 4 | private void doUpdateCY(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String chengYuanId = StringUtil.toString(request.getParameter("chengYuanId"));
if(!StringUtil.isEmpty(chengYuanId)) {
boolean isSuccess = true;
// ObjectMapper... |
b94eed65-cf8d-4613-bdca-f91186522b6b | 2 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
RequestDispatcher rd;
HttpSession session = request.getSession();
String eventId = request.getParameter("eventId");
int seatRequested = Integer.parseInt((String)request.getParameter("noOfTic"))... |
4369a346-973a-4fa6-aaca-75a58f57ef5a | 9 | private boolean findDepthSanityCheck(){
ArrayList<InputNeuron> inputs=findInputs();
ArrayList<OutputNeuron> outputs=findOutputs();
for(int i=0;i<inputs.size();i++)
if(inputs.get(i).getDepth()!=0){
System.out.println("Input depth not right");
return fal... |
db29083a-a6db-4ef8-a857-5f4871568d31 | 1 | private Text getField(String key) throws IOException {
try {
return new Text(next.getString(key));
} catch (JSONException ex) {
throw new IOException(ex);
}
} |
f63fd843-9a5c-4740-b589-69269f0c14a8 | 4 | void computeDisplayTexts (GC gc) {
if ((parent.getStyle () & SWT.VIRTUAL) != 0 && !cached) return; /* nothing to do */
int columnCount = parent.columns.length;
if (columnCount == 0) return;
for (int i = 0; i < columnCount; i++) {
gc.setFont (getFont (i, false));
computeDisplayText (i, gc);
}
} |
b597bb69-e86e-46c2-b0f9-6f68570f4c0b | 9 | @Override
public void run() {
Wrapper obj;
synchronized (this) {
while (true) {
if (que.isEmpty()) {
try {
System.out.println("start to wait");
wait();
} catch (Interr... |
460d95e8-4da0-491a-80d7-4be5828755ba | 8 | @Override
public String getToolTipForCell(Object cell)
{
String tip = "<html>";
mxGeometry geo = getModel().getGeometry(cell);
mxCellState state = getView().getState(cell);
if (getModel().isEdge(cell))
{
tip += "points={";
if (geo != null)
{
List<mxPoint> points = geo.getPoints();
... |
44322c65-9f35-4082-8c93-a1312b9c9c03 | 8 | static int entrance(List<Point> points,int k){
int size=points.size();
Map<String,Integer> indexHash=new HashMap<>();//坐标hash
Map<String,Point> pointHash=new HashMap<>();//point hash
for(int i=0;i<size;++i){
Point p=points.get(i);
indexHash.put(p.x+","+p.y,i);
... |
b6abc120-191c-4594-89fa-1a5c75c2b2a5 | 1 | private void startTimer()
{
btnCancel.setEnabled(true);
btnStart.setEnabled(false);
model.setTime(getTimeFromSPinners());
recentList.addItem(getTimeFromSPinners());
recentList.saveItems();
updateRecentMenu();
timer.start();
timeDirection = 0;
i... |
59256e92-dec9-486f-bfa7-a6795804446a | 5 | public static void main(String [] args) {
// assuming that 1-1-2 is not a triangle, (2-2-1 is not an AET) so starting with 2-2-3
long cumulativePerim = 0;
int countOfAETris = 0;
for (int i = 1; i < ((long) (1000000000/3)+2); i++) { // sloppy, see *** below
int j = i + 1;
double area = 0.0;
boolean i... |
8b53a94e-f0f1-4d88-960c-e3a682dcbeaa | 9 | public void update(Observable observable, Object change) {
if (observable instanceof Board && change instanceof Turn) {
// A turn was had - was it by our player's team?
Turn turn = (Turn) change;
if (turn.getTeam() == player.getTeam()) {
if (turn instanceof Pass)
addPassText();
... |
dbd51910-4df8-4657-a200-b5e8676b52e9 | 8 | public void run() {
Socket s = null;
try {
s = ss.accept();
DataInputStream dis = new DataInputStream(s.getInputStream());
DataOutputStream dos = new DataOutputStream(s.getOutputStream());
model.addPlayer("Fred");
while (true) {
// read commands and return random response
char c = (char)dis.r... |
55225848-f334-46ee-b0b1-90b21675864b | 7 | @Override
public void run() {
double unprocessedTicks = 0.0;
double nsPerTick = 1000000000.0/tps;
double unrenderedFrames = 0.0;
double nsPerFrame = 1000000000.0/fps;
long lastTime = System.nanoTime();
long lastFpsTime = System.currentTimeMillis();
... |
1acd5209-6099-4659-b92a-28eb0c6f55cd | 5 | private static int getCharWidth(char c) {
int charWidth = 6;
if(width5.indexOf(c) >= 0) {
charWidth = 5;
}
if(width4.indexOf(c) >= 0) {
charWidth = 4;
}
if(width3.indexOf(c) >= 0) {
charWidth = 3;
}
if(width2.indexOf(c) >= 0) {
charWidth = 2;
}
if(width1.indexOf(c) >= 0) {
charWidth =... |
49b54d30-7a4d-45b1-911c-d1ebdee279d7 | 7 | private void nextRun() throws IOException {
out.setLength(0);
type = null;
token = null;
int c = in.peek();
if (c == -1) {
type = Type.END;
return;
}
clearSpace();
c = in.peek();
if (c == -1) {
type = Type.EN... |
c6a09159-0761-4262-95ad-874c162a1b50 | 4 | @Override
public String askForNewGame() {
HttpGet request;
try {
request = new HttpGet(new URI("http", null, SERVER, PORT, NEW_URL, null,
null));
} catch (URISyntaxException e1) {
throw new RuntimeException(e1);
}
HttpResponse response;
try {
response = client.execu... |
33330df9-2ebb-4bf3-8f2b-568e9dd5c768 | 6 | public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)
tree.getLastSelectedPathComponent();
if (node == null) return;
Object nodeInfo = node.getUserObject();
if (node.isLeaf()) {
BookInfo book = (Bo... |
6d8bbcd1-74e7-4e6d-9cb2-13fa264b4cc7 | 8 | static String toHex8String(int pValue)
{
String s = Integer.toString(pValue, 16);
//force length to be eight characters
if (s.length() == 0) {return "00000000" + s;}
else
if (s.length() == 1) {return "0000000" + s;}
else
if (s.length() == 2) {return "000000" + s;}
else
if (s.lengt... |
ca865bb1-ef3e-4ad7-a0f5-9b3cb817c8da | 0 | public Object clone() {
return new Matrix(this);
} |
95d94fbc-395f-4fed-8014-4d4303c7e7d8 | 3 | public static void main(String[] args) {
// TODO Auto-generated method stub
int[] src = {7,6,8,3,4,5,3,2,1,8,9};
int start = 0;
int end = src.length-1;
int index = patition(src,start,end);
int k =4;
while( index != k){
if(index > k){
end = index - 1;
index = patition(src,start,end);
}else{
... |
3dbe7605-f363-4fdd-b5a9-6007c49c744a | 7 | private LinkDecor getDecors2(String s) {
// System.err.println("s2=" + s);
if (s == null) {
return LinkDecor.NONE;
}
s = s.trim();
if ("|>".equals(s)) {
return LinkDecor.EXTENDS;
}
if (">".equals(s)) {
return LinkDecor.ARROW;
}
if ("^".equals(s)) {
return LinkDecor.EXTENDS;
}
if ("+".e... |
022acf4f-9c2a-4501-bc06-e86175e33707 | 5 | public static int[] maxIndex(double[] __array) throws Exception {
ArrayList best_list = new ArrayList();
double best_val=Double.NEGATIVE_INFINITY;
double val;
int[] RET;
int _MAX = __array.length;
for (int i=0; i < _MAX; i++) {
val = __array[i];
i... |
e7fe27b6-0219-46c7-af50-59338a789b4e | 7 | public ComponentState getState(){
CTaskState state = cTaskContext.getTaskState();
if(state.equals(CTaskState.CInit))
return ComponentState.INIT;
else if(state.equals(CTaskState.CPreOperational))
return ComponentState.PRE_OPERATIONAL;
else if(state.equals(CTaskState.CFatalError))
return ComponentState.F... |
34378e44-e77d-4b26-b69a-b9e8ccd4d495 | 1 | public void inicio(InstituicaoCooperadora instituicaocooperadora)
throws Exception
{
salvar = new JButton("Salvar");
id = new JTextInt(instituicaocooperadora.getId());
id.setEditable(false);
id.setEnabled(false);
nome = new JTextField(instituicaocooperadora.getNome() == null ? ""
: instituicaocooperad... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.