method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
ab7380ac-e181-4952-bbdc-e5c9e9828a0f | 0 | public Version(String version, String majorVersion, String minorVersion) {
super();
this.version = version;
this.majorVersion = majorVersion;
this.minorVersion = minorVersion;
} |
4741380f-2ad6-4db6-87e5-0a0491cad7bc | 8 | public void createJoinGameSocket() {
new Thread("startClient") {
public void run() {
try {
String temp = null;
// Create a new socket connection
clientSocket_ = new Socket(InetAddress.getByName(gameIp_
.getText()), 3913);
// Create the data input and output streams
printOut_ =... |
60a0b710-6752-4030-876e-7d476dea756d | 7 | public static <E> void topKSort(E[] array, Comparator<E> comparator, int k) {
if(k>=array.length){
k = array.length;
}
if(k<0){
throw new UnsupportedOperationException("-k <number> number must be equal or greater than zero.");
}
//k is less than or equal array.length
FourHeap<... |
797dbd82-6e6d-4ac6-a153-9469e7675e8a | 7 | @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
try {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You can only register if you're on the server!");
return true;
}
if (args.length != 2) {
sender.sendMessage(Cha... |
2114f46d-bc18-4252-8c10-edde39eea695 | 3 | @SuppressWarnings("unchecked")
@Override
public T mapRow(ResultSet rs, int rowNum) throws SQLException {
T result = (T) ReflectUtils.newInstance(clazz);
if (result == null) {
return result;
}
initColumnName(rs);
for (String property : columnNameSet) {
Method writeMethod = writeMethods.get(property)... |
169d2aeb-2d69-4625-85d2-8341180da3ac | 1 | public static String genericAPICall(String region, String service, String operation, boolean async, Object[] args)
{
if(!async)
return BaseMethods.genericSyncAPICall(region, service, operation, args);
int id = BaseMethods.genericAsyncAPICall(region, service, operation, args);
return BaseMethods.returnAsyncAPI... |
55553b38-b384-4234-8a0c-00c6cf638c6d | 7 | public ParseByteStream(String systemId, InputStream istream, ParseLog log,
String guessedEncoding, ParseHandler handler) throws ParseException, IOException {
if (log == null) log = DEFAULT_LOG;
//We need to be able to restart the stream if the declared encoding
//is different than our guess, os buffe... |
47df1b2e-d750-458b-bc34-6977e568a10b | 0 | public String getAddress() {
return address;
} |
76e46212-2ad2-4a53-9755-46e7182dc75d | 8 | public void generateUpdatedEntries()
{
_modifiedEntries.clear();
HashSet<String> newEntries = new HashSet<String>();
for (int i = 0; i < 10; i++)
{
OrderEntry orderEntry = null;
int action = _random.nextInt(100);
if (_orderEntries.size() == 0 |... |
c024df62-aa60-4938-8566-4a8816de1b59 | 8 | public boolean moveUnit(Position from, Position to) {
//Moves your unit
if(mapUnit.get(to) == null ) {
if(mapUnit.get(from).isNotArcherFortify() == false) {
return false;
}
else{
mapUnit.put(to, mapUnit.get(from) );
mapUnit.remove(from);
if(mapCity.get(to) != null ) {
if(mapCity.get(to).... |
5f32cdaa-7a5d-4314-9076-f10f143e082e | 6 | public LocationDescription search(String location, String item){
LinkedTransferQueue<LocationDescription> queue = new LinkedTransferQueue<LocationDescription>();
game.get(location).mark();
queue.add(game.get(location));
while(!queue.isEmpty()){
LocationDescription current = queue.remove();
i... |
4ac133e7-b234-4bbc-9a17-ba5e0c01e3f4 | 2 | public static void main(String args[]){
ArrayList<Molecule> children;
Molecule X = new Molecule();
Molecule A = new Molecule(1, X, X);
Molecule B = new Molecule(2, X, X);
Molecule C = new Molecule(3, X, X);
Molecule D = new Molecule(4, new Molecule(A), new Molecule(B));
Molecu... |
950a3fbf-5b31-49e0-a61e-b333c02a1dde | 8 | private void colisao(ServidorCliente cliente, Servidor servidor){
int x, y, h = 40, l;
x = cliente.getPosicao().getX();
y = cliente.getPosicao().getY();
h = cliente.getPosicao().getH();
l = cliente.getPosicao().getL();
// nao passa do chao
if (y > CHAO_Y) {
y = 408;
}
if (y < 408) {
y+=... |
5319997a-ca11-4968-ba4c-be0577f57955 | 5 | public void findSubArray(int[] arrA, int Sum) {
int currSum = 0;
int start = 0;
// idea is to keep adding all the elements to the currSum
// keep checking if the currSum<Sum
// if currSum gets greater than the Sum then start reducing the currSum
// from the beginning of the array using "start"
// if any t... |
afcde4c6-75b6-4419-98c7-04edf62155e7 | 2 | public Type getHint() {
int hint = possTypes & hintTypes;
if (hint == 0)
hint = possTypes;
int i = 0;
while ((hint & 1) == 0) {
hint >>= 1;
i++;
}
return simpleTypes[i];
} |
86a3176d-32f5-4b57-8393-9430a378d9a5 | 8 | public Set<MOB> getEveryoneHere(MOB spareMe, Room R)
{
final Set<MOB> V=new HashSet<MOB>();
if(R==null)
return V;
for(int i=0;i<R.numInhabitants();i++)
{
final MOB M=R.fetchInhabitant(i);
if((spareMe!=null)&&(spareMe==M))
continue;
if((M!=null)
&&(!CMSecurity.isAllowed(M,R,CMSecurity.SecFlag... |
a6a2ead9-4421-41ea-b0e6-5c73803c1740 | 0 | public UndoKeeper getUndoKeeper(){
return myKeeper;
} |
44c634f2-bb48-4859-a78a-fc24852cdded | 2 | public boolean canMoveEnPassant(Board board, Field currentField, Field emptyField) {
return this.validSetupForMove(currentField, emptyField) && emptyField.distanceBetweenRank(currentField) == this.forwardDistance(1) && Math.abs(emptyField.distanceBetweenFile(currentField)) == 1;
} |
b9ba364e-2eaa-4b72-ba66-33983ffc74c8 | 8 | private void readIncomingFlits() {
m_inputPort.readInputFlit();
Flit flit = m_inputPort.peekNextFlit();
if(flit != null) {
flit.setTimeReceived(Simulator.clock());
m_receivedFlits.add(m_inputPort.takeNextFlit());
console("Received flit "+flit);
m_inputPort.incCurrVCCredits();
// Only record ... |
30fa4048-4be2-48a5-a939-2409c1718ef7 | 4 | @CodCommand(
command = "ban",
aliases = {"tempban"},
weight = 70,
usage = {
"§2<command> <Player>§b Ban the given Player"
},
minArgs = 1
)
public boolean ban(CommandSender sender, String[] args) {
int i = 1;
if (args.length < 2 || !APIT... |
1d009d9c-3915-4970-9d9e-5b391b543295 | 0 | public Test(T d, Test<T> n) {
this.data = d;
this.next = n;
} |
06dac1c9-e8d8-4115-a609-13e2190a846d | 9 | private void method38() {
for(int i = -1; i < playerCount; i++) {
int j;
if(i == -1)
j = myPlayerIndex;
else
j = playerIndices[i];
Player player = playerArray[j];
if(player != null && player.textCycle > 0) {
player.textCycle--;
if(player.textCycle == 0)
player.textSpoken = null;
... |
1e9a0379-f31e-4820-9d3f-e675a1ad2843 | 4 | @Override
public ByteBuffer getMessage() {
buffer.clear();
buffer.order(ByteOrder.LITTLE_ENDIAN);
buffer.putShort((short) 0xaaa6); // sig
buffer.putShort((short) 40); // byte len
buffer.put((byte) 1); // rcmNodeId;
buffer.put((byte) 0); // reserved
for (short val : pwm) {
buffer.putShort(val)... |
f0a76319-a735-4d78-864c-80a6a2bd5a0b | 8 | public static boolean batch( WebSocketImpl ws, ByteChannel sockchannel ) throws IOException {
ByteBuffer buffer = ws.outQueue.peek();
WrappedByteChannel c = null;
if( buffer == null ) {
if( sockchannel instanceof WrappedByteChannel ) {
c = (WrappedByteChannel) sockchannel;
if( c.isNeedWrite() ) {
... |
a9417f89-9980-4acd-a89b-763d4b6148d7 | 5 | @Test
public void testSetListenThreadServer() {
LOGGER.log(Level.INFO, "----- STARTING TEST testSetListenThreadServer -----");
boolean flag1 = false;
boolean flag2 = false;
if (server1.getState() == Server.LISTEN) {
flag1 = true;
}
if (flag1) {
... |
e79ee573-6ce9-4fa4-b829-803583a51c6e | 9 | private void paintLinks(Graphics2D g) {
Stroke s = g.getStroke();
Link in, out;
int max = 0;
for (Node n : graph.nodes) {
for (int i = 0; i < n.inLinks.size(); i++) {
in = n.inLinks.get(i);
out = n.outLinks.get(i);
if (out.toNode.id < n.id)
continue;
int total = in.packets.si... |
bb163ec9-7923-498d-9673-b3473d5d9caf | 5 | private boolean canFlow(Level var1, int var2, int var3, int var4) {
if(this.type == LiquidType.WATER) {
for(int var7 = var2 - 2; var7 <= var2 + 2; ++var7) {
for(int var5 = var3 - 2; var5 <= var3 + 2; ++var5) {
for(int var6 = var4 - 2; var6 <= var4 + 2; ++var6) {
... |
43798873-d44c-4a8c-8a78-ca45251b5ba5 | 0 | private void controlPanel(JToolBar bar, final ConvertController controller) {
bar.addSeparator();
bar.add(new AbstractAction("Show All") {
public void actionPerformed(ActionEvent e) {
controller.complete();
}
});
bar.add(new AbstractAction("Create Selected") {
public void actionPerformed(ActionEven... |
9d493333-d396-40bd-a393-5348de1e66a4 | 1 | public void notInteresting() {
if (this.interesting) {
logger.trace("Telling " + this + " we're no longer interested.");
this.send(Message.NotInterestedMessage.craft());
this.interesting = false;
}
} |
4cd7cbec-28d3-4c0e-9328-e08668132054 | 5 | public static void main(String[] args)
{
String server, username, password, command;
RExecClient client;
if (args.length != 4)
{
System.err.println(
"Usage: rexec <hostname> <username> <password> <command>");
System.exit(1);
return... |
b93ec8a4-7af6-4951-ac28-30bde4a1d756 | 8 | private void keresTargyat(Mondat mondat) {
List<String> tVeguSzavak = egyTVeguSzavakatKeres(mondat.getVizsgalandoSzavak());
if (tVeguSzavak.isEmpty()) {
return;
}
List<Szo> potencialisSzavak = new ArrayList<>();
for (String s : tVeguSzavak) {
s = s.toLower... |
e550195a-56ab-4a11-af94-cbb74f283577 | 6 | public static long solveBenchmark( LinearSolver<DenseMatrix64F> solver , int numTrials ) {
rand.setSeed(SEED);
DenseMatrix64F X = new DenseMatrix64F(A.numCols,B.numCols);
RandomMatrices.setRandom(A,rand);
RandomMatrices.setRandom(B,rand);
DenseMatrix64F B_tmp = new DenseMatrix64... |
0ae35fd9-5b7f-4875-a081-53246e5dec9e | 4 | private Selector parseSelector() {
//System.out.println("parseSelector");
Selector node = new Selector();
while(nextIs("dot") || nextIs("lb")) {
switch (showNext().getKind()) {
case "dot":
acceptIt();
Identifier id = new Identifier(expect("ident"));
node.getChain().add(new IdentSelector(id));
... |
3c64255a-83cd-4ac0-bb6b-cece5576cbda | 2 | protected static void exportOutlinerDocument(OutlinerDocument document, FileProtocol protocol) {
// We need to swap in a new documentSettings object so that the changes don't carry over
// to the open document, but are conveyed to the export. We'll put the real object back
// when we're done.
DocumentSettings o... |
c87b87cb-3e13-4ed9-98b5-0cad766b7462 | 6 | final Class318_Sub4 method2386(int i, AbstractToolkit var_ha) {
anInt10111++;
AnimatableToolkit class64
= ((Class318_Sub1_Sub4_Sub2) this).aClass235_10115
.method1668(false, true, i ^ ~0x7f, 2048, var_ha);
if (class64 == null)
return null;
Class101 class101 = var_ha.method3705();
class101.method894((... |
1c96c8fb-bc4a-429e-a5d3-9912d1800965 | 8 | public static int[] getNextPixel(int orientation_index)
{
// RSLV: find a mathematical expression for the switch statement?
int[] dp = new int[2]; // [0]=dx, [1]=dy
switch(orientation_index)
{
case 0:
dp[0] = 1;
dp[1] = 0;
break;
case 1:
dp[0] = 1;
dp[1] = 1;
break;
case 2:
... |
7a80f2f6-5466-4da6-9a21-6eede8b647f1 | 0 | private Combination<Colors> generateAttemptCombination6() {
List<Token<Colors>> attemptTokens = new ArrayList<Token<Colors>>();
attemptTokens.add(new Token<Colors>(Colors.O));
attemptTokens.add(new Token<Colors>(Colors.G));
attemptTokens.add(new Token<Colors>(Colors.Y));
attemptTokens.add(new Token<... |
02039be5-92b8-4294-92be-450c8485ac4e | 3 | Transcript findTranscriptByName(String trName) {
for (Gene gene : genome.getGenes()) {
for (Transcript tr : gene)
if (tr.getId().equals(trName)) return tr;
}
return null;
} |
2c28ce85-d1ea-4e29-92a9-9b75d62a020d | 7 | public static TemporalUnit toTemporalUnit(final TimeUnit units)
{
switch (units)
{
case DAYS:
return ChronoUnit.DAYS;
case HOURS:
return ChronoUnit.HOURS;
case MINUTES:
return ChronoUnit.MINUTES;
case SEC... |
7205a95b-88b9-4dda-ac85-21492b2361ab | 8 | public static void recoverLatest(Player p, String server) {
try {
reconnect();
PreparedStatement stat = con.prepareStatement("SELECT * FROM `inv_slots` WHERE `server` = ? AND `player` = ?");
stat.setString(1, server);
stat.setString(2, p.getName());
stat.execute();
p.getInventory().clear();
... |
634f862a-9df0-485c-bae9-db5eb82c4bd6 | 9 | private void saveSettings()
{
LinkedList<String> settingsContents = new LinkedList<String>();
// Read in the file, replacing the appropriate lines with the new values from the text boxes. Later on, overwrite the file.
try {
BufferedReader ... |
7494de14-b370-4bb8-92e9-59a51bcd3f26 | 2 | public double getWidth() {
if (intervals == null || intervals.size() == 0) {
return 0.0;
}
// TODO check indices here:
return getSubStackWidth(1, intervals.size() - 1);
} |
582f5043-1ca7-445c-8527-3e4caa32afa9 | 7 | @Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
List<?> inputs = (List<?>)
ObjectInspectorUtils.copyToStandardObject(arguments[0].get(), listOI);
if (inputs == null) {
return null;
}
if (evaluator == null) {
Text functionName =
(Text)Obj... |
2deae77f-a759-4fee-99d9-eb009cbd3e93 | 4 | public double determineDirection(int x, int y, int width, int height) {
if(x < 0){
return Math.random()*Math.PI - Math.PI/2;
} else if(x > width) {
return Math.random()*Math.PI + Math.PI/2;
}
if(y < 0) {
return Math.random()*Math.PI;
} else if(y > height) {
return Math.random()*-Math.PI;
}
... |
a7ea3785-807e-4b7f-9cdb-4f91d8ee9b9e | 6 | private Image getImage(String filename) {
// to read from file
ImageIcon icon = new ImageIcon(filename);
// try to read from URL
if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) {
try {
URL url = new URL(filename);
... |
60cbb03d-a8de-42f8-93cf-b77999bd937c | 7 | public String getTestingModeAnswer() {
if (!isSurvey && answer != null)
return answer;
else if (options != null && options.length > 0) {
int numOptions = options.length;
if (getOtherChoice() != null)
numOptions++;
Random rand =... |
d988da62-1fcf-4c61-8260-0eecea66184d | 3 | @Test
public void simpleDecode() throws JAXBException {
// Unmarshall
File file = new File("xml/response_example.xml");
JAXBContext jaxbContext = JAXBContext.newInstance(MaritimeInformationResponse.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
MaritimeInformationResponse response... |
8eb62040-8a2f-4d66-813b-f10f0749450b | 9 | public static <TKey extends TKeyT, TKeyT, TValue1 extends TValueT, TValueT> Map<? super TKey, TValueT> mergeMapWith(Map<TKeyT, TValueT> target, Map<? extends TKey, ? extends TValue1> source, Function<? super TValueT, Function<TValue1, ? extends TValueT>> merger) {
for (Entry<? extends TKey, ? extends TValue1> e... |
f526efb4-fb76-4cde-80b2-987b0f29bc06 | 4 | private void initialize() {
optionItems = new ArrayList<Item>();
ButtonItem i;
StackPanel sp = new StackPanel();
Dimension stackDims = new Dimension(manager.getScreenDims().width/8,3*manager.getScreenDims().height/8);
sp.setDims(stackDims);
sp.setPosition(new Vector((manager.getScreenDims().width - stackDim... |
abfca2a4-63b6-40b7-9894-241e60791e37 | 4 | public boolean equals(Object object)
{
boolean result = false;
if (object != null && object instanceof Building)
{
result = (this.value == ((Building) object).value &&
this.getStartPos().equals(((Building) object).getStartPos()) &&
this.getEndPos().equals(((Building) object).getEndPos()) );
}
r... |
d8b7f6de-65b8-4d4a-bdc3-804c6c146b82 | 9 | public void scrollCellToView(JTable table, int rowIndex, int vColIndex) {
if (!(table.getParent() instanceof JViewport)) {
return;
}
JViewport viewport = (JViewport) table.getParent();
Rectangle rect = table.getCellRect(rowIndex, vColIndex, true);
Rectangle viewRect =... |
acab871d-4856-42aa-974a-24a88a5fcf0a | 0 | public void setHold(int hold) {
this.hold = hold;
} |
e2634524-ebfb-41a5-af79-9955968ca1ac | 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 Taxon)) {
return false;
}
Taxon other = (Taxon) object;
if ((this.taxonVersionKey == null && other.taxonVersion... |
db978713-df0d-4bc5-af4e-ce0972c71b4e | 1 | @Override
public List<ValidateException> validate(String parameter) {
List<ValidateException> validateExceptionList = new LinkedList<>();
final int maxAddressLength = 150;
if (!ValidateUtils.stringMaxLengthValidation(parameter, maxAddressLength)) {
String exMsg = "entered quite ... |
0d5bc8cb-1f1f-40b5-a3b8-46d876a85ea1 | 5 | public static Map loadMapFromCSV(File f) {
BufferedReader reader = null;
Map m = null;
try {
reader = new BufferedReader(new FileReader(f));
String line = reader.readLine();
if (line.startsWith("m ")) {
m = new Map(Integer.parseInt(line.split("... |
5ec7ad9e-b1c4-4183-972a-91645ff3f374 | 5 | public boolean equals(Object o) {
if (!(o instanceof Astronomy))
return (false);
Astronomy a = (Astronomy) o;
if (a.dt != dt)
return (false);
if (a.mp != mp)
return (false);
if (a.yt != yt)
return (false);
if (a.night != nig... |
fc116294-c25e-427d-84f3-487838faeb87 | 3 | public boolean isReducableToLambdaProduction(Production production,
Set lambdaSet) {
ProductionChecker pc = new ProductionChecker();
if (ProductionChecker.areTerminalsOnRHS(production))
return false;
String[] variables = production.getVariablesOnRHS();
for (int j = 0; j < variables.length; j++) {
if (!... |
5be688a8-364a-4540-a636-3c90ef2472c7 | 9 | public String getSchemeSpecificPart()
{
StringBuffer schemespec = new StringBuffer();
if (m_userinfo != null || m_host != null || m_port != -1)
{
schemespec.append("//");
}
if (m_userinfo != null)
{
schemespec.append(m_userinfo);
schemespec.append('@');
}
if (m_ho... |
455e8e0b-9d0a-41bb-95bf-68266aa445eb | 8 | @EventHandler
public void onClick(PlayerInteractEvent e){
// TODO: Handle the left and right click of blocks with QuestWand in order to make selections for regions in the world.
Player player = e.getPlayer();
if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
if(player.getInventory().getItemInHand().ge... |
2983e837-3a63-4dea-aafc-59f920d2b4da | 3 | private void run() {
initialize();
while (true) {
long time = System.currentTimeMillis();
update();
render();
time = (1000/fps) - (System.currentTimeMillis() - time);
if (time>=0) {
try {
Thread.sleep(time);
} catch (Exception e) {}
}
}
} |
d23d671b-1e73-49ad-94d3-bb5d0e731934 | 0 | public void setId(Long id) {
this.id = id;
} |
dade809d-1292-420a-8617-e2962b55e86a | 0 | @Override
public void doNewGame()
{
SettingsDialog.getInstance().showDialog();
} |
2b46d519-519c-43b5-88fd-6b8b3494094c | 7 | public Pattern getPattern(String name) {
if (patterns != null) {
Object attribute = library.getObject(patterns, name);
// An instance of TilingPattern will always have a stream
if (attribute != null && attribute instanceof TilingPattern) {
return (TilingPatte... |
a52ee8b1-4d87-4599-8e64-bdd6707c4000 | 6 | @Override
public boolean equals(Object object){
if(object instanceof Leitor){
Leitor l = (Leitor)object;
if(l.getId() == this.getId() && l.getNome().equals(this.getNome()) && l.getLogin().equals(this.getLogin()) && l.getSenha().equals(this.getSenha()) && l.getEmail().equals(this.getE... |
2ce8d442-7270-434e-b8cf-3e3d69e56f3a | 6 | public static void main(String[] args) {
if (args.length != 2) {
printUsageAndExit();
}
File baseFolder;
try {
baseFolder = new File(args[0]);
if (!baseFolder.exists()) {
throw new RuntimeException(args[0] + " doesn't exist");
... |
15c7954f-8906-44b6-8b76-7fb652ed602f | 2 | private boolean canMove(Board board, Direction direction) {
Point[] selection = getSelection();
for (Point point : selection) {
if (!board.isEmpty(point.getNeighbour(direction))) {
return false;
}
}
return true;
} |
5b18137d-5ba8-4610-b6c3-9615b3267b86 | 6 | public void goBottom()
{
nNode = top;
sRecno = 0;
found = false;
for(;;)
{
goNode();
readPage();
if(right_page>0) nNode=right_page;
else
{
for(;;)
{
if(key_cnt>0 || left_page<0) break;
nNode = left_page;
goNode();
readPage();
}
nKey = key_cnt-1;
... |
4673ed08-4140-452c-9ed9-ed25331b6321 | 9 | public Float scaledMinkowskiDistanceFrom(Point p, Integer norm, Float scale) throws GeometryException {
if (this.dimensions <= 3) return this.minkowskiDistanceFrom(p, norm);
if (norm <= 0) throw new GeometryException("p must be positive in p-norm distance");
if (p == null) throw new GeometryExce... |
9759f503-8b16-44b9-b699-9eaef7e31709 | 3 | public JSONObject putOnce(String key, Object value) throws JSONException {
if (key != null && value != null) {
if (opt(key) != null) {
throw new JSONException("Duplicate key \"" + key + "\"");
}
put(key, value);
}
return this;
} |
c8a124be-69c9-4cae-8fde-e16c4a4f7ebb | 5 | @Override
public void onCreate(SQLiteDatabase db) {
for (Class<? extends Model<?>> c : Application.getModels(mContext)) {
try {
db.execSQL(getSQL(c));
} catch (IllegalArgumentException e) {
} catch (SecurityException e) {
... |
f1f147da-4b7e-4a4e-9971-003624956901 | 5 | public static void main(String args[]) {
try {
Registry registry = LocateRegistry.getRegistry(args[0]);
TheInterface remoteObject = (TheInterface) registry.lookup("TheServer");
String testType = args[1];
if("talk".equalsIgnoreCase(testType)){
talk(args, remot... |
525f2a03-9f0d-4d27-a985-6a5300cc1e33 | 8 | private Component cycle(Component currentComponent, int delta) {
int index = -1;
loop : for (int i = 0; i < m_Components.length; i++) {
Component component = m_Components[i];
for (Component c = currentComponent; c != null; c = c.getParent()) {
if (component == c) {
index = i;
break loop;
}
... |
58ffd46b-91a5-40ee-bf62-b0714d913362 | 6 | public int removeDuplicates(int[] A) {
if (A == null || A.length == 0) {
return 0;
}
int size = 0;
for (int i = 1; i < A.length; i++) {
if (A[i] == A[size] && size > 0 && A[size - 1] == A[size]) {
continue;
}
A[++size] = A[i];
}
return size + 1;
} |
52eaf6f6-f9c9-4440-b683-ce0021026d03 | 4 | public void recursivePrint(TreeNode root, int parentPosition, Node innerNode, Node p) {
Node innerParent;
int position;
if (root != null) {
int height = heightRootToNode(root);
int nextTop = getRectNextTop(height);
if (innerNode != null)
inn... |
37e7153c-e201-4b9c-b905-54e7ff6f22dc | 3 | public int count(int intToCount, int[][] convolution) {
int count = 0;
for (int[] row : convolution) {
for (Integer i : row) {
if (i.equals(intToCount)) {
count++;
}
}
}
return count;
} |
c39fc292-dea6-4f0b-a215-5df88e26c9e5 | 3 | public void stopGame() {
// Setting isRunning to false will
// make the thread stop (see run())
this.isRunning = false;
// Unset the game model...
this.view.setModel(null);
// Stop listening for events
this.view.removeKeyListener(this.keyListener);
// Make sure we wait until the thread has stopped...... |
7197f58e-f491-4601-a89f-686b1d4d82d0 | 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... |
4259f2af-7982-49a4-ae31-eb4e68597d3c | 3 | public Serwer( int port ) {
try {
System.out.println( "Binding to port " + port + ", please wait ..." );
server = new ServerSocket( port );
System.out.println( "Server started: " + server );
System.out.println( "Waiting for a client ..." );
socket = ... |
0359690c-0795-4666-a300-f1e4a865c2a1 | 9 | public void testClosedPoolBehavior() throws Exception {
final ObjectPool<Integer> pool;
try {
pool = makeEmptyPool(new MethodCallPoolableObjectFactory());
} catch (UnsupportedOperationException uoe) {
return; // test not supported
}
Integer o1 = pool.borro... |
25f1dfe9-4b0b-48e3-8c4f-43b155ba2e5d | 9 | protected char convertEscapes() throws EOFException {
if (ch == '\\') {
switch (nextChar()) {
case 'n': // Line feed
return '\n';
case 't': // Tab
return '\t';
case 'f': // Form feed
return '\f';
... |
aa4472f9-691d-478f-9c63-1af8a7bdee3e | 4 | public ArrayList<String> getUsersInGroup(int groupID){
ArrayList<GroupMembership> allGroupMemberships = groupMemberships().getGroupMemberships();
ArrayList<String> usersInGroup = new ArrayList<>();
if(groupID == -1){
usersInGroup = new ArrayList<>(users().getAllUsers());
... |
31804616-010b-4fd5-afba-6a13301b4288 | 0 | public float getX() {
return x;
} |
53137c19-e0f9-41b4-948d-f16fd391430a | 1 | public static ResultFunction getResultFunction() {
if (null == _resultFunction) {
_resultFunction = new SudokuResultFunction();
}
return _resultFunction;
} |
761510cf-c3f4-4392-bfe7-71eb47bcd5c6 | 9 | protected boolean isValidRange(String range) {
if (range == null) {
return false;
}
int hyphenIndex;
if ((hyphenIndex = range.indexOf('-')) >= 0) {
if (isValidRange(range.substring(0, hyphenIndex)) &&
isValidRange(range.substring(hyphenIndex + 1))) {
return true;
}
return fa... |
b23fdc27-a645-4893-8a8a-a8e284f1d4c2 | 0 | public static IMusicBox createMusicBox() {
return new IMusicBox() {
@Override
public void play() {
log.debug("播放钢琴音乐...");
}
};
} |
ff4e9b2d-d545-4f8e-a6a1-ecb317aaace0 | 1 | public String[] getDNSBLServers(){
if(!getConfig().isList("DNSBLServers"))
return null;
return getConfig().getStringList("DNSBLServers").toArray(new String[0]);
} |
de2a4124-5b77-4e05-ae62-950403b2529e | 6 | public static Cons PARSE_XML_FROM_STREAM(InputStream in, boolean skipFrontmatterP) {
{ Stella_Object item = null;
XmlExpressionIterator ITER_000 = InputStream.xmlExpressions(in, null);
while (ITER_000.nextP()) {
item = ITER_000.value;
if ((!skipFrontmatterP) ||
((Stella_Obje... |
08859e14-c06c-4436-bfec-372331051d26 | 7 | public void processSelection()
{
if (state == LobberState.WELCOME_PLAYER || state == LobberState.WAITING_FOR_OPPONENT)
{
if (playGrid[currentOpponentPos.getRow()][currentOpponentPos.getColumn()] == CellContent.NON_FILLED_CELL)
{
/*
* 1. Check ... |
7fc05768-4da5-4793-9634-982950c1f4ca | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Parameterized other = (Parameterized) obj;
if (m_field == null) {
if (other.m_field != null)
return false;
... |
815db0a1-b71d-4c8f-ba28-100edfe44e99 | 8 | public char mainMenu() {
Termio terminal = new Termio();
char userChoice = ' ';
boolean error = true;
while (error) {
System.out.println("\n\n1) List resources");
System.out.println("2) List projects");
System.out.println("3) List projects currently assigned to a resource");
System.out.println("4... |
68a1ef30-b503-49f3-a3fc-600f6af6b247 | 1 | public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
CreatePark frame = new CreatePark();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
} |
20e4910f-922b-4ea9-8035-ec6397210c01 | 4 | public static void showCrashReport(Throwable error) {
Log.e(error);
try {
inst.deinit();
} catch (Throwable t) {}
JFrame f = new JFrame("SpriteGen has crashed!");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
... |
a8a1fff9-ab92-44f6-a892-8d2e62ceafd8 | 4 | public boolean hasSideEffects(Expression expr) {
if (expr instanceof MatchableOperator
&& expr.containsConflictingLoad((MatchableOperator) expr))
return true;
for (int i = 0; i < subExpressions.length; i++) {
if (subExpressions[i].hasSideEffects(expr))
return true;
}
return false;
} |
6a4b001e-4c44-45c5-aab5-60ced4c22f8f | 3 | public String getString() {
String re = "";
int x = this.getBegin();
while (this.getBegin() < this.getCad().length() && (this.getCad().charAt(x) + "").matches(this.getMatchSring())) {
re = re + this.getCad().charAt(x++);
this.setBegin(x);
}
return re.equa... |
42f9fdc5-e06b-4492-9529-e7a7539068df | 6 | public void draw(){
if(currentWidth != display.getDisplayWidth() || currentHeight != display.getDisplayHeight()){
image = new BufferedImage(display.getDisplayWidth(), display.getDisplayHeight(), BufferedImage.TYPE_INT_ARGB);
currentWidth = display.getDisplayWidth();
currentHeight = display.getDisplayHeight()... |
8f80e2f9-d373-4864-b8b2-f64097368a36 | 5 | public void actionPerformed(ActionEvent e) {
int steps = 0;
if (e.getSource() == next)
steps = 1;
else if (e.getSource() == next10)
steps = 10;
else if (e.getSource() == next50)
steps = 50;
for (int i = 0; i < ... |
a8f40fcf-20ae-45b4-a33c-d634ecb047a3 | 2 | protected Map<Integer, UserData> persistAdresses(List<Availability> objects, Map<Integer, UserData> users) throws Exception {
for (Availability row : objects) {
if (!users.containsKey(row.id)) {
throw new Exception("The user is not readed yet");
}
UserData use... |
310c9778-673f-40f6-a9c7-52c9321d9c3d | 3 | private void acceptClient(int clientId, String address, int port) {
boolean clientAccepted = false;
synchronized(CONNECTION_LOCK) {
try {
ClientInfo client = new ClientInfo(clientId, address, port, InetAddress.getByName(address));
sendPacket(Packet.createConnectionAcceptedPacket(clientId), client);
c... |
6a38fb20-bc4f-4a05-bca0-1b76059287fc | 2 | private static StringBuilder appendHistoricalForm(StringBuilder buff,
String className) {
int namelen=className.length();
for(int i=0;i<className.length();i++) {
char cch=className.charAt(i);
if (cch=='.') cch='/';
buff.append(cch);
};
... |
ddee7d42-3f9c-4209-a7b4-15bfb23db3af | 7 | protected boolean isCollision(Vector3d v3d) {
Transform3D t3d = new Transform3D();
tg.getTransform(t3d);
Matrix4d m4d = new Matrix4d();
t3d.get(m4d);
GMatrix gm1 = new GMatrix(
4,
1,
new double[] {
v3d.x,
v3d.y,
v3d.z,
0.0
}
);
GMatrix gm2 = new GMatrix(
4,
4,
new doub... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.