method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
12a2b947-ae3d-4d56-8c13-6120ea1e1a5d
2
protected void readCases(Document doc, ContextFreePumpingLemma pl) { NodeList caseNodes = doc.getDocumentElement().getElementsByTagName(CASE_NAME); for(int i = 0; i < caseNodes.getLength(); i++) { Node caseNode = caseNodes.item(i); if(caseNode.getNodeType() != Node.EL...
f3322658-8d77-41f0-83b9-9b61bf348a19
2
@SuppressWarnings("deprecation") public void compileShader() { glLinkProgram(program); if(glGetProgram(program, GL_LINK_STATUS) == 0) { System.err.println(glGetProgramInfoLog(program, 1024)); System.exit(1); } glValidateProgram(program); if(glGetProgram(program, GL_VALIDATE_STATUS) == 0) ...
7bf16bd1-7910-48e9-b422-2f66d5cc19a0
4
public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter credit card number without spaces: "); String codeString = sc.nextLine(); System.out.println(); char[] codeChar = codeString.toCharArray(); int[] number = new int[codeChar.length]; for (int i = 0; i <...
4fa057de-c136-4253-89cd-5fff8b897b51
9
private void storeTypeLink(String itemName, String filename, String usedByName, String usedByType) { boolean bFound = false; ItemUsage itemUsage = new ItemUsage(); if (!itemName.toUpperCase().trim().contains("<A HREF=")) //Does the item name contain a hyperlink? { //No - We...
a9be3ac8-3167-46e2-9f03-ad42ed0d4548
4
private boolean checkMove(Move move) { switch (map[move.toY][move.toX]) { case MOUNTAIN: case WATER: return false; default: break; } if (units[move.toY][move.toX] != null) { return false; } if (units[move.fromY][move.fromX] == null) { return false; } return true; }
87d3fe12-4180-40c7-858a-40e8824b26bf
0
public static void main(String[] args) { OJ354 oj354=new OJ354(); //[5,4],[6,4],[6,7],[2,3] //[[1,15],[7,18],[7,6],[7,100],[2,200],[17,30],[17,45],[3,5],[7,8],[3,6],[3,10],[7,20],[17,3],[17,45]] // int[][] test={{1,15},{7,18},{7,6},{7,100},{2,200},{17,30},{17,45},{3,5},{7,8},{3,6},{3,10},...
40bcd32d-8ce8-46f3-ab22-700985f2d744
0
public int getWarmerState() { return this.warmerState; }
f05deaab-f137-4250-817a-b8c21d923dcb
7
int pack_books(Buffer opb){ opb.write(0x05,8); opb.write(_vorbis); // books opb.write(books-1,8); for(int i=0;i<books;i++){ if(book_param[i].pack(opb)!=0){ //goto err_out; return(-1); } } // times opb.write(times-1,6); for(int i=0;i<times;i++){ opb.write(time_ty...
9b93a10d-6481-41db-8658-cff1e3643eea
2
@Override public int compareTo(ChoiceItem other) { if ((cmpValue == 0) && (other.cmpValue == 0)) return item.name.compareTo(other.item.name); return other.cmpValue - cmpValue; }
69a1180c-5eb3-44c4-824e-f901fe46d857
2
public ArrayList<Equipo> buscaEquipo(int clave) { int id_equipo, clave_activo_fijo, num_inv_unam; String clave_descripcion, clave_modelo, clave_marcar, serie, clave_familia, clave_tipo, clave_proveedor, clase, uso, nivel_de_obsolescencia, estado_físico, cl...
6839421d-347f-4c51-906d-ff093d44599b
1
protected byte[] getByteArray(int length) { if (byteBuf.length < length) { byteBuf = new byte[length + 1024]; } return byteBuf; }
bb0a76ae-9684-4c03-9bf9-e2d8a0d60b6f
7
private void calcNavigatePageNumbers() { // 当总页数小于或等于导航页码数时 if (pageRecode <= navigatePages) { navigatePageNumbers = new int[pageRecode]; for (int i = 0; i < pageRecode; i++) { navigatePageNumbers[i] = i + 1; } } else { // 当总页数大于导航页码数时 ...
321f4db8-eba3-4bc6-acdb-340f5ae45144
5
@Override public void run() { if (input == null) //check if we already created the input stream { try { input = new DataInputStream(socket.getInputStream()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } while (true) { try { ...
3c796649-2004-40dd-8f8a-527706969148
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Delta other = (Delta) obj; if (original == null) { if (other.original != ...
8054b5a4-a89d-4208-a59e-b3da6cb16b18
7
private void updateComboBoxes() { int tempindexleft,tempindexright; for(int i=0; i<15;++i) { tempindexleft=CBLeftList.get(i).getSelectedIndex(); // get all selected indexes tempindexright=CBRightList.get(i).getSelectedIndex(); CBLeftList.get(i).removeAllItems(); // delete all entries CBRightLis...
4eec22f7-0938-4c5b-a83a-c986f75895b8
7
public void update(){ getNextPosition(); checkTileMapCollision(); setPosition(xtemp, ytemp); if(flinching){ long elapsed = (System.nanoTime() - flinchTimer) / 1000000; if(elapsed > 400){ flinching = false; } } if(up && dy == 0){ up = false; down = true; } else if((down && dy == 0...
860e8cf6-d240-45ae-b8cb-db888d42638e
1
private int toInt(String s){ int result=0; for(char ch : s.toCharArray()){ result|=(1<<(ch-'a')); } return result; }
85a2e4fe-3aa6-40a0-b3dd-3e5614f8665a
8
public void renderAnimatedTiles(int xPos, int yPos, Tile tile, boolean flip, int tileNr) { xPos -= xOffset; yPos -= yOffset; for (int y = 0; y < tile.sprite.SIZE; y++) { int yp = yPos + y; for (int x = 0; x < tile.sprite.SIZE; x++) { int flipX = (flip) ? tile.sprite.SIZE - x - 1 : x; int xp = xPos + x;...
ac890245-9b4f-46a9-ab0d-d5943ac49a65
5
@Override public void ParseIn(Connection Main, Server Environment) { Environment.InitPacket(451, Main.ClientMessage); Environment.Append(0, Main.ClientMessage); Environment.Append(Integer.toString(6), Main.ClientMessage); Room[] Rooms = new Room[Main.Data.Favorite_Rooms.size()]; ...
72b653eb-1e35-47e7-ba1d-442fadec439d
0
public void stop() { isRunning = false; }
750dcae0-34d0-47e8-adfd-e00c1760faaa
8
void downHeap(int size) { int i = 0; final DisiWrapper node = heap[0]; int j = leftNode(i); if (j < size) { int k = rightNode(j); if (k < size && heap[k].doc < heap[j].doc) { j = k; } if (heap[j].doc < node.doc) { do { heap[i] = heap[j]; i = j;...
4a075761-4004-402a-9054-3b1807f9661b
3
public void EliminaInicio() { if ( VaciaLista()) System.out.println ("No hay elementos"); else { if (PrimerNodo.siguiente==PrimerNodo) PrimerNodo = null; else { PrimerNodo = PrimerNodo.siguiente; NodosProcesos Aux = PrimerNodo; while (Aux.siguiente!=PrimerNodo) Au...
54b0dd7e-49b1-4066-aed7-446843c4ead9
1
public static boolean fileExists() { File file = new File(FILE); if (file.exists()) return true; else return false; }
d84165e2-f06a-4272-914f-e9cfd2ac9b5e
0
public TiltSetDistance(double power, Distance distance) { super(power, distance); }
88f1ed26-b8ad-4a18-aece-5e0475209ef8
2
public Map<Integer, CatalogPage> GrabSecondaryPages(int Parent) { Map<Integer, CatalogPage> Primaries = new HashMap<Integer, CatalogPage>(); for(CatalogPage Page : Pages.values()) { if (Page.Parent == Parent) { Primaries.put(new Integer(Page.ID), Page); } } return Primaries; }
94137d0d-b302-4335-93ad-9cb552226e72
6
public static Node findNode(NodeList list, String tagName, boolean caseSensitive) { for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); if (node instanceof Element) { Element nodeAsElement = (Element) node; if ((caseSensitive && nodeAsElement.getNodeName().equals(tagName)) || (!...
3223c9ab-b7a7-4485-926d-abfcfdb870e2
0
public byte[] getSeed() { return seed; }
9af57cba-ffce-4b5f-bc67-cd2740e30258
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 CleasingCaracterEspecial)) { return false; } CleasingCaracterEspecial other = (CleasingCaracterEspecial) object; ...
21b86545-5e1f-41a2-8acd-813b26e63c7b
4
public static void merge(int[] arr, int left, int mid, int right){ //分成左右两个数组,左边是left,left+1,...mid //右边是mid+1,mid+2,...,right int lsize = mid - left + 1; int rsize = right - mid; int[] L = new int[lsize + 1]; //加上最后一个哨兵(最大值) int[] R = new int[rsize + 1]; for(int i=0; i<lsize; i++){ L[i] = arr[left ...
d6e42051-a59b-4b8d-99c3-8dfea1b3c9d4
5
public void levelUpdate(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException{ Mouse.setGrabbed(false); //sets if player 1 is Doge if(Keyboard.isKeyDown(Keyboard.KEY_D)){ Map.dogepossible=true; Map.dogepossible=true; Map.secondinit(); Map.secondinit(); if(wow...
b87ec5c6-eeb4-41b5-a2dd-c3b2487e1628
3
public static boolean addNewConnection(InetSocketAddress sockaddr) { if(!isInit) { init(); } for(InetSocketAddress iSockAddr : clientRecent) { if(iSockAddr.equals(sockaddr)) { return false; } } RecentConnections.clientRecent.add(sockaddr); return true; }
d435e12d-65f3-4cc3-9d5f-b8ffcd0329aa
1
public void checkConsistent() { if (!(outer instanceof SwitchBlock)) throw new alterrs.jode.AssertError("Inconsistency"); super.checkConsistent(); }
3e731c22-79e1-4b7b-8bf3-c9e88c27c37e
1
public void testWithFieldAdded_unknownField() { MonthDay test = new MonthDay(9, 6); try { test.withFieldAdded(DurationFieldType.hours(), 6); fail(); } catch (IllegalArgumentException ex) {} }
d8f1c333-2028-4fa0-8b30-e78219b143e5
3
public VariableSet intersect(VariableSet vs) { VariableSet intersection = new VariableSet(); intersection.grow(Math.min(count, vs.count)); big_loop: for (int i = 0; i < count; i++) { LocalInfo li = locals[i]; int slot = li.getSlot(); if (vs.containsSlot(slot) && !intersection.containsSlot(slot)) inte...
603bf0ed-f4b4-43f3-94e2-fa70f27cdb0c
2
public int getPort() { int port = getAddress().getPort(); if( port == 0 && server != null ) { port = server.socket().getLocalPort(); } return port; }
f4a081fd-25a9-4ce0-8a66-250e461ed2ba
6
public boolean hasItemStack(ItemStack par1ItemStack) { int var2; for (var2 = 0; var2 < this.armorInventory.length; ++var2) { if (this.armorInventory[var2] != null && this.armorInventory[var2].isStackEqual(par1ItemStack)) { return true; } ...
7f77fc35-4591-4723-81d1-f4a82ddd9ed8
7
static String depthInfo(int depth) { Object[] args = {new Integer(depth), ""}; switch (depth) { case 1: args[1] = createMsg(bundle.getString("Multi_pixels"), new Object[] {new Integer(8), " [01234567]"}); break; case 2: args[1] = createMsg(bundle.getString("Multi_pixels"),...
2d748ec9-ec76-45d3-8955-d46144b2b641
5
public UserVO login(String username, String password) { UserVO user = null; try { connection = DriverManager.getConnection(URL, USER, PASSWORD); Statement statement = connection.createStatement(); System.out.println("SELECT * FROM user WHERE username = '"+username+"';"); ResultSet result_user = statemen...
f7397ad3-caac-4bcc-8983-3a9be86ce9b4
0
public void clearPaths() { pathList.clear(); attList.clear(); walkList.clear(); }
302f7431-b4d5-4fc7-84b4-10bdac865aee
2
private void waitOnSetupToComplete() { // avoid blocking on this ptr, which would stop the // notifySetupCompleted method from working correctly try { initializedSemaphore.acquire(); } catch (InterruptedException xcpt) { initializationError = new IllegalStateException("Unable to ...
a3ef5d8c-55c3-4f32-b838-0d5070dcc970
3
@Override public boolean equals(Object other) { if (other == this) { return true; } if (other instanceof AuthorModel) { AuthorModel otherAuthor = (AuthorModel) other; boolean isSameClass = this.getClass() .equals(otherAuthor.getClass()); return (this.id == otherAuthor.id) && isSameClass; } ...
7067bea8-012e-484d-8c12-1ef236a67e84
3
private String[] parseAuthority(String authority) { String[] parts = new String[3]; if (authority != null) { // userInfo int first_ampersand = authority.indexOf(USERINFO_DELIM); if (first_ampersand >= 0) { parts[0] = authority.substring(0, first_ampersand); authority = authority.substring(first_...
3c4766c9-2832-4d33-b607-1bf0a7388be5
0
public Object remove(int index) { Object o = this.opt(index); this.myArrayList.remove(index); return o; }
a574a284-eac1-4688-8ae7-3dce984c43c4
0
public Long getId() { return id; }
62f849f3-f625-4c20-9b05-bb9b61f9fc11
0
public void setLink(IntNode newLink) { link = newLink; }
1b062df5-f286-46e2-80fe-17a0ce55285a
4
private static String encode(HashMap<Integer, Integer> mappedSides, int resultLength) { String[] result = new String[resultLength]; for (int i = 0; i < mappedSides.size(); i++) { // Find the shift amount for this current position int diffAmount = 0; int thisCorner = mappedSides.get(i); for (int j = 0; j...
3482a9b8-8a67-4e85-ad01-06545143bbde
3
public boolean startFindBestSolution(int[] rightCuts){ // SubPath[] subPaths=getSubPaths(rightCuts,p); // System.out.println("subPaths: "+Arrays.toString(subPaths)); //temporary int[] solution=new int[rightCuts.length]; boolean[] reversed=new boolean[rightCuts.length]; boolean[] used=new boolean[...
addeef13-2904-48e3-b7b9-958fee588776
9
public static String getRankedStats(String region, int accountID, String gameMode, String season, boolean async) { HashMap<Integer, HashMap<String, Double>> champions = new HashMap<Integer, HashMap<String, Double>>(); LoLRTMPSClient client; try { client = LoadBalancer.returnClient(region); } catch (Nul...
cfc25f68-7f36-4000-9415-79aea61b5e6d
8
public void p_Username_abusive_Playforreal( LinkedHashMap<String, LinkedHashMap<String, String>> credentials) { autoutil.openBrowser(dataSheet(credentials,"url","url")); autoutil.waitTime(8000); autoutil.clickButton(dataSheet(credentials,"button","sign"),propFile("link")); autoutil.waitTime(3000); for(...
de5cddb1-07ba-4ed6-bb21-c657aec8b068
8
private void cftrec4_th(final int n, final double[] a, final int offa, final int nw, final double[] w) { int i; int idiv4, m, nthreads; int idx = 0; nthreads = 2; idiv4 = 0; m = n >> 1; if (n > ConcurrencyUtils.getThreadsBeginN_1D_FFT_4Threads()) { nth...
30073b36-7024-4428-9e6b-7c051d91ec6a
0
@Basic @Column(name = "unit_price") public double getUnitPrice() { return unitPrice; }
9cf17183-0afa-497b-935b-68034d60715e
7
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { final MOB target=this.getTarget(mob,commands,givenTarget); if(target==null) return false; if(!super.invoke(mob,commands,givenTarget,auto,asLevel)) return false; final boolean success=prof...
01e1b37e-27b5-4e8e-a4a7-75d8f8a3204f
2
public static Path getSystemfile_Authui() { Path ret = SystemInformation.getOSPath().resolve(SYSTEMFILE_AUTHUI_x86); if (!isX86() && FileUtil.control(SystemInformation.getOSPath().resolve(SYSTEMFILE_AUTHUI_x64))) { ret = SystemInformation.getOSPath().resolve(SYSTEMFILE_AUTHUI_x64); ...
0f43da60-e285-4850-8701-f424c5d5d01b
2
private void deleteOnExit(File tempFile) { tempFile.deleteOnExit(); if (tempFile.isDirectory()) { File[] files = tempFile.listFiles(); for (int i=0; i<files.length; i++) { deleteOnExit(files[i]); } } }
948f1cd1-a0ff-4020-9fa6-f006b5cb96e1
7
public int accessMemCache(int smpIndexFrom, int numCPUFrom, int smpIndexTo, int numCPUTo, int cacheIndex, int startTime){ int n = getNumberSyncObjectsUntil(smpIndexTo); SMPNodeConfig smpNodeCfg=Configuration.getInstance().smpNodeConfigs.get(smpIndexTo); n+=1+smpNodeCfg.cacheConfigsPT.size(); if(smpNodeCfg.hasRe...
5438d08a-53f6-483f-a110-1558c3e74953
4
@Test public void testTimeNowIsUpdatedOnWorkbookOpen() throws Exception { try( InputStream inp = OpenXLSTest.class.getResourceAsStream( "/TimeNow.xls" ) ) { WorkBookHandle wb = new WorkBookHandle( inp ); WorkSheetHandle ws = wb.getWorkSheet( 0 ); Date timeNow = new Date(); int mins = timeNow.getMinut...
ceae76e1-b4d0-408d-a919-e24039f10092
6
@Override public boolean equals(Object obj) { if (!super.equals(obj)) { return false; } InternetSubscription o = (InternetSubscription) obj; return (source == null ? o.source == null : source.equals(o.source)) && (mail == null ? o.mail == null : mail.equal...
b3ba2e1b-a2fb-47e2-870f-f5b5ba52ee1c
9
private void doSend(Message message) { String dest = message.getDest(); Socket sendSock = null; for(SocketInfo inf : sockets.keySet()) { if(inf.getName().equals(dest)) { sendSock = sockets.get(inf); break; } } if(sendSock == null) { try { SocketInfo inf = config.getConfigSockInfo(dest); ...
73fe97e7-b736-41be-b303-c578542992e4
6
private BigDecimal analizarTipoCliente(String codProducto,BigDecimal iva,BigDecimal sub,BigDecimal cantidad){ int sitFrenteIva=Integer.parseInt(field_situacion_IVA.getText()); BigDecimal impuestoInterno=calcularImpInterno(codProducto,sub,cantidad); if((sitFrenteIva==3)||...
6eee0522-daf5-4913-84bc-a7b51fb4b923
6
static boolean isPalindrome(LinkedListNode n) { if (n == null) return true; LinkedListNode fast = n; LinkedListNode slow = n; Stack<Integer> stack = new Stack<Integer>(); while (fast != null && fast.next != null) { stack.push(slow.getValue()); fast = fa...
d81eb8e4-6507-466f-9386-2192d19aac30
2
public void setWidth(int width) { int minWidth = getPreferredHeaderWidth(); if (width < minWidth && width != -1) { width = minWidth; } mWidth = width; }
574d5572-21cb-47f5-99fa-3b0dba5b865c
5
void checkExpiration(){ for(Record rec:server.table.getTable() ){ for(Connection conn:server.connections){ if(conn.username.compareTo(rec.getUsername())==0 && (System.currentTimeMillis()- rec.getTimeStamp() > 80000)){ Message mes=new Message("server","TIMEOUT"); mes.assureIntegrity(); tr...
b89922ff-9149-48c0-8a98-98e76fcc1cab
4
public static void main(String[] args) { Calculadora calculadora = new Calculadora(); try { System.out.println(calculadora.dividir(5, 3)); calculadora.arreglo(); System.out.println("Gracias por participar"); } catch(MiExcepcion me){ System.out.p...
a8de0b61-d188-464a-ae22-ff2bd6ecbad5
6
private void calculateRanges(){ //creates ranges in which to put cards int[] tmpRack = rack.getCards(); int lowEnd = 1, highEnd, startSlot = 1, numSlots = 1; if (anchorPoints.contains(new Integer(1))) //handle if slot 1 is an anchor, skip it { lowEnd = tmpRack[0] + 1; numSlots--; startSlot...
386caa1b-b67b-4c7a-8672-69708bd40a51
4
public boolean addAccount(CuentaBancaria account){ if(!activo.validateTipo(Usuario.LIMITADO)){ if(account.getNum()<1){ return false; } if(!validarCuenta(account.getNum())){ if(add(account)){ return true; } ...
fbdc7ff5-a5f2-409b-94b0-6ae867416036
3
private void initiateLatch() { int count = 4; final CountDownLatch latch = new CountDownLatch(count); for (int i = 0; i < count; i++) { final int localCount = i; new Thread(new Runnable() { @Override public void run() { ...
b36e773c-4324-4317-bd0e-82b233f2ac7b
4
public static void main(String args[]) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAcce...
7fffa92f-f0bd-4a1c-8fda-12eabdc06f15
3
private void refreshGraph() { Object parent = graph.getDefaultParent(); graph.removeCells(graph.getChildVertices(parent)); graph.setCellsLocked(false); graph.getModel().beginUpdate(); try { idToVertexMap = new HashMap<Long, Object>(); vertexToHardwareMap = new HashMap<Object, NetworkHardware>();...
c44a5e42-3afa-47d8-90de-92b22df672d3
7
public int look(int bits) { int ret; int m = mask[bits]; bits += endbit; if (endbyte + 4 >= storage) { if (endbyte + (bits - 1) / 8 >= storage) { return (-1); } } ret = ((buffer[ptr]) & 0xff) >>> endbit; if (bits > 8) { ...
828d8e01-3743-4c73-bf4d-6556b3653a6d
6
public final void expelMember(final MapleGuildCharacter initiator, final String name, final int cid) { final Iterator<MapleGuildCharacter> itr = members.iterator(); while (itr.hasNext()) { final MapleGuildCharacter mgc = itr.next(); if (mgc.getId() == cid && initiator.getGuildRank() < mgc.getGuildRank()) {...
36722a12-9c9e-4f7d-b5c7-d831ee0e8019
4
public Hypothesis probabilisticSelect(int sumFitness) { boolean found = false; int cIndex = 0; Hypothesis h = null; while (!found) { double prob = (double)fitnessValues[cIndex] / (double)sumFitness; double rnd = Math.random(); ...
7f897ac5-28f5-4366-969a-b15f625fedb6
2
public static void render(){ glClear(GL_COLOR_BUFFER_BIT); ball.draw(); bat.draw(); for (Brick brick : bricks) { if (brick.isUse()){ brick.draw(); } } }
2a1dee87-1067-4bae-b3dd-5e936e9856e9
3
public static String[] makeCSV(String[][] s){ String[] ss = new String[s.length]; for (int i=0;i<s.length;i++){ String returnable = ""; for (int ii=0;ii<s[i].length;ii++){ returnable = returnable + s[i][ii]; if (ii != s[i].length-1){ ...
dbed9c3e-4e50-4444-879a-38cc964c940e
4
public boolean schlagen(SchachbrettFeld istFeld, SchachbrettFeld sollFeld, SchachbrettFeld[] felder) { //if (wegFrei(istFeld, sollFeld, felder) && (sollFeld.figur.figurFarbe != istFeld.figur.figurFarbe)) { if (Figurfarbe().equals(white) && !(sollFeld.figur.getClass().getSimpleName().equals("Koenig")) )...
f755b286-8c92-423a-a3cd-25e265e4f055
3
public void appendSamples(int channel, float[] f) { int pos = bufferp[channel]; short s; float fs; for (int i=0; i<32;) { fs = f[i++]; fs = (fs>32767.0f ? 32767.0f : (fs < -32767.0f ? -32767.0f : fs)); s = (short)fs; buffer[pos] = s; pos += channels; } buf...
3b6094fe-839f-4f66-8c00-39935760f0d9
2
public double getMedian() { if ( leftHeap.size() == rightHeap.size() ) { return ( leftHeap.peekMax() + rightHeap.peekMin() ) / 2; } else if ( leftHeap.size() > rightHeap.size() ) { return leftHeap.peekMax(); } else { return rightHeap.peekM...
4aba3a9c-7115-4be1-8bfc-ffcd4d522237
5
@Override public void render() { StateManager.update(); Renderer.get().begin(); StateManager.draw(); // TextPool.get().draw(); Renderer.get().end(); if (initial == 0 && Gdx.input.isKeyPressed(Keys.ENTER)) { initial++; StateManager.loadState(gamePlayState); } if (Gdx.input.isKeyPressed(Keys....
5a4df517-9d8c-46fd-8fe5-94c282b3431b
0
public FenetreJeuDeuxJoueurs(ModeleDeuxJoueurs _plateaux) { super(_plateaux.getPlateau1()); score2 = new Score(); grid2 = new GrilleTetris(_plateaux.getPlateau2().getTailleX(), _plateaux.getPlateau2().getTailleY(), 2); pieces2 = new Reserve(_plateaux.getPlateau2().getSuivantes()...
d5baa7c9-f92a-4b1e-b428-a77c124e6b1b
2
private void addDataEx(String date, String value, String sensorId){ Form form = new Form(); form.add("date", date); form.add("value", value); form.add("sensorId", sensorId); try { ClientConfig clientConfig = new DefaultClientConfig(); clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING...
1afee6cf-9c65-4929-bdb5-1fb6c938d941
7
public void copyNewKeysToDisk(String fileName){ InputStream in = plugin.getResource(fileName); if (in == null) return; YamlConfiguration locales = new YamlConfiguration(); try { locales.load(in); } catch (IOException e) { e.printStackTrace(); } catch (InvalidConfigurationException e) { e....
8662203c-1c01-44cd-9dd8-1d0c463f43bf
8
protected void hndlRegChnl(String xml, HttpRequest req) { List<InterfaceHttpData> httpDatas; try { httpDatas = new HttpPostRequestDecoder(new DefaultHttpDataFactory( DefaultHttpDataFactory.MINSIZE), req).getBodyHttpDatas(); ArrayList<ChnlRscIntf> rsces = getRsces(httpDatas); Pair<String, DiscnHdlrAbs...
81ef5c87-85fd-4551-923a-7a73028a9b0e
3
public static boolean isPlayerOn(String playerName) { for(int i = 0; i < maxPlayers; i++) { if(playersCurrentlyOn[i] != null){ if(playersCurrentlyOn[i].equalsIgnoreCase(playerName)) return true; } } return false; }
5aaebb6e-b69e-4fa3-999a-c4b0fe55f322
2
public float getMaximumDifference_as_float(){ float diff = 0.0F; if(this.type==2 || this.type==3){ float max = this.getMaximum_as_float(); float min = this.getMinimum_as_float(); diff = max - min; } else{ throw new IllegalArgumentException(...
bd251e49-f43b-4380-b33b-cac54998fbca
7
public void showNetworkIPDialog(){ final JDialog in = new JDialog(this,"Send to GCodeSimulator/GCodePrintr for Android",true); in.setLayout(new FlowLayout()); in.setBackground(Color.lightGray); final JTextField tf2 = new JTextField(15); final JLabel status = new JLabel(" ...
1e560ca7-15c9-4ad6-905b-c1f9b7eb3917
3
private Subscription getSubscription(long subscriptionId, int clientId){ //TODO this method is not very efficient... for(Subscription s : subscriptions){ if (s.clientId==clientId && s.clientSubscriptionId==subscriptionId){ return s; } } return null; }
fe02b095-318c-40ec-8740-cc1b308df6ae
5
public static void main(String[] args) throws IOException { Scanner in = new Scanner(System.in); StringBuilder out = new StringBuilder(); while (in.hasNext()) { int size = in.nextInt(), n = 0; if (size == 0) break; long cur = 0, max = 0; for (int i = 0; i < size; i++) { n = in.nextInt(); i...
63a20576-9246-4a0a-a587-50aadda1220c
1
private void handlePointCreation(Point clickedPoint) { creatorPoints.add(clickedPoint); if (creatorPoints.size() >= 4) { Main.getCurveManager().addCurve( new Curve(creatorPoints.get(0), creatorPoints.get(1), creatorPoints.get(2), creatorPoints.get(3), new Color(random.nextFloat(), random.nextFloat(),...
4ef65077-ec0e-4912-a31e-eb3282613cc9
3
public void leaveAllChannels(User user){ try { Socket socket = new Socket(SERVER_ADDRESS_CHAT, CHAT_PORT); socket.setSoTimeout(TIMEOUT); OutputStream outputStream = socket.getOutputStream(); ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream); objectOutputStream.wri...
45d644d2-861b-4db8-9346-6bd11031fe37
8
int calcChunkIx( int[] startIxs) throws HdfException { int ichunk = 0; for (int ii = 0; ii < varRank; ii++) { if (startIxs[ii] < 0) throwerr("startIxs[%d] == %d is < 0: %d", ii, startIxs[ii]); if (startIxs[ii] >= varDims[ii]) throwerr("startIxs[%d] == %d is >= varDims[%d] == %d", ii, sta...
ccc79d9a-42a8-4424-b233-d426bfb68721
2
public String getOneChapterHtmlSource(String ver, String book, int chapter) throws ParseException, IOException { Path file = Paths.get("/home/mark/bible/cobl/unv_" + book + "_" + chapter + ".html"); StringBuilder sb = new StringBuilder(); Charset charset = Charset.forName("UTF-8"); Str...
4ffa4a01-aac4-4150-9180-6973cd45da25
9
private void getMainClassesFromJar(List<String> mainClasses) { CodeSource src = Main.class.getProtectionDomain().getCodeSource(); if (src != null) { URL jar = src.getLocation(); ZipInputStream zip; try { zip = new ZipInputStream(jar.openStream()); ...
798d2142-8a68-4c16-b7dc-be7a91d598c9
8
protected void startGame() { notifyNewGame(); discardCards(); community.clear(); shuffle(); doAntes(); doBlinds(); dealCard(players.get((dealer + 1) % numplayers), false); dealCard(players.get((dealer + 1) % num...
2cde1312-ce27-4b62-84a9-3e6287667370
1
private double exptGreaterThan(double b) { double sum=0,interval=(bowSize*12-b)/1000,val=b; for (int i = 0; i <1000; i++) { sum+=phi(val, mu, sigma)*val*interval; val+=interval; } return sum/(1-probLessThan(b)); }
49e6c874-9f19-4e9f-9391-cd0264e33a51
4
public static void renderDemGremlins(){ int n; for (n=0;n<gremlin.allGremlins.size();n++){ if (gremlin.allGremlins.get(n).world==player.world){ float x = (float)(gremlin.allGremlins.get(n).xCoord); float y = (float)(gremlin.allGremlins.get(n).yCoord); TextureImpl.bindNone(); if (gremlin.allGremli...
9356520a-6b28-48ca-af46-96da92200e93
7
public void transaction() throws Exception { boolean done = false; System.out.println("Début de la transaction"); messagePacket = Packet.Create(MessageType.NACK, Sequence, new byte[0], WIN-1, '0'); message = messagePacket.getUDPdata(); tx(dataSocket, message); while(!done) { try { System.out....
647fdc92-4363-4b6a-a5f6-5fd7c54ac4d9
5
public static String getJsCalendarFormatPattern( String ifmt ) { if( ifmt.equals( "14" ) ) { return "%m/%d/%Y"; } if( ifmt.equals( "15" ) ) { return "%d-%b-%y"; } if( ifmt.equals( "16" ) ) { return "%d-%b"; } if( ifmt.equals( "17" ) ) { return "%m-%y"; } if( ifmt.equals( "22" ) ) ...
e8fc0ba2-7f8a-4ef3-90d1-a4bdcb9b651e
3
public Boolean secondDown() { if (time.getSeconds() > 0) { time.setSeconds(time.getSeconds() - 1); } else { if (time.getMinutes() > 0) { time.setMinutes(time.getMinutes() - 1); time.setSeconds(59); } els...
7bafdb88-3551-4363-845b-44f8522c11ac
6
public boolean connect() { for(int i = 0; i < 3; i++) { try { mServerInt = (ServerInterface) Naming.lookup("rmi://127.0.0.1:9090/server1"); mServerInt.ping(); System.out.println("Connected to Server 1"); return true; } catch(Exception ex) { System.out.println("Server 1 is not responding. \nR...
4840d02c-3c40-4bbe-9b11-e5923e8b54d0
3
private double carte(ICard card) { List<List<ICard>> prese = Rules.getPrese(card, table.cardsOnTable()); if(prese.size() > 0){ double fp = 0.0; for(List<ICard> presa : prese) for(int i = 0; i < presa.size(); i++) fp+=0.1; return fp; } return 0.0; }
12ff389a-0728-4adf-86cc-717a1e03c52f
7
@Override /** * Movement allowed, stopping to the first obstacle[non VOID] : diagonals UP LEFT-UP RIGHT-DOWN RIGHT-DOWN LEFT * RETURNS true if the move is allowed */ public boolean checkMove(int Px, int Py,Player J,Piece[] B){ int Dx = Px - getPosx(); int Dy = Py - getPosy(); boolean W = J.isWhite(); bo...