method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
1fc5f4c2-0275-405d-82f6-248a61368d54 | 4 | public static void printGappedConsensusToFile(String path, Consensus consensus,boolean append) {
try {
FileWriter fr = new FileWriter(new File(path), append);
fr.write(">"+consensus.getLayoutID());
StringBuilder builder = new StringBuilder();
for (int i = 0; i < consensus.getSymbols().size(); i++) {
... |
24f39d88-7591-4ecc-bb10-406eacc1d96e | 3 | protected void submitPurchaseButtonClicked() throws ParseException {
log.info("New payment started");
try {
log.debug("Contents of the current basket:\n"
+ model.getCurrentPurchaseTableModel());
domainController.submitCurrentPurchase(model
.getCurrentPurchaseTableModel().getTableRows());
doub... |
2399bcd0-25a9-4394-bd22-a749af49ae00 | 4 | public JSONObject toJSONObject(JSONArray names) throws JSONException {
if (names == null || names.length() == 0 || length() == 0) {
return null;
}
JSONObject jo = new JSONObject();
for (int i = 0; i < names.length(); i += 1) {
jo.put(names.getString(i), this.opt(i... |
9cdbbe17-2dfa-4887-91a2-2e3634ded633 | 7 | static public boolean intersect3(DwRay3D ray, float[] A, float[] B, float[] C, boolean two_sided, float[] ptr_hit_backface, float[] tuv){
float rdx = ray.d[0];
float rdy = ray.d[1];
float rdz = ray.d[2];
// edge1: v0 -> v1 // edge2: v0 -> v2
E1x = B[0]-A[0]; E2x = C[0]-A[0];
E1y =... |
08855921-5b50-49a1-bc26-8669aca6dbb8 | 1 | public void add(InstrInfo info) {
if (info.nextTodo == null) {
/* only enqueue if not already on queue */
info.nextTodo = first;
first = info;
}
} |
76e8cc52-8a2f-4347-96fd-ad7cf8235e83 | 5 | public JSONObject increment(String key) throws JSONException {
Object value = this.opt(key);
if (value == null) {
this.put(key, 1);
} else if (value instanceof Integer) {
this.put(key, ((Integer)value).intValue() + 1);
} else if (value instanceof Long) {
... |
110561d7-1760-4509-9745-916af02e9a5e | 8 | private String chooseSuitableNetworkSetup(String osVersion, String osArch, String... files) {
// DGF we don't technically need to know osArch, but according to comments in SRC-13,
// sometimes Tiger on PPC looks different from Tiger on Intel, so we'll leave it in,
// just in case
... |
22bf9ad6-3a7d-4a43-b8e4-9ee01d709fb8 | 2 | static AbstractFactory getFactory(CHOICE choice) {
switch (choice) {
case A:
pf = new ConcreteFactory1();
break;
case B:
pf = new ConcreteFactory2();
break;
}
return pf;
} |
24aa694a-498e-4a0b-8520-2a0f99ecbf6f | 6 | public MapObject getObjectAt(int x, int y) {
for (MapObject obj : objects) {
// Attempt to get an object bordering the point that has no width
if (obj.getWidth() == 0 && obj.getX() + bounds.x == x) {
return obj;
}
// Attempt to get an object borde... |
f5b57a9c-780a-463a-9f7e-508747cf5a35 | 3 | @Override
public void mouseDragged(MouseEvent e) {
if (isMouseDown) {
int ny = e.getY();
if (ny > mouseY) {
keys[KeyEvent.VK_DOWN] = true;
updateStatus();
keys[KeyEvent.VK_DOWN] = false;
} els... |
5ce1cbc2-f63a-4a29-b772-616a7e99282c | 6 | private static void merge(int[ ] list, int first, int n1, int n2)
{
int[ ] temp = new int[n1+n2]; // Create temp array
int copied = 0; // Number of elements copied from list to temp
int copied1 = 0; // Number copied from the first half of list
int copied2 = 0; // Number copied from the second half of... |
227b4117-36b1-447e-b632-ac10d75cbe15 | 7 | public static void main(String[] args) {
log("Enabling LIG server..\n");
log("Loading main configurations..\n");
try {
config = new Config("main");
port = Integer.parseInt(config.getString("port", "20222"));
accounts = new Config("accounts");
}catch(Ex... |
9edac515-798d-4442-8715-f8ab1b7affe1 | 4 | public boolean SaveToDisk() {
if (spawnLocation1 == null || spawnLocation2 == null) {
return false;
}
File arenaFileLocationPath = Config.getArenaFileLocationPath();
File arenadir = new File(arenaFileLocationPath, "arenas");
if (!arenadir.exists()) {
arena... |
20a3c6f6-e6a1-4e82-8486-551f84d2e4c1 | 9 | public boolean add(T newChromosome) {
Iterator<T> iterator = iterator();
DominanceComparator<T> dominanceComparator = new DominanceComparator<T>();
while (iterator.hasNext()) {
T chromosome = iterator.next();
int flag = dominanceComparator.compare(newChromosome, chromoso... |
8bb20cee-4660-4fe7-b405-d08e39022544 | 3 | protected void receiveReplicaLocation(Sim_event ev) {
if (ev == null) {
return;
}
Object[] data = (Object[]) ev.get_data();
if (data == null) {
return;
}
String filename = (String) data[0]; // get file name
Integer resID = (Integer) data[... |
9b5b436b-9ac3-42b9-ab8e-7d00222e8f30 | 0 | public IrcPlayerListener(AprilonIrc plugin)
{
Parent = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
} |
3c1c9c00-2afc-4017-9da6-a48153cb5992 | 9 | @GrubsCommandHandler(
command = "timelock",
desc = "Toggle freezing time to current value, or to the specified time value or preset.",
usage = "/<command> off|on|day|night|<0-24000>"
)
public void onTimeLockCommand(GrubsCommandInfo cmd) {
CommandSender sender = cmd.sender;
String[] args = cmd.args;
if (a... |
06db1158-62f6-4f75-89e0-6830cdd6a995 | 1 | public boolean isHeld() {
if(isDisabled())
return false;
return held;
} |
73d42f6b-808d-4ac0-b401-7149f8de583c | 1 | private static boolean shouldStop(BouncyBallSimulation simulation) {
return simulation.isBallResting() || simulation.getBallHitGroundCounter() >= 5;
} |
18331c17-75a9-4960-a95e-44fbcee6e2c3 | 5 | public LinkedHashMap<String,Integer> getWordMap() {
Map<String,Integer> mostWords = new TreeMap<String,Integer>();
Iterator<?> k = resultlist.iterator();
while(k.hasNext()) {
Map<String,Integer> temp3 = ((IResultSet) k.next()).getMostFrequentWord(10);
Iterator<String>h = temp3.keySet().iterator(... |
7a8f07e5-2f4b-4e6f-9f27-6bf46d4e33b1 | 0 | public UserRemovalInitiated(User user)
{
this.user = user;
} |
0fcaace3-f71e-4efc-87a8-46314b173fab | 4 | public void resetTextToButtons()
{
for (int i = 0; i < getMenuLayer().getComponentCount(); i++)
{
Component component = getMenuLayer().getComponent(i);
if (component.getClass() != JButton.class) continue;
JButton button = (JButton)component;
for (Inpu... |
3f14b8ba-9ee1-4b12-8b15-d2a03436c79e | 3 | private byte[] writeIntRE(int i) {
final int mask = 0x7f;
int hByte = 0;
int bytesEncoded = 1;
int j = i >> 7;
while (j != 0) {
if (++bytesEncoded == 4) {
break;
}
j >>= 7;
}
j = i;
final byte[] bytes = new byte[bytesEncoded];
while (--bytesEncoded >= 0) {
bytes[bytesEnco... |
599e7076-4f1b-4a8e-9b93-9e540fcbb249 | 3 | public void validaUsuario() {
UsuarioController uc = new UsuarioController();
JanelaPrincipal jp = new JanelaPrincipal();
String login = txUsuario.getText();
String senha = txSenha.getText();
if (txSenha.getText().equals("") || txUsuario.getText().equals("")) {
JOptio... |
6fb964c0-1855-480f-bac8-4c6d23f67442 | 5 | public int[][] createSolution(int[][] game, int index) { //requires 2d array and index to be passed into
if (index > 80) {
/*FOR DEBUGGING PURPOSES ONLY
//displays the solution
for (int j = 0; j < game.length; j++) {
for (int k = 0; k < game[j].length; k++) {
... |
bd3b5983-2845-4f85-98eb-fd7e4d18072b | 6 | public void readTxtFromSzenario(String path){
DBConnection dbc = DBConnection.getInstance();
try {
// szenario Data has to be in the project file in your
// workspace
File file = new File(path);
BufferedReader szenario = new BufferedReader(new FileReader(file));
filename = file.getName();
... |
07eb24b1-a298-44bf-bcfc-d19341ca86c8 | 7 | public AnchorPane createMonster(NpcMonster npcMonster) {
AnchorPane anchor = new AnchorPane();
int startTime = npcMonster.getTimeInSeconds();
ImageView imageView = new ImageView(npcMonster.getImage());
if (npcMonster.isInhibitor()) {
imageView.setFitHeight(90);
imageView.setFitWidth(90);
... |
6465c3d3-fd1d-4d16-bb63-f9ebda0c441f | 9 | private static void configurePlugin (Node configNode) {
boolean goOn = true;
Node pluginConfiguratorClassNameNode = configNode.getAttributes ().getNamedItem ("plugin-configurator-class");
if (pluginConfiguratorClassNameNode == null) {
LogHelperDebug.printError ("No plugin-configurator-class attribute in plugi... |
d2053e0b-c292-4a35-b8a1-6eaee5c60060 | 5 | public static boolean Create(String f) {
if (!CreateFolder("server")) return false; // Root directory
if (!CreateFile("history")) return false; // History
if (!CreateFile("config")) return false; // Config
if (!CreateFile("ops")) return false; // OPs
if (!Check()) return false;
return true;
} |
32faeb50-322b-416e-aca4-c6c5726b0b5b | 1 | @Override
public void encode(OutputStream os) throws IOException {
os.write(PREFIX);
for (Map.Entry<BencodeString, BencodeType> entry : dictionary.entrySet()) {
entry.getKey().encode(os);
entry.getValue().encode(os);
}
os.write(COMMON_POSTFIX);
} |
31010607-6b2e-4139-af3c-49b61532b0fc | 0 | @Override
public int attack(double agility, double luck) {
System.out.println("I tried to do a special attack but I haven't set it so I failed at this turn...");
return 0;
} |
e5e3cc2a-3fb2-4382-bfa1-115ca83ab5c9 | 8 | public static List<Word> load(File file, String charsetName) throws FileNotFoundException, UnsupportedEncodingException, IOException {
List<Word> seedWords = new ArrayList<Word>();
charsetName = (charsetName == null
? Charset.defaultCharset().name() : charsetName);
Re... |
e05910ef-5ddb-4a70-9e64-eab71c1d1d73 | 9 | private boolean evaluateTargets(Card c) {
String effects = c.getEffects();
String[] effectList = effects.split(",");
String[] effect;
for (String s : effectList) {
effect = s.split(" ");
switch (effect[0]) {
case "Destroy":
switch (effect[1]) {
case "Target":
switch (effect[2]) {
case... |
1a9b061a-be6d-4ee2-8912-81032c7c5831 | 8 | public static void main(String[] args) throws Throwable{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
for(StringTokenizer st; (st = new StringTokenizer(in.readLine()))!=null; ){
int N = parseInt(st.nextToken()), M = parseInt(st.nextToken());
... |
563af48f-a5ee-4084-9691-ac08532cdba4 | 7 | private JPanel createCenterPanel() {
coreCheck = new ComponentCheckBox("Core", "_installer/core.xml");
coreCheck.setEnabled(false);
prologueCheck = new ComponentCheckBox("Prologue", "_installer/prologue.xml");
route1Check = new ComponentCheckBox("Route 1: Fate", "_installer/route01-fate.xml");
route2Check = n... |
d60cf316-4a1c-49de-98b7-4836c26b7ca1 | 5 | protected Piece FindOppPieceNearFlag(Board b) {
Position flagpos = getFlagPos();
int row = flagpos.getRow();
int col = flagpos.getCol();
oppRow = (row == 1) ? (row + 1): (row - 1);
oppCol = 0;
for(oppCol = col - 1; oppCol <= col + 1; oppCol++) {
Piece piece = b.getPiece(opp... |
be289fc7-54dc-4280-9d74-705775735524 | 7 | public void populateFauna(
final Species... species
) {
//
// Okay. First of all, there ought to be a minimum distance between lairs.
// Secondly, it might be simplest to just sample the dozen closest lairs
// and their occupants to get an idea of predator quotients.
//
// Thirdly... ... |
03abd8e6-ea69-4de8-a302-a73ac9b2b552 | 9 | void parseList()
{
if (!car.isSymbol()) { form = new Regular(); }
else if (car.getName().toLowerCase().equals("if")) { form = new If(); }
else if (car.getName().toLowerCase().equals("lambda")) { form = new Lambda(); }
else if (car.getName().toLowerCase().equals("begin")) { form = ne... |
68c9b55a-7c39-46a5-ae7b-1286c2525305 | 9 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Triple triple = (Triple) o;
if (first != null ? !first.equals(triple.first) : triple.first != null) return false;
if (second != null ? !second.... |
c63ea9fa-82ce-4c17-9e72-68769d822ae7 | 9 | public void close()
{
if (readyState == ReadyState.Closing || readyState == ReadyState.Closed)
{
return;
}
if (readyState == ReadyState.Open)
{
// send termination char to server (fake closing handshake)
out.write(0xFF);
out.flush();
}
readyState = ReadyState.Closing;
try
{
... |
2d4431be-10e5-4884-a718-d75b62119cdb | 4 | public static int oppositeDirection(int currentDirection)
{
switch(currentDirection)
{
case 0: return 2;
case 1: return 3;
case 2: return 0;
case 3: return 1;
default: throw new DirectionOutOfBoundsException();
}
} |
fd7874a1-b506-4592-933d-12e76caef6af | 7 | synchronized private void replyConnectToMe(String user, String ip, int port) throws BotException, IOException { //Called in response to $ConnectToMe command from hub.
if (!isConnected()) {
throw new BotException(BotException.Error.NOT_CONNECTED_TO_HUB);
}
if (!user.equalsIgnoreCase(_botname)) {
throw new Bo... |
e38cffbd-c758-4316-9a9e-dd8ec6c9770b | 2 | private String[] getGameParameters() {
// TODO Get parameters in key value pairs ready for next state
String[] radioName = { "playInTeams", "blackHand", "swapCard",
"surrender", "timed", "tournamentMode", };
String[] key = { "teamGame=", "blackhand=", "cardSwap=", "surrender=",
"timeLimit=", "tournament="... |
e34125f2-e24a-4306-ac1d-b2ba50b4f1e1 | 3 | void attackPlaceHorizontallyLeft(int position, char[] boardElements, int dimension, int leftPosition) {
while (leftPosition > 0) {
if (isPossibleToPlaceLeft(position, dimension, leftPosition)
&& isBoardElementEmpty(boardElements[position - leftPosition])) {
boardE... |
ac6a1fac-462f-4559-b505-686899a227c5 | 9 | public String nextToken() throws JSONException {
char c;
char q;
StringBuffer sb = new StringBuffer();
do {
c = next();
} while (Character.isWhitespace(c));
if (c == '"' || c == '\'') {
q = c;
for (;;) {
c = next();
... |
0966d694-f0e9-4bb1-b48e-82cf65d63d0c | 3 | public JSONArray showHelp() throws JSONException {
JSONArray rtn = new JSONArray();
rtn.put("@description " + this.info);
if(this.requireLogin) {
rtn.put("REQUIRE LOGIN");
}
{
Iterator<ParamCons> it = nConstraint.iterator();
while(it.hasNext()) {
ParamCons cons = it.next();
rtn.put("... |
6995bb17-e121-48c6-9334-00af4d9421f0 | 9 | public void onMessage(Application.Request message) {
System.out.println(message);
if (Requests.QUIT.equals(message)) {
dispatch(Events.SHUTDOWN);
}
if (Requests.AddPlayer.class.isInstance(message)) {
final Requests.AddPlayer add = Requests.AddPlayer.class.cast(m... |
a4beff9e-537a-4124-9451-045c74d49f25 | 5 | private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
int fila = 0;
fila = this.jTable1.getSelectedRow();
nomCat = jTextField1.getText();
this.tienePadre=this.jRadioButton1;
this.contProd = this.jRadioButton2;
S... |
b0687f07-8185-4a8a-9074-02e429b6a038 | 5 | private void doCommand(int index)
{
switch(index){
case 0:
out.println("Exit...");
break;
case 1:
int count = 5;
createStorage(count);
break;
case 2:
String name = "Golden ... |
9e619ee0-11eb-42f8-be72-3e83f84071c4 | 3 | public Stack<DirectedNode> topologicalSort(DirectedNode root) {
//uses dfs, and then places each visited node onto a stack. This stack when emptied, comprises of
//the only or first found permutation of possible topological sorts
Stack<DirectedNode> visitedNodes = new Stack<DirectedNode>();
... |
e7075425-04b3-4dfb-8eb9-2badda872857 | 6 | public boolean setClassConstant(String clazzName) {
if (constant != null)
return false;
if (clazzName.charAt(0) == '[') {
if (clazzName.charAt(clazzName.length() - 1) == ';')
clazzName = clazzName.substring(0, clazzName.length() - 1);
if (fieldName.equals("array"
+ (clazzName.replace('[', '$').re... |
576a6c20-4c24-444b-8f34-8f8a8d7424ce | 2 | public void updateServer(Connection connection,
java.sql.Timestamp time_stamp, String local_path) {
try {
Statement stmt = connection.createStatement();
if (inServerDB(connection, local_path))// already exists so should
// update
{
PreparedStatement ps = connection
.prepareStatem... |
b149ad78-9ba1-49ff-8532-cb4a8b5a01b9 | 9 | public ResultPage<Book> getPatronRecord(int cardNumber, String search,
String searchColumn, String orderColumn, int offset)
throws SQLException {
openPatronsDatabase();
PreparedStatement statement = patronsConnection.prepareStatement(
"SELECT * FROM CheckedOut WHERE CardNumber = ?");
statement.setI... |
558784d3-b555-497d-8cc4-7086f8b53ac8 | 9 | public int largestRectangleArea(int[] height) {
Stack<Integer> heights = new Stack<Integer>();
Stack<Integer> indexes = new Stack<Integer>();
int LargestAres = 0;
for (int i = 0; i < height.length; i++) {
if (heights.isEmpty() || height[i] > heights.peek()) {
... |
73a8e151-25bc-4f32-a594-bf18fa55e480 | 0 | public SaveFileFormat getDefaultExportFileFormat() {
return defaultExportFileFormat;
} |
fc50f368-79c2-4b3e-8a94-8f98dac92a24 | 7 | public void simplify() {
if (this.simplified)
return;
this.simplified = true;
// we're doing a cool method here--represent the numerator and denominator as prime decompositions, and remove
// anything in common.
// ignoring the overhead of calculating primes (which is a one-time operation that takes a few ... |
e8552325-f50e-4b08-bfb1-65bd70a02398 | 7 | final boolean method1565(boolean bool, int i) {
anInt2780++;
int i_53_ = ((ItemDefinition) this).anInt2815;
int i_54_ = anInt2804;
int i_55_ = anInt2805;
if (bool) {
i_55_ = anInt2770;
i_53_ = ((ItemDefinition) this).anInt2788;
i_54_ = anInt2760;
}
if (i_53_ == -1)
return true;
boolean bool_... |
eb0a0b0d-7435-4dac-b929-82b3978c1a23 | 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... |
adc61036-4279-4ae1-8473-f814cd44df38 | 0 | void loadTemplatesDefault()
{
Templates.addElement(loadTemplate("triangle", TemplateData.trianglePoints));
Templates.addElement(loadTemplate("x", TemplateData.xPoints));
Templates.addElement(loadTemplate("rectangle CCW", TemplateData.rectanglePointsCCW));
Templates.addElement(loadTemplate("circle CCW", Templat... |
b90d0fb1-52b0-4f59-b097-dea41bafabe4 | 2 | private String getAddress(String label) {
if (labelMap.get(label) == null) {
Error.codeError(oLine, oLineNumber, 10); // 10 -- The given label cannot be found
error = true;
} else {
int address = labelMap.get(label); // Return the address of the label
String hex = Integer.toHexString(address); // C... |
ffc0916e-9939-46d6-b2b2-fe7cef1ae630 | 4 | public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int cases = input.nextInt();
for (int q = 0; q < cases; ++q) {
int numcoins = input.nextInt();
int[] coins = new int[numcoins];
for (int i = 0; i < numcoins; ++i) {
coins[i] = input.nextInt();
}
Arrays.sort(coin... |
28ce3951-c4a1-4ccf-acd8-ffb0bb4d621a | 5 | private void pop(char c) throws JSONException {
if (this.top <= 0) {
throw new JSONException("Nesting error.");
}
char m = this.stack[this.top - 1] == null ? 'a' : 'k';
if (m != c) {
throw new JSONException("Nesting error.");
}
this.top -= 1;
... |
0e37b24e-0051-41f4-8d2a-ee2aca4a3c6c | 4 | public void filter() {
Map<Integer, Map<String,String>> newCollection = new HashMap<Integer, Map<String,String>>();
int newID = 0;
for (int i=0; i<originalCollection.size(); i++) {
Map<String,String> currentLogEntry = originalCollection.get(Integer.valueOf(i));
boolean good = true;
for (FilterCriteria ... |
3399784b-b205-4f7c-81c4-697d690126bb | 2 | public static Texture loadTexture(BufferedImage image){
int[] pixels = new int[image.getWidth() * image.getHeight()];
image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0, image.getWidth());
ByteBuffer buffer = BufferUtils.createByteBuffer(image.getWidth() * image.getHeight() * BYTES_PER_PIXE... |
4019a693-e63c-447d-a77d-72c9a285abe0 | 1 | @Override
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
int indexOf = systemId.lastIndexOf('/');
String resourceName = systemId.substring(indexOf+1);
InputStream resourceAsStream = getClass().getClassLoader().getResource... |
e9ea1f4d-15a0-44e9-856b-a15a7ddd1930 | 2 | public int transferProvince(String worldName, int chunkX, int chunkZ, String newOwner) {
int success = 0;
String SQL = "UPDATE `Monarchy_Provinces` SET `player` = ? WHERE `world` = ? AND `x` = ? AND `z` = ?;";
try {
Connection con = getSQLConnection();
PreparedStatement statement = con.prepareStatement(SQL... |
3e45568f-aee5-42f5-b68c-504bb635dfe6 | 2 | private static void displayOrderVideo(BufferedReader reader, VideoStore videoStore) {
try {
System.out.println("Please enter the title of the video you would like to order " +
"(leave blank to display all videos):");
String isbn = getISBNFromTitle(reader, videoStore, ... |
b1151de1-e582-4f6c-a2b9-13ad2a71efa0 | 6 | @Override
public void render(float interpolation) {
Renderer.drawRect(pos, dim, 0x000000, 1.0f);
Renderer.drawLineRect(pos, dim, 0xffffff, 1.0f);
String s = prefix+text;
if(!s.equals(""))
{
int[] size = Fonts.get("Arial").getStringDim(s, fontsize);
while(size[0] > dim.x-20)
{
s = s.substri... |
7f625054-7fe7-4b54-a61f-26f867ae96d8 | 9 | public List<String> getListDistrictSelected(String s_nameProvinceSelected, int i_nbProvinceAround)
{
// On initialise les coordonnees de la province selectionnee
int i_xProvinceSelected = -1;
int i_yProvinceSelected = -1;
// On initialise la liste de nom
List<String> listProvinceSelected = new ArrayList<... |
9471bc25-9c7a-4235-baf7-1cf0698d50cd | 4 | public boolean allUniqueCharacters(String s){
for(int i=0; i<s.length(); i++){
for(int j=0; j<s.length(); j++){
if(i!=j){
if(s.charAt(i)==s.charAt(j)){
return false;
}
}
}
}
re... |
b11582b9-42c0-4e67-822e-5fe4afca2050 | 3 | public static Continent fromCode(String code) {
if (!StringUtils.isBlank(code)) {
for (Continent c : Continent.values()) {
if (code.equalsIgnoreCase(c.code)) {
return c;
}
}
}
return null;
} |
b754320b-91d5-4dea-961a-35a12db5e25b | 3 | public void shoot(EnumBoard player, EnumLine line, EnumColumn column)
throws PositionAlreadyUsedException, InvalidPositionException {
Map<String, EnumElement> board = (player.equals(EnumBoard.PLAYER1)) ? this.boardPlayer1
: this.boardPlayer2;
if (this.checkPositionUsed(board, line, column)) {
if (this.i... |
b20a3105-d91c-4c26-a9e2-062906e64830 | 1 | public Coord getc() {
Coord tc = this.tc;
Gob tgt = gob.glob.oc.getgob(this.tgt);
if(tgt != null)
tc = tgt.rc;
Coord d = tc.add(gob.rc.inv());
double e = gob.rc.dist(tc);
return(gob.rc.add((int)((d.x / e) * dist), (int)((d.y / e) * dist)));
} |
508c06d7-dcb4-4962-897e-d9aed20e5c68 | 4 | public boolean cartaEstaVirada(int i, int j)
throws PosicaoDeCartaInvalidaException {
if (i > 3 || i < 0 || j > 3 || j < 0)
throw new PosicaoDeCartaInvalidaException(
"Posição de carta fora dos limites do tabuleiro!");
return tabuleiro[i][j].isVirada();
} |
3b208048-33c3-442c-a695-8dfcd6068e13 | 4 | public int etc(Model model){
int res = 0;
for(Classe c : model.getClasse()){
for(Operation op : c.getArrayOperation()){
for(Argument arg : op.getArg()){
if(this.identifier.trim().equals(arg.getType().trim())){
res++;
}
}
}
}
//System.out.println("La classe " + this.identifier + " a... |
474619bb-2a4f-4aa3-80ce-98c158fb8e50 | 7 | private void initStandardBtnFontMenu(Color bg) {
this.standardBtnPanel = new JPanel();
this.standardBtnPanel.setBackground(bg);
this.standardBtnPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
String initFontTmp = this.skin.getBtn_Std_Font();
int initFontSizeTmp = th... |
477752b9-03c4-4de1-90aa-c2c18911e0fc | 0 | public JacksonMapToJsonStringConverter(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
} |
19f39c31-fc1e-4bef-bf9a-9dba80f76025 | 6 | @Override
public String toString(){
String res = null;
if(this.aceptacion && !this.inicial){
res = "F";
Iterator<Transicion> it = this.trans.iterator();
while(it.hasNext()){
res += it.next().toString();
}
}else{
if(t... |
c29c0874-1234-48aa-a45b-582eaf2e0409 | 2 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
if(user != null) {
UserModel usermod = DataStore.getUser(user.getUserId());
if(usermo... |
ce517152-e8c2-4936-b099-07568618714b | 6 | public void Render(GameContainer gc, Graphics g, LinkedList<Light> lights) throws SlickException
{
// Shadow drawing
// if (lights != null)
// {
// for (Light curr : lights)
// {
// Color tmp = new Color(0, 0, 0, 0.75f / (lights.size() + 1));
// double d = pos.getDistance(new Vector2(curr.getX(), curr.ge... |
a5019eae-0cf1-4b7d-b253-8a7d6872ec82 | 9 | @Override public boolean accept(File f) {
if (f.isDirectory()) {
return true;
}
String extension = Utils.getExtension(f);
if (extension != null) {
if (extension.equals(Utils.tiff) ||
extension.equals(Utils.tif) ||
extension.equals(Utils.gif) ||
extension.equa... |
438ca671-7521-4faf-a5c0-8155023e9561 | 4 | public static void unpackTextures(Archive archive) {
loadedTextureCount = 0;
for (int i = 0; i < 50; i++)
try {
textureImages[i] = new Background(archive, String.valueOf(i), 0);
if (lowMemory && textureImages[i].libWidth == 128)
textureImages[i].method356();
else
textureImages[i].method357(... |
db93204d-2303-4fc1-b48b-4ef25f96420b | 2 | public void move() {
PhysicsComponent ownPC = (PhysicsComponent)getOwningActor().getComponent("PhysicsComponent");
if(ownPC.getAngleRad() < ownPC.getTargetAngle() + 0.1 && ownPC.getAngleRad() > ownPC.getTargetAngle() - 0.1) {
ownPC.applyAcceleration(1.0f);
}
} |
d30ba444-9669-4b85-a309-c83e1e4439a0 | 6 | @Override
public void map(LongWritable key, Text value,
OutputCollector<Text, IntWritable> output, Reporter reporter)
throws IOException {
// TODO Auto-generated method stub
String line = value.toString();
boolean start = false;
if(line.trim() == "") {
return;
}
if(line.contains("<text"))... |
5facbc12-e726-4590-852d-43297212857e | 1 | @Override
public void main() {
cleanOutput();
Turtle turtle = new Turtle();
Map<String, Command> commands = new HashMap<String, Command>();
commands.put("right", new TurtleRightCommand(turtle));
commands.put("left", new TurtleLeftCommand(turtle));
commands.put("forward", new TurtleForwardCommand(turt... |
18aa137e-84c0-4dab-9490-79efa9090645 | 7 | private void showList(MP3Container con) {
mp3list = new MP3List(con,new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
JTable list = (JTable)evt.getSource();
searchPanel.setSelected(list.getSelectedRow()+1);
searchPanel.revalidate();
if (evt.getClickCount() == 2) {
... |
c5af576f-e777-47e8-a3f6-6e715ed52bdf | 0 | public Set<The5zigModTimer> getTimers() {
return timers;
} |
b976ce29-1b89-4c1f-9675-92368423dd91 | 4 | public static long getTimeInMillis(String time) {
Integer secs = DateUtils.secondsPastMidnight(time);
if (secs == null) {
secs = 0;
try {
int isPM = 0;
String[] t = time.split("[\\W]+");
if (t.length >= 3 && t[2].trim().equalsIgnor... |
a7121947-bc3e-486f-999a-2a00dc7626d1 | 3 | @Override
public boolean retainAll(Collection<?> c) {
HashSet<T> removeSet = new HashSet<T>();
for (T obj : typeKey.keySet()) {
if (!c.contains(obj)) {
removeSet.add(obj);
}
}
return removeAll(removeSet);
} |
bdc52854-0c65-43a0-8925-36cba05dfa5b | 2 | public static String getUnparsedData(String name){
try{
URL oracle = new URL("http://www.wdfatv.net/olywar/output.php?user=" + name);
BufferedReader in = new BufferedReader(new InputStreamReader(oracle.openStream()));
try{ return in.readLine().replaceAll("/", "#"); }
catch(Exception e){ return... |
0373d9c0-e073-4aa1-b5ae-8fe5163017a2 | 8 | public static void main(String[] args) {
List<Test> tests = new ArrayList<Test>();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("tests.json")));
StringBuilder stringBuilder = new StringBuilder();
String line;
... |
b93f55db-390e-40f5-890f-10c86d57d981 | 4 | public int uniquePaths(int m, int n) {
int [][] array = new int[m][n];
for(int i = 0 ; i < m; i++)
array[i][0] = 1;
for(int i = 0 ; i < n ; i++)
array[0][i] = 1;
for(int i = 1 ; i < m ; i++){
for (int j = 1 ; j < n; j++){
array[i][j] = ... |
bb15328a-faca-4380-9cc6-ebc6ec2a19a8 | 6 | private ProtocolEncoderImpl() throws Exception {
MessageEncoderFactory[] encoderFactories = DemuxingProtocolCodecFactory.this.encoderFactories;
for (int i = encoderFactories.length - 1; i >= 0; i--) {
MessageEncoder encoder = encoderFactories[i].getEncoder();
Set<... |
e490d55a-7692-4a3b-b886-90c26685dde8 | 9 | public void creerPioche(int nombrePaquet){
int[] valeurCarte = new int[8];
int[] valeurCarteSpeciale = new int[5];
int i,j,k;
String[] couleurCarte = new String[4];
couleurCarte[0]="coeur";
couleurCarte[1]="carreau";
couleurCarte[2]="trefle";
couleurCarte[3]="pique";
valeurCarte[0]=2;
valeurCa... |
f305fae7-e220-4980-9b8d-c5483316dda8 | 3 | @Override
public void mouseReleased(MouseEvent arg0) {
SquareGraphic square = (SquareGraphic) arg0.getSource();
if (selectedSquare != null && !square.equals(selectedSquare)) {
selectedSquare.deselect();
}
square.toggleClick();
selectedSquare = square;
String output = "";
if (square.getIsSe... |
3452cee2-1985-427c-a80a-61e849719ee9 | 1 | public int getRowCount() {
return current == null ? 0 : current.size();
} |
20143988-b69e-4da1-9241-d6597aa20926 | 1 | @Override
public String toString() {
if(opcode.isBasic())
return opcode.toString()+" "+valueA.toString()+", "+valueB.toString();
else
return opcode.toString()+" "+valueA.toString();
} |
6be30667-06fe-41bc-be41-c2cfd429d144 | 9 | private static File[] getFiles(String directory, String[] files){
File[] inputFiles = null;
if(directory != null){
File dir = new File(directory);
if (!dir.exists() || !dir.isDirectory()){
System.out.println("Directory parameter " + directory + " does not exist or is not a directory.... |
3f6ad30f-9125-4aad-acb7-2228d1e8bdcb | 3 | private void resizeArray() {
HeapNode[] ar2;
if (heap_size >= ar.length - 4) {
ar2 = (HeapNode[]) Array.newInstance(HeapNode.class, ar.length * 2);
System.arraycopy(ar, 0, ar2, 0, ar.length);
this.ar = ar2;
}
if (heap_size < (ar.length / 2) - 1 && ar.l... |
6a217a68-2c06-42b0-9ef6-237e191f903b | 3 | @Override
public Case getCaseForIA(Joueur joueurAdverse) {
Random rand = new Random();
Case caseTouchee = null;
if (this.listeCaseATester.isEmpty()) {
int x = rand.nextInt(this._parametre.getNbCaseX());
int y = rand.nextInt(this._parametre.getNbCaseY());
w... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.