method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
b9332bea-a232-425d-9211-46a6c0f18a02 | 2 | void loadProject(File folder) {
if (!folder.exists()) {
return;
}
workCombo.addItem(new FileDisplayer(folder));
File simDir = new File(folder, SIMULATION_DIR);
openChooser.setCurrentDirectory(simDir.exists() ? simDir : folder);
currWork = folder;
enabl... |
84f4d510-b4cd-44f7-9268-25fee0c4810b | 1 | public byte[] getByteArray( String name ){
XAttribute attribute = getAttribute( name );
if( attribute == null )
throw new XException( "no attribute known with name: " + name );
return attribute.getByteArray();
} |
e71fbd64-4ee3-41c1-92fc-02802f431bb1 | 6 | public void repeat(int dist, int len) throws IOException {
if (dist < 0 || dist >= full)
throw new CorruptedInputException();
int left = Math.min(limit - pos, len);
pendingLen = len - left;
pendingDist = dist;
int back = pos - dist - 1;
if (dist >= pos)
... |
a7ff4dcd-acbb-4f9a-ba88-c980787779b7 | 7 | public Set<String> parse(URL pageUrl, Reader reader, String encoding) throws IOException {
if (pageUrl == null || reader == null) {
throw new IllegalArgumentException("reader an pageUrl shouldn't be null");
}
MyHTMLEditorKit kit = new MyHTMLEditorKit();
HTMLEditorKit.Parser p... |
5a8967f8-184c-4654-a70d-1150a7ce2fae | 1 | public static String longToStringZeroForEmpty(Long timeLong) {
final Long startTime = StringToLong("1970/01/01 09:00:00 000");
if (startTime == timeLong) {
return "";
}
return longToString(timeLong);
} |
d44f27cd-090f-4845-9f03-110b65eb0d61 | 4 | private static void createAndShowGUI() {
JButton crop = new JButton("Crop");
JFrame frame = new JFrame("Crop image");
JButton load = new JButton("Load");
Calendar localCalendar = Calendar.getInstance(TimeZone.getDefault());
JPanel panel = n... |
8e9dde7b-10b6-4aea-a232-55a60b51a18e | 1 | private void toAndroid_adbMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toAndroid_adbMenuActionPerformed
try {
adbController.rebootDevice(selectedDevice, RebootTo.ANDROID);
} catch (IOException ex) {
logger.log(Level.ERROR, "An error occurred while reboot... |
2f4d5ea4-abae-445f-be06-d1164ce0113b | 3 | public String getDescription() {
String input = getInputToRead();
if (input.length() == 0)
input = Universe.curProfile.getEmptyString();
String toPop = getStringToPop();
if (toPop.length() == 0)
toPop = Universe.curProfile.getEmptyString();
String toPush = getStringToPush();
if (toPush.length() == 0)
... |
e3c12d62-9eb9-4862-9d27-6223c957dc71 | 4 | @Override
public boolean pieceMovement(Point startPosition, Point endPosition) {
Point difference = new Point();
difference.setLocation(endPosition.getX() - startPosition.getX(), endPosition.getY() - startPosition.getY());
if((Math.abs(difference.getX()) == 2 && Math.abs(difference.getY()) == 1) ||
(Math.... |
656c6719-5359-4a54-93d2-6c6a2e0e9f02 | 7 | public boolean revert() {
if (type instanceof Reaction.A2_B2__2AB) {
Reaction.A2_B2__2AB r = (Reaction.A2_B2__2AB) type;
r.moleFractionA2().setPointer(0);
r.moleFractionB2().setPointer(0);
r.moleFractionAB().setPointer(0);
r.numberOfA2().setPointer(0);
r.numberOfB2().setPointer(0);
r.numberOfAB()... |
56a0b873-6461-4bfb-8b83-17e35f49932c | 5 | private int getPrecedence() {
int precedence = 0;
//All other symbols are precedence 0
switch (operatorSymbol) {
case '+':
case '-':
precedence = 1; break;
case '*':
case '/':
precedence = 2; break;
case ... |
ea8a7c61-0610-4df7-8f7c-524c68225840 | 5 | public void createIndex() {
Segmenter seg = new Segmenter();
WordsFilter filter = new WordsFilter();
List<CoreLabel> words;
ResultSet resultSet = null;
String query = "select distinct indexid from dblpcitation union select distinct citationid from dblpcitation;";
ResultSet rs = sqLconnection.Query(query);
... |
c5a6e235-4c10-402e-9679-80d4082fad8b | 5 | @Override
public boolean isValid()
{
boolean isValid = this.no_of_files >=0 && toDownloadFiles != null && maxFileSizes != null && toDownloadFiles.size() == maxFileSizes.size() && toDownloadFiles.size() == this.no_of_files;
if(!isValid)
{
//TODO: cleanup
//Do clean up if required
}
return isValid;
} |
d9fbc587-7908-49a9-b86d-fd1969c14475 | 7 | @Override
public Computer find(long id) {
// TODO Auto-generated method stub
String query = "SELECT * FROM computer WHERE id="+id;
ResultSet results = null;
Connection connect = ConnectionMySql.getInstance();
Computer computer = null;
try (Statement stmt = connect.createStatement()){
results = stmt.e... |
931a2165-db89-4ca1-91ff-3d234ece2ea3 | 1 | public String moveCardOntoTopRowFromRow(int boardIndexFrom, int boardIndexTo) {
List<Card> from = topRow.get(boardIndexFrom);
String result = moveCardOntoTopRow(from, boardIndexTo, from.size()-1);
if (result.isEmpty()) {
from.remove(from.size() - 1);
}
return result;
... |
00877990-0cb1-4281-ae88-9dad1c1d057a | 2 | @Override
protected AFUNIXOutputStream getOutputStream () throws IOException {
if ( !this.connected && !this.bound ) {
throw new IOException("Not connected/not bound");
}
return this.out;
} |
65cd27a5-8f14-43f6-b0e4-664d22ac3657 | 7 | private void updateHistogram() {
int red, green, blue;
double max_red = FindPeak(img_red);
double max_green = FindPeak(img_green);
double max_blue = FindPeak(img_blue);
double max_alpha = FindPeak(img_alpha);
max_red = Math.pow(max_red, gradient);
max_green = Math.pow(max_green, gradient);
max_blue = M... |
76f753d5-d8b2-4766-9512-c1f1c46280e2 | 1 | public String getValue(int place) throws NotExist {
ListElement current = head;
for (int i = 1; i < place; i++) {
current = current.next();
}
return current.getValue();
} |
f84678d2-e660-415c-8251-0907203d8ea2 | 3 | public static void count1Number(int n){
int count = 0;
int factor = 1;
int cur = 0;
int high = 0;
int low = 0;
while(n / factor != 0){
low = n - (n / factor ) * factor;
cur = (n / factor) % 10;
high = n / factor / 10 ;
if(cur == 0){
count += (high) * factor;
}
else if(cur == 1){
... |
00d79060-4fb1-40de-89a1-2e59a5248657 | 6 | public void updateToSlide() {
if(imageFlow != null) {
if(panel.isVisible()){
try{
imageFlow.scrollAndAnimateTo(Engine.getCurrentSlideID() - 1);
}
catch(NullPointerException e){}
catch(IndexOutOfBoundsException e){}
}
else{
try{
imageFlow.setSelectedIndex(Engine.getCurrentSlideID... |
dab382bc-c6ce-44f2-8a1a-2ea95e80320a | 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... |
ad920539-40f6-4eed-b91e-f0bb7d7bec25 | 5 | public static void main(String[] args) throws Exception
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int[] charCount = new int[33];
//алфавит
ArrayList<Character> alphabet = new ArrayList<Character>();
for(int i=0;i<32;i++)
{
... |
3d94c351-190f-4df2-a33a-77b76a8a4b36 | 9 | public void move() {
if (type.equals("Quade") || type.equals("Hail")) {
x += MISSILE_SPEED;
distance++;
if (distance >= 150) {
visible = false;
} //when quade powers up, this code activates his super energyballs
if (type.equals("Quade"... |
8aa54599-b3f3-4363-ab51-455f49871db6 | 9 | public static int hg_step4(int step, double[][] cost, int[][] mask, int[] rowCover, int[] colCover, int[] zero_RC)
{
System.out.println("STEP 4");
//What STEP 4 does:
//Find an uncovered zero in cost and prime it (if none go to step 6). Check for star in same row:
//if yes, cover the row and uncover ... |
8de8e5e4-3f2c-46b0-aa24-97dc18842d1e | 8 | public Component getListCellRendererComponent(final JList list,
final Object value, final int index, final boolean isSelected,
final boolean cellHasFocus) {
if (!(value instanceof LogEntry))
return new JLabel();
final LogEntry wlr = (LogEn... |
579d4546-6e86-4b97-b332-8771f1c81a9f | 3 | @Test
public void containsWorks()
{
boolean test = true;
for (int i = 0; i < 1000; i++)
{
tree.clear();
for (int j = 0; j < 1000; j++) tree.add(j);
int r = (int)(Math.random() * 1000);
if (!tree.contains(r))
{
te... |
96fbde5b-5c21-4ec7-8d44-1d22f9b27266 | 8 | public boolean set( int row, int column, int value ){
boolean flag = (0 <= row && row < DIGITS &&
0 <= column && column < DIGITS &&
0 < value && value <= DIGITS &&
board[row][column] == 0);
if( flag ){
board[row][column]... |
84b01d52-4c8e-4332-afd7-9e75858af31a | 4 | public void exit(){
int opt = JOptionPane.showConfirmDialog(this, AimConstants.CLOSE_MESSAGE);
if (opt == JOptionPane.OK_CANCEL_OPTION) return;
if (opt == JOptionPane.NO_OPTION) return;
if (opt == JOptionPane.CLOSED_OPTION) return;
if(opt == JOptionPane.YES_OPTION){
// TODO, Save transactions if any ... |
9cc00330-8147-4dfd-918a-c441ef59dbe9 | 3 | public void run() {
ultimaEscritura(nombre);
while (s >= 0) {
if (s == 0)
{
cont--;
System.out.println(nombre + " - " + s + " - ultima escritura"
+ IDanterior);
System.out.println("ultima escritura " + nombre + " - " + cont
+ " Threads activos");
}
else {
System.out... |
2b71e989-f93a-4bb7-a695-8215950033d1 | 7 | private void xmlBuildFloatingNode(NodeList dockables, Rectangle bounds)
throws SAXException {
// @todo not optimal.. we should refactor it oustide this method
Window desktopWindow = SwingUtilities.getWindowAncestor(this);
if (desktopWindow != null) {
Point windowLocation = desktopWindow.getLocation();
b... |
bf864d01-d626-4d97-b82c-b34ad9cf3ac8 | 7 | @Override
public void move(int dx,int dy){
if(x+dx>=Level.SIZE || y+dy>=Level.SIZE || x+dx<=0 || y+dy<=0 || (l.world[x+dx][y+dy] != TileType.AIR && l.world[x+dx][y+dy] != TileType.FIRE && l.world[x+dx][y+dy] != TileType.TORCH)){
l.worldDamage[x+dx][y+dy]-=1;
}else{
x+=dx;
... |
97e34844-687e-4c17-a395-462ffd4ddbcd | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Foul other = (Foul) obj;
if (fouler == null) {
if (other.fouler != null)
return false;
} else if (!fouler.equals(other.fouler))
retur... |
c3a841a9-d204-4bc4-addd-7acd2b5f6c20 | 9 | private void calculaTipoPagamento() {
PedidoDao pDao = new PedidoDao();
pDao.abreConnection();
List<Pedido> pedidos = pDao.listaPedidosPorCaixa(caixa.getIdCaixa());
pDao.fechaConnection();
if (pedidos != null && !pedidos.isEmpty()) {
double totalDinheiro = 0;
... |
91f6bed9-211e-4843-954f-28fcd6169b47 | 0 | public static void main(String[] args) {
int a = 0, b = 1;
System.out.println(a == b); // false
System.out.println(a != b); // true
System.out.println(a < b); // true
System.out.println(a <= b); // true
System.out.println(a >= b); // false
} |
2a718d5d-d716-41f2-8c45-0f9da4ebf9b3 | 1 | public float getImageHeight() {
if(texture != null) {
return (float)texture.getImageHeight();
}
else {
System.err.print("RoyalFlush: Texture2D.getImageHeight - No texture has been loaded.\n");
return -1.0f;
}
} |
db5fd225-d6e6-4b71-a578-74e67a7054e4 | 4 | public String execute() throws CrashException {
try {
Registry registry = LocateRegistry.getRegistry(destPeer.IPaddr, destPeer.serverPortno);
ServerSideInterface stub = (ServerSideInterface) registry.lookup("ServerSide");
return stub.ElectionSetTurnHolder(this.turnHolder);
} catch (java.rmi.ConnectExceptio... |
072f3023-8ee1-4f8b-ab12-2593a1e997a2 | 0 | @Override
public String getEmail() {
return super.getEmail();
} |
1a3ea40f-1ba5-4656-949b-6a47ec2c2cd4 | 5 | public void run()
{
// Applies the running state, and notifies all listeners that the
// service has started.
notifier.proxy().onServiceStart(this);
// While the service is in a runnable state...
while (!stopped)
{
boolean valid = true;
// If event processing is active...
if (activeEvents) ... |
376b5a3d-a932-4941-8ade-33efe22bfa20 | 1 | public void registerResource(Resource r) {
if (!resources.containsKey(r.getId())) {
resources.put(r.getId(), r);
}
} |
98816d7b-0545-4be3-8dbe-19ed76a5b937 | 0 | public Worker () {
//initial settings
results = new int[VALUE_ITERATIONS_NUMBER];
this.keyboard = new BufferedReader(new InputStreamReader(System.in));
System.out.println(MSG_WELCOME);
//start
this.lifeCycle();
} |
992d650b-acd7-4fd7-b036-893a502b9483 | 3 | public void actionPerformed(ActionEvent e) {
String[] args = getArgs(e);
String channel = args[0];
String sender = args[1];
String source = args[2];
String message = args[3];
if (isCommand("agdq", message))
{
if (acebotC... |
5574c30c-30ec-4778-b008-e690d974cc7f | 3 | private void copyAnimations() {
standAnim = new Animation[PlayerEntity.STAND_ANIMATIONS.length];
for(int i = 0; i < PlayerEntity.STAND_ANIMATIONS.length; i++)
standAnim[i] = PlayerEntity.STAND_ANIMATIONS[i].copy();
moveAnim = new Animation[PlayerEntity.MOVE_ANIMATIONS.length];
for(int i = 0; i < PlayerEntity... |
e6046e0e-e87c-4b74-b032-82106332c8e9 | 6 | public static GamePhase makeGamePhase(PhaseTag tag, Player playerOne,
Player playerTwo, Engine engine) {
switch (tag) {
case ATTENTION:
return new AttentionGamePhase(playerOne, playerTwo, engine);
case MEDITATE:
return new MeditateGamePhase(playerOne, playerTwo, engine);
case HEARTRATE_H... |
3e76399d-fda3-477b-9fb4-cad9bbee923c | 2 | public boolean mouseWithin(int x, int y) {
//System.out.println(rectAL.size());
for(int i = 0; i < rectAL.size(); i++) {
// the "highness" of y is inversed due to top being considered y = 0
if(x >= rectAL.get(i).getULX() & x <= rectAL.get(i).getURX() & y <= rectAL.get(i).getDLY()... |
15ada54d-ebc8-4933-acdf-009d1ddf7faf | 2 | public void draw(Graphics2D g) {
if(highlighted)
g.setColor(Color.RED);
else
g.setColor(Color.BLACK);
if(border)
g.draw(theBox);
g.drawString(text, X, Y+height/2);
} |
40d5d339-09e9-4e9c-a39b-999abad58bc6 | 2 | public boolean doTransformations() {
StructuredBlock last = flowBlock.lastModified;
return super.doTransformations()
|| CombineIfGotoExpressions.transform(this, last)
|| CreateIfThenElseOperator.createFunny(this, last);
} |
8121b865-12b9-4f80-adc0-79d946408c71 | 9 | static public void startMethod(int methodNumber, Object o, com.github.danfickle.cppToJavaRpcSvrLibrary.Connection conn) throws Exception {
java.lang.Object internal = (java.lang.Object) o;
switch (methodNumber) {
case 1: { /* public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException... |
246d6e49-f7e9-43c0-9fe2-0b227e602a5e | 7 | static public String doubleToString(double d) {
if (Double.isInfinite(d) || Double.isNaN(d)) {
return "null";
}
// Shave off trailing zeros and decimal point, if possible.
String s = Double.toString(d);
if (s.indexOf('.') > 0 && s.indexOf('e') < 0 && s.indexOf('E') < 0) {
... |
7edb44a6-8f92-4c20-995b-8079f6052137 | 1 | public void visit_if_acmpne(final Instruction inst) {
stackHeight -= 2;
if (stackHeight < minStackHeight) {
minStackHeight = stackHeight;
}
} |
92f5fec9-6a71-4634-9454-99538f9339bf | 8 | private void startSocketHandler() {
socketHandler = new Thread() {
@Override
public void run() {
XMLStreamReader parser = connection.getParser();
try {
while(socketHandler != null) {
if(parser.next() != XMLStreamConstants.START_ELEMENT) continue;
socketHandlerLatch = new CountDownLatch... |
87ca0fe7-6d91-47ef-adf4-b3e9e87e2166 | 9 | public JSONObject getCityList(String filter, Integer countryCode, Integer regionCode, Integer limit, Integer offset, String orderBy, String direction) {
StringBuilder uriBuilder = new StringBuilder("/api/getCityList?") ;
log.debug("Setting API Token") ;
uriBuilder.append("AUTH_TOKEN="+apiToken) ;
if (filter!=... |
470d917a-9147-432a-85bf-478eb8b51a8c | 5 | private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed
name=(String)jComboBox2.getSelectedItem();
try {
try {
try {
try {
... |
9ac8e982-fc4a-42f1-9d67-07ad680ee023 | 8 | @Override
public double getCategoryJava2DCoordinate(CategoryAnchor anchor,
int category,
int categoryCount,
Rectangle2D area,
Rectan... |
fd561da7-f7e5-4231-a454-229d034e5836 | 8 | private RouteLabel labelReroute(int startNode, int endNode, int maxRisk){
// Initialization
RouteLabel bestRoute = null; // Keeps track of so far best finishing label
ArrayList<RouteLabel> activeLabels = new ArrayList<RouteLabel>(); // Keeps track of all labels
RouteLabel initialLabel = new RouteLabel(startNode... |
b355dce4-7089-4328-b3d7-f9c1c1189db7 | 9 | @Override
public boolean equals(final Object obj) {
if (obj == null)
return false;
if (obj == this)
return true;
if (obj.getClass() != getClass())
return false;
PartialCKDoor otherPCKDoor = (PartialCKDoor) obj;
if (new EqualsBuilder()
.append(isValid, otherPCKDoor.isValid)
.append(isDouble, ... |
2e422b96-eefb-4491-b54f-c517be9dae79 | 1 | public void attacked(int dmg) {
subtractHitpoints(dmg);
if (getHitpoints() <= 0) {
setToDead();
// tower.addKills(1);
}
} |
1143e529-a263-4b22-a9b7-ddbce0611c02 | 4 | public static void main(String[] args) {
long start = System.nanoTime();
int count = 0;
for (int i = 1; i <= 10000; i++) {
BigInteger newNum = BigInteger.valueOf(i);
boolean isLychrel = true;
for (int k = 0; k < 50; k++) {
newNum = reverseAdd(newNum);
if (isPalindromic(newNum)) {
isLychrel =... |
beddf6cc-bdf0-4ddd-bca8-1e3e95b2f9ce | 3 | private void RemoverEscola_ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RemoverEscola_ButtonActionPerformed
try {
String escola = Escola_ComboBox2.getSelectedItem().toString();
a.RemoverEscola(escola);
EscolaSelecionada_Label.setText("nenhuma");
... |
57fd87d7-542c-4ebd-901a-b3dd82c7bb2b | 4 | public byte[] unpack() {
if (compression == 0) {
return buffer;
}
byte[] result = new byte[size];
if (compression == 1) {
try {
DataInputStream stream = new DataInputStream(new BZip2CompressorInputStream(
new ByteArrayInputStream(buffer)));
stream.readFully(result);
stream.close();
} ... |
74acb6ad-b130-4c77-8a31-484fc8ff9d7d | 9 | void headerOnMouseDoubleClick (Event event) {
if (!isFocusControl ()) setFocus ();
if (columns.length == 0) return;
CTableColumn[] orderedColumns = getOrderedColumns ();
int x = -horizontalOffset;
for (int i = 0; i < orderedColumns.length; i++) {
CTableColumn column = orderedColumns [i];
x += column.width;
i... |
9cd73057-59d4-4b55-8c54-9a49e59c0312 | 4 | public UsuarioBean type(UsuarioBean oUsuarioBean) throws Exception {
try {
oMysql.conexion(enumTipoConexion);
Boolean isAlumno = oMysql.typeUser("alumno", "usuario", "alumno.id_usuario", "alumno.id_usuario", oUsuarioBean.getId());
Boolean isProfesor = oMysql.typ... |
ace58478-2652-49db-924f-9efc558c141c | 3 | @Override
public void run() {
ByteBuffer buf = ByteBuffer.allocate(8196);
try {
int bytesRead = channel.read(buf);
while (bytesRead > 0) {
bytesRead = channel.read(buf);
System.out.println(bytesRead);
}
} catch (IOException ... |
8c18119b-f4b0-402a-85b0-f73bd914c331 | 9 | public void method389(boolean flag1, int i, int j, String s, int k)
{
aBoolean1499 = false;
int l = i;
if(s == null)
return;
k -= anInt1497;
for(int i1 = 0; i1 < s.length(); i1++)
if(s.charAt(i1) == '@' && i1 + 4 < s.length() && s.charAt(i1 + 4) == '@')
{
int j1 = getColorByName(s.substring(i1 + 1, i1 + 4... |
5f3d71c9-400d-4d68-a3a9-7e6db2471fdf | 7 | protected static void initFilters(boolean loader, Vector<String> classnames) {
int i;
int n;
String classname;
Class cls;
String[] ext;
String desc;
FileSourcedConverter converter;
ExtensionFileFilter filter;
if (loader)
m_LoaderFileFilters = new Vector... |
930fdae9-e015-496c-a7f8-70ab2586b5f7 | 5 | public NexTServer(){
try {
serverSocket = new ServerSocket(port_number);
}
catch (IOException e)
{System.out.println(e);}
while(true){
try {
clientSocket = serverSocket.accept();
for(int i=0; i<=max_clients; i++){
if(t[i]==null)
{
(t[i] = new clientT... |
44df7ffb-75f8-4253-9a11-a55074dab5aa | 8 | public void convertGeodeticToGeocentric(ProjCoordinate p) {
double Longitude = p.x;
double Latitude = p.y;
double Height = p.hasValidZOrdinate() ? p.z : 0; //Z value not always supplied
double X, Y, Z; // output
double Rn; /*... |
2db21796-8164-4c43-901d-91378550f3f8 | 2 | public static int fibonacci (int n) {
if (n == 0)
return 0;
if (n == 1)
return 1;
return fibonacci(n - 1) + fibonacci(n - 2);
} |
93b1a42a-d0b0-4c89-91cf-03199e9a5eef | 6 | static final int method2253(int i, int i_0_) {
anInt3814++;
int i_1_ = -124 % ((i_0_ - 55) / 63);
int i_2_ = 0;
if (i < 0 || i >= 65536) {
i_2_ += 16;
i >>>= 16;
}
if ((i ^ 0xffffffff) <= -257) {
i >>>= 8;
i_2_ += 8;
}
if (i >= 16) {
i_2_ += 4;
i >>>= 4;
}
if ((i ^ 0xffffffff) <=... |
acbdab7d-c4e3-49bf-a336-48120e8419d7 | 5 | public static int getIndex(String type) {
switch (type) {
case "water_turbine":
return WATER;
case "wind_turbine":
return WIND;
case "solar_plant":
return SOLAR;
case "nuclear":
return NUCLEAR;
... |
0c8ee85b-e16d-4c99-af68-be675e8a0837 | 8 | @Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((created == null) ? 0 : created.hashCode());
result = prime * result
+ ((emagVoucherId == null) ? 0 : emagVoucherId.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prim... |
c9803df5-e6ac-48b7-adaf-7be8f0461c07 | 5 | public List<Integer> preorderTraversal1(TreeNode root) {
if (root == null) return list;
Stack<TreeNode> st = new Stack<TreeNode>();
Queue<TreeNode> qu = new LinkedList<TreeNode>();
st.add(root);
while(!st.isEmpty())
{
root = st.pop();
qu.add(root);
if (root.right != null) st.push(root.rig... |
27206175-a1d6-4682-968f-bc6d8a2810db | 6 | public int ladderLength(String start, String end, HashSet<String> dict) {
if (start == null || end == null) return 0;
if (start.equals(end)) return 1;
dict.remove(start);
dict.add(end);
Queue<String> queue = new LinkedList<String>();
Queue<Integer> levelqueue = new LinkedList<Integer>();... |
0adcff8e-f073-425c-a372-fc825e64520c | 9 | private void prebox(TypeDesc from, TypeDesc to) {
// Wouldn't it be cool if I could walk backwards in the instruction
// list and insert the new-dup pair before the value to box was even
// put on the stack?
switch (from.getTypeCode()) {
default:
break;
case ... |
9a41fc2a-114b-418d-9ebb-d91902cb81f7 | 3 | private <T> int altezza(AlberoBin<T> a) {
int h1 = 0, h2 = 0;
if (a.sin() != null) h1 = 1 + altezza(a.sin());
if (a.des() != null) h2 = 1 + altezza(a.des());
return h1 > h2 ? h1 : h2;
} |
2be188c8-aa5f-4533-a9b6-c0d7613ddc65 | 3 | private void tastendruckBenachrichtigen(String ergebnis) {
try {
for (Object o : tastaturListener) {
try {
o.getClass().getMethod(TASTE, String.class)
// .invoke(o, "" + ev.getKeyChar());
.invoke(o, "" + ergebnis);
} catch (Exception e1) {
... |
b78bbd5b-8eea-4b98-b773-d69fdd6da9e7 | 6 | public static final boolean contentEquals( Object c1, Object c2 ) {
if( c1 == null && c2 == null ) return true;
if( c1 == null || c2 == null ) return false;
if( c1 instanceof byte[] && c2 instanceof byte[] ) {
return equals( (byte[])c1, (byte[])c2 );
}
return c1.equals(c2);
} |
c17d5050-6429-4e17-80c6-20ad32e5b1fc | 9 | public void locateEntities(EntitySet set, Point point) {
radarSize.setSize(this.size);
radarSize.width -= insets.left + insets.right;
radarSize.height -= insets.top + insets.bottom;
int x = point.x - insets.left;
int y = point.y - insets.top;
set.clear();
Point point1 = new Point();
int dist2 = Inte... |
e10908e6-3d52-4672-b29c-c933121eafd5 | 7 | @SuppressWarnings("resource")
public void promptPatientFieldSelection(DataSource ds, int health_care_no) {
while (true) {
Patient patient = ds.getPatient(health_care_no);
if (patient == null) {
System.out.println("Could not find a patient with Health Care No. " + health_care_no);
return;
}
... |
b50ed8d8-93f1-4a90-8850-262a69a0f269 | 4 | private void RealizeOsServicosPrincipais () {
int flag = 0;
for (int i = 0; i < numeroGeracoes; i++) {
if ( flag == 1) {
minhaGeracao = new MinhaGeneracao(taxaSelecao, tamanhoPopulacao, mecanismoSelecao, mutacao.getPopulacaoDaPonteControladora());
... |
e67417f1-9cb4-40d2-8dfd-8afce4994f16 | 2 | public static boolean isPalindrome(int n) {
String numString = Integer.toString(n);
String revString = "";
for (int i = numString.length() - 1; i >= 0; i--) {
revString = revString + numString.charAt(i);
}
if (numString.equals(revString)) {
return true;
}
return false;
} |
e89aed3a-5ef5-402f-8206-727d6c521061 | 2 | @Override
public void executeAll() {
try {
for(IUsersCommand c : _usersCommandLog) {
c.setExecutor(users);
c.execute();
}
} catch (CommandException e) {
System.err.println("Error: Illegal/Invalid command was stored in UsersCommandLog");
e.printStackTrace();
}
} |
868f6efa-4a07-4683-9ec0-48195ae619c2 | 7 | private void update() {
if (!ball.isMoving()) {
ball.setX(board.getX() + (board.getWidth() - ball.getWidth()) / 2);
} else {
if (ball.getX() <= 0 || ball.getX() >= WIDTH) {
System.out.println("bang!");
ball_vx = - ball_vx;
}
if (ball.getY() <= 0) {
System.out.println("bang!");
ball_vy = ... |
89763bb4-da9a-420c-9ca8-67dc307c6916 | 7 | public static GetSampleImage_Result getSampleImage(Database database, GetSampleImage_Param params) {
Logger.getLogger(API.class.getName()).log(Level.FINE, "Entering API.getSampleImage()");
GetSampleImage_Result result;
try {
ValidateUser_Result vResult = validateUser(databas... |
523e9515-1842-4376-ae82-80079e4c0ef7 | 0 | @Before
public void setUp() throws Exception {
validadorUsuarios = new ValidadorUsuarios();
} |
aa3e6ca4-54ae-4e1e-90ed-38931502c1c7 | 5 | public static double getSimilarDegree(String str1, String str2)
{
//���������ռ�ģ�ͣ�ʹ��mapʵ�֣�����Ϊ���ֵΪ����Ϊ2�����飬����Ŷ�Ӧ�������ַ��еij��ִ���
Map<String, int[]> vectorSpace = new HashMap<String, int[]>();
int[] itemCountArray = null;//Ϊ�˱���Ƶ������ֲ����������Խ�itemCountArray�����ڴ�
//... |
1ee4f2e4-c1ae-4f65-9b39-7f258343ade9 | 0 | public String getEWord(){
return eWord;
} |
403c82e8-39e3-4839-aec1-ca9e0a7cd471 | 3 | public void run(){
DataOutputStream output;
DataInputStream input;
GameManager.gameIsRunning = true;
int[] message = new int[2];
int[] action = new int[2];
try {
output = new DataOutputStream(socket.getOutputStream());
input = new DataInputStream(socket.getInputStream());
GameManager.endRoom... |
9b1323c8-baf8-4786-8731-36cb7d5a8753 | 8 | public void paintComponent(Graphics g)
{
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < columns; j++)
{
Point point = new Point(j, i);
if (maze.isOpen(point))
drawBox(j, i, SIDE, openColor, g);
if (maze... |
55c84fc0-0d99-4766-a793-44dd71a5a098 | 2 | private void fireClientConnectEvent(ConnectEvent evt) { //throws Exception {
connected = true;
Object[] listeners = connectEventListenerList.getListenerList();
for (int i=0; i<listeners.length; i+=2) {
if (listeners[i]==ConnectListener.class) {
((ConnectListener)listeners[i+1]).OnConnectEvent(... |
9e188f63-4f34-4e60-8ad2-df6f6df66222 | 1 | private static double narrow(final double d)
{
if (d < 0)
{
return d - 0.1;
}
else
{
return d + 0.1;
}
} |
3601d491-259d-4735-ae8b-799b6f1e0377 | 1 | public StockCUDialog() {
this.setTitle("Stock manager");
this.setModal(true);
this.setResizable(true);
this.setSize(new Dimension(300, 300));
this.setLocationRelativeTo(this.getRootPane());
this.setLayout(new BorderLayout(5, 5));
JPanel pnlMain = new JPanel();
this.add(pnlMain, BorderLayout.CENTER);
... |
feb31c29-ea92-40ce-8dbe-312e768e6cce | 9 | private void solve() {
for (int i = 0; i < vertices.length; i++) {
vertices[i].setDistance(Integer.MIN_VALUE);
vertices[i].setPrevious(null);
}
vertices[0].setDistance(0);
PriorityQueue<Vertex> queue = new PriorityQueue<>(Arrays.asList(vertices));
while (!queue.isEmpty()) {
Vertex<Integer> v = queue.... |
83713daa-d7b8-46c1-aa79-4694ba97b002 | 4 | private void setImageDefault(Attributes attrs) {
// find the value to be set, then set it
if (attrs.getValue(0).equals("starttime"))
imageDef.setStartTime(Integer.valueOf(attrs.getValue(1)));
else if (attrs.getValue(0).equals("endtime"))
imageDef.setEndTime(Integer.valueOf(attrs.getValue(1)));
else if (at... |
65d88a75-65eb-4047-8023-f80187fb354c | 2 | public static void handleTransferFailed(SerializableTransferFailed pack) {
SelectionKey key;
String seller;
if (pack.commandInfo.isEmpty()) {
Server.loggerServer.error("The packet doesn't contain seller's name");
return;
}
seller = pack.commandInfo.get(0);
key = Server.registeredUsersChannels.... |
b5bf851c-d3f9-4981-8e71-dfe284e2e785 | 7 | public static void floodFill(int r, int c) {
for (int i = 0; i < dir.length; i++)
if (r + dir[i][0] >= 0 && r + dir[i][0] < n + 2
&& c + dir[i][1] >= 0 && c + dir[i][1] < m + 2
&& map[r + dir[i][0]][c + dir[i][1]] != 'X'
&& map[r + dir[i][0]][c + dir[i][1]] != '#') {
map[r + dir[i][0]][c + dir[i... |
800c0349-1eed-426b-80dd-a5c2121b49cd | 8 | public int func_27297_a(StatCrafting par1StatCrafting, StatCrafting par2StatCrafting)
{
int var3 = par1StatCrafting.getItemID();
int var4 = par2StatCrafting.getItemID();
StatBase var5 = null;
StatBase var6 = null;
if (this.slotStatsBlockGUI.field_27271_e == 2)
{
... |
5eda7835-8af5-4a07-a2ba-8a767ff243bb | 7 | public static void main(String[] args) {
final int limit = 10000;
final SieveOfAtkin sieve = new SieveOfAtkin(limit);
final ArrayList<Integer> list = sieve.run();
final HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
for (int p : list) {
map.put(p, ma... |
9c4df74d-7994-4199-af4b-5be9797d0802 | 3 | @Override
public Loja ListById(int id_loja) {
Connection conn = null;
PreparedStatement pstm = null;
ResultSet rs = null;
Loja l = new Loja();
try{
conn = ConnectionFactory.getConnection();
pstm = conn.prepareStatement(LISTBYID);
pstm.setIn... |
5b54a3ff-3219-43e6-8e23-3dd740a90b55 | 0 | @BeforeClass
public static void setUpClass() {
} |
a349eb70-5756-4e25-9e71-5099fab080e3 | 7 | public static String[] readfileTxt(String fileName){
String [] s = new String [0];
String direccion = System.getProperty("user.dir")+"/"+ fileName;
// Try to load the file (archive)
File archive;
FileReader fr = null;
BufferedReader br = null;
try {
// Open the file and create B... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.