method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
76d4c18d-06cd-4d72-b35e-dd933aed75f4 | 7 | public boolean shellCollideCheck(Shell shell)
{
if (deadTime != 0) return false;
float xD = shell.x - x;
float yD = shell.y - y;
if (xD > -16 && xD < 16)
{
if (yD > -height && yD < shell.height)
{
world.sound.play(Art.samples[Art.SAMP... |
3acbc4e7-8e63-4bec-9bfa-9a09ff94ac16 | 5 | public ArrayList<Object> findObject(String command, String keywords)
throws RemoteException {
if(command.equals("userFind")){
return new UserController().find(keywords);
}
if(command.equals("accountFind")){
return new FinanceController().find(keywords) ;
}if(command.equals("getCustomer")){
ArrayList... |
6f03961e-690f-4544-b0d9-79ed9a9dfc72 | 5 | public static void scanWorlds()
{
for(World a:Bukkit.getWorlds())
{
if(!AddressBook.containsWorld(a.getName()))
{
AddressBook.writeAddress(a.getName(), new ChevronWorld(a.getName(),a.getName(),"NONE",1,(a.getName().equals("world_nether")? true:false),false,false,false));
File f = new File(data + "/wo... |
e0fcbb41-cf27-4770-9c74-1b8cbb627409 | 3 | public Ink_Calculator(List<RecParametr> params) {
if(params != null)
for(RecParametr rp : params)
{
InkMass im = new InkMass(rp);
if(im.GetColor() != record_ink.Unknown)
inks.add(im);
}
} |
8bf8d7e3-e954-4b9f-9d40-64e404c43589 | 3 | public Object invokeMethod(Reference ref, boolean isVirtual, Object cls,
Object[] params) throws InterpreterException,
InvocationTargetException {
if (isWhite(ref))
return super.invokeMethod(ref, isVirtual, cls, params);
MethodIdentifier mi = (MethodIdentifier) Main.getClassBundle()
.getIdentifier(ref)... |
00a811fd-0724-4b78-bc89-5e1a5a431de6 | 3 | public int rocRLookback( int optInTimePeriod )
{
if( (int)optInTimePeriod == ( Integer.MIN_VALUE ) )
optInTimePeriod = 10;
else if( ((int)optInTimePeriod < 1) || ((int)optInTimePeriod > 100000) )
return -1;
return optInTimePeriod;
} |
e92eedda-f19c-40ff-b553-e368013ba2c0 | 7 | public void setInstances(Instances inst) {
m_Instances = inst;
String [] attribNames = new String [m_Instances.numAttributes()];
for (int i = 0; i < attribNames.length; i++) {
String type = "";
switch (m_Instances.attribute(i).type()) {
case Attribute.NOMINAL:
type = "(Nom) ";
break... |
29f211bb-f0d8-4947-ad74-cf20313e641e | 6 | @Override
public ProvaEscrita alterar(IEntidade entidade) throws SQLException {
if (entidade instanceof ProvaEscrita) {
Connection connection = ConnectionFactory.getConnection();
ProvaEscrita provaEscrita = (ProvaEscrita) entidade;
String sql2 = "delete from candidato_... |
e0b9d703-a184-4751-8a69-cd0f453e3b8c | 2 | public boolean opEquals(Operator o) {
if (o instanceof ConstOperator) {
Object otherValue = ((ConstOperator) o).value;
return value == null ? otherValue == null : value
.equals(otherValue);
}
return false;
} |
e6555030-d481-4b32-b60f-4672056a0832 | 0 | public String getHtmlCode() {
return htmlCode;
} |
a85d9922-bfc4-497a-bded-36302cdf5dfd | 0 | public int run()
{
qSortBase(aInt, 0, aInt.length-1);
return 0;
} |
ee0863df-99ce-4bd7-9857-46931aeac1b0 | 9 | public static void finalizeOneClass(Stella_Class renamed_Class) {
{ Object old$Module$000 = Stella.$MODULE$.get();
Object old$Context$000 = Stella.$CONTEXT$.get();
try {
Native.setSpecial(Stella.$MODULE$, renamed_Class.homeModule());
Native.setSpecial(Stella.$CONTEXT$, ((Module)(Stella.... |
20789f70-025b-4594-9a80-d1b32af1ae54 | 8 | public Object invoke(Bindings bindings, ELContext context, Class<?> returnType, Class<?>[] paramTypes, Object[] paramValues) {
Object base = prefix.eval(bindings, context);
if (base == null) {
throw new PropertyNotFoundException(LocalMessages.get("error.property.base.null", prefix));
}
Object property = getP... |
aa7d8d08-3e47-4cc0-951d-bc2a7723089a | 5 | public Card chooseSeven() {
CardArray sevenCards = new CardArray();
for (Card i : cards)
if (i.num() == 7)
sevenCards.add(i);
if (sevenCards.isEmpty())
return null;
Card.Suit mSuit = Agonia.findDominantSuit(sevenCards);
for (Card i : sevenCards)
if (i.suit() == mSuit) {
cards.remove(i);
... |
4a174217-f751-443f-8570-7632379e7bf1 | 3 | private List<String> getNumCombinations(String phoneNum) {
List<String> numCombinations = new ArrayList<String>();
// Get Position Combinations for Inserting, each combination may form a new set of words
List<String> insertPointList = getInsertPositions(phoneNum.length() - 1);
Iterator<String> itorator = inse... |
ecf4e435-da3c-4a20-a624-b8736402d222 | 1 | public List<T> getNextValues() {
List<T> values = new ArrayList<T>();
for (int i = 0; i < count(); i++) {
values.add(getNextValue(i));
}
return values;
} |
814d541c-e166-439e-8915-ed4b92e584f4 | 2 | public void handleAbilityButtonClick(Ability ability) {
panel.getMatchInfoPanel().setSurrenderPending(false);
if (inProgress && selectedTile != null) { //Ignore ability button clicks when the match is over.
setRange(new Range(this, selectedTile, ability));
}
} |
a772cfb9-c8d2-4fe2-9e7b-8e34f56c6877 | 8 | final void method3669(Canvas canvas, int i, int i_90_) {
do {
try {
anInt8025++;
Object object = null;
if (canvas == null || canvas == ((NativeToolkit) this).aCanvas7925)
object = anObject8020;
else if (aHashtable8014.containsKey(canvas))
object = aHashtable8014.get(canvas);
if (object == nu... |
4eddcd42-bd12-486e-b969-8a0d0e2ea2d6 | 7 | public void transferImage()
throws IOException, DBException
{
VersionDTO version = getVersion();
if (null == version)
throw new IllegalStateException("Cannot transfer an image: target version is not set");
if (version.isImageAvailable())
return;
InputStream image = null;
Logger log = log();
log.fin... |
9f5fcdaf-e483-423f-969d-d847422c7430 | 3 | private static int rank_recursive(int[] N, int key, int hi, int lo) {
if (lo > hi) {
return KEY_NOT_FOUND; //base case
}
int mid = findMidpoint(hi, lo); // find the midpoint
if (key < N[mid]) { // the key is in the lower half so lower the upper bound
hi = --mid;
rank_recursive(N, key, hi, l... |
d1c7d6e9-fa2e-4743-8013-412bec654435 | 9 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String action = request.getParameter("action");
String nextPage = "showResult.jsp";
String message = "action nulo o invalido";
try {
HttpSession session = request.getSession();
switch (ac... |
6861b000-a506-4cfa-8a73-99023f08483f | 4 | public void run(){
try {
synchronized(this){
BufferedReader br=new BufferedReader(new InputStreamReader(socket.getInputStream()));
String fileName=null;
while((fileName=br.readLine())!=null){
break;
}
System.out.println(fileName);
File receivedFile=new File(fileName);
... |
460f85fa-895f-4da7-a848-2a4ba84ddcee | 9 | public static void main(String[] args) throws Throwable{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0, N = parseInt(in.readLine().trim()); i < N; i++) {
in.readLine();
StringTokenizer st = new StringTokenizer(in.readLine().trim());
... |
22812baf-dc45-4266-82b5-bf3078faeb14 | 2 | private OutputChannels(int channels)
{
outputChannels = channels;
if (channels<0 || channels>3)
throw new IllegalArgumentException("channels");
} |
98627d25-029b-4e8b-b5cd-5c53dd7411e0 | 1 | public static void printTable(double itemArray[][], int itemNumber[], double unitValue[], DecimalFormat df){
System.out.println("This is the current Item Set: ");
System.out.println("Item " + itemNumber[0] + ": $"+itemArray[0][0]+" | "+itemArray[1][0]+" lbs");
System.out.println("Item " + itemNumber[1] + ": $"+it... |
5809ca25-bb1f-4cb9-8d3b-f813f21576e1 | 0 | public int getRandom() {
return this.random;
} |
2b5f63a6-47e2-4a67-bbba-8e6a1e133e8e | 3 | private static Collection<Circle> filterFinalScoreCheck(ShortImageBuffer edgeImage, Collection<Circle> input)
{
Collection<Circle> output = new ArrayList<>(input.size());
for (Circle original : input)
{
List<Circle> permutations = new ArrayList<>(input.size());
for(in... |
f92f7c1b-7295-4711-b79e-452f9ec9226b | 2 | public State stateAtPoint(Point point) {
State[] states = getAutomaton().getStates();
// Work backwards, since we want to select the "top" state,
// and states are drawn forwards so later is on top.
for (int i = states.length - 1; i >= 0; i--)
if (point.distance(states[i].getPoint()) <= StateDrawer.STATE_RAD... |
3a57be38-5793-42b3-bead-5e3676d4c089 | 8 | @Override
public String howMuch(String item, String client, String market) {
logger.info("Calculating expected time to delivery. " +
"item " + item + ", client " + client + ", market " + market);
// business rule: delivery date depends of the market last letter
// business rule: delivery date depends of ... |
6d4d1a59-1e67-4c47-baff-9f3eeba9bc27 | 9 | public static void main(String[] args) {
Scanner in = null; // for input
PrintStream out = null; // for output
BasicMapADT<String, Entry> concord = new BSTBasicMap<String, Entry>();
// the concordance
File inFile = null; //store input fil... |
e3d4ec51-1bd7-4fa4-8a14-7a499a3c31c2 | 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... |
7049864a-b181-472a-921c-1316e86adfb7 | 9 | public void giveHint(String target, String hint)
throws HanabiException
{
if (hintsLeft <= 0) {
throw new HanabiException("No hints left; discard or play a card instead");
}
int seatNumber = Integer.parseInt(target);
if (seatNumber < 0 || seatNumber >= seats.size()) {
throw new HanabiException("Invali... |
820ae766-bc4c-477a-9e6f-905ec73b5dc1 | 7 | public void affiche(Graphics g) {
if (type == TYPE.HEAL) {
g.setColor(Color.green);
String text = "+" + Integer.toString(value);
int width = g.getFont().getWidth(text);
int height = g.getFont().getHeight(text);
if (perso != null)
g.draw... |
b73805bc-b0ee-4b63-b313-f6268068f989 | 4 | private String getFormatString(TextureFormat _format) {
switch(_format){
case PNG: {
return "PNG";
}
case JPG: {
return "JPG";
}
case GIF: {
return "GIF";
}
case TGA: {
return "TGA";
}
default: {
//TODO: Error, texture type not supported. Return error texture.
return... |
b386178f-9485-4b86-b131-9d337fafdf77 | 3 | public static synchronized ArrayList<Stock> addStock(String tickername,
ArrayList<Stock> stocks) {
stocks = DataReader.getStocks();
double price = 0;
tickername = tickername.toUpperCase();
try {
price = PriceUpdater.price(tickername);
} catch (Exception e) {
System.out.println("The tickername you ent... |
a6dca3b1-e29b-4f03-a56c-5c43fa7f933d | 1 | public IVideo createVideo(String path) {
if(getExtension(path).equals("wmv")) {
return new VideoWMV(path);
}
else {
return null;
}
} |
8da0617d-67e6-4e2e-aeda-7dfbccfed86a | 5 | public Font(String s){
location = new File(s);
if(!location.exists()){ Util.ERRORCODE2();}
else {
File[] listOfFiles = location.listFiles();
for (int i = 0; i < listOfFiles.length; i++)
{
try {
String files = listOfFiles[i].getName();
if (files.length() > 4 && files.substring(files... |
44b04c10-6e7c-4b90-9ca9-b1cac11d86e4 | 2 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
String usuario = tf_usuario.getText();
String pass = tf_pass.getText();
Usuario u = new Usuario();
u.setRut(Integer.parseI... |
69db803b-aadf-46e1-a7ba-3c7cb3d9c3dd | 4 | protected void read(File file) throws IOException{
String tempFile = "";
if(file.isDirectory()){
if(file.list().length==0){
}else{
String files[] = file.list();
for (String temp : files) {
File fileDelete = new File(file, temp);
read(fileDelete... |
1de8f64a-aab3-4e1b-adf4-57300780f952 | 1 | public boolean tieneSiguiente(){
boolean resp = false;
if(siguiente != null)
resp = true;
return resp;
} |
a6eaafa3-3a72-43ad-a421-a7406ebd0c30 | 7 | public void unmutePlayer(Client c, String name){
if (!isOwner(c)) {
c.sendMessage("You do not have the power to do that!");
return;
}
if (clans[c.clanId] != null) {
for (int j = 0; j < clans[c.clanId].mutedMembers.length; j++) {
for(int i = 0; j < Config.MAX_PLAYERS; i++) {
if (Server.playerHand... |
4a41f209-53bc-490c-9709-9ebbd9d3a110 | 2 | private void userTypeJComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_userTypeJComboBoxItemStateChanged
// TODO add your handling code here:
String selected_user_type = String.valueOf(userTypeJComboBox.getSelectedItem());
/**
*If the the user type selected is a ... |
80b589af-202d-4345-984a-4a3693b6d32a | 3 | public boolean interact(Level level, int x, int y, Player player, Item item, int attackDir) {
if (item instanceof ToolItem) {
ToolItem tool = (ToolItem) item;
if (tool.type == ToolType.shovel) {
if (player.payStamina(4 - tool.level)) {
level.add(new ItemEntity(new ResourceItem(Resource.flower), x * 16 ... |
a3266a28-ce06-41ae-b1da-8b4d391c74a1 | 7 | @Override
public void unInvoke()
{
if(canBeUninvoked())
{
if(affected instanceof MOB)
{
final MOB mob=(MOB)affected;
if((buildingI!=null)&&(!aborted))
{
if(messedUp)
{
if(activity == CraftingActivity.LEARNING)
commonEmote(mob,L("<S-NAME> fail(s) to learn how to make @x1.",... |
24154e4b-8718-424a-9740-413558eb0958 | 1 | @Override
public synchronized void destroy() throws Exception {
if (isActive()) doStop();
closeConnections();
doDestroy();
} |
c9ae8793-2d11-45e5-8344-bd07eacbc2a1 | 8 | public static void main (String args[])
{
boolean homefound = false;
String localgame = "";
int na = 0;
int move = 0;
while (args.length > na)
{
if (args.length - na >= 2 && args[na].startsWith("-h"))
{
Global.home(args[na + 1]);
na += 2;
homefound = true;
}
else if (args[na].starts... |
5596050b-9660-4248-b72c-4d86289f76e7 | 4 | private int selectInvertColors(invertColorsAvailable chanelInvert, Color color){
int colorReturn=0;
switch (chanelInvert){
case RGB:
colorReturn=super.colorRGBtoSRGB(new Color(255-color.getRed(),
255-color.getGreen(), 255-color.getBlue(),color.getAlph... |
45a78738-d6b0-4956-819b-506e279e0670 | 5 | @Override
public boolean wipeTable(String table) {
Connection connection = open();
Statement statement = null;
String query = null;
try {
if (!this.checkTable(table)) {
this.writeError("Error at Wipe Table: table, " + table + ", does not exist", true);
return false;
}
statement = connection.cr... |
93c6697c-7b96-427b-9e5f-545bd8714c44 | 9 | private void gameKeyReleased(int key){
switch(key){
case KeyEvent.VK_W:
//UP
break;
case KeyEvent.VK_S:
//DOWN
break;
case KeyEvent.VK_A:
//LEFT
mainModel.wilbert.stopMoveLeft();
break;
case KeyEvent.VK_D:
//RIGHT
break;
case KeyEvent.VK_SPACE:
//JUMP
mainModel.wilbert.getBo... |
5950f39a-fc6b-4a58-82d0-6653d9738900 | 0 | public int size() { return N; } |
4eee2f3d-83f9-44d3-90b9-f9eb506d2257 | 6 | private RequestDispatcher goSetting(HttpServletRequest request, HttpServletResponse response) throws ServletException{
if(request.getParameter("oldpwd")!=null&&request.getParameter("newpwd")!=null&&request.getParameter("newpwd2")!=null){
try {
if(DB.passwordCorretta(((Utente)request.... |
1637603c-3c9d-477e-b796-926a525c993f | 8 | public int converterParaInteiro(String romano) {
int numeroConvertido = 0;
int tamanhoString = romano.length();
int iteracao = 0;
while(true){
if(romano.charAt(iteracao) == 'M')
numeroConvertido += 1000;
if(romano.charAt(iteracao) == 'D')
numeroConvertido += 500;
if(romano.charAt(iteraca... |
94fec532-2538-4c9c-870b-840f2ed7cd71 | 0 | public Node getNode() {
return this.node;
} |
964dac7c-e55a-4265-9382-a01fe5a3987c | 2 | @Override
public int insertOne(String strTabla) throws Exception {
ResultSet oResultSet;
java.sql.PreparedStatement oPreparedStatement;
int id = 0;
try {
String strSQL = "INSERT INTO " + strTabla + " (id) VALUES (null) ";
oPreparedStatement = oConexionMySQL.pr... |
cbcb7457-76dc-42ea-bf44-e92b859c7b1e | 6 | void savefile()
{
// FrontEnd.statuswindow.append("Saving File...\n");
FrontEnd.appendToPane(FrontEnd.statuswindow,"Saving File...\n",Color.BLACK);
//frontend.FrontEnd.statuswindow.setCaretPosition(frontend.FrontEnd.statuswindow.getText().length());
int id = FrontEnd.EditorPane.getS... |
4dda8f3f-ed54-48bd-b271-2893a82196c4 | 3 | private static void winCondition() {
// If the alien and the predator are on the same node
if (ship.getAlienNode().equals(ship.getPredatorNode())) {
// prints to the status bar
uigui.changeWinStatus(" The Alien Wins");
... |
242f2fca-b42f-435f-a01f-a00e484be880 | 3 | void printFrequency(String filename){
HashMap m=new HashMap();
char c[]=new FileReadHelper().readFile(filename);
for(int count=0;count<c.length;count++){
if( m.containsKey(String.valueOf(c[count]))){
Integer value = (Integer) m.get(String.valueOf(c[count]));
value=value+1;
m.put(String.valueOf... |
cb11528e-8701-47ca-896d-fd6d0a8cf8d2 | 8 | private boolean check() {
if (N == 0) {
if (first != null) return false;
}
else if (N == 1) {
if (first == null) return false;
if (first.next != null) return false;
}
else {
if (first.next == null) return false;
}
... |
b91578b0-de34-4882-9d04-740d6cda7ca4 | 0 | public int tapes() {
return tapes;
} |
db97cc1a-58de-4f09-af94-5d6ddc952cef | 2 | public static boolean isTypeCollection(Class<?> type) {
return (type != null && isAssignable(type, Collection.class));
} |
24495384-b987-406f-8e3f-1c6508cc66c9 | 8 | static int f(int p, boolean[] v, int c){
if(p==vis.length)return prim(v)+c;
boolean[] cp=new boolean[v.length];
int min=MAX_VALUE;
for(int i=0;i<v.length;i++)
for(int j=0;j<v.length;j++)
if(v[i]&&vis[p][j])min=Math.min(min,mAdy[i][j]);
for(int i=0;i<v.length;i++)cp[i]=v[i]||vis[p][i];
return Math.min... |
29e9611f-5ba8-4e4e-bc5e-3c9d7543b1bc | 3 | @Override
public boolean isMine(String command) {
if (super.isMine(command)) {
if ((command.indexOf("[") == -1) || (command.indexOf("]") == -1)) {
error = hint;
return false;
}
jsonStr = command.substring(command.indexOf("["), command.lastI... |
5e305f4f-3525-4369-98e9-a3c033917b3b | 6 | public static List<String> getFileNames(String prefix, String suffix, String language,
String country, String variant) {
List<String> result = new ArrayList<String>(4);
if (!language.equals("")) {
language = "_" + language;
}
if (... |
8731c10e-208f-4cc8-9a48-d64f50c1eff3 | 0 | public FileIOException(Exception e, String name)
{
super(e, name);
} |
e6fd5edd-d091-47d5-9dd6-2a511ff41a25 | 9 | public void run() {
if (!mClient.connect()) {
return;
}
Scanner scan = new Scanner(System.in);
boolean running = true;
while(running) {
StringBuilder sb = new StringBuilder();
sb.append(sUserActions[0]);
for(int i=1; i<sUserActions.length; i++) {
sb.append(", ");
sb.append(sUserActions[i... |
8ff299bd-5b6d-404f-a63a-bfe62b4ac4a4 | 3 | public boolean checkIfHasSameName(String uuid, String metaname){
if(plugin.getAnimalData().getString("Farmer."+ uuid + ".Animals") == null){
return true;
}
Set<String> auuids = plugin.getAnimalData().getConfigurationSection("Farmer."+ uuid + ".Animals").getKeys(false);
for(String auuid : auuids){
String c... |
acad720b-226a-43cb-af2e-e70058bfc2e0 | 5 | public void discoverChildren() {
GsSong[] songs=null;
if(album!=null)
songs=album.getSongs();
if(artist!=null)
songs=artist.getSongs();
if(playlist!=null) {
File f=new File(playlist.saveFile());
if(useFile)
songs=readFile(f);
else {
songs=playlist.getSongs();
savePlaylist(songs,f);... |
667bb839-2c8c-4478-b2bd-c63cb4fe1512 | 6 | @SuppressWarnings("unchecked")
private List<List<Gate>> getLayersOfGates(List<Gate> gates) {
List<List<Gate>> layersOfGates = new ArrayList<List<Gate>>();
initMaps(gates);
int totalNumberOfInputs = circuitParser.getNumberOfInputs();
/*
* Loop to run through each list in our MultiMap, first runs through all... |
a7fe53dd-b8e8-4e01-9f43-950a96ca565f | 7 | @Override
public void actionPerformed(ActionEvent event)
{
if (!event.getSource().equals(back))
{
try
{
Item item = (Item) inventory.getSelectedValue();
int indexNumber = inventory.getSelectedIndex();
int itemNumber = item.getIDNumber();
if... |
653995f7-d982-4c23-a215-b8f55ac552da | 4 | private Mark makeMark0(HashMap table, int pos,
boolean isBlockBegin, boolean isTarget) {
Integer p = new Integer(pos);
Mark m = (Mark)table.get(p);
if (m == null) {
m = new Mark(pos);
table.put(p, m);
}
... |
fe8f8c9b-5c88-4c60-a075-9c7242721294 | 8 | public Connection createConnection() {
if (use_MySQL) {
try {
Class.forName("com.mysql.jdbc.Driver");
cn = DriverManager.getConnection("jdbc:mysql://" +
plugin.getConfig().getString("dbPath"),
plugin.getConfig().getStri... |
15f410c8-3743-4983-8f74-eb996a793933 | 6 | private void loadPositions(Path baseDir) throws IOException {
Path provinceDefinitionsPath = getFilePath(MapFile.POSITIONS, baseDir);
Pattern pattern = Pattern.compile("(\\d+)=");
Map<Integer, Province> provincesById = getProvincesById();
try(BufferedReader reader = Files.newBufferedRea... |
2bff2011-cf8b-46b8-a267-2cd16f230d1a | 0 | @Override
public void mouseReleased(MouseEvent e) {
isMouseDown = false;
} |
380aff04-8574-47ee-964e-736667f34847 | 1 | public OfflinePlayer getStoreOwner(Chest chest){
if(chest==null)
return null;
return stores.get(chest).getOwner();
} |
56c04c05-6dfc-4154-ad79-1159aabeea8c | 3 | public synchronized void init() throws IOException {
int nPieces = new Double(Math.ceil((double)this.totalLength /
this.pieceLength)).intValue();
this.pieces = new Piece[nPieces];
this.completedPieces = new BitSet(nPieces);
this.piecesHashes.clear();
logger.debug("Analyzing local data for " + this.getN... |
ac30a578-1f9b-4a2a-b861-1f6bf2409e2b | 1 | @Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
processRequest(request, response);
} catch (Exception ex) {
Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex);
... |
ebf40095-5217-47e3-9373-ee5d16eddd72 | 4 | public static int longestValidParentheses(String s) {
int maxLen = 0, last = -1;
Stack<Integer> lefts = new Stack<Integer>();
for (int i=0; i<s.length(); ++i) {
if (s.charAt(i)=='(') {
lefts.push(i);
} else {
if (lefts.isEmpty()) {
... |
fc70f966-5097-4c14-b1c3-28372515825c | 5 | private File search(File current, FileFilter filter) {
if (current.isDirectory()) {
File[] expected = current.listFiles(filter);
if (expected != null) {
if (expected.length > 0) {
// found
return expected[0];
} else {
for (File f : iterateOver(current)) {
File found = search(f, fi... |
30285b60-5bb6-4a65-94d0-bd4318bdf2cb | 7 | private byte[] crypt_raw(byte password[], byte salt[], int log_rounds) {
int rounds, i, j;
int cdata[] = (int[])bf_crypt_ciphertext.clone();
int clen = cdata.length;
byte ret[];
if (log_rounds < 4 || log_rounds > 31)
throw new IllegalArgumentException ("Bad number of rounds");
rounds = 1 << log_rounds;
... |
7aa6f5e5-9751-4aeb-80d1-00c673daca83 | 7 | /* */ public void handleDirection(int targetX, int targetY)
/* */ {
/* 75 */ double hitX = this.hitCheck.getX2();
/* 76 */ double hitY = this.hitCheck.getY2();
/* */
/* 78 */ if (this.y < hitY) {
/* 79 */ if (this.x > hitX) {
/* 80 */ if (Math.abs(this.x - hitX) > Math.ab... |
e49ef040-3f41-4542-a8cb-21713cfdb4ef | 1 | private static long makelong(byte[] x) {
long y = 0L;
for(int i = 0; i < x.length; i++) {
y += ((long)x[i]) << (8*i);
}
return y;
} |
8e4c9680-48e5-4105-83e1-9cd280cf80e2 | 6 | public boolean deleteNode(E data) {
BinaryTreeNode<E> node = findNode(data);
if (node == null) {
return false;
}
if (node.left == null && node.right == null) {
// Deleting the leaf node
replaceNodeWithChild(node, null);
} else if (node.left == ... |
6e977c68-5f03-4d8d-8cc6-6f2a3b371f77 | 5 | int dinicDfs(int[] ptr, int[] dist, int dest, int u, int f) {
if (u == dest)
return f;
for (; ptr[u] < ady[u].size(); ++ptr[u]) {
Edge e = ady[u].get(ptr[u]);
if (dist[e.t] == dist[u] + 1 && e.f < e.cap) {
int df = dinicDfs(ptr, dist, dest, e.t,
Math.min(f, e.cap - e.f));
if (df > 0) ... |
9513830d-a5a2-4049-b2a3-993baaed05ee | 5 | private void dfs(EdgeWeightedDigraph G, int v) {
onStack[v] = true;
marked[v] = true;
for (DirectedEdge e : G.adj(v)) {
int w = e.to();
// short circuit if directed cycle found
if (cycle != null) return;
//found new vertex, so recur
e... |
3d15af06-4b5d-4b96-aff3-4366f31e145a | 2 | public void loadFromFile() throws Exception{
String filename = "Girl.bin";
File file = new File(filename);
FileInputStream fis = new FileInputStream(file);
ObjectInputStream ois = new ObjectInputStream(fis);
try{
Object temp = ois.readObject();
if(temp.getClass().getName().equals("Girl")){
ghead = (... |
07b2ff04-fb84-467d-bea6-50ef0274612c | 0 | public void setRound(int round)
{
this.round = round;
notifyListeners();
} |
901ac75e-896d-43f2-b26f-09662eddf053 | 0 | public void mouseReleased(MouseEvent e)
{
} |
d962e036-a0d8-4337-8d4e-bcf85ceb483d | 3 | public boolean contains(E target) {
DoubleLinkedListElement tmp = head;
for (int i = 0; i < size(); i++) {
if(tmp!=null && tmp.data.equals(target)) return true;
tmp = tmp.nextElement;
}
return false;
} |
292727bf-a8db-4d38-80f6-fe7332db261f | 8 | public Object scalar() //to fetch single value
{
ResultSet rs=null;
Object s=null;
try {
rs=ps.executeQuery();
if(rs.next())
{
s=rs.getObject(1);
}
}catch(Excepti... |
bf5ef96e-256a-481e-a16e-7b55a7c8b380 | 2 | public boolean addAll(Collection<? extends Car> c) {
if((c.size() + list.size()) > maximum){
return false;
}
list.addAll(c);
return true;
} |
b9f91b7e-f55a-493f-af9a-dc4318efa0ce | 0 | public CheckResultMessage checkSum4(int i,int j){
return checkReport1.checkSum4(i,j);
} |
cc746c71-3b0d-42a0-87a1-c452bde3e4d8 | 7 | public boolean equals(Object _other)
{
if (_other == null) {
return false;
}
if (_other == this) {
return true;
}
if (!(_other instanceof BillDetailsPk)) {
return false;
}
final BillDetailsPk _cast = (BillDetailsPk) _other;
if (billId != _cast.billId) {
return false;
}
if (u... |
11cb4283-137b-4105-8028-d2090e280438 | 6 | public boolean getBoolean(String key) throws JSONException {
Object object = this.get(key);
if (object.equals(Boolean.FALSE)
|| (object instanceof String && ((String) object)
.equalsIgnoreCase("false"))) {
return false;
} else if (object.equals... |
40da18a7-b2d4-454e-ba21-3c75613fd80f | 7 | private void AddTextElementToRulesList(TranscriptionRulesElement textElement)
{
//At first we need to validate whether the rule element has the minimum required data.
if (textElement!=null && textElement._text.length()>0)
{
if (_rules==null)
{
//If this is the first rule in the list:
_rules = textE... |
c3436336-6cfa-4be4-9706-f9b5a0cf11a5 | 9 | @Override
public void paintComponent(Graphics g) {
// lancement de la musique de fond
SoundEffect.MUSIC.playLoop();
super.paintComponent(g);
g.drawImage(backgroundImage, 0, 0, getWidth(), getHeight(), this);
int nbLosers = 0;
int winner = 0;
for(int i = 0; i < p... |
da7b4bfa-6dd6-4001-8da3-59fbacd82ce3 | 6 | public void quickSort(Integer[] values, int start, int length) {
// Check for empty or null array
if (values == null || values.length == 0) {
return;
}
if (length == 0 || (start - length) == 0) {
return;
}
int p = pivot.ChoosePivot(values, start, length - 1);
int i = partition(values, p, length);
... |
6597acab-c636-40d8-be9a-c234dd1a2919 | 8 | public boolean rotate(Polyomino poly){
//Allows for wall kicks
for (int i=0; i<=poly.getLength()/2; i=(i<=0)?(-i+1):(-i)){
boolean canRotate=true;
for (Point loc:poly.getRotateAndTranslateLocs(i,0)){
if (loc.y<0 || loc.x<0 || loc.x>=fWidth ||
... |
678dc3f5-373a-40d9-8b68-3138fb1860d2 | 0 | public SignedInfoType getSignedInfo() {
return signedInfo;
} |
f931bcfb-7a05-4ebe-948b-f5fd4873dd51 | 1 | private void SaveTimestampDiffsToFile(HashMap<Integer, String> hashMap) {
try (
OutputStream file = new FileOutputStream("timestamps.ser");
OutputStream buffer = new BufferedOutputStream(file);
ObjectOutput output = new ObjectOutputStream(buffer);) {
o... |
a8f09fb7-9785-4185-880a-dd2b53641bf6 | 2 | public static void process(String s, int durationInMillis) {
if(!process)
return;
try {
Thread.sleep(durationInMillis);
} catch (InterruptedException e) {
// ignore
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.