method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
5a863794-7a4b-4b88-bfff-8cc010ec0abf | 9 | private void determineNextPosition() {
boolean positionReturned = n != 0;
do {
n++;
final int width = currentRadius * 2;
if (n >= width * 4) {
currentRadius++;
if (currentRadius > radius) {
... |
b10a04c3-e4d5-4aba-bc2f-58abb70d2fea | 9 | public void write(TProtocol oprot) throws TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
oprot.writeFieldBegin(USER_ID_FIELD_DESC);
oprot.writeI32(this.userId);
oprot.writeFieldEnd();
if (this.shardId != null) {
oprot.writeFieldBegin(SHARD_ID_FIELD_DESC);
oprot.writeS... |
deadf9a4-858d-4217-99ee-94032c292111 | 8 | public Double getUnnormalizedDataPoint(String sample, String taxa)
throws Exception
{
int x = -1;
for (int i = 0; x == -1 && i < getSampleNames().size(); i++)
if (sample.equals(getSampleNames().get(i)))
x = i;
int y = -1;
for (int i = 0; y == -1 && i < getOtuNames().size(); i++)
if (taxa.equals(... |
2da43afb-50f9-4d66-8b3b-09d5aacef578 | 8 | final public Exp AddOp() throws ParseException {Exp leftExp = null;
Exp rightExp = null;
Token op;
leftExp = MulOp();
label_11:
while (true) {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case SYM_PLUS:
case SYM_MINUS:{
;
break;
}
default:
jj_la1[... |
50b2e941-4229-454f-a99a-148ecaae4073 | 2 | public static <T> Params fill(List<T> beans, Mapper<T> mapper) {
if (beans == null || mapper == null)
throw new IllegalArgumentException(DATA_OR_MAPPER_IS_NULL_ERROR);
Params params = new Params();
beans.stream().forEach((bean) -> {
params.paramsList.add(mapper.map(bean))... |
eb50eaf4-6879-460d-b27b-dc83a06c621b | 0 | public boolean checkFiftyMoveRule() {
return this.fiftyMoveRuleCount < 50;
} |
0ddd0e28-7c01-4e57-86c8-431bff3ebfb3 | 5 | static public void main(String[] args) {
KDTree mainKDTree = new MainKDTRee();
ArrayList<double[]> puntos = new ArrayList<double[]>();
ArrayList<double[]> puntosQ = new ArrayList<double[]>();
int n = 100000;
int maxRange = 1;
Random r = new Random();
for (int i = 0; i < n; i++) {
double[] punto = new d... |
1ce557d2-a9ff-4e61-8c50-ade71cb43d66 | 2 | @Override
public int compareTo(Delayed o) {
Student that = (Student) o;
return submitTime > that.submitTime?1:(submitTime < that.submitTime ? -1 : 0);
} |
b33fd349-97c3-4e74-8107-026c23f938af | 3 | private ByteBuffer convertImageData(BufferedImage bufferedImage,core.render.Texture texture) {
ByteBuffer imageBuffer = null;
WritableRaster raster;
BufferedImage texImage;
int texWidth = 2;
int texHeight = 2;
// find the closest power of 2 for the wid... |
458c4832-c874-4538-8858-0f1f0afd0fc0 | 8 | private byte[] writeField(TKey<?, ?> key, List<QualifiedValue<?>> values) {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
CodedOutputStream output = CodedOutputStream.newInstance(bout);
try {
Integer id = converterFactory.getEncodedKey(key);
if (id != null) {
... |
15d21093-d302-48e3-b74a-2d5e4869af05 | 8 | private void writeElementType(ElementType elementType)
throws IOException
{
ElementType child;
if (pretty)
{
writer.write(RETURN);
writer.write(RETURN);
}
writer.write(DECLSTART);
writer.write(DTDConst.KEYWD_ELEMENT);
writer.write(SPACE);
writ... |
ae0cbba9-156d-4b1a-9e92-8c7fb80c91f5 | 0 | public static void setOpenOfficeListenerPort(int openOfficeListenerPort) {
OfficeToPdfUtils.openOfficeListenerPort = openOfficeListenerPort;
} |
7866884d-e23b-4239-b5c2-17403e65a6dc | 4 | public Turn[] getValidTurns(int position) {
Set<Turn> turns = new TreeSet<Turn>(Arrays.asList(Turn.values()));
Set<Turn> badTurns = new HashSet<Turn>();
Point p = getPoint(position);
Direction initialDir = getDir(position);
int i = 0;
for(Point testPoint: this) {
if(i++ > position) break;
for(Turn t: ... |
83865afd-edd4-40d9-8035-50f95864ca8e | 5 | public Object getField(Reference ref, Object obj)
throws InterpreterException {
Field f;
try {
Class clazz = TypeSignature.getClass(ref.getClazz());
try {
f = clazz.getField(ref.getName());
} catch (NoSuchFieldException ex) {
f = clazz.getDeclaredField(ref.getName());
}
} catch (ClassNotFou... |
18c4fe05-54a2-4bbb-bff0-e3048a199d05 | 9 | public void removePaper(Paper outPaper)
{
publications.remove(outPaper);
for (Scholar scholar: scholars)
{
if (scholar.getPapers().contains(outPaper))
{
scholar.getPapers().remove(outPaper);
}
}
//remove Paper from conferences
//ArrayList<Conference> outCon = new ArrayList<Confer... |
fe266272-d69a-4725-9cb8-a7e3c64fa00c | 5 | static final int method888(byte i, int i_7_, Widget class46) {
anInt1580++;
if (i != 57)
method886(7);
if (!Client.method105(class46).method3301(i_7_, false)
&& ((Widget) class46).anObjectArray741 == null)
return -1;
if (((Widget) class46).anIntArray706 != null
&& i_7_ < ((Widget) class46).anInt... |
f3b9be5c-9f69-47ee-8d18-f15e48d8fbeb | 2 | public static File generate(String file, String certLoc, String privateKey){
//adapted from http://docs.oracle.com/javase/tutorial/displayCode.html?code=http://docs.oracle.com/javase/tutorial/security/apisign/examples/GenSig.java
/* Generate a DSA signature */
File storedSig = null;
String res... |
b54b5164-a513-4db6-83a6-bde7cb6b71a8 | 2 | @Override
public int hashCode() {
int result = idPost;
result = 31 * result + userId;
result = 31 * result + (description != null ? description.hashCode() : 0);
result = 31 * result + (title != null ? title.hashCode() : 0);
result = 31 * result + threadId;
return resu... |
59c98e60-a982-4491-b64d-8ff8c699ea96 | 4 | public ArrayList<ArrayList<String>> subset(TreeNode root, int attr, int value, String type) {
ArrayList<ArrayList<String>> subset = new ArrayList<ArrayList<String>>();
for(int i = 0; i < root.getRecords().size(); i++) {
ArrayList<String> record = root.getRecords().get(i);
if(type.equalsIgnoreCase("equalto"... |
0cb29a93-2212-40f1-9e27-2d36512b0634 | 5 | public void update() {
if (hp <= 0) {
new Spawner((int) x + 16, (int) y + 16, 1000, Type.BLOOD);
this.remove();
}
if (shoots > 0) {
shoots--;
}
if (moving) {
animTile.update();
tileNr = animTile.getCurrFrame();
} else if (inWater()) {
animTile.update();
tileNr = animTile.g... |
c83fe143-b518-45b0-8383-ec4cdf6177da | 0 | public SkillsMain getSkill2() {
return skill2;
} |
48f29ac0-2aa8-4e2c-8534-21450659211b | 2 | public static void main(String[] args) {
String[] names ={"dsgsdfh", "sd vsd"};
String[] values ={"dfs xdfs d", "sisd nas"};
ArrayList<String[]> allArrays = new ArrayList<String[]>();
allArrays.add(names);
allArrays.add(values);
ArrayList<Object[]> allArrays2 = new ArrayList<Obje... |
fccf6fd3-2a30-4667-91b9-aa9890c6d0b7 | 1 | public ColorChooserButton(Color startColor) {
super();
color = startColor;
setBackground(startColor);
setMaximumSize(new Dimension(30,30));
setPreferredSize(new Dimension(30,30));
addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Color c = JColorChooser.showDialog(... |
85de9798-5046-452d-aa66-fbfe5f34884f | 1 | @BeforeTest
public void isSkip()
{
Page.initconfigration();
if(!TestUtil.isExecutable("ChatterTest",Page.excel)){
throw new SkipException("Skipping the test case as the Run mode is not Y");
}
} |
fd17db66-a76f-4156-9fd6-2e29ce43d49a | 9 | @Override
public double maxValue(BackgammonState state, String player, double alpha, double beta, int depth) {
expandedNodes++;
maxDepth = Math.max(maxDepth, depth);
if (depth >= currDepthLimit || state.getUtility() == 1 || state.getUtility() == 0) {
return eval(state, player); /... |
0ccd2ce6-4897-4e9b-bf87-8a2553dbaa6b | 9 | private void loadInputData() {
men = new ArrayList<Person>();
women = new ArrayList<Person>();
try {
FileInputStream fstream = new FileInputStream("input-indifference.tsv");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedRea... |
52eb9982-2934-4694-a824-4683b272d812 | 6 | @Override
public void run() {
try {
System.out.println( "ConnectionAccepter #" + Thread.currentThread().getId() + ": " + serverSocketChannel.getLocalAddress() + " -> " + proxyToAddress);
while(true) {
selector.select();
Set<SelectionKey> selectedKeys ... |
6f3ea8f4-9d1a-4323-bd54-2870bf46ea03 | 8 | public void parseLine(User guesser, Game game, String channel, String message) {
if(guesser != null) {
for(User setter : game.users) {
Set<Word> words = new HashSet<Word>(setter.wordobjs);
for(Word word : words) {
if(message... |
bb6e6fa3-ab55-4d83-b350-84f4221563ad | 6 | public void draw(Graphics2D g) {
//Draw Background
g.setColor(Color.black);
int[] PacmanI = {16, 1, 3, 13, 1, 14};
g.fillRect(0, 0, 336, 492);
int x = 120;
//draw pacman title
for (int i = 0; i < PacmanI.length; i++) {
drawSprite(g, 12, PacmanI[i], 2, ... |
0943fb84-72dd-4cf2-baf0-ae53124ff822 | 4 | protected boolean out_grouping(char [] s, int min, int max)
{
if (cursor >= limit) return false;
char ch = current.charAt(cursor);
if (ch > max || ch < min) {
cursor++;
return true;
}
ch -= min;
if ((s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) {
cursor ++;
return true;
}
return false;
} |
4c80086c-116b-477a-9d2d-90d8de96b87c | 6 | public static boolean twoOpt(int[] tour,int[][] dist){
boolean better=false;
for(int current=0;current<tour.length;current++){
int nextVerticeIndex=(current+1)%tour.length;
int swapWith=(current+2)%tour.length;
for(int iters=0;iters<tour.length-3;iters++){
//check if edge to swapwith is bett... |
16b8ebed-b537-426e-a369-fe8d6c8d0460 | 1 | public void Input(float delta)
{
m_transform.Update();
for(GameComponent component : m_components)
component.Input(delta);
} |
bfa7a5fd-adfa-491b-9ca6-220f39a2635e | 5 | static String[] split(char delim, String text) {
if (text.length() == 0)
return new String[0];
int nFields = 0;
for (int pos = 0; pos < text.length(); ++pos)
if (text.charAt(pos) == delim)
++nFields;
String[] list = new String[nFields + 1];
int toIndex = 0;
int fromIndex = 0;
int ctr = 0;
... |
ee31e328-8067-43c5-9fe6-963d7e20fa77 | 7 | public void startElement(String uri,String localName,String qName,Attributes attrs){
if(qName.equals(XmlConst.XML_MEDICINE)){
curr = new MedicineData();
curr.setId(attrs.getValue(XmlConst.XML_ATTRIBUTE_ID)) ;
}
if(qName.equals(XmlConst.XML_DOSAGE)){
curr.setDo... |
988e8d69-a8a5-4090-ade3-a2a38353c55d | 8 | private String toRules(){
if (numInstances() == 0)
return "No Rules (Empty Exemplar)";
String s = "", sep = "";
for(int i = 0; i < numAttributes(); i++){
if(i == classIndex())
continue;
if(attribute(i).isNumeric()){
if(m_MaxBorder[i] != m_MinBorder[i]){
s += sep + m_MinBo... |
66177756-eb15-4284-b4eb-87d320e9b805 | 1 | protected Integer calcBPB_FSVer() throws UnsupportedEncodingException {
byte[] bTemp = new byte[2];
for (int i = 42;i < 44; i++) {
bTemp[i-42] = imageBytes[i];
}
BPB_FSVer = byteArrayToInt(bTemp);
System.out.println("Номер версии FAT32 = " + BPB_FSVer);
return... |
bfd22e76-17c1-4739-813d-a221b381097d | 1 | public Enumeration declaredAttributes(String elname)
{
Hashtable attlist = getElementAttributes(elname);
if (attlist == null) {
return null;
} else {
return attlist.keys();
}
} |
b683f835-170a-413f-98ae-f1a57b810d7f | 5 | private static BufferedImage makeIcon(Color background) {
final int WIDTH = 16, HEIGHT = 16;
BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB);
for (int y = 0; y < HEIGHT; ++y)
for (int x = 0; x < WIDTH; ++x)
image.setRGB(x, y, 0);
... |
59861c28-3663-47ff-bb07-d41da5e3bf10 | 1 | protected void pauseGame() {
if (gamePaused == false) {
mainTimer.stop();
powerUpTimer.stop();
gamePaused = true;
repaint();
} else {
startGame();
}
} |
e0cbae7a-92a5-46c9-b538-f7c3158829fd | 5 | public boolean zugPruefen(SchachbrettFeld istFeld, SchachbrettFeld sollFeld, SchachbrettFeld[] felder) {
if (wegFrei(istFeld, sollFeld, felder) && sollFeld.figur == null) {
System.out.println("Der Weg ist frei");
return true;
} else if (weg... |
72b25b10-6d7e-4205-9912-7fe2c9d3f664 | 7 | public final TLParser.mulExpr_return mulExpr() throws RecognitionException {
TLParser.mulExpr_return retval = new TLParser.mulExpr_return();
retval.start = input.LT(1);
Object root_0 = null;
Token set124=null;
TLParser.powExpr_return powExpr123 = null;
TLParser.powExpr... |
13fb840e-5a5b-489b-8b62-83679a14df35 | 4 | private void createConnectionWindow(){
try {
//Create the frame.
final JFrame frameWindow = new JFrame("Pong");
//Close the window when the frame is closed.
frameWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Creates the panel.
fi... |
0776675d-0365-465e-95e1-0921d14cf82e | 3 | @Override
public void run() {
File dataFile=new File("C:\\Dropbox\\data.txt");
try {
FileReader fr=new FileReader(dataFile);
char[] c=new char[50];
fr.read(c);
String temp=new String(c);
userName=temp.trim();
File m... |
b8ab0f9d-fd18-43ee-b78c-6f4a129bb4c2 | 2 | public int xCoordToColumnNumber(int x) {
Insets insets = getInsets();
if (x < insets.left)
return -1;
double colWidth = (double)(getWidth()-insets.left-insets.right) / columns;
int col = (int)( (x-insets.left) / colWidth);
if (col >= columns)
return columns;
else
... |
5208cf18-9e35-4290-abfc-f20e89a16be4 | 0 | public void setProcessed(boolean processed)
{
this.processed = processed;
} |
2fcb4cff-1421-43e0-9e68-961c3ee86049 | 1 | public void deletePeople(String peopleID) {
People people = manager.find(People.class, peopleID);
if (people != null) {
manager.remove(people);
}
} |
9f2a5d1d-f2f1-4f07-93f2-45399a54e9e3 | 8 | public int findMaxDistance(int[] arrA) {
int[] Lmin = new int[arrA.length];
int[] Rmax = new int[arrA.length];
int leftMinIndex = 0;
int leftMinValue = arrA[0];
int rightMaxValue = arrA[arrA.length - 1];
int rightMaxIndex = arrA.length - 1;
// traverse the main array and fill the Lmin array with the inde... |
0788118b-862b-47aa-81df-6575098e83b6 | 0 | public Point getVertice() {
float h = -0.5f * b / a;
float k = c - 0.25f * b * b / a;
return new Point(h, k);
} |
6d29d8a6-c33c-4a77-aad5-875fe07085db | 4 | public ArrayList<String> getFileNames(){
System.out.println("getting all files with reads per transcripts counts. Files names finish with " + fnamePattern);
ArrayList<String> file_names = new ArrayList<String>();
File dir = new File(dirName);
for (File ch : dir.listFiles()) {
if (ch... |
0c3f9ce0-16b1-42f7-856b-1698b1b62fd9 | 6 | private void startTournamentWatch() {
Thread watchThread = new Thread( new Runnable() {
@Override
public void run() {
while (tournamentThread != null && tournamentThread.isAlive()) {
try {
messageLabel.setText("Games completed: "
+ facade.getTournamentNumGamesCompleted())... |
11935690-036e-4604-9314-180870516b0c | 3 | public void apply() throws XPathExpressionException {
Element existing = editor.getXMLElementByString("/MLP_Save/MapZone[@ID='0']/GameObjects/Pony_Objects/Object[@ID='" + id + "']");
Element bluePrintExisting = editor.getXMLElementByString("/MLP_Save/MapZone[@ID='0']/GameObjects/Pony_Objects/Object[@ID... |
157dd9b9-79c1-404b-9042-37dadafc11db | 4 | public Path getImgPath_CommandBtnArrow(Imagetype type) {
Path ret = null;
switch (type) {
case KEYFOCUS:
ret = this.imgComArrow_KFoc;
break;
case MOUSEFOCUS:
ret = this.imgComArrow_MFoc;
break;
case PR... |
b9366a1e-8301-4012-8c63-c03d1b98b742 | 6 | @Override
public void mouseReleased(MouseEvent e)
{
Object sender = e.getSource();
if (sender == _redPrimeButton)
{
refreshLcd();
}
else if (sender == _bluePrimeButton)
{
refreshLcd();
}... |
f8d51dbc-645b-4db9-bb38-22f529a4e8c5 | 4 | @Override
public int compare(UsedPair<?, ?> one, UsedPair<?, ?> two) {
return one.usedCounter - two.usedCounter;
} |
be65a610-c7e1-4798-aa94-58b8193ddfae | 5 | public static int getClosestLine(Vector<int[]> Lines, float[] g)
{
//Findet in Richtung der Gerade g die naeheste Linie, gibt -1 zurück wenn keine da ist
//g[0] und g[1] beschreiben einen Punkt, g[2] und g[3] einen Richtungsvektor
float d = 1000000;
int line = -1;
float[] p = null;
Vector<float[]> Punkte... |
a83737ba-c824-4f95-95fe-5cc744b2a9c4 | 3 | public boolean chromKeysMatch(String chromKey) {
String thisKey = this.chromKey;
String thatKey = chromKey;
// Note: must have the same length to compare chromosome names
int thisKeyLength = thisKey.length();
int thatKeyLength = thatKey.length();
// check if need to tru... |
fc5f1df5-19df-42bd-9cd6-c8a709317e03 | 6 | public static DataOutputStream getMainOutputStream(String fileName, boolean overwrite) throws ClassFileLoaderException
{
File file = new File(fileName);
if (file.exists())
{
if (overwrite)
{
file.delete();
}
else
... |
090cab19-9e91-4b0d-8c65-bcf918f80dc3 | 9 | @Test
public void AppTest() throws IOException{
String startTime=null;
ReportUtil.startSuite("TestSuite");
System.out.println(controller.getRowCount("TestSuite"));
for(int tcid=2;tcid<=controller.getRowCount("TestSuite");tcid++){
currentTest = controller.getCellData("TestSuite", "TCID", tcid);
curren... |
725f537c-e620-4868-a523-d9c1513bd91f | 2 | public boolean addCharacter(Character character){
if(character != null){
if(!checkOverLimit()){
characterList.add(character);
return true;
}
}
return false;
} |
0e91bf5b-12c7-4f87-a622-2581ec07e1ed | 8 | public Status cadastraUsuario(Usuario usuario, Endereco endereco, Cidade cidade){
Status status = new Status();
Connection conexao = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
conexao = criarConexao();
try {
String insertSQL = "insert into \"Usuario\" (nome,login,senha,dataNascimento,cpfC... |
12535c85-8b69-4658-b35d-22699aa4f975 | 7 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
final Item target=getTarget(mob,mob.location(),givenTarget,commands,Wearable.FILTER_ANY);
if(target==null)
return false;
if(!(target instanceof Weapon))
{
mob.tell(mob,target,null,L("You c... |
3eeca842-5e56-49d6-8e44-a925f212769c | 9 | static public ParseException generateParseException() {
jj_expentries.clear();
boolean[] la1tokens = new boolean[54];
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 24; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
... |
f7f4fdd0-a52b-4ff9-ba9b-d7e56c83f174 | 3 | private void printToFile() throws IOException {
// Writes the current state of the ContactManager to a CSV File.
BufferedWriter CSVFile = new BufferedWriter(new FileWriter(fileName));
for(Contact eachContact : allContacts) {
CSVFile.write("contact,"+eachContact.getId()+","+eachContac... |
e7d7f803-61b5-4d52-8a4b-8415d148d87c | 2 | public Command(Object obj, String methodName, Object[] arguments) {
receiver = obj;
args = arguments;
Class cls = obj.getClass(); // get the object's "Class"
Class[] argTypes = new Class[args.length];
for (int i = 0; i < args.length; i++) // get th... |
fd9b76de-c471-4981-a283-914018913cae | 5 | public static long[] listOfPrimeNumbers(long m) {
long[] numbers = getRangeOfOddNumbers(2, (int) m);
int[] primeMarker = new int[numbers.length];
Arrays.fill(primeMarker, 2);
long square;
int index;
for (int i=0; i<numbers.length; i++) {
if (primeMarker[i] == 2) {
primeMarker[i] = 1;
square = (lo... |
7c49281c-1592-45b1-b0f2-50ddd7312028 | 0 | private void setSettings()
{
campaignRef.setSettings(background1Field.getText(), background2Field.getText(), background3Field.getText(), logoField.getText(),
buttonField.getText());
} |
9a36f5eb-155c-4538-9076-bbc6a5a55797 | 0 | public static void main(String[] args) {
System.out.println("test");
laenderGraph = new LaenderGraph();
brett = new Brett(laenderGraph);
System.out.println("Nachbarn von land 0");
System.out.println(laenderGraph.getNachbarn(laenderGraph.getLaenderList().getLandByID(0)));
Spieler spieler1 = new Sp... |
96d05986-df0c-4eeb-8493-539a81867797 | 6 | @EventHandler
public void GiantSlow(EntityDamageByEntityEvent event) {
Entity e = event.getEntity();
Entity damager = event.getDamager();
String world = e.getWorld().getName();
boolean dodged = false;
Random random = new Random();
double randomChance = plugin.getGiantConfig().getDouble("Giant.Slow.DodgeCha... |
48849da8-569f-4391-b470-134f039c31c9 | 5 | public Problem9(){
loop : for(a=1;a+b+c<=1000;a++){
for(b=1;a+b+c<=1000;b++){
for(c=1;a+b+c<=1000;c++){
if(a+b+c == 1000 && verifyTriple()){
answer = a*b*c;
break loop;
}
}
c=1;
}
b=1;
}
} |
95127119-c6f3-414e-9009-a0026ed7f9ad | 4 | public static void saveParamsToFile(String fileName){
File input =new File(fileName);
if( !fileName.substring(fileName.indexOf(".")+1).equalsIgnoreCase("xml")){
String newFilName = fileName.substring(0, fileName.indexOf(".")+1)+"xml";
input= new File(newFilName);
}
if (!input.exists()) {
try {
inpu... |
820adf1f-f717-4348-8cdc-5f8fd3a04a33 | 5 | public Component prepareRenderer(TableCellRenderer renderer, int row,
int column) {
Component c = super.prepareRenderer(renderer, row, column);
boolean selected = false;
for (int i : getSelectedRows()) {
if (row == i) {
selected = true;
break;
}
}
if (c instanceof JComponent) {
if(c instan... |
1c644b89-fc4c-4ead-b045-3ed754d45731 | 8 | public static float drawTextWrap(float x, float y, float width, float height, int horzAlign, int vertAlign, AngelCodeFont font, Color c, String baseText)
{
ArrayList<String> textSplit = new ArrayList(Arrays.asList(baseText.split(" ")));
ArrayList<String> texts = new ArrayList<String>();
Stri... |
5f87632e-5826-4144-b465-350841b9e75f | 8 | public void shortestPath(int s){
if(current == null){
int index = (int)(Math.random()*graph.vertexes.size());
current = graph.vertexes.get(index);
showCurrentCity();
}
cities = graph.vertexes;
City c = null;
for(City d: graph.vertexes){
if(d.id == s){
c = d;
}
}
if(c == null){
System... |
98d01612-47c7-47bd-be36-5be8786f94f2 | 5 | public void keyPressed(KeyEvent ke) {
switch(ke.getKeyCode()){
case KeyEvent.VK_SPACE:
// call object methods that happen when key is pressed
Ball.jump(this);
break;
case KeyEvent.VK_LEFT:
// call object methods that happen when key ... |
a0ad23d6-e846-4585-9f4f-ce7e7e39630e | 9 | private StringResource createStringResource(ArrayList<String> headers, ArrayList<String> rows) {
if (rows.size() == 0) {
return null;
}
// Check for blank entries in row and fill out with blanks. This should
// never happen as all fields should be filled in.
if (headers.size() > rows.size()) {
int rows... |
7da80203-1c1e-49ef-bea1-46b0eaf440bd | 7 | public static Collection<Restaurant> parse(String fileName) {
BufferedReader br = null;
Map<Integer, Restaurant> restaurantMap = new HashMap<Integer, Restaurant>();
try {
String line;
br = new BufferedReader(new FileReader(fileName));
while ((line = br.readLine()) != null) {
String[] values = line.sp... |
0c8488e2-16dc-4552-9eae-5068f4033075 | 8 | public SearchPanel(Dictionary dictionary) {
d=dictionary;
txtSearch = new JTextField();
txtSearch.setToolTipText("<html>Enter word to be searched<br>? replaces one character<br>* replaces a sequence of characters</html>");
txtSearch.setColumns(10);
JButton btnSearch = new JButton("Search");
btnSearch.add... |
250ac9d7-30e9-407a-bba1-ca36ff7e0c9e | 8 | public void loadSchema(String catalogFile) {
String line = "";
try {
BufferedReader br = new BufferedReader(new FileReader(new File(
catalogFile)));
while ((line = br.readLine()) != null) {
// assume line is of the format name (field type, field type,
// ...)
String name = line.substri... |
5e4c11dc-6080-432d-b0fe-21d893857d97 | 7 | static public int actionToColumn(String action)
{
if( action.equalsIgnoreCase("a") )
{
return 0;
}
else if( action.equalsIgnoreCase("b") )
{
return 1;
}
else if( action.equalsIgnoreCase("c") )
{
return 2;
}
... |
fa82871c-ec19-4dc4-b36e-cf06c48e4e17 | 6 | @Test
public void eightRooks() {
Map<String, Integer> figureQuantityMap = new HashMap<>();
int size8 = 8;
figureQuantityMap.put(ROOK.toString(), size8);
int dimension = size8;
Chessboard chessboard = Chessboard.newBuilder(figureQuantityMap).withDimension(dimension).withRook(... |
36f4f86a-c5a3-4523-b488-a5e3fa70f2c9 | 5 | private boolean isValidStart(Node node) {
if (node.x < 0 || node.y < 0 || node.x >= width || node.y >= height)
return false;
else {
if (isInInvalidArray(node))
return false;
else
return true;
}
} |
7dc9aa94-936d-461a-9c0b-36b83d83dc05 | 4 | public void check() throws InvalidGameStateException {
if (points == 0) throw new InvalidGameStateException("field '"+answer+"' has no points assigned (=0)");
if (answer == null || answer.isEmpty()) throw new InvalidGameStateException("field has null or empty string set as an answer");
if (status == null) throw n... |
c831fcc2-c492-4b02-8969-864dc3ee7c81 | 3 | @Override
public GameState doAction(GameState state, Card card, int time) {
if(time == Time.DAY)
{
state = gunnerDay(state, card, true);
}
else if(time == Time.DUSK)
{
PickTreasure temp = new PickTreasure();
state = temp.doAction(state, card, time);
}
else if(time == Time.NIGHT)
{
//Do noth... |
21d1291f-587e-4f02-8c19-4a5085376ff0 | 2 | public boolean isDiatomic()
{
for(int i = 0; i < eDiatomic.length; i++)
if(eDiatomic[i] == protons)
return true;
return false;
} |
8a9568a0-bd38-4c46-8529-68fcac7a9d01 | 5 | private static void setInTop5(int score, String name){
ArrayList<String> temp = getTop5List();
String s = name + " " + score;
temp.add(0, s);
File fil = new File(FILENAME);
try {
FileWriter writer = new FileWriter(fil);
@SuppressWarnings("resource")
BufferedWriter buf = new BufferedWriter(writer);
int size... |
6d252fa6-c732-4353-965d-644eb85ba5ff | 3 | private Agrupamento criarAgrupamentoPorRealizacao() {
Agrupamento agrupamento = new Agrupamento("Bancas Examinadoras por realização");
for(Object o : bancas){
if(o instanceof BancaExaminadora){
BancaExaminadora banca = (BancaExaminadora)o;
... |
49335ea5-5574-437f-b066-0d41eb4cc1ca | 9 | public boolean isValidSudoku(char[][] board) {
for (int i = 0; i < 9; i++) {
boolean[] pos1 = new boolean[board.length];
boolean[] pos2 = new boolean[board.length];
for (int j = 0; j < 9; j++) {
char c1 = board[i][j];
char c2 = board[j][i];
... |
aa8b79b1-db80-425d-aa3a-07f51f691461 | 6 | public static Object findFirstMatch(Collection<?> source,
Collection<?> candidates) {
if (isEmpty(source) || isEmpty(candidates)) {
return null;
}
for (Object candidate : candidates) {
if (source.contains(candidate)) {
return candidate;
}
}
return null;
} |
1e016693-5b90-4402-8aa8-d3380d0e3b60 | 2 | @Override
public void teardownTest(JavaSamplerContext context) {
super.teardownTest(context);
try {
if (table != null) {
table.flushCommits();
table.close();
table = null ;
}
} catch (IOException e) {
System.out.println("teardown error");
}
} |
d8109d66-f48b-45c7-89ea-0f5d3dd979c1 | 3 | public Tour tourCalc(Double[] currCity, LinkedList<Double[]> unusedCities, Double[] origin)
{
Tour t1 = new Tour();
//Base case
if(unusedCities.size() == 0){
t1.cost = distanceFormula(currCity, origin);
t1.tour = ((Integer) origin[0].intValue()).toString();
return t1;
}
//Set comparison point for... |
e20368fd-fcd7-4415-930f-85b54686e657 | 0 | public void setType(String type) {
this.type = type;
} |
e85368bb-617a-48cc-b514-12fbc8231107 | 0 | @Test
public void testGetS1() {
System.out.println("getS1");
Mark instance = new Mark(6,9);
int expResult = 9;
int result = instance.getS1();
assertEquals(expResult, result);
} |
8b3a8f62-6763-47e2-9351-cf2674dd8a6d | 7 | private BufferedImage loadImage(String fnm) throws IOException {
if(VectorWorld.DEBUG_LOAD_IMG) {
System.out.println("Loading image file " + fnm + " from directory "
+ IMAGE_DIR);
}
BufferedImage copy = null;
try {
InputStream in = this.getClas... |
cf0078c3-e7ca-45d6-85e4-01feab4bf6d8 | 4 | public void heitaNopat(){
if (nopat.isEmpty()) {
for (int i = 0; i < 5; i++) {
this.lisaaNoppa(new Noppa(arpoja.annaArvo()));
}
} else {
Set<Noppa> nopsut = new HashSet<Noppa>(nopat.keySet());
for (Noppa noppa : nopsut) {
if... |
cc98c209-0b5b-457c-9daf-cf986b90e618 | 6 | public ListNode insertionSortList(ListNode head) {
if(head == null || head.next == null) return head;
ListNode preHead = new ListNode(0);
preHead.next = head;
ListNode run = head;
while(run != null && run.next != null){
if(run.val > run.next.val){
... |
1fae75b1-a1f3-4b39-af4d-36c8f629189a | 1 | protected InferenceParameters loadKBQProperties(CycAccess access, CycDenotationalTerm kbq)
throws CycApiException, IOException {
try {
InferenceParameters properties = new DefaultInferenceParameters(access);
final String command = SubLAPIHelper.makeSubLStmt(KBQ_PROPERTIES, kbq);
properti... |
206828c9-db60-431f-99eb-c69fc106e458 | 4 | @Override
public ArrayList<STTPoint> getWrappedData() {
ArrayList<STTPoint> pointList = new ArrayList<STTPoint>();
try{
URL url = new URL(getWrapperParams().getSource());
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String fileLine;
whil... |
910bee87-11d4-4b3f-bedb-d1cb43ddd4c9 | 7 | public static String builDOMStructureString(XMLStreamReader xmlsr,
String regexEndParsing) throws XMLStreamException {
int deepLevel = 0;
String builderDOMStructure = "<root>";
int eventType;
while (xmlsr.hasNext()) {
eventType = xmlsr.next();
if (eventType == XMLEvent.END_ELEMENT
&& xmlsr.getLo... |
3f4b0631-11e5-42d0-abf5-d4bb4f5e711e | 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... |
348effba-2875-4d9d-982e-e7d067dd7d04 | 9 | final void _write_(final String string) throws IOException {
final Writer target = this._writer_;
for (int i = 0, length = string.length(); i < length; i++) {
final int symbol = string.charAt(i);
switch (symbol) {
case '\t':
target.append("\\t");
break;
case '\r':
target.append("\\r");
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.