method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
63a84e14-1160-4d8f-b995-4ac1df2e59dc | 6 | private PuuSolmu remove( PuuSolmu solmu, PuuSolmu juuri )
{
if( juuri == null )
return juuri;
int vertailu = vertaaSolmuja(solmu, juuri);
//Jos poistettava on pienempi kuin juuri, poistetaan vasemmalla
if(vertailu < 0){ ... |
0d396bd3-769a-482b-ac73-6495ba9f4bf7 | 8 | private static void parseArgs(String[] args) {
try {
boolean isNameNode = false;
InetAddress address = InetAddress.getLocalHost();
int port = 15332;
for (int i = 0; i < args.length; i++) {
/* It is the namenode */
if ("-n".equalsIgnoreCase(args[i])) {
isNameNode = true;
}
/* Add... |
798576fb-4d0d-4e3a-b3bb-0a8ef0f00186 | 8 | public static String fixURL(String URI) {
//System.out.println("\tFIX URL Getted URI: "+URI);
if (URI.length() >= 7 && URI.indexOf("http://", 0) == 0)
URI = URI.substring(7);
String s = URI;
int startIndex = s.indexOf('#');
if (startIndex >= 0) {
StringBuilder sb = new StringBuilder(s);
s = sb.delete... |
ef7a0dd2-71ef-47cb-9664-65de71600d20 | 1 | public List<KeyPackageType> getKeyPackage() {
if (keyPackage == null) {
keyPackage = new ArrayList<KeyPackageType>();
}
return this.keyPackage;
} |
5470e9d6-fc4c-4217-b8d3-ba9d20cfa789 | 8 | @Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
String serviceName = (String) table.getValueAt(row, column - 1);
User user = instanceGUI.getUser();
JLabel label;
// Check if transfer active for this
User... |
59ec41ed-4b66-44da-8192-553323758e92 | 1 | public static void start() throws IOException {
ContactManager manager = new ContactManagerImpl(0);
manager.addNewContact("Bill Smith", "");
manager.addNewContact("Jim Smith", "");
manager.addNewContact("Sally Smith", "");
manager.addNewContact("Sue Smith", "");
... |
9dbfcee5-f750-4746-99cf-7fd7c0dadfaf | 6 | public void accept(final MethodVisitor mv) {
switch (type) {
case Opcodes.F_NEW:
case Opcodes.F_FULL:
mv.visitFrame(type, local.size(), asArray(local), stack.size(),
asArray(stack));
break;
case Opcodes.F_APPEND:
mv.visitFrame(type, local.size(), asArray(local), 0, null);
break;
case Opcodes.... |
de80863e-6c89-454a-b243-d82626296125 | 3 | private void cutRod(int n)
{
// For each incrementally greater length of the rod
// determine the cut which will produce the greatest revenue
for (int i = 1; i <= n; i++)
{
int max = Integer.MIN_VALUE;
// The maximal revenue of all possible cuts of length i
for (int j = 1; j <= i; j++)
if (p[... |
880f877b-2cda-4f87-b053-c65c1bceb348 | 0 | public static void main(String[] args) {
test(new Base());
System.out.println("----------------------------------------------------");
test(new Derived());
} |
b5e3e61a-6c8c-47dd-b99e-333f2dd63b6a | 1 | public void actionPerformed(ActionEvent event)
{
Date now = new Date();
System.out.println("At the tone, the time is " + now);
if (beep) Toolkit.getDefaultToolkit().beep();
} |
32e96a82-8a89-47a6-8972-87b84937a51f | 5 | @Override
public void run() {
if (remainingIron() < nextDeposit[0]) {
nextDeposit[0] = Random.nextInt(500, 2000);
depositOre(ID_IRON_NOTED);
}
if (remainingMithril() < nextDeposit[0]) {
nextDeposit[0] = Random.nextInt(500, 2000);
depositOre(ID_MITHRIL_NOTED);
}
if (remainingAdamant() < nextDepo... |
82c03651-ee00-470d-a6b5-27338ac3a3f3 | 9 | public static int maximalInRow(int[] row, int len) {
int last = -1;
int maxSize = 0;
Stack<Integer> stack = new Stack<Integer>();
int minHeight = Integer.MAX_VALUE;
for(int i=0;i<len;i++) {
if(stack.empty() || row[i] >= last) {
stack.push(i);
last = row[i];
}else {
... |
402faa7a-fb3d-4355-87c9-7a0593572ef6 | 0 | public int peek() {
return runStack.get(runStack.size() - 1);
} |
fe842a63-4491-489b-b1a7-27f7fabb8dbe | 7 | @Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SocketId other = (SocketId) obj;
if (host == null)
{
if (other.host != null)
return false;
} else if (!host.equals(other.host))
re... |
890d4d1d-d28a-4724-86bd-615f78a2e1e9 | 5 | public void afficherPopupParties(final Profil profil) {
// Empeche de cliquer sur la fenetre principale
this.setEnabled(false);
// Mise a jour du nom du joueur
this.nomProfil.setText(profil.getNom());
FlowLayout fl = new FlowLayout();
this.panelParties.... |
fe0cb31b-9046-4957-919e-68e5f4f1cb91 | 1 | public void makePurchase(int amount) {
if (amount > balance) {
throw new IllegalArgumentException("Amount of the purchase exceeds the balance");
}
this.balance = this.balance - amount;
} |
b11193e4-b435-4f11-ada0-abf5f51c1e6a | 2 | private static void traverseNode(TreeItem treeItem) {
VCNTreeItem item = (VCNTreeItem) treeItem;
if (item.isBold) {
item.setFont(newBoldFont);
}
for (TreeItem ti : treeItem.getItems()) {
traverseNode(ti);
}
} |
4efef57b-2cd7-4c33-905a-dd248291d9a3 | 8 | private static void runExperiments(List<PathFinder> finders, List<Integer> lengths, List<Double> confidences){
System.out.print("Will try: ");
for (PathFinder finder : finders)
System.out.print(finder.getClass().getName() + " ");
System.out.print(", For lengths: ");
for (Integer length : lengths)
System.o... |
355df61d-6753-4ebf-a200-72477c807ba4 | 8 | public static double[] normalizeArray(double[] values, double normalizedSum) {
if (Double.isInfinite(normalizedSum)) {
throw new MathIllegalArgumentException(LocalizedFormats.NORMALIZE_INFINITE);
}
if (Double.isNaN(normalizedSum)) {
throw new MathIllegalArgumentExcep... |
3035eef4-a3bf-4d57-a1fb-31ff1d0821b6 | 6 | public static Model loadModel (File f, boolean textured) throws FileNotFoundException, IOException{
BufferedReader reader = new BufferedReader(new FileReader(f));
Model m = new Model();
String line;
while ((line = reader.readLine()) != null){
// Import vertices from .obj file
if (line.startsWith("v "))... |
a18ea1ac-a9dd-4442-abee-942e26a6b61d | 8 | @SuppressWarnings("unchecked")
private void collectPreloadEntities(
final Map<PreloadAccessor, Collection<Object>> bulkPreloadMap,
final Set<Object> visited, final Object entity,
final PreloadAccessor[] preloads,
final Map<Object, Object> alreadyLoadedEntities) {
if (entity == null || preloads == null) {... |
652ce1c7-e156-43be-a7c8-ddf038f2982b | 6 | public void searchRecommendedFlights() {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
System.out.println("Where is your MySQL JDBC Driver?");
e.printStackTrace();
}
PreparedStatement ps = null;
Connection ... |
30314928-dd21-4a29-9381-cd1ea0b98d57 | 7 | public String toString() {
int[][] miniBoard = new int[height * 2][width * 2];
for (int row = 0; row < miniBoard.length; row++) {
for (int col = 0; col < miniBoard[row].length; col++) {
miniBoard[row][col] = 0;
}
}
miniBoard[height][width] = 1; //gblock moved from (0, 0)
for (Point p : points)
... |
d86a5557-c0fd-4e25-9d68-61891c627ea5 | 6 | public void run() {
int t = 0;
try {
InputStream in = receivesocket.getInputStream();
OutputStream out = sendsocket.getOutputStream();
while (true) {
int len = in.read(buffer);
if (len != 0) {
if (t == 0) {
String s = new String(buffer).substring(0, len);
System.out.println("init: ... |
84484484-54bb-41ff-abe1-848c8ab9a6b7 | 2 | public boolean addCensoredWord(String word) {
if (censoredWords == null) censoredWords = Lists.newArrayList();
if (censoredWords.contains(word.toLowerCase())) return false;
censoredWords.add(word.toLowerCase());
return true;
} |
7ade7995-3c63-4101-ac18-e9e5923a4a27 | 1 | private double calculateComponentConsumptionEP(LifelineElement receiver) {
double componentConsumption = 0;
try {
Component component = (Component) receiver;
componentConsumption = component.getUsageCPU().getEnergyPoints() + component.getUsageHDD().getEnergyPoints() + component.getUsageMemory().getEnergyPoint... |
634e0e10-94ee-4bef-9a39-15c520b8132d | 4 | @SuppressWarnings("unchecked")
public <E> E executeGetMethod(E instance, Method method) {
if(method == null)
return null;
try {
return (E) method.invoke(instance);
} catch (IllegalArgumentException e) {
System.err.println("<ClassInspect> Failed to execute GET Method <" + method.getName() + ">. Method s... |
4f59ec94-bf13-4a5b-ba08-aa809a0fdd36 | 0 | public SalableRange getSalableRange() {
return this._salableRange;
} |
a01dfc0b-a4f5-4099-82a1-8a6415a59369 | 2 | public void highlight(boolean[] hl)
{
for(int i = 0; i < 6; i++)
if(!hl[i])
txtComps[i].setForeground(Color.RED);
else
txtComps[i].setForeground(Color.GREEN);
} |
eee47031-5158-4b2e-a885-59b0aedbd005 | 8 | private void addBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addBtnActionPerformed
question = questionField.getText();
instructions = instructionField.getText();
if (instructions.equals("")|| instructions==null)
JOptionPane.showMessageDialog(null, "y... |
9bb3d39f-df69-4b61-8457-d2c37c9c1e6c | 8 | private void expand(Node crt) {
while (crt != null && !crt.isVisited()) {
crt.setVisited(true);
for (Cord c : crt.getNb()) {
if (c == null)
continue;
Node nd = nodes[c.i][c.j];
if (nd == null)
continue;
Integer dist = nd.costFrom(crt, panel, to.getDirectP());
if (dist == null)
... |
87e2dd2d-a5de-4ad3-9576-ab4a1d5f6ec2 | 7 | @Override
public int attack(NPC npc, Entity target) {
final NPCCombatDefinitions defs = npc.getCombatDefinitions();
npc.setNextAnimation(new Animation(defs.getAttackEmote()));
delayHit(
npc,
0,
target,
getMeleeHit(
npc,
getRandomMaxHit(npc, defs.getMaxHit(), defs.getAttackStyle(),
... |
74c74bc0-42be-4ec8-b6b1-071ecccec624 | 6 | public static HashMap<String, Integer> findRepetition(ArrayList<Sentence> listOfSentences) {
HashMap<String, Integer> repetitionValues = new HashMap<String, Integer>();
// key - a word that is repeated;
// value - the number of repetitions
// in different sentence
HashM... |
66863587-9c8c-4dcc-a1ad-c0e0c1087f19 | 7 | private MidiDevice openMidiDevice(String containsString) {
message("Searching for MIDI device with name containing '"
+ containsString + "'");
MidiDevice device = null;
MidiDevice.Info[] midiDevices = MidiSystem.getMidiDeviceInfo();
for (int i = 0; i < midiDevices.length; i++) {
device = null;
try {
... |
57deaff7-0f5b-400a-8b67-c08356b94cdc | 9 | public static boolean fileprocess(String downloadpath, String filepath, String []paras, String sn){
int errorcode=0;// print error code in the final output file;
int errornum=6; // feature number
String result="";
double emmc_size=0;
double size = 0;
File downloadfile = new File(downloadpath+"\\emmc_test.... |
8971305f-a3bc-438d-a02e-e138156de24a | 7 | public int goodPick() {
for (int j = VALID_PICK.length - 1; j >= 0; j--) {
if (c.playerEquipment[c.playerWeapon] == VALID_PICK[j]) {
if (c.playerLevel[c.playerMining] >= PICK_REQS[j])
return VALID_PICK[j];
}
}
for (int i = 0; i < c.playerItems.length; i++) {
for (int j = VALID_PICK.length - 1;... |
8a390137-6af6-4a8d-badb-8cb88d766a7a | 9 | private String readFileAsString(String filename) throws Exception {
StringBuilder source = new StringBuilder();
FileInputStream in = new FileInputStream(filename);
Exception exception = null;
BufferedReader reader;
try {
reader = new BufferedReader(new InputStreamR... |
b9d03255-8c55-482d-bad8-652f08179e67 | 1 | private void append(String str) {
java.util.Date date = new java.util.Date();
String leader = "" + new Timestamp(date.getTime());
leader = String.format("%1$-" + 24 + "s", leader);
str = leader + str + "\n";
try {
Document doc = debugText.getDocument();
... |
917e01a4-d2a3-4139-9b21-798116ebf0a0 | 6 | public static void main( String[] args ) {
Fiche fiche = null;
System.out.println( "--------------------------------------------------------------" ) ;
System.out.println( " Test du constructeur\n" ) ;
// Test Constructeur Fiche avec et sans erreurs.
try {
System.out.print( "[*] Test basé sur une chaine de... |
353802bc-9a20-4857-885f-be1b979b29e9 | 4 | private void removeNodeWithTwoChildren(Node u)
{
Node n = getNext(u);
u.key = n.key;
Node removedsRight = n.right;
if (n.parent == u)
{
u.right = removedsRight;
if (removedsRight != null) removedsRight.parent = u;
}
else
{
... |
07ecdfbc-1e03-4d82-8248-b6c3dffbba8d | 3 | static int registrerProtocolType(String message) {
if (message.startsWith(CONNECT)) {
return 1;
}
if (message.startsWith(SEND)) {
return 2;
}
if (message.startsWith(CLOSE)) {
return 3;
}
r... |
c4b85ad8-ebf4-4ca4-9c03-2b6944c86449 | 6 | public void testApp() {
Log4JStopWatch watch = new Log4JStopWatch(log);
PoolingClientConnectionManager pool = new PoolingClientConnectionManager();
pool.setDefaultMaxPerRoute(20);
final HttpClient httpClient = new DefaultHttpClient(pool);
ForkJoinPool forkJoinPool = new ForkJoinP... |
d2b7858f-55af-4388-826a-526617c74bb9 | 4 | private void btnRemoverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoverActionPerformed
if(JOptionPane.showConfirmDialog(rootPane, "Você tem certeza que deseja "
+ "apagar o produto selecionado ?","",JOptionPane.OK_CANCEL_OPTION)== 0){
try {
... |
1756d958-3400-4e02-b27c-6fad33b560d2 | 9 | public int trap(int[] A) {
if (A.length <= 2) return 0;
int rst = 0;
int i = 0;
int hight = A[i];
while (true) {
int j = i + 1;
while (j < A.length && A[j] < hight)
j++;
if (j < A.length)
rst += calc(i, j, hight, A);
else
break;
i = j;
hight = A[j];
}
i = A.length - 1;
... |
2b6ab459-aa35-4dfb-a4f6-5a8717adce97 | 7 | public static int getTPDUService(final byte[] tpdu)
{
final int ctrl = tpdu[0] & 0xff;
if ((ctrl & 0xFC) == 0)
return 0;
// 0x04 is tag_group service code, not used by us
if ((ctrl & 0xFC) == 0x04)
return 0x04;
if ((ctrl & 0xC0) == 0x40)
return T_DATA_CONNECTED;
if (ctrl == T_CONNECT)
return T_... |
ad1419fd-b8ec-45de-9613-b202bc6453d9 | 6 | @Override
public Object process(Object value, ValueProcessInvocation invocation) throws BeanMappingException {
BeanMappingField currentField = invocation.getContext().getCurrentField();
if (currentField.isMapping() == false && invocation.getContext().getBeanObject().getBehavior().isDebug()
... |
9362c57d-1665-4797-b2d6-2b74afefcb7c | 1 | private String userResponse() {
String playerName;
try {
playerName = bufferedReader.readLine();
} catch (IOException e) {
throw new UncheckedIOException();
}
return playerName;
} |
e11bead2-ea04-4981-a4f0-8a0f8b80c57a | 9 | public Transition<ET, ?> nextTransition(State<ET> inputState, Event<?> event,
ET entity) throws FiniteStateException
{
if (!initialized)
throw new FiniteStateException(
"State map not yet initialized through call to build() method");
State<ET> matchingSta... |
82f92a6f-dca5-4ce6-b465-71b86bad01f7 | 1 | public boolean makeMove(Move move) {
if (this.checkMoveEligible(move)) {
this.board[move.getRow()][move.getColumn()] = move.getPlayer();
return true;
}
return false;
} |
8f3254b1-db5d-4fdc-ae1c-b925b689c924 | 6 | public static void main (String[] args) {
String string_in = new String();
int count_voc = 0;
int i = 0;
char char_tmp;
int length_string = 0;
Scanner kb = new Scanner (System.in);
System.out.println ("Inserisci Una Stringa: ");
string_in = kb.nextLine();
length_string = string_in.length();
... |
40cba517-fd5f-42b2-a36f-4df00d95fd4c | 9 | @Override
public void checkMail() {
super.checkMail();
List<Literal> percepts = convertMessageQueueToLiteralList(getTS().getC().getMailBox());
model.update(percepts);
Iterator<Message> im = getTS().getC().getMailBox().iterator();
while (im.hasNext()) {
Message message = im.next();
Literal percept... |
07709ab2-ebdb-4263-8f21-27f9f83b883d | 9 | private void sum (int type) {
if (type >= 1 && type <= 4) a++;
if (type >= 7 && type <= 14) b++;
if (type >= 15 && type <= 18) c++;
if (type == 0) d++;
if (type == 5 || type == 6) e++;
sumFields = a + b + c + d + e;
} |
fa782cd2-8641-4e99-aad2-6038b737f53c | 5 | @Override
public void check(Minecraft m, ByteClass bClass)
{
byte[] data = bClass.getData();
for (int i = 0; i < data.length + 1 - checkData.length; i++)
{
boolean searching = true;
int sIndex = 0;
while (searching)
{
if (d... |
8ccedfdf-7b51-4682-b7ac-88133daab415 | 6 | protected void calcSize() {
if (image != null) {
imgWidth = image.getWidth(null);
imgHeight = image.getHeight(null);
if (getWidth() != 0 && getHeight() != 0) {
int w = getWidth() - imgWidth;
int h = getHeight() - imgHeight;
if... |
cee4e8f5-49e0-486c-96f4-309c63d87f7a | 1 | public ChessGameConfiguration putPiece(Piece piece,int boardPosition)
throws IllegalMark{
ChessGameConfiguration out;
Cell[] newCellBoard = Arrays.copyOf(this.currentBoard, this.currentBoard.length);
//
CellMarkerFactory cellMarkFactory = CellMarkerFactory.getInstance()... |
d7a307f7-2924-499b-874d-52a4d275ff0d | 3 | public void setUpCheckBoxes(Set<Card> cards) {
for (Card card : cards) {
String name = card.getName();
if (card.getType().equals(CardType.PERSON)) {
people.add(new JCheckBox(name));
} else if (card.getType().equals(CardType.WEAPON)) {
weapons.add(new JCheckBox(name));
} else {
rooms.add(new JC... |
fcc9eda6-d0a9-4e61-91a4-2e073a096ef0 | 0 | public void setTitleText(String text) {
surfacePanel.setTitleText(text);
} |
c03d3c97-62f5-4853-9c62-65b8b7964ea8 | 4 | public void drawTile(Tile tile, Graphics2D g2d, int x, int y, int width, int height, Menu menu) {
if(tile.visible) {
g2d.translate(x,y);
/*
if((tile.menuID >= 0) && (tile.menuID == menu.selected)) { g2d.setColor(COLORS[2]); }
else { g2d.setColor(tile.color); }
*/
drawHex(g2d,widt... |
e8f5cf9e-ab51-4e06-8d90-50e4055c3e05 | 2 | public AttachDetachCommand(String cmd, CommandSender cs, String[] args){
if(cmd.equalsIgnoreCase("attach")){
ExecuteAttach(cs, args);
} else if(cmd.equalsIgnoreCase("detach")){
ExecuteDetach(cs, args);
} else {
//This should never be called, but let's just make sure the user knows if we somehow did get h... |
45cdd2fe-f005-4931-bd21-3328127857e8 | 2 | @Override
public void selectionDidChange() {
if (mNotifyOfSelections) {
OutlineModelListener[] listeners = getCurrentListeners();
for (OutlineModelListener element : listeners) {
element.selectionDidChange(this);
}
}
} |
1a3bd526-4bb8-4594-9b40-ca4de78275d9 | 8 | Dimension computeSize(IFigure figure, boolean flushCache) {
if (cacheWidth != -1 && cacheHeight != -1) {
return new Dimension(cacheWidth, cacheHeight);
}
for (int i = 0; i < cacheIndex + 1; i++) {
if (cache[i][0] == widthHint && cache[i][1] == heightHint) {
cacheWidth = cache[i][2];
cacheHeight = ca... |
cbb6137a-df0a-4c07-99ab-149c1301e508 | 1 | public void setName (String val) throws IllegalArgumentException{
if (val == null)
throw new IllegalArgumentException();
//val != null
this.name = val;
} |
5044f0bc-1bb0-4fa7-baaf-63d978be0a7e | 4 | private void interpreterCle(String k) {
ArrayList<Character> dejaVu=new ArrayList<Character>();
for(int i=0;i<k.length();i+=2) {
if(!dejaVu.contains(k.charAt(i)) && !dejaVu.contains(k.charAt(i+1)) && k.charAt(i)!=k.charAt(i+1)) {
this.h.put(k.charAt(i), k.charAt(i+1));
this.h.put(k.charAt(i+1), k.charAt(... |
3711b07d-ed9d-4287-8574-9b0801cd15bf | 7 | public void renamedEnum(String oldName, Enum<?> currentValue) {
if (oldName == null) {
throw new IllegalArgumentException("oldName must not be null");
}
if (currentValue == null) {
throw new IllegalArgumentException("currentValue must not be null");
}
Clas... |
1626f4be-0079-4f2f-b082-9a3d20e3992c | 8 | private static boolean getMethods(Term term, Vector vect) {
boolean result = true;
if (term.var != null) {
return result;
} else if (!term.operation.behavorial) {
return false;
} else if (term.operation.isMethod()) {
boolean found = false;
for (int i=0; i<vect.size(); i++) {
Operation op = (O... |
93b76ad8-a24a-404e-a9a2-5e2038a1f814 | 2 | @Override
public boolean equals(Object obj) {
if (obj instanceof BITalinoFrame) {
BITalinoFrame that = (BITalinoFrame) obj;
return Objects.equal(this.crc, that.crc)
&& Objects.equal(this.seq, that.seq);
}
return false;
} |
c0becddf-1184-4a7c-bd2a-6eeb13825287 | 3 | public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String line = "";
StringWriter out = new StringWriter();
fillPre(LIM);
while ((line = in.readLine()) != null && line.length() != 0) {
int nSet = Integer.parseInt(line.trim()... |
ec4d46ab-7309-4e6c-8ceb-93172184f916 | 2 | public static boolean palindrome( int x) {
String s = Integer.toString(x);
for( int i = 0; i <= s.length()/2; i++) {
if( s.charAt(i) != s.charAt(s.length()- 1- i)) {
return false;
}
}
return true;
} |
eacf9b99-2cef-4a48-a43f-c1cddbc66ca3 | 7 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Cargo other = (Cargo) obj;
if (!Objects.equals(this.cargoid, other.cargoid)) {
return false;
... |
1b2c9210-a8d5-4c1f-8558-3412fb1d3f2b | 3 | public void xyzToFront()
{
int insertAt = 0;
ArrayList<String> xyz = new ArrayList<String>();
// TODO: Move any word that starts with x, y, or z to the front of the ArrayList, but otherwise preserves the order
for (int i = list.size()-1; i > 0; i--)
{
String current... |
06d76318-f079-4846-9885-a7ee877fbfa8 | 9 | public Card midPlay(ArrayList<Card> n){
if (isLeading == false && _trickSuit != 0){
for (int x = 0; x < n.size(); x++){
if (n.get(x).getSuit() == 0){
return n.get(x);
}
}
}
if (isLeading == false && _trickSuit ==... |
3b1237f0-3901-44bc-aca2-afa8a7726208 | 5 | @Override
public boolean onKeyDown(int key) {
super.onKeyDown(key);
if(selected) {
if(key == Keyboard.KEY_RETURN) {
ConsoleFactory.get().processInput(currentInput);
currentInput = "";
return true;
}
else if(... |
ab7718d8-958d-4220-ab13-c29100c7c6f5 | 1 | public void rememberDef(final LocalExpr e) {
if (MethodEditor.OPT_STACK_2) {
uMap.add(e, (Instruction) code.get(code.size() - 1));
}
} |
837f0f66-2df6-4be0-962a-081ed255b33a | 9 | protected void rebuildBeanConnections(Vector deserialized, Object key) throws Exception {
int i;
int n;
int sourcePos;
int targetPos;
String event;
boolean hidden;
Vector ... |
242c2034-20b8-40b9-a319-ff496d718036 | 7 | @Override
public void keyPressed(KeyEvent e) {
int code = e.getKeyCode();
int dx = 0;
int dy = 0;
if (code == KeyEvent.VK_LEFT) {
dx = -1;
} else if (code == KeyEvent.VK_UP) {
dy = -1;
} else if (code == KeyEvent.VK_RIGHT) {
dx = 1;... |
81692044-f09b-43a2-ba3d-0650f52f3c05 | 8 | private static String initialise(Token currentToken,
int[][] expectedTokenSequences,
String[] tokenImage) {
String eol = System.getProperty("line.separator", "\n");
StringBuffer expected = new StringBuffer();
int maxSize = 0;
for (int i = 0; i < expe... |
0577b9d8-0656-47b3-9454-e490efbaa026 | 0 | public void setSubjects(String subjects) {
this.subjects = subjects;
} |
23140087-3597-4cd1-8634-29b4172ce6bd | 8 | public void actionPerformed(ActionEvent e){
if(drawing.frame <29){
drawing.frame++;
}else{
drawing.frame=0;
}
if(startTime==true){
time++;
}else{
time=0;
}
MenuSelect.menuItems = MenuSelect.Dmenu.get(MenuSelect.menu);//if out of bounds errors here then create menu is doing somethin... |
3953df45-8f15-4e54-b7c1-55421d81f280 | 4 | private String Change_POS(String str)
{
if(str.compareToIgnoreCase("Noun")==0)
return "বিশেষ্য";
else if(str.compareToIgnoreCase("Pronoun")==0)
return "সর্বনাম";
else if(str.compareToIgnoreCase("Adjective")==0)
return "বিশেষন";
else if(str.compareT... |
181b1e0c-5b2b-4ef9-80b6-71130b0863e5 | 1 | @Override
protected void nodeCompleted(Object parent, Object node) {
current = (Buildable) parent;
if (log.isLoggable(Level.CONFIG)) {
log.config("Completed: " + parent + " " + node);
}
} |
51b4424c-cd60-4049-a9eb-4e63fd534180 | 3 | private void go(){
Scanner in = new Scanner(System.in);
int n = in.nextInt();
x = in.nextInt();
int xCopy = x;
ArrayList<Candy> t0 = new ArrayList<Candy>();
ArrayList<Candy> t1 = new ArrayList<Candy>();
ArrayList<Candy> t0Copy = new ArrayList<Candy>();
ArrayList<Candy> t1Copy = new ArrayList<Candy... |
bd461c83-496b-446b-9431-84dc794c3947 | 3 | public static void main(String[] args) {
for (int i = 1; i <= 100; i++ ) {
if (i % 3 == 0) {
System.out.println(i);
}
}
System.out.println("Fatoriais");
for (int n = 1, fatorial = 1; n <= 10; n++) {
fatorial *= n;
System.out.print("Fatorial de " + n + " = ");
System.out.println(fatorial... |
23cc66a7-cb34-4be8-8839-81e7193afbad | 9 | public void run() {
BoardState board = new BoardState();
Stack<BoardState> gameboards = new Stack<BoardState>();
int r = 0;
int c = 0;
board.num_of_queens = 0;
while (c < BOARD_SIZE) {
while (r < BOARD_SIZE) {
// System.out.println(r + " " + c);
if (QueenConflicts(board, r, c) == 0) {
Syst... |
abbd6b10-ff72-4ec1-933a-cd99d67e2ceb | 0 | @Test
public void findDuplicateTypeHand_whenThreeSevensAndAceKingExist_returnsTripSevenswithAKKickers() {
Hand hand = findDuplicateTypeHand(threeSevensAndAceKing());
assertEquals(HandRank.ThreeOfAKind, hand.handRank);
assertEquals(Rank.Three, hand.ranks.get(0));
assertEquals(Rank.Ace, hand.ranks.get(1));
ass... |
fb42d204-1d96-4dab-a726-8776a6d3ec7d | 1 | public Statement NewStatement() {
try {
return this.dbConnection.createStatement(/*ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE*/);
} catch (SQLException ex) {
System.out.println("Impossible de créer le statement demandé.\n" + ex.getMessage());
}
... |
e862e046-8c6c-45e6-bcae-883ede4d29a6 | 2 | public void loadData(boolean isKrak)
{
final boolean isKrakB = isKrak;
// Solution with thread taken from StackOverflow: http://stackoverflow.com/questions/9419252/why-does-this-simple-java-swing-program-freeze
Thread thread = new Thread() {
@Override
@SuppressWarnings("empty-statement")
public void run... |
767d7b36-2147-438d-8b84-7a327ccd8b03 | 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... |
6c254258-d866-448a-ac68-e4990eb150e8 | 4 | @Override
protected boolean perform(final CommandSender sender, final Command command, final String label, final List<String> args, final Region region) {
String owner = RegionExecutor.parse(args, 0, "<Owner>", sender);
if (owner == null) return false;
if (region.owners.contains(owner)) {
... |
167048a7-efd1-4a57-bb23-2e3fac7405c6 | 6 | public void init(PolicyFinder finder) {
// now that we have the PolicyFinder, we can load the policies
PolicyReader reader = new PolicyReader(finder, logger, schemaFile);
Iterator it = policyList.iterator();
while (it.hasNext()) {
String str = (String)(it.next());
... |
3c79662a-aa6c-45d1-83bc-839cf16e2da6 | 5 | public void doRoboty() {
try {
Socket gniazdo = new Socket("localhost", 6666);
InputStreamReader czytnikStrumienia = new InputStreamReader(gniazdo.getInputStream());
BufferedReader czytnik = new BufferedReader(czytnikStrumienia);
String komunikatSerwera = czytnik.... |
8f4a2136-7f28-4a18-8888-0adae4ba80d3 | 8 | public static void main(String[] args) throws Exception {
String env = null;
if (args != null && args.length > 0) {
env = args[0];
}
if (! "dev".equals(env))
if (! "prod".equals(env)) {
System.out.println("Usage: $0 (dev|prod)\n");
... |
ecff3a5c-64ac-4bac-b049-4b360b41ba74 | 0 | public static void main(String[] args) {
suballoy = new Alloy();
System.out.println("Hello.");
CalculateService cs = new CalculateService();
ReportService rs = new ReportService();
cs.start();
rs.start();
System.out.println("Goodbye.");
} |
bface058-1537-4471-8210-50ae19af68f3 | 5 | public void drop() {
for (byte i = 0; i < 16; ++i) {
for (byte j = 0; j < 16; ++j) {
File file = new File(getFullName(new DirFile(i, j)));
if (file.exists()) {
if (!file.delete()) {
throw new DataBaseException("Cannot delete... |
d707fc87-206c-44c6-8e97-76d2d3521c1a | 5 | @Override
public void write(String path) {
BufferedWriter buffer = null;
long startTime = System.currentTimeMillis();
try {
buffer = new BufferedWriter(new FileWriter(path));
buffer.write(rows + " " + cols + "\r\n");
for (int i = 0; i < rows; i++) {
... |
d3f09694-d971-4575-9894-d0490e4e80e8 | 8 | public boolean equals( Object other ) {
if ( ! ( other instanceof TObjectDoubleMap ) ) {
return false;
}
TObjectDoubleMap that = ( TObjectDoubleMap ) other;
if ( that.size() != this.size() ) {
return false;
}
try {
TObjectDoubleIterator... |
a713ad09-5a9d-4d33-a9a8-db88d2310f5e | 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 Sintoma)) {
return false;
}
Sintoma other = (Sintoma) object;
if ((this.idSintomas == null && other.idSintomas ... |
de49379d-4789-4337-89aa-613e482d4f9f | 8 | public static String composeQuery(String anime_title, String[] args) {
String queryString = "SELECT * WHERE {";
if (args.length > 1) {
queryString = queryString + "{";
}
// Mapping a title to its genre -> get all category -> retrieve all genres in all categories
queryString = queryString
+ "SELECT DI... |
fdcd357e-1dbf-4bff-950b-ce567cd08f65 | 2 | private String handleDelete(String cmd) {
String[] arg = cmd.split("\\s+"); // delete entry
if (arg.length < 2) {
return " usage: del <name>...\n";
}
for (int i = 1; i < arg.length; i++) {
p.remove(arg[i]);
}
((AbstractTableModel) table.... |
efa52ad6-7db6-4a67-aeb5-dccea9500f8d | 4 | @SuppressWarnings("unchecked")
Object getMatchResult(String args[], int idx, int cnt, String errMsg,
int resultIdx) {
boolean exceptionThrown = false;
int k = 0;
try {
k = parser.matchArg(args, idx);
} catch (Exception e) {
exceptionThrown = true;
checkException(e, errMsg);
}... |
f30066b1-ef34-4e9a-961f-f01be7881f47 | 7 | @Override
public void clickEvent(MouseEvent e, String actionCommand) {
if(test != null)
test.clickEvent(e, actionCommand);
else if(actionCommand != null){
switch (actionCommand){
case "gridTest":
test = new Tests.gridTest(this);
break;
case "jldTest":
test = new Tests.jldTest();
break;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.