method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
b241835e-ca6e-45dc-8cc7-7d2c6ffa3cb7 | 1 | @Test
public void filtersByYearWorks() {
citations.add(c1);
filter.addFieldFilter("year", "1999");
List<Citation> filtered = filter.getFilteredList();
assertTrue(filtered.contains(c1) && filtered.size() == 1);
} |
2ba7b26e-7bf7-4c92-88bf-b40f68c767d9 | 9 | public void paint(Graphics g)
{
super.paint(g);
Graphics2D g2 = (Graphics2D) g;
for(int i = 0; i < to_draw.snow_model.length; i++)
{
for(int j = 0; j < to_draw.snow_model[i].length; j++)
{
g2.setColor(Color.white);
if(i == to_draw.obstacle_x && j == to_draw.obstacle_y) g2.setColor(Color.red);
... |
1eb89871-8a94-4016-99d4-fb5ff092610a | 9 | private void fill() throws IOException
{
if (eof)
return;
// as long as we are not just starting up
if (count > 0)
{
// if the caller left the requisite amount spare in the buffer
if (count - pos == 2) {
// copy it back to the start of the buffer
System.arraycopy(buf... |
07c3496e-85f8-413d-a5a1-8269bf95538b | 3 | * @param back Specifies if the cells should be moved to back.
*/
public void cellsOrdered(Object[] cells, boolean back)
{
if (cells != null)
{
model.beginUpdate();
try
{
for (int i = 0; i < cells.length; i++)
{
Object parent = model.getParent(cells[i]);
if (back)
{
model.a... |
b0d61596-e11a-45d7-84a6-86ec00f7dbf0 | 9 | double[] lineMinimize(DiffFunction function, double[] initial, double[] direction) {
// make a 1-dim function along the direction line
// THIS IS A HACK (but it's the NRiC peoples' hack)
OneDimDiffFunction oneDim = new OneDimDiffFunction(function, initial, direction);
// do a 1-dim line min on this func... |
91cac82f-f1da-4291-bd34-0a2b272ebeca | 1 | static double[] spawnTimeSeriesForFFT(String ticker) {
TreeMap<Float, float[]> allTickerHistoricData = TECHNICAL_PRICE_DATA
.get(ticker);
double[] priceData = new double[allTickerHistoricData.size()];
int i = 0;
for (float[] data : allTickerHistoricData.values()) {
priceData[i++] = data[6];
}
return ... |
e52997b4-7f70-4e82-b6c5-5005bc095f93 | 4 | public void tuloksenLisays(int tulos){
int apumuuttuja=tulos;
int apumuuttuja2;
for (int i = 0; i < 10; i++) {
if (apumuuttuja>lukutaulu[i]){
apumuuttuja2=lukutaulu[i];
lukutaulu[i]=apumuuttuja;
tulokset[i]=""+apumuuttuja;
... |
1b673b00-0b71-46e8-b0d9-6c7e90fbfa79 | 8 | public int axics() {
int ret = 0;
System.out.println(this);
if (minY == maxY) {
if (minX < maxX) {
ret = Axcis.POSITIVEX.getAxcisCode();
} else if (minX == maxX) {
if (minX == 0)
ret = Axcis.NEGITIVEY.getAxcisCode();
if (minY == 0)
ret = Axcis.POSITIVEX.getAxcisCode();
if (minX == ... |
bbba5db1-ba6f-48d5-8613-62ec953b392d | 5 | public void filterStatus(int index) {
switch (index) {
case 0:
filterCheck(statusFilter1);
break;
case 1:
filterCheck(statusFilter2);
break;
case 2:
filterCheck(statusFilter3);
bre... |
4e12f31c-1217-4770-8cda-95781cbf2fc6 | 3 | public boolean contains(int x) {
boolean val = false;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (this.board[i][j] == x)
return true;
}
}
return val;
} |
c9d39b1d-c87a-4569-bf77-a53b7490c387 | 7 | public void run() {
byte buffer[] = new byte[1024];
try {
InputStream is = from_socket.getInputStream();
OutputStream os = to_socket.getOutputStream();
do {
int length = is.read(buffer);
if (length == -1) {
String type = name.equals("Send") ? "Client" : "Server";
System.out.println(String... |
d61f2c11-e841-47a7-bff3-9eb1e8137cbd | 8 | public StringBuffer print(int indent, StringBuffer output) {
if (currentPackage != null) {
printIndent(indent, output).append("package "); //$NON-NLS-1$
currentPackage.print(0, output, false).append(";\n"); //$NON-NLS-1$
}
if (imports != null)
for (int i = 0; i < imports.length; i++) {
if (imports[i... |
285eda9b-3c35-4143-8855-50f364f26510 | 0 | public static IntArrayBag union(IntArrayBag b1, IntArrayBag b2)
{
IntArrayBag answer = new IntArrayBag(b1.getCapacity( ) + b2.getCapacity( ));
System.arraycopy(b1.data, 0, answer.data, 0, b1.manyItems);
System.arraycopy(b2.data, 0, answer.data, b1.manyItems, b2.manyItems);
answer.ma... |
7b437b17-e0e9-46da-894f-19d371c1c681 | 2 | private static void test_getShort(TestCase t) {
// Print the name of the function to the log
pw.printf("\nTesting %s:\n", t.name);
// Run each test for this test case
int score = 0;
for (int i = 0; i < t.tests.length; i += 3) {
int exp = (Integer) t.tests[i];
int arg1 = (Integer) t.tests[i + 1];
in... |
7e13c32b-e280-4ad7-8960-a930590706a9 | 2 | public final synchronized int readInt(){
this.inputType = true;
String word="";
int ii=0;
if(!this.testFullLineT) this.enterLine();
word = nextWord();
if(!eof)ii = Integer.parseInt(word.trim());
return ii;
... |
96a26ef7-389f-49e8-b232-959b845356b9 | 9 | @Override
public void visit(Page page) {
if (page.getParseData() instanceof HtmlParseData) {
HtmlParseData htmlParseData = (HtmlParseData) page.getParseData();
try {
System.out.println(page.getWebURL().getURL());
... |
1e7241d0-d735-4170-a7a8-9246c61c958e | 9 | private void loadState(int state) {
if(state == INTRO_STATE)
gameState = new IntroState(this);
else if(state == SINGLE_PLAYER_STATE)
gameState = new SinglePlayerGame(this);
else if(state == OPTION_STATE)
gameState = new O... |
478c1a8c-97ed-44c9-a3fe-5195bda380fa | 7 | @Override
public void restoreLimb(String gone)
{
if (affected != null)
{
if (affected instanceof MOB)
{
((MOB)affected).location().show(((MOB)affected), null, CMMsg.MSG_OK_VISUAL, L("^G<S-YOUPOSS> @x1 is now mended.^?",gone));
}
else
if ((affected instanceof DeadBody)
&& (((Item)affected).ow... |
d3a04808-cf81-40cc-a8a1-b79c1d587005 | 8 | private void dumpMemory() {
short [] m = chip8.getCpu().getMemory().getEntireMemory();
String s = "00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\n";
for (int i = 0; i < 4096; i++) {
if (i % 15 == 0 || i == 0) {
String val = i == 0 ? "00 " : "";
val = (i != 0 && i < 10) ? "0" + i + " " : "";
s +=... |
49f2510e-1a1e-4e1b-bcee-45e8b5ac0d44 | 0 | public int run(){
sort(array);
return 0;
} |
d1aabae2-abf2-45e9-b21f-43b54d24175e | 9 | private boolean isStandardProperty(Class clazz) {
return clazz.isPrimitive() ||
clazz.isAssignableFrom(Byte.class) ||
clazz.isAssignableFrom(Short.class) ||
clazz.isAssignableFrom(Integer.class) ||
clazz.isAssignableFrom(Long.class) ||
clazz.isAssignab... |
decd79a5-a531-4c29-93d8-4d00aa72ee4b | 5 | @Override
public O process(I input) throws Exception {
Object i = input;
for(Processor p : processors){
p.setContext(context);
context.getProgressReporter().reportProgress(p.getClass().getSimpleName() + " process: ", 0);
long t0 = System.currentTimeMillis();
... |
0f42bd5a-fb7a-4886-888e-5b517f9abb68 | 2 | private void acao127(Token token) throws SemanticError {
try {
Identificador id = tabela.get(token.getLexeme(), nivelAtual);
if (!(id instanceof IdentificadorConstante))
throw new SemanticError(
"Esperava-se um identificador de constante",
token.getPosition());
tipoConstante = ((Identificado... |
cbf92a56-801c-4e4f-9f35-2ac1c74ad760 | 8 | static double test(double[] w) {
int success = 0;
int trials = 0;
for (int example = 5000; example < (int) I.size(); example++) {
// valitetaan vain + ja - -luokista.
if (I.elementAt(example).characterClass != targetChar
&& I.elementAt(example).chara... |
180255c5-2298-45a4-a6c9-483d152d7ef3 | 3 | public static String doPOST(String URLstring, String JSONInput) {
try {
String returnVal = "";
URL url = new URL(URLstring);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application... |
c9af22f2-8bdb-465a-ba19-169f71e445ea | 8 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Auto other = (Auto) obj;
if (this.convertible != other.convertible) {
return false;
}... |
1e426e64-41c0-45be-b96b-4dc44bc74016 | 7 | public static void fourSum(int[] input, int target) {
Arrays.sort(input);
List<String> result = new ArrayList<>();
HashSet<String> hashSet = new HashSet<>();
for( int i=0; i< input.length; i++) {
for( int j = i+1; j< input.length; j++) {
int k = j+1;
... |
37efcd3f-f400-4b7f-a8b5-39b63b0baff7 | 8 | public Object readList(AbstractHessianInput in, int length)
throws IOException
{
if (length >= 0) {
Object []data = createArray(length);
in.addRef(data);
if (_componentType != null) {
for (int i = 0; i < data.length; i++)
data[i] = in.readObject(_componentType);
... |
fcae56d5-71f5-4cff-8d90-ec8ec336d393 | 6 | protected void updateSprite() {
final GroupSprite s = (GroupSprite) buildSprite().baseSprite() ;
final Model m =
(drill == NOT_DRILLING || drill == STATE_RED_ALERT) ?
null : DRILL_MODELS[drill] ;
final ImageSprite old1 = (ImageSprite) s.atIndex(1) ;
if (old1 != null && old1.model() == m... |
e4b3a5d1-cce8-4d92-99e5-2114d053843a | 5 | public void keyPressed(KeyEvent ke)
{
if(ke.getKeyCode() == KeyEvent.VK_D)
{
dp.moveCenter(GlobalSettings.EAST);
}
else if(ke.getKeyCode() == KeyEvent.VK_A)
{
dp.moveCenter(GlobalSettings.WEST);
}
else if(ke.getKeyCode() == KeyEvent.VK_W)
{
dp.moveCenter(GlobalSettings.NORTH);
}
else if(ke... |
f28faa14-8af4-4b7c-a87b-239b2ee899fb | 7 | public static String generateIdentity(java.io.File documentFile) {
StringBuffer result = new StringBuffer();
FileInputStream in = null;
{
DigestInputStream md5 = null;
try {
in = new FileInputStream(documentFile);
md5 = new DigestInputStrea... |
17856e95-580d-40e4-b255-8c5de590ff03 | 3 | @SuppressWarnings("unchecked")
private static final byte[] encodeList(ArrayList list) throws BencodingException
{
byte[][] list_segments = new byte[list.size()][];
for(int i = 0; i < list_segments.length;i++)
{
list_segments[i] = encode(list.get(i));
}
int total_... |
fe277da6-062f-4a14-9de3-d485c7c49c49 | 4 | public void render(final Graphics g) {
Map.getInstance().render(g);
for (GenericMinion gm : mobs)
gm.render(g);
for (Tower t : towers) {
t.render(g);
}
for (Shot s : shots) {
if (s.isAlive())
s.render(g);
}
drawMenu(g);
} |
56c088bc-4438-454b-a37f-2a7dc93ff246 | 0 | @Override
public void start(final Stage primaryStage) throws MalformedURLException {
contacts = this;
stage = primaryStage;
primaryStage.setTitle(AppSettings.getStringValue("app.title.text"));
primaryStage.initStyle(StageStyle.TRANSPARENT);
root = new StackPane();
root.getStyleClass().add("root-stack");... |
ccdb007a-298d-4b85-9fe2-90d071816220 | 4 | @Override
public void run(){
try {
sequencer.open();
} catch (MidiUnavailableException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
sequencer.start();
while(true) {
if(sequencer.isRunning()) {
run=true;
sequencer.start();... |
ded8fbb1-d5fb-40e2-871d-d379f52a121b | 2 | private String readInputStream() {
while (true) {
if (inStream.hasNext()) {
String line = inStream.nextLine();
return line;
} else {
continue;
}
}
} |
27638c73-e783-4c9e-997c-51aa2bceb133 | 9 | public static String[] tidy(Object[] arr) {
String[] distinct = new String[ getAmountUniqueItems(arr) ];
int index = 0;
for(int i=0; i<arr.length; i++) {
boolean isDistinct = true;
for(int j=0; j<i; j++){
if( arr[i] != null && arr[j] != null ... |
d02ee684-aa04-497a-82a2-3c036c2ec6a3 | 1 | private ReportingAPI getReportingApi() {
if (reportingApi == null)
reportingApi = new ReportingAPI(config);
return reportingApi;
} |
262b39ca-41a1-447f-9395-1c99b63f048a | 5 | public static synchronized SolidNode from( Object thing, SourceLocation sLoc ) throws ScriptError {
if( thing instanceof SolidNode ) return (SolidNode)thing;
SolidNode n = nodesFromOtherThings.get(thing);
if( n != null ) return n;
if( thing instanceof SurfaceMaterial ) {
thing = StandardMaterial.opaque( (Sur... |
435362b3-7672-4c7f-9d12-8510857fa4e5 | 5 | public static JSONObject httpRequest(String requestUrl,
String requestMethod, String outputStr) {
JSONObject jsonObject = null;
StringBuffer buffer = new StringBuffer();
try {
// SSLContextʹָιʼ
TrustManager[] tm = { new MyX509TrustManager() };
SSLContext sslContext = SSLContext.getInstance("SSL", "S... |
e28745a9-00f5-4b27-9d08-b622bff29678 | 1 | public boolean removeExportFormat(String formatName) {
int index = indexOfName(formatName, exporterNames);
if (index >= 0) {
exporterNames.remove(index);
exporters.remove(index);
// Also remove it from the list of formats stored in the preferences
Preferences.FILE_FORMATS_EXPORT.remove(index);
... |
da80cc9b-ec35-4793-988b-b1af7de22798 | 6 | @EventHandler
public void WolfHunger(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.getWolfConfig().getDouble("Wolf.Hunger.DodgeCh... |
6a128528-dac3-48b9-a129-47d1e1981531 | 8 | @Override
public void doPost(final HttpServletRequest request, final HttpServletResponse response) throws IOException,
ServletException {
log.info("決済結果確認開始");
request.setCharacterEncoding(Constants.AW_ENCODE);
// リクエストの一覧をログ出力
if (log.isInfoEnabled()) {
Enu... |
8a1a015d-2e05-4cd5-8c3a-f283980023a9 | 2 | private void expurgateCheckedList(Collection<String> c, String strAuthor) {
for (Iterator<String> i = c.iterator(); i.hasNext();) {
if (i.next().contains(strAuthor)) {
i.remove();
}
}
} |
509d88b0-e4a0-459b-a0d6-2431f4cccbc0 | 8 | static final void method1642(byte i, AbstractToolkit var_ha) {
anInt2997++;
int i_3_ = 0;
int i_4_ = 0;
if (Class59_Sub1.aBoolean5300) {
i_3_ = s_Sub3.method4008((byte) -124);
i_4_ = Class16.method260(false);
}
int i_5_ = -10660793;
Class318_Sub7.method2509(Class63.anInt1117,
Class348_Sub42_Sub5.a... |
946e26f0-965e-47ad-9322-033c3047dbb2 | 9 | public static void load() {
ColorKeys.Log(Level.INFO, "Loading Debuggers...");
if (!DebugFile.exists())
ColorKeys.Log("No Debuggers to load.");
else {
Debuggers = new HashMap<String, Boolean>();
DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = null; tr... |
5bad545c-b51e-44a8-bf62-7eb66d07cd5a | 0 | public int getTotalNum() {
return totalNum;
} |
76a863a1-d72a-4116-94e7-35abca764d6c | 8 | @Override
public boolean evaluate() throws ScriptRuntimeException {
Object leftObject = left.evaluate();
Object rightObject = right.evaluate();
if (leftObject instanceof Integer && rightObject instanceof Integer) {
int leftValue = ((Integer) leftObject).intValue();
... |
e1c1d2c7-4ae6-4972-bc7d-3b3063513523 | 5 | public E get(int index) throws IndexOutOfBoundsException
{
if(index >= size || index < 0)
throw new IndexOutOfBoundsException();
int count;
Node temp;
//Occurs if index is towards the end of the list
if(index > size/2){
count = size;
temp = tail;
while(--count >= index)
temp = temp.prev;
r... |
58ffc970-d505-4343-add2-44357e75e638 | 0 | public static void main(String[] args) {
w = new Worker();
} |
b54dddd6-8907-4321-95fd-0ee51280f866 | 8 | @RequestMapping(method = RequestMethod.POST)
public String submitForm(HttpServletRequest request,
HttpServletResponse response,
@ModelAttribute("reservation") PeriodicReservation reservation,
BindingResult result, SessionStatus status,
@RequestParam("_page") int currentPage, Model model) {
Map pageForms ... |
ade69eb6-3928-4259-9d83-dd373c84f48e | 5 | public void DoSubmit() {
String error_message = "An error has occured please try again";
try {
String filename = "driver.jpg";
// display.setCurrent(wait, disp);
String METHOD_NAME = "set_entry";
String SOAP_ACTION = SOAP_URL + ME... |
6189ace1-2d30-47ea-ae43-77c9b3a6bbba | 8 | public void compExecTime() {
double newExeTime;
double newCost;
dEval = 0;
dTime = 0;
dCost = 0;
for (int i = 0; i < iClass; i++) {
newExeTime = 0;
// System.out.print("Cost[" + i + "]");
for (int j = 0; j < iSite; j++) {
if (dmAlloc[i][j] != -1) {
if (dmAlloc[i][j] < 1) {
newExeTime... |
f1c353ac-b7f1-47cc-a482-bbd70dbc415b | 3 | public void whitespaceChars(int low, int hi) {
if (low < 0)
low = 0;
if (hi >= ctype.length)
hi = ctype.length - 1;
while (low <= hi)
ctype[low++] = CT_WHITESPACE;
} |
241cbd01-914e-445c-9c2a-a63622948ebc | 4 | public boolean isOnButton(int wX, int wY, int mouseX, int mouseY){
mouseY = Standards.W_HEIGHT - mouseY - 1;
if ((mouseX > wX + x) && (mouseX < wX + x + width)){
if ((mouseY > wY + y) && (mouseY < wY + y + height)){
return true;
}
}
return false;
} |
96d2e18a-b6e4-4c15-ad13-194cb0b4b357 | 7 | public void updateGear(int numUpdates) {
if (Float.isNaN(credits)) credits = 0 ;
if (Float.isNaN(taxed)) taxed = 0 ;
if (verbose) I.sayAbout(actor, "Updating gear...") ;
if (outfit != null) regenerateShields() ;
else currentShields = 0 ;
for (Item item : allItems()) {
if (item.refers ... |
6d4751e9-3074-476d-af1d-0d2560549bbc | 2 | public static boolean isTerminalInProductions(Grammar grammar,
String terminal) {
ProductionChecker pc = new ProductionChecker();
Production[] productions = grammar.getProductions();
for (int k = 0; k < productions.length; k++) {
if (ProductionChecker.isTerminalInProduction(terminal,
productions[k])) {... |
7b1a96f7-da98-4324-be8b-1e9c95518d3c | 9 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
final MOB target=getTarget(mob,commands,givenTarget);
if(target==null)
return false;
if((target.getWearPositions(Wearable.WORN_HANDS)==0)
&&(target.getWearPositions(Wearable.WORN_FEET)==0))
... |
b37b5c16-1c28-4951-90e0-3cade059bf4b | 7 | String printResultTable() {
String retVal = "";
size = comparisonResult.numberGenesOnBorderIntervalAllSide.size();
if (!comparisonResult.numberGenesOnBorderIntervalAllSide.isEmpty())
{
for (String gene : comparisonResult.numberGenesOnBorderIntervalAllSide.keySet())
... |
96dfcfeb-ebb6-41ff-8a4b-ba0c3f2a7067 | 1 | public static void tokenize(String line, ArrayList<String> tokens) {
StringTokenizer strTok = new StringTokenizer(line);
while (strTok.hasMoreTokens()) {
String token = strTok.nextToken();
tokens.add(token);
}
} |
6f19c3dd-a908-4448-abc8-c7ed9080d364 | 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... |
5332935a-fb9b-428e-b153-b71a55980ec2 | 8 | static public double igamc(double a, double x) throws ArithmeticException {
double big = 4.503599627370496e15;
double biginv = 2.22044604925031308085e-16;
double ans, ax, c, yc, r, t, y, z;
double pk, pkm1, pkm2, qk, qkm1, qkm2;
if (x <= 0 || a <= 0)
return 1.0;
if (x < 1.0 || x < a)
return 1.0 - ig... |
4b783974-5298-4824-b56c-bb56986f6325 | 5 | public boolean jogoFinalizado() throws JogoNaoIniciadoException,
PosicaoDeCartaInvalidaException {
if (jogoAnteriorFinalizado)
return jogoAnteriorFinalizado;
if (!jogoIniciado())
throw new JogoNaoIniciadoException("Jogo não foi iniciado!");
for (int i = 0; i < 4; i++)
for (int j = 0; j < 2; j++)
i... |
a07bc86f-b44e-4a0b-9d40-a4693275025d | 8 | public Wave29(){
super();
MobBuilder m = super.mobBuilder;
for(int i = 0; i < 1050; i++){
if(i % 13 == 0)
add(m.buildMob(MobID.PARASECT));
else if(i % 11 == 0)
add(m.buildMob(MobID.LICKITUNG));
else if(i % 6 == 0)
add(m.buildMob(MobID.TENTACOOL));
else if(i % 5 == 0)
add(m.buildMob(Mob... |
f96a176c-7315-4cf4-99cd-fa64604e59f3 | 1 | public void addRole(Roleschool role) {
if(roles == null){
roles = new ArrayList<>();
}
roles.add(role);
} |
a129e9ec-02a1-409d-9ddf-00fb22e1d9ae | 9 | public void actionPerformed(ActionEvent event)
{
if(event.getActionCommand().equals("Add"))
{
String name = userField.getText().trim();
if (name.equals("") || name.equals("Enter User Name"))
JOptionPane.showMessageDialog(null, "Invalid User Name");
else
{
String key = randomKeyGenerator();
... |
5c1305f5-3847-4008-9cf8-b12a3613d5a1 | 8 | public void SetColors(String hbgcolor,
String hfgcolor,
String abgcolor,
String afgcolor,
String dbgcolor,
... |
7fc02749-0ec8-4a47-8265-fc9db35e0bd1 | 2 | public IPLocation getLocationByIp(String ip) {
IPLocation ipLoc = null;
if(ipCache.containsKey(ip)){
ipLoc = ipCache.get(ip);
}
if (ipLoc == null) {
ipLoc = getIPLocation(Util.getIpByteArrayFromString(ip));
ipCache.put(ip, ipLoc.getCopy());
}
return ipLoc;
} |
6973c3e5-f3fc-4de6-92a3-16baf2a894ea | 8 | public void resetRelation()
{
if(startBtn.getX()+startBtn.getWidth() < endBtn.getX())
{
double separation = (endBtn.getX()-(startBtn.getX()+startBtn.getWidth()))*App.currentDistance/20;
relDialog.relDesc.min = 0.0;
relDialog.relDesc.max = separation;
relDialog.relDesc.rel = RelationType.BEFORE;
r... |
b671e410-ca30-4e94-8a7c-d12babdcfd79 | 3 | private static FastByIDMap<Movie> loadMovieMap(String file) {
InputStream fis = null;
BufferedReader br;
String line;
FastByIDMap<Movie> movieMap = new FastByIDMap<Movie>();
try {
fis = new FileInputStream(file);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTr... |
99edd7eb-cc8b-43c0-89b1-eb2d91205004 | 4 | private Order getOrderWithId(int orderId) {
for (Order order : acceptedOrders) {
if (order.getOrderId() == orderId)
return order;
}
for (Order order : newOrders) {
if (order.getOrderId() == orderId)
return order;
}
// Es wurde keine Order in dem OrderPool gefunden, die mit der OrderId
// vom ... |
70fb4e5f-efa2-44f5-a11b-7a447d2ff1be | 2 | private static void secondStrategy()
{
Semaphore MReading = new Semaphore(1);
Semaphore MWriting = new Semaphore(1);
Semaphore MPrio = new Semaphore(1);
int counter = 0;
Random r = new Random();
while(true)
{
if(r.nextDouble() > 0.5)
new Lecteur(MReading,MWriting, counter).run();
else
n... |
a1c97bdf-16e0-4277-9d7d-78ffae24ff3f | 9 | public String getString(StringBuilder sb) {
if (sb.length() == 0) return "";
if (sb.length() < 32) {
int index = getCacheIndex(sb);
if (index < 0) {
return sb.toString();
}
if (stringCache == null) stringCache = new String[CACHE_SIZE];
if (numberCache == null) numberCache = new BigDecimal[... |
983d4ca3-decc-43cf-ab80-f245617230fa | 1 | @SuppressWarnings("unchecked")
@Override
public void validate(ProcessingEnvironment procEnv,
RoundEnvironment roundEnv, TypeElement annotationType,
AnnotationMirror annotation, ExecutableElement e) {
AnnotationValue expectedReturnType = AnnotationProcessingUtils
.getAnnotationElementValue(procEnv, annotat... |
d7c45f4b-d5a6-4c24-8516-9321311fc119 | 7 | private KrakenMove getMaxValue(double maxValue, KrakenMove[] moves,
double[] values,KrakenState state) {
for (int i = 0; i < values.length; i++) {
if (values[i]==maxValue){
KrakenItem item = state.getValue(moves[i].getInitialPlace());
if (item instanceof Pawn) values[i]+= Math.random() * 5 + 1;
if (... |
685bacf4-e47e-4113-af34-935187289beb | 6 | public static void main(String[] args) {
// new file that we are getting data from
Scanner inFile = null;
try {
// Create a scanner to read the file, file name is parameter
inFile = new Scanner(new File(System.getProperty("user.dir") + "/src/Files/prog465h.dat"));
} catch (FileNotFoundException e) {
Sy... |
81596ee6-7e17-4913-a2de-19b8f3796a79 | 6 | private int partition(Comparable[] tempArray, int lower, int upper){
int i = lower, j = upper+1;
Comparable v = tempArray[lower];
while(true)
{
while (less(tempArray[++i],v)) if(i == upper) break;
while (less(v,tempArray[--j])) if (j == lower) break;
if (i >= j) break;
exch(tempArray,i,j);
}
exc... |
8fe88755-f9d2-4ac0-93c9-6e6ae5a51803 | 3 | public String getCalendars(String username) {
try {
pstmt = doQuery("SELECT calendar, createdBy FROM calendars WHERE active = true AND (isPublic = true OR calendar IN (SELECT calendar FROM usercalendars WHERE username = ?))");
pstmt.setString(1, username);
rs = pstmt.executeQuery();
while(rs.next()) {
... |
28f5073e-7961-40e8-b586-8becdd19dbf9 | 1 | public int getDimensions() {
int i = 1;
while (buf[off + i] == '[') {
++i;
}
return i;
} |
24eab82d-c247-4f87-b53f-6a14cf76f957 | 6 | private void teeTaso() {
int i = 1;
for (String string : rivit) {
i++;
char etumerkki = string.toUpperCase().charAt(0);
if (etumerkki == 'E') {
esteRivi(string, EsteenTyyppi.ESTE);
} else if (etumerkki == 'P') {
pelaajaRivi(... |
4696daf7-fd0f-452d-aad7-7911cfd73607 | 2 | public static void writeMemory(String path) {
try (FileOutputStream fileOut = new FileOutputStream(("".equals(path) ? "pitmanager" : path));
ObjectOutputStream out = new ObjectOutputStream(fileOut)) {
out.writeObject(Competition.getInstance());
out.close();
fi... |
17b89e31-0e96-4131-8ce1-55dd45309e80 | 1 | @Test
public void dot_test() {
try{
double []mat1= {1.0,2.0,3.0,1.0};
double []mat2= {1.0,2.0,3.0,1.0};
double result = Vector.dot(mat2, mat1);
double exp=15.0;
Assert.assertEquals(exp, result, 0);
}
catch (Exception e) {
// TODO Auto-generated catch block
fail("Not yet implemented");
}
} |
9ef9755a-c62a-467d-9d17-9fc139295ebf | 2 | public RequestWrapper getLastReferRequestWrapper() {
if (null != this.getReferRequestWrappers()
&& this.getReferRequestWrappers().size() > 0) {
return this.getReferRequestWrappers().get(
this.getReferRequestWrappers().size() - 1);
}
return null;
} |
4273312c-92b9-4705-b830-2a788fc38b31 | 9 | public boolean searchMatrix(int[][] matrix, int target) {
if(matrix == null || matrix.length == 0)
return false;
int up = 0;
int down = matrix.length-1;
while(up <= down ){
int mid = (up + down) /2;
if(target > matrix[mid][0])
up = mid... |
d39ed976-c960-44bf-91c2-c09335f3655d | 6 | public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (qName.equals("annonce")) {
if (currentFacture != null) {
throw new IllegalStateException("already processing a voys");
}
currentFacture = new... |
d25804da-d154-4a57-ba8d-704e98dd2f14 | 0 | @Override
public void startSetup(Attributes atts) {
super.startSetup(atts);
setEnabled(false);
addActionListener(this);
Outliner.documents.addDocumentRepositoryListener(this);
} |
87c40aa0-c204-47c9-87a3-35db69b421b2 | 5 | public void run() {
try {
if (isWindowed) {
Display.setDisplayMode(findDisplayMode(sizeX, sizeY, Display.getDisplayMode().getBitsPerPixel()));
} else {
Display.setDisplayModeAndFullscreen(findDisplayMode(sizeX, sizeY, Display.getDisplayMode().getBitsPerPix... |
c1ae293c-5239-4ccf-b818-eb46ab19062c | 8 | public static long buff2long(byte[] bs, int offset) {
return (((long) (bs[offset] >= 0 ? bs[offset] : 256 + bs[offset])) << 56)
| (((long) (bs[offset + 1] >= 0 ? bs[offset + 1] : 256 + bs[offset + 1])) << 48)
| (((long) (bs[offset + 2] >= 0 ? bs[offset + 2] : 256 + bs[offset + 2]... |
44e3b369-e52f-4f51-a68f-27f8b8eab1fb | 9 | public static void main(String args[])
{
System.out.println("Starting finite buffers example ...");
try
{
/************
The network topology is as follows:
1Gbps 1Gbps 1Gbps
Users --------- Router1 ----------... |
005f7181-f7f0-47ef-8eb9-946bf5ad211e | 7 | public List<List<Integer>> levelOrderBottom(TreeNode root) {
List<List<Integer>> res = new LinkedList<List<Integer>>();
if(root == null) return res;
TreeNode END = new TreeNode(0);
Queue<TreeNode> queue = new LinkedList<TreeNode>();
Stack<List<Integer>> stack = new Stack<List<Integer>>();
List<I... |
9992d014-49ee-48f5-9601-102a4c369113 | 5 | public TreeElement[] getChildrens(TreeElement parent) {
TreeElement[] result = (TreeElement[]) cachedChildrens.get(parent);
if (result == null) {
TreeSet v = new TreeSet();
String prefix = parent == root ? "" : parent.getFullName() + ".";
Enumeration enum_ = ClassInfo.getClassesAndPackages(parent
.get... |
0558ef98-10fe-46fc-809c-f76db1545f45 | 2 | public String getCityByPID(Statement statement,String PID)//根据PID获取城市
{
String result = null;
sql = "select city from Park where PID = '" + PID +"'";
try
{
ResultSet rs = statement.executeQuery(sql);
while (rs.next()) {
result = rs.getString("city");
}
}
catch (SQLException e)
{
System... |
dfb224d5-880d-493d-992b-b4126a350045 | 8 | public int check(String host, byte[] key){
int result=NOT_INCLUDED;
if(host==null){
return result;
}
int type=getType(key);
HostKey hk;
synchronized(pool){
for(int i=0; i<pool.size(); i++){
hk=(HostKey)(pool.elementAt(i));
if(hk.isMatched(host) && hk.type==type){
... |
57f5e1f0-803c-4431-8f01-02daf02ef1be | 2 | private void configureMenuItem(JMenuItem item, String resource, ActionListener listener) {
configureAbstractButton(item, resource);
item.addActionListener(listener);
try {
String accel = resources.getString(resource + ".accel");
String metaPrefix = "@";
if (accel.startsWith(metaPrefi... |
5a9ce13c-f049-4597-84fc-1c2d08fc1be7 | 9 | @Override
public int compareTo(Object o) {
if (this == o) return 0;
if (!(o instanceof Rule)) return getClass().getName().compareTo(o.getClass().getName());
Rule r = (Rule) o;
int c = mode.compareTo(r.mode);
if (c != 0) return c;
c = body.size() - r.body.size();
if (c != 0) return c;
Iterator<Literal>... |
6bbd8b4b-938e-4528-9df0-b6cd9176040c | 5 | @Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof TaxonGroup)) {
return false;
}
TaxonGroup other = (TaxonGroup) object;
if ((this.key == null && other.key != nu... |
31f768f3-7649-48ca-ade9-16008dcca2c6 | 7 | public void stateChanged(ChangeEvent ce){
JTabbedPane pane = (JTabbedPane)ce.getSource();
int sel = pane.getSelectedIndex();
switch (sel){
case 0:
//Nothing will really need to be done b/c objs drive the data
case 1:{
repaint(); break;
}
case 2:{
if(pnlAlternatives.... |
7a239e80-8b20-4e31-be71-c2579d141f86 | 6 | private int affineTransformation(int value) {
/*Prepare affineMatrix:
[ 1, 0, 0, 0, 1, 1, 1, 1 ]
[ 1, 1, 0, 0, 0, 1, 1, 1 ]
[ 1, 1, 1, 0, 0, 0, 1, 1 ]
[ 1, 1, 1, 1, 0, 0, 0, 1 ]
[ 1, 1, 1, 1, 1, 0, 0, 0 ]
[ 0, 1, 1, 1, 1, 1, 0, 0 ]
[ 0, 0... |
a1f2daf2-fbbe-4f65-ad4c-0d74c841220f | 0 | public Mouse(Game game) {
this.game = game;
} |
423cd5ce-31e8-4c72-89a6-7eba85f6c8d6 | 5 | private static boolean store(Object data, String name)
{
String nomFichier;
FileOutputStream f = null;
ObjectOutputStream out = null;
if(data == null) return false;
File file = new File("");
String path = "";
try
{
path = file.getCanonica... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.