method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
a46bfcd1-7c37-4ddd-8db0-f04b02f3b9cc | 4 | private int partition(char[] arr, int left, int right) {
char pivotEle = arr[(left + right) / 2];//just pick the middle one
while (left <= right) {
while (arr[left] < pivotEle)
left++;
while (arr[right] > pivotEle)
right--;
if (left <= right) {
swap(arr, left, right);
left++;
right--;... |
d253c51d-f916-4a40-8006-d7144346ad2e | 1 | public static String trimExtension(String text, String separator) {
int index = text.lastIndexOf(separator);
if (index == -1) {
return text;
} else {
return text.substring(0, index);
}
} |
5accb855-0afa-4369-a52d-590e5f3fec20 | 0 | @Before
public void setUp() {
} |
617fd5b7-b294-4c56-9657-45103ee81996 | 8 | private Content processParamTags(boolean isNonTypeParams,
ParamTag[] paramTags, Map<String, String> rankMap, TagletWriter writer,
Set<String> alreadyDocumented) {
Content result = writer.getOutputInstance();
if (paramTags.length > 0) {
for (int i = 0; i < paramTags.le... |
49e085aa-3e3e-4d8c-9467-50d8c69be11e | 9 | public static BufferedImage gaussianFilterWithDepthMap(File file) {
// Get depthMap
DepthImage depthImage = new DepthImage(file);
if (!depthImage.isValid())
return null;
BufferedImage depthMap = toGrayScale(depthImage.getDepthMapImage());
BufferedImage originImage = depthImage.getOriginalColorImage();
Bu... |
1cc0dfd1-59f8-46ff-b0d1-bdfe961aaa54 | 7 | public void think() {
List<MouseEvent> mouseEvents = board.getMouseEvents();
//System.out.println("MOUSEVENTS: " + mouseEvents.size());
if(mouseEvents.size() > 0) {
MouseEvent e = mouseEvents.get(0);
//System.out.println("Clicked: " + e.getX() + "-" + e.getY());
int x = e.getX() / (int)Chess.SQUARE_PIXEL... |
c3324bc5-0631-48b0-b436-4b1e8a1dfe42 | 4 | public static DoorDirection makeFromChar(char initial) {
switch(initial) {
case 'U':
return UP;
case 'D':
return DOWN;
case 'L':
return LEFT;
case 'R':
return RIGHT;
default:
return NONE;
}
} |
83b93e3d-8596-4bac-90bb-153d2aef5f56 | 7 | public void expandsLeaf(Coordinate coord) {
Coordinate subCoord;
for (int i = 0; i < 4; i++) {
subCoord = coord.copy();
switch (i) {
case 0:
subCoord.moveNorth();
break;
case 1:
subCoord.moveEast(dimension);
break;
case 2:
subCoord.moveSouth(dimension);
break;
case 3:
s... |
f3d6d729-646f-4c35-a913-2db6798b8027 | 8 | public synchronized boolean setLevel(String str,int level){
//返回是否拥有这个属性 如果有则返回true 没有就返回false
//如果没有 会自动为你添加属性
boolean has = false;
for (int i = 0; i < getLoreSize() ; i++) {
String line = getString(i);
if(line.contains(str)) {
if(line.contains(": ")... |
3876df14-06e0-4a71-b4d9-c50cf4126cfe | 6 | public Object invokeAdvice(Method method, Object invoker) throws Throwable
{
Object result;
final long tid = Thread.currentThread().getId();
final ThreadMXBean bean = ManagementFactory.getThreadMXBean();
MethodInfo caller = null;
if (Cpu.getInstance().getThreadProf... |
9c044743-6ba1-477a-8c63-ccd663b58308 | 5 | @Override
public void execute(CommandSender sender, String worldName, List<String> args) {
this.sender = sender;
if (worldName == null) {
error("No gate given.");
reply("Usage: /gworld setweather <worldname> <sun|storm>");
} else if (args.size() == 0) {
error("No weather given.");
reply("Usage: /g... |
725eb951-b7de-4206-ae61-6f929ace99d0 | 3 | public List<String> getNextLink() {
if (inFile == null) {
openFile();
}
if (open) {
try {
return inFile.readLine();
} catch (IOException ex) {
closeFile();
Logger.getLogger(ReadSimpleLi... |
7e4d3812-aa9b-431b-81c6-abd91eb00001 | 3 | public static DayTypeEnumeration fromString(String v) {
if (v != null) {
for (DayTypeEnumeration c : DayTypeEnumeration.values()) {
if (v.equalsIgnoreCase(c.toString())) {
return c;
}
}
}
throw new IllegalArgumentException(v);
} |
5b75c9b2-eeb4-460f-8806-87224b4e6599 | 9 | private int[] getNumbers () {
boolean numberBegin = false;
boolean addDigit = false;
boolean isDigit;
int numberBeginPos = -1;
int[] vector;
int position = 0;
char eachChar;
String vector1;
String temporary = "";
vector = new int[50];
... |
60979b30-b5e2-4825-ae56-3c0eb0a4c946 | 2 | public static void main(String[] args){
List<String[]> list = new N_Queens().solveNQueens(4);
String[] board;
for(int i = 0; i< list.size();i++){
board = list.get(i);
for(int j = 0 ; j < board.length;j++)
System.out.println(board[j].toString());
... |
05e1e029-9b76-418b-b7c7-60189c382a37 | 0 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
} |
2b04e591-87e8-4e9d-87e6-3fc80b27e151 | 9 | void populateWinPanel(){
setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
panelWidth = getWidth();
panelHeight = getHeight();
labelWidth = panelWidth/(BrackEm.bracketData.getTotalRoundsW() + 1); // Include final winner (+1)
int startingLabels = 2*(BrackEm.bracketData.getSecondPlayersW... |
c808cb2b-4afc-47ae-9694-e451d701de4a | 8 | public Client_Part2(){
Socket socket = null;
ObjectOutputStream out = null;
ObjectInputStream in = null;
try {
Object[] input = new Object[4];
Object[] output;
socket = new Socket("127.0.0.1", 4444);
out = new ObjectOutputStream(socket.get... |
67acbe83-54d3-45bd-ac61-5738af709e2e | 5 | @Override
public void render() {
if(previousScreen != null && previousScreen instanceof GameScreen){
GameScreen prevGameScreen = (GameScreen) previousScreen;
if(!prevGameScreen.outTransitionFinished()){
prevGameScreen.renderOut(Gdx.graphics.getDeltaTime());
return;
}
else{
previousScreen = nu... |
8015f36a-034a-42ec-b0e4-1f7f4f50dd2f | 6 | private void addFileMenu() {
JMenuBar jb = this.getJMenuBar();
if (jb == null)
jb = new JMenuBar();
JMenu menu = new JMenu("file");
JMenuItem newItem = new JMenuItem("new simulation ...");
saveItem = new JMenuItem("save");
saveAsItem = new JMenuItem("save as");
JMenuItem openItem = new JMenuItem("ope... |
722b4b3d-305f-4355-9412-4e2062ed98aa | 1 | private boolean shouldCollide(PositionChangedObservable o) {
ShouldCollideWithPowerFailureVisitor visitor = new ShouldCollideWithPowerFailureVisitor(o);
for(PositionChangedObservable e : hoveringElements)
e.accept(visitor);
return visitor.shouldCollide();
} |
c09aa9b8-99da-4095-b92f-a5be5f40fa5d | 9 | public static ClassData getPrimitiveClassFor(TypeType type) {
switch (type) {
case BOOLEAN: return boolClassData;
case BYTE: return byteClassData;
case CHAR: return charClassData;
case SHORT: return shortClassData;
case INT: return intClassData;
... |
d820311b-4624-4191-8498-cd7ba94d3a76 | 8 | private ByteBuffer createQueue(String queueName, String address) {
ClientConnectionLogRecord record = new ClientConnectionLogRecord(
address, SystemEvent.QUEUE_CREATION,
"Received request to create queue " + queueName + " from "
+ address + ".");
LOGGER.log(record);
Connection conn = null;
try {
... |
6da4078f-6e8d-4f78-b9a5-e4fafe5a968d | 9 | public static PlotData2D setUpVisualizableInstances(Instances testInstances,
ClusterEvaluation eval)
throws Exception {
int numClusters = eval.getNumClusters();
double [] clusterAssignments = eval.getClusterAssignments();
FastVector hv = new FastVector();
Instances newInsts;
Attr... |
0a112a0a-d1de-45e3-a5e4-e6a542e8c1fd | 2 | public Counter nextTurn(Counter lastPlaced, Board b) {
Counter next = Counter.EMPTY;
if (lastPlaced == Counter.BLACK) {
next = Counter.WHITE;
} else if (lastPlaced == Counter.WHITE) {
next = Counter.BLACK;
}
return next;
} |
567468a4-168a-4897-a99f-7c0c2032cd4d | 6 | public int t3Lookback( int optInTimePeriod,
double optInVFactor )
{
if( (int)optInTimePeriod == ( Integer.MIN_VALUE ) )
optInTimePeriod = 5;
else if( ((int)optInTimePeriod < 2) || ((int)optInTimePeriod > 100000) )
return -1;
if( optInVFactor == (-4e+37) )
optInVFact... |
179386bc-eb71-47b0-a897-c4bad01f789e | 2 | public ZoomDataRecord next() {
// Is there a need to fetch next data block?
if (zoomRecordIndex < zoomRecordList.size())
return (zoomRecordList.get(zoomRecordIndex++));
// attempt to get next leaf item data block
else {
int nHits = getHitRegion(selectionRegi... |
e08ba8dc-df95-432f-a529-c7ecdd9ce47c | 4 | private void fechavenceFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_fechavenceFieldKeyTyped
// TODO add your handling code here:
if (!Character.isDigit(evt.getKeyChar()) && evt.getKeyChar() !='-' && !Character.isISOControl(evt.getKeyChar()))
{
Toolkit.getDefa... |
1cae4f3d-6eeb-44fe-91e4-a55ce8fbb3bc | 5 | public boolean addClient(String s){
boolean added = false;
for(byte i = 0; i < maxPlayers; i++){
if(!added){//make sure not to add a person multiple times
if(clients[i] == ""){
clients[i] = s;
added = true; //they've been added.
currentPlayers++;
}
}
}
System.out.println("curre... |
5f400241-4241-4616-a5ae-90d4da397091 | 0 | public void clearSelected() {
selectedNodes.clear();
} |
a012958d-a08d-445f-a253-28008d2e6147 | 4 | public synchronized void broadcast(String message, Player player) {
for (Player client : players) {
if (client == null)
continue;
if (player == client)
continue;
if (client.getUser().getGameSocket() != null)
client.getUser().getGameSocket().sendMessage(message);
}
} |
5b7525b0-2b32-4802-b629-930a8cb11aab | 6 | public void drawInverse(int i, int j) {
i += offsetX;
j += offsetY;
int l = i + j * DrawingArea.width;
int i1 = 0;
int j1 = height;
int k1 = width;
int l1 = DrawingArea.width - k1;
int i2 = 0;
if (j < DrawingArea.topY) {
int j2 = DrawingArea.topY - j;
j1 -= j2;
j = DrawingArea.topY;
i1 += ... |
b0874dcf-9ed6-4451-bad8-602966f0256b | 8 | public static void main(String[] args) {
//创建一个serversocket
try(AsynchronousServerSocketChannel serverSocketChannel = AsynchronousServerSocketChannel.open()) {
//判断是否打开
if (serverSocketChannel.isOpen()) {
//判断支持那些optiosn
Set<SocketOption<?>> socket... |
14859e64-dfa7-427d-bd0d-35eea0489d61 | 4 | public List<String> getFirstDefinition(Collection<PearsonDictionaryEntry> entries) {
List<String> definition = new ArrayList<String>();
for (PearsonDictionaryEntry entry : entries) {
for (PearsonWordSense sense : entry.getSenses()) {
if (sense.getDefinition() != null && !"".equals(sense.getDefinition())) {
... |
80749a69-3b36-41b3-a855-951e19791e41 | 3 | @Override
public Object execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
Contexto oContexto = (Contexto) request.getAttribute("contexto");
//Parte para saber el tipo de usuario
UsuarioBean oUsuarioBean;
oUsuarioBean = (UsuarioBean) request.getSessio... |
6dcf64a0-3a1a-463b-99a7-bed1b985ef56 | 0 | public long getId(){
return id;
} |
5e0b12df-e051-42e2-a17d-6965dfe03424 | 7 | public static void main(String[] args) {
// TODO Auto-generated method stub
ticTACtoe game1 = new ticTACtoe();
game1.table = new char[3][3];
game1.populate();
game1.print();
boolean win = true;
int x1 = 0, y1 = 0;
int x2 = 0, y2 = 0;
int last=0;
System.out.println("You will play against the compute... |
cfd984b0-6e90-46b6-af8b-e5a9aa94b27f | 9 | public static void insert(User currUser, Tables tables, Statement stmt,
String query) {
ResultSet rset = null;
if (query.toLowerCase().contains("users")) {
} else {
Iterator tableIter = tables.getIter();
while (tableIter.hasNext()) {
String table = (String) tableIter.next();
// System.out.pr... |
d3cf1235-2fd6-4d91-8c36-1b92c7290d25 | 1 | public DisjointSet(int n) {
root = new int[n + 1];
for (int i = 0; i < root.length; i++) {
root[i] = i;
}
rank = new int[n + 1];
} |
30dfd4bb-4417-4416-b76b-99dce8bb34f3 | 8 | public boolean equals(Object obj) {
if (obj == this) return true;
if (obj == null) return false;
if (obj.getClass() != this.getClass()) return false;
Picture that = (Picture) obj;
if (this.width() != that.width()) return false;
if (this.height() != that.height()) return... |
7d369bf5-2a2f-43b3-835d-77dc189c7c62 | 3 | private void parseDocument() throws XPathExpressionException {
XPath xpath = XPathFactory.newInstance().newXPath();
NodeList forceList;
NodeList cityList;
NodeList characterList;
Node structure;
Node technology;
Database db = Database.getInstance();
... |
9a5aad50-1a20-4f72-b223-94620d2e121e | 7 | @Override
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
if (gameOver) {
if (keyCode == KeyEvent.VK_F2) {
startGame();
return;
}
}
pt.flag = false;
switch (keyCode) {
case KeyEvent.VK_LEFT:
currentTetro.toLeft();
break;
case KeyEvent.VK_RIGHT:... |
a498d46a-1372-4dc1-ade4-c862110def5b | 8 | public static void main(String[] args) throws IOException {
Scanner in = new Scanner(new File("transform.in"));
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("transform.out")));
int N = in.nextInt();in.nextLine();
char[][] before = new char[N][N];
for (int ... |
f60872fa-f2a3-4595-8274-ad6fd47b6444 | 3 | @Override
public int hashCode() {
int result;
long temp;
result = boxId;
result = 31 * result + (boxDate != null ? boxDate.hashCode() : 0);
temp = amount != +0.0d ? Double.doubleToLongBits(amount) : 0L;
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp... |
5264b5ab-6ba9-4b74-9d34-158b39d1cec6 | 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... |
12d41351-3eb1-40fb-a215-15b755a9f241 | 0 | public ROUI() {
robotInstance = new RORobotInstance();
robotInstance.getDashboardData().addObserver(this);
robotInstance.getJoystickHandler().addObserver(this);
addKeyListener (this);
buildGUI();
} |
8a4a6995-2de1-4365-a9ef-de120058a71a | 9 | public void mouseReleased(MouseEvent e) {
if (e.getModifiers() == MouseEvent.BUTTON1_MASK) {
if (isValidPosition(e.getX(), e.getY())) {
mouseX = e.getX();
mouseY = e.getY();
}
selectObstacle(e.getX(), e.getY());
mouseLeftClick = fal... |
6fe47e46-aba4-462c-97c1-626cfb99656f | 3 | public SignatureVisitor visitInterfaceBound() {
if (state != FORMAL && state != BOUND) {
throw new IllegalArgumentException();
}
SignatureVisitor v = sv == null ? null : sv.visitInterfaceBound();
return new CheckSignatureAdapter(TYPE_SIGNATURE, v);
} |
638e97f5-7736-4903-b83b-f13eda013f54 | 3 | public List<Card> removeOne(List<Card> mutableCards, final List<Card> constCards ) {
List<Card> copyRun = new ArrayList<Card>(constCards);
ListIterator<Card> cardsIterator = copyRun.listIterator();
while(cardsIterator.nextIndex() < copyRun.size() && mutableCards.size() >= 0) {
int potentialmatch = cardsIte... |
314b06f1-ac67-4fa4-a0c3-0607a93429ac | 0 | public CtrlConnexion getCtrl() {
return ctrl;
} |
81b439c0-0595-4a17-8a7b-a62c335aadcb | 9 | static final void method2165(boolean bool, String string) {
anInt6287++;
if (string != null) {
if (string.startsWith("*"))
string = string.substring(1);
String string_0_ = Class285_Sub1.unformatUsername(string);
if (string_0_ != null) {
for (int i = 0;
((i ^ 0xffffffff)
> (Class348_S... |
26f15081-b7d6-479b-8610-901f69b43371 | 3 | public void delAll(String path)
{
File file = new File(path);
if (file.isFile() || (file.list().length == 0)) {
file.delete();
} else {
String[] files = file.list();
for (String f : files) {
System.out.println(file.getPath());
delAll((file.getPath()) + File.separator + f);
... |
6560bc88-2e19-43c1-99b6-2ccd7509870f | 9 | public ArrayList<HashMap<List<Integer>, HashSet<Integer>>> lshBucketA(HashMap<Integer, ArrayList<Integer>> sigList, HashMap<Integer, ArrayList<Integer>> semanList) {
ArrayList<HashMap<List<Integer>, HashSet<Integer>>> lshBuckets = lshBucket(sigList);
for (int j = 0; j < lshBuckets.size(); j++) {
... |
c4031099-312b-425c-a3f8-085675877918 | 0 | public Being split() {
dynamicStats.get(StatType.D_EATEN).addToValue(-30.0);
return new CellCreature(new Point3(pos), constStats, childDynamicStats.clone(), classID);
} |
ea7ae33b-7fb7-414e-a580-8dcd95d05449 | 5 | public void save(){
if(this.getId() != null){
String q = "SELECT id, name " +
"FROM positions " +
"WHERE id = ?";
try {
PreparedStatement statement = Speciality.getConnection().prepareStatement(q,
ResultSet.T... |
1c29b9f6-6904-42a7-b2e0-6128b3376bb9 | 3 | private void printLet(Node t, int n)
{
if (t.getCdr().isNull())
{
t.getCar().print(n+4, false);
System.out.println();
if (n > 0)
{
for (int i = 0; i < n; i++)
System.out.print(" ");
}
t.getCdr... |
9d968eb1-51f1-4f64-b8fd-058c2a0144e4 | 0 | public void add(
int i,
String name,
String find,
String replace,
boolean ignoreCase,
boolean regExp
) {
addName(i,name);
addFind(i,find);
addReplace(i,replace);
addIgnoreCase(i,ignoreCase);
addRegExp(i,regExp);
} |
2f462cac-b9dc-429a-b1d7-c71bb8fe6bf6 | 9 | private long readLong()
{
switch ( type )
{
case MatDataTypes.miUINT8:
return (long)( buf.get() & 0xFF);
case MatDataTypes.miINT8:
return (long) buf.get();
case MatDataTypes.miUINT16:
return (long)( buf.getShort() & ... |
acec542f-ac3c-4535-ba21-ffa5e17e7ac8 | 2 | private int checkInteger(String integer) throws Exception {
try {
int res = Integer.parseInt(integer);
if(res<0)
throw new Exception("Valeur négative interdite");
return res;
} catch (NumberFormatException e) {
throw new Exception("Champ numerique non valide");
} // Integer... |
fc1bd67e-f5e5-4796-baf0-458a5228bb55 | 4 | public void setFieldValue(FieldAccessCommand fac, Object value) throws Throwable {
Object object = ObjectResolver.resolveObjectReference(fac.getObjectName());
System.out.println("Found Object: " + object);
Field field = null;
try {
field = object.getClass().getField(fac.getM... |
5735734e-5e54-4bc3-b3cf-00d8b2c1a7c7 | 9 | public Object getValueAt(int rowIndex, int column) {
if (rowIndex >= hits.size()) {
// Feature row
CDDFeature feature = features.get(rowIndex-hits.size());
switch (column) {
case 0:
return feature.getAccession();
case 1:
return feature.getFeatureType()+" feature";
case 2:
return fe... |
59d2fd7a-49e0-480c-bcd4-5c2d9e063887 | 1 | public String taulukkoTulostusmuotoon(String[] taulukko){
String palautettava = "";
for (int i = 0; i < taulukko.length; i++) {
palautettava += taulukko[i] + "\t";
}
return palautettava.substring(0, palautettava.length()-1);
} |
356eabf8-70df-45e6-bc2d-b599928671e1 | 2 | public void testGetField() {
YearMonth test = new YearMonth(COPTIC_PARIS);
assertSame(COPTIC_UTC.year(), test.getField(0));
assertSame(COPTIC_UTC.monthOfYear(), test.getField(1));
try {
test.getField(-1);
} catch (IndexOutOfBoundsException ex) {}
try {
... |
5fa85824-174c-4656-bbfc-4c085c22b608 | 3 | public void collision(PhysicsCollisionEvent event) {
System.out.println("Ghosty Collision impulse is "+event.getAppliedImpulse());
if (event.getObjectA() == this || event.getObjectB() == this){
if(event.getAppliedImpulse()>50){
playHitSound(event.getPositionWorldOnA(),event.g... |
6bfeeed1-6270-4310-8c78-af0bbcd4d31f | 3 | public static RelatedToEnumeration fromString(String v) {
if (v != null) {
for (RelatedToEnumeration c : RelatedToEnumeration.values()) {
if (v.equalsIgnoreCase(c.toString())) {
return c;
}
}
}
throw new IllegalArgumentException(v);
} |
5c34629c-48da-4a9b-9266-e4d76e3a23bf | 6 | public Integer getValue(int x, int y, int z)
{
VariableResolver resolver = this.resolver.clone();
for (Enumeration<String> e = modifiers.keys(); e.hasMoreElements();)
{
String key = e.nextElement();
resolver.setVariable(key, modifiers.get(key).getValue(x, y, z));
}
resolver.setVariable("xPos", x);
re... |
4270e8cb-2f3d-4732-ba83-80af7223b0dd | 6 | public synchronized void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(BUTTON_NEW_GAME)) {
if (JOptionPane.showConfirmDialog(view,
"Start a new game of the current size?",
"New Game?",
... |
3d6e788a-984b-4c30-9ec5-e0dd15e84f92 | 4 | public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UsermanForm usermanForm = (UsermanForm) form;// TODO Auto-generated method stub
String output ="doneedit";
String login = usermanForm.getLogin();
String password = usermanFor... |
76adfca2-0c8d-4a00-ba6e-22369eafe08d | 7 | public void draw(Graphics g) {
towerFrame.draw(g);
barrelCell.draw(g);
ammoCell.draw(g);
baseCell.draw(g);
/*************************
*** Taarn og knapper ****
*************************/
for(int i = 0; i < towerButtons.size(); i++){
if(i == activeTowerIndex)g.setColor(Colors.red);
else ... |
0ee60bb2-d535-47be-9ae5-741ccf8327e1 | 4 | public void update(float dt) {
music.update(dt);
if (tempSong)
prevSong.update(dt);
Array<Song> rmv = new Array<>();
for (Song s : songsToKill) {
s.update(dt);
if (!s.fading)
rmv.add(s);
}
songsToKill.removeAll(rmv, false);
if(!menus.isEmpty())
menus.peek().update(dt);
} |
36c48f68-ca76-4f15-a902-24fa5314ef0e | 5 | @Override
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
if (args.length == 0) {
Main.courier.send(sender, "requires-argument", "message", 0);
return false;
}
final String text = Edit.join(args, ... |
6e22b012-a5b5-482a-be37-9457daf62543 | 8 | public void setupOverlay(Hashtable<String, Connection> connections)
{
//add all nodes to graph
addNodesToGraph(connections);
List<Connection> connList = new ArrayList<Connection>(connections.values());
//first iteration
for(int i = 0; i < connList.size(); ++ i)
{
int destinationIndex;
if(i == con... |
99dafce0-70cf-42e7-bb74-05fd2c47f449 | 5 | public String interpreterWeatherCondition(String conditionRating){
String weatherCondition = "";
switch (conditionRating){
case "0.0":
weatherCondition = "veryBad";
break;
case "0.25":
weatherCondition = "bad";
break;
case "0.5":
weatherCondition = "ok";
break;
case "0.75":... |
cee1ec5b-2e2e-4ee3-8ac5-1151780a6ef2 | 5 | private static void deleteFile(File file) {
if (file == null || !file.exists()) {
return;
}
// 单文件
if (!file.isDirectory()) {
boolean delFlag = file.delete();
if (!delFlag) {
throw new RuntimeException(file.getPath() + "删除失败!");
} else {
return;
}
}
// 删除子目录
for (File child : file.l... |
7588f8fd-4727-4e96-b1c5-c071a32c256c | 2 | public void doGet(HttpServletRequest request, HttpServletResponse response) {
response.setContentType("text/html");//设置服务器响应的内容格式
// response.setCharacterEncoding("gb2312");//设置服务器响应的字符编码格式。
DButil ab = new DButil();
try {
PrintWriter pw = response.getWriter();
St... |
fb7ab612-7469-43ea-bf97-d248e374e49f | 8 | private void detectEncoding( char[] cbuf, int off, int len )
throws IOException
{
int size = len;
StringBuffer xmlProlog = xmlPrologWriter.getBuffer();
if ( xmlProlog.length() + len > BUFFER_SIZE )
{
size = BUFFER_SIZE - xmlProlog.length();
}
xmlProlog... |
2a8ecea5-08a1-4957-9bb3-4152e8defe0a | 6 | public static void main(String[] args) throws IOException, FileNotFoundException{
long startTime = System.currentTimeMillis();
BufferedReader br = new BufferedReader(new FileReader("knapsack_big.txt"));
String[] split = br.readLine().trim().split("(\\s)+");
int weightCapacity = Integer.parseInt(split[0]);
... |
62b1b5bd-e254-477e-8ec3-dec63a15b1a8 | 0 | public Chlodzenie produkujemyChlodzenie(){
return new ChlodzenieDlaLaptopa();
} |
2340341c-4e40-4229-a3c1-e1c44af77625 | 0 | public int getNeedReport() {
return NeedReport;
} |
43a9b221-fc4b-49a3-a28a-eb4b8b6f4154 | 3 | public static TreeNode commomAncestorWithBinaryTreeHasParent(TreeNode p,TreeNode q){
Map<TreeNode,Boolean> ancestorPath = new HashMap<TreeNode,Boolean>();
while(p.parent != null){
ancestorPath.put(p, true);
p = p.parent;
}
while(q.parent != null){
if(ancestorPath.get(q)){
return q;
}
q = q.pa... |
42b28b76-9d2c-4c40-bde9-6865a2e165d6 | 7 | public static ReplicationResult SendAndRecv2(HttpClient client,
ContentExchange exchange) throws BookStoreException {
int exchangeState;
try {
client.send(exchange);
} catch (IOException ex) {
throw new BookStoreException(
BookStoreClientConstants.strERR_CLIENT_REQUEST_SENDING, ex);
}
try {
... |
6f4d5432-1be1-4242-8ccf-281cdfec626e | 9 | public static void parseAndRegister(Node convertorsNode) {
NodeList nodeList = convertorsNode.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if ("convertor".equals(node.getNodeName())) {
Node aliasNode = node.getAtt... |
3fe05df6-a915-4858-86bb-405d95afac3b | 8 | public static byte[] B64tobyte(String ec) {
String dc = "";
int k = -1;
while (k < (ec.length() - 1)) {
int right = 0;
int left = 0;
int v = 0;
int w = 0;
int z = 0;
for (int i = 0; i < 6; i++) {
k++;
v = B64.indexOf(ec.charAt(k));
right |= v << (i * 6);
}
for (int i = 0... |
24e405ea-e493-4888-936f-56d272fd81e1 | 6 | public void loadCenter(FileSystem fs, Path path, Configuration conf){
SequenceFile.Reader reader ;
try {
reader = new SequenceFile.Reader(fs, path, conf);
IntWritable key = (IntWritable) reader.getKeyClass().newInstance();
FloatArrayWritable value = (FloatArrayWritable) reader.getValueClass().newIn... |
cb284547-297b-4191-8377-397fe3df4812 | 9 | public static void main(String[] args) {
Scanner input = new Scanner( System.in );
int num1 = 0;
int num2 = 0;
int num3 = 0;
int sum = 0;
int product = 0;
int average = 0;
int smallest = 0;
int largest = 0;
System.out.print( "Please enter first integer: ");
num1 = input.nextInt();
Syste... |
d47a521b-7846-46ad-a4b9-7152aaa3a0b0 | 9 | public void putchar(ArrayList<String> ret,char c){
if(c=='1'){
ret.add("");
}
else if(c=='2'){
ret.add("a");
ret.add("b");
ret.add("c");
}
else if(c=='3'){
ret.add("d");
ret.add("e");
ret.add("f")... |
4ee75090-7b1c-4b2d-9699-9d072fab28e2 | 4 | private boolean isDisplayModeAvailable(
int screenWidth, int screenHeight, int screenColorDepth ) {
DisplayMode[] displayModes = this.graphicsDevice.getDisplayModes();
for( DisplayMode mode : displayModes ) {
if( screenWidth == mode.getWidth() && screenHeight == mode.ge... |
a63858bf-e894-4865-b596-fabb5a249022 | 9 | @SuppressWarnings("unchecked")
private void createObjectReceiveServer() {
ServerSocket serverSocket = null;
try {
serverSocket = new ServerSocket(Integer.parseInt(port));
while (true) {
byte[] data = readData(serverSocket);
//convert bytes from socket into an object
if ((data[0] == -84) && (data[... |
f686b224-a0ca-46ee-aa31-a4deea34e80e | 8 | public static void main(String[] args) {
Watch.start();
int lim = 1_000_000;
boolean[] primeTable = Utils.primeTable(lim);
List<Integer> primes = new ArrayList<>();
for (int i = 0; i < lim; i++)
if (primeTable[i]) primes.add(i);
int maxLen = 0, s = 0, maxS = 0... |
b11691b0-54fc-427e-bbde-26930cdf512d | 5 | @EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
Block block = event.getClickedBlock();
Player player = event.getPlayer();
if (!worldmanager.isHiddenWorld(player.getWorld()))
{
return;
}
if (event.getAction().equals(Action.RIGH... |
e2fd3a55-e840-4621-b8f7-c0ade4edccf7 | 8 | public static void main(String[] args) {
byte op = 0;
do{
System.out.print("\n\t***GESTION DE PRESTAMOS*\n1. Agregar Prestamos.\n" +
"2. Pagar cuota.\n3. Ver informacion de prestamo.\n4. Salir.\n" +
... |
55eeeb76-7d72-4af3-af94-f421056aa733 | 7 | public void run() {
Scanner scanner = new Scanner(System.in);
do {
if (level == null) {
if (scanner.hasNextLine()) {
level = scanner.nextLine();
}
message("Enter level: ");
level = scanner.nextLine();
}
program.init(level);
program.run(this);
Integer result = null;
while (resu... |
a1d0f0c7-9df5-4d32-b0da-3307fa363a6b | 3 | public static boolean calcWaterNeeded(double playerGuess) {
boolean result;
if (playerGuess < 0 || playerGuess > 25) {
result = false;
} else {
int berrieEaten = (int) (Math.random() * 15);
System.out.println("Berries Eaten = " + berrieEaten);
d... |
35ede4b8-2a3d-4544-b80d-29db111778e2 | 1 | @Override
public void draw(FrameBuffer buffer) {
buffer.blit(texture, 0, 0, buffer.getOutputWidth() - x, y, width, height, widthDest, heightDest, 0, false);
for(String str : namePrimitives)
primitives.get(str).blit(buffer);
} |
8ea8bd5e-a43e-47f4-a573-fa2b911736db | 4 | @Override
public boolean importData(TransferHandler.TransferSupport dataInfo) {
if (!dataInfo.isDrop()) {
return false;
}
if (!dataInfo.isDataFlavorSupported(DataFlavor.stringFlavor)) {
return false;
}
JList list = (JLis... |
be8ea809-a5fa-492f-af86-a3c51f2789cb | 4 | @Override
public List<Bounty> getOwnBounties(String issuer) throws DataStorageException {
List<Bounty> bounties = new ArrayList<Bounty>();
Set<String> keys = this.config.getConfigurationSection("bounties").getKeys(false);
for (String key : keys) {
try {
int keyVa... |
6368f75f-4176-4d35-9fbf-a1a0e49ca4f2 | 7 | public static void q4(String[] args) throws Exception{
//Question 7.4: Write methods to implement the multiply, subtract, and divide
//operation for integers. Use only the add operator.
SOP("Running q4");
Scanner s = new Scanner(System.in);
SOP("Please Enter two numbers to perform computation on");
SOP2("Nu... |
3feb1bf3-d0fc-442c-9d64-92df369f4aa2 | 9 | public static Method[] getterMethodDrilldown(Class<?> type, String property)
throws NoSuchMethodException {
Class<?> innerClass = type;
Method method;
if (property.startsWith("./")) {
property = property.substring(2);
}
String[] path = property.split("[./]... |
a14cac34-3cac-421c-8ee2-50fcd2c1c721 | 9 | public List<Interval> merge(List<Interval> intervals) {
List<Interval> result = new ArrayList<Interval>();
if (intervals == null || intervals.size() == 0)
return result;
HashMap<Integer, Integer> processedIntervals = new HashMap<Integer, Integer>();
ArrayList<Integer... |
5108ea6e-e20d-4025-8397-f5531dd45168 | 1 | public String encodeFromFile( String rawfile )
{
byte[] ebytes = readFile( rawfile, ENCODE );
return ebytes == null ? null : new String( ebytes );
} // end encodeFromFile |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.