method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
9f7f48ff-0d53-44bb-847d-5ba063b2e828 | 3 | public void setFullScreen() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
device = ge.getDefaultScreenDevice();
myWindow.setVisible(false);
myWindow.dispose();
myWindow.setUndecorated(true);
myWindow.setIgnoreRepaint(true)... |
25a9fff2-0bb1-4c49-85a2-f1659af9e5d4 | 0 | public Calendar getGameStart()
{
return gameStart;
} |
0213e018-507f-4a46-b7e9-e8d461372ee8 | 3 | private void placeChargedIdentityDiscs() {
// Calculate the middle position of the grid
Position middle = new Position(grid.width / 2, grid.height / 2);
// Generate all the surrounding positions
List<Position> positions = grid.getPositionsAround(middle);
Random random = new Random();
while (positions.size... |
abcea796-71fa-4904-9d17-8170c7c22050 | 5 | public void Control () {
String mess;
do {
mess= receive();
if (mess.equals("1")){
LCD.drawString("it works!", 2, 2);
//Location();
//set the return values
//FlowOut.writeBytes("Message")
}else if (in.equals("2")){
//getMap();
... |
4b7c0abe-70ff-419a-a9a3-34b3b4286de2 | 5 | public void GetUniversalOptions(Input in, GameContainer gc)
throws SlickException {
// listens for things that work always even in pause
if (in.isKeyPressed(Input.KEY_ESCAPE)) {
if (currentState == PAUSED) {
switch (gameType) {
case 1:
currentState = ARCADE;
break;
case 2:
currentSt... |
62be831b-c18f-4923-a5e1-6c571f992b00 | 9 | private void exportFramedDiffCatsSimStructVsMoa(String path, int level) throws Exception {
SmilesParser smilesParser = new SmilesParser(SilentChemObjectBuilder.getInstance());
DrugBank db = new DrugBank("data/tmp/drugbank.ser");
Brain atc = new Brain();
System.out.println("Learning ATC...");
atc.learn("data... |
ccaff751-5077-4115-9604-db30a1486560 | 8 | private int[] breadthFirstSearch(Scanner inputFile, int maxNode)
{
HashMap<Integer, ArrayList<Integer>> nodes = new HashMap<Integer, ArrayList<Integer>>();
while(inputFile.hasNext())
{
int key = inputFile.nextInt(), value = inputFile.nextInt();
if(nodes.containsKey(key))
{
ArrayList<Integer> ... |
bc841f99-bae6-47e4-a557-b5240f08f2fd | 5 | @SuppressWarnings("resource")
public static void main(String[] args) throws ImageFormatException {
System.out
.println("Select your grayscale picture or hit cancel to select a picture to be grayscaled.");
String picLoc = FileChooser.pickAFile();
if (picLoc == null) {
String noGrayPicLoc = FileChooser.pick... |
bcbf6e6b-a102-4eed-9e16-11d4da33d4a4 | 7 | public void saveScore(String name, int points) {
ArrayList<Score> scoreList = new ArrayList<Score>();
scoreList.add(new Score(name, points));
setPath(new Strings().FILE_TO_XML_HIGHSCORE);
build();
NodeList nodeList = getAllValue("player");
for (int temp = 0; temp < nodeList.getLength(); temp++) {
... |
f8136d61-71ca-40fc-9a34-0bd7868d7684 | 0 | @Test (expected = OutOfBoardException.class)
public void test_moveException() throws OutOfBoardException{
when(board.getXSize()).thenReturn(2);
when(board.getYSize()).thenReturn(2);
pawn.move(Direction.Right);
} |
97513cc2-a026-4bbb-bb99-380ed2a79af1 | 4 | public void writeHistory(DataOutput output) {
try {
output.writeInt(VERSION);
int chainCount = filterLists.size();
output.writeInt(chainCount);
for (int i = 0; i < chainCount; ++i) {
JList filterList = (JList) filterLists.elementAt(i);
... |
a6f5f8dd-6ecf-4557-a8b6-7412cd7bfd20 | 3 | public static final void setTracks(
@SuppressWarnings("hiding") final Map<Integer, ?> trackMap) {
ParamMap.trackMap.clear();
for (final Map.Entry<Integer, ?> entry : trackMap.entrySet()) {
ParamMap.trackMap.put(
Integer.valueOf(entry.getKey().intValue() + 1),
entry.getValue());
}
ParamMap.unassi... |
cf5d558f-4158-4fd0-8880-a505bc3ab85d | 6 | public Linear(Data data) throws IloException, FileNotFoundException {
this.data = data;
cplex = new IloCplex();
cplex.setOut(new PrintStream("./solution/" + data.filename + "LP.log"));
//decision variable y (integer)
y = new IloNumVar[data.nLinks];
for (int i = 0; i < data.nLinks; i++) {
Link l... |
64445bb8-b616-4ba7-b113-29adeea46fcc | 0 | public AbstractGUITreeJDialog(boolean resizeOnShow, boolean alwaysCenter, boolean modal, int initialWidth, int initialHeight, int minimumWidth, int minimumHeight) {
super(resizeOnShow, alwaysCenter, modal, initialWidth, initialHeight, minimumWidth, minimumHeight);
} |
921868ae-0099-4965-b391-3ce331ffec19 | 5 | public int addUser(String name, String password)
{
if (name.length() < 4 || name.length() > 10)
return -1;
if (password.length() < 2 || password.length() > 10)
return -2;
if (users.containsKey(name))
return -3;
users.put(name, new Trader(this, name, password));
return 0;
} |
9c5dd590-f0f2-4813-a4c4-1c74d98669d4 | 5 | public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException
{
posx = Mouse.getX();
posy = Mouse.getY();
//Back Button
if ((posx > 5 && posx < 205) && (posy < 80 && posy > 5) && Mouse.isButtonDown(0))
{ sbg.enterState(0); }
} |
30df1962-adcd-4152-8143-3ccdac0729ce | 9 | public static void push(Integer stackNum, Object val) {
if (stackNum == 0 && top1 != top3_left + 1) {
arr[top1] = val;
top1++;
} else if (stackNum == 2) {
if (isLeft && top3_left + 1 != top1) {
arr[top3_left] = val;
top3_left--;
... |
9cf271e8-cf4e-4a3b-a738-15bdd211efa3 | 3 | public void run()
{
while(isRunning)
{
// Timer work in progress
long now = System.nanoTime();
updateGame();
repaint();
long update = System.nanoTime() - now;
//TO-DO: Clean up speed control code, magic numbers
long sleep = ( 500 - (update / CONVERSION) ) / speed;
try
{
if(sleep > ... |
c0e037c9-af9b-46d3-9f29-ceacba68d5a4 | 5 | public static int editDistance(String s1, String s2) {
int[][] distance = new int[s1.length() + 1][s2.length() + 1];
for (int i = 0; i < s1.length() + 1; i++)
distance[i][0] = i;
for (int i = 1; i < s2.length() + 1; i++)
distance[0][i] = i;
for (int i = 0; i < s1... |
7936eb03-e79f-4ae8-8483-d189c3c658d9 | 5 | public static void newStartMenu(Game game, Screen parent) {
try {
pokedexMenuClass.getConstructors()[0].newInstance(game, parent);
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTr... |
7897a023-11bb-46f1-8a5b-d622ef498931 | 4 | public AState getNeighbor(AState state, Direction dir)
{
int x = state.getX() + dir.X();
int y = state.getY() + dir.Y();
if(x < 0 || x >= this.columnsCount() || y < 0 || y >= this.rowsCount())
return null;
return this.map[y][x];
} |
be885f26-be04-4474-ae3e-900eb60e1c71 | 1 | public static Edge makeBurnEdge(Node.Dir dir) {
Node nodeOne = ship.getAlienNode();
// find second node using connected ship
Node connectedNodeOne = connectedShip.getNodeAt(nodeOne.getRow(), nodeOne.getCol());
Edge connectedMoveEdge = connectedShip.getNod... |
c61a9a75-ae43-4d4f-a564-a4bde0f6716e | 4 | public void shiftSeconds(double accum) {
if (accum >= 1.0 || accum <= -1.0) {
second += (long) accum;
accum -= (long) accum;
}
if (accum != 0) {
accum += (accum < 0 ? -0.0000000005 : 0.0000000005);
nanosec += (long) (accum * 1000000000);
}
... |
ade93583-0b3a-47c5-a9db-605746069603 | 6 | private Token name() throws ScanException {
text = new StringBuilder();
while (!in(c, "[ \t\r\n=<>!]")) {
text.append(c);
nextChar();
}
String val = text.toString().toLowerCase();
switch (val) {
case "where":
return WHERE;
... |
48d722e1-383d-49b3-a8b2-cc2d834bce8a | 1 | public static void clearAll(SeatChart aChart)
{
for(int index = 0; index < aChart.seat.length ; index++)
{
aChart.seat[index] = false;
}
} |
3c4887e4-660a-41c3-ab6f-fea65d80fb82 | 9 | private boolean verifyPart(int[] arr, int start, int end, int max, int min) {
if (start > end)
return true;
if (arr[end] <= max && arr[end] >= min) {
if (start == end)
return true;
int smaller;
for (smaller = start; smaller < end; smaller++) {
if (arr[smaller] > arr[end])
break;
els... |
3a2f4265-ef42-44be-ba34-a992920acda2 | 3 | final String getString (int start, int count)
{
try {
int end;
start += off;
for (end = start; count > 0 && data [end] != 0; end++)
count--;
// NOTE: this constructor doesn't exist
// in some embedded profiles
return new String (data, start, end - start, "8859_1");
} catch (Unsu... |
9be29e55-6b20-41f5-9777-cf460d4b3505 | 7 | private void observeResultingState(TicTacToe game) {
if (!learn)
return;
// reward received
double reward = 0.0;
if (game.hasEnded() && game.isDraw() == false) {
if (game.getWinner() == this)
reward += 1;
else
reward -= 1;
}
// observe resulting state
NeuralData newState = new BasicNe... |
32540087-e130-414d-ad02-dd388de8a477 | 6 | public boolean execute(IMove move) {
if (!isLegal(move))
return false;
if (move instanceof Move) {
Move aMove = (Move)move;
placeMove(aMove);
if (currentTurnColor != null)
currentTurnColor = currentTurnColor.getOpposite();
if (isCheckmated(currentTurnColor)) {
setCheckmated(currentTurnCol... |
df893882-8d62-4cf6-b69b-181ba26f987a | 6 | public ArrayList<Pair> get(Pair[] set, int k, int type) {
BinaryHeap binaryHeap = new BinaryHeap(type);
int i = 0;
/** Inheap the k first elements */
for (i = 0; i < k; i++)
binaryHeap.inHeap(kList, set[i]);
if (type == SMALLEST) {
/**
* If the next heaps.element is smaller than the priority que... |
9c274319-7321-4bbf-9226-0e2e7f6e2143 | 6 | @Override
public void tick() {
int xa = 0, ya = 0;
if (input.up) {
ya--;
}
if (input.down) {
ya++;
}
if (input.left) {
xa--;
}
if (input.right) {
xa++;
}
if (xa != 0 || ya != 0) {
... |
5f91c87e-a277-4f84-af64-1e5c695e2bfb | 5 | @Override
public FileHandle openFile(String path, boolean read, boolean write)
throws PathNotFoundException, AccessDeniedException,
NotAFileException {
if (path.contains(hiddenPrefix))
throw new AccessDeniedException();
if (hardlinks)
{
//Get hard link paths
String[] hardlinks = getHardLinks... |
a9815fc4-5aac-4947-9e4e-b22519affbed | 8 | private void unfilterPaeth(byte[] curLine, byte[] prevLine) {
final int bpp = this.bytesPerPixel;
int i;
for(i=1 ; i<=bpp ; ++i) {
curLine[i] += prevLine[i];
}
for(int n=curLine.length ; i<n ; ++i) {
int a = curLine[i - bpp] & 255;
int... |
6e747fa3-8720-4179-8409-3496d1d8281a | 5 | private Function funcDecl() throws Exception
{
Function rval = new Function();
currentFunction = rval;
currentBB = new BasicBlock(null);
currentJoinBlock = null;
rval.entryPoint = currentBB;
env.enter();
if(!(scan.sym == Token.function || scan.sym == Token.pro... |
c7c0d318-92e0-44a9-8191-abb7e1e9160e | 5 | public static Sandbox parse(HtmlElement element, String str){
switch(str){
case "allow-same-origin":
return SAME_ORIGIN;
case "allow-top-navigation":
return TOP_NAVIGATION;
case "allow-forms":
return FORMS;
case "allow-scripts":
return SCRIPTS;
default:
case "":
... |
6014c578-00a1-48e2-9e1c-aa155c1db934 | 1 | public static boolean canBeServed(String hostname) {
if ( !isInLog(hostname) )
return true;
ArrayList<Long> times = records.get(hostname);
removeOldRecords(times);
records.put(hostname, times);
return ( times.size() < MAX_SERVES_PER_MINUTE );
} |
c8613591-9df1-40a8-a64f-3b62831d7578 | 6 | public void mutate(Sequence reference){
for(int i = 0; i < reference.length(); i++){
//insert new bases
while(insert()){
mutated.append(new Base());
}
//if delete skip reference base
if(delete()){
}
else{
... |
f37e2636-4476-4fe8-afe6-8fff675693af | 5 | public int faltaEnvidoNoQuerida(boolean envido, boolean envidoEnvido, boolean realEnvido){
int puntosGanados;
if(envido){
if(realEnvido){
puntosGanados = 5;
}else{
puntosGanados = 2;
}
}else if(envidoEnvido){
if(realEnvido){
puntosGanados = 7;
}else{
puntosGanados = 4;
}
}else ... |
17ff8bcc-5000-4345-921c-4d070f595416 | 0 | @Override
public void endSetup(Attributes atts) {} |
c2f07758-9eb6-4678-b320-7337df563d35 | 6 | private static void writeFields(final ClassEditor ce,
final DataOutputStream dos) throws IOException {
// Sort the fields by their names
final SortedSet sorted = new TreeSet(new Comparator() {
public int compare(Object o1, Object o2) {
FieldEditor fe1 = (FieldEditor) o1;
FieldEditor fe2 = (FieldEdito... |
8de40546-c40a-48e1-99bc-7b06e081fe00 | 1 | @Override
protected Result check() throws Exception {
final String saying = String.format(template, "TEST");
if (!saying.contains("TEST")) {
return Result.unhealthy("template doesn't include a name");
}
return Result.healthy();
} |
0ae810f2-06e8-43a3-b012-175a1c4b3286 | 0 | @Basic
@Column(name = "CTR_ID_SOLICITUD")
public int getIdSolicitud() {
return idSolicitud;
} |
fff3e709-d6f7-4eb8-9f01-6a4adbe4e80b | 6 | public ProductionDirectory(Grammar grammar) {
Production[] p = grammar.getProductions();
// Create the map of LHSes to RHSes.
for (int i = 0; i < p.length; i++) {
String lhs = p[i].getLHS(), rhs = p[i].getRHS();
if (rhs.indexOf('(') != -1)
throw new IllegalArgumentException(
"Grammar has th... |
c99cd648-8e48-4a93-932d-43fe66d89fd2 | 6 | @Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final BitArray other = (BitArray) obj;
if (!Arrays.equals(bits, other.bits)) {
return false;
}
if (lastBit != othe... |
bba5b9b4-3ed2-4480-ba19-9de4fd0eabbc | 3 | @Override
public void move(Excel start, Excel finish) {
// TODO Auto-generated method stub
for(int i=0;i<allex.size();i++)
{
if (start.getX() == allex.get(i).getX() && start.getY() == allex.get(i).getY())
{
allex.remove(i);
allex.add(i, finish);
setColoredExes();
break;
}
}
} |
74f5223a-7129-457b-91cb-8cfa0b378c5f | 4 | public String getIterableValue(Field field) throws IllegalAccessException{
String iterableValue = "{";
Iterable<?> iterable = (Iterable)field.get(obj);
int m = 0;
for (Object anIterable : iterable) {
if (m < getMaxAmount(field)) {
iterableValue += anIterabl... |
f1920ae4-e7da-4b76-a52d-c36d47a8ce5f | 8 | static SVNode createSVTree(ArrayList<Img<Color>> allEls, ArrayList<Img<Color>> testEls, int maxD, int minImprovement,
Color currentTag)
{
if (maxD == 0) { return null; }
SVNode node = new SVNode();
node.sv = findBestSV(allEls, testEls);
if (node.sv == null) {
return null;
}
ArrayList<Img<Color>> aLis... |
125aa349-60c3-4334-a7a4-518d97f6e188 | 1 | public void AddNode(String v) {
Node newNode = new Node(v);
if (!nodes.containsKey(v)) {
nodes.put(v, newNode);
}
} |
9b9d9da1-5768-4be5-a876-33ac5cdf50dc | 0 | public Document toDOM(java.io.Serializable structure) {
RegularExpression re = (RegularExpression) structure;
Document doc = newEmptyDocument();
Element se = doc.getDocumentElement();
// Add the regular expression tag.
se.appendChild(createComment(doc, COMMENT_EXPRESSION));
se
.appendChild(createElement... |
3e57af3d-0a79-4828-82e5-b59d227ec0d6 | 2 | public void refreshSearches () { // method to refresh the search panel
int pageSize = pages.size(); // holds # of pages at the time when this method is called
for (int i = pageSize-1; i > 0; i --) { // loop through all page buttons
remove(pages.get(i)); // remove page buttons from panel
pages.remove(pages.ge... |
50e597ab-5242-4435-9010-2dc95d35e0f0 | 2 | public boolean isRemovable (int port)
{
int b;
if (port <= 0 || port > ports)
throw new IllegalArgumentException ();
b = getU8 (7 + (port / 8));
b >>= port % 8;
return (b & 0x01) == 0;
} |
f6745b67-5bed-40e7-be2d-26d3e3ae07aa | 7 | private boolean check_type(String dataBaseName, String tableName,
String entryValue, String entryName) {
ArrayList<Tables> tablesList = new ArrayList<Tables>();
SchemaParser ob = new SchemaParser();
tablesList = ob.loadDataBase(dataBaseName);
if (tablesList != null)
for (Tables tb : tablesList) {
if ... |
da461e2a-cdca-4047-acc1-450cd6cd8a0a | 4 | @Test
public void test_addition() {
int m = 2;
int n = 3;
Matrix m1 = new MatrixArray(m,n);
Matrix m2 = new MatrixArray(m,n);
Matrix m3 = new MatrixArray(m,n);
for(int i = 1; i <= m; i++){
for(int j = 1; j <= n; j++)
m1.insert(i, j, (double)(2*i+j));
}
for(int i = 1; i <= m; i++){
for(i... |
0d39c901-1b19-47e1-aaee-d5b2d37fe3e4 | 2 | @Override
public String execute(String[] args) {
String strVar = null;
StringBuffer strBuffer = new StringBuffer();
try{
File file = new File(ROOT, args[0]);
BufferedReader in = new BufferedReader(new FileReader(file.getCanonicalPath()));
while((strVar = in.readLine())!= null){
strBuffer.append(strV... |
8e6bf2ad-7165-4632-9f0f-cfc7378a896d | 1 | @Test
public void TestCreateHousehold() throws InstanceNotFoundException {
Household household = new Household("111-111-333-333",
new HashSet<Student>(), new HashSet<Bill>(),"Francisca");
try {
familyService.createHousehold(household);
} catch (DuplicateInstanceException e) {
e.printStackTrace();
}... |
edb195e0-8206-494f-b51e-5e955b740dfc | 8 | public EditAd(final Advertisement ad) {
setSize(new Dimension(620, 620));
setResizable(false);
setTitle("Edit Ad");
setIconImage(Toolkit.getDefaultToolkit().getImage("ICON2_Scaled.png"));
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(200, 200, 620, 620);
contentPane = new JPanel();
conten... |
506358ee-9a3b-4bcf-a014-5fd2463277dd | 0 | @Override
public void addExtension(String ext, boolean isDefault) {
extensions.put(ext, new Boolean(isDefault));
} |
0dcfe1b2-edad-4d9e-b2e2-5ccb4cc668f6 | 6 | public static void cleanMp3Songs(File directory)
{
for(File file : directory.listFiles())
{
// if this is a sub-directory, then go examine .mp3 files in it
if (file.isDirectory())
{
cleanMp3Songs(file);
}
else if (file.getName().endsWith(".mp3"))
... |
661d2065-028d-48a0-8aef-2fbd2c8fddbf | 2 | public void start() {
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
shell.dispose();
} |
1c1347c7-5818-48e4-8e0b-3debe8164f4c | 5 | public static Logger newLogger(int dstType, String... dstName) {
switch (dstType) {
case CONSOLE:
return new Console(dstName.length == 0 ? null : dstName[0]);
case FILE:
return new File(dstName.length == 0 ? null : dstName[0]);
case NULLDEVICE:
return new NullDevice(null);
default:
return null;
... |
51f7e22e-495c-4bd0-9235-6803741bd468 | 7 | public boolean check(CommandSender sender, String[] args)
{
String[] saArgs = api.parseArguments(args);
// No Name to check for.
if (saArgs.length == 0)
{
return false;
}
// Name Given to check for.
else if (saArgs.length == 1)
{
Player[] players = api.checkName(saArgs[0]);
if (players.... |
a061833e-861e-4d76-b881-88e0a476987f | 2 | public void save(){
FileWriter writer = null;
try {
Random rand = new Random();
String fileName = "aReinforcementLearner" + rand.nextInt() + ".txt";
writer = new FileWriter(fileName);
String toWrite = "" + score + "\n";
toWrite = toWrite + rl.saveString();
writer.write(toWrite);
} catch (IOExcep... |
de3baecd-6382-44ba-af67-637e26bddfc1 | 1 | public void printAddress(String enteredAddress, boolean lineSeparator) {
if (lineSeparator) {
System.out.printf("Address: %s\n", enteredAddress);
} else {
System.out.printf("Address: %s", enteredAddress);
}
} |
b1ad7880-c944-4da2-9536-121eb2785660 | 5 | public CheckResultMessage check26(int day) {
int r1 = get(6, 5);
int c1 = get(7, 5);
int r2 = get(39, 5);
int c2 = get(40, 5);
BigDecimal b = new BigDecimal(0);
if (checkVersion(file).equals("2003")) {
try {
in = new FileInputStream(file);
hWorkbook = new HSSFWorkbook(in);
b = getValue(r1 + d... |
9a7b4bd5-fe66-4eb6-a38a-0eee9d1f6663 | 4 | public static void solve(SudokuBoard b,int row, int col) {
//is a solution?
if(b.isFieldEmpty(row, col)) {
for(int i = 1; i <= 9;i++) {
if(b.placeNumber(row,col,i))
{
if(b.isSolved())
{
solutionCounter++;
b.printBoard();
}
else
{
//solve next field
... |
0a40bc7f-56c1-4dec-adf4-8e6b5ede7066 | 8 | private BitSet selectTriangles(String str) {
int n = view.getNumberOfInstances(TriangleComponent.class);
if (n == 0)
return null;
BitSet bs = new BitSet(n);
if ("selected".equalsIgnoreCase(str)) {
for (int i = 0; i < n; i++) {
if (view.getTriangle(i).isSelected())
bs.set(i);
}
return bs;
... |
e00a13c0-a751-4a3b-86d7-e0df12447f40 | 9 | protected Object newDynamicProxy(TypeToken typeToken, final ITestContext iTestContext) {
final Class<?> clazz = typeToken.getRawType();
final Map<String, Object> methodResults = new HashMap<String, Object>();
Object res = Proxy.newProxyInstance(clazz.getClassLoader(), new Class<?>[] { clazz }, ... |
8935f30a-3720-4aa0-8813-035b0069bbe8 | 5 | public boolean setNewValue(int depth, int value) {
if(isFull()) {
return false;
}
if(depth==1) {
if(o0==null) {
set0(new HuffmanNode(this, value));
return true;
}
else if(o1==null) {
set1(new HuffmanNode(this, value));
... |
f5959dbd-b1d7-4c3c-846f-22bdb13166f5 | 3 | private boolean onVieressa(Sijainti a, Sijainti b)
{
return (a.x() == b.x() && Math.abs(a.y() - b.y()) == 1) ||
(a.y() == b.y() && Math.abs(a.x() - b.x()) == 1);
} |
85eb60f0-948f-4df3-8857-6ca10baeed87 | 8 | public static List<Integer> getKNearestUsers(int k, int index) {
SparseVector base = rowMatrix.get(index);
List<Integer> nearestIndices = new ArrayList<Integer>();
List<Double> nearestScores = new ArrayList<Double>();
for (int i = 0; i < rowMatrix.size(); i++) {
if (i == index)
continue;
... |
b5f84090-ec7c-4f43-baff-68541cb8e10d | 8 | private void checkBalance(List<Token> tokens) {
int count = 0;
for (Token token : tokens) {
if (token == OPEN) {
count++;
} else if (token == CLOSE) {
count--;
}
if (count < 0) {
throw new ParseException("Clo... |
cd5d8211-762e-483c-a340-857819f67cdf | 7 | private static void generateTestCases(){
firstNumbers = new ArrayList<int[]>();
secondNumbers = new ArrayList<int[]>();
bases = new ArrayList<Integer>();
// you can change the bases here
int [] basesArray = {2,10,17};
int [] firstNum;
int [] secondNum;
int [] zero = {0};
Random rand = new Random... |
c307326a-ed91-4645-87fe-4c3aef54963f | 8 | public Set<Map.Entry<Byte,Character>> entrySet() {
return new AbstractSet<Map.Entry<Byte,Character>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TByteCharMapDecorator.this.isEmpty();
}
... |
4368688e-e4f5-4743-915c-f4cb893de275 | 7 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SequenceImpl0<?> other = (SequenceImpl0<?>)obj;
i... |
08e40932-d561-492f-a041-5b5d10122204 | 8 | private static String convertFromAnotherDecades(final char[] digits) {
final String start;
switch (digits[0]) {
//case '1' : start = "one"; break;
case '2' : start = "twenty"; break;
case '3' : start = "thirty"; break;
case '4' : start = "forty"; break;
... |
526c96a8-5906-41aa-90ce-3a066deea1e9 | 0 | public Dimension(int id){
this.id = id;
attachChild(SkyFactory.createSky(
ContentManager.getInstance().getAssetManager(), "Textures/enviroment/BrightSky.dds", false)); addLight(new Sun());
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White.mult(0.6f));
... |
f1660082-10ea-4fe2-be70-b7f14b053346 | 3 | public boolean dispatchKeyEvent(KeyEvent e) {
if (e.getID() == KeyEvent.KEY_PRESSED) {
keys[e.getKeyCode()] = true;
YSPL.player.newInput();
} else if (e.getID() == KeyEvent.KEY_RELEASED) {
keys[e.getKeyCode()] = false;
} else if (e.getID() == KeyEvent.KEY_TYPED) {
}
... |
6eb824da-37a0-404b-bb21-7578683abccc | 0 | public void setReplaceInterests(boolean replaceInterests) {
this.replaceInterests = replaceInterests;
} |
2b9ab915-1358-4f78-bb38-945891e4e7c8 | 6 | private int solve() {
int maxScore = 0;
for (int i = 2; i <= myWords.length; i++) {
int power = 1;
for (int lastWordIndex = 0; lastWordIndex < myWords.length; lastWordIndex++) {
for (int j = 1; j < prevDpState[0].length; j++) { // mask
if ((j & power) != 0) {
int previousMask = ~power & j; // m... |
47c4ee8a-217d-4b80-9782-88b347ccc8df | 4 | protected int compareFolders(final Entry e1, final Entry e2) {
final boolean f1 = e1 instanceof Folder;
final boolean f2 = e2 instanceof Folder;
if (f1 && !f2) {
return -1;
}
else if (!f1 && f2) {
return 1;
}
else {
ret... |
e4fb0cff-8990-4780-8b55-92fa78282e60 | 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... |
bd124160-d05c-4217-9351-f2a3937ee096 | 7 | public void lecturePGM(String nomFichier){
try{
String line;
BufferedReader fichier = new BufferedReader(new FileReader(nomFichier));
String delimiteurs = " \t";
if (!fichier.readLine().equals("P2")){
throw new WrongFileTypeException();
... |
4bce2a2a-42a7-4a7e-a090-ec0c5d95c981 | 5 | public void simplify() {
BigInteger factorNum = this.numerator.abs();
BigInteger factorDenom = this.denominator;
while(!factorNum.equals(BigInteger.ZERO)) {
BigInteger temp;
temp = factorNum;
factorNum = factorDenom.mod(factorNum);
factorDenom = temp;
}
this.numerator = this.numerator.divide(facto... |
b6960994-5888-4b66-a9ed-6f8bc83ab946 | 0 | public void setSession(int i, String time){
int hr, min;
hr = Integer.parseInt(time.substring(0,2));
min = Integer.parseInt(time.substring(3,5));
session[i].set(0,0,0,hr,min);
} |
8865c483-c73c-423a-998e-f3d4e97c89b3 | 8 | void evaluate2() throws InterruptedException {
if (!getAsTask()) {
EventQueue.invokeLater(new Runnable() {
public void run() {
model.notifyModelListeners(new ModelEvent(model, ModelEvent.SCRIPT_START));
}
});
}
stop = false;
interrupted = false;
if (script == null) {
out(ScriptEvent.FAIL... |
2162518f-44af-4de3-bf31-07c54b4b5daa | 4 | public void init(Session session,
byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C) throws Exception{
this.session=session;
this.V_S=V_S;
this.V_C=V_C;
this.I_S=I_S;
this.I_C=I_C;
try{
Class c=Class.forName(session.getConfig("sha-1"));
sha=(HASH)(c.newInst... |
74a857fa-4936-4644-a509-41de36af4da1 | 6 | public static Minecraft getMinecraftInstance()
{
if (instance == null)
{
try
{
ThreadGroup var0 = Thread.currentThread().getThreadGroup();
int var1 = var0.activeCount();
Thread[] var2 = new Thread[var1];
var0.enu... |
c2c1c58b-56ef-4a04-82b2-be1857d872e2 | 2 | public void setBaggageCurWeight(int baggageCurWeight)
throws CarriageException {
if ((baggageCurWeight >= 0) && (baggageCurWeight <= baggageMaxWeight)) {
this.baggageCurWeight = baggageCurWeight;
} else {
throw new CarriageException(
"Current baggage weight is out of range [0,"
+ this.passenge... |
b0cf8d0f-5701-4bfb-b43b-184166bee219 | 5 | @Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Log)) {
return false;
}
Log other = (Log) object;
if ((this.id == null && other.id != null) || (this.id != null... |
c97b3586-e2a7-4a74-91d8-c0f387dbe646 | 6 | @EventHandler
public void WolfHarm(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.getWolfConfig().getDouble("Wolf.Harm.DodgeChance... |
d6827511-f463-4f3e-9d26-fccae7526036 | 3 | private static int initOriginal(final Display display, Composite inComposite) {
final Composite original = new Composite(inComposite, SWT.BORDER);
int heightHint = 0;
try {
originalImage = new Image(display, Resource.class.getResourceAsStream(IMAGE_PATH));
if (originalImage.getImageData().depth != 8 && ori... |
c88acc5a-2c97-4373-af6d-824715368da2 | 8 | Expression parseExpression(LineAwareBufferedReader reader, int expectedLevel) throws ScriptParsingException, IOException {
skipBlankLines(reader);
String line = stripComments(reader.readLine());
int currentLine = reader.getCurrentLine();
if (line == null) {
return null;
}
// Find indentation level... |
9e6a36f0-13ae-439a-a385-994af45f1d53 | 3 | public void makeCandidate(User user) {
if (type == DnDElectionType.REFERENDUM)
throw new RuntimeException("Noone can become a candidate in a referendum");
if (getElectionState() == ElectionState.NOMINATIONS_OPEN &&
nomineeSet.contains(user)) {
nomineeSet.remove(user);
candidateSet.add(user);
}
else... |
a6351a03-62f6-4da7-a51a-187dc2fa0cbb | 3 | public void rewardWord(String[] units, Boolean[] stresses) {
// Look up the key, check if the word is there, create it if needed
String key = makeKey(units, stresses);
Word w = lexicon.get(key);
if (w == null) {
w = new Word(units, stresses, this.initScore, time);
lexicon.put(key, w);
if (trace) System... |
f5899b72-683b-4ce0-9316-cf9bf33a788c | 2 | public static void main(String[] args) {
Queue<Integer> queue = new LinkedList<Integer>();
Random rand = new Random(47);
for (int i = 0; i < 10; i++)
queue.offer(rand.nextInt(i + 10));
printQ(queue);
Queue<Character> qc = new LinkedList<Character>();
for (char c : "Brontosaurus".toCharArray())
qc.of... |
d255eee7-60cd-4c67-bdd5-9986879da8db | 4 | private String sendCheckCommand(IEZioLibrary eZioLib) {
byte[] ret = new byte[100];
int msgSize;
eZioLib.sendcommand("~S,CHECK");
for (int i = 0; i < 10; i++) {
msgSize = eZioLib.RcvBuf(ret, ret.length);
if (msgSize > 0) {
break;
}
... |
ef25d027-2b50-414e-a2c0-09dca691305a | 8 | public boolean set( int row, int column, int value ){
boolean flag = (0 <= row && row < DIGITS &&
0 <= column && column < DIGITS &&
0 < value && value <= DIGITS &&
board[row][column] == 0);
if( flag ){
board[row][column]... |
9cc21d3f-3dd1-4363-913a-93a64dacb6f6 | 1 | public void createEntity(Entity e) {
Point pos = e.getPosition();
int key = genKey(pos.getX(), pos.getY());
if (!entities.containsKey(key)) {
entities.put(key, new ArrayList<Entity>());
}
entities.get(key).add(e);
} |
7624a79b-b2ca-44ed-98b3-fbfe7cd92315 | 4 | private ResultSet retryResult(String query) {
Boolean passed = false;
while (!passed) {
try {
Connection connection = getConnection();
Statement statement = connection.createStatement();
ResultSet result = statement.executeQuery(query);
passed = true;
re... |
b97cdfb9-103b-4b37-9282-86cb29fb6f9a | 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 fe... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.