method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
1417ae97-cd07-4941-986d-a6ad3943e1cc | 3 | private static void splitReciprocal(final double in[], final double result[]) {
final double b = 1.0/4194304.0;
final double a = 1.0 - b;
if (in[0] == 0.0) {
in[0] = in[1];
in[1] = 0.0;
}
result[0] = a / in[0];
result[1] = (b*in[0]-a*in[1]) / (in... |
532b9b60-a4e0-4af9-929d-4a78f76fc160 | 7 | public static void main(String[] args) {
log = new Log();
options = new OptionParser();
options.parse(args);
log.setPath(options.logPath);
// if files == null -> read from stdin
List<File> files = options.getFiles();
List<IREntry> irEntries = new ArrayList<IREntry>();
try {
IRProcessor irProcessor ... |
38607161-d841-46f5-881a-351d188682ce | 9 | @Override
public After after(final Promise<?>... promises)
{
checkInTask();
final List<Task<?>> tmpPredecessorTasks = new ArrayList<Task<?>>();
for (Promise<?> promise : promises)
{
if (promise instanceof Task)
{
tmpPredecessorTasks.add((Task<?>) promise);
}
}
fina... |
abccb574-ba4c-4e74-8e7e-b1e260de826c | 5 | private static Integer getLocationCategory(Measurement m)
{
if (m == null || m.getId() == null) return -1;
Fingerprint f = HomeFactory.getFingerprintHome().getByMeasurementId(m.getId());
if (f != null) {
Location l = (Location) f.getLocation();
if (l != null && l.getId() != null) {
return Categ... |
9d1c570c-c8d8-4081-a397-7ab1aefe715a | 7 | public void gatherContextInformation(String triggerMessage) {
// Decode trigger message and get:
// (A) user presence (key: user_presence)
// (B) tags related to specific contextual situations that require specific recommendations
// (e.g. "humidRoom" -> "open window" (key: room_airquality);
// "noMovement" -... |
4a74584b-db94-4317-a8b5-5aeac5c9e530 | 9 | @Override
public void execute() {
if(cheminsAvant == null){
if(chemins != null){
cheminsAvant = new LinkedList<>();
for(Chemin Ch : chemins){
cheminsAvant.add(new Chemin(Ch));
}
}
... |
164f3ad9-b9d2-4cbb-8291-39e282991e2f | 3 | private int[] GetWiredsInSquare(int[] Pos)
{
int p_count = count;
int[] Wireds = new int[MAX_WIREDS_PER_ROOM];
int cur = 0;
for (int i = 0; i < p_count; i++)
{
if (WiredPos[i][0] == Pos[0])
{
if (WiredPos[i][1] == Pos[1])
... |
7da4e37a-1997-4ce3-b37b-2c4dc5c8ca2c | 8 | public static String reverseWords(char[] input) {
int left = 0;
int right = input.length-1;
//reverse the complete string first
while(left < right) {
//swap left and right
swap(input, left++, right--);
}
left = 0;
// now run till left is l... |
0e4775e7-b803-4821-93bf-affd2e6e8fc3 | 3 | public boolean checkRight(Tetromino current, int x, int y, int orientation) {
boolean result = true;
int col = x-1;
int width = current.getTiles()[0].length == 9 ? 3 : 4; // get width (3 or 4) of piece
width = current.getTiles()[0].length == 4 ? 2 : width;
if(col - current.bufferRight(orientation) > (9-width-... |
0fee999c-78f7-437a-a531-83259511cde0 | 2 | @Override
public boolean execute() {
Boolean val = true;
try {
List<Font> fonts = new ArrayList<Font>();
for (int i = this.startFrom; i <= this.endAt; i++) {
Font previousFont = this.document.getChildren().get(i)
.getFont();
Font newFont = new Font(previousFont.getName(),
previousFont.get... |
6d319480-7235-449a-b382-ac5a8a61e219 | 8 | public static Score[] getHighscores(){
Score[] scores = new Score[Config.HIGHSCORES_COUNT];
try {
if (Pang.game.haveToBeOffline) {throw (new java.net.ConnectException());}
Socket socket = new Socket(Config.HOST_NAME, Config.PORT_NUMBER);
OutputStream os = socket.getOutputStream();
... |
f73f65e3-8251-493b-99d6-e9515f285dda | 4 | public void createFromXML(NodeList options) {
Node n = options.item(0);
while(n != null) {
if(n.getNodeType() == Node.ELEMENT_NODE) {
if(n.getNodeName().equalsIgnoreCase("soundVolume")) {
soundVolume = Float.parseFloat(n.getFirstChild().getNodeValue());
... |
a4a7cb39-8398-4a17-8214-afdb2d9f4cd2 | 6 | static void init()
{
try{
p = new PrintWriter("bitvals.txt");
}
catch (Exception e)
{
System.out.println("Can't open the file");
}
try{
u = new URL("https://coinbase.com/api/v1/prices/buy");
}
catch (Exception e)
{
System.out.println("URL ain't right");
}
try{
h = (HttpURLConnection... |
a0f1733c-46b7-4b8a-8157-8a5925bf49c8 | 4 | public void initiateCloaking()
{
cloakedBlocks.clear();
BlockFace facing = getDirection(machineLocation.getBlock());
Vector miningOffset = getCloakingOffset(facing);
Location startingPos = machineLocation.getBlock().getLocation().add(
(int)miningOffset.getX(), (int)miningOffset.getY(), (int)miningOff... |
a1dc9a4e-8729-44c4-aa0b-4b4fff7dcc01 | 3 | public static Shape getWallShadow(Point2D source, Line2D wall, double panelWidth, double panelHeight) {
final Path2D shadow = new Path2D.Double();
final LineEquation eq = new LineEquation(wall);
final boolean clockwise = eq.getRelativePostion(source);
final Point2D p1 = clockwise ? wall... |
87d80f3a-7783-49f4-a38d-c9c0d592dac5 | 5 | public void doUpdating(){
if (shouldBeUpdated()){
update();
}
if (isDraggable()){
doMouseDraggingCheck();
}
for (Runnable r : runList){
r.run();
}
for (VGuiBase parent : childs) {
if (parent.shouldBeUpdated()) {
... |
2413d9e7-c426-4766-b0ae-98c2b6f61f2a | 1 | static int recursiveFactorial(int a){
if(a == 1){
return 1;
}
return a * recursiveFactorial(a-1);
} |
fd091669-9796-4574-92fc-caf67fa9606a | 8 | @Override
public void actionPerformed(ActionEvent e) {
if(connect == e.getSource())
{
connect();
}
if(leave == e.getSource())
{
leave();
}
if(quit == e.getSource()){
leave();
close();
System.exit(0);
}
/*
* If the user pressed enter in the message text box.
*/
... |
9369f5e8-16ff-48ce-a539-42d6b388425c | 6 | private static int hex2int(char c) {
int nybble;
if (c >= '0' && c <= '9') {
nybble = c - '0';
} else if (c >= 'a' && c <= 'f') {
nybble = 10 + c - 'a';
} else if (c >= 'A' && c <= 'F') {
nybble = 10 + c - 'A';
} else {
throw new Il... |
c2ec5fed-ae95-4598-bcc9-6df4cc83bae4 | 3 | public static void load(File file) {
YamlConfiguration config = new YamlConfiguration();
try {
config.load(file);
Major.add("Dollar");
Major.add("Dollars");
BankMajor.add("Dollar");
BankMajor.add("Dollars");
Minor.add("Coin");
Minor.add("Coins");
BankMinor.add("Coin");
BankMinor.add("Coi... |
70a98a5a-62d2-4c84-b867-ba65c8a43ccb | 9 | public BigramHiddenMarkovModel(Corpus corpus) {
this.vocabSize = corpus.getVocabularySize();
this.numSentences = corpus.getNumSentences();
this.tagBigrams = new HashMap<String, Map<String,Integer>>();
this.tagToToken = new HashMap<String, Map<String,Integer>>();
this.probabilityMatrix = new ArrayList<double[]... |
256d61bf-77f7-4440-82a5-670c010a5d3c | 2 | private void giveBirth(List<Actor> newFoxes)
{
// New foxes are born into adjacent locations.
// Get a list of adjacent free locations.
Field field = getField();
List<Location> free = field.getFreeAdjacentLocations(getLocation());
int births = breed();
for(int b = 0; ... |
0c7ac591-4ff4-40a3-9ea0-de306961451d | 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.... |
e3c66416-5775-4142-a9e6-be26e8f6fbaa | 8 | @Override
public void update(Observable o, Object arg) {
System.out.println(boardToString());
if (boardModel.getGameWon() || boardModel.getGameLost()) { //check win and loss conditions
//set up a window with message for each possible game outcome
if (boardModel.getGameLost()) {
System.out.println("Yo... |
9f565e70-a1fd-43fc-a4a3-06e29bff06af | 4 | protected JacksonJsonProvider getJsonProvider() {
if (delegate != null) {
return delegate;
}
synchronized (this) {
if (delegate != null) {
return delegate;
}
for (Object o : application.getSingletons()) {
if (o instanceof JacksonJsonProvider) {
delegate = ... |
f1cc596e-e8bf-4d35-9014-2e61306f49ad | 6 | void writeAVLMassData(FileOutputStream fos) {
PrintStream ps = new PrintStream(fos);
String lunit = "0.01 m";
if(this.getLengthUnit().equals("m")) lunit = "1 m";
else if(this.getLengthUnit().equals("in")) lunit = UnitConversor.INCHES_TO_METERS + " m";
String munit = "0.001 kg";... |
40f1b19b-d083-42c1-a3ca-476c5c273756 | 4 | public void literal()
{
if(have(Token.Kind.INTEGER)){
expectRetrieve(Token.Kind.INTEGER);
}
else if(have(Token.Kind.FLOAT)){
expectRetrieve(Token.Kind.FLOAT);
}
else if(have(Token.Kind.TRUE)){
expectRetrieve(Token.Kind.TRUE);
}
else if(have(Token.Kind.FALSE)){
expectRetrieve(Token.Kind.FALSE)... |
17aec39b-98a2-478d-9f66-da0babaa3ed7 | 7 | public void run() {
long currentTime = System.currentTimeMillis();
//mark things as deletable if they have not been updated
//in timeFail milliseconds
for(String key: this.gs.getMembershipList().getKeys()) {
long compareTime = this.gs.getMembershipList().getMember(key).getTimeStamp();
//mark as deletable... |
96942e5f-5f5b-4427-b0a7-c7fa7618b823 | 8 | @Override
public boolean isMoveValid(int srcRow, int srcCol, int destRow, int destCol) {
// TODO Auto-generated method stub
boolean result = false;
if(
((destRow == (srcRow - (srcRow - destRow))) && (destCol == srcCol)) || //up
((destRow == (srcRow + (srcRow - destRow))) && (destCol == srcCol)) || ... |
2220f530-bb11-41cb-ba21-9ed88c3dcfd2 | 4 | private void insertSubLCommandInfo(final SubLCommandInfo subLCommandInfo) {
//// Preconditions
assert subLCommandInfo != null : "subLCommandInfo must not be null";
assert mostTimeConsumingSubLCommandInfos != null : "mostTimeConsumingSubLCommandInfos must not be null";
assert MOST_TIME_CONSUMING_API_REQ... |
fe29be69-96a5-46c7-8080-bb329458933c | 3 | protected int getNeighbor(int cellId, Directions dir) {
if (cellId > countCells() - 1) {
return countCells() - 1;
}
if (cellId < 0) {
return 0;
}
Vector<Integer> sortedNeighbors = getSortedNeighbors(cellId);
if (dir == Directions.none) {
... |
5c62793d-1c13-464c-8e4b-7df8c7af3213 | 9 | public void parse(Node n){
if (null != n){
NodeList _list = n.getChildNodes();
String idstr = n.getAttributes().getNamedItem("id").getNodeValue();
id = Integer.parseInt(idstr);
for (int i=0;i<_list.getLength();i++){
String name = _list.item(i).getNodeName();
NodeList _l = _list.item(i).getChildNod... |
97ec8705-35b4-4c24-9a01-22575553e2ef | 9 | private Keycode convertKeycode(int extendedKeycode)
{
switch (extendedKeycode) {
case 65: // 'A'
case 37: // Arrow Left
return Keycode.LEFT;
case 68: // 'D'
case 39: // Arrow Right
return Keycode.RIGHT;
case 87: // 'W'
case 38: // Arrow Up
return Keycode.UP;
case 83: // 'S'
case 4... |
05cded42-fd20-4f4e-b5cd-08327dba6c58 | 2 | public void testGetField() {
Partial test = createHourMinPartial(COPTIC_PARIS);
assertSame(CopticChronology.getInstanceUTC().hourOfDay(), test.getField(0));
assertSame(CopticChronology.getInstanceUTC().minuteOfHour(), test.getField(1));
try {
test.getField(-1);
} catc... |
6deaa6c8-2538-44c9-abf5-5fab381c25a6 | 0 | public static String unescapeHTML(String text) {
text = StringTools.replace(text,"&","&");
text = StringTools.replace(text,"<","<");
text = StringTools.replace(text,">",">");
text = StringTools.replace(text,""","\"");
return text;
} |
6c469e00-fee0-43ef-9aa7-091d12490b21 | 3 | public Object[][] consultarProgramas(String codigo, String nombre, String nivel, String creditos) {
//<editor-fold defaultstate="collapsed" desc="consultarProgramas()">
if (!creditos.isEmpty()) {
try {
Integer.parseInt(creditos);
} catch (NumberFormatException num... |
ddb580a4-4d84-47d1-b300-6625d81eb4d5 | 4 | public AlumnoBean get(AlumnoBean oAlumnoBean) throws Exception {
if (oAlumnoBean.getId() > 0) {
try {
oMysql.conexion(enumTipoConexion);
if (!oMysql.existsOne("alumno", oAlumnoBean.getId())) {
oAlumnoBean.setId(0);
} else {
... |
2ccbc44d-8acf-425f-8a00-c66eab37951f | 8 | public List<JSONArray> extractFromCrawler(Path file, String[] related) {
List<JSONArray> results = new ArrayList<JSONArray>();
String name = "" + file;
boolean cont;
try {
Object obj = parser.parse(new FileReader(name));
JSONObject jsonObject = (JSONObject) obj;
JSONArray docs = (JSONArray)jsonO... |
649820c6-b9ca-4891-b56b-a7b39b64a31f | 8 | public static <E> boolean structurallyEquivalent(Dendrogram<E> dendrogram1,
Dendrogram<E> dendrogram2) {
if (dendrogram1 instanceof LeafDendrogram) {
if (!(dendrogram2 instanceof LeafDendrogram))
return false;
... |
6628d9e4-f7fb-490c-a75f-355294a8aef4 | 8 | private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
// Pick Up
boolean resPicked=false;
for(Reservation r:reservations){
if(r.getMember().getFirstName().trim().equals(jTextField32.getText().trim().s... |
fb2b140f-bc08-4e31-8898-8cb7b0b85641 | 2 | public Boolean getBooleanItem(String... names) throws ReaderException {
if (getItem(names).toString() == "true" || getItem(names).toString() == "false") {
return Boolean.parseBoolean(getItem(names).toString());
} else {
throw new ReaderException("No key exists with this type, keys: " + _parseMessage(names) + ... |
79ce64ca-c2ac-4604-8d3b-4c96c42a63a6 | 8 | public final GalaxyXLinkingParser.assignment_statement_return assignment_statement() throws RecognitionException {
GalaxyXLinkingParser.assignment_statement_return retval = new GalaxyXLinkingParser.assignment_statement_return();
retval.start = input.LT(1);
int assignment_statement_StartIndex = i... |
2a4082a8-69bd-44ac-91c2-4eb8eeb85f2f | 5 | public boolean isEqual(Cluster c)
{
if(!name.equals(c.getName()))
return false;
if(c.getNumberOfPoints() != points.size())
return false;
for(int i = 0; i < points.size(); i++)
{
if(!points.get(i).isEqual(c.getPointAt(i)))
return false;
}
if(!centoid.isEqual(c.getCentoid()))
return false;
... |
44ca68d5-9bf1-4fbb-a997-50ab311ab73a | 3 | public Match(int width, int height, int playerCount, int unitCount, int abilityCount) {
MatchCommandListener commandListener = new MatchCommandListener(this);
board = new Board(width, height, commandListener);
panel = new MatchPanel(commandListener, commandListener, board);
this.players = new Player[playerCo... |
df6716f6-4a7e-496f-b2c4-e767c249be1a | 1 | public boolean ModificarActividad(Actividad p){
if (p!=null) {
cx.Modificar(p);
return true;
}else {
return false;
}
} |
76b615b9-9238-4e90-87d8-98529cd5c858 | 9 | public PropQuad(PropQuad parent, Rectangle2D container, ArrayList<Entity> props, ArrayList<Rectangle2D> rects, ArrayList<Rectangle2D> flatRects) {
this.parent = parent;
this.container = container;
for(int x = 0; x<props.size(); x++) {
if(container.intersects(props.get(x).getBox())) {
this.props.add(props.g... |
3b92c77b-1dfc-481c-aa92-7793365bf0b1 | 2 | public SpinningWheel(int x, int y, int size, int delay) {
for(int i = 0; i < images.length; i++) {
images[i] = Utilities.resizeImage(size, size, "resources/InfiniteProgress_" + i + ".png");
currentImage = images[0];
}
this.setBounds(x, y, images[0].getWidth(null), images[0].getHeight(null));
timer = new T... |
f89493a0-7b41-43d0-acfa-b0be57b43bb3 | 3 | public void sendState(sharedstate.SharedState state) throws Exception {
System.out.println("Sending state");
if (!connected) {
byte[] sendBuffer = ("type:connect\nid:" + state.getMyId() + "\n").getBytes();
DatagramPacket sendPacket = new DatagramPacket(sendBuffer, sendBuffer.length, ip, port);
sock.send(se... |
08258a75-846a-4feb-9f31-8eaaf1a3fdf6 | 4 | public FeedManager(){
loadListbox();
this.setPreferredSize(new Dimension(500,255));
this.setResizable(false);
this.setSize(500, 500);
ActionListener action = (ActionEvent e) -> {
if(null != e.getActionCommand()){
switch (e.getActionCommand()) {
... |
952b80dd-a99a-44f2-91c0-b082d5164b36 | 4 | @Override
public int compare(Tile o1, Tile o2)
{
if (o1.getPriority() == Tile.Priority.Low && o2.getPriority() == Tile.Priority.High)
{
return 1;
}
if (o1.getPriority() == Tile.Priority.High && o2.getPriority() == Tile.Priority.Low)
{
return -1;
}
return 0;
} |
7072b9f1-8964-496a-9bc5-4f813fb6b3de | 9 | private void updateTable(){
_files = new ArrayList<File>();
_dirs = new ArrayList<File>();
int rowCount=_tablemodel.getRowCount();
for (int i = rowCount - 1;i >= 0;i--) {
_tablemodel.removeRow(i);
}
File folder = new File(_currentpath);
... |
f65020dd-0ee4-4697-9611-1418249c1ca3 | 3 | private boolean accepts(final String[] lines) {
for (int i = 0; i <= 3; i++)
if (this.text[i] != null && !this.text[i].matcher(lines[i]).find())
return false;
return true;
} |
bcef4e4c-1c2f-4e65-9ae9-107bd6ecafb2 | 9 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ExpressionNode that = (ExpressionNode) o;
if (left != null ? !left.equals(that.left) : that.left != null) return false;
if (right != null ? !ri... |
31ea6981-dc43-4625-af6b-f99738215ea9 | 1 | public boolean checkUniqueNickname(String nickname){
boolean isUnique = false;
try {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
String url = "jdbc:derby:" + DBName;
Connection connection = DriverManager.getConnection(url);
Statement statement = connection.createStatement();
String sqlStat... |
3d31898d-6500-4c33-9588-0b83cb420d71 | 0 | @Test
public void test_removeAllPawns(){
assertNotNull(board);
assertEquals(numberOfPawns, board.numberOfPawns());
Pawn pawn1 = new Pawn('l', 3,4, board);
Pawn pawn2 = new Pawn('m', 2,3, board);
board.addPawn(pawn1);
board.addPawn(pawn2);
board.removeAllPawn... |
56804940-48f0-475c-b616-4cab17711cec | 4 | public void inscrireJoueurs() {
Scanner sc = new Scanner(System.in);
System.out.println("Entrez le nombre de joueurs :");
int NbJoueurs;
if(this.isDetermine()){NbJoueurs = 4;}
else{NbJoueurs = sc.nextInt();}
if(NbJoueurs < 2){NbJoueurs... |
ceb2d80d-e4b8-47de-8e80-eef40971c89b | 6 | public boolean isRunActive(boolean quiet) {
try {
URL url = new URL(HTTP_DATA_SERVER + "status");
String reply = _readText(url.openStream()).trim();
Document document = _documentBuilder.parse(new InputSource(new StringReader(reply)));
NodeList nlist = document.getElementsByTagNam... |
2e9d1c47-1e9f-4ac2-8845-dcc4c6a07044 | 0 | public static void main(String[] args)
{
new DataType(4);
} |
6f35b8c3-2e11-42f5-b83a-ef85db11621b | 6 | public Player findPlayer(String name) {
Player toreturn = null;
for (int i = 0; i < players.size(); i++) {
if (name.equals(players.get(i).username))
return players.get(i);
else if (players.get(i).username.indexOf(name) != -1 && toreturn == null)
toreturn = players.get(i);
else if (players.get(i).us... |
e92d943d-331e-49b8-8acd-423d583937c9 | 6 | void updateVerticalBar () {
if (drawCount > 0) return;
ScrollBar vBar = getVerticalBar ();
if (vBar == null) return;
int pageSize = (clientArea.height - getHeaderHeight ()) / itemHeight;
int maximum = Math.max (1, itemsCount); /* setting a value of 0 here is ignored */
if (maximum != vBar.getMaximum ()) {
vBar... |
a71ec067-c9c8-4845-8451-09e8b42b04e3 | 9 | * @param options
* @param legaloptionsAtypes
* @param coercionerrorP
* @param allowotherkeysP
* @return PropertyList
*/
public static PropertyList parseOptions(Stella_Object options, Cons legaloptionsAtypes, boolean coercionerrorP, boolean allowotherkeysP) {
{ PropertyList self000 = PropertyList.ne... |
67058cc4-50e0-405d-83b3-0f76a8d76498 | 7 | public boolean onCommand(CommandSender sender, Command cmd, String label,
String[] args) {
if (args[0].equalsIgnoreCase("create")) {
if (!sender.hasPermission("scrollteleportation.create")) {
sender.sendMessage(ChatColor.RED
+ "You are not allowed to create scrolls");
return true;
}
if (!(... |
dd58d35a-cf11-4e0e-b7c0-fa7d52e542ef | 4 | public void aniadirSeg (int numSeg) {
if (numSeg>=0) {
seg+=numSeg;
if (this.getSeg()>=60) {
int acum=this.getSeg()/60;
this.setSeg(seg%=60);
min+=acum;
if(this.ge... |
782ec3d2-ed5d-4ee9-93a6-acfa8f8f86d5 | 2 | void parseAttDef(String elementName) throws java.lang.Exception
{
String name;
int type;
String enum_ = null;
// Read the attribute name.
name = readNmtoken(true);
// Read the attribute type.
requireWhitespace();
type = readAttType();
// Get... |
4f096a95-380d-4609-8439-05d17e3b7702 | 7 | public static void main(String args[]){
barcos = new ArrayList<Barco>();
int op;
do{
System.out.println("\n\nMENU PRINCIPAL");
System.out.println("1- Agregar Barco");
System.out.println("2- Agregar Elemento");
System.out.println("3- Vaciar... |
c424cc05-f777-4063-8fb0-d248266b8a99 | 5 | public Object nextEntity(char ampersand) throws JSONException {
StringBuffer sb = new StringBuffer();
for (;;) {
char c = next();
if (Character.isLetterOrDigit(c) || c == '#') {
sb.append(Character.toLowerCase(c));
} else if (c == ';') {
... |
c8230cc3-9073-481a-9b83-a60c3e81e99f | 6 | public boolean getBoolean(int index) throws JSONException {
Object object = this.get(index);
if (object.equals(Boolean.FALSE)
|| (object instanceof String && ((String) object)
.equalsIgnoreCase("false"))) {
return false;
} else if (object.equal... |
db532c6e-630a-433f-9b09-2640d6580375 | 9 | void run() {
Vertex[] vertices = new Vertex[SIZE * SIZE];
for (int x = 0; x < SIZE; x++) {
for (int y = 0; y < SIZE; y++) {
vertices[index(x, y)] = new Vertex(x, y);
}
}
for (int x = 0; x < SIZE; x++) {
for (int y = 0; y < SIZE; y++) {
Vertex v = vertices[index(x, y)];
// add left
if ... |
d6de328a-69a3-417c-ae1a-fe9439be29fb | 9 | public int checkELU()
{
if(cornerMap.get("E").equals("E")
&& cornerMap.get("L").equals("L")
&& cornerMap.get("U").equals("U"))
{
return SOLVED;
}
if(cornerMap.get("E").equals("U")
&& cornerMap.get("L").equals("E")
&& cornerMap.get("U").equals("L"))
{
return CW;
}
if(cornerMap.get("E... |
ab25d68b-a823-4a2d-b241-14f4f929919d | 0 | public Items() {
} |
a42279e2-d229-45c5-acaf-78e04e5a36f9 | 7 | public static void main(String[] args) {
long startTimeMillis = System.currentTimeMillis();
int[] factorials = new int[10];
factorials[0] = factorials[1] = 1;
for (int i = 2; i < factorials.length; i++)
factorials[i] = factorials[i - 1] * i;
int[] lengths = new int[1000000];
for (int i = 0; i < lengths.... |
5db097e0-14ea-4320-bd23-646709fc695e | 6 | public static String request(String url) {
CloseableHttpClient httpclient = HttpClients.createDefault();
CloseableHttpResponse response = null;
StringBuilder builder = new StringBuilder();
StringBuilder reqUrl = new StringBuilder();
reqUrl.append(URL);
reqUrl.append(url);
reqUrl.append("&key=");
reqUrl... |
8c731c69-6b75-4a73-94a9-9af96852a552 | 7 | private float[] getComputedWindow() {
int ix = (blockFlag ? 4 : 0) + (previousWindowFlag ? 2 : 0) + (nextWindowFlag ? 1 : 0);
float[] w = windows[ix];
if (w == null) {
w = new float[n];
for (int i = 0; i < leftN; i++) {
float x = (float) ((i + .5) / leftN... |
8213b289-e9cf-486b-80c1-8bcb1321ad12 | 4 | private void oilResatBuffer(CPRect srcRect, CPRect dstRect, int[] buffer, int w, int alpha1, int color1) {
if (alpha1 <= 0) {
return;
}
int by = srcRect.top;
for (int j = dstRect.top; j < dstRect.bottom; j++, by++) {
int srcOffset = srcRect.left + by * w;
int dstOffset = dstRect.left + j * widt... |
4b6022d6-c17f-4a48-8442-5e908c21b9f0 | 4 | public static int verify(InputStream stream) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(stream));
int lineNum = 0;
String prev = "";
while(true) {
lineNum++;
String line = in.readLine();
if(line == null) break;
if(line.length() == 0) continue;
//t... |
6db7a54f-7343-4ac9-8ba1-fe19081de3b3 | 7 | public void addNeighbors(int x, int y, int z, BlockType blockType){
if (!blockType.isTransparent())
return;
if (getVisited(x - 1, y, z) == NOT_VISITED) {
queue.add(new Point3D(x - 1,y, z));
setVisited(x-1, y, z, QUEUED);
}
if (getVisited(x + 1, y, z) == NOT_VISITED) {
queue.add(new Point3D(x + 1,... |
d5d95838-5c74-4f2e-84ef-c398d4b72c1d | 6 | @Override
public Dimension getPreferredSize() {
List<Column> columns = mOwner.getModel().getColumns();
boolean drawDividers = mOwner.shouldDrawColumnDividers();
Insets insets = getInsets();
Dimension size = new Dimension(insets.left + insets.right, 0);
ArrayList<Column> changed = new ArrayList<>();
for (Co... |
2bb64b8b-a9dc-4e2b-b1be-b739e8d09c1e | 9 | public Map getHeaders()
{
Map lisOfHeader=new LinkedHashMap();
FileInputStream file = null;
try {
try {
file = new FileInputStream(new File("C:\\AEM-CQ-Automation\\AEM-CQ-Automation\\Ford\\ExcelToXml.xlsx"));
... |
ed56c541-0080-4636-9cbb-c094dc1b1635 | 3 | private void waitForThread()
{
if ((this.thread != null) && this.thread.isAlive()) {
try {
this.thread.join();
} catch (final InterruptedException e) {
e.printStackTrace();
}
}
} |
bb6790b1-4efd-4a89-9cd6-829e97221a64 | 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... |
02714403-8ff1-40c9-8890-55db9e820b62 | 9 | public static EntityFilter from(ConfigurationSection section) throws InvalidConfigurationException
{
EntityFilter filter = new EntityFilter();
for (String key : section.getKeys(false))
{
String value = section.getString(key);
boolean include;
if (value.equalsIgnoreCase("ignore"))
include = false;
... |
0877f0be-43fb-48c7-8dbb-72efd94837a0 | 8 | @Before
public void setUp() {
this._instance = new ChristmasDay();
this._years = new LinkedList<Integer>();
for (int year = 1974; year < 2021; year++)
this._years.add(year);
this._ChristmasDayUnitedKingdoms = new HashMap<Integer, GregorianCalendar>();
for (int yea... |
575d970b-4206-454f-b94d-b3dd42d06f1e | 9 | public void paint(Graphics g)
{
Font font=g.getFont();
if(fontSize==-1)
fontSize=font.getSize();
if(font.getSize()!=fontSize)
font=font.deriveFont(fontSize);
font=new Font("sansserif",Font.PLAIN,fontSize);
g.setFont(font);
FontMetrics fm=getFontMetrics(font);
Rectangle2D titleRect=fm.getStringB... |
479a31a0-9876-4642-9864-78db66c61af3 | 2 | private static void makeDefaults(String filename, Server server, Properties p) {
//TODO Fill in all defaults
server.Log("System config not found..creating..");
p.addSetting("Server-Name", "[GGS] Default Server");
p.addSetting("WOM-Alternate-Name", "[GGS] Default Server");
p.addSetting("MOTD", "Welcome!");
p... |
d16d8319-caa1-4e5d-a882-e6eb853d4cbb | 1 | public static void main (String[] args){
int ss = 0;
int sum = 0;
for (int i=1;i<=100;i++){
sum+=i;
ss+=i*i;
}
System.out.println(sum*sum - ss);
} |
fcf4a890-29a7-498b-86fe-36f9d1cf991a | 3 | public void buyObjective()
{
if (this.game.chestOpen && this.chestWood >= 50 && this.chestStone >= 30)
{
// build objective
// end game
this.chestWood -= 50;
this.chestStone -= 30;
System.out.println("juhuu gewonnen!");
this.game.house = true;
}
} |
b1b16447-f02d-4165-a5a4-738f8a877d90 | 3 | public int getIndexSize (int loc) {
// System.out.println("Getting size of index at "+loc);
int hold = pos;
pos = loc;
int count = readInt (2);
if (count <= 0) {
return 2;
}
int encsz = readByte ();
if (encsz < 1 || encsz > 4) {
thr... |
1a92da74-5f9a-4fc6-87c3-1fc67684bcff | 3 | public void flushInputStream(byte buf[], int len) throws IOException {
int i = 0;
if (closed) {
return;
}
int k;
for (; len > 0; len -= k) {
k = inputStream.read(buf, i, len);
if (k <= 0) {
throw new IOException("EOF");
}
i += k;
}
} |
1902ba7c-75f4-4aa4-a7ed-fa3c547f0635 | 4 | public int uniquePaths(int m, int n) {
// A[i][j] = A[i-1][j] + A[i][j-1]
int[][] A = new int[m][n];
for( int i = 0; i < m; i++ ) A[i][0] = 1;
for( int j = 1; j < n; j++ ) A[0][j] = 1;
for( int i = 1; i < m; i++ ) {
for( int j = 1; j < n; j++ ) {
A[i... |
8a9b98cf-9bd3-46c5-8274-af4e9b3d936a | 0 | public Transition copy(State from, State to) {
return new VDGTransition(from, to);
} |
7720501e-876f-4205-96c2-27e3d5cef9ad | 4 | @Override
public void execute(CommandSender sender, String worldName, List<String> args) {
this.sender = sender;
if (worldName == null) {
error("No world given.");
reply("Usage: /gworld listplayers <worldname>");
} else if (!hasWorld(worldName)) {
reply("World not found: " + worldName);
} else {
... |
65a5262f-fec5-41ff-9eca-ddb4628b5d5f | 6 | public void initSimulationPanel() {
if (results == null) return;
int maxPeopleEating = Integer.MIN_VALUE;
int maxPeopleFinished = Integer.MIN_VALUE;
int maxPeopleInFoodQueue = Integer.MIN_VALUE;
int maxPeopleInTableQueue = Integer.MIN_VALUE;
int actualPeopleEating;
int actualPeopleFinished;
int actualPe... |
910d052f-81a7-4a83-be16-bea37736f2af | 5 | private static byte method513(char c) {
if (c >= 'a' && c <= 'z')
return (byte) ((c - 97) + 1);
if (c == '\'')
return 28;
if (c >= '0' && c <= '9')
return (byte) ((c - 48) + 29);
else
return 27;
} |
a7ac778e-cf11-4005-b451-7a2712ee0c75 | 2 | public int singleNumber(int[] A) {
int res = 0;
for(int i = 0; i < 32; ++i){
int bit = 1 << i;
int count = 0;
for(int a : A){
count += (a&bit) >> i;
}
res |= (count%3) << i;
}
return res;
} |
a1f3c2c5-0ab2-46c6-a9bd-be2ec96f0b47 | 0 | public EncryptedDataType createEncryptedDataType() {
return new EncryptedDataType();
} |
b1731bb4-283d-472c-9f25-537774082e84 | 4 | public void run()
{
try
{
// reader for incoming messages initialization
ObjectInputStream objIn = new ObjectInputStream(clientSocket.getInputStream());
// wait for a request
CAMessage received = (CAMessage)objIn.readObject();
... |
2c689d51-c448-4ba7-9305-8adcc0eefe79 | 9 | @Override
public BakingActionResult checkActionIsApplicableInState(State state, String[] params) {
BakingActionResult superResult = super.checkActionIsApplicableInState(state, params);
if (!superResult.getIsSuccess()) {
return superResult;
}
String agentName = params[0];
ObjectInstance agent = stat... |
269118db-5692-46b6-9eea-60665dc2d40f | 0 | public static String convertResourcePathToClassName(String resourcePath) {
Assert.notNull(resourcePath, "Resource path must not be null");
return resourcePath.replace('/', '.');
} |
a0c359b9-ed9d-4205-9270-b33e3a529e66 | 0 | public void setDefault(FileProtocol defaultProtocol) {
this.defaultProtocol = defaultProtocol;
} |
1a82532c-cbb6-4a9d-bbba-1109598d9742 | 0 | public void draw() {
//Buffer for manual double buffering
BufferedImage buffer = new BufferedImage(GraphicsMain.WIDTH, GraphicsMain.HEIGHT, BufferedImage.TYPE_INT_ARGB);
Graphics2D gBuffer = (Graphics2D)buffer.getGraphics();
drawGround(gBuffer);
drawWorld(gBuffer);
g.drawImage(buffer, 0, 0, GraphicsMain.WI... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.