method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
fd7c1226-19e2-4c0d-b8ae-9450c2d7b2ef | 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... |
9dc51c92-0991-4e7a-8e8a-a6c5144b25c9 | 0 | public void keyTyped(KeyEvent e) {
} |
88e0b1b5-0023-41b2-a09d-8f8d7cfa9dff | 7 | public static void doMultiThreadTest(String host, int txn, int threads) {
int eachUnitCount = txn/threads;
final LoadTest ltu[] = new LoadTest[threads];
for(int i=0;i<threads;i++) {
ltu[i] = new LoadTest("Test-"+i, host, eachUnitCount, threads);
ltu[i].setUp();
}
Thread threadPool[] = new Thread[thr... |
7662aecd-7847-487a-bc5c-fd243a6bf6d6 | 1 | private void searchPropietarioTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_searchPropietarioTextKeyPressed
cList = taller.searchClientes(searchPropietarioText.getText());
clientsModel.clear();
for(int i=0; i<cList.size(); ++i){
clientsModel.addElement(cList.get(i).g... |
aef18c72-b232-40dd-bc4f-8ff8c578d88a | 5 | private float buscar(String nombreAntecedente, String etiquetaRegla,File archivo) throws FileNotFoundException, IOException
{
RandomAccessFile raf = new RandomAccessFile(archivo, "rw");
char temp[] = new char[15];
String variable = null;
String etiqueta = null;
... |
e3b25ea6-d9d9-47ad-8448-01f828d4e1e4 | 1 | private void actionOk( )
{
int m = acceptanceList.length;
for ( int i = 0; i < m; ++i )
acceptanceList[i] = eigenValueCB[i].isSelected();
state = State.OKAY;
setVisible(false);
} |
34d809ec-edcc-49d2-b7fe-0a92e84f05b6 | 2 | public synchronized String invoke( String endpoint, Serializable request ) throws IOException {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpPost post = new HttpPost(endpoint);
post.setHeader("Content-Type", "application/json");
Gson gson = new Gso... |
f8e250db-0c9f-45a0-93b6-b36635a81eb5 | 6 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!(obj instanceof Node<?>))
return false;
Node<?> other = (Node<?>) obj;
return this.getElem() == other.getElem()
&& this.getNext() == other.getNext();
} |
36473536-1898-4296-a65b-bf46a472e842 | 6 | @Test
public void testPerformanceEdgeCount() throws FileNotFoundException
{
final OrdinaryCluster cl = new OrdinaryCluster(null, 0.5);
cl.setGroundTruthIndex(0);
final Random random = new Random();
final int numRuns = 1;
final int numQueries = 1000000;
final int maxSize = (int) 1e4;
final int stepsPerDe... |
b22cf862-72ef-4e08-bcde-f4b86e087881 | 7 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
if (firstname != null ? !firstname.equals(user.firstname) : user.firstname != null) return false;
if (lastname != null ? !lastname.equals(user.... |
6024985a-d70f-4ac0-9b16-727d139f2bc1 | 6 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Card other = (Card) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;... |
b58d6d81-f48c-46ea-9277-57a0688e0d2b | 1 | synchronized public static org.omg.CORBA.TypeCode type ()
{
if (__typeCode == null)
{
__typeCode = pgrid.service.corba.PeerReferenceHelper.type ();
__typeCode = org.omg.CORBA.ORB.init ().create_sequence_tc (0, __typeCode);
__typeCode = org.omg.CORBA.ORB.init ().create_alias_tc (pgrid.service... |
fb4db4c8-4034-4441-8a84-828cd714f864 | 6 | public void check() {
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
if (check1(i, j) || check2(i, j) || check3(i, j)
|| check4(i, j)) {
int tmp = getMatrix(i, j);
System.out.println("Player " + tmp + " wins.");
return;
}
}
}
System.out.println("No player wins... |
234bac67-3ad9-4e3e-a971-248d8f71fd7c | 8 | @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
GenericTreeNode<?> other = (GenericTreeNode<?>) obj;
... |
d957f5f5-a716-4dcc-914d-f959718a9210 | 9 | @Override
public void confirm(String mail, Integer... workshopIds) {
File tempFile = new File(file.getAbsolutePath() + ".tmp");
try (BufferedReader br = new BufferedReader(new FileReader(file)); PrintWriter pw = new PrintWriter(new FileWriter(tempFile), true)) {
String line;
... |
ce9c25e4-12a2-4fe5-9342-c53d3ccf3fdf | 0 | public IautosSellerInfo getSeller() {
return seller;
} |
abc61026-88eb-46bf-8b86-478e1af67081 | 7 | public static NearbyPlace toNearbyPlace(RequestBean request, PFPAd ad)
throws CitysearchException {
NearbyPlace nearbyPlace = new NearbyPlace();
String adUnitIdentifier = request.getAdUnitIdentifier();
StringBuilder nameLengthProp = new StringBuilder(adUnitIdentifier);
name... |
dfdffe6e-93bb-48ad-bd0a-82e53840f2bb | 2 | public void showdown(int currentPlayer, ArrayList<Card> holeCards, ArrayList<Card> sharedCards) throws Exception {
for (OpponentEntry entry : histories.get(currentPlayer).getHistory()) {
double handStrength;
if(entry.getStage() == STAGE.PREFLOP) {
handStrength = preFlops.get(entry.getNumberOfPlayers() - 2).... |
f7abb5e1-bece-40e1-9746-833b749231c0 | 4 | public boolean containsValue(Object value)
{
if (value == null) return containsNullValue();
Entry[] tab = this.table;
for (int i = 0; i < tab.length; i++)
for (Entry e = tab[i]; e != null; e = e.next)
if (value.equals(e.value)) return true;
return false;
} |
9bd1f0ba-048d-467e-b107-7719bb72d7d2 | 5 | public PeerManager(int portNumber, Tracker tracker, String flag){
port = portNumber;
this.tracker = tracker;
this.flag = flag;
downloading = false;
peerList = new ArrayList<Peer>(MAX_PEERS);
th = this.tracker.getTorrentHandler();
th.setPeerManager(this);
if(flag.equals("")){
peerCheck = new Thread... |
cc603d14-8eb4-46ee-b86e-9376b357c4c4 | 2 | @Override
public void destroy () {
assert (pipe == null);
// If there's still a pending linger timer, remove it.
if (has_linger_timer) {
io_object.cancel_timer (linger_timer_id);
has_linger_timer = false;
}
// Close the engine.
if (engine !... |
b7499e2d-763e-4564-bd27-353669867497 | 6 | public static void printDifferentElements(int[] arr1, int[] arr2) {
int[] biggerArray;
int[] smallerArray;
int n;
if(arr1.length > arr2.length) {
biggerArray = arr1;
smallerArray = arr2;
n = arr2.length;
}
else {
biggerArray = arr2;
smallerArray = arr1;
n = arr1.length;
}
int count = 0... |
d0031c28-a597-47bc-a07f-c8ee6af24310 | 5 | public void connect(String connection_id, Properties prop)
throws Exception {
if (connection_id == null || connection_id.trim().equals(""))
throw new Exception("Cannot connect to empty database identifier.");
String dump = prop.getProperty(connection_id);
if (dump == null) throw new Exception("Database ide... |
6f630772-253c-4f69-a4c9-5f3eccde1f08 | 9 | public static Node hasCycle(Node head) {
Node slow = head;
Node fast = head;
while (slow != null && slow.next != null && fast != null
&& fast.next != null && fast.next.next != null) {
slow = slow.next;
fast = fast.next.next;
if (slow == fast) ... |
41d9014c-48bf-4b4e-9812-af17683acb4f | 2 | public void UpdateGame(long gameTime, Point mousePosition) {
// Move the car
playerCar.Update();
movingBg.Update();
enemyCar.Update(playerCar.getSpeedY(), passedPoint[2]);
for (int i = 0; i < courseList.size(); i++) {
courseList.get(i).Update(playerCar.getSpeedY(), p... |
d50afe0f-a26e-4d89-9918-4fdcb23ffdbb | 4 | public void sendTo(CommandSender target, int pageNumber) throws InvalidMenuException, NoPageException, InvalidPageException{
validate();
Page page = getPage(pageNumber);
page.validate();
StringBuilder header = new StringBuilder();
if(usePrefix){
header.append(prefix);
if(!prefix.endsWith(" ")){
head... |
ffcab410-3682-4986-863c-1f680b85068c | 2 | @Override
void update() {
countDown--;
if (countDown < 0) remove = true;
int index = ImageManager.EXPLOSION_SPRITES - 1 - (int) (countDown / LENGTH_MULTIPLIER);
if (SCALE == 1) painter.drawImage(ImageManager.EXPLOSION[index], (int) x, (int) y, null);
else {
... |
b33a5772-b3eb-409d-9319-f4cf1d409d99 | 1 | public DynFactory(Class<? extends Sprite> cl) {
this.cl = cl;
} |
676ae389-e335-45ef-bf80-bd4bcf396862 | 6 | private void viewTabStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_viewTabStateChanged
String agcoopLoan = "maininterface.ViewLoan";
String agcoopMember = "maininterface.ViewMember";
String agcoopCompany = "maininterface.ViewCompany";
String agcoopSupplier = "maininterfa... |
a0f241e1-129b-41e1-9e62-e2205fb15bec | 1 | public boolean delete(Usuarios u){
PreparedStatement ps;
try {
ps = mycon.prepareStatement("DELETE FROM Usuarios WHERE codigo=?");
ps.setString(1, u.getCodigo());
return (ps.executeUpdate()>0);
} catch (SQLException ex) {
Logger.getLogger(UsuariosC... |
6d79ddda-1fd5-4e8c-8b5c-d6812212f741 | 6 | void readBlock() throws IOException {
if (_streamEndWasReached) {
return;
}
while (true) {
int size = (0 - _bufferOffset) + _blockSize - _streamPos;
if (size == 0) {
return;
}
int numReadBytes = _stream.read(_bufferBase,... |
9ca548f3-e583-4a35-883f-188938662166 | 5 | public boolean checkBox (int row, int col) {
int i = 0, j = 0, k = 0, count = 0;
/* Uses nested for loops to check the entries */
for (k = 1; k < 10; k++) {
for (i = row; i < row+3; i++) {
for (j = col; j < col+3; j++) {
count = 0;
if (k == Integer.parseInt(entries[i][j].getText())) {
... |
45a4b482-5251-4d94-bd3a-4d3752a3b091 | 1 | public void sort(T[] a, int lo, int hi)
{ // Sort a[lo..hi].
if (hi <= lo)
return;
int mid = lo + (hi - lo) / 2;
sort(a, lo, mid); // Sort left half.
sort(a, mid + 1, hi); // Sort right half.
merge(a, lo, mid, hi); // Merge results (code on page 271).
} |
b993bd13-52bb-4e1d-aaa4-ad1ff15e48ec | 8 | public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
for (int i = 0; i < n; i++) {
start.add(new Node(i));
finish.add(new Node(i));
}
int m = s.nextInt(); //количество рёбер
if (m == 0) {
System.out.println(n);
return;
}
while (m-- > 0) {
in... |
b57d1717-e663-496a-b086-65a314cad448 | 2 | public void render(){
glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
switch(page){
case 0:
renderMainPage();
break;
case 1:
renderHowToPage();
break;
}
} |
d015c79b-74a3-4c3a-a20c-3eeee5fd39e0 | 4 | @Test
public void resolve() {
long MAX=Long.MAX_VALUE;
int max=0;
for(long i=1, s=1;s<MAX; s=sum(++i)){
//print(i, s);
Set<Integer> divisors=new HashSet<Integer>();
for(int j=1;j<Math.sqrt(s)+1; j++){
if(s%j==0){
divisors.add(j);
divisors.add((int) (s/j));
}
}
max=Math.max(max, d... |
3b1548f3-635a-4b07-820c-9d88f114fdd6 | 9 | public <S> S getService(Bundle bundle, ServiceReference<S> ref)
{
UsageCount usage = null;
Object svcObj = null;
// Get the service registration.
ServiceRegistrationImpl<S> reg =
((ServiceRegistrationImpl.ServiceReferenceImpl) ref).getRegistration();
synchronize... |
6ad5351e-36e9-445d-8cb7-f1b34de3ae6f | 3 | public static void readFile(Map<Integer, UserPreferences> mapUP ,Map<Integer, ItemPreferences> mapIT ) throws FileNotFoundException{
File file = new File("u.data");
Scanner sc = new Scanner(file);
while(sc.hasNextLine()){
StringTokenizer st = new StringTokenizer(sc.nextLine(), "\t");
int userId = Integer.p... |
603680d0-f981-4d83-8abd-1ff52a9ebef1 | 7 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MyRectangle rectangle = (MyRectangle) o;
return Double.compare(rectangle.h, h) == 0
&& Double.compare(rectangle.r, r) == 0
... |
c6268fcf-bfa0-4457-b712-923adbfb8057 | 2 | public CollisionSolverThread(ActorSet actors, int start, int stride){
if(stride <= 0 || start < 0)
throw new IllegalArgumentException("CollisionSolverThread: Stride must be positive");
this.actors = actors;
this.stride = stride;
this.start = start;
} |
5ba054ee-ce5d-40b1-bd5a-07dee17a95d7 | 9 | public static int[] add(int[] number1, int[] number2) {
int num1Len = number1.length;
int num2Len = number2.length;
int[] result = (num1Len>num2Len)?new int[num1Len+1]:new int[num2Len+1];
int carry = 0;
int i=1;
for(;i<=num1Len&&i<=num2Len;i++) {
int currIdx1 = num1Len-i;
int currIdx2 = num2Len-i;
... |
2ac34171-af2a-4ba0-9d77-9007a3723227 | 4 | public JSONObject toJSONObject(JSONArray names) throws JSONException {
if (names == null || names.length() == 0 || this.length() == 0) {
return null;
}
JSONObject jo = new JSONObject();
for (int i = 0; i < names.length(); i += 1) {
jo.put(names.getString(i), this.... |
d988e7b2-9b3b-48df-af57-074dba08d70f | 0 | public Circle2D(Point2D _center, double _radius) {
center = _center;
radius = _radius;
} |
5af923c9-de11-4d09-bdf8-b6bf4a538703 | 0 | public String getContentType() {
return contentType;
} |
8cc5311a-746b-4802-b788-cbf02ffa5d29 | 6 | void getFetInfo(String arr[], String n) {
arr[0] = ((pnp == -1) ? "p-" : "n-") + n;
arr[0] += " (Vt = " + getVoltageText(pnp * vt) + ")";
arr[1] = ((pnp == 1) ? "Ids = " : "Isd = ") + getCurrentText(ids);
arr[2] = "Vgs = " + getVoltageText(volts[0] - volts[pnp == -1 ? 2 : 1]);
ar... |
013be536-76fd-4c52-a9ec-29990e04dc77 | 1 | public int getSize() {
// the size is in byte 0 of 'off' for primitive types (buf == null)
return buf == null ? (off & 0xFF) : 1;
} |
a78ee768-c93e-462e-bebf-31defe33e29a | 8 | public void onKeyPressed(KeyEvent e) {
switch (e.getKeyCode()) {
case VK_UP:
case VK_W:
// Arrow up key: move direction = forward (infinitely)
moveDirection = 1;
moveAmount = Double.POSITIVE_INFINITY;
break;
case VK_DOWN:
case VK_S:
// Arrow down key: move direction = backward (infinitely)
... |
4397c38b-5b12-447e-854d-eaeac546b0be | 0 | public String getAlgorithm() {
return algorithm;
} |
04e0e080-65fd-41f3-b330-61cd19a9f953 | 1 | public void restoreOps(Object s) {
Stack state = (Stack) s;
while (!state.isEmpty()) {
int penalty = ((Integer) state.pop()).intValue();
startOp(DONT_BREAK, penalty);
}
} |
7f058e04-3479-496a-871d-ae80ed5d4821 | 5 | @Override
public int hashCode() {
int prime = 31;
int prime1 = 37;
int prime2 = 41;
int prime3 = 43;
int rId = recordId;
int nIId = imageId;
int tFId = fieldId;
int tRNum = rowNumber;
int tVal;
if (rId == 0) {
rId =... |
a9225e93-2def-442d-8d2e-7025eb9f9bcc | 2 | */
public void destroyInferenceProblemStoreByName(final String name) throws IOException, CycApiException {
//// Preconditions
if (name == null) {
throw new NullPointerException("name must not be null");
}
if (name.length() == 0) {
throw new IllegalArgumentException("name must not be an emp... |
13aa5f55-d1bb-499d-835b-1a2da7c75d3c | 1 | public int hashCode() {
return (int)(5 *((milky == null) ? 0 : milky.hashCode()));
} |
5dd4383b-81f2-46c1-be6a-f95517e6ffba | 9 | private void createWindow (JFrame f){
final JComboBox categoryList= new JComboBox(categoryStrings); //initiate drop down lists
final JComboBox ratingList= new JComboBox(ratings);
final JComboBox yearList= new JComboBox(years);
final JComboBox pageList= new JComboBox(pages);
fin... |
a1bf98d8-665e-4101-946b-8e57d6eba494 | 3 | public static <V> Set<Rectangle> drawSector(Node<V> node, BufferedImage image, int w, int h, int s, int d)
{
Set<Rectangle> result = new HashSet<Rectangle>();
Graphics2D graphics = image.createGraphics();
Rectangle rect = node.nodeRect;
if (node.color) {
gra... |
7d11e353-b7e9-4515-a62e-1f6ecca37e82 | 9 | public static List<SystemObject> getObjects(String objectSpecString, DataModel dataModel) throws IllegalArgumentException {
List<SystemObject> allObjects = new LinkedList<SystemObject>();
String[] objectSpecs = objectSpecString.split(",");
for(int specIndex = 0; specIndex < objectSpecs.length; ++specIndex) {
L... |
4c2386d7-9742-479a-a998-5eea7a32d027 | 1 | @Override
public List<ValidateException> validate(String parameter) {
final int maxFirstNameLength = 30;
List<ValidateException> validateExceptionList = new LinkedList<>();
if (!ValidateUtils.stringMaxLengthValidation(parameter, maxFirstNameLength)) {
String exMsg = "entered qui... |
357d13ec-416b-47f0-8a8f-69a75d5c4576 | 8 | final public void Elif_statement() throws ParseException {
/*@bgen(jjtree) Elif_statement */
SimpleNode jjtn000 = new SimpleNode(JJTELIF_STATEMENT);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
jjtn000.jjtSetFirstToken(getToken(1));
try {
jj_consume_token(ELIF);
... |
ed02cbbc-69d0-437e-a4ab-946ca1f643c2 | 7 | protected boolean setArmorModel(EntityPlayer var1, int var2, float var3) {
ItemStack var4 = var1.inventory.armorItemInSlot(3 - var2);
if(var4 != null) {
Item var5 = var4.getItem();
if(var5 instanceof ItemArmor) {
ItemArmor var6 = (ItemArmor)var5;
this.loadTexture("/... |
9889afa3-9a74-4f73-9a29-a2e534c1d115 | 8 | public Number addNumbers(Number a, Number b)
throws NumberClassNotFoundException {
Number sum = null;
if (a instanceof Double && b instanceof Double) {
sum = new Double(roundDouble(a.doubleValue() + b.doubleValue()));
// trimNumber(sum);
} else if (a instanceof Integer && b ... |
ae0237eb-2c90-4690-ba45-b80c0a736182 | 4 | public static Object decodeToObject( String encodedObject )
{
// Decode and gunzip if necessary
byte[] objBytes = decode( encodedObject );
java.io.ByteArrayInputStream bais = null;
java.io.ObjectInputStream ois = null;
Object obj = null;
try
... |
3411f21f-fb29-4762-b641-1c0293a9d892 | 0 | public int getNumberOfPoints(){
return numberOfPoints;
} |
f76bcfe7-66e6-479a-b0a9-bb677868d890 | 7 | public void initOccupy(Scene s){
if(main.dayTime>=Main.NIGHT_TIME && spawnType==SpawnType.CIVILIAN)
spawnType = SpawnType.NIGHTER;
else if(main.dayTime<Main.NIGHT_TIME && spawnType==SpawnType.NIGHTER)
spawnType = SpawnType.CIVILIAN;
int toSpawn = (int)(Math.random()*(3) +1);
for(int i = 0; i<toSpawn; i... |
c424bc2e-60ff-4623-b39d-cd0004bac0c3 | 9 | static void configure() throws NumberFormatException, IOException {
textArea.append("In order to analyze your keystroke, you will be required to " +
"enter you password a certain amount of times to gather data.\n");
delay(1000);
textArea.append("You must enter you password at least five times.\n");
delay(15... |
53d98809-ddd5-403b-bf9d-733db3be841e | 2 | private void buildVerticalRoads() {
_verticalRoads = new VehicleAcceptor[_gridDimensions.getColumn()][_gridDimensions.getRow()+1];
//[column][row]
for (int j=0; j<_gridDimensions.getColumn(); j++) {
for (int i=0; i<=_gridDimensions.getRow(); i++) {
VehicleAcceptor l = VehicleAcceptorFactory.newR... |
4c76644e-232f-4fea-9c78-d6a35a3e757a | 2 | public void TempPlayers(){
File PLog = new File(getDataFolder() + ("tempPlayers.yml"));
if(!(PLog.exists())){
try {
PLog.createNewFile();
getLogger().info("TempPlayer File made!");
} catch (IOException e) {
e.printStackTrace();
}
}
getLogger().info("TempPlayer File Already exists not making... |
f165de86-2b7d-44ac-9c7e-4f13d243bafe | 9 | private int CharacterCollapse(int inTarget){ // computes and returns role code of the freshly deceased.
double[] CumulProbs = new double[4 + (2*NumWolves)];
CumulProbs[0] = Probabilities[inTarget - 1][0];
for(int i = 1; i < (4 + (2*NumWolves)); i++){
CumulProbs[i] = Probabilities[inTarget - 1][i] + CumulProbs[... |
a60b1b6f-5ebf-4639-aa44-b2a7fdaf8eae | 0 | public GUI(){
c = new Counter();
mr = new MindReader();
s = new Score();
r = new Random();
show();
} |
c8581c16-7df7-4569-b8c4-1e1e023d362a | 5 | public static void playSound(int id) {
Float[] floats = new Float[10];
floats[0] = 0.0f;
floats[1] = 0.1f;
floats[2] = 0.2f;
floats[3] = 0.3f;
floats[4] = 0.4f;
floats[5] = 0.5f;
floats[6] = 0.6f;
floats[7] = 0.7f;
floats[8] = 0.8f;
floats[9] = 0.9f;
if (Main.isSoundOn) {
if (id == 0) {
M... |
bfd0a473-118a-4dec-bbe5-1c8439d312f2 | 3 | public char[] stringCompresssion(char[] s) {
StringBuffer ss = new StringBuffer();
ss.append(s[0]);
int count = 1;
for (int i = 1; i < s.length; i++) {
if (s[i] == s[i - 1]) {
count++;
} else {
ss.append(count);
ss.append(s[i]);
count = 1;
}
}
ss.append(count);
if(ss.length()>=s.l... |
abb59fee-2762-4a56-a1ce-146c2347295b | 3 | public static void main(String[] args) {
double[] fs = { 0 * Math.PI / 180, 1 * Math.PI / 180,
2 * Math.PI / 180, 3 * Math.PI / 180, 4 * Math.PI / 180,
5 * Math.PI / 180, 6 * Math.PI / 180, 7 * Math.PI / 180, };
System.out.println(Arrays.toString(fs));
// frequency,magnitude,phase
double[] timeData = ge... |
57024e3d-adf9-47a6-9dd7-bc85b5c4f613 | 5 | public void calcTable()
{
int countCalc = table.size();
int prevCount = 0;
while(countCalc != prevCount)
{
prevCount = countCalc;
countCalc = 0;
for (Map.Entry<String, TableCell> entry : table.entrySet())
{
// System.out.println("Key : " + entr... |
f32d9fd2-057f-4a94-ac91-c5a61df8ee5b | 8 | public Drive put (Object key, Drive drive) throws IllegalArgumentException
{
if(containsKey(key) || containsValue(drive) || (key == null && drive != null && drive.getID() != null) ||
(key != null && drive != null && !key.equals(drive.getID())))
throw new IllegalArgumentException ("The specified drive is alre... |
0a40edc1-9191-4fd3-98f8-1157e389871d | 2 | public static void main(String[] args) {
try {
g();
} catch (Exception e) {
System.out.println("main: printStackTrace()");
e.printStackTrace(System.out);
}
try {
h();
} catch (Exception e) {
System.out.println("main: printStackTrace()");
e.printStackTrace(System.out);
}
} |
56c4132b-e548-4f94-afc2-09d92bfe0118 | 6 | public void forward(double amount)
{
double dx = amount * Math.cos(heading * Math.PI / 180);
double dy = amount * Math.sin(heading * Math.PI / 180);
double temp1 = xPos + dx;
double temp2 = yPos - dy;
((Graphics2D)graphics1).setStroke(new BasicStroke(thi... |
56766bad-c9de-4644-a940-e91d09880c6d | 4 | @Override
public void populateVals()
{
byte[] temp1 = new byte[7]; // PtgRef3d is 7 bytes
byte[] temp2 = new byte[7];
// Encoded Cell Range Address:
// 0-2= first row
// 2-4= last row
// 4-6= first col
// 6-8= last col
// Encoded Cell Address:
// 0-2= row index
// 2-4= col index + relative flag... |
876d694f-a4e7-4d66-892c-b0c8f5c56567 | 3 | public static void main(String[] args){
if(args.length < 1){
System.out.println("TCPServer port number not specified.");
System.exit(1);
}
ServerSocket parentSocket = null;
try{
int portNo = Integer.valueOf(args[0]).intValue();
parentSocket = new ServerSocket(portNo);
while(true){
Socket ch... |
2dd6da67-0459-4231-9d2e-f1fdb91e0ac4 | 6 | public void nextPermutation(int[] num) {
int i,j,k,t;
for(i = num.length - 2; i>=0; i--){
if(num[i]>=num[i+1])continue;
else break;
}
if(i==-1) {
sort(num,0,num.length-1);
return;
}
k = Integer.MAX_VALUE;
t = -1;
for(... |
89e9922d-acbb-4f4f-92a9-bd2c956e4145 | 3 | public SignatureVisitor visitParameterType() {
if (type != METHOD_SIGNATURE
|| (state & (EMPTY | FORMAL | BOUND | PARAM)) == 0)
{
throw new IllegalArgumentException();
}
state = PARAM;
SignatureVisitor v = sv == null ? null : sv.visitParameterType();
... |
79c2140c-8d5c-4345-899e-454b89fd5d06 | 1 | private static void solve(String[] input) {
for (String str:input){
recordChanges(str);
}
} |
04662e9d-e23b-4aba-9241-5f10e35c4f7f | 7 | public void updateBoard()
{
// Iterate through entire gameBoard, deleting position of currentBlock
for (int i = 0; i < NUM_ROWS; i++) // Loop through rows
{
for (int j = 0; j < NUM_COLUMNS; j++) // Loop through columns
{
if(gameBoard[i][j] == ACTIVE_BLOCK)
{
gameBoard[i][j] = EMPTY;
}
... |
f6b7ea31-c8df-41db-94f4-300db2c19fa8 | 3 | @Override
public GameState[] allActions(GameState state, Card card, int time) {
GameState[] states = new GameState[1];
states[0] = state;
if(time == Time.DAY)
{
states = new GameState[]{bruteDay(state, card, false)};
}
else if(time == Time.DUSK)
{
PickTreasure temp = new PickTreasure();
state... |
0757d853-f8e9-4d9c-8647-4e0d1f7884b1 | 0 | public void setEncode(ENCODE encode) {
this.encode = encode;
} |
56dc001d-a0ad-4717-bea4-8ddecf954457 | 7 | public MeterDatos(Principal init) {
initComponents();
this.setLocationRelativeTo(null);
this.setVisible(true);
lblInfo.setVisible(false);
this.inicio = init;
if (inicio.principal != null) {
txtAntiguedad.setText("" + inicio.principal.datos.getAntiguedad());
... |
9b6af7af-7b79-4aa1-96b4-805a92b7b703 | 4 | public void checkCbolOriginalDirV3() {
Path dir = Paths.get(CBOL_HOME);
List<String> list = new ArrayList<>();
//
//http://docs.oracle.com/javase/tutorial/essential/io/dirs.html
String str;
String str2;
String str3;
try (DirectoryStream<Path> stream = F... |
f0351b0b-3ce1-4635-9815-650e9ba36388 | 8 | public boolean printDistance(BSTNode<T> root, BSTNode<T> node1, BSTNode<T> node2, LinkedList<BSTNode<T>> queue) {
if(root != null) {
//if either of the nodes match with root
if(root == node1 || root == node2) {
// do the counting down logic
BSTNode<T> targ... |
0d72a94d-2ad4-4ad9-9f89-0a5a239f9fdd | 3 | public static void main(String[] args) {
String temp = "abcd";
byte[] b = temp.getBytes();
ByteArrayInputStream in = new ByteArrayInputStream(b);
for(int i = 0 ; i < 2; i ++)
{
int c;
while(-1 != (c = in.read()))
{
if(0 == i)
{
System.out.println((char)c);
}
e... |
a8408194-9558-40d4-9c25-d289cdcef376 | 5 | public static void main(String[] args)
{
for (int i = 1; i <= 100; i++)
{
if (i % 3 == 0 && i % 5 == 0)
{
System.out.println(i+"-"+"FizzBuzz");
}
else if (i % 3 == 0)
{
System.out.println(i+"-"+"Fizz");
... |
9cc9ac9f-d032-4827-8b33-54ef26317cd6 | 3 | @Test
public void testGetAllDeployments() throws IOException {
List<Deployment> remoteDeployments = dexmaRestFacade.getAllDeployments();
assertEquals(1,remoteDeployments.size());
Iterator<Deployment> itRemote = remoteDeployments.iterator();
while (itRemote.hasNext()) {
Deployment dep = ... |
478825d5-2206-4f9c-aa24-a9a2afc9e353 | 5 | @Override
public Group createGroup(Group group) {
Connection cn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
cn = ConnectionHelper.getConnection();
ps = cn.prepareStatement(QTPL_INSERT_GROUP, new String[] { "group_id" });
ps.set... |
11e01f2a-db8c-4261-9f72-11d7fb6841e6 | 6 | private static void initializeLists() {
try{
readCubes();
}
catch(ParserConfigurationException | SAXException | IOException e){
System.out.println(e.getMessage());
createRandomCubes();
}
try{
readLines();
}
catch(Par... |
dde32e74-2689-4298-b8d5-ec74a9f07296 | 5 | @Override
public void execute(CommandSender sender, String gateName, List<String> args) {
this.sender = sender;
if (gateName == null) {
error("No gate given.");
reply("Usage: /gate setdenysilent <gatename> <true|false>");
} else if (!gateExists(gateName)) {
reply("Gate not found: " + gateName);
} e... |
d9df8116-da89-486c-b419-714aa4ce68b2 | 9 | private String buildDirectoryListing(String path, File[] files) {
// Sort all files: first directories, then files
Arrays.sort(files, (f1, f2) -> {
if (f1.isDirectory() && !f2.isDirectory()) {
return -1;
} else if (!f1.isDirectory() && f2.isDirectory()) {
return 1;
} else {
return f1.toString()... |
b9248ca5-d884-4985-a7c6-ad0399eea547 | 3 | private int getIndexToWrite() { //returns the first empty particle array index, and if none exist returns the location of the "oldest" particle instead
int oldestParticleAge = 0;
int oldestParticleIndex = 0;
for (int particleIndex = 0; particleIndex < particleArray.length; particleIndex... |
3983459d-4bd0-43dd-8553-fd18afdf4956 | 4 | */
@Override
public boolean equals(Object arg0) {
for (int i = 1; i < transitions.length; i++) {
for (int j = 1; j < transitions[0].length; j++) {
// Lazy!
try {
if (transitions[i][j] != ((Automata<Integer>)arg0).getTransitions()[i][j]) {
return false;
}
... |
9334e05a-6f78-4c52-b01e-d708fae2d9a8 | 4 | private void leftComp(float a, int vel) {
for (float i = 0; i < a; i++) {
if (!this.touchRobotRotate()) {
this.rotateRobot(-1);
if (this.checkTouchBullet()) {
this.onHitByBullet();
return;
}
... |
b6d7a3e5-7ca0-4747-a78f-2221d61749b8 | 6 | @Override
public String calculate(VcfEntry vcfEntry) {
if (vcfEntry == null) return null;
try {
// We set the master (and VcfFileIterator) 'parseNow=false', so the VcfEntry should be 'unparsed' at this moment.
// The idea is that the workers can do this, relieving the master from this task.
vcfEntry.pars... |
9c91759c-1045-4746-aa0a-dac1c9258746 | 8 | private int classifyFitness(char[][] board) {
float[] input = new float[48];
int i = 0;
for (int r = 0; r < board.length; r++) {
for (int t = 0; t < board[0].length; t++) {
switch(board[r][t]) {
case PLAYER1:
input[i++] = 1;
break;
case PLAYER2:
input[i++] = -1;
break;
case ... |
afc0f3f1-a404-489d-a8a3-1ecc4d55c602 | 0 | @Override
public String getName() {
return "dump";
} |
4a44792a-5780-4aa8-882d-8a3e34cc214e | 0 | public BodyArmorSlots getBodyArmorSlots(){
return bodyArmorSlot;
} |
f8d030f3-8f31-4a3f-9edb-358abdcee5ba | 5 | public static ArrayList<Planet> forGR(PlanetWars pw){
// Tested
ArrayList<Planet> asw = new ArrayList<Planet>(2);
asw.add(null);
asw.add(null);
// Find the biggest fleet to attack with
int maxShips = 0;
for (Planet p : pw.MyPlanets()){
if (p.NumShips() > maxShips){
maxShips = p.NumShips();
asw.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.