method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
5b767331-3bed-4926-a95b-9d8ad63a4e0c | 5 | @Override
public String toString() {
if (isNan()) {
return "Nan";
} else if (isPositiveInfinite()) {
return "PositiveInfinite";
} else if (isNegativeInfinite()) {
return "NegativeInfinite";
} else {
BigDecimal r = this.getBigDecimal();
if (r.equals(0)) {
if (negative)
return "-0";
e... |
44095521-a045-4383-a643-06837b32f8e7 | 8 | @Test
public void testAddCopiesCorrectBook() throws BookStoreException {
// Add a copy of a book
int copies_to_add = 1;
Set<BookCopy> bookCopiesSet = new HashSet<BookCopy>();
bookCopiesSet.add(new BookCopy(TEST_ISBN, copies_to_add));
storeManager.addCopies(bookCopiesSet);
// Get books with that ISBN
Se... |
371384ae-fcf7-45c5-900c-e372c3f00ad9 | 8 | @POST
@Path("/optimize")
@Produces("application/json; charset=UTF-8")
public BestPlanning processOptimize(String request) {
try {
List<Flight> flights = new ObjectMapper().readValue(request, new TypeReference<List<Flight>>(){});
LOGGER.info("flightsCount: " + flights.size());
if (flights.size() < 1000) {... |
c1ec7a76-0a24-4c00-b0ed-0a09368d83c1 | 2 | public int hashCode() {
T[] a = arr.get();
if(a == null)
return(0);
int ret = 1;
for(T o : a)
ret = (ret * 31) + System.identityHashCode(o);
return(ret);
} |
2c2e6d48-3d50-4dd4-98e3-f7436194c2e8 | 3 | public static void sort(Comparable[] a) {
for (int i = 0; i < a.length; i++) {
for (int j = i; j > 0; j--) {
if (less(a[j], a[j - 1]))
exch(a, j, j - 1);
else
break;
}
}
} |
111994b8-483b-45da-bc7d-96dce8a3f4ef | 7 | public static void main(String[] args) {
// TODO Auto-generated method stub
int n = 10;
int input[] = {5,7,9,3,4,5,1,6,2,7};
// 采用动态规划方法。
// len存储的是到input(i)截止的最长递增长度
int len;
// max 存储的是到input(i)截止的最长递增长度为s的末尾的最小值
int min[]= new int [n];
// 辅助数组,用来最终输出单调递增子序列
int b[] = new int[n];
for(... |
8a81e976-5c3e-493c-ab8e-81fa1932491d | 3 | public boolean playerHasPermissions(Player player) {
if (this.permissions == null) {
return true;
}
if (P.p.permission.has(player, this.permissions) || player.isOp()) {
return true;
}
return false;
} |
b0239f06-f3b4-4c69-8f2e-720beef0f3e0 | 4 | @Override
public void run() {
if (t != null && t.isRunning()) {
t.stop();
} else {
t = new Timer(TIMER_TIME, displayError);
t.setRepeats(false);
}
setMsgLabel(txt);
msgLabel.setForeground(Color.white);
pane.setBackground(Color.red);
for (Component c : errorComps)
if (c != null)
... |
10e478bf-c3b1-42de-adf0-b95f5e82994c | 5 | public String mulHelper(String num, char c, int power) {
StringBuffer sb = new StringBuffer();
if (c == '0') {
return "0";
}
int m = (c - '0');
int carry = 0;
for (int i = num.length() - 1; i >= 0; i--) {
char cc = num.charAt(i);
int i1 = (cc - '0');
int r = i1 * m + carry;
if (r >= 10) {
... |
395c4449-9212-4f9c-9d1a-1130dd0de074 | 5 | private Client_Response armeen_hinzufuegen_betreten(){
Zustand=Spielzustaende.Armeen_hinzufuegen;
Client_Response zwischen = new Client_Response(DieSpielwelt, Zustand, aktueller_Spieler, false);
if (ist_erste_runde==true){
switch (dieS... |
2e96505a-5d79-422c-93a5-7d448656cb5e | 6 | public void run(){
while(!END_AReceber){
try {
//try { Thread.sleep(1000); } catch (InterruptedException ex) {}
//Console_println("AR1");
Transporte tr = new Transporte(initTransportePSH);
Da... |
4f547b33-648d-4657-b1cf-3f0f30a3e40b | 6 | public void setPN(Boolean x)
{
if(intPort == 0)
intPort = 5252;
if(x!=null)
blPN = x;
//Kill/Reset connection
if(blPN == true && internetCon == null)
{
internetCon = new DroneClient(serverAddress, intPort);
internetCon.setBase(me);
serverAddress = internetCon.getServerIP();
intPort = intern... |
bc741e5d-0fb1-4e9a-9ee8-e0dadcc02729 | 0 | public BarControllerImpl(BarService barService) {
this.barService = barService;
} |
8e01a7f2-8b90-4daa-809f-e4ab51dc35b7 | 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... |
82139305-c7fa-4230-b666-6b603d234fd5 | 0 | public final int getMaxLineLength() {
return InputThread.MAX_LINE_LENGTH;
} |
9fefa841-a0bf-41e4-8650-c2fe9bcfd4d5 | 3 | @Override
public Class getColumnClass(int column) {
Class returnValue;
if ((column >= 0) && (column < getColumnCount())) {
if(getValueAt(0, column)==null)
return String.class;
returnValue = getValueAt(0, column).getClass();
... |
42245696-2bb2-491d-8a92-706db1852ab4 | 5 | public GameSelecter() {
boolean test = false;
if (test || m_test) {
System.out.println("GameSelecter :: GameSelecter() BEGIN");
}
JFrame newChoose = new JFrame();
setChooseFrame(newChoose);
getChooseFrame().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
newChoose.setTi... |
96c77d16-ad5f-4bfe-9ba4-35f00ea7d12c | 7 | public static int insertMstxImage(int mid, File fileName, Date imageTime) {
int result = 0;
int id = MstxDao.getMaxNumber("mstx_image");
MstxDao.updateMaxNumber(4);// 将该字段值加1
FileInputStream fis = null;
Connection con = DBUtil.getConnection();
PreparedStatement pstmt = null;
try {
fis = new FileInputSt... |
fb0b3d4c-069f-4548-8599-b7ef5ce3ec8d | 6 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Vector other = (Vector) obj;
if (Float.floatToIntBits(theta) != Float.floatToIntBits(other.theta))
return false;
if (Float.floatToIntBits(x)... |
5b08bb7f-7fc2-462f-9829-f84a92258b29 | 5 | private void selectClient() {
List<Client> clients = dc.getAllClients();
System.out.println("Select client:");
int index = 0;
for(Client client : clients) {
System.out.println(++index + ") " + client.getFirstName());
}
System.out.print("> ");
BufferedR... |
f1b33eeb-2eda-429c-a783-3bcfc03d57f9 | 8 | public void menu(int a){
switch (a){
case 0 :
System.out.println("\nGOOD BYE!");
break;
case 1:
addContactToPhonebook();
break;
case 2:
searchByName();
break;
case 3:
contactList();
break;
case 4:
addCompanyToPhonebook();
break;
case 5:
searchByEmail();
break;
case 6:... |
cf4eca5e-23b1-4b89-adf1-3bb85c8b8a37 | 0 | public int getMOV() {
return mov;
} |
e0cb6603-64a7-4141-ac5e-40ad567ac4ba | 7 | @EventHandler
public void onSign(PlayerInteractEvent event)
{
if(!event.getPlayer().getWorld().getName().equals(p.getWorld())) return;
if(event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
if(event.getClickedBlock().getType() != SIGN_POST && event.getClickedBlock().getType() != WALL_... |
be1cbc3c-f6d7-4dc3-b623-82b30f50c572 | 3 | @Override
public byte[] getBytes() {
VariableLengthIntegerMessage length = getMessageFactory().createVariableLengthIntegerMessage(ints.length);
VariableLengthIntegerMessage[] varInts = new VariableLengthIntegerMessage[ints.length];
for (int i = 0; i < ints.length; i++) {
varInts[i] = getMessageFactory().cre... |
964f632b-949a-40c1-b2c1-fa15686d4d5f | 9 | @EventHandler(priority = EventPriority.NORMAL)
public void onEntityDeath(final EntityDeathEvent event) {
final int i = ran.nextInt(100);
final Entity entity = event.getEntity();
if (!(entity instanceof Player)) {
return;
}
final Player player = (Player) entity;
... |
a77e28b0-3ef4-4dac-aeb9-b2c510b15420 | 2 | public void setLugar(int x, int y)
{
if (x < 0 || y < 0)
{
throw new IllegalArgumentException("Las coordenadas x(" + x+ ") o y(" + y + ") tienen que ser positivas" +
"");
}
this.x = x;
this.y = y;
} |
961253c9-c1a7-47a5-873b-4ebae411c32c | 9 | private void extractEnvelope(XMLEventReader xrd) throws XMLStreamException {
XMLEvent xev = xrd.nextTag();
if (xev.isStartElement() && xev.asStartElement().getName().getLocalPart().toLowerCase().contains("lower")) {
// skip attributes,comments and whitespace
do {
... |
6decb132-1a59-4204-aaad-5b2904915793 | 9 | public static int allocateSlots(Expression exp, int nextFree, SlotManager frame) {
if (exp instanceof Assignation) {
((Assignation)exp).setSlotNumber(nextFree);
int count = ((Assignation)exp).getRequiredSlots();
nextFree += count;
if (frame != null) {
... |
4ffa4c4c-2176-41eb-a884-a2a14d3dafca | 5 | public static void main(String[] args) {
// TODO code application logic here
int opcion=0;
Scanner oScanner=new Scanner(System.in);
do{
System.out.println("Digite la opcion que desea");
System.out.println("1: Ejercicio 1");
System.out... |
d8ca30dc-020f-41b5-85c6-05d1a8f50f89 | 9 | private boolean processFields() {
boolean newSecurity;
//
// Validate the security information
//
int type = securityType.getSelectedIndex();
if (type < 0) {
JOptionPane.showMessageDialog(this, "You must select a security type",
... |
9319acdd-ad4c-4405-aa42-90068f81c02f | 1 | public Boolean close() {
try {
this.con.close();
return true;
} catch (SQLException e) {
log.severe("Couldn't close Connection: ");
LogHandler.writeStackTrace(log, e, Level.SEVERE);
return false;
}
} |
224816b6-3a87-45ff-9d02-7b81763dd25e | 7 | public boolean start() {
synchronized (optOutLock) {
// Did we opt out?
if (isOptOut()) {
return false;
}
// Is metrics already running?
if (task != null) {
return true;
}
// Begin hitting the s... |
372bf9c1-1a43-48e7-9075-03cb1746586d | 8 | public synchronized void removeListener(Class c, Object listener) {
if (array == null || array.length == 0)
return;
if (listener == null || c == null)
throw new IllegalArgumentException();
int index = 0;
while (index < array.length) {
if (array[index] == c && array[index + 1] == listener)
break;
... |
ce870213-7340-40bc-aadb-8915d62b53b6 | 7 | void render(float[][] dest, int nsamples) {
assert (nsamples <= V2Instance.MAX_FRAME_SIZE);
float voice[] = inst.vcebuf;
float voice2[] = inst.vcebuf2;
//memset(voice, 0, nsamples * sizeof(*voice));
// clear voice buffer
for (int i = 0; i < nsamples; i++) {
voice[i] = 0.0f;
voice2[i] = 0.0f;
}
... |
ab0c76ca-79be-4b99-b206-3485fcd07930 | 4 | static Font createFont(Device device, int points, int style) {
if(SWT.getPlatform() == "win32") {
return new Font(device, "Verdana", points, style);
} else if (SWT.getPlatform() == "motif") {
return new Font(device, "Times", points, style);
} else if (SWT.getPlatform() == "gtk") {
return new Font(de... |
129123ea-e889-4f2f-a734-1bc0daed0091 | 5 | public static boolean isPrime(int x) {
if (x == 2) {
return true;
}
if (x % 2 == 0 || x == 1) {
return false;
}
for (int i = 3; i * i <= Math.abs(x); i += 2) {
if (x % i == 0){
return false;
}
}
return true;
} |
a8adb6ba-cab2-436f-8a55-297121d21e1b | 5 | public static void checkStructureIntegrity() {
for (File f : dirList) {
if (!f.exists()) {
try {
Log.debug("Creating: " + f.getName() + "(" + f.getPath() + ")");
f.mkdir();
} catch (Exception e) {
Log.error... |
4c2360fc-b89c-4903-b72d-8a0ac50fd742 | 5 | private ArrayList<Entry> toArrayList(double startTime, double finishTime) {
ArrayList<Entry> subProfile = new ArrayList<Entry>();
startTime = Math.max(startTime, currentTime());
Iterator<ProfileEntry> it = avail.itValuesFromPrec(startTime);
Entry fe = null;
// get first entry or create one if the profil... |
315c541d-059b-4cfb-be36-9974e141195a | 4 | public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
CFG.INTERNET = Assistant.isInternetReachable();
File jar = new File(CFG.DIR, "Vloxlands.jar");
UniVersion.offline = !CFG.INTERNET;... |
9293db14-f065-4d60-a9a4-cb9f6dccdb32 | 8 | public void run() {
// TODO Auto-generated method stub
try {
// Apertura Socket
servidor = new ServerSocket(9003);
Socket serv;
PartidaChip objeto_rx;
PartidaChip objeto_tx_play = new PartidaChip("PLAY", nick, 0, 0);
enviarJugada(objeto_tx_play);
while (true) {
// Acepta cx entrantes
... |
efb9a13c-6941-4251-aab0-245e809557e1 | 6 | public static String numberToString(Number number) throws JSONException {
if (number == null) {
throw new JSONException("Null pointer");
}
testValidity(number);
// Shave off trailing zeros and decimal point, if possible.
String string = number.toString();
if (string... |
0f5505a7-bfb1-443f-82f5-cdf4166636bd | 9 | public boolean equals(Species other)
{
if(num != other.getDexNum())
return false;
if(!species.equals(other.getName()))
return false;
if(canEvo != other.canEvolve())
return false;
if(!Arrays.equals(types,other.getTypes()))
return false;
if(!Arrays.equals(baseStats,other.getBaseStats()))
return ... |
d8615860-4d58-41c9-84cc-4625991183d6 | 6 | public void openFletching(int item) {
if (item == 1511) {
c.getPA().sendFrame164(8880);
c.getPA().sendFrame126("What would you like to make?", 8879);
c.getPA().sendFrame246(8884, 250, 839); // middle
c.getPA().sendFrame246(8883, 250, 841); // left picture
c.getPA().sendFrame246(88... |
80cb923c-e731-4c2e-9476-1ee6e5d94dc8 | 4 | protected boolean scanImage(byte[] imageData) {
ImageInfo ii = new ImageInfo();
ii.setInput(new ByteArrayInputStream(imageData));
if (ii.check()) {
// grokked
this.imgHeight=ii.getHeight();
this.imgWidth=ii.getWidth();
this.imgBitsPerPixel=ii.getBitsPerPixel();
if(th... |
ede9c04b-cfb3-45d0-96b9-781585239ca7 | 1 | public void visitForceChildren(final TreeVisitor visitor) {
if (visitor.reverse()) {
expr.visit(visitor);
} else {
expr.visit(visitor);
}
} |
dfb27612-79b8-42b9-8de0-0fe04fb7aca9 | 9 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof TestTransaction)) return false;
TestTransaction that = (TestTransaction) o;
if (amount != that.amount) return false;
if (entity != null ? !entity.equals(that.entity) : that.entity != ... |
996d5530-8a0b-4040-b52b-cfb205ea70c2 | 9 | @Override
public void actionPerformed(ActionEvent e) {
String comando = e.getActionCommand();
switch (comando) {
case "DEPOSITO MANUAL":
depoManual = new DepoManual();
depoManualControlador dmc = new depoManualControlador(depoManual, model, this);
... |
566d6578-4a0a-4345-aa48-bc9bf139c29b | 8 | private static void solve(StringBuilder pStr, StringBuilder vStr) {
ArrayList<Integer> al = new ArrayList<>();
for (int i = 0; i < pStr.length(); i++) {
int numErrors = 0;
int numCounted = 0;
int index = i;
for (int j = 0; j < vStr.length(); j++) {
if (index >= pStr.length()) {
numErrors = numE... |
d9bb8f93-f03a-4166-9565-5dfa53e6f1fe | 0 | public BooleanResource(int value) {
this.value = (value != 0);
} |
6a1e6c1c-3630-4a63-abbd-953013dfc52d | 1 | public void testEncryptBlock() {
byte[] key = ByteHelper.convertBinaryStringToByteArray("00010011 00110100 01010111 01111001 10011011 10111100 11011111 11110001".replace(" ", ""));
byte[][][] subKeys = new byte[][][] { KeyCalculator.generateSubKeys(key) };
byte[] block = ByteHelper.convertBina... |
9b18167a-d999-4d7f-adaa-63038bce719e | 7 | private void canSeeAnythingAction() {
switch (this.getType()) {
case "Goalie" :
//MP- Do nothing, if not the ball or the goal the goalie doesn't need to do anything
break;
case "Attacker" :
//Will run the player into s... |
d039c782-bddc-4645-ae1b-c6c7c4e3e2ec | 7 | public static void runPostRaceScreen() {
try {
while (!exit && !goToMainMenu) {
// If the display is not visible (minimised), add much more
// delay
if (!Display.isVisible()) {
Thread.sleep(200);
}
// If the display is requested to close, exit the program
else if (Display.isCloseReque... |
f6f6c55a-f666-4e39-b166-68e0b3fc9771 | 5 | public Object getValueAt(int row, int column) {
if (row >= listData.size())
throw new IndexOutOfBoundsException("Table row "+row+" is not valid");
AmortizationElement element = listData.get(row);
Object value;
switch (column) {
case 0: ... |
c20f355f-7eef-4bcc-9dd9-26ae567e5a3c | 6 | public static void main(String[] args) throws UnknownHostException {
MongoClient client = new MongoClient();
DB courseDB = client.getDB("school");
DBCollection collection = courseDB.getCollection("students");
System.out.println("before count: " + collection.count());
DBCursor cursor = collection.find();
tr... |
bf02fdcb-9140-4f31-a703-f2c6bca0124d | 2 | public static void main(String[] args) throws Exception
{
Configuration configData = QcConfigDataHandler.getConfigDataHandler().getConfigData();
String resultFilename = configData.getString("qc.result.file");
String resultClass = configData.getString("qc.result.class");
String className = "co... |
300e410b-09a1-4a8d-a362-c83486d4a0e0 | 9 | public ValidationErrorList validate(){
Person person = patient.getPerson();
ValidationErrorList errorList = new ValidationErrorList();
Validator instance = ESAPI.validator();
DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
if ( (instance.getValidInput("username", userAccount.getUsername(), "Name", ... |
98931875-8e89-4f1e-a74f-1f204738e150 | 0 | public double getAvb() {
return delegate.getAvb();
} |
47630d11-a6f1-420a-93f0-b55f00eac160 | 3 | double findLength(String[] s){
double length=0;
boolean find=false;
int i=0;
while(find ==false && i<s.length){
String tmp = s[i];
if(tmp.contains("Len=")){
find=true;
String tmpNum=tmp.split("\"")[0];
length=Double.parseDouble(tmpNum.substring(4));
}
i++;
}
return length;
} |
319cd679-4b21-432e-8819-cd6c34ef57d4 | 6 | public void storeRelease(RSS feed) {
Release r;
String firstSeen = null;
for (Item item : feed.getChannel().getItems()) {
try {
r = Release.parseItem(item, this.name);
if (firstSeen == null)
firstSeen = r.toString();
if (lastSeenTitle!=null && lastSeenTitle.equals(r.... |
07336061-dd74-42b6-9e32-6c93e34844a5 | 3 | private void findExtremes() {
this.MAX_TEMP = Long.MAX_VALUE;
this.MIN_TEMP = Long.MIN_VALUE;
if (alloy.getS() < alloy.getT()) {
this.HIGH_TEMP = alloy.getT();
this.LOW_TEMP = alloy.getS();
} else {
this.HIGH_TEMP = alloy.getT();
this.LOW_T... |
dadc7093-acb9-410e-8dfc-9db9a1f9f802 | 8 | public Customer getRecord(String custId) {
Customer cust = null;
String sql = "SELECT * from Customer WHERE id=?";
if(conn == null){
boolean result = openConnection();
if(result != true){
logger.error("Unable to connect to the DB ");
return cust;
}
}
try {
preparedStmt = conn.prepa... |
68658a70-f2ec-4684-b947-a2ba41e553f4 | 9 | public void sendCommand(String command) {
System.out.println("command " + command + "| cientFeatures "
+ clientFeatures + "| lobby " + lobby);
try {
if ((!command.startsWith(util.Protocol.CMD_SAID) || (clientFeatures != null && clientFeatures
.contains(util.Protocol.FEAT_CHAT)))
&& (!command.starts... |
1d19c2c1-efc8-4e7f-9e10-86d16d4d999d | 4 | @Override
public void serialize(Buffer buf) {
buf.writeShort(bonesId);
buf.writeUShort(skins.length);
for (short entry : skins) {
buf.writeShort(entry);
}
buf.writeUShort(indexedColors.length);
for (int entry : indexedColors) {
buf.writeInt(ent... |
11040e44-d954-479e-b146-a10bc70209d2 | 8 | private void writeJSON(Object value) throws JSONException {
if (JSONObject.NULL.equals(value)) {
write(zipNull, 3);
} else if (Boolean.FALSE.equals(value)) {
write(zipFalse, 3);
} else if (Boolean.TRUE.equals(value)) {
write(zipTrue, 3);
} else {
... |
a17c9272-82df-4c9a-ac75-81d66d40f060 | 3 | public boolean save()
{
try
{
boolean hasSaved = false;
if (databaseType == DatabaseType.FLATFILE)
{
hasSaved = FDFlatFileHelper.saveFlatFile((FlatFile)dataBase);
}
if (!hasSaved)
{
System.err.println("DATABASE DID NOT SAVE!!!");
return false;
}
else
{
System.out.println(... |
f96bfefb-9815-4849-b5f5-5303ae0a5c1b | 8 | public void downloadTextFile(URL url) throws IOException {
String fileName = null;
File tempFile = null;
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
// This case means that is index that is being processed
if (url.getPath().equalsIgnoreCas... |
3de5c15c-2746-4bf0-9ec0-f0a00ea91820 | 3 | public Session stopWatching(Session session) {
watcherToUser.remove(session);
Session clientSession = null;
boolean deleteSet = false;
for(Map.Entry<Session, Set<Session>> watchers : userToWatchers.entrySet()){
if (watchers.getValue().remove(session)) {
deleteSet = watchers.getValue().isEmpty();
clie... |
c9ea93a4-ee71-4d6b-ac1f-47b53243afcb | 4 | @SuppressWarnings("unchecked")
public String loadUsers() {
PreparedStatement st = null;
PreparedStatement ust = null;
ResultSet rs = null;
ResultSet urs = null;
JSONArray json = new JSONArray();
try {
conn = dbconn.getConnection();
st = conn.pr... |
512a860f-8177-4362-8073-7d80dd7e1695 | 3 | public void encoder(Circuit c, String endroit){
try {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuild = docFactory.newDocumentBuilder();
Document doc = docBuild.newDocument();
root = doc.createElement... |
05bae118-9722-496b-bdd1-da67de683b48 | 2 | private void renderGhost(Screen screen) {
Point[] gSelection = tetromino.getGhost(this).getSelection();
for (Point point : gSelection) {
int yy = point.getY()-HIDDEN_ROWS;
if (yy >= 0) {
int x = point.getX()*BLOCK_SCALE+getX();
int y = yy*BLOCK_SCALE+getY();
screen.renderHue(x, y, Art.GHOST, tetro... |
22eff7d7-c613-4a9f-8992-718a7845684f | 4 | public void waitAndResponse(MessageHandler handler) {
while (true) {
if (messageResponse.size() > 0) {
synchronized (this) {
for (String id : messageResponse.keySet()) {
MessageAdaptor response = handler
.handle(messageResponse.remove(id));
messageSource.add(response);
}
}
... |
2ed99501-6c17-4e3a-9632-b2c785bf6299 | 2 | public static Customer getByNumber(final Long number) {
JSONArray fetchByNumber = null;
try {
fetchByNumber = fetchByNumber(ApiProperties.get().getToken(), object, number);
} catch (IOException e) {
e.printStackTrace();
}
List<Customer> formatOutputs = formatOutputs(fetchByNumber);
if (formatOutputs.s... |
9e66e601-b0e9-4451-b450-6e4b599b7fda | 9 | public static boolean matches(AudioFormat format1,
AudioFormat format2) {
//$$fb 19 Dec 99: endian must be checked, too.
//
// we do have a problem with redundant elements:
// e.g.
// encoding=ALAW || ULAW -> bigEndian and samplesizeinbits don't matter
// sample siz... |
95b9d467-efc1-4a3e-96fb-28f31debb628 | 5 | public void run(){
byte arr1[] = new byte[576];
dack = new DatagramPacket(arr1, arr1.length);
try{
//keeps reading from server
while (lBound<totPacket){
dsock.receive(dack); // receive the packet
byte[] data = dack.getData();
int ack = getAcknowledgmentNumber(data);
receivedTime[ack... |
ae1541ad-b3a2-4a0f-9f20-66c2c16bd363 | 8 | @EventHandler
public void oreGinInteraction(PlayerInteractEvent event) throws IOException
{
Block clicked = event.getClickedBlock();
Player creator = event.getPlayer();
if (event.getAction().equals(Action.LEFT_CLICK_BLOCK))
{
if (clicked.getState() instanceof Dispenser)
{
//Create and/or upgrade ... |
e385d02b-f7f9-4767-8f6e-4c90fb7bc783 | 4 | public synchronized void stopInternalAudioPlayer() {
//TODO remove here all not used players
// may try to use the stream, if is connected, remove it again
for (final AudioPlayer_Mplayer player : allPlayers)
{
if(player != null)
{
player.stopPlaying();
player.killThread();
}
}
... |
b40b1eee-25e4-4218-bb0d-fceb3850eebe | 7 | private void doServerModule(final String moduleName) {
assert moduleExists("server", moduleName);
this.serverLoginModule = moduleName;
// confirm that runtime loaded the login file
final Configuration config = Configuration.getConfiguration();
// we o... |
eba6cb53-c2e7-455a-bd7a-fae31e6eefbe | 9 | private List<byte[]> doLayering(PngImage baseImage, PngImage layerImage, List<byte[]> baseRows, List<byte[]> layerRows) throws IOException {
final List<byte[]> result = new ArrayList<>(baseRows.size());
final PngImageType baseImageType = PngImageType.forColorType(baseImage.getColorType());
final PngImageType lay... |
73e8ecc7-3c6a-4838-9ff4-b17b5effbe0c | 1 | static void print(int[] A){
for(int i=0;i<A.length;i++){
System.out.printf("%d ", A[i]);
}
System.out.println();
} |
03eb4921-499d-464e-82f6-125072d587bf | 5 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Projeto other = (Projeto) obj;
if (this.id != other.id && (this.id == null || !this.id.equals(other.id)))... |
6170e0da-6921-4082-8804-6c6682c0bfdb | 4 | private final void drawGlobalDetails(Graphics2D g) {
String altString = String.format("ALTITUDE : %s", "----.--");
String disString = String.format("DISTANCE : %s", "----.--");
if(lander != null && model.positions.get(lander) != null &&
landingPad != null && model.positions.get(landingPad) != ... |
77a19c48-0884-4514-bea1-8d99538eb685 | 7 | private boolean _execCommand(String command, boolean reset) {
logPanel.add("Sent command <strong>" + command + "</strong>", LogPanel.OK, true);
String xmlString = null;
try {
URL url = new URL(HTTP_CAMERA_SERVER + HTTP_PATH_EXEC + "?" + command);
xmlString = _readText(url.openStream()).trim();
D... |
d699aa1e-5e23-4025-921e-ec0b2a96ccaa | 3 | public ArrayList<Object> lowerOutliersAnscombe_as_double(double constant) {
switch (type) {
case 1:
double[] dd = this.getArray_as_double();
lowerOutlierDetails = lowerOutliersAnscombeAsArrayList(dd, constant);
break;
case 12:
BigDecimal[] bd = this.getArray_as_BigDecimal();
ArrayList<Object> ret ... |
8da008bc-2add-4f47-994c-1308f36b622a | 5 | private void tryOnBadIntervalException(double startValue, double endValue, double step) {
try {
if (startValue < Integer.MIN_VALUE || endValue > Integer.MAX_VALUE) {
throw new BadIntervalException("Invalid borders of interval!");
}
if (endValue <= startValue)... |
4fcb2409-1a8e-4beb-9ef2-82c7621cc152 | 7 | @Override
public void visitIincInsn(final int var, final int increment) {
if (currentBlock != null) {
if (compute == FRAMES) {
currentBlock.frame.execute(Opcodes.IINC, var, null, null);
}
}
if (compute != NOTHING) {
// updates max locals
... |
09b6a5a4-13e3-4fbb-b054-1cc373525ae5 | 0 | public void setDestinationStation(String value) {
this._destinationStation = value;
} |
5abb64c7-62d2-4932-8435-04b7c9bab0bb | 1 | public void freeze(int layer){
assert(layer >= 0 && layer <= layers.size()-3);
frozen = layer;
} |
7def44d4-79d2-4e03-8f27-024ce2f528a9 | 2 | @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
matchLabel = new javax.swing.JLabel();
newTournButton = new javax.swing.JButton();
addPlayerButton = new javax.swing.JButton();
addWorldButton = new jav... |
441a9f33-a687-4bab-a85a-baabb16a30cc | 7 | public Unit getDivisors(int number){
if(map.containsKey(number)){
return map.get(number);
}
Unit unit=new Unit();
for(int div=2;div<number;div++){
if(number%div==0){
Unit unit1=getDivisors(div);
Unit unit2=getDivisors(number/div);
for(Integer div1:unit1.divisorSet){
for(Integer div2:un... |
e8648280-2c5a-47b7-80a4-9791a03dd8fd | 8 | private void runSoak()
{
final int cap = 10*1000;
HashedSetInt set = new HashedSetInt(0, 5);
// general put-get
for (int v = 0; v != cap; v++) org.junit.Assert.assertTrue(set.add(v));
org.junit.Assert.assertEquals(cap, set.size());
for (int v = 0; v != cap; v++) org.junit.Assert.... |
210754c3-6176-4491-a12d-f2d3b1bb594c | 1 | public final void clearEffects()
{
for(int e = 0; e<effectList.length;e++)
{
effectList[e] = Effect.CLEAR;
}
} |
36f74ef3-9905-49c0-affa-215daaf85d65 | 0 | public int getIntelligentY() {
return intelligentY;
} |
260f0572-1e4f-4cf2-a4bd-3531ba375f39 | 7 | public static void makeCompactGrid(Container parent,
int rows, int cols,
int initialX, int initialY,
int xPad, int yPad) {
SpringLayout layout;
try {
layout = (SpringLayout)pa... |
a8acc36f-5dcd-422e-a4de-f1e7b45c7c31 | 3 | private String readLine(BufferedReader clientRequest) {
String clientCommand = null;
this.log.info("before read Line");
do {
if (this.currentThread.isInterrupted()) {
this.log.info("current Thread is Interrupted");
closeClientSocket();
this.log.info("ClientHandler " + id + " finish");
return nu... |
50528e78-fb26-4068-8769-c6250c3edde6 | 0 | public void mouseDragged(MouseEvent event) {
adapter.mouseDragged(event);
} |
726a2f58-8b16-4266-8e85-0daa0afb9f2c | 2 | @Test
public void test() {
int[] arr = {3, 7, 8, 6, 5, 5, 4, 3, 1};
// Sort an array a[] of N integers between 0 and R - 1
for(int i : arr)
System.out.print(i);
System.out.println();
Strings.keyIndexedCounting(arr, 9);
for (int i : arr)
System.out.print(i);
} |
a15d33df-b2a4-4120-ba03-d4208520457d | 9 | public int bracket_matcher(String str){
//Initialize result to 0 by default;
int result = 0;
//This List<String> brackets stores the brackets in the input String.
List <String> brackets = new ArrayList<>();
//This is a counter for the number of opening brackets
int open = 0;
//This is a counter for t... |
40e35e8a-9aee-4ffb-97e5-f86d8a3e5198 | 3 | public static boolean deepEquals(boolean[] array1, boolean[] array2){
if (array1.length != array2.length) return false;
for (int i = 0; i < array1.length; i++){
if (!(array1[i] == array2[i])) return false;
}
return true;
} |
fec1822d-9e73-4edf-965d-af8bd5e69127 | 5 | private final String getChunk(String s, int slength, int marker)
{
StringBuilder chunk = new StringBuilder();
char c = s.charAt(marker);
chunk.append(c);
marker++;
if (isDigit(c))
{
while (marker < slength)
{
c = s.charAt(marker... |
c341970c-6e55-4330-b1df-6f6b7352d8c4 | 3 | static void indexShrink(){
/*
* remove half old entries in the index
*/
System.out.println("Index size before shrinking: "+index.size());
resultRecord.println("Index size before shrinking: "+index.size());
int max = index.size()/migratePara;
int count = 0;
Iterator<Entry<String, long[]>> ite... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.