method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
253f7c19-bd3b-417f-8a66-94c7634ced5d | 1 | public void visitCatchExpr(final CatchExpr expr) {
// Catch(t)
// t <= [Catch(t)]
Type catchType = expr.catchType();
if (catchType == Type.NULL) {
catchType = Type.THROWABLE;
}
start(expr, catchType);
} |
72702998-ac06-4a65-9607-8a0d92f1dabd | 4 | @Override
protected void checkKeyStates() {
if (keyDown) {
for (int keyID : importantKeys)
if (Keyboard.isKeyDown(keyID))
return;
if (Mouse.isButtonDown(0))
return;
}
keyDown = false;
} |
22340497-0785-4974-ac13-0c8d24f9681b | 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... |
5259a77c-9d17-487e-9be7-3b967f62f6b7 | 4 | public void connect(TreeLinkNode root) {
TreeLinkNode cur = root;
while(cur != null){
TreeLinkNode head = new TreeLinkNode(-1); // 用于辅助编程,有辅助节点之后 代码精炼一些。
TreeLinkNode pre = head;
while(cur != null){
if(cur.left != null){
pre.next =... |
92701810-68e8-42d0-b81b-726ebe2ae7ce | 0 | @Basic
@Column(name = "account_number")
public String getAccountNumber() {
return accountNumber;
} |
4694c741-2045-4b50-86ad-2b2b6e7872a8 | 7 | public void removeUnit(Unit unit) {
if (unit != null) {
removeAllBuffs(unit.getBuffs());
removeAllAbilities(unit.getAbilities());
if (LOGGER.isDebugEnabled())
LOGGER.debug("Successfully removed ALL abilities from unit: " + unit);
if (unit instanceof Hero) {
Hero hero = (Hero) unit;
removeAll... |
0944947e-c886-4cd6-ab10-26f2023e7070 | 0 | public String toString() {
return "Philosopher " + id;
} |
04fa7edb-20fe-441f-933e-1632be290c21 | 4 | public void close(String message) {
if (!closed) {
closed = true;
socket.close();
for (Map.Entry<String, Handler<? extends Message<?>>> handler : eventBusHandlers.entrySet())
eventBus.unregisterHandler(handler.getKey(), handler.getValue());
System.out.println("Client closed " + message);
}
} |
80a1a355-ea65-4dc1-a44e-5bf4b1f4bd79 | 5 | private static Instrument read_xm_instrument( DataInput data_input, boolean delta_env ) throws IOException {
int instrument_header_length, num_samples, idx;
int env_tick, env_ampl, env_num_points, flags;
byte[] structure_header, instrument_header, sample_headers;
Instrument instrument;
Envelope envelope;
st... |
d6a94562-e65d-4ed0-b28a-005d9887485f | 5 | public void uncloak()
{
for (String string : cloakedClients.keySet())
{
Player player = Bukkit.getServer().getPlayer(string);
if (player != null)
{
int chunkXDiff = Math.abs(player.getLocation().getChunk().getX()
- machineLocation.getChunk().getX());
int chunkZDiff = Math.abs(player.get... |
94b97882-305f-4ed6-b7cc-fc771830497f | 0 | @Override
public void blit(FrameBuffer buffer) {
buffer.blit(texture, 0, 0, buffer.getOutputWidth() - x, y, width, height, widthDest, heightDest, 0, false, new Color(200, 190, 150));
} |
2ebee215-83e3-4b9f-bd9d-60a711a2c19f | 6 | private int getBallNumber(int arrayIndex)
{
int currentBall = 10;
for (int i = 0; i < arrayIndex; i++)
{
int pinsKnockedDown = pinsKnockedDownArray[i];
if (pinsKnockedDown == 0)
{
currentBall += 5;
}
if (pinsKnockedDown != 10 && pinsKnockedDown != 0)
{
currentBall += 5;
}
else if ... |
0fe20f98-97fa-4bcc-82b0-03793bc0bfbc | 6 | public void clear() {
boolean useIterator = true;
Iterator it = getKeys();
while (it.hasNext()) {
String key = (String)it.next();
if (useIterator) {
try {
it.remove();
} catch (UnsupportedOperationException usoex) {
... |
755990c1-1ed7-4dad-a411-238c83fcc72c | 2 | public static void main(String[] args) {
// using pattern with flags
Pattern pattern = Pattern.compile("ab", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher("ABcabdAb");
// using Matcher find(), group(), start() and end() methods
while (matcher.find()) {
... |
6857b01e-b025-4cff-9127-1107e1bdeaf9 | 8 | public static Suit fromChar(char c) {
switch (c) {
case 'c': case 'C': return Clubs;
case 'h': case 'H': return Hearts;
case 'd': case 'D': return Diamonds;
case 's': case 'S': return Spades;
default: return null;
}
... |
cccbef57-dac3-40b1-b904-96e9c77c33e2 | 9 | private void getPixels() throws IOException {
try {
image = robot.createScreenCapture(screenRect);
/* Just testing. Not needed
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
... |
7aea4f40-527b-4354-9eca-80a00e1cd458 | 2 | public List<ValidateException> validateMonth(int monthOfBirth) {
List<ValidateException> validateExceptionList = new LinkedList<>();
if ((monthOfBirth < 1) || (monthOfBirth > 12)) {
String exMsg = "entered wrong month of birth";
validateExceptionList.add(new ValidateException(St... |
c236af01-ed3c-43ce-94d1-42b2ce44d76f | 5 | public static double[] doLinearRegressionFromTo(int start,int end,double[][] args) //input int start, int end
{ //input double[1]=array of prices
double[] answer = new double[3];
int ... |
cf418394-fff7-4668-aa42-270ca9649a5b | 2 | public void putBooleans(boolean[] x)
{
ByteBuffer b = stream.getWriter(x.length);
for (int i = 0; i < x.length; i++) {
b.put((byte)(x[i] ? 1 : 0));
}
} |
a7e99f7a-58c0-4d06-ab34-0eb3ac96d0f4 | 3 | @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
FooterPanel = new javax.swing.JPanel();
HeaderPanel = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = ... |
c4dcb8e1-f7d3-44ca-af90-6ef1905301ca | 4 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
State other = (State) obj;
if (index != other.index)
return false;
return true;
} |
d0d51031-c6e7-4e72-afa2-e2ca64012f3e | 0 | @Test
public void testParseUserAgentString() {
UserAgent userAgent = UserAgent.parseUserAgentString("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)");
assertEquals(OperatingSystem.WINDOWS_XP, userAgent.getOperatingSystem());
assertEquals(Browser.IE6, userAgent.getB... |
63e43722-fb78-4558-a53d-310c0949a2e8 | 1 | private void clear() {
if (cur != null) {
ui.destroy(cur);
cur = null;
ui.destroy(btn);
btn = null;
}
progress(null);
} |
e0dd0493-bd8e-415c-b947-4e37b8b8ca36 | 4 | public static ArrayList<Integer> numerosPrimos(int n) {
if (n < 2) return new ArrayList<Integer>();
char[] is_composite = new char[(n - 2 >> 5) + 1];
final int limit_i = n - 2 >> 1, limit_j = 2 * limit_i + 3;
ArrayList<Integer> results = new ArrayList<>((int) Math.ceil(1.25506 * n / Math.log(n))... |
b5b1417f-4d49-4d00-9629-5ddd502c43d7 | 9 | private boolean handleUserDataNotFound() {
String s = Modeler.getInternationalText("HaveYouRegisteredWithMolecularWorkbench");
String s2 = Modeler.getInternationalText("Question");
int i = JOptionPane.showConfirmDialog(JOptionPane.getFrameForComponent(page), s != null ? s
: "You need a Molecular Workbench acc... |
90f63435-e25b-463b-a636-4eb6704590df | 5 | public static void main(String... args) {
String txt = args[0];
String result = "";
for (int i = 0; i < REGEXES.length; i++) {
Pattern p = Pattern.compile(REGEXES[i][0]);
String repl = REGEXES[i][1];
Matcher m = p.matcher(txt);
if (m.find()) {
... |
ce373fb7-74a6-4b77-87be-ea67878bd9bb | 4 | @SuppressWarnings("unchecked")
protected Map<TaFuncSignature, TaFuncMetaInfo> getTaFuncMetaInfoMap()
{
Map<TaFuncSignature, TaFuncMetaInfo> result = new TreeMap<TaFuncSignature, TaFuncMetaInfo>();
Method[] ms = coreClass.getDeclaredMethods();
Map<String, Method> lookbackMap = getLookbackMethodMa... |
96759e93-5e26-485c-a59d-95cfc1a281dc | 9 | private void handleFrame(Frame frame) throws IOException {
QueueManager queueManager = QueueManager.getInstance();
Command command = frame.getCommand();
FrameHeader headers = frame.getHeader();
try {
if (command == Command.COMMIT || command == Command.ABORT || command == Co... |
51029cb6-8408-4c27-b891-cf6d8939cd04 | 7 | public void startup() {
systems = systemProducer.createSystems();
for (S system : systems) {
if (system instanceof LifeCycleSystem) {
lifeCycleSystems.add((LifeCycleSystem) system);
}
}
for (LifeCycleSystem lifeCycleSystem : lifeCycleSystems) {
... |
90fc733e-1d04-46e1-84e7-f3d564571755 | 2 | @Test
public void testMoveCharacter() {
for (Direction dir : Direction.values()){
try {
testTile.moveCharacter(dir);
fail("IllegalArgumentException was expected");
}
catch (IllegalArgumentException e){
//this exception was expected
}
}
} |
a63b93dc-6cdc-4191-b3f1-d0d7002bca67 | 8 | private void juliaMap(int image_size) {
double size = fractal.getSize();
double size_2_x = size * 0.5;
double size_2_y = (size * height_ratio) * 0.5;
double temp_size_image_size_x = size / (TOx - FROMx);
double temp_size_image_size_y = (size * height_ratio) / (TOx - FROMx);
... |
5074d53a-32c0-405e-a65e-291bec9bf520 | 6 | public void setColumnData(int i, Object value) throws Exception {
if (i == 0)
userName = (String) value;
else if (i == 1)
password = (String) value;
else if (i == 2)
firstName = (String) value;
else if (i == 3)
lastName = (String) value;
else if (i == 4)
email = (String) val... |
ea7e305f-9b25-4faa-b9c9-90a04fa32510 | 7 | private void writeFile(String protein, String name, URI file)
{
File f = new File(file);
try
{
FileWriter fw = new FileWriter(f);
try
{
fw.write(protein);
}
catch(IOException i)
{
throw new RuntimeException("Error writing... |
3279a83a-1ca4-4dab-842f-7df0f428ea45 | 4 | public void stworzPolaGry(String _nazwaPola, boolean _czyRysowacSymbole, boolean _czyjePole, JLabel[][] _pola, int _szerPojPola, int _wysPojPola, int _skok, JPanel _obszarPol, JPanel _obszarLiter, JPanel _obszarCyfr, int _szer, int _wys)
{
JLabel lb_litery[] = new JLabel[10];
JLabel lb_cyfry[] = new JLabel[10];
... |
d8c553fe-b1bc-46d5-8aeb-a76379f14897 | 8 | public Object getValueAt(int rowIndex, int columnIndex) {
switch (columnIndex) {// parcour par colonne
case 0://colonne id_Stock
return Pharmacies.get(rowIndex).getId_ph();
case 1://colonne id_Stock
return Pharmacies.get(rowIndex).getNom_ph();
... |
92b38203-d397-4259-a488-1eefe45ed582 | 7 | private JSONWriter append(String s) throws JSONException {
if (s == null) {
throw new JSONException("Null pointer");
}
if (this.mode == 'o' || this.mode == 'a') {
try {
if (this.comma && this.mode == 'a') {
this.writer.write(',');
... |
a8829ba8-f45b-4d3f-9324-00b163d0309c | 8 | public GffParser(String filePath) throws Exception
{
BufferedReader reader = new BufferedReader(new FileReader(filePath));
String s= reader.readLine();
while( s.startsWith("#"))
s= reader.readLine();
StringTokenizer sToken = new StringTokenizer(s);
sToken.nextToken(); sToken.nextToken();
if... |
77557f31-5155-4eb9-bf33-9a0b6aa5e75e | 6 | public void paintComponent(Graphics g2) {
int w = getWidth() / 2 + 1;
int h = getHeight() / 2 + 1;
if ((img == null) || (img.getWidth(null) != w) || (img.getHeight(null) != h)) {
img = createImage(w, h);
Graphics g = img.getGraphics();
for (int x = 0; x <= w / 32; x++) {
for (int ... |
13f12419-7c61-4663-8816-f50666843dc0 | 6 | private boolean load(){ //returns true if loaded, false if new files created
System.out.println("Loading files...");
FileInputStream input = null;
try{
File file = new File("users.txt");
if(!file.exists()){
file.createNewFile();
return fals... |
681496b6-4b0a-4c7c-b202-39292538dc5f | 4 | public Levenshtein(String word1, String word2) {
m = new int[word1.length() + 1][word2.length() + 1];
w1 = word1;
w2 = word2;
for (int i = 0; i <= w1.length(); i++) {
m[i][0] = i;
}
for (int j = 1; j <= w2.length(); j++) {
m[0][j] = j;
}
for (int i = 1; i <= word1.length(); i++) {
for (int j = ... |
5662bfbd-a3ab-4ee1-a6f5-4c610b56dc1b | 7 | @Override
/**
* Returns true if this handler is either closed, or needs to be
* due to timing out in one way or another.
* @return true if this handler is done
*/
public boolean isCloseable()
{
if(closeMe)
return true;
final long currentTime=System.currentTimeMillis();
if((idleTime!=0) && ((currentT... |
5d58c0c8-7f6e-423d-9903-50eed6180182 | 8 | private List<Posicao> posicoesPossiveisRei(Posicao posicao) {
List<Posicao> posicoesPossiveis = new ArrayList<>();
Peca peca;
int coluna;
int linha;
for (int varianteColuna = -1; varianteColuna < 2; varianteColuna++) {
for (int varianteLinha = -1; varianteLinha < 2;... |
b748b5bb-e2bb-4772-948e-19381930858d | 9 | protected void _socketReceivingMessage(ByteBuffer _buf)
{
//将数据放入缓冲中
try
{
_m_bByteBuffer.put(_buf);
}
catch (BufferOverflowException e)
{
//长度不足,此时提示
ALServerLog.Error("_socketReceivingMessage length is too long, Socket Buffer need... |
88c9cc9b-5839-4099-aab1-1b607ebe2e19 | 4 | private Flagger getBoundaryFlagger(int x, int y, int plane, int type, int orientation, boolean flag,
boolean flag2) {
FlagGroup group = new FlagGroup();
int base = getBase(flag, flag2);
switch (type) {
case 0:
int dir = ((orientation * 2 - 1) & 0x7);
group.add(new De... |
546a09fb-2717-4bca-acea-ad1ca74bf97a | 7 | private void handleChildrenChanged(String eventPath) throws InterruptedException, KeeperException {
ZNodeState zNodeState = retrieveOrCreateZNodeState(eventPath);
zNodeState.acquire();
try {
final Set<String> lastTimeChildren = zNodeState.getChildren();
Set<String> newChi... |
38d31a70-2f97-4854-9d47-5e32c928f361 | 3 | public boolean setPower2Probability(int jobType, double prob) {
if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) {
return false;
}
if(useJobType_) {
pow2Prob[jobType] = prob;
} else {
pow2Prob[INTERACTIVE_JOBS] = pow2Prob[BATCH_JOBS] = prob;
}
return tru... |
3d94a88e-e847-4cc6-b98d-4c84cbf0d1be | 8 | public Set<Map.Entry<Double,Byte>> entrySet() {
return new AbstractSet<Map.Entry<Double,Byte>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TDoubleByteMapDecorator.this.isEmpty();
}
p... |
2c84389c-30ba-4684-a82d-0fce85388aea | 1 | public List<Class<? extends Peuple>> getPeuplesDispo() {
return peuplesDispo;
} |
7b5dc6e1-d863-4b41-8cc9-4b6833791c34 | 9 | private void modifyIndex(Move move) {
Game game = gameListModel.getSelection();
Award award = awardListModel.getSelection();
List<Award> awards = awardListModel.getList();
if (game != null && award != null) {
int index = award.getIndex();
int selectedIndex = awardList.getSelectedIndex();
... |
395aa524-21b7-460f-9173-144b97acdb6f | 3 | public String generatePageKey(Object[] args, String key) {
Page page = getPageArgument(args);
if (page == null) {
return null;
}
if (StringUtils.isEmpty(key)) {
key = generateCacheKey(args);
}
if (StringUtils.isEmpty(key)) { // 无法创建key
return null;
}
StringBuilder builder = new StringBuilder("p... |
8056077d-1544-4abd-a129-bd7675b22a39 | 6 | boolean hasProgression(int requiredWordLength) {
if (requiredWordLength <= word.length()) {
if (requiredWordLength == 2) {
winningWord = word.substring(0, 2);
hasProgression = true;
return hasProgression;
} else {
int ratio ... |
7f2debb6-ef67-4320-bd55-e4dfe8854487 | 0 | private int calculateNextRound() {
int offset = (int) (Math.random() * (double) (roundRange - 1)) + 1;
return (currentRound + offset)%roundRange;
} |
74ba8823-f7fb-4c34-a18f-1a7847bfb85f | 3 | private String convertHexChars(StringBuilder name) {
// we need to search for an instance of # and try and convert to hex
try {
for (int i = 0; i < name.length(); i++) {
if (name.charAt(i) == HEX_CHAR) {
// convert digits to hex.
name.d... |
381d9dba-c571-41f9-bcd2-9bdb9d851b49 | 3 | public Board.Direction nextMove(Board start, List<Integer> nextPiece)
{
if (first)
{
first = false;
predict(start, nextPiece);
}
curDepth++;
int hardness = lookAheadHard();
if (deathDepth - curDepth < deathCutoff) // we are soon to die, prioritise score
{
return deathSearch.nextMove(start, nextP... |
d089c7c4-7b5a-4401-95d6-b7aa6fb5761c | 0 | public boolean isDragging() {
return isDragging;
} |
d97eff03-22c7-46bd-a56c-fd7b8b489101 | 1 | * @param mt the microtheory in which the query is asked
*
* @return a list of bindings for the query
*
* @throws UnknownHostException if cyc server host not found on the network
* @throws IOException if a data communication error occurs
* @throws CycApiException if the api request results in a cyc ser... |
31e3bc07-38f2-492e-89b6-7d6981e091f6 | 1 | public void visitNegExpr(final NegExpr expr) {
print("-");
if (expr.expr() != null) {
expr.expr().visit(this);
}
} |
e1ea288d-5f34-4562-84e4-cc3b1c92d5bc | 8 | public void actionPerformed(ActionEvent event) {
toDisplay("User", outgoing.getText());
String id = outgoing.getText().toLowerCase();
if (id.equals("start") && !serverOn) {
frame.startServer();
}
else if (id.equals("stop") && serverOn) {
try {
serverSocket.close();
serverStatus.setIcon(... |
91af9659-d79f-4c24-bbd7-fa530ba9a8b4 | 5 | public static AudioInputStream convertSampleRate(AudioInputStream in, float sampleRate) throws IllegalArgumentException
{
AudioInputStream converted;
AudioFormat sourceFormat, targetFormat;
//check for not null
if(in == null)
throw new IllegalArgumentException("the inputstream must no... |
6b3fb256-a899-4069-905e-e0c5fd700dad | 3 | void load(File configFile) {
this.configFile = configFile;
FileInputStream inputStream = null;
try {
configurations.load(inputStream = new FileInputStream(configFile));
} catch (Exception e) {
// do nothing
System.err
.println(RemoteResourcesLocalization
.getMessage(RemoteResourcesMessages.... |
8133375d-42dc-4cc3-8f8b-19c5a020540c | 2 | public BoilingPointAL()
{
setPreferredSize(size);
Container pane = getContentPane();
pane.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
// temperature label
JLabel tempLabel = new JLabel("Temperature (K)");
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 2;... |
fc28832e-09c4-4019-9ac0-08fc8ad7011d | 8 | public void putNumberOfDroppedPin(int pNum) {
frames[frameCnt].setDroppedPins(pNum);
addFrameScore(frameCnt, pNum);
if (frameCnt != 0) { // 최소 두번째 프레임 이상일 때
int cleanCnt = frameCnt-1; // 연속 스트라이크, 스페어 연산을 위한 카운터
while (isCleanFrame(cleanCnt)) { // 현재 프레임의 직전... |
e5ee9a75-4ead-4b00-bf51-ac7d7ef97d18 | 8 | Deserializer getMessageDeserializer2(Data reply, String expectedMessageType)
throws RequestException, ConfigurationTaskException, ConfigurationChangeException {
String messageType = reply.getTextValue("nachrichtenTyp").getValueText();
final byte[] message = reply.getScaledArray("daten").getByteArray();
final D... |
d15001fb-33b2-4401-97f2-073407061bd4 | 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://downl... |
96bf6419-be7d-4b87-baea-f3e888260b48 | 7 | public int executeChanges(List<DbChange> changes) throws SQLException, UpdateFailureException {
if (conn == null) {
throw new IllegalStateException("You must first call initialize()!");
}
if (changes.isEmpty()) {
return 0;
}
ResultSet rs = null;
b... |
cdf1ebd2-6028-47d7-9c2c-a66aefc61d4b | 5 | public CompanyApplicationVisual() {
setIconImage(Toolkit.getDefaultToolkit().getImage(CompanyApplicationVisual.class.getResource("/InterfazGrafica/Images/1417568890_new-file.png")));
setTitle("NUEVA SOLICITUD DE PERSONAL");
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(10, 50, 760, 650);
setMod... |
b3558d91-2d0e-4698-8372-6c9f3f1e6e27 | 7 | public int compareTo(Object o)
{
if (o instanceof ServletHolder)
{
ServletHolder sh= (ServletHolder)o;
if (sh==this)
return 0;
if (sh._initOrder<_initOrder)
return 1;
if (sh._initOrder>_initOrder)
return ... |
6c3472eb-f47f-4acc-a43a-6a81ee36b956 | 3 | public boolean connection(String userName,String password)
{
boolean response=false;
for(Member m : memberBean.getMembers() )
{
if(m.getUsername().equals(userName)&&m.getPassword().equals(password))
{
currentMember=m;
response=true;
}
}
return response;
} |
d5847406-f1ac-48f4-a78c-bcf9415f593c | 8 | public void execute() {
System.out.println("Objects: " + this.objects);
for (int i = 0; i < this.sObjects().length; i++) {
if( !sObjects()[i].getTriggerable() || this.objectIsIgnored(sObjects()[i].getName()) ){
continue;
}
if(!this.objects.equals("all") && !this.objectList().contains(sObjects()[i].getN... |
06ff582a-8167-4ce5-85ae-162ad3b38d78 | 5 | @Override
public void init() throws NoDataSourceException, IOException {
setLayout(new BorderLayout()); // use a BorderLayout
// Use lightweight components for Swing compatibility
Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);
try {
Player player = Manager.createRealizedPlayer(url);
Component v... |
5c2eaf1d-285c-4626-83e4-4e7e313abb7e | 1 | public static void makeNextWhiteMoves(){
Vector<Move> resultantMoveSeq = new Vector<Move>();
alphaBeta(Game.board, Player.white, 0, Integer.MIN_VALUE, Integer.MAX_VALUE, resultantMoveSeq);
//Apply the move to the game board.
for(Move m:resultantMoveSeq){
... |
ab37ee61-6ba9-4b76-aa6d-2ae6ee2773dc | 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... |
200af141-b0a7-4f87-9d32-51c23f1b4052 | 0 | @Override
public void init() throws Exception {
doInit();
} |
c18fea35-b9e0-4bde-a5f4-4aa82ea24721 | 8 | @Override
public boolean tick(final Tickable ticking, final int tickID)
{
if((flag==State.STOPPED)||(amDestroyed()))
return false;
tickStatus=Tickable.STATUS_START;
if(tickID==Tickable.TICKID_AREA)
{
if((flag==State.ACTIVE)
&&((System.currentTimeMillis()-lastPlayerTime)>Area.TIME_PASSIVE_LAPSE))
{... |
72a42cb5-6e28-4456-a1db-a607fbcf753f | 1 | public static void main(String[] args) throws Exception {
ExecutorService executor = Executors.newCachedThreadPool();
for (int i = 0; i < 20; i++) { //200 hundred times will be called
executor.submit(new Runnable() {
public void run() {
Connectionn.getIns... |
bb7830f7-e27b-44f1-ab35-8f9215cd9260 | 7 | private void up()
{
boolean sel = false;
int debut = 0, fin = 0;
for (int i = 0; i < listDroite.getSize() + 1; i++) {
if (droite.isSelectedIndex(i) && !sel) {
debut = i;
sel = true;
} else if (!droite.isSelectedIndex(i) && sel) {
... |
abd134ff-3d9f-4840-9c4b-869821632d98 | 8 | private static Puzzle bruteForce(Puzzle puzzle) {
if (puzzle.isInvalid())
return null;
if (puzzle.isComplete())
return puzzle;
//Find cell with smallest available then start there.
int row = 0;
int col = 0;
int smallest = Integer.MAX_VALUE;
... |
c56c0499-b23f-48a9-acfc-7f5442657c4f | 0 | public void setColor(Color color) {
this.color = color;
} |
1fb114ea-d7ed-4cb5-90e7-40ef1c213b30 | 1 | public void removeStock() {
if (selectedSquare != null) {
pnlDashboardCenter.remove(selectedSquare);
squareGraphicList.remove(selectedSquare);
selectedSquare = null;
this.repaint();
this.validate();
}
} |
d8c74fec-ef48-40e6-bf1a-4bfda92e9bda | 1 | public TripDB readTripDB (String fn) {
// import rivers
try {
tripDB = TripDB.read (fn);
return tripDB;
} catch (Exception e) {
System.out.println ("Could not read trip data file " + fn + ".");
e.printStackTrace();
}
return null;
} |
f90c0742-58a5-4b7d-a911-61cb48b966e6 | 1 | @Override
public void onMoveTick(int x, int y, Game game) {
SinglePlayerGame spg = (SinglePlayerGame) game;
int population = EntityType.filterByID(spg.getSquareNeighbors(x, y, 1), id).size();
spg.getEntity(x, y).setAlive(population > 1 && population < 4);
} |
302e29b2-1739-4395-b29f-4bf976b3cc02 | 6 | private static int breadthFirstSearch(int from, int to) {
int maxDistance = 0;
Integer[] object;
LinkedList<Integer[]> cola = new LinkedList<Integer[]>();
LinkedList<Integer> visited = new LinkedList<Integer>();
int[] precedents = new int[listaNombres.size()];
int[] distances = new int[listaNombres... |
16b3fcfe-6ef4-4fba-8c8f-8e0cfe563198 | 0 | public void onMessage(IMessage message) throws JFException {} |
0c3a9048-014d-4e02-87b4-c8b064c3235b | 5 | public boolean onCommand(CommandSender sender, Command command,
String label, String[] args) {
if(enabled){
if(command.getName().equalsIgnoreCase("message")){
}else if(command.getName().equalsIgnoreCase("reply")){
if(reply.get(sender) != null){
Player reciever = reply.get(sender);
... |
8eb526e3-8fca-44b4-be06-44d681db5c65 | 7 | public static Cons normalizeDefpropositionArguments(Cons arguments) {
{ Stella_Object name = arguments.value;
Stella_Object proposition = arguments.rest.value;
PropertyList options = null;
Stella_Object value = null;
Cons annotations = Stella.NIL;
{ Surrogate testValue000 = Stella_Obj... |
e6fdabc1-6492-4384-baff-cdf067378c84 | 7 | public void shoot() {
int dx = me.getCenterX() - me.getPlayer().getCenterX();
int dy = me.getCenterY() - me.getPlayer().getCenterY();
Random r = new Random();
if (Math.abs(dx) < Math.abs(dy)) {
if (dy < 0) {
if (r.nextInt(4) < 3) me.shoot(Direction.DOWN);
... |
ee2d4371-be5d-4ebe-9b1e-1adc06cb4ce0 | 4 | public void handlePress(int x, int y) {
handlePlayerSelection(x, y);
handleWin();
if (aiBegins && state == GameState.CROSS_MOVE){
ai.makeMove();
state = GameState.CIRCLE_MOVE;
}
if (!aiBegins && state == GameState.CIRCLE_MOVE){
ai.makeMove();
state = GameState.CROSS_MOVE;
}
handleWin();
... |
cf21cd07-f507-43d7-958e-a300fd9a0ed0 | 2 | public boolean isValid() {
int length= this.position.length;
for(int i= 0; i< length; ++i)
if(this.position[i] != 0)
return true;
return false;
} |
8999904a-a673-445c-bd2c-b561683fecbd | 9 | private void mt (LineNumber l1, LineNumber l2, Expression prove) throws IllegalLineException, IllegalInferenceException {
if ((l1.toString().length() > globalLine().toString().length()) ||
(l2.toString().length() > globalLine().toString().length())) {
throw new IllegalLineException("Incorrectly referencing li... |
3de624f4-9ec3-4d12-be56-c79b25ad5ddd | 1 | public boolean opEquals(Operator o) {
return (o instanceof CompareBinaryOperator)
&& o.operatorIndex == operatorIndex;
} |
d14c4169-9451-4279-af9a-d0fcf1ea40b3 | 6 | private RequestDispatcher goLogin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (request.getParameter("username") == null || request.getParameter("password") == null) {
Logger.getGlobal().warning("null");
}
Utente utente... |
61a21400-30ae-4c44-b50f-8d7332d26c4d | 5 | @Override
public void tableChanged(TableModelEvent e) {
if (e.getType() == TableModelEvent.UPDATE) {
int row = e.getFirstRow();
int col = e.getColumn();
if ((row < 0) || (col < 1)) { // account for first column being
// header too
return;
}
Object newObj = routeTableModel.getValueAt(row... |
e47d68c2-4747-4ae4-a748-2e70666992ec | 5 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Point2 other = (Point2) obj;
if (Float.floatToIntBits(x) != Float.floatToIntBits(other.x))
return false;
if (Float.floatToIntBits(y) != Floa... |
e95dd82a-e91a-455f-baae-62fac1248d4b | 7 | public static void main(String[] args){
// Socket which will connect to the engine.
Socket socket = null;
// Reader to read packets from engine
BufferedReader inStream = null;
// Convenience wrapper to write back to engine
PrintWriter outStream = null;
// port number... |
b27faf04-b6bf-4648-a70b-a08b98e3200f | 2 | @SuppressWarnings("unchecked")
public void loadFruits() throws IOException, ClassNotFoundException
{
FileInputStream fis = new FileInputStream(DevilFruits.getInstance().getDataFolder() + "/fruitdata.xml");
if(fis == null) return;
ObjectInputStream ois = new ObjectInputStream(fis);
if(ois == nul... |
d97a796e-b128-482f-abd2-4b7eb6c6a17e | 9 | public static void main(String[] args) {
if (args.length == 0) {
System.err.println("USAGE: java polimi.reds.examples.Broker <protocol> <localPort> [--logger]");
return;
}
// configuring logging facility
Logger logger = Logger.getLogger("polimi.reds");
ConsoleHandler ch = new ConsoleHandler();
logger.... |
18c003bb-e409-4742-ab02-c8126f6c7472 | 3 | public static void main(String[] args) {
int var = 1;
Object o = new Object();
o = null;
if (o == null) {
System.out.println("o is null");
}
double[] arr = new double[10];
for (int i = 0; i < arr.length; i++) {
arr[i] = Math.sqrt(i);
}
while (true) {
// do some... |
35366cf8-0af9-41a0-820e-f2855fe5bf2b | 2 | String decryptOther(String value){
String symbol;
switch(value){
case ".":
symbol = " ";
break;
case "#":
symbol = ".";
break;
default:
symbol = "?";
break;
}
return symbol;
} |
bd9e6f19-0255-4888-906c-92ae786ccd5f | 6 | private void searchLevel(Node node, double[] query, ResultSet resultSet,
int k, float eps, Double mindistsq, ArrayList<Double> dists) {
// If this is a leaf node.
if (node.child1 == null && node.child2 == null) {
double worstDistance = resultSet.worstDistance();
for (int i = node.leftObjectIndex; i < node.... |
bbc93a48-f441-47ac-be73-2e365826efcf | 4 | @Override
public Boolean[] segment(Utterance utterance, boolean training, boolean trace) {
// Get info about the utterance. Since the segmentation is a copy,
// don't worry about modifying it
String[] units = utterance.getUnits();
Boolean[] segmentation = utterance.getBoundariesCopy();
Boolean[] stresses = u... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.