method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
76c9a459-cfa2-44bf-b1db-aa47d9002175 | 6 | public void addFleet(){ // Creates a fleet of boats
for(int i=0; i<GameConfiguration.gameConfiguration_NBSHIP; i++){
boolean add = false;
while(!add) {
Ship s = null;
int x = (int) (Math.random()*4);
int y = (int) (Math.random()*4);
char orient;
int orien = (int) Math.random();
if (o... |
92880825-8382-4580-b0aa-1f0a3d9391ec | 6 | @Override
public boolean equals(Object obj) {
if(this == obj)
return true;
if(obj == null)
return false;
if(getClass() != obj.getClass())
return false;
IntPoint other = (IntPoint) obj;
if(x != other.x)
return false;
if(y != other.y)
return false;
if(z != other.z)
return false;
return ... |
210ac295-5354-4914-ac23-246836340b0e | 6 | public void shutdownInput (final SocketChannel sc, final Callback.TCPClient cb) {
if ( !sc.isConnected()
|| !sc.isOpen()
|| sc.socket().isClosed()
|| sc.socket().isInputShutdown()) {return;}
if (this.isLoopThread()) {
try { sc.socket().shutdownInput(); } ... |
7a995f00-f2e7-455c-87f7-5b099fac11b3 | 2 | public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
//Initialisation musique
musiqueJeuPlay = new Music("music.wav");
musiqueJeuPlay.setVolume(0.10f);
//Initialisarions des états
modePausePlay = true;
inventaire = false;
//structure&... |
cd46f5b5-4b87-4a89-879e-8be64379dace | 1 | @Override
public String getName() {
String name = super.getName();
if (name == null) {
return DEFAULT_NAME;
} else {
return name;
}
} |
3f9761ab-e1f4-4220-b842-cd7d0c398e31 | 3 | private void checkEnoughCapacity(int number) {
if (array.length - currentSize < number) {
changeCapacityBy(array.length);
} else if (currentSize < array.length / 4 && array.length / 2 > INITIAL_CAPACITY) {
changeCapacityBy(-array.length / 2);
}
} |
507d7eff-6c2f-42df-9a9f-9496e3e12a94 | 5 | public final double moure(final int midaCamp) {
double distMax = 0;
double posXFinal = 0;
double distRecorre = r.nextInt((int) movimentMaxim) + 1;
if (direccio != DRETA) {
distMax = -(0 - imatgeEsquerra.getX());
} else {
distMax = midaCamp - imatgeDreta.ge... |
e67a73fd-f5cc-4370-8341-866709556f61 | 0 | public void setBranches(Set<String> branches) {
this.branches = branches;
} |
9dcc7817-a718-473c-84ad-af95929ed1f5 | 0 | private int spin() {
return (int) (Math.random() * 5 + 1);
} |
a2fbff53-b449-4621-98a6-8d68525dcaf0 | 0 | public static void main(String[] args) {
CreateProductXml cpx = new CreateProductXml();
cpx.creadXml();
cpx.readXml();
} |
9d325bed-3d4d-4dcf-aecc-061b3c089f69 | 1 | public void setLoopEnabled(boolean enabled){
if (enabled == true){
clip.loop(Clip.LOOP_CONTINUOUSLY);
}
} |
c95eaa50-3fb0-4dc6-aa5a-5f3779f2cc3f | 8 | public int[] getBestHandPoseRanking(int hand) {
int poseRanking[] = new int[N_POSES];
int defaultRanking[] = new int[N_POSES];
for(int iPose = 0; iPose < N_POSES; iPose++) {
poseRanking[iPose] = iPose;
defaultRanking[iPose] = iPose;
}
int lastBestPose = getBestHandPose(... |
4f61ea4c-b83a-4d5e-a4cf-04f98042dfba | 0 | @Override
public File getFile() {
return this.actualFile;
} |
967d0692-b9d7-4526-a9ca-8a7c3ddc3a76 | 7 | String showScriptContextHTML( String s, int lineNo, int context )
{
StringBuilder sb = new StringBuilder();
BufferedReader br = new BufferedReader( new StringReader(s) );
int beginLine = Math.max( 1, lineNo-context );
int endLine = lineNo + context;
for( int i=1; i<=lineNo+context+1; i++ )
{
if ( i < ... |
70a1dcc5-9b73-409c-bee0-9ccc1db7fe7c | 9 | protected void paintTopTabBorder(int tabIndex, Graphics g, int x1, int y1, int x2, int y2, boolean isSelected) {
int tc = tabPane.getTabCount();
int currentRun = getRunForTab(tc, tabIndex);
int lastIndex = lastTabInRun(tc, currentRun);
int firstIndex = tabRuns[currentRun];
boolea... |
edd55d20-8a78-49c0-a9da-05cf2bdf2781 | 2 | public void draw()
{
for(int j = 8;j>=0;j--)
{
System.out.print("\n");
for(int i = 0;i<9;i++)
{
System.out.print(" "+board[i][j]);
}
}
System.out.print("\n");
} |
1968a9fd-d28d-4c46-b3e9-64bb99937d5c | 4 | public int GetNPCDropArrayID(int NPCID, int DropType) {
for (int i = 0; i < maxNPCDrops; i++) {
if (NpcDrops[i] != null) {
if (NpcDrops[i].npcId == NPCID && NpcDrops[i].DropType == DropType) {
return i;
}
}
}
return -1;
} |
1a2fff2a-3317-4db3-a838-a6473d2785fb | 2 | public int getHigh(int symbol) {
if (symbol < 0 || symbol >= numSymbols)
throw new IllegalArgumentException("Symbol out of range");
return symbol + 1;
} |
112450bc-72f5-4a11-bf3d-3623f01d1278 | 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 Personal)) {
return false;
}
Personal other = (Personal) object;
if ((this.id == null && other.id != null) || (... |
d060bae6-dc8c-4010-a740-55dd8d928dff | 3 | public void setColors(Color p1, Color p2) {
Color col1 = p1;
Color col2 = p2;
if (col1 == null) {
col1 = player.getPlayerOneColor();
}
if (col2 == null) {
col2 = player.getPlayerTwoColor();
}
if (col1.equals(col2)) {
grid.getS... |
851c52c1-ff87-4ae1-ab64-9170ea51787b | 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... |
c8ff56e0-066a-4d57-93fe-5612ba69a107 | 6 | private void placeQueen(ArrayList<String[]> result, int[] tag, int row, int n) {
//when finish placing all the Q, build the list
if (row == n) {
String[] temp = new String[n];
for (int i = 0; i < n; i++) {
String point = new String();
for (int j = ... |
39fe3d39-548e-4a62-8508-672e4f467305 | 2 | public void addIstore(int n) {
if (n < 4)
addOpcode(59 + n); // istore_<n>
else if (n < 0x100) {
addOpcode(ISTORE); // istore
add(n);
}
else {
addOpcode(WIDE);
addOpcode(ISTORE);
addIndex(n);
... |
5ff3a0c5-15b9-4bfa-8e2e-fc56ff85c59d | 3 | public void music(){
try {
file = new FileInputStream("sound/dragonroost.wav");
} catch (FileNotFoundException ex) {
Logger.getLogger(Sounds.class.getName()).log(Level.SEVERE, null, ex);
}
catch (IOException ex) {
}
... |
0652dad9-cb1b-4284-907c-cee9b1a2816b | 7 | public void printWords(List<String> words, char[][] board){
if(words == null || words.size() == 0 || board == null || board.length == 0)
return;
for(String word: words){
for(int i=0; i<board.length; i++){
for(int j=0; j<board[0].length; j++){
dfs(boa... |
d544014c-474a-4e7e-8bd2-8961d8d9a39d | 4 | private String getValueForElement(String elementName,Node node) throws Exception{
if(node.getNodeType()==Node.ELEMENT_NODE){
Element elem = (Element)node;
if(elem.getElementsByTagName(elementName).getLength()>=1){
Element x = (Element) elem.getElementsByTagName(elementName).item(0);
if(x.hasChi... |
864d2fef-343e-4ca4-bcd5-364402e0c193 | 0 | public int getVistingHourId() {
return vistingHourId;
} |
416b8239-38cb-4531-b4ef-84a3f973aef7 | 1 | public void printPath(List<Edge<T>> path) {
for (int i=0; i<path.size(); i++) {
System.out.print(path.get(i).start.label + " ");
//System.out.print(path.get(i).start.label + "->" + path.get(i).end.label + " ");
}
} |
0c0d56dd-a2e3-4590-8ba3-bda832618401 | 7 | protected List<String> sshExecCmd(final String command,
final SshStreams sshStream) throws OpenShiftSSHOperationException {
final Session session = getSSHSession();
if (session == null) {
throw new OpenShiftSSHOperationException(
"No SSH session available for application ''{0}''",
this.getName());
... |
b522f00c-e2b7-4a80-afe5-f2c2095501ad | 9 | @Test
public void conversionTEst() throws Exception
{
Long found = 0l;
Long notFound = 0l;
Float pixelLon;
Float pixelLat;
Integer pixelHeight;
Integer pixelWidth;
Map<Float, Boolean> lats = new HashMap<Float, Boolean>();
String path = "resources\\COLOR_SCALEBAR.TIF";
Float totalElevation = 19910... |
4927fee6-0653-4833-8b3f-536a48412f20 | 9 | private WrapperMoney getChange( int m ) {
List<Money> lom = new ArrayList<>();
while ( m > 0 ) {
if ( m > 100 && dollar_count > 0 ) {
lom.add(Money.dollar);
m -= 100;
dollar_count--;
} else if ( m > 25 && quarter_count > 0 ) {
lom.add(Money.quarter);
m -= 25;
quarter_count--;
... |
fca2886f-e252-47fa-a285-146d521fbce0 | 4 | @Override
public String toString() {
String str = "{ ";
for (int j = 0; j < rhymeList.size(); j++) {
for (int k = 0; k < rhymeList.get(j).size(); k++) {
if (k + 1 == rhymeList.get(j).size())
str += rhymeList.get(j).get(k);
else
str += rhymeList.get(j).get(k) + ", ";
}
if (j + 1 == rhym... |
d22d3087-6a34-4851-b018-8dfa73f691bb | 3 | public void cargarTabla(){
ControladorCategoria cont = new ControladorCategoria();
//categorias= null;
//categorias.addColumn("Categoria");
categorias = new DefaultTableModel();
categorias.addColumn("Categoria");
int a =categorias.getRowCount();
for(i... |
cd6db0e0-38d3-4cae-9ac7-3c718242f256 | 0 | public void driver() {
System.out.println("audo bus drive");
} |
35162bda-3643-47a4-b233-15dd013c155c | 3 | public int getEntityIndex(String name){
for (int i=0;i<eHandler.length;i++){
if (eHandler[i] != null)
if (!eHandler[i].getName().equals(name)){ return i; }
}
return -1;
} |
66e78831-36e1-40c4-8c96-516560de2267 | 9 | private String setPosition( String line){
String result=null;
try{
Pattern p = Pattern.compile("([0-9])");
if(this.card_position==null){
if(line.length()>4){
for(String lin :stripAccents(line.toLowerCase()).split(" ")){
if(lin.length()>4){
for(String function : Cache.get(lang, "jobs")){
... |
a13e5536-53b0-45ab-93fc-7c758feec240 | 1 | public Speicherzelle getStatus(boolean bank1) {
if(bank1)
return speicherZellen[0x03];
else
return speicherZellen[0x83];
} |
7453593a-4d03-4e5c-be90-c445ef4ce497 | 6 | static final void method1006(boolean bool, byte i) {
anInt1655++;
if (bool) {
if (r.anInt9721 != -1)
Class14.method235(r.anInt9721, (byte) -108);
for (Class348_Sub41 class348_sub41
= (Class348_Sub41) Class125.aClass356_4915.method3484(0);
class348_sub41 != null;
class348_sub41 = ((Class348_Su... |
c37d5bbc-659e-42cf-a0cd-d155537c81d8 | 9 | @Override
public Class<?> getColumnClass(int column) {
switch (column) {
case 0:
return String.class;
case 1:
return PluginType.class;
case 2:
return Boolean.class;
case 3:
case 4:
ret... |
bdc43657-39f9-4359-aee5-e1ffa6ecd0ed | 7 | public void stopService()
{
if(!isRunning())
throw new IllegalStateException("Server is already stopped");
serverTh.interrupt();
try{serverTh.join(2000);} catch (InterruptedException ignored){}
handleRequestWorkers.shutdown();
try{handleRequestWo... |
a4a9a929-ec42-416f-a407-257bdc64f5f7 | 4 | public String[][] readFeldStruktur(String pfad) throws FileNotFoundException, IOException {
String[][] struktur = new String[8][8];
BufferedReader b;
b = new BufferedReader(new FileReader(pfad));//die Strukturdatei
for (int i = 0; i < 8; i++) {
String line = b.readLine(); /... |
d6d3525d-8422-4601-af86-9b79460c5a91 | 7 | protected void addSource( String consolFunc, String dsName, String name ) throws RrdException
{
if ( consolFunc.equalsIgnoreCase("AVERAGE") || consolFunc.equalsIgnoreCase("AVG") )
datasources[AVG].add( new String[] { dsName, name } );
else if ( consolFunc.equalsIgnoreCase("MAX") || consolFunc.equalsIgnoreCase("... |
ff6af10d-0a56-4a28-8746-6bdae93e2fe3 | 0 | @Bean
public JpaVendorAdapter jpaVendorAdapter() {
HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
hibernateJpaVendorAdapter.setShowSql(false);
hibernateJpaVendorAdapter.setGenerateDdl(true);
hibernateJpaVendorAdapter.setDatabase(Database.DERBY)... |
03751c4d-83e8-4db3-950f-79c971707b3a | 6 | static void process() {
int i, j;
// we initialize every element in P with -1
for (i = 0; i < nodes; i++)
for (j = 0; 1 << j < nodes; j++) {
P[i][j] = -1;
M[i][j] = 0;
}
// the first ancestor of every node i is T[i]
for (i = 0; i < nodes; i++) {
P[i][0] = T[i];
M[i][0] = H[i];
}
// ... |
269fd118-f17e-4e68-a22b-87297f2db3b2 | 3 | void NNItopSwitch( edge e, direction d, double[][] A )
{
edge par, fixed;
edge skew, swap;
if ( direction.LEFT == d )
swap = e.head.leftEdge;
else
swap = e.head.rightEdge;
skew = e.siblingEdge();
fixed = swap.siblingEdge();
par = e.tail.parentEdge;
/*perform topological switch by changing... |
88a789c6-aa6a-4225-822b-452da36b85ec | 8 | public void actionPerformed(ActionEvent e)
{
String actioncommand = e.getActionCommand();
if (actioncommand.equals("open")) {
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.showOpenDialog(this);
File file = fc.getSelectedFile();
if (file != null) {
... |
934cac1f-a6c6-432e-a9ed-990f7863e5ed | 1 | public boolean damage(int amount) {
int temp = dmg;
this.dmg += amount;
return temp < maxHP && !isAlive();
} |
080b4d23-98db-4cd8-b48b-21c045e13f6a | 2 | public Matrix invertRigid() {
/*
* this only works for rigid body transformations!
*/
/*
* calculate the inverse rotation by transposing the upper 3x3 submatrix.
*/
Matrix ri = new Matrix();
for (int c = 0; c != 3; c++)
for (int r = 0; r != 3; r++)
ri.set(c, r, get(r, c... |
cb2a00be-83fb-4666-a540-eafb425108b7 | 9 | public static void show(JFrame frame, Point point, int[][] old, int[][] ne) {
JDialog dialog = new JDialog(frame, "DiffDialog", true);
JPanel jpanel = new JPanel();
JTextPane textPane = new JTextPane();
dialog.setContentPane(jpanel);
jpanel.add(textPane);
StyledDocument doc = textPane.getStyledDocument();... |
01470321-5d6a-4f95-a23c-d7e7d00af498 | 4 | public static void giveTool(Player player, int type) {
final Inventory inv = player.getInventory();
if (inv.contains(type))
player.sendMessage(ChatColor.RED + "You have alredy a " + materialName(type));
else {
final int free = inv.firstEmpty();
if (free >= 0) {
if (player.getItemInHand() != null && p... |
8febc671-0e58-4a70-8d0e-19f10b643894 | 5 | public void showViewAddSpec(final Medecin med) {
final List<Specialisation> listSpecMed = new ArrayList<>(); // Préparation de la liste des spécialités que ce médecin n'a pas
for (Specialisation spec : getListSpecialisation()) {
boolean result = true;
for (Specialisation specMed ... |
784806d0-ea36-456e-880d-c4aa4a8fc6e6 | 9 | private ItemStack[] getItemsForPage() {
ItemStack[] pageItems = pages.get(Math.max(getCurrentPage(), 0));
int pageSize = pageItems.length;
if (pages.size() > 1 || this.getExitInventory() != null) {
pageSize += 9;
}
if (!this.dynamicInventorySize || isPlayerInventory()... |
95927022-c055-42d0-98e1-02b3725a1465 | 6 | public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
LogUtils.ensureConfigured();
//temp patch code to create log file
DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");
D... |
6f3cb002-6761-4c8d-bc0b-44de34df6177 | 0 | @Test
public void testFindString() throws Exception
{
Assert.assertEquals(
"this is a test",
_xpath.findString("//div[@id='main']/p/text()")
);
} |
f9855785-7748-41c2-89b0-339252b7553b | 7 | @Override
public String serializeField(Field field) {
StringBuilder sb = new StringBuilder();
char[][] tableView = Field.getInstance().getTableView();
int yMax = Field.getInstance().getYBound()+2;
int xMax = Field.getInstance().getXBound()+2;
char[][] rotate... |
cf19ac88-9d93-404e-91fb-87dcd57d6cbc | 3 | public BufferedImage getImage(String state, int frame, int dir)
{
// Try to get the state
SpriteState st = states.get(state);
if(st == null) return null;
// Try to get the frame
SpriteFrame fr;
try
{
fr = st.frames.get(frame);
}
catch(IndexOutOfBoundsException e)
{
// If the frame doesn't... |
c5ee5d43-86d9-411f-bc81-a2ab974f3f91 | 8 | public void mouseClicked(MouseEvent e){//それぞれをクリックしたとき
requestFocus();//キー処理できるように
if(TITLE){
if(hajime.isOn(e.getX(),e.getY())){//はじめから
Sound.play(Sound.itemGet);
score = 0;//獲得点数
TITLE = false;
}else if (tuduki.isOn(e.getX(), e.getY())){//つづきから
Sound.play(Sound.itemChange);
SCOR... |
e7ff9a6d-12e8-438f-b976-915801eca9f3 | 2 | @Override
public T validate(String fieldName, T value) throws ValidationException {
if (value == null) {
return null;
}
if (min.compareTo(value) > 0) {
throw new ValidationException(fieldName, value, "must be at least " + min);
}
return value;
} |
6709ac47-e5a6-4463-a0b0-066fc3099620 | 7 | public static int nextWithSameBits(int x){
int bak = x;
int bit = 0;
for(;((x & 1) != 1) && bit < 32;x >>= 1,bit++);
for(;((x & 1) != 0) && bit < 32;x >>= 1,bit++);
if(bit == 31){
return -1;
}
x |= 1;
x <<= bit;
if(bit == 32)
x =0;
int count = count1(bak) - count1(x);
int c = 1;
for(;count... |
c33864ab-d6a4-484e-aecc-4e25bb660f19 | 4 | @Test(timeout = 10_000)
public void testTCPBackEnd() {
Node n = senderAddr.connectTo();
System.out.println("Connected.");
final Thread local = Thread.currentThread();
n.addListener(new Object() {
@JPListener
public Boolean rec(final StringMessage s) {
System.out.println("Client: " + s.getText());... |
aeb23de3-0255-41d2-ab66-49cc0bae62ce | 7 | protected void handleView(View view) {
this.view=view;
if(log.isDebugEnabled())
log.debug("view=" + view);
List<Address> members=view.getMembers();
_consumerLock.lock();
try {
// This removes the consumers that were registered that are now gone
... |
50c846ce-9333-4501-9b76-aa7595955cfe | 7 | public DocumentDictionary(File file) {
Scanner scanner = null;
try {
scanner = new Scanner(file);
} catch (FileNotFoundException e) {
System.out.println("Error occured with: "+ file.getAbsolutePath());
e.printStackTrace();
}
partsOfSpeech = new HashMap<Object, ArrayList<WordNode>>();
posCounts =... |
2c983063-d117-496a-9543-6830c5dfdc0e | 9 | public static <TYPE> void shortestPath(TYPE neuron, TYPE endNeuron, Graph graph, Map infoMap, Set visitedNeurons){
//add to visited so we wont check it again
visitedNeurons.add(neuron);
DataHolder<TYPE> neuronData = (DataHolder<TYPE>)infoMap.get(neuron);
//find all it edges
List<Edge> list = graph.getEdgesFr... |
15c45e0f-f26b-4c09-8795-7f407c82f08f | 1 | public boolean checkHit(double enemyX, double enemyY, long currentTime){
if (Point2D.distance(startX, startY, enemyX, enemyY) <= (currentTime - fireTime) * getBulletSpeed()){
double desiredDirection = Math.atan2(enemyX - startX, enemyY - startY);
double angleOffset = Utils.normalRelative... |
7ad8393b-2c53-4950-a13d-e22aa60dd42d | 6 | private String scanFlowScalarBreaks(Mark startMark) {
// See the specification for details.
StringBuilder chunks = new StringBuilder();
while (true) {
// Instead of checking indentation, we check for document
// separators.
String prefix = reader.prefix(3);
... |
837331d6-3859-4e27-8baa-b0ff1d627c29 | 7 | public void LoadLocations()
{
for (String key : Locations.getCustomConfig().getConfigurationSection("Locations.") //$NON-NLS-1$
.getKeys(true))
{
if (key != null)
{
if (key.equalsIgnoreCase("loc_GameLobby")) //$NON-NLS-1$
{
loc_GameLobby = Locations.getLocation("Locations." + key); //$NON-NL... |
beb082c3-a8dc-4358-b3af-2845a1559eaf | 6 | @EventHandler
public void WitchSpeed(EntityDamageByEntityEvent event) {
Entity e = event.getEntity();
Entity damager = event.getDamager();
String world = e.getWorld().getName();
boolean dodged = false;
Random random = new Random();
double randomChance = plugin.getWitchConfig().getDouble("Witch.Speed.DodgeC... |
0f5cf76f-d103-4136-b1fa-ca6be0ef7664 | 9 | public static int getRankOfSeven(int card_1, int card_2, int card_3, int card_4,
int card_5, int card_6, int card_7) {
long KEY = deckcardsKey[card_1] + deckcardsKey[card_2]
+ deckcardsKey[card_3] + deckcardsKey[card_4]
+ deckcardsKey[card_5] + deckcardsKey[card_6]
+ deckcardsKey[card_7];
int FLUSH_C... |
7a5862c2-402c-490d-b081-a18cf1e30fea | 0 | public State getState() {
return myState;
} |
78bb6253-47ff-453e-8432-dcffffe8e73a | 7 | @Override
public String makeMobName(char gender, int age)
{
switch(age)
{
case Race.AGE_INFANT:
case Race.AGE_TODDLER:
return name().toLowerCase()+" fledgling";
case Race.AGE_CHILD:
switch(gender)
{
case 'm':
case 'M':
return "male owlet";
case 'f':
case 'F':
return ... |
37d2a0ae-4c09-460b-a19a-0b33c0e386a7 | 6 | private KeyAdapter fullscreenKeyController() {
return new KeyAdapter () {
public void keyPressed(KeyEvent evt) {
if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) {
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
gd.set... |
9ba4db21-08b6-4568-ba90-66022230f82e | 8 | public Decision chooseDecision(State s) {
if (!strategic)
return Util.sample(s.allPossibleDecisions(), random);
PlayerState ps = s.currentPlayerState();
Set<Decision> ds = new LinkedHashSet<Decision>(50);
if (ps.drawn_card != null) {
ds = DrawCardDecision.availableTo(s, ps, ds);
} else if (ps... |
d1e34ee8-1be2-44be-934e-92e6fa4cc6e1 | 3 | public List<Integer> spiralOrder(int[][] matrix) {
if(matrix.length == 0) return new ArrayList<Integer>();
List<Integer> result = new ArrayList<Integer>();
int m = matrix.length;
int n = matrix[0].length;
status = new int[m][n];
//init
... |
e5d0c091-2d9b-409d-a3bb-7f52d1fb6fdd | 3 | public static double ceil(double x) {
double y;
if (x != x) { // NaN
return x;
}
y = floor(x);
if (y == x) {
return y;
}
y += 1.0;
if (y == 0) {
return x*y;
}
return y;
} |
a5dab87b-1d70-4dce-a429-bedc2b703ab4 | 4 | @Override
public void run() {
byte[] clientSentence;
String capitalizedSentence;
ServerSocket welcomeSocket;
while (true) {
try {
Thread.sleep(1000);
welcomeSocket = new ServerSocket(1236);
Socket connectionSocket = welcomeSocket.accept();
DataInputStream inFromClient = new DataInputStream(
... |
702ac2e9-9dff-4e35-9a1f-bd5541e13e8d | 8 | public void drop(DropTargetDropEvent e) {
try {
DataFlavor stringFlavor = DataFlavor.stringFlavor;
Transferable tr = e.getTransferable();
if (e.isDataFlavorSupported(stringFlavor)) {
String filename = (String) tr.getTransferData(stringFlavor);
if (filename.endsWith(".txt") || filename.endsWith(".jav... |
49322ab9-4ebb-4c3f-8f51-b78fd6cdd97d | 9 | private ParsedCode parseXML(final String path) {
final ParsedCode parsedCode = new ParsedCode();
try {
final DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
.newInstance();
final DocumentBuilder docBuilder = docBuilderFactory
.newDocumentBuilder();
final Document doc = docBuil... |
81212ea2-bfee-42c5-a4c6-ae1e9b8f712a | 4 | public void body()
{
// send the registration to GIS
int register = 0;
if (policyType_ == ResourceCharacteristics.ADVANCE_RESERVATION) {
register = GridSimTags.REGISTER_RESOURCE_AR;
}
else {
register = GridSimTags.REGISTER_RESOURCE;
}
... |
b0488148-9fbe-4b52-8e90-c8d56be55156 | 0 | @Override
protected EntityManager getEntityManager() {
return em;
} |
99911997-8aee-4ecf-b3b8-eb4cb9f5e5df | 1 | private static boolean isValidStars(Integer stars) {
return stars <= STARS_MAX && stars >= STARS_MIN;
} |
c037fb54-3df1-44ec-af79-059a71d3cc6c | 2 | public static boolean generateFile(){
if (f != null){
if (f.exists()){
GameManager.state = State.LC_OW;
}
else {
overwriteFile();
}
}
return false;
} |
15cf3234-58d6-4546-a768-4f0366943cae | 9 | private static void runRuleByHeader(String header, String value){
//get Rule for header
Rule rule = rules.getRuleByHeader(header);
try {
Class<?> c = Class.forName("com.zuora.api.validator.plugin." + rule.getClassName());
Object t = c.newInstance();
//System.out.println("Methods found: ");
Metho... |
9dbbde50-a8c8-45c8-9d4b-c20b9d1744d3 | 6 | public static List<PTM> filterPTMsByAminoAcidSpecificity(List<PTM> ptms, String aa) {
List<PTM> resultPtms;
if(aa == null || aa.isEmpty()){
resultPtms = ptms;
}else{
resultPtms = new ArrayList<PTM>();
Specificity currentSpecificity = new Specificity(Specifici... |
87dabf8f-e613-41df-badf-46479a2efd2b | 0 | public static float[] GetEquationResult(float[][] array) {
return Elimination(array);
} |
3f4295e3-043c-405f-befb-af6131912ad5 | 0 | protected void reset() {
component_stack = new Stack();
elements_stack = new Stack();
attributes_stack = new Stack();
characters_stack = new Stack();
} |
28ffbdb7-7f03-4bae-9b9e-feef65b32964 | 5 | private static void processAction(ContactsExample example,
ContactsExampleParameters parameters) throws IOException,
ServiceException {
Actions action = parameters.getAction();
System.err.println("Executing action: " + action);
switch (action) {
case LIST:
example.listEntries(param... |
bd550d49-15fd-4950-9750-04a0719d8c2d | 7 | public boolean addElementFieldView(ElementField el) {
ElementFieldView element = null;
if (el instanceof Ball) {
element = new BallView(el.x(), el.y());
_ballsView.add((BallView) element);
} else if (el instanceof BoundaryField) {
element = new BoundaryView(((... |
0920b4b2-21f0-453a-a22d-a3558507d8fc | 5 | public static Mask buildGaussianMask(int size, double sigma) {
if (size % 2 == 0) {
size++;
}
Mask mask = new Mask(size);
double total = 0;
for (int i = -mask.getWidth() / 2; i <= mask.getWidth() / 2; i++) {
for (int j = -mask.getHeight() / 2; j <= mask.getHeight() / 2; j++) {
double gaussian = Math... |
09aa8962-fa0c-468f-8ae7-5075f1c1bb92 | 4 | public void processMenu(UIMenu menu) {
_out.println(menu.getHeading());
_out.println("Enter choice by number:");
for (int i = 1; i < menu.size(); i++) {
_out.println(" " + i + ". " + menu.getPrompt(i));
}
String response = getResponse();
int selection;
try {
selection = Intege... |
3dcb41bc-475a-4efa-ac4f-05ab612e8f8b | 7 | private void checkPromptInput() {
if (Keyboard.isKeyDown(Keyboard.KEY_RETURN)) {
if (canSelect) {
chooseSound.play();
canSelect = false;
if (yesSelected) {
if (selectedOption == 1) {
game.setScreen(Screens.MAIN_MENU);
} else {
game.quitGame();
}
} else {
exitPrompt =... |
8e9f44a6-e3f6-429c-9ddb-0e18cc6a2954 | 9 | private static ThreadGroup startMethodThreads(
final MultithreadedTestCase test,
SortedMap<String, Method> methods,
final LinkedList<java.lang.Thread> threads, final Throwable[] error) {
ThreadGroup threadGroup = new ThreadGroup("MTC-Threads");
final CountDownLatch latch = new CountDownLatch(methods.si... |
a0bcbcfd-ee88-4c52-8a69-34e2db96cb5c | 4 | public void dumpSource(TabbedPrintWriter writer) throws IOException {
if (isDeprecated) {
writer.println("/**");
writer.println(" * @deprecated");
writer.println(" */");
}
if (isSynthetic)
writer.print("/*synthetic*/ ");
int modifiedModifiers = modifiers;
/*
* JLS-1.0, section 9.3:
*
* E... |
41d4dc98-6f7a-4da4-ba56-1b01681b1f16 | 6 | private static void parseCommandLine(final String[] args) {
for (final String arg : args) {
if (arg.startsWith("--")) {
final String command = arg.substring(2);
final int index = command.indexOf('=');
if (index < 0) {
OPTIONS.put(co... |
5a3d0823-97c8-4c10-bc64-d6d43729e6fa | 6 | public static void postForm(@Required long inputLoanAmount, int inputBank, long inputRegularIncome,
long inputRegularBills, long inputCreditCard, long inputBankAccount) {
if(validation.hasErrors()) {
response.status = 400;
renderJSON(validation.errors().toArray());
}
... |
3316ba2c-db70-4268-9424-9fb748297010 | 3 | private void processRequests() {
//iterate through the map
for (int x=0; x<getMapWidth(); x++) {
for (int y=0; y<getMapHeight(); y++) {
//handle a request
//TODO not pick the first received request
if (requests[x][y].size()>0) {
... |
e06a44e8-5741-4ea2-82ed-107c81f7a700 | 0 | public long getClientId() {
return clientId;
} |
eb476b1e-d137-47ec-afd8-e0fc93259532 | 8 | @Override
/**
* Returns the generated sentence in String form.
*/
public String toString() {
if (this.eventObject.size() < 1 && this.eventSubject.size() < 1) {
return "< Error in FindGroupSentence: No object nor subject found >";
}
if (this.checkObject() && this.c... |
8db1cc02-8b62-4a89-8e0d-614d1f8c3dc6 | 2 | @Override
public boolean shouldReact(Message message) {
return message.text.startsWith(MESSAGE_PREFIX)
&& message.text.length() > MESSAGE_PREFIX.length() + 1
&& Math.random() <= PROBABILITY_TO_SLAP;
} |
b48a6cec-e29b-4823-92a4-0e9c1a90624f | 7 | @Override
public void run() {
if (options.useBOB.get() && !options.usedBOB.get() && ctx.summoning.summoned() && options.beastOfBurden.bobSpace() > 0) {
options.status = "Taking items from BoB";
script.log.info(options.status);
final int inventoryCount = ctx.backpack.select().count();
if (ctx.summoning.... |
7a20e5db-61f4-493d-8a14-9a3a2db9b0ff | 0 | public void setConsignee(String consignee) {
this.consignee = consignee;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.