method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
748d3eba-b4f2-47de-9678-77ef81b9e279 | 4 | private static ArrayList<Long> readNumbersArrayFromFile()
{
ArrayList<Long> longArray = new ArrayList<Long>();
FileInputStream fstream = null;
try
{
fstream = new FileInputStream("algo1-programming_prob-2sum.txt");
// Get the object ... |
7151f99b-499f-46ab-b4e7-fc94873fba2d | 6 | public void createNextGeneration(ArrayList<BuildOrder> orders) {
Gson gson = new Gson();
System.out.println("The following build orders will survive in the gene pool: ");
for (BuildOrder order : orders) {
System.out.println(gson.toJson(order));
}
try {
File knowledgeBase = new File(knowledgeBasePath);... |
9d5ca272-5fee-45aa-af3f-ffb8a081e4a7 | 5 | public void printViterbi(boolean getBest) {
Iterator<String> myIt=ViterbiEndpoint.keySet().iterator();
String myStr;
boolean entered=false;
double bestVal=2;
String bestStr="";
while (myIt.hasNext()) {
myStr=myIt.next();
if (!entered || bestVal< ViterbiEndpoint.get(myStr))
{bestVal=ViterbiEndpo... |
70202a35-fe96-4dbf-9f10-4bacfcb39968 | 3 | public boolean equals(DisplayState other) {
if(other == null) return false;
return other.getCurrState() == this.getCurrState() &&
this.getImageIndex() == other.getImageIndex() &&
this.commands.equals(other.getCommands());
} |
43d3dc45-a0bf-4b23-8acf-92ced1561c34 | 1 | void sendBytes ( final Socket sock ) throws IOException {
@SuppressWarnings ( "resource" )
OutputStream out = sock.getOutputStream();
byte[] buf = new byte[this.bytesSent];
for ( int i = 0; i < this.bytesSent; i++ ) {
buf[ i ] = (byte) ( i + 'A' );
}
out.write... |
dad0290a-5e95-4eb8-9851-1bbddc1f4287 | 8 | static String getQudrantXY(String v, String h) {
int hor = Integer.valueOf(h);
int vert = 1;
if (v.equals("b")) {
vert = 2;
} else if (v.equals("c")) {
vert = 3;
} else if (v.equals("d")) {
vert = 4;
} else if (v.equals("e")) {
vert = 5;
} else if (v.equals("f")) {
vert = 6;
} else if ... |
47dca36c-1ed4-4dfc-9f01-9b4e93f2f7c2 | 1 | public void updateFont(List<Font> fonts, int startFrom, int endAt) {
int i, j;
for (i = startFrom, j = 0; i <= endAt; i++, j++) {
this.children.get(i).setFont(fonts.get(j));
}
this.modelChanged();
} |
bb61e9f5-2343-4b6f-8009-e83aa1f422f9 | 6 | private void processSendButton() {
//
// make sure the the specified file exits
//
String fileName = fFileFullPathname.getText();
File file = null;
String[] recipients = null;
WarningUI warning = null;
if (fileName.length() == 0) {
warning = n... |
d492de7c-a447-4a2f-b581-4ffd2f6bb516 | 5 | private static void lisaaAveceja(int aveceja, ArrayList<Sitsaaja> sitsaajat) {
int i = 0;
do {
Sitsaaja sitsaaja = Yhteydet.annaRandomSitsaaja(sitsaajat);;
do {
sitsaaja = Yhteydet.annaRandomSitsaaja(sitsaajat);
} while (sitsaaja.puolisoIsSet() == true... |
95728d74-c90e-434d-8045-d9db03b21835 | 0 | @Test
public void testSetFood() throws IOException {
System.out.println("setFood");
AntBrain b = new AntBrain("cleverbrain1.brain");
Ant instance = new Ant(b,true,0);
boolean expResult = false;
boolean result = instance.getFood();
assertEquals(expResult, resu... |
213f9e94-06bb-4ad1-ac73-3542c99d8ef0 | 7 | public boolean containsValue(Object value) {
if (value == null) {
for (int i = 0, isize = data.length; i < isize; i++) {
HashEntry entry = data[i];
while (entry != null) {
if (entry.getValue() == null) {
return true;
... |
5f887b4c-6396-4e6f-a664-0217b0fa81aa | 0 | public static void main(String[] args){
Application app = new Application();
app.run();
System.exit(0);
} |
6f98b189-f4fa-463c-82dc-997f9d6c215f | 6 | public boolean modelTypeCached(int modelType) {
if (modelTypes == null) {
if (modelIds == null)
return true;
if (modelType != 10)
return true;
boolean cached = true;
for (int id = 0; id < modelIds.length; id++)
cached &= Model.isCached(modelIds[id] & 0xffff);
return cached;
}
for (int ... |
38578cf6-b777-4297-8c81-19ca4060b77b | 2 | public static <T, A extends Annotation> String getClassAnnotationValue(Class<T> classType, Class<A> annotationType, String attributeName) {
String value = null;
Annotation annotation = classType.getAnnotation(annotationType);
if (annotation != null) {
try {
value = (String) annotation.annotationType().getM... |
aa26b0e7-f464-4ba6-9193-0deafc4aaf95 | 4 | @Test(groups = { "Character-Sorting", "Fast Sort" })
public void testHeapSortChar() {
Reporter.log("[ ** Heap Sort ** ]\n");
try {
testSortCharacters = new HeapSort<>(
fastShuffledArrayChar.clone());
Reporter.log("1. Unsorted Random Array\n");
timeKeeper = System.currentTimeMillis();
testSortC... |
0f8611c3-24c9-4802-b6db-772c8f4ed5b5 | 5 | public void remotePlayerPutCard(Player p, Card c) {
TurnContext cx = p.getCurrentContext();
CardRange r = getCorrespondingCardRange(cx.currentPlayable, p);
CardEntity ent = null;
boolean found = false;
cardsReadLock.lock();
try {
int remaining = r.getLength();
for (Iterator<CardEntity> iter = cards.li... |
afaf852b-7a0c-41a1-b98e-6e94c0bd6074 | 4 | public void setTargetPoint( EndPoint targetPoint ) {
ConnectionArray array = null;
if( this.targetPoint != null ){
removeChild( this.targetPoint );
array = this.targetPoint.getArray();
if( array != null ){
array.remove( this.targetPoint );
}
this.targetPoint.setConnection( null );
}
this.t... |
37f77a27-1736-46a0-9e11-911e82aa1c73 | 0 | public NodeSetTransferable(NodeSet nodeSet) {
super(nodeSet.toString());
this.nodeSet = nodeSet;
} |
4dd424b2-43a5-402f-819f-1798547b913b | 4 | public AsetInterface shortestPath() {
VertexInterface r, pivot;
for (VertexInterface x : gi.getGraph()) {
pi.setPoids(x, (int) Integer.MAX_VALUE / 2);
// je divise par 2 parce que Integer.MAX_VALUE+1=Integer.MIN_VALUE
}
r = gi.getDeparture();
pivot = r;
int n = gi.getGraph().size();
for (int j = 1;... |
cb04b65e-2fe1-4761-aec3-2f9bb086e069 | 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... |
7bddbfde-47e6-4fb7-a401-879d78e5f3af | 9 | private Font updateFont() {
String fontStr = (String) jlFont.getSelectedValue();
String styleStr = (String) jlFontStyle.getSelectedValue();
int style;
int size = sizeValue[jlFontSize.getSelectedIndex()];
if (styleStr.equals("常规")) {
style = Font.PLAIN;
} else ... |
cea152c0-5fff-48d0-8203-f1aa0b00bf9e | 7 | public void run()
{
while (thread != null && state == STATE_PLAYING && read != -1) {
if (written >= read) {
try {
read = audioInputStream.read(buffer, 0, buffer.length);
written = 0;
}
catch (IOException e) {
e.printStackTrace();
... |
4fe794da-2a3c-42b8-b0a9-b42aab5c4a57 | 0 | public void setName(String name) {
this.name = name;
} |
a4c02fb5-f06e-4cc0-b4c2-af03f36b45ef | 5 | public MP3Filter(boolean title, boolean artist, boolean caseSensitive, String searchString) {
super();
filterList = new Vector<MP3Filter.BasicFilter>();
if (caseSensitive) {
this.searchString = searchString;
if (title) {
filterList.add(new TitleFilter());
}
if (artist) {
filterList.add(new... |
d1b17622-2ed7-4e10-bb87-0263f8b699f3 | 7 | private void CancelTicketButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelTicketButtonActionPerformed
int selRow = ViewHistoryTable.getSelectedRow();
if (selRow == -1) {
jLabel1.setText("Please select a ticket to continue");
return;
... |
5dd4b1e8-6739-4067-808e-65ad1ee6089d | 1 | static String nextBlackMove(){
if(!blackOpening.isEmpty())
return blackOpening.remove(0);
else
return null;
} |
835eeb38-844e-4fda-9270-9b6e4067b8c2 | 4 | public Game(List<User> u)
{
users = u;
start = System.currentTimeMillis();
System.out.println("Game has been created.");
System.out.println("Team 1: ");
int sumaBlue = 0;
float sredniaBlue = 0;
int sumaPurple = 0;
float sredniaPurple = 0;
for(U... |
c63d35fe-cd4b-4df8-be81-be96bdbd71b7 | 2 | private static void mergeWithPrevVisibleNode(OutlinerCellRendererImpl textArea, JoeTree tree, OutlineLayoutManager layout) {
Node currentNode = textArea.node;
Node prevNode = tree.getPrevNode(currentNode);
if (prevNode == null) {
return;
}
// Abort if prevNode is not editable
if (!prevNode.isEditab... |
b1fafcbb-0c30-4e25-b9de-fea31252e85d | 5 | private boolean getFilmography(int start, int end, StringBuilder sourceCode, String pattern) {
boolean flag = true;
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(sourceCode);
m.region(start, end);
while (m.find() &&
(end < sourceCode.indexOf("id=\"External_links\"... |
1afaa3e9-4715-47a1-a771-e715bf020a7f | 0 | public PermissionRcon getRcon() throws DataLoadFailedException {
return dataHolder.getRcon();
} |
062931ef-7e6b-4575-bd57-7f6f4a300a50 | 6 | public void Loadfile(String xmlfile)
{
File file = new File(xmlfile);
if (!file.exists())
return;
Document doc = null;
try
{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
doc = db.parse(file);
doc.getDocumentElement().norm... |
478c3344-8bc8-4551-9f65-f18cb3d2d060 | 1 | public static boolean addNewDrug(NewDrugPage newDrug){
Drug newd = new Drug();
String quantity = newDrug.getdQuantity().getText();
int quant = Integer.parseInt(quantity);
String cont = newDrug.getdControlled().getText();
String t= "true";
boolean controlledt=false;
controlledt=cont.equals(t);
newd.s... |
6d6812f0-e8a7-486a-86bd-332fc942fa8d | 0 | @Override
public void initialize(Vertex start) {
} |
a21af683-cda6-4bb0-81c3-2d3316b0c7ed | 6 | private final AbstractTrack getTrack(int trackNr)
{
if(trackNr >= 0)
this.trackNr = trackNr;
switch(this.trackNr)
{
default:
case 0:
return this.testtrack;
case 1:
return this.otrack;
case 2:
... |
63b34358-d8b9-4f9a-b7a0-681f668d3d7d | 8 | protected static Map<DeltaSQLStatementSnapshot, List<WaitEventForStatementTuple>> loadWaitEventsForStatements(
List<DeltaSQLStatementSnapshot> worstStatements,
Calendar startTime,
Calendar stopTime,
ProgressListener progressListener) {
Map<DeltaSQLStatementSnapsh... |
164fd199-5bfe-4dd6-ad00-b6b684bb8926 | 4 | public long getLong(String key) throws JSONException {
Object o = get(key);
if(o==null) return 0;
if(o instanceof String){
if(o.toString().length()>0){
return Long.valueOf((o.toString()));
}else
return 0;
}
return o instanceof Numbe... |
6be07ca3-1ea8-4db5-9331-c9e873c45c6f | 8 | private GamePosition blockSeriesOfFourOrMoreInCheckMode(GameBoardMark playerMark) {
int zero = 0;
int upToSquaresPerSide, upToFive, upToSix;
GamePosition position = new GamePosition();
GamePosition position2 = new GamePosition();
for (upToSix = 0; upToSix < 6; upToSix++) {
... |
d0940f50-1d66-408b-9316-708e32a2fced | 2 | public Object match(PathPattern<ServletAction> pattern, PathInput input, MapHttpServletRequest request) {
if (type == Type.DEPLOY) {
try {
Page page = pageClass.newInstance();
input.bind(page);
pattern.match(input);
request.setAttribute... |
20943e71-939a-464b-b1b3-12bf83f9be61 | 7 | public void handle(String line) {
String[] message = line.split(" ");
String command = message[0].toLowerCase();
for(int x = 0; x < message.length; x++) {
// Misc.println(message[x]);
}
if(command.startsWith("oper")) {
UserOper oper = new UserOper(server);
oper.handleCommand(line);
} else if(comma... |
deceb8ac-3427-45a3-beb2-06967cf9cdd6 | 5 | public List<Booking> getStudentBookingsByDate(Student student, Calendar date) {
List<Booking> b = new ArrayList<Booking>();
Iterator<Booking> iter;
iter = bookings.iterator();
while (iter.hasNext()) {
Booking booking = iter.next();
if ((booking.getDate().get(Calendar.DAY_OF_MONTH) == date
.get(Calend... |
a2475e3e-61bc-4070-80ae-a9dee174c481 | 1 | public Label newLabel() {
if (this.isDeleted) {
final String s = "Cannot change a field once it has been marked "
+ "for deletion";
throw new IllegalStateException(s);
}
this.setDirty(true);
return new Label(maxLabel++);
} |
2b0027ed-82a7-47cb-a47e-5f5d805ded7a | 9 | private void cleanUpImports() {
Integer dummyVote = new Integer(Integer.MAX_VALUE);
SortedMap newImports = new TreeMap(comparator);
List classImports = new LinkedList();
Iterator iter = imports.keySet().iterator();
while (iter.hasNext()) {
String importName = (String) iter.next();
Integer vote = (Intege... |
85b91c0e-6428-4494-b69a-2232c94e4d8b | 4 | public static void calculateSimilarities() {
double sim;
for (Integer user1 : userCommunity.keySet()) {
for (Integer user2 : userCommunity.tailMap(user1, false).keySet()) {
sim = computeSimilarity(user1, user2);
// this is for user1's list
if (userSimilarities.containsKey(user1)) {
userSimila... |
dcfee32d-9ec2-4482-a719-40a5fc98825b | 6 | public void init(PolicyFinder finder) {
// now that we have the PolicyFinder, we can load the policies
PolicyReader reader = new PolicyReader(finder, logger, schemaFile);
Iterator it = policyList.iterator();
while (it.hasNext()) {
String str = (String)(it.next());
... |
49fbc532-4f08-479e-8d3e-853c16316fe1 | 8 | public void processEvent(Event event)
{
if (event.getType() == Event.COMPLETION_EVENT)
{
System.out.println(_className + ": Receive a COMPLETION_EVENT, " + event.getHandle());
return;
}
System.out.println(_className + ".processEvent: Received Login Response..... |
fe8618c8-533d-426d-a1a9-7f5178634163 | 7 | private BufferedImage putIntoImageCache(BufferedImage bim, int width, int height, boolean allowScaling) {
// create new Image cache if needed.
if (image == null) {
image = new ImageCache(library);
}
boolean setIsScaledOnImageCache = false;
if (allowScaling && scaleIm... |
5f64db2e-1793-4912-bae5-e8684839171f | 6 | private static List<List<Integer>> Bucketize(List<Integer> candidates, List<Long> primes, int primeSet) {
ArrayList<List<Integer>> result = new ArrayList<List<Integer>>();
for (int i = 0; i < candidates.size(); i++) {
Integer n1 = candidates.get(i);
System.out.print("Candidate=... |
fd1b3f97-53ec-4354-a5ae-36459afad60c | 2 | CPGreyBmp makeVertLinesTexture(int lineSize, int size) {
CPGreyBmp texture = new CPGreyBmp(size, size);
for (int i = 0; i < size * size; i++) {
if (i % size >= lineSize) {
texture.data[i] = (byte) 255;
}
}
return texture;
} |
526b6132-e731-4847-b6ae-adf03cec030e | 3 | @Override
public void reactOnCollision(ElementField element, CollisionMan.TYPE type) {
if (_faced == null || !_faced.equals(element)) {
if (element.mass() == MASS.INF_MASS) {
collideWithUnmovableElement(element, type);
} else {
collideWithMovableElemen... |
37d789bf-323a-40fd-98f4-d98877328efe | 5 | public void keyPressed(KeyEvent e) {
int key = e.getKeyCode();
if (key == KeyEvent.VK_SPACE) {
fire();
}
if (key == KeyEvent.VK_LEFT) {
dx = -1;
}
if (key == KeyEvent.VK_RIGHT) {
dx = 1;
}
if (key == KeyEvent.VK_UP) {... |
32fe9faf-8e61-4176-b719-8d2da32915ef | 9 | protected void generateClassFiles(ClassDoc[] arr, ClassTree classtree) {
Arrays.sort(arr);
for(int i = 0; i < arr.length; i++) {
if (!(configuration.isGeneratedDoc(arr[i]) && arr[i].isIncluded())) {
continue;
}
ClassDoc prev = (i == 0)?
... |
614d432d-cfb8-4810-ab40-7ae7ec0c0de2 | 1 | public static Cursor getCursor(int id) {
Integer key = Integer.valueOf(id);
Cursor cursor = m_idToCursorMap.get(key);
if (cursor == null) {
cursor = new Cursor(Display.getDefault(), id);
m_idToCursorMap.put(key, cursor);
}
return cursor;
} |
8b9de9c8-9dcc-4217-b224-55e4070abe6d | 4 | private static int method516(char arg0[], int arg1) {
for (int k = arg1; k < arg0.length && k >= 0; k++) {
if (arg0[k] < '0' || arg0[k] > '9') {
return k;
}
}
return arg0.length;
} |
80e189d6-7106-4ab9-bd01-f4403cf9253a | 6 | @Override
public void keyPressed(KeyEvent e)
{
final int key = e.getKeyCode();
if (userName.isFocusOwner()) if (key == KeyEvent.VK_ENTER || key == KeyEvent.VK_TAB)
{
password.requestFocus();
return;
}
if (password.isFocusOwner()) if (key == KeyEvent.VK_ENTER || key == KeyEvent.VK_TAB)
{
login.do... |
e7f735ce-f881-4cbe-8aa7-7565fe118f74 | 9 | @Override
public void actionPerformed(ActionEvent ae) {
if(ae.getSource() == btnSubmit){
CustomerDataSource cusDS = new CustomerDataSource();
if(!tfFName.getText().isEmpty() && !tfLName.getText().isEmpty() && !tfPhone.getText().isEmpty() && !cusDS.checkCustomerByPhone(tfPhone.getText()))
{
Custom... |
d816bb35-e51e-4eeb-8d62-fe91040b05e5 | 0 | @Test
public void runTestButton1() throws IOException {
InfoflowResults res = analyzeAPKFile("Callbacks_Button1.apk");
Assert.assertNotNull(res);
Assert.assertEquals(1, res.size());
} |
c8071153-4668-464a-8077-fc9f930aa441 | 9 | public static void readConfigDB() throws Exception {
try {
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
InputStream in = new FileInputStream(configFile);
if (in.available() == 0) {
throw(new Exception("File not found or empty"));
... |
0e4da97f-5e2e-4474-bf48-b6908c3fb097 | 7 | public void paintComponent(Graphics g) { //хз, прокатит ли с 2 параметрами
super.paintComponent(g);
x_centr = this.getWidth() / 2;
y_centr = this.getHeight() / 2;
Graphics2D g2d = (Graphics2D) g;
this.setBackground(Color.WHITE);
g2d.setColor(Color.BLACK);
// тестовая... |
e62ffa19-b348-4ddc-b4a9-b743e2434e89 | 7 | private boolean checkLinesAndColums(String curBoard) {
for (int i = 0; i < 3; ++i) {
if (curBoard.charAt(i * boardSize) == curBoard.charAt(boardSize * i + 1)
&& curBoard.charAt(i * boardSize) == curBoard.charAt(boardSize * i + 2)
&& curBoard.charAt(i * boardSize) != ' ') {
return true;
}
i... |
7d79a7e1-de36-4f3a-b5c7-efc4198db148 | 5 | public void updateLevel(Game game) {
this.game = game;
for (Tile t : tiles) {
t.tick(game);
if (game.getInput().rightButton && t.isContainsMouse())
rightClick(t);
if (game.getInput().leftButton && t.isContainsMouse())
leftClick(t);
}
} // End update |
4bf1be48-ca8e-49d4-8a9f-6490558b8692 | 6 | @Override
public int compareTo(Object o) {
if (this == o) return 0;
if (o instanceof CommandBase) {
CommandBase cmd = (CommandBase) o;
int c = (name.compareTo(cmd.name));
if (c != 0) return c;
if (options.size() != cmd.options.size()) return options.size() - cmd.options.size();
for (CommandOption ... |
3a9df0e8-7491-46c1-92da-ee25d0ab6554 | 5 | public Node selectRandomNode(Node nodeIn) {
List<Node> selectCollection = new ArrayList<Node>();
if (nodeIn.getType() == NodeType.INPUT) {
selectCollection.addAll(outNodes);
selectCollection.addAll(hiddenNodes);
} else if (nodeIn.getType() == NodeType.OUTPUT) {
... |
960ee2f2-1e19-4b2b-99ef-5b458581d5cb | 1 | private void initCheckSavingReq() {
if (theWorker == null) {
state = UIState.CHECKSAVINGREQUIREMENT;
lblStatus.setText("Checking files on disk");
theWorker = new MyWorker(rootPage, JobType.CHECKSAVINGREQUIREMENT, true);
theWorker.execute();
}
} |
88be0ebe-cdd6-4acc-93c2-655fcd0fa635 | 1 | public void println(String text) {
if(frame == null) buildGUI();
area.append("\n" + text);
} |
6b61952c-66f6-46a1-a38f-a41c232c9a73 | 3 | public void gen() {
for (int i = 0; i < tiles.length; i++) {
for (int j = 0; j < tiles[0].length; j++) {
if (r.nextInt(10) > 1) {
tiles[i][j] = new Grass(i * 64, j * 64);
}
else {
tiles[i][j] = new Stone(i * 64, j * 64, this);
}
}
}
} |
d61da0ec-8e9f-47f3-a633-556e229937ac | 5 | @SuppressWarnings("unchecked")
public static <E> E findFirstMatch(Collection<?> source, Collection<E> candidates) {
if (isEmpty(source) || isEmpty(candidates)) {
return null;
}
for (Object candidate : candidates) {
if (source.contains(candidate)) {
return (E) candidate... |
f9670c8b-01ad-4ef4-90f9-3e50e833981f | 5 | public IVPNumber add(IVPNumber number, Context context, DataFactory factory, HashMap map) {
IVPNumber result = factory.createIVPNumber();
map.put(result.getUniqueID(), result);
if(getValueType().equals(IVPValue.INTEGER_TYPE) && number.getValueType().equals(IVPValue.INTEGER_TYPE)){
int resultInt = context.getIn... |
0c87debd-c0c9-45bf-9a62-e2a3d61c81f1 | 3 | private void dropElement() throws Exception {
Session s = HibernateUtil.getSessionFactory().getCurrentSession();
try {
ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
Object obj = ois.readObject();
if(obj instanceof NetworkHardware) {
s.beginTransaction();
... |
9b7d3937-f606-4ffd-be1e-3281ff3bc806 | 6 | public static void main(String[] args){
// Example of creating a set and partitioning it:
System.out.println("Starting by creating a partitioned set of 4 elements:");
PartitionListElement<String> list = new PartitionListElement<String>();
list.add("one");
list.add("two");
list.add("three");
list.add("four... |
3a079638-1bb0-450b-8407-21432633325c | 1 | public void close() throws XmlRpcException {
if (xmlRpcClient != null) {
xmlRpcClient.close();
}
} |
f948c8bd-9ab9-4cf5-8a27-687e4c65eab5 | 9 | public void Partition(int[] a, int k, int begin, int end) {
int left = begin;
int right = end;
int temp = a[left];
while (left < right) {
while (left < right && a[right] >= temp)
right--;
if (left < right)
a[left] = a[right];
while (left < right && a[left] < temp)
left++;
if (left < righ... |
adfac691-2d5d-4cca-9ec9-33b9893f095f | 9 | private void process(File aFile) {
if(aFile.isFile()){
String name = aFile.getName();
if (name.substring(name.length()-4).equals("java")){
try {
if (!name.equals("Command.java") && !name.equals("CommandFactory.java")){
String pack = aFile.getPath().replaceAll("\\\\", ".");
pack = pack.subst... |
1fe4ba43-b559-4aaf-97de-8ca33f1213d8 | 8 | public void addSlower(double x, double y){
Slower t = new Slower(new Vertex2D(x, y), getGos());
if (!touchesAnything(t))
if (y >= .5 * Tower.HEIGHT
&& y <= TDPanel.HEIGHT - .5 * Tower.HEIGHT
&& (y < TDPanel.HEIGHT / 3 - .5 * Tower.HEIGHT || y > 2
* TDPanel.HEIGHT / 3 + .5 * Tower.HEIGHT)
&&... |
26b62265-415b-4a36-9aec-54d41e1f938e | 5 | @Override
public double[] intersect(Ray ray) {
// Algorithm: http://www.ray-tracing.ru/articles213.html
Vector3 T = ray.getFrom().subtract(v0);
Vector3 Q = T.crossProduct(e1);
Vector3 P = ray.getDirection().crossProduct(e2);
double pDotE1 = P.dotProduct(e1);... |
38dd2293-ffa2-4f4d-93cc-d085c40498f3 | 3 | private void dropAlarm() throws Exception {
Session s = HibernateUtil.getSessionFactory().getCurrentSession();
try {
ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
Object obj = ois.readObject();
if(obj instanceof Alarm) {
s.beginTransaction();
s.delete(obj... |
13112a9f-2f1b-4c9d-9f36-7140da390730 | 8 | List<Position> getNeighbours() {
List<Position> list = new ArrayList<Position>();
if(this.north != null && this.north.data != '*') {
list.add(this.north);
}
if(this.south != null && this.south.data != '*') {
list.add(this.south);
}
if(this.east != null && this.east.data != '*') {
list.add(this.e... |
c4b0113b-66b4-4e4f-99bf-aed129492b36 | 3 | @Override
public boolean equals(Object other) {
if (other == null || !(other instanceof Word))
return false;
else {
Word otherWord = (Word) other;
return Arrays.equals(stresses, otherWord.stresses) &&
Arrays.equals(units, otherWord.units);
}
} |
6063f160-a886-41be-9754-a7cb7477fcc2 | 2 | public void playSound(String path){
try {
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File(path).getAbsoluteFile());
if (path == "TurretPurchase.wav"){
Clip clip = AudioSystem.getClip();
clip.open(audioInputStream);
clip.start();
}
else... |
28e2b2a8-2a2e-472c-a55d-29d1822bccd2 | 7 | public void setPheromoneLevel(int pheromone)
{
amtPheromone = pheromone;
pheromoneLabel.setText("Ph: " + pheromone);
if (pheromone >= 1000)
setBackground(PHEROMONE_1000);
else if (pheromone >= 800)
setBackground(PHEROMONE_800);
else if (pheromone >= 600)
setBackground(PHEROMONE_600);
else if (p... |
83ad725c-853d-41c3-b7b3-5e116a6d67e4 | 0 | public String getType()
{
return "mealy";
} |
e3fa685e-7896-4a8a-b802-2fddcb62b782 | 2 | private SensorSingleData process(List<Double> measurementValues) {
if (isInitialised) {
List<Double> correctedValues = new ArrayList<Double>();
for (int i = 0; i < measurementValues.size(); i++) {
// compute the Kalman gain
double kalmanGain = predictedVariances.get(i) / (predictedVariances.get(i) + noi... |
ffed8061-2c8b-4904-80d6-272ea3421c04 | 7 | public final void actionPerformed(ActionEvent e) {
JTextComponent textComponent = getTextComponent(e);
if (textComponent instanceof RTextArea) {
RTextArea textArea = (RTextArea)textComponent;
//System.err.println("Recordable action: " + getMacroID());
if (RTextArea.isRecordingMacro() && isRecordable()) {
... |
59eb8338-5530-4c82-9a22-bce5cf34ca2b | 1 | @Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((loc == null) ? 0 : loc.hashCode());
return result;
} |
04b0a332-7833-4097-886b-b92efe686881 | 7 | public void buildAssociations(Instances instances) throws Exception {
Frame valuesFrame = null; /* Frame to display the current values. */
/* Initialization of the search. */
if (m_parts == null) {
m_instances = new Instances(instances);
} else {
m_instances = new IndividualInstances(new I... |
3e0b291d-ac8f-4ae1-aff2-23c198754df7 | 4 | public boolean isObstacle(Coordinate coord) {
if (getCell(coord).getElementType() == ElementType.WATER
|| getCell(coord).getElementType() == ElementType.LEAFWATER
|| getCell(coord).getElementType() == ElementType.TRUNK
|| getCell(coord).getElementType() == ElementType.WALL)
return true;
else
retur... |
77ee4cad-9af1-495b-b456-18f6130987fb | 7 | static final int method2960(boolean bool, int i) {
if (i >= -16)
aFloatArray6865 = null;
anInt6870++;
int i_0_ = ByteBuffer.anInt7207;
while_128_:
do {
do {
if ((i_0_ ^ 0xffffffff) != -1) {
if (i_0_ != 1) {
if (i_0_ == 2)
break;
break while_128_;
}
} else {
if (bool)... |
45983399-0843-4409-9f7a-60f9c56a4ef5 | 7 | public ArrayList<ArrayList<String>> partition(String s) {
int length = s.length();
//initial a indicator:
boolean[][] indicator = new boolean[length][];
for(int i = 0; i < length; ++i){
indicator[i] = new boolean[length];
for(int j = 0; j < length; ++j){
indicator[i][j] = false;
}
}
for(int... |
6a24c1a2-fcb5-49a1-b926-f77aeed4a0a5 | 4 | public static boolean canAfford(CostType cost) {
if(wood >= cost.wood && stone >= cost.stone && gold >= cost.gold && food >= cost.food) {
return true;
}
return false;
} |
e3d6f8e7-de7d-4379-9759-2ddbc8968130 | 9 | public void submit(Integer partId) {
System.out.println(String.format("==\n== [nlp] Submitting Solutions" +
" | Programming Exercise %s\n==", homework_id()));
partId = promptPart();
List<String> partNames = validParts();
if(!isValidPartId(partId)) {
System.err.println("!! Invalid ... |
210b25a9-81fc-4c2b-8a75-1e92d5d7eb33 | 5 | public void saveAnimation() {
BufferedReader reader;
try {
reader = new BufferedReader(new FileReader(System.getProperty("resources") + "/database/sprites"));
String line;
StringBuilder fileContent = new StringBuilder();
String newLine = null;
while((line = reader.readLine()) != null) {
String[]... |
ac009340-4653-48ec-a457-84112f31e10e | 5 | public static void main(String[] args) {
if(args.length == 0){
System.out.println("Specification and assembly filenames not given.");
System.exit(0);
}
else if(args.length == 1){
System.out.println("Assembly file not given.");
System.out.println("Specification file: " + args[0]);
Syste... |
83c9b8c6-95b2-43e9-8005-98a4c921e8fe | 5 | private void updateJson() {
//Worlds
List<DynmapWorld> dynmapWorlds = new ArrayList<>();
List<Component> components = new ArrayList<>();
ArrayList<String> addedComponents = new ArrayList<>();
config.setConfighash(0);
String temp = gson.toJson(config);
for (Dynm... |
3b2f1528-4061-4d65-8c7c-3dde6ea2e95c | 0 | public AdaptedRandomDoubles(int count) {
this.count = count;
} |
3ab39786-e532-45a0-99d5-e398e917ef54 | 0 | public BladesSword(){
this.name = Constants.BLADES_SWORD;
this.attackScore = 11;
this.attackSpeed = 10;
this.money = 300;
} |
32e08750-fa86-459a-a971-fc1eb5a5c9a9 | 9 | static protected void FillBuff() throws java.io.IOException
{
if (maxNextCharInd == available)
{
if (available == bufsize)
{
if (tokenBegin > 2048)
{
bufpos = maxNextCharInd = 0;
available = tokenBegin;
}
else if (tokenBegin < 0)
bufpos... |
df03bf63-314f-4270-85a1-8d0278afff9e | 9 | public static int cal(int i, int j, int cur) {
if (min[i][j] != 0)
return min[i][j];
int up, down, left, right;
up = down = left = right = 0;
if (i - 1 >= 0 && m[i][j] < m[i - 1][j])
up = cal(i - 1, j, cur + 1);
if (j - 1 >= 0 && m[i][j] < m[i][j - 1])
left = cal(i, j - 1, cur + 1);
if (i + 1 < row... |
d44364a0-aba5-4515-bb5e-fd0cfb11a1f6 | 9 | private boolean isValid(String head) {
if( head.length() > 3 ) return false;
int n = Integer.valueOf( head );
int length = head.length();
if( n >= 100 && n <= 255 ) return true;
if( n >= 10 && n < 100 && length == 2 ) return true;
if( n >= 0 && n <= 9 && length == 1 ) ... |
e5f28240-4dca-4658-a746-f704f5a4fe9a | 1 | @Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((sourceName == null) ? 0 : sourceName.hashCode());
return result;
} |
5e41d0e9-4365-40cc-bd98-b84ee3daeae9 | 0 | public UpgradeType getType() {
return type;
} |
fd6c596f-d7e2-424f-b922-2c1c9ea65e33 | 8 | @Override
public double evaluate(int[][] board) {
int max = 0;
int diffCnt = 0;
for (int i = 0; i < board.length; i++) {
for (int j = 0; j < board[0].length; j++) {
max = Math.max(max, board[i][j]);
if (cnt[board[i][j]] == 0) {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.