method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
da1cfd3f-c79c-42ea-8635-5b2371b03b64 | 6 | public static void main(String[] args) {
int a, b, c ;
a = 2;
b = 3;
if (a < b) System.out.println("a is less than b");
if (a == b) System.out.println("you wont see this");
System.out.println();
c = a - b;
if(c >= 0) System.out.println("c is non negative")... |
6ad919df-27fa-41c9-a1dd-4f015dd60e46 | 0 | private Object readChar() {
return new Character((char) bytes[streamPosition++]);
} |
afa05cd3-fdea-4fbd-92e7-20e95dcda3ea | 8 | public String replaceChar(char ch) {
String replaceCh = "";
if (ch == '\n') {
return "\\n";
}
else if (ch == '\t') {
return "\\t";
}
else if (ch == '\b') {
return "\\b";
}
else if (ch == '\r') {
return "\\r";
... |
9d9fc0f6-bcfc-4f0a-989d-1e8fc8686d12 | 5 | @Override
public void close() throws IOException {
if (connection == null) return;
active = false;
try {
RedisResult result = handler.request(new ProtoBuilder().array(Protocol.Command.QUIT).build(), timeout);
if (result == null) {
throw new RedisTimeoutException();
}
if (result.... |
734570db-7181-4021-9554-6605cfbef441 | 3 | public static ArrayList<Card> generateDeck() {
ArrayList<Card> deck = new ArrayList<>(DECK_SIZE);
for (int s = 0; s < NUM_SUITES; s++) {
for (int v = 0; v < NUM_VALUES; v++) {
if (NUM_SUITES * s + v >= DECK_SIZE) {
break;
}
... |
cec0ef57-a8a0-47d2-bf4d-7d60e65d58fa | 4 | private String getInvoiceId() {
String data = null;
try {
Connection conn = getConnection();
boolean error = true;
conn.setAutoCommit(false);
conn.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
while (error) {
... |
44332686-763e-4d7f-8afe-e274274dc584 | 4 | public List<BipolarQuestion> getPublicBipolarList(String parentId, String actionType) {
List<BipolarQuestion> bipolarQuestionList = new ArrayList<BipolarQuestion>();
Element bipolarQuestionE;
BipolarQuestion bipolarQuestion;
for (Iterator i = root.elementIterator(actionType); i.hasNext();) {
bipolarQuestionE... |
ea81c373-7753-4575-a93e-20c505744436 | 2 | public String getOrdernumberByCarnumberAndOrdertime(Statement statement,String carnumber,String ordertime)//根据预定进入时间和车牌号查找订单
{
String result = null;
sql = "select ordernumber from ParkRelation where carnumber = '" + carnumber +"' and ordertime = "+ordertime+"'";
try
{
ResultSet rs = statement.executeQuery(... |
df176186-9ceb-4ada-bf6e-143619928554 | 8 | protected void columnModelToView() {
String[] columnNames = new String[this.columns.size()];
String[] columnTooltips = new String[this.columns.size()];
double[] columnWidths = new double[this.columns.size()];
for (int i = 0 ; i < this.columns.size() ; i++) {
columnNames[i] = this.columns.get(i).name;
c... |
b4b068ea-97dd-41c5-abbe-01462cf8897f | 1 | private void checkRestoreCuror() {
int selectedStart = registry.getInvSlotFrom();
if (selectedStart > -1) {
restoreCursor();
}
selectedStart = -1;
registry.setInvSlotFrom("", selectedStart);
} |
180d1332-5673-4d99-a2ba-6a2dc918ffd3 | 6 | public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // SHORT_VALUE
return SHORT_VALUE;
case 2: // INT_VALUE
return INT_VALUE;
case 3: // LONG_VALUE
return LONG_VALUE;
case 4: // DOUBLE_VALUE
return DOUBLE_VALUE;
... |
a24980e5-e135-4318-a1e2-baf7026ff664 | 0 | public static FontMetrics getFontMetrics2(Font font) {
Graphics2D g2 = (Graphics2D) new BufferedImage(1, 1,
BufferedImage.TYPE_INT_ARGB).getGraphics();
g2.setFont(font);
return g2.getFontMetrics();
} |
095d4721-9680-4d8e-bde5-8302db709db4 | 1 | private MemcachedCache initializeClient(String poolName) {
MemcachedCache cache = clientPool.get(poolName);
if (cache == null) {
// I don't know why binary protocol is invalid in my pc, so just
// use tcp ascii;
MemCachedClient client = new MemCachedClient(poolName, true, false);
cache = new MemcachedCa... |
88274a28-64d1-43e1-bc31-7abe9d863562 | 6 | public static void main(String[] args) {
int sendSpeed = args.length > 0 ? Integer.parseInt(args[0]) : 32000000;
int packetSize = args.length > 1 ? Integer.parseInt(args[1]) : 16;
int fileSize = args.length > 2 ? Integer.parseInt(args[2]) : 1000;
int bufferSize = args.length > 3 ? Integer.parseInt(args[3]) : 10... |
9f551c8d-24af-474c-8ded-feb5cb2be185 | 6 | public void init(FileInputStream is) throws Exception
{
int save_active;
// Get saveram start, length (remember byteswapping)
// First check magic, if there is saveram
if(content[0x1b0] == 'R' && content[0x1b1] == 'A')
{
// Make sure start is even, end is odd, for... |
1756aef7-aa56-47cd-b631-eff9458c1046 | 7 | protected void cleanScriptHosts(final SLinkedList<LocatedPair> hosts, final PhysicalAgent oneToDel, final boolean fullCleaning)
{
PhysicalAgent PA;
for (final LocatedPair W : hosts)
{
if(W==null)
hosts.remove(W);
else
{
PA=W.obj();
if((PA==null)
||(PA==oneToDel)
||(PA.amDestroyed())
... |
b045a3d3-6a16-49d4-b153-d966b7778781 | 6 | private boolean isValidChild(int archiveId, int childId) {
anInt662++;
if (!isInitialized())
return false;
if (archiveId < 0 || childId < 0 || archiveId >= indexTable.amountChildEntries.length || childId >= indexTable.amountChildEntries[archiveId]) {
if (Class285.aBoolean4741)
throw new IllegalArgumentEx... |
00f9fb66-ffb4-4739-8fc4-adb7b1dc4046 | 3 | @Override
public boolean dispatchKeyEvent(KeyEvent e) {
if (e.getID() == KeyEvent.KEY_PRESSED) {
keyPressed(e.getKeyCode());
} else if (e.getID() == KeyEvent.KEY_RELEASED) {
keyReleased(e.getKeyCode());
} else if (e.getID() == KeyEvent.KEY_TYPED) {
keyTyped(e.getKeyChar());
}
return false;
} |
c746f672-7894-48c9-b2e8-0bc9d0f36406 | 9 | public boolean containsValue (Object value, boolean identity) {
V[] valueTable = this.valueTable;
if (value == null) {
K[] keyTable = this.keyTable;
for (int i = capacity + stashSize; i-- > 0;)
if (keyTable[i] != null && valueTable[i] == null) return true;
} else if (identity) {
for (int i = capacity... |
9280a98f-e530-41f4-b0df-569f596609d7 | 9 | @Override
protected void animateRearLED() {
if (rearCurrent == rearTarget) {
rearTarget = random.nextInt(26);
rearDirection = rearCurrent < rearTarget;
}
int rearLeftInd = (25 - rearCurrent) * 3;
int rearRightInd = (26 + rearCurrent) * 3;
rearBytes[r... |
fd8db4e6-b105-4595-a349-b1798801fbf9 | 7 | @Override
public int castingQuality(MOB mob, Physical target)
{
if(mob!=null)
{
final Room R=mob.location();
if(R!=null)
{
if((R.domainType()!=Room.DOMAIN_INDOORS_CAVE)
&&(R.domainType()!=Room.DOMAIN_INDOORS_STONE)
&&(R.domainType()!=Room.DOMAIN_OUTDOORS_MOUNTAINS)
&&(R.domainType()!=Room... |
96bf6117-f4e8-4207-b321-3c22245af79b | 0 | public boolean getRight(){
return right;
} |
1cefc32e-a891-4ea6-adfd-98d552d6c903 | 1 | public void testForStyle_shortTime() throws Exception {
DateTimeFormatter f = DateTimeFormat.shortTime();
DateTimeFormatter g = DateTimeFormat.forStyle("-S");
assertSame(g, f);
DateTime dt = new DateTime(2004, 6, 9, 10, 20, 30, 0);
String expect = DateFormat.getTimeInstance(DateF... |
d86c5e11-9a77-4579-b742-f292d31a2eb8 | 0 | public final void setMetadata(byte metaData){
short id = getID();
metaData = (byte)(metaData << 4) ;
metaData = (byte)(metaData >>> 4);
data = (char)(id|metaData);
} |
a4081468-a2db-4d98-aa81-e2c0321489e3 | 5 | private void moverTarea(String titulo) {
int indice;
switch (jCBEstado.getSelectedIndex()) {
case 1:
indice = buscarTarea(this.proyectos.get(index).getProximo(), titulo);
if (indice != -1) {
this.proyectos.get(index).getHaciendo().add(this.... |
b39bc20d-df69-4ba2-8fef-6504a50ed6e3 | 8 | private void hentBetalere(boolean ignoreError) {
String value = betaler_textField.getText();
ArrayList<Betaler> betalere;
if (!value.isEmpty()) {
betalere = sLEBHandler.getBetalerV2(value);
if (!betalere.isEmpty()) {
betalere_table.setEnabled(true);
... |
e4b1a751-a30e-4e78-a5e9-bb7f9d24d780 | 3 | @Override
public void run() {
try {
sender.SendMessage(packet, broadcast, socket);
totalTX++;
if (JaguarExist){
sender.SendMessage(jag, broadcast, socket);
totalTX++;
}
if (CanipedeExist){
sender.SendMessage(rcm, broadcast, socket);
totalTX++;
}
} catch (IOExcep... |
d4623376-3cd3-4f87-b82e-9264019da2b5 | 8 | @Test
public void testRollDie(){
// This is a random function so tests multiple times for range
int sum = 0;
// Test Range for one die
int i = 0;
while (i < 100){
sum = game.rollDice(1);
assertTrue((sum <= 2) && (sum >= 0));
i++;
}
// Test Range for two die
i = 0;
while (i < 100){
... |
e489434c-84f1-4142-ba4b-20c7e8e6c6cf | 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... |
2c30ab60-8c0d-484a-89ea-aaef23ee76f3 | 8 | private void readSqlIni() {
String sybasePath = System.getenv("SYBASE");
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(sybasePath + File.separatorChar + "ini" + File.separatorChar + "sql.ini"));
String line;
String serverName = null;
while ((line = reader.readLine()) !... |
8d9dd9d0-6854-413f-b474-7dce235df634 | 8 | @Override
public Scalar evaluate(final ScriptEnvironment e) {
if (return_type == ScriptEnvironment.FLOW_CONTROL_THROW) {
final Scalar temp = (Scalar) e.getCurrentFrame().pop();
if (!SleepUtils.isEmptyScalar(temp)) {
e.getScriptInstance().clearStackTrace();
e.getScriptInstance().recordStackFrame("<ori... |
ace6c806-20dd-40d3-972d-9bc0a1d97955 | 2 | public static Image track(Frontier frontier, Panel panel, int iterations) {
Image image = (Image) frontier.getImage();
int i = 0;
boolean changed = true;
// long time0 = System.currentTimeMillis();
while (i < iterations && changed) {
changed = frontier.change();
i++;
}
panel.setTempImage(drawBorder(f... |
107b24d3-06a6-47c1-9ae8-988f62d2af85 | 0 | public boolean isDirected() {
return directed;
} |
27494c4a-1850-4cd1-9c8b-4677c4a5e6cb | 6 | public static <T> Collection<T> added( Collection<T> left, Collection<T> right )
{
if ( right == null || right.isEmpty() ) {
return java.util.Collections.emptyList();
}
if ( left == null || left.isEmpty() ) {
return new ArrayList<T>( right );
}
Collect... |
b279a92e-7f6f-482a-8c8e-5908addd0957 | 2 | public boolean addCharacter(Character character){
int positionX=character.getXPosition();
int positionY=character.getYPosition();
if (mapObjectGrid[positionX][positionY]==null && characterGrid[positionX][positionY]==null){
characterGrid[positionX][positionY]=character;
return true;
}
else
return f... |
86859939-91c5-4763-acaa-1abd4b3b48dd | 7 | public static void testPlay() {
while (true) {
final Key key = engine.getDisplay().readKeyInput();
if (key != null) {
switch (key.getKind()) {
case ArrowLeft:
engine.swipe(Engine.D_LEFT);
break;
case ArrowRight:
engine.swipe(Engine.D_RIGHT);
break;
case ArrowUp:
engin... |
d1503147-db2e-4c6d-b09b-8a73b20b16f4 | 3 | public void GenerateFileList(File node) {
// add file only
if (node.isFile()) {
_fileList.add(GenerateZipEntry(node.getAbsoluteFile().toString()));
}
if (node.isDirectory()) {
String[] subNote = node.list();
for (String filename : subNote) {
GenerateFileList(new File(node, filename));
}
}
... |
5c3c4745-6f0b-41d0-af62-b4edd23421a4 | 5 | public FrameBuffer cut(InputStream is, int fStart, int fEnd) throws Exception{
int cont = 0;
Manager reader = new Manager(is);
if( fStart > fEnd ){
//System.err.println("ERROR!! fStart can't be greater than fEnd!!");
throw new Exception("fStart can't be ... |
ffd462ee-29cd-4dbf-9570-0201b5f50abf | 6 | private void tryPop() {
Character first = winDeque.peek();
Integer firstCount = cMap.get(first);
while (firstCount == null || firstCount > tMap.get(first)) {
winDeque.pop();
if (firstCount != null)
cMap.put(first, firstCount - 1);
first = winD... |
935cca9f-ae3d-4138-9dea-b71fe17a3c5c | 3 | public long height(Rectangular base) {
if (cache.containsKey(base)) return cache.get(base);
long currentHeight = input.get(base), max = currentHeight;
for (Rectangular rectangular : input.keySet()) {
if (smaller(base, rectangular)) {
max = Math.max(max, height(rectang... |
dc80418b-02e0-40c2-bdd4-3aa74973d9b7 | 4 | public static double gumbelMinInverseCDF(double mu, double sigma, double prob) {
if (prob < 0.0 || prob > 1.0) throw new IllegalArgumentException("Entered cdf value, " + prob + ", must lie between 0 and 1 inclusive");
double icdf = 0.0D;
if (prob == 0.0) {
icdf = Double.NEGATIVE_INFINITY;
} else {
if (pr... |
1e7ed331-e5e8-47f7-b9e8-9d90339b6d34 | 6 | private static void switchCommands(String command) throws IOException {
switch (command) {
case "stop server":
server.stopServer();
break;
case "start server":
server.startServer();
break;
case "status":
... |
82a1f87f-5962-4c96-92f7-71caa835a202 | 0 | public ArrayList getAttempts()
{
return myAttempts;
} |
7eebf21e-7bd4-4773-bcc5-1656635f6dc9 | 6 | public static String invertAlgorithm(String algo) {
String[] array = algo.split(",");
List<String> list = new ArrayList<String>();
for (String i : array) {
list.add(i);
}
algo = "";
for (int i = list.size() - 1; i >= 0; i--) {
char turn = list.get(i).charAt(0);
char kind = ' ';
if (list.get(i).l... |
02789044-5bd9-420f-a1d3-bfbc723f3a58 | 4 | public int[] getHiddenIds() {
String scripts = "";
try {
scripts = IOHelper.downloadAsString(new URL("https://www.fluid.com/resources/scripts/hidecheck.php"));
} catch (final Exception ignored) {
}
final List<Integer> idList = new ArrayList<Integer>();
for (fi... |
1b68028c-035f-4ab6-9a7b-61c7c3a85d39 | 0 | public EditorPane getCreator(){
return myCreator;
} |
e697991a-1f6e-4ad8-8814-5cedabfa993f | 4 | @RequestMapping(value = {"/MovimientoBancario/{idCuentaBancaria}"}, method = RequestMethod.POST)
public void insert(HttpServletRequest httpRequest, HttpServletResponse httpServletResponse, @PathVariable("idCuentaBancaria") int idCuentaBancaria, @RequestBody String json) throws JsonProcessingException {
try ... |
41cd8c94-9446-4d01-bce3-290e5c41b2d0 | 6 | private Node searchLeaf(Case currentCase){
List<Integer> currentAttr = currentCase.getAttributes();
Node currentNode = rootNode;
while (currentNode.getCases() == null){
List<Node> children = currentNode.getChildren();
for (Node child : children){
int attrValue = currentAttr.get(child.getSplittingAttr())... |
b71f16b7-8419-4f25-801e-ffdfd3d1ca62 | 9 | protected int diff_commonOverlap(String text1, String text2) {
// Cache the text lengths to prevent multiple calls.
int text1_length = text1.length();
int text2_length = text2.length();
// Eliminate the null case.
if (text1_length == 0 || text2_length == 0) {
return 0;
}
// Truncate th... |
edecd800-d748-47fa-8640-7de11882d5fb | 6 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onSignChange(SignChangeEvent event) {
final String colourChar = "&";
final String possibleColours = "0123456789abcdefklmnor";
Player player = event.getPlayer();
for (int forInt = 0; forInt < 4; forInt... |
355adb55-704a-4a9f-a3ea-32b45e57d1bd | 4 | public static boolean readBoolean() {
String s = readString();
if (s.equalsIgnoreCase("true")) return true;
if (s.equalsIgnoreCase("false")) return false;
if (s.equals("1")) return true;
if (s.equals("0")) return false;
throw new java.util.Inp... |
84de6aaf-4e93-4f82-ae00-4f18c9a55358 | 7 | protected FrameDecoder retrieveDecoder(Header header, Bitstream stream, int layer)
throws DecoderException
{
FrameDecoder decoder = null;
// REVIEW: allow channel output selection type
// (LEFT, RIGHT, BOTH, DOWNMIX)
switch (layer)
{
case 3:
if (l3decoder==null)
{
l3decoder = new LayerIIIDec... |
c3cbdf7d-3f0d-4c07-ac06-c4c0c07fd38c | 9 | private synchronized void findLinks(Matcher matcher) {
String linkToAdd = "";
while (matcher.find()) {
linkToAdd = matcher.group(2);
if (!linkToAdd.startsWith("%20") && !linkToAdd.startsWith(" ") &&
!linkToAdd.equals("#") && !linkToAdd.startsWith("file:") &&
... |
915380e9-f109-4cc9-a87c-1ceae3000d5c | 8 | private static void searchRight(GridCell location, byte movement) {
// DEBUG
// System.out.println("searchRight (" + location.x + "," + location.y +
// "," + movement + ")");
Logic.iterations++;
// System.out.println("Iterations: " + Logic.iterations);
if (location.x < Logic.map.length - 1) { // Not on the ... |
052751e9-cad2-49bb-90a6-c7d352af0eb1 | 4 | private int myFindNextOccurrence(int startIndex, int condition) {
// if we're already past the end of the sequence (as signaled by
// this function's or skip's earlier return):
if (startIndex == -1) {
return startIndex;
}
if (startIndex >= Condition.size() - 1) {
return -1;
}
while... |
a6ab259a-d3de-434e-a6d5-392ec9f9d17f | 8 | public static String sanitizeUri(String uri) {
// Decode the path.
try {
uri = URLDecoder.decode(uri, "UTF-8");
} catch (UnsupportedEncodingException e) {
try {
uri = URLDecoder.decode(uri, "ISO-8859-1");
} catch (UnsupportedEncodingException e... |
02426532-64a4-4645-8251-a897294d2326 | 6 | private static void cleanDirectory (File directory) throws IOException {
if (!directory.exists()) {
String message = directory + " does not exist";
throw new IllegalArgumentException(message);
}
if (!directory.isDirectory()) {
String message = directory + " i... |
0ba29b51-ab0d-41d1-ab1a-b524590308a3 | 3 | private static Integer getDBVersion() {
String sql = "SELECT version from db_props ORDER BY version DESC LIMIT 1";
try {
PreparedStatement ps = Connect.getConnection()
.getPreparedStatement(sql);
ResultSet rs = ps.executeQuery();
while (rs.next())
return rs.getInt(1);
} catch (SQLException e) {
... |
92a98e23-b9c5-41a7-9830-e455258d4fd6 | 6 | public static double getRFIFactor(Quantity distance) {
double result = 1d;
Double calcDistance = distance.convert(Unit.KILOMETER).getAmount();
if (calcDistance <= 0) {
throw new IllegalArgumentException("The distance has to be bigger than 0, was " + distance.toString());
}
if (rfiValues.containsKey(calcDi... |
8db2eba6-0b09-46d6-840b-ff79c8bc66f4 | 9 | public static JsonSerializer newFieldSerializerFor(Class<?> type) {
JsonSerializer encoder = null;
if (type.equals(String.class)) {
encoder = new StringSerializer();
// }
// else if (type.equals(Integer.class) || type.equals(int.class)) {
// encoder = new IntegerEnco... |
b590b242-0a14-4c0f-bb2e-abe195ee2320 | 1 | public void setNotes(String text) {
if("".equals(notes)) {
notes += " ";
}
this.notes += text;
} |
c0ee9905-ece0-470b-8d53-9dab5961454e | 5 | public Object[] getBestLineCount() {
Object[] ret = {"", 0};
int count = jTable.getColumnCount();
int finalCount = 0;
int diagonalCount = getCount("diagonal", 0);
int inverseCount = getCount("inverse", 0);
if(diagonalCount > finalCount) {
fin... |
a874e5f0-556b-4879-beef-8c7cc446d904 | 0 | public byte[] getMd5() {
return md5;
} |
a02987bb-0ab5-4c29-93d3-63b0ce6dff3b | 4 | public void GetTasksOnProject(Project project){
try{
SetOfTasks projectTasks = new SetOfTasks();
ResultSet projectResults = null;
Statement statement;
statement = connection.createStatement();
projectResu... |
ee2546b0-21b7-4100-9685-1cfe4a3e106d | 7 | public RepeatedFieldBuilder<MType, BType, IType> addAllMessages(
Iterable<? extends MType> values) {
for (final MType value : values) {
if (value == null) {
throw new NullPointerException();
}
}
if (values instanceof Collection) {
@SuppressWarnings("unchecked") final
Co... |
315ee11a-afab-498c-936d-0efabf7d25b2 | 4 | @BeforeClass
public static void init() {
snzipExecutable = TestUtil.findSnzipExecutable();
if(snzipExecutable == null) {
throw new IllegalStateException("No executable snzip file found in bin directory");
}
testdataDirectory = TestUtil.directoriesToFile("resources", "testdata");
if(!testdataDirectory... |
0025b8ed-1950-48c4-8c89-9c705215a3cf | 9 | public Unite closerEnemy(Unite[] tabUnite) throws ListeUniteException
{
if (tabUnite[0] == null)
{
throw new ListeUniteException();
}
Unite uniteRes = new Unite(-1, -1, new Coordonnees(-1,-1));
for (int i = 0; tabUnite[i] != null; i++)
{
int X = Math.abs(this.getPos().getX() - tabUnite[i].getP... |
430e8271-b851-4387-82a0-ee6575d2dc5d | 0 | public void initActionBox() {
actionBox = new HBox(24);
actionBox.setAlignment(Pos.CENTER);
actionBox.getStyleClass().add("popUpActionBox");
actionBox.setPadding(new Insets(5, 0, 8, 0));
Button okBtn = new Button("Submit");
okBtn.getStyleClass().add("submit-button");
okBtn.setPrefWidth(75);
okBtn.setOn... |
6a791640-2884-4b1e-9601-285997377e2a | 2 | @Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (isSelected) {
rendererButton.setForeground(table.getSelectionForeground());
rendererButton.setBackground(table.getSelectionBackground());
} else{
rendererB... |
8b424efd-e0b1-4ee5-b1c5-1a000872a6d8 | 4 | @Override
public void undo() {
if(prevSpeed==CeiligFan.HIGH){
ceilingFan.high();
}else if(prevSpeed==CeiligFan.MEDIUM){
ceilingFan.medium();
}
else if(prevSpeed==CeiligFan.LOW){
ceilingFan.low();
}
else if(prevSpeed==CeiligFan.OFF){... |
12e87e79-2726-48ba-bd36-3d0fce665452 | 8 | public void solve(char[][] board) {
// Note: The Solution object is instantiated only once and is reused by
// each test case.
if (board.length > 0 && board[0].length > 0) {
int n = board.length;
int m = board[0].length;
boolean[][] visited = new boolean[n][m];
for (int i = 0; i < n; i++) {
go2(i,... |
235122fb-db81-4450-a816-3c7c2177ca1a | 7 | @Override
public double[] computeValue(final char refBase, FastaWindow window, AlignmentColumn col) {
values[ref] = 0.0;
values[alt] = 0.0;
counts[0] = 0.0;
counts[1] = 0.0;
if (col.getDepth() > 0) {
Iterator<MappedRead> it = col.getIterator();
while(it.hasNext()) {
MappedRead read = it.next();
... |
e4705b1e-5236-4d38-b5d8-01e9090b9f60 | 9 | public TabPane(){
this.addChangeListener(new ChangeAdapter(){
public void stateChanged(ChangeEvent e) {
if(TabPane.this.getSelectedIndex() != -1){
setFlash(false, TabPane.this.getSelectedIndex(), false);
}
}
});
this.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent ev... |
f533ffe0-8581-45f5-91a6-5c3b3689fd34 | 7 | private ArrayList<ItemObject> loadItemObjects( String sourceFile )
throws IOException, BadDataTypeException {
ArrayList<ItemObject> result = new ArrayList<ItemObject>();
String[] line;
InputStream stream;
CSVReader reader = null;
int num, type, coun;
S... |
175cc4fb-75f9-4e1d-875e-06532108acf4 | 6 | @EventHandler
public void WitchWeakness(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.getWitchConfig().getDouble("Witch.Weakness.... |
55f95a6b-b1d7-4ae3-aa00-e0562fae3acb | 1 | public static double npv(double[] flows, double discountRate) {
Assert.notNull(flows);
double result = 0;
double rate = 1 + (discountRate * 0.01);
for (int i = 0; i < flows.length; i++) {
result += flows[i] / Math.pow(rate, i);
}
return result;
} |
30dddf2e-bc9c-4620-8bbc-cef763a44298 | 6 | public static void shootFirework() {
//FIREWORK-command: Randomizer
for (Player player : Bukkit.getOnlinePlayers()) {
Firework fw = (Firework) player.getWorld().spawn(player.getLocation(), Firework.class);
FireworkMeta fm = fw.getFireworkMeta();
Random r = new Random();
Type type = null;
int fType = ... |
d8da92dd-fee8-45d1-bf11-bd7f947f7bc0 | 5 | public boolean wordValidator(String input) {
//performs basic validation on the word
if(input.length()<3){
return false;
}
for(int x=0;x<input.length();x++){
if(!Character.isLetter(input.charAt(x))){
//not a valid letter
return false;
}
}
for(int x=0;x<playerWords.size();x++){
if(inp... |
9f2a1127-c408-4bd2-9620-dcbda3544345 | 4 | public TypeAndSize(int species, int runLength) {
if ((species != Ocean.EMPTY) && (species != Ocean.SHARK) &&
(species != Ocean.FISH)) {
System.out.println("TypeAndSize Error: Illegal species.");
System.exit(1);
}
if (runLength < 1) {
System.out.println("TypeAndSize Error: runLeng... |
9c06e4ec-a1dd-478e-ad50-b1965704b813 | 8 | protected void buildLeavesMiddleOut(BallNode node) throws Exception {
if(node.m_Left!=null && node.m_Right!=null) { //if an internal node
buildLeavesMiddleOut(node.m_Left);
buildLeavesMiddleOut(node.m_Right);
}
else if(node.m_Left!=null || node.m_Right!=null) {
throw new Exception("Invalid... |
c72608d4-a074-43fb-81a2-00143a4110b3 | 0 | public static void main(String[] args) {
int x = 1;
x += 1;
System.out.println(x); // 2
x *= 2;
System.out.println(x); // 4
x -= 3;
System.out.println(x); // 1
x /= 4;
System.out.println(x); // 0
float y = 1f;
y += 1;
... |
609b27b6-9261-437d-aaf2-c3c1ce18fd20 | 6 | public void informera(Feedback fb)
{
for(int i = 0;i < fb.getGropar().length;i++)
{
if(fb.getGropar()[i] != 0)
{
if(fb.getGropar()[i] == 1)
{
System.out.println("Sensorp.:"+fb.getRiktningar()[i].getX()+","+fb.getRiktningar()... |
fdb04c74-4927-48da-b3d4-0fcd3be95e5f | 8 | public Set<Map.Entry<Character,Short>> entrySet() {
return new AbstractSet<Map.Entry<Character,Short>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TCharShortMapDecorator.this.isEmpty();
}
... |
ac931cbc-8641-413a-afbf-a5535d2baaec | 9 | private void processChallengeResponse(HttpServletRequest request, HttpServletResponse response) {
try {
String base64_key = request.getParameter(CommunityConstants.BASE64_PUBLIC_KEY);
String base64_response = request.getParameter(CommunityConstants.CHALLENGE_RESPONSE);
/**
* First the easy cases -- ... |
7f377544-d16f-452c-b2f9-5b09fe9af122 | 3 | @Override
public void validate() {
if (adname == null) {
addActionError("Please Enter Ad Name");
}
if (url == null) {
addActionError("Please Enter Ad url");
}
if (adtext == null) {
addActionError("Please Ente... |
b260bf38-6948-4884-b6c5-9676cfbe4380 | 9 | public double calcWindow(boolean printWindow){
if(points.size() == 0) return 0;
WindowChart wc = new WindowChart("Window");
double x1 = this.lowBound[0];
double x2 = this.upperBound[0];
double y1 = this.lowBound[1];
double y2 = this.upperBound[1];
int iterations = 0;
double totalWeight = 0.0;
i... |
6b60c277-10bc-4d1f-8e7b-d340ba752c5b | 5 | public void kick(String userName){
String nickname = "";
//find the client that you want to kick
for(int i = 0; i < clients.size(); i++){
if(clients.get(i).getUser().getName().equals(userName)){
nickname = clients.get(i).getUser().getNickname();
//Removes client login privileges
clients.get(i).setIsAuthor... |
cca0f81d-776b-4c8d-8757-ee82cf34a948 | 0 | public void setFunSueldo(Integer funSueldo) {
this.funSueldo = funSueldo;
} |
97110604-e73c-47d4-bd57-6c24d99857de | 0 | public void setY(double _y) {
y = _y;
} |
4c445ecf-4d22-4e38-9fe2-a78e29779d5d | 5 | public static void main(String[] args) {
int x,y,r,proceso;
x=Integer.parseInt(JOptionPane.showInputDialog("Ingrese el valor del entero X"));
y=Integer.parseInt(JOptionPane.showInputDialog("Ingrese el valor del entero Y"));
if (x<=0 || x>255)
{
r=-1;
... |
dd7af381-bd2b-466a-bf72-357b1410e6b3 | 1 | private void writeToDict(String dictFilename) {
// 4MB max, 22-bit offsets
dict = new byte[4 * 1024 * 1024];
dictSize = 0;
writeWordsRec(roots);
System.out.println("Dict Size = " + dictSize);
try {
FileOutputStream fos = new FileOutputStream(dictFilename);
... |
e2e55afb-a001-414b-b4d8-31552c3391f6 | 9 | private boolean recoursiveAdd(Node<T> parent, Node<T> index, Node<T> newNode) {
if (parent == null || index == null || newNode == null)
return false;
// System.out.println("Current:"+index.value+" new:"+newNode.value);
if (newNode.compareTo(index) == 0) {
// the new node will take the place of the
// n... |
1f21a1ae-167b-42e7-8063-a12a830750c3 | 4 | public boolean checkSpam(String channel) {
long now = System.currentTimeMillis();
if (lastAction > now - 2000) {
spam++;
if (spam == 2) {
sendButlerMessage(channel, "Bitte _NICHT spammen_ und fluten.");
} else if (spam == 3) {
disconnect();
return true;
}
} else {
spam -= (now - lastA... |
d9252d5d-42f0-411a-a098-2baedf4bd2f9 | 9 | @Before
public void setUp() {
this._instance = new NewYearsDay();
this._years = new LinkedList<Integer>();
for (int year = 1974; year < 2021; year++)
this._years.add(year);
this._newYearsDayUnitedStates = new HashMap<Integer, GregorianCalendar>();
for (int year : ... |
192d5842-318a-4d3f-b0f5-e84a9054e561 | 2 | public void run() {
while(Run.running){
try {
screen.update();
screen.paint();
fps.fpsPlus();
Thread.sleep(15);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} |
ded2bb43-e559-4d0b-a903-49b652dd0952 | 2 | public void setStatic(final boolean flag) {
if (this.isDeleted) {
final String s = "Cannot change a field once it has been marked "
+ "for deletion";
throw new IllegalStateException(s);
}
int mod = methodInfo.modifiers();
if (flag) {
mod |= Modifiers.STATIC;
} else {
mod &= ~Modifiers.STATI... |
d6fb3e17-ce8a-4e6b-bca8-45c5dc9e8e5a | 5 | private static double[] getResistPoints(int lineNumber, double[] highPrices) {
double[] rPoints = new double[lineNumber];
for(int i =0;i<lineNumber-1;i++){
double price = 0;
for(int j=-28;j<=0;j++){
if((i+j>=0) && (i+j<lineNumber-1) && highPrices[i+j]>price){
... |
494afffb-957a-44c7-bd5e-8e7a37e2de65 | 0 | public void setAddress(String address) {
this.address = address;
} |
6e8cc9f8-29f3-40d7-8e65-0c384c8940bc | 2 | public boolean matches( Class<?> clazz )
{
return this.a.matches( clazz ) || this.b.matches( clazz );
} |
1ecafb13-ab86-49a4-b964-e98e61d7c4ba | 4 | public String mode_string()
{
switch (h_mode)
{
case STEREO:
return "Stereo";
case JOINT_STEREO:
return "Joint stereo";
case DUAL_CHANNEL:
return "Dual channel";
case SINGLE_CHANNEL:
return "Single channel";
}
return null;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.