method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
6be76d5d-eb37-4104-9d24-29d4b94c8c0d
4
public Iterable<Key> levelOrderTraversal() { Queue<Key> q = new LinkedList<Key>(); if (root == null) return q; Queue<Node> tempQ = new LinkedList<Node>(); Node n = root; tempQ.add(n); while (!tempQ.isEmpty()) { n = tempQ.poll(); q.ad...
39b0129b-f2c7-41b1-a7e2-a02f0400e46b
0
@XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "X509IssuerSerial", scope = X509DataType.class) public JAXBElement<X509IssuerSerialType> createX509DataTypeX509IssuerSerial(X509IssuerSerialType value) { return new JAXBElement<X509IssuerSerialType>(_X509DataTypeX509IssuerSerial_QNAME,...
bcd95770-40ec-4c1d-83e4-7d2eede99431
5
public static void main(String[] args) throws Exception{ txtPath = args[0]; label = args[1]; txtPath = "text/CRF/predicted"; ArrayList<File> files = FileFinder.GetAllFiles(txtPath, ".txt", true); int count = 0; for(File f : files){ @SuppressWarnings("resource") BufferedReader br = new BufferedRe...
f3cd13a0-4b92-4b43-9c7a-a33be7fe7abc
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 ItemProperty)) { return false; } ItemProperty other = (ItemProperty) object; if ((this.itemPropertyPK == null &...
52c35e54-6162-4a2b-aa1d-b034f4a5a5da
3
private void initAgents() { agents = new Vector<Agent>(); for(int a = 0; a < numAgents; a++) { agents.add(new Agent(this)); } for(int a = 0; a < agents.size(); a++) { int x = 0; int y = 0; boolean free = false; while (!free) { x = gen.nextInt(xSize); ...
f87b6d43-fe06-4b43-9148-5fab5c855f53
7
private void add(LocalVarEntry li) { LocalVarEntry prev = null; LocalVarEntry next = list; while (next != null && next.endAddr < li.startAddr) { prev = next; next = next.next; } /* * prev.endAddr < li.startAddr <= next.endAddr */ if (next != null && li.endAddr >= next.startAddr) { if (next.ty...
5099c14c-7f8c-46ca-8b32-59e45ef5adcf
6
public static MazeNode parseMaze(RoomType[][] maze) { MazeNode result = new MazeNode(); MazeNode current = result; MazeNode nextRow = result; MazeNode nextCol = result; for (int x = 0; x < maze.length; x++) { for (int j = 0; j < maze[x].length; j++) { if(maze[x][j] == RoomType.START) result = curr...
d1812c3e-0c9d-4ca4-a388-73e8ff63f9b7
0
public List<PhpposSalesItemsEntity> getItemsDeMovimientoPos(PhpposSalesEntity movimientoPos){ return getHibernateTemplate().find( "from PhpposSalesItemsEntity where saleId = ?", movimientoPos.getSaleId()); }
96c2c2fd-9c73-449b-9788-d8dc163d326f
8
@Override public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { // TODO Auto-generated method stub IWorkbench wb = PlatformUI.getWorkbench(); IWorkbenchWindow window = wb.getActiveWorkbenchWindow(); if(window != null) { I...
9ead5625-5026-429c-a838-361c716f6998
9
public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Tile other = (Tile) obj; if (key == null) { if (oth...
5de4c424-2d5e-4f6a-a71b-ef4313d853da
9
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed // TODO add your handling code here: Validaciones v = new Validaciones(); if (jCheckBox1.isSelected()){ jLabel4.setVisible(false); Cargar_Tabla("SELECT * FROM "...
9c72067c-d2d3-4dfc-85dd-ff11bb441a0b
2
public EndPoint buildEndPoint() { switch( direction ){ case DIRECT: return new UndirectedEndPoint(); case ORTHOGONAL: return new OrthogonalEndPoint(); default: throw new IllegalStateException( "unknown enum: " + direction ); } }
c3933b2f-1d7c-4fc3-b6ac-349bc8b8657e
3
public void killEntity(UUID entity) { if (frozen) { return; } synchronized (componentStores) { for (HashMap<UUID, ? extends Component> componentStore : componentStores .values()) { componentStore.remove(entity); } ...
75b00730-d208-471f-af08-c057ecee180a
9
public ArrayList<BeanRecursos> getRecursos(int tipusRecurs) { ArrayList<BeanRecursos> list = new ArrayList<BeanRecursos>(); if (tipusRecurs == BeanReserves.AULES) { String SQL1 = "SELECT * FROM sig_espais where reservable='1'"; try { Statement st = client.getMy...
45333560-ba14-4d6a-b21a-925725b68d69
7
public void construct() { for (int i = 0; i < n; i++) { sA[i] = new Node(i, cad[i]); } int prev; int rank = 0; Arrays.sort(sA); int ind[] = new int[n]; for (int i = 2; i <= 2 * n; i <<= 1) { rank = 0; prev = sA[0].rank; sA[0].rank = 0; for (int j = 1; j < n; j++) { if ...
c3407707-077b-44ea-9c48-4349b2955f7c
5
@Override public int indexOf(Object o) { if (o == null) { for (int i = 0; i < list.size(); i++) { Object current = list.get(i); if (getInvoke(current) == null){ return i; } } } else { for (int i =...
e083359b-9ca2-46b2-811b-46d655af61eb
8
@Override public ItemStack tryAdd(ItemStack stack) { int free = getNextCompatibleIndex(stack.item, 0); if(free == -1) return stack; else { ItemStack comp = getStackIn(free); if(comp == null) comp = new ItemStack(); if(comp.nbr+stack.nbr <= stack.item.getMaxInStack()) { this.putStack(fr...
ffb1aee0-51c9-4cd7-9737-6dd478d7d127
1
public void check4WE() { if (getServer().getPluginManager().getPlugin("WorldEdit") == null) { Bukkit.getConsoleSender().sendMessage(coloredPrefix + ChatColor.DARK_PURPLE + "WorldEdit not found, commands will not work!"); } else { MuddleUtils.outputDebug("Got plugin WorldEdit!"); ...
53e5e676-6aea-4f77-8387-1d72643f4ca7
0
public String getAccount() { return account; }
00d6729e-3058-45c8-b5e5-4d80af786777
9
public List<Position> getDestinations(Position start, Player.Orientation orientation, Board board) { List< Position> destinations = new ArrayList<Position>(); int xDest = start.getX(); int yDest = start.getY(); int xShift, yShift; if (orientation == Player.Orientation.UP) { ...
42fe3752-46ae-42cd-b9db-83d69de2ec41
6
public boolean containsInRuleBody(final Literal literal, final RuleType ruleType) { Map<String, Rule> rules = getRules(literal); if (null == ruleType) { for (Rule rule : rules.values()) { if (rule.isBodyLiteral(literal)) return true; } } else { for (Rule rule : rules.values()) { if (ruleType == r...
dce6f049-e9ca-423f-b95b-3319264cc500
0
public JComboBox getjComboBoxSearch() { return jComboBoxSearch; }
9b7ac715-4f76-4b37-8129-a2318aea2f82
4
public void SetOver(boolean isOver){ boolean test = false; if (test || m_test) { System.out.println("Drawing :: SetOver() BEGIN"); } gameBoardGraphics.SetOver(isOver); if (test || m_test) System.out.println("Drawing:: SetOver() - END"); }
bd54d46e-f760-45b7-93ad-fbf82cc303cb
7
final private boolean jj_3R_120() { if (jj_scan_token(DO)) return true; if (jj_3R_47()) return true; if (jj_scan_token(WHILE)) return true; if (jj_scan_token(LPAREN)) return true; if (jj_3R_40()) return true; if (jj_scan_token(RPAREN)) return true; if (jj_scan_token(SEMICOLON)) return true; ...
9d82c960-b6f3-4de1-87e9-186b808b5b00
4
@Override public void onDraw(Graphics G, int viewX, int viewY) { if (X>viewX&&X<viewX+300&&Y>viewY&&Y<viewY+300) { G.setColor(Color.BLACK); G.fillArc((int)(X-radius)-viewX, (int)(Y-radius)-viewY, radius*2,radius*2, 0, 360); } }
a9a667cc-8af0-4730-8fe8-9ebee64dfab9
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...
c5382deb-25ba-465d-8570-c2bbbe4459dd
3
@SuppressWarnings("unchecked") private void readFile() throws IOException { synchronized (file) { if (!file.exists()) { autoincrement = 0; cache = new HashMap<Object, Object>(); writeFile(); } else { // Hooray Java 7 try resource closing! try (FileInputStream fis = new FileInputStream(file)...
a31d2aaa-6813-49e3-b0b4-3f6209ec36a8
3
public void start() { if (this.started) { return; } for (int c = 0; c < this.threads.length; c++) { this.threads[c] = new ThreadTaskWorker(c + 1); } for (ThreadTaskWorker t : this.threads) { t.start(); } this.started = true; }
229bed03-50f0-4429-93a5-86c7417232da
9
private static void parseValueElement(Element element, ConfigurableEmitter.Value value) { if (element == null) { return; } String type = element.getAttribute("type"); String v = element.getAttribute("value"); if (type == null || type.length() == 0) { // ...
ecd12043-8bfb-4856-9be0-ee4749960f2c
0
@Before public void setUp() throws Exception { }
e113fa8a-10c8-4aac-95d9-841ab7604bb8
5
public static void main(String[] args) { File testAccounts = new File("./test.txt"); try { BufferedReader accounts = new BufferedReader(new FileReader(testAccounts)); String line = ""; LineNumberReader lineNumberReader = new LineNumberReader(new...
76a6bc02-c149-4fed-8b8f-d657da218ae6
0
public String getContacterPhone() { return contacterPhone; }
d643c7a9-5fc0-4a3a-994c-4ca6755323ab
8
public void detectNearbyObjects() { for (MaskObject o1 : mapObjects) { // the coordinates are wrong, but its // too annoying to change all of the // code so it will stay this way for (MaskObject o2 : mapObjects) { int checkX; int checkY; checkX = o2.posX - o1.posX; checkY = o...
d72ddb98-55d0-4d50-9af1-947607ca2ffb
6
public void setTile(Vector2i coords, Tile tile, Layer Layer) { int Tiley = coords.tileY() * (width); int Tilex = coords.tileX(); if((Tiley + Tilex) <= (width * height) && (Tiley + Tilex) >= 0) { int ChosenTile = Tiley + Tilex; int TileID = tile.getTileID(); if(TileID == VoidTile.getTileID()) T...
296c1a62-af41-45ae-84c9-7d2897f09680
4
private static LinkedList<Vertex> getUnobstructedVertices(LinkedList<Vertex> vertices) { LinkedList<Vertex> unobstructed = new LinkedList<>(); addNeighbours(unobstructed); while (vertices.hasNext()) { Vertex q = vertices.getNext(); if (src == q || !q.isVertex(...
8da0b4eb-02c6-4138-929a-42566a2aa01c
0
public UserNotificationBuffer(long uid) { this.uid = uid; }
88d78166-a9d3-4008-bf94-a50e3a59fc32
6
@Override public boolean execute(final CommandSender sender, final String[] split) { if (sender instanceof Player) { if (MonsterIRC.getHandleManager().getPermissionsHandler() != null) { if (!MonsterIRC.getHandleManager().getPermissionsHandler() .hasCommand...
61583b5a-ee4a-4a6b-9faf-24a21643d31f
1
@Override protected int messageLength() { return grantedQoSs == null ? 2 : 2 + grantedQoSs.size(); }
023a965a-2356-4a8d-bb58-8787779d3aed
6
@Override public boolean equals(Object obj) { if (!super.equals(obj)) { return false; } MailSubscription o = (MailSubscription) obj; return (address == null ? o.address == null : address.equals(o.address)) && (city == null ? o.city == null : city.equals(o....
1d31d3b5-7495-4860-9dc3-92b928bfbb9f
3
public static <T extends Individual<T>> T tournamentSelection(ArrayList<T> genePool, Creator<T> creator) { // select competitors at random, possibly selecting the same more than // once ArrayList<T> competitors = new ArrayList<T>(); for (int i = 0; i < creator.getTournamentSize(); i++) { competitors ....
c57ef40e-85b4-4330-a61c-b9582b916b9d
8
static boolean isSubclass(Class a, Class b) { // We rely on the fact that for any given java class or // primtitive type there is a unqiue Class object, so // we can use object equivalence in the comparisons. if (a == b) { return true; } if (a == null || b ==...
5b7e4592-e80b-4dff-9aa2-36bf1d4a7553
4
public void undo() { if (prevSpeed == CeilingFan.HIGH) { ceilingFan.high(); } if (prevSpeed == CeilingFan.MEDIUM) { ceilingFan.medium(); } if (prevSpeed == CeilingFan.LOW) { ceilingFan.low(); } if (prevSpeed == CeilingFan.OFF) {...
09ffb8c6-1238-4332-a2b8-d1107f90c806
2
public Worldnode getWorldnodeByID(int id){ conn = new SQLconnect().getConnection(); Worldnode tmp = new Worldnode(); try { String sql = "select * from worlds where display = 'true' and id =" + id; Statement st = (Statement) conn.createStatement(); // 创建用于执行静态sql语句的Statement对象 ResultSet rs = st.execu...
4a66dd84-0312-4f29-aa09-583366f7405a
3
public void addFromStream(InputStream is) throws IOException { if (is.available() > 0) { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String line; while ((line = reader.readLine()) != null) { if (line.length()...
9eabbedf-f2f6-4690-b254-ad8ccbe23e70
1
private boolean paikkaOsaTunnusta() { return paikkaSisaltyySyotteeseen() && paikkaSisaltaaSallitunMerkin(); }
c2b122e7-4d90-4730-a145-3ee49c25b71d
7
public static Rule_HTAB parse(ParserContext context) { context.push("HTAB"); boolean parsed = true; int s0 = context.index; ArrayList<Rule> e0 = new ArrayList<Rule>(); Rule rule; parsed = false; if (!parsed) { { ArrayList<Rule> e1 = new ArrayList<Rule>(); int s1...
dbb98957-05a7-4566-a2d9-c9a844ef1809
3
public boolean free(Point p) {//This does not count the player (yet) TODO make this count the player REMEMBER THE SIMILAR CODE IN THE PATHFINDING int key = genKey(p); boolean tilefree = false; boolean actorfree = true; if (tileHashMap.containsKey(key)) { tilefree = tileHashMa...
28231439-b773-4e9e-9a37-b395480335e0
7
public static void handleFileOpenEvent(IWorkbenchPartReference partRef) { // get preference store of this plugin IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); IWorkbenchPart part = partRef.getPart(true); if (part instanceof IEditorPart) { /*...
294a472f-4c8f-4ae8-b35f-650838386062
3
protected void calcPositions() { for (int index = 0; index < vertexArray.length; index++) { if (isMoveable[index]) { // Get the distance of displacement for this node for this // iteration double deltaLength = Math.sqrt(dispX[index] * dispX[index] + dispY[index] * dispY[index]); if (de...
dbdd3996-e1d3-4db3-9dbc-946b6473e8e5
3
boolean isEastward() { if ( (this == northeast) || (this == east) || (this == southeast) ) { return true; } return false; }
e71519f5-90e6-41f5-b0a4-2a56881a8409
8
public static void main(String[] args) { // insert a bunch of strings String[] strings = { "it", "was", "the", "best", "of", "times", "it", "was", "the", "worst" }; IndexMaxPQ<String> pq = new IndexMaxPQ<String>(strings.length); for (int i = 0; i < strings.length; i++) { pq....
09fbd9aa-c266-4b7c-ac65-e441b2cc8b26
0
void initItemCounter() { itemCounter = 0; }
b7ef3110-0d17-4e8c-a7a2-a427829e4198
4
public String reverseWordsInSentenceInPlace(String inputSentence) { logger.info("Start reverseWordsInSentenceInPlace, inputSentence = \"" + inputSentence + "\""); long startTime = System.nanoTime(); StringBuilder reversedSentence = new StringBuilder(inputSentence); int startWord = 0; ...
c5fd3c33-841d-42fb-9f27-26afc9a901bd
4
public int getRequiredChange(int currentHeading, int desiredHeading){ double error; double derivative; double output; //If desired heading changes, integral is reset. if(previousHeading!=desiredHeading){ integral = 0; previousHeading = desiredHeading; } // Caculate P,I,D //error = desiredH...
8458b61c-7ffa-48bf-9c8f-3dfffc448424
4
public boolean checkPosition(int x, int y) { boolean ok = false; if ((x >= Board.MINWIDTH) && (y >= Board.MINHEIGHT)){ if (x <= this.tx && y <= this.ty) { ok = true; } } else { System.out.println("Not valid position"); } return ok; }
966874b2-c546-47c7-a60b-a8e5c60edf2a
8
@Override public Node findNode(URL node) throws RestApiException { Node ret = null; Collection<String> aliases = aliasLookup.getForAlias(node.getHost()); List<Node> nodes = getNodes(); for (Node n : nodes) { boolean hostMatches = false; // Not the same host for (String alias : alia...
23845d03-07a0-46eb-8aad-4a93c0a7d891
4
private void buildWinchPanel(Winch winch, boolean isSelected) { if(winch == null) return; DEBUGWinchPanel = new JPanel(); DEBUGWinchPanel.setBackground(Color.WHITE); JPanel WinchPanel = new JPanel(); WinchPanel.setLayout(new BoxLayout(WinchPanel, BoxLayout.Y_AXIS)); JLab...
afb22d8a-f577-47d4-b763-d4a36cc8b017
7
public ArrayList<Location> findHeroes(int radius){ ArrayList<Location> locations = new ArrayList<Location>(); Grid grid = Grid.get(); for(int i = -radius; i <= radius; i++){ for (int e = -radius; e <= radius; e++){ if(i != 0 || e != 0){ int x = lo...
e51544f3-bf1d-4a65-82f8-12042741eb1c
4
protected void scanFields(ClassFile cf) { List fields = cf.getFields(); if (fields == null) return; for (Object obj : fields) { FieldInfo field = (FieldInfo) obj; AnnotationsAttribute visible = (AnnotationsAttribute) field.getAttribute(AnnotationsAttribute.visibleTag); ...
c870d48a-b417-4560-acde-65134d8fbc99
1
public void publishEvents(int numberOfEvents) { for(int i = 0; i < numberOfEvents; i++) { Date eventDate = new Date(); final String uuid = UUID.randomUUID().toString(); Map<String, Object> event = new HashMap<String, Object>(); event.put("id", i); eve...
16c2af79-e45b-484d-b381-775336a99d91
5
public void checkIdleActivity(){ if(activeEvents.isEmpty()) { return; } Iterator<Job> it = activeEvents.iterator(); while(it.hasNext()){ DatedEvent event = (DatedEvent) it.next(); if((event.getDate().before(new Date(System.currentTimeMillis()))) || (ev...
240cc5bb-a533-41c5-801c-4dbb7eb87c0d
5
public void unlockUpgrade(Upgrade upgrade) { if(!upgrade.multipleUsage()) return; if (getType() != HabitatType.House || getType() != HabitatType.Villa) return; if (getUpgrades().containsKey(upgrade)) { if (upgrade.multipleUsage()) getUpgrades().put(upgrade, getUpgrades().get(upgrade) + 1); } else ...
76b2ce67-3fdf-4d86-b75a-1a9c56114922
2
public Stream<String> placeFigures(Stream<String> boards) { if (Objects.isNull(boards)) { throw new IllegalStateException("boars are null"); } Stream<String> boardsToReturn = placePartOfChain(boards); if (Objects.nonNull(chain)) { return this.chain.placeFigures(bo...
3d7fa7d6-2eea-454d-8269-3559ba55a181
7
public List<Node> nearestNodes(byte[] nodeIdOrInfoHash) { List<Node> nodes = new LinkedList<>(); if (buckets.isEmpty()) { return nodes; } int bucketIndex = bucketIndex(nodeIdOrInfoHash); nodes.addAll(buckets.get(bucketIndex).nodes); int minBucketIndex = bucket...
362f8963-b3b8-438b-9778-0e7d017f8cc3
4
public void fixBounds() { if (x < xmin) { x = xmin; } if (y < ymin) { y = ymin; } if (x > xmax) { x = xmax; } if (y > ymax) { y = ymax; } }
8e7f93a1-881a-4367-967c-1b70cfd9e397
6
@Override public void mouseReleased(MouseEvent e) { int x = e.getX(); int y = e.getY(); for (int i = 0; i < selection.length; ++i) { if (selection[i].contains(x, y)) { if(i == 0) { frame.dispose(); clip...
2d9f500d-0f5e-46ec-bf47-dc6afe9c9ce3
3
public boolean correspondsWith(GameObject go){ return (this.getX() + this.size.width) >= (go.getX()) && (this.getX() <= (go.getX() + go.getSize().width)) && (this.getY() + this.size.height) >= (go.getY()) && (this.getY()) <= (go.getY() + go.getSize().height); }
91858ff8-3940-4e0c-8688-032848673632
2
public Collection<Artist> getArtists() { try { if (!executed) execute(); } catch (SQLException e) { e.printStackTrace(); } return artists.values(); }
b543efc9-6e99-47d7-a65d-45bb68586770
7
@SuppressWarnings({ "unchecked", "rawtypes" }) public static void setCache(String domain, Class<Table<?>> clazz, Object condition, Object result) { CacheBeen cb = (CacheBeen) cacheMap.get(domain); if (cb == null) return; List<Object> list = new ArrayList<Object>(); final long l = System.currentTimeMillis();...
df249306-f950-41cc-8724-7251935b10fa
8
public void setPosicionJugador1(int x,int y){ if(x>=0&&x<8&&y<8&&y>0){ switch (pd.mapa_jugador1[x][y]) { case "SM": case "DT": case "AZ": System.out.print("POSICION OCUPADA"); System.out.println("OTRA CORDENADA"); ...
c1bf1d9a-7abe-4f24-8ac4-bcddaef1784c
8
public void goTo(){ boolean bol=false; pos2D.setSpeed(0.3, 0); while(!bol){ while(!sonar.isDataReady()); double[] sonarValues = sonar.getData().getRanges(); if(sonarValues[0]<0.5 ||sonarValues[1]<0.5){ pos2D.setSpeed(0, 0); avoidObs(); } while(!pos2D.i...
c4441c31-531a-492f-9412-999c454f1b22
3
protected List<StoreLoader<?>> popLoaders() { List<StoreLoader<?>> popedLoaders = loaders; loaders = new ArrayList<StoreLoader<?>>(); return popedLoaders; }
3031928a-5393-4f63-8e75-309636173024
5
@Override public boolean equals( Object o ) { if( this == o ) return true; if( o == null || getClass() != o.getClass() ) return false; ExtraComplexImmutableObject that = ( ExtraComplexImmutableObject )o; if( !aspect.equals( that.aspect ) ) return false; if( !compositeBehavior.equals( that.composi...
796f2c2f-852a-450b-a96d-0bd91bc74624
9
private boolean hasPickAxe(Player player) { if (player.getInventory().containsOneItem(15259, 1275, 1271, 1273, 1269, 1267, 1265, 13661)) return true; int weaponId = player.getEquipment().getWeaponId(); if (weaponId == -1) return false; switch (weaponId) { case 1265:// Bronze PickAxe case 1267:// I...
4a120808-14c7-4074-bd8b-51f7ccd2dc75
2
public void cargarArchivoLocal(){ try { FileInputStream fileIn = new FileInputStream("configLocal.txt"); ObjectInputStream in = new ObjectInputStream(fileIn); Configuracion confi; confi = (Configuracion) in.readObject(); if(confi!=null){ ...
682a3fbf-3335-4c6c-9a2b-465ad480cea6
1
public boolean isPalindrome(){ reversedString = new StringBuilder(testString).reverse().toString(); if (reversedString.equals(testString)) { return true; } else { return false; } }
f6debd57-341d-4c1c-b2a9-afef2f2e85dd
4
private Position getPosOnDirection(Position pos, Direction direction) { Position p = pos.copy(); if (direction.equals(Direction.UP)) { p.setY(p.getY() - 1); } else if (direction.equals(Direction.DOWN)) { p.setY(p.getY() + 1); } else if (direction.equals(Direction....
1ebfab7b-cb34-4c3d-80c9-2e6d4491b95d
8
public Airport[] findKNearestAirport(Airport[] airports, int k, Airport origin) { if (airports == null || airports.length == 0 || k <= 0) { return null; } PriorityQueue<Airport> queue = new PriorityQueue<Airport>(k, new Comparator<Airport>() { @Override public int compare(Airport a, Airport b) { d...
37c984d1-09dc-4cee-811f-79ec5a0e6381
1
private static Integer getParamIndex(Map<String, Integer> paramIndexes, String paramName) throws DaoGenerateException { if (!paramIndexes.containsKey(paramName)) { throw new DaoGenerateException("方法参数中必须包含@Param(\"" + paramName + "\")注解或者参数名为\"" + paramName + "\"的参数"); } Integer index = paramIndexes.get(par...
42d89bf7-2769-41b6-abad-b19c73eab9ac
1
public void testConstructor_ObjectStringEx4() throws Throwable { try { new YearMonthDay("10:20:30.040+14:00"); fail(); } catch (IllegalArgumentException ex) { // expected } }
ecff8323-ac15-40a0-8669-e641cf2b1c34
0
public static void main(String[] args) throws Exception { SimpleResultSet rs = new SimpleResultSet(); rs.addColumn("NAME", Types.VARCHAR, 255, 0); rs.addColumn("EMAIL", Types.VARCHAR, 255, 0); rs.addRow("Bob Meier", "bob.meier@abcde.abc"); rs.addRow("John Jones", "john.jones@abcd...
a97cfafb-7f6c-4852-8d4a-298555425410
8
public StringBuffer printStatement(int tab, StringBuffer output) { printIndent(tab, output).append("for ("); //$NON-NLS-1$ //inits if (initializations != null) { for (int i = 0; i < initializations.length; i++) { //nice only with expressions if (i > 0) output.append(", "); //$NON-NLS-1$ initializa...
97f31480-38fd-4e93-ae5f-5aab3266cf52
3
public void generateIndividual() { for (int i = 0; i < GA.items.length; i++) { byte gene = (byte) Math.round(Math.random()); if(gene == 1 && getFitness() + GA.items[i] > 2000) { gene = 0; } genes[i] = gene; } }
b599578b-7da0-420f-9c1b-0256e360f59d
3
@Override public String strip(String s) throws Exception { byte[] oldBytes = s.getBytes(UTF8); byte[] newBytes = new byte[oldBytes.length]; int newlen = 0; for (int j = 0; j < oldBytes.length; j++) { byte ch = oldBytes[j]; if (!(ch >= 0 && ch < 32)) { ...
358c1330-f106-4d28-8302-cf2f9c62dd44
0
public DrawArea(Stack<IPaintable> a) { actions = a; zapl = new ZoomAndPanListener(this); this.addMouseWheelListener(zapl); this.addMouseListener(zapl); this.addMouseMotionListener(zapl); this.addKeyListener(new KeyListener() { public void keyReleased(KeyEven...
99388346-acd4-489b-aee5-3cc2859cec03
4
private void delete(NoeudRN z) { NoeudRN y= z, x; Couleur noeudY= y.getCouleur(); if(z.getGauche() == sentinelle){ x= z.getDroit(); transplant(z, z.getDroit()); } else if(z.getDroit() == sentinelle){ x= z.getGauche(); transplant(z, z.getGauche()); } else { y= minimum(z.getDroit()); noeu...
ae1d2573-fca5-4b36-9a1d-1df44ea7bc4e
5
@Override public boolean equals(Object that) { boolean result = false; if (that != null && that instanceof LongBitSet) { LongBitSet b = (LongBitSet) that; if (this.cardinality() == b.cardinality()) { result = true; for (long l : b) { if (this.get(l) == false) { ...
e811737c-869d-48df-93b9-c22422387834
6
public void update(GameContainer gc) { int scrollWheel = Mouse.getDWheel(); if(gc.getInput().isKeyDown(Input.KEY_LEFT)) { x-=CAM_SPEED; } if(gc.getInput().isKeyDown(Input.KEY_RIGHT)) { x+=CAM_SPEED; } if(gc.getInput().isKeyDown(Input.KEY_UP)) { ...
1f42ee0e-78b4-4a04-8dfb-4a3a14d8b082
4
public static String byteDesc(long len) { double val = 0.0; String ending = ""; if (len < 1024 * 1024) { val = (1.0 * len) / 1024; ending = " KB"; } else if (len < 1024 * 1024 * 1024) { val = (1.0 * len) / (1024 * 1024); ending = " MB"; } else if (len < 1024L * 1024 * 1024 * 1024) { val = (1.0 ...
97c96568-96d6-4493-b7c0-76cbc8566b34
7
public void run() { if (src.exists() && src.isFile()) { if (!dst.exists() || dst.isFile()) { try { if (dst.exists()) dst.delete(); dst.createNewFile(); progressStr = src.getAbsolutePath()+"\n"+dst.getAbsolutePath(); FileInputStream fis = new FileInputStream(src); BufferedInputStr...
76505ca9-07ab-4240-8eef-1db98d1debe9
8
public WordVector lookUp(String wordToFind) { // first check if word is in clue if (clues.contains(wordToFind)) { // check row and reverse row int row = 0; int column = 0; for (int i = 0; i < n; i++) { StringBuffer rowString = new StringBuffer(); rowString.append(puzzle[i]); column = rowStri...
f4446c3c-9541-49be-b564-57be98754595
0
public boolean addFile(AlgorythmFile objFile){ return dataBaseFiles.add(objFile); }
5b1b2c89-242d-42a6-8261-b2f6b583bc72
9
private var_type eval_exp13() throws StopException, SyntaxError { var_type result, partial_value; String op; result = eval_exp14 (); op = token.value; while(op.equals("*") || op.equals("/") || op.equals("%") ){ token = lexer.get_token(); partial_value = eval_exp14(); boolean constant = resul...
5c2bfd7a-7a22-4e12-834f-67164846f1f5
5
public void run(){ boolean running = true; while (running){ synchronized(outputQueue){ while (outputQueue.size() == 0){ try { outputQueue.wait(); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } String line = output...
b631d7df-da7a-4321-b4a5-8ec479a3cc54
6
@Override public boolean read( File file, HashMap< String, HashMap< String, String > > tags ) { try { BufferedReader br = new BufferedReader( new FileReader( file ) ); // reads data from the file Map< String, HashMap< String, String > > data = new HashMap<>(); // contain...
2e8949a0-7ff0-4e63-a8db-54aa68da6dd8
8
protected Expression unary() throws ParsingException { char nextChar = getChar(); if (Character.isLetter(nextChar) || Character.isDigit(nextChar)) { return predicate(Character.isUpperCase(nextChar)); } else if (nextChar == '!') { return new Not(unary()); } else if...
a4a781e1-ac1b-499a-b445-9b86adce26e1
6
@Override public void contextInitialized(ServletContextEvent event) { ServletContext context = event.getServletContext(); /*The method retrieves the context object from the event argument. */ List leaguelist = new LinkedList(); String leaguesfile =context.getInitParameter("leagues-file"); /*...
73fcb190-d631-4721-b032-1014ac895fae
9
public String toString() { StringBuffer text = new StringBuffer(); if (m_t == null) return "Gaussian Processes: No model built yet."; try { text.append("Gaussian Processes\n\n"); text.append("Kernel used:\n " + m_kernel.toString() + "\n\n"); text.append("Average Target Value : ...
dcd17c0d-cc1c-485f-8345-3eebf61a7e2b
9
public boolean intersect(IntersectionRecord outRecord, Ray rayIn) { double txMin, txMax, tyMin, tyMax, tzMin, tzMax; double invx = 1 / rayIn.direction.x; double tx1 = (minPt.x - rayIn.origin.x) * invx; double tx2 = (maxPt.x - rayIn.origin.x) * invx; txMin = Math.min(tx1, tx2); txMax = Math.max(tx1, tx2);...
c0bbd389-0b91-4a11-a3ef-503d05285968
7
private Node insert(int key) { Node uusi = new Node(key, false); uusi.height = 0; // Jos puussa ei ole mitään, laitetaan uusi solmu juureksi if (root == null) { root = uusi; return uusi; } Node current = root; Node parent = current; ...