method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
61ac218a-da8b-4fa7-aa0f-a56c99089b9f | 5 | public List<Integer> topKFrequent(int[] nums, int k) {
Map<Integer,Integer> aux=new HashMap<>();
for(int i : nums){
Integer cnt=0;
if(aux.containsKey(i)) cnt=aux.get(i);
aux.put(i,++cnt);
}
PriorityQueue<Node> priorityQueue=new PriorityQueue<>();
... |
12b7d2e2-cfd4-4b15-b409-c56a41225113 | 5 | public ArrayList<Device> findDeviceByPower(int minPower, int maxPower) throws LogicException{
if (minPower > maxPower) {
LOG.error("Wrong searching options");
throw new LogicException("ERROR Min value can not be bigger then Max value");
}
ArrayList<Device> foundDevices ... |
f0ca57c8-a4a8-4dbe-8d26-0c0b93b26be1 | 0 | public EditorPane getEditorPane() {
return editorPane;
} |
20a26f2e-718e-4ee4-afad-a753a03ff605 | 1 | String dblfmt(double[] d) {
StringBuilder b = new StringBuilder();
for (int i = 0; i < d.length - 1; i++) {
b.append(String.format(Locale.US, fformat, d[i]));
b.append(',');
}
b.append(String.format(Locale.US, fformat, d[d.length - 1]));
... |
31bc086f-c127-4f8e-9285-756b8e3b1356 | 4 | boolean isNextToARobot(Robot r, int x, int y) {
synchronized (robots) {
for (Robot robot : robots)
if (robot != r && robot.getX() == x && robot.getY() == y)
return true;
return false;
}
} |
ba18b5ea-d5b6-4528-8b2a-ea65b78363ed | 3 | @Override
public void loadReader(String name, Reader reader)
throws LevelLoaderException {
filename = name;
try {
xmlreader.parse(new InputSource(reader));
}
catch (SAXException e) {
throw new LevelLoaderException(e);
}
catch (IOException e) {
throw new LevelLoaderException(e);
}
catch (Num... |
99dd7f91-caf6-45e4-89f8-fd825a9b72c8 | 4 | public Zone getZone(int x, int y) throws OutOfBoundsException{
if (x < 0 || x >= this.width || y < 0 || y >= this.height)
throw new OutOfBoundsException();
return this.zones[x][y];
} |
e094333e-e31d-4ecf-b4fe-60fc034c98f7 | 8 | int depthFirstCutValue(Edge edge, int count) {
Node n = getTreeTail(edge);
setTreeMin(n, count);
int cutvalue = 0;
int multiplier = (edge.target == n) ? 1 : -1;
EdgeList list;
list = n.outgoing;
Edge e;
for (int i = 0; i < list.size(); i++) {
e = list.getEdge(i);
if (e.tree && e != edge) {
co... |
61500f73-68ad-4d88-8ba9-cc2b8a5c4dcd | 0 | public static OthelloBoardBinary getInitialBoard(){
OthelloBoardBinary board = new OthelloBoardBinary();
// FOLLOWING BINARIES REPRESENT INITIAL BOARD CONDITION
board.binHasDisk = 0x00_00_00_18_18_00_00_00l;
board.binIsBlack = 0x00_00_00_08_10_00_00_00l;
board.isBattingFirstTu... |
54f5df77-0348-4d86-b52a-527e17f24872 | 4 | private void reportPath(String title, Route path) {
I.add(""+title+": ") ;
if (path == null) I.add("No path.") ;
else {
I.add("Route length: "+path.path.length+"\n ") ;
int i = 0 ; for (Tile t : path.path) {
I.add(t.x+"|"+t.y+" ") ;
if (((++i % 10) == 0) && (i < path.path.length... |
9e5e54c8-c79c-42ec-a12b-07969cb1fb6c | 5 | public final WaiprParser.stat_return stat() throws RecognitionException {
WaiprParser.stat_return retval = new WaiprParser.stat_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
ParserRuleReturnScope globalstat54 =null;
ParserRuleReturnScope localstat55 =null;
try {
// Waipr.g:46:6: ( g... |
ac62957d-19c0-4dce-91d4-b2c535ce9879 | 0 | public static void g() throws MyException {
System.out.println("Throwing MyException from g()");
throw new MyException("Originated in g()");
} |
186f1bbd-31d8-4f92-9d97-c095d84b529e | 4 | private void refreshModel(DefaultListModel model) {
if (model.equals(guestModel)) {
ArrayList<Guest> guestList;
guestList = ctr.getGuestsFromDB();
guestModel.clear();
for (int i = 0; i < guestList.size(); i++) {
guestModel.addElement(guestList.get(... |
7691fdac-bbd3-4181-be72-7ece1ba30829 | 4 | public static Data data(String value)
{
Data data = null;
if (value.length() > 0)
{
if (value.charAt(0) == '[')
{
String content = value.substring(1, value.length() - 1);
try
{
int number = I... |
0b9445b3-5f64-47f4-9433-20b23d5ac924 | 3 | @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new java... |
783cc1af-2c1a-476c-9e66-da8b0f2c215c | 3 | private void readStateMove(State[] states, BufferedReader reader)
throws IOException {
for (int i = 0; i < states.length; i++) {
int x, y;
String[] tokens = reader.readLine().split("\\s+");
try {
x = Integer.parseInt(tokens[1]);
y = Integer.parseInt(tokens[2]);
} catch (NumberFormatException e)... |
3fc167e5-c06a-4cd4-bfab-81e784704842 | 7 | public void paintComponent(Graphics g) {
synchronized (LiveSystemCopyMutex) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.black);
g2d.fillRect(0, 0, panelWidth, panelHeight);
List<Ship> ships = p... |
93fcaced-0aff-4298-8fc9-4a3811d895be | 7 | public Main(final File file) {
try {
jmdns = JmDNS.create();
} catch (IOException e1) {
e1.printStackTrace();
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(... |
e0b5fa5c-62f6-4d82-b82d-7bb303f84dbd | 0 | protected void onRemoveChannelBan(String channel, String sourceNick, String sourceLogin, String sourceHostname, String hostmask) {} |
91341700-1883-415f-8a77-3143f2339bdb | 1 | public void removeOnetimeLocals() {
StructuredBlock[] subBlocks = getSubBlocks();
for (int i = 0; i < subBlocks.length; i++)
subBlocks[i].removeOnetimeLocals();
} |
e22b09f5-be0f-40fe-b41d-34a420555ac5 | 8 | private void calculate() throws Exception {
//Get B
Matrix diagonalizedMatrix = matrix.transpose().copy().times(matrix.copy()).copy();
//Diagonalize B
EigenvalueDecomposition ed = new EigenvalueDecomposition(diagonalizedMatrix);
//Get eigenvalues and sort them into ArrayLists
double[] eigenValues = ed.getRe... |
148d8bbb-1d96-4418-a09d-4175eb440d49 | 9 | public static String[] convertUserInput(String input) {
assertNotNull("User input is null", input);
int index;
String temp1, temp2;
// preprocess of the input string to ease the progress of detecting
// deadline indicators which are "due at" and "due on"
if (input.contains(StringFormat.DUE_INDICATOR)) {
... |
cb359e3d-2b38-4295-807e-b0faed59b73b | 7 | public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
{
if (par1World.getBlockMaterial(par3, par4, par5) != Material.water)
{
return false;
}
else
{
int var6 = par2Random.nextInt(this.radius - 2) + 2;
byt... |
67bb3d47-8155-46cc-9f93-3ba03cfbc777 | 6 | @Override
public void valueUpdated(Setting s, Value v) {
if (s.getName().equals(Trigger)) {
try {
boolean b = v.getBoolean();
if (trigger_ == null && b) {
trigger_ = addInput(Trigger, ValueType.VOID);
trigger_.addListener(this);
} else if (trigger_ != null && !b) {
trigger_.removeListen... |
34cd45df-5fcb-461b-ac80-9758d2734f0b | 6 | private boolean readHyphenatedWordBackwards()
{
boolean hadHyphen = false;
ArrayList<Character> saved = new ArrayList<Character>();
// check for page numbers
char token;
if ( readArabicPageBackwards()||readRomanPageBackwards() )
{
// remove page number
... |
c13078e0-5fbd-4da1-ac2f-ad272fa7b449 | 9 | private void writeEncoded(String str)
{
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
switch (c) {
case 0x0A:
this.writer.print(c);
break;
case '<':
this.writer.print("<");
break;
... |
3dfe4f60-9ab7-4fb3-9eeb-f4203432f6c5 | 7 | private String getIPAddress() {
String ip = null;
try {
Enumeration<NetworkInterface> interfaces = NetworkInterface
.getNetworkInterfaces();
while (interfaces.hasMoreElements()) {
NetworkInterface iface = interfaces.nextElement();
if (iface.isLoopback() || !iface.isUp()
|| !iface.isPointT... |
749b37fe-e76e-4468-a7c5-012b3496a246 | 6 | public static Map<String,String> updateNamespaces( Object xmlPart, Map<String,String> previousNsAbbreviations ) {
if( !(xmlPart instanceof XMLOpenTag) ) return previousNsAbbreviations;
XMLOpenTag openTag = (XMLOpenTag)xmlPart;
Map<String,String> newNsAbbreviations = previousNsAbbreviations;
for( Iterator<String... |
57d04e17-6e4b-4f98-84f9-b4f598180446 | 0 | public String getCountry() {
return country;
} |
acd96137-098c-4ea1-a245-ee861fb93c0f | 3 | public boolean contains(Object o) {
if (o == null)
return false;
int mask = elements.length - 1;
int i = head;
E x;
while ( (x = elements[i]) != null) {
if (o.equals(x))
return true;
i = (i + 1) & mask;
}
return ... |
ff8ea982-13e5-40b9-a1e4-dbef9bc295ff | 2 | public void insert(E element) {
heap.insert(element);
int i = heapSize;
while (i > 0 && heap.get(parent(i)).compareTo(element) > 0) {
swapElementsByIndex(i, parent(i));
i = parent(i);
}
heap.set(i, element);
heapSize++;
} |
38be3f63-74aa-45aa-bb59-5a0e5dcab232 | 4 | double heuristicEstimation(int i, int j) throws Exception {
if (BitmapGraph.this.destI_pos == -1 || BitmapGraph.this.destJ_pos == -1) {
throw new Exception("heuristicEstimation failed! End point is not found!!");
}
//return 15*Math.sqrt(pow2(BitmapGraph.this.destI_pos... |
5b939782-abed-4713-9ce4-1427169dad12 | 5 | public static boolean createAssignExpression(InstructionContainer ic,
StructuredBlock last) {
/*
* Situation: sequBlock: dup_X(lvalue_count) store(POP) = POP
*/
SequentialBlock sequBlock = (SequentialBlock) last.outer;
StoreInstruction store = (StoreInstruction) ic.getInstruction();
if (sequBlock.subB... |
3d05b3fa-e84d-4bb7-9083-8fa0c1d4e0de | 0 | public PWWindow(PermWriter project) {
this.project = project;
this.setTitle("PermWriter");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.getContentPane().setLayout(new GridBagLayout());
this.setSize(750, 475);
} |
0d775a95-27ca-4910-930b-4d6f7aeb0fca | 3 | public boolean hasSingleFinalState(Automaton automaton) {
State[] finalStates = automaton.getFinalStates();
if (finalStates.length != 1) {
// System.err.println("There is not exactly one final state!");
return false;
}
State finalState = finalStates[0];
Transition[] transitions = automaton.getTransitio... |
3fcaa61e-4867-44e5-bc1c-b7bdefff8c98 | 4 | public static List<Mouse> loadMice()
{
LinkedList<Mouse> mouseList = new LinkedList<>();
try (BufferedReader savedMice = new BufferedReader(new FileReader(
"mice.list")))
{
String mouseString;
while ((mouseString = savedMice.readLine()) != null)
{
if (mouseString.isEmpty())
{
continue... |
468ac8af-8083-4ebe-b7bf-eed564640516 | 5 | public void mousePressed(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e))
{
int x = (int)e.getPoint().getX();
int y = (int)e.getPoint().getY();
ActionJouer action = null;
if (x > 0 && x < 300 && y > 0 && y < 300) {
action = new ActionJouer(x/100, y/100);
m_view.sendActionToContro... |
d8dc1604-2871-496a-a517-229c599aa36d | 3 | private int clearAnswer() throws Exception
{
int n = 0;
while(n < this.MAX_TRIES && this.sendClearCommand() != 1)
{
if ( n > this.MAX_TRIES)
throw new Exception("Достигнут максимальный лимит попыток");
n += 1;
}
return 0;
} |
e3273bbd-4a37-462b-a3b0-c022f55c76cb | 0 | @Override
public void setValue(Object o) {
throw new UnsupportedOperationException("set replaygain not yet supported");
} |
5c0438a4-425a-43e0-a718-298959e06453 | 3 | private NoeudArbre recherchePrioriteList(double priorite) {
NoeudArbre result = NIL;
int i = 0;
while (result == NIL && i < listNoeudArbres.size()) {
if (listNoeudArbres.get(i).priorite == priorite) {
result = listNoeudArbres.get(i);
}
i++;
... |
be14254a-43b4-44ba-b09d-c936381175d3 | 0 | public CheckResultMessage pass(String message) {
return new CheckResultMessage(message);
} |
16ae1b8b-d9e7-4eeb-a53c-041ac0f44f15 | 6 | private int pairIndex(int ii, int jj){
int ret = -1;
int i = 0;
boolean test = true;
while(test){
if(this.pairIndices[i][0]==ii && this.pairIndices[i][1]==jj){
ret = i;
test = false;
}
else{
if(this.pairI... |
c9acd1a8-5506-4e04-8590-83f126f4a303 | 7 | public void tick()
{
super.tick();
if(this.fluidIn != null && this.fluidIn.getName().equals("water") && !hasAchievement(AchievementList.touchWater))
{
this.toggleAchievement(AchievementList.touchWater);
}
if(getHeldItem() != null)
{
getHeldItem... |
49bfc6c9-f291-4041-b045-94b1bd2dbef9 | 2 | private static Item findClosestMatch(String input){
Levenshtein compare = new Levenshtein();
float max = 0.0f;
float comp;
Item maxitm = null;
for(Item item : items){
comp = compare.getSimilarity(input, item.name);
if(comp > max){
max = comp;
maxitm = item;
}
... |
de661eb6-78b2-4f6d-b7af-eefef2ae1d56 | 1 | public static void main(String[] args) {
List<Interval> result = new ArrayList<Interval>();
Interval a = new Interval(1,5);
Interval b = new Interval(6,8);
result.add(a);
result = new Insert_Interval().insert(result, b);
for(int i = 0 ; i< result.size();i++)
... |
848ce6c2-063e-4d90-a954-fd9f46d2f36d | 7 | protected boolean isLegalActionTiles(GameContext.PlayerView context,
Set<Tile> tiles) {
PlayerLocation location = context.getMyLocation();
if (!meetPrecondition(context)) {
return false;
}
int legalTilesSize = getActionTilesSize();
if (legalTilesSize > 0
&& (tiles == null || tiles.size() != legalTi... |
41d0afe6-656c-45ef-b510-3d9112e22dc8 | 4 | public void update(){
if(beginningAnimation){
AffineTransform transform = new AffineTransform();
transform.translate(WIDTH/2 - scaleFirst*WIDTH/2, HEIGHT/2 - scaleFirst*HEIGHT/2);
transform.scale(scaleFirst,scaleFirst);
Graphics2D g2d = (Graphics2D)beginningImage.getGraphics();
g2d.setRenderingHint(Ren... |
ee05d801-0a3e-4420-bf25-b0df2a349c5b | 6 | public static boolean Substring(String s1, String s2) {
boolean is_substring = true;
if (s2.length() > s1.length()) {
return false;
}
char[] input = s1.toCharArray();
char[] sub = s2.toCharArray();
for (int i = 0; i < input.length; i++) {
if (input[i] == sub[0] && (input.length - i > sub.length)) {
... |
e48b26c6-6088-4037-9409-607a4115b0cd | 0 | public void setPostition(int[] newPos) {
this.position = newPos;
} |
2628592f-c464-4812-95c2-f6feb8024ed3 | 9 | public static int computeStorageClass (int tag)
{
switch (tag)
{
case T_BOOLEAN: case T_CHAR: case T_BYTE:
case T_SHORT: case T_INT:
return SC_INT;
case T_ARRAY: case T_CLASS:
case T_ADDR: case T_NULL:
return SC_ADDR;
default:
return tag;
}
} |
59704096-e6dd-4239-b54d-6bf96988ce25 | 6 | public static void tag(String catalogFile, String tagFile) {
ObjectOutputStream tagOutput = null;
try {
FileOutputStream fos = new FileOutputStream(tagFile);
BufferedOutputStream bos = new BufferedOutputStream(fos, 4096*4);
tagOutput = new ObjectOutputStream(bos);
... |
61a3b67d-fdba-461e-b5e1-fa7d89e8135e | 6 | private void updateSpelprojektInPanel() {
tfSpelprojectSearch.setEnabled(false);
PanelHelper.cleanPanel(spelprojectHolderPanel); // do some cleanup before
ArrayList<String> matches = fetchMatchingSpelproject();
if (!matches.isEmpty()) {
for (String st : matches) {
... |
9c3e8b4f-3895-41bd-bc7e-5d43b45e5425 | 2 | public int compareTo(Element element)
{
int myCharge = this.getCharge(getName(), protons);
int otherCharge = element.getCharge();
if (myCharge == otherCharge)
return 0;
else if (myCharge > otherCharge)
return 1;
else
return -1;
} |
ffca1227-224e-42e1-9806-6174b64cbab2 | 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 Company)) {
return false;
}
Company other = (Company) object;
if ((this.id == null && other.id != null) || (thi... |
d5055bf6-f2a9-40e9-9358-5ac595094b67 | 2 | protected void setCod(String cod) throws Exception{
if(cod.length()<5 || cod.length()>20){
throw new Exception("El codigo tiene que tener minimo 5 caracteres y menos de 20 caracteres.");
}else{
this.cod = cod;
}
} |
c1107423-2d0a-4cc8-94a7-bf3c0206b600 | 2 | public static ErrorLogs parameterLogs(String supMsg, String confMsg){
ErrorLogs logs = new ErrorLogs();
String parameterError = "Parameter Input Error: ";
String parameterRange = " Must be between 0.0 and 1.0, inclusively";
if (!supMsg.equals("")) {
logs.getErrorMsgs().add(
parameterError + " Min Suppor... |
b8d8c1f8-de4a-4499-bfd7-d52ae7ac9589 | 2 | public static void roverChange(){
rover = head;
while(rover!=null){
if(rover.img.endsWith(".jpeg")){
String holder = rover.img;
String temp = changeExtension(holder);
System.out.println(temp);
rover.img = temp;
}
rover = rover.next;
}
} |
ba55f99a-7798-45a7-96dc-513271244412 | 6 | void hitmiss(int xe, int ye, int [][] pixel2, int [][]pixel, int [] lut){
int x, y;
// considers the pixels outside image to be 0 (not set)
for (x=1; x<xe-1; x++) {
for (y=1; y<ye-1; y++) {
pixel[x][y]+= lut[(
pixel2[x-1][y-1] +
pixel2[x ][y-1] * 2 +
pixel2[x+1][y-1] * 4 +
pixel2[x-1][y ]... |
d513d6ce-b3ff-4d7b-a290-1d881375a9ef | 2 | public static List<TaskWorker> configRunners(DeployConfig config, String taskId, boolean undo) {
List<TaskWorker> result = new ArrayList<TaskWorker>();
boolean flag = true;
Task task = config.getTasks().getTaskById(taskId);
List<Server> servers = parseServers(config, task.getTargetServer());
... |
88272ccd-3470-456d-818a-f7c48ed24f86 | 7 | @Override
public void buttonPressed(ClickableComponent button) {
if (button instanceof LevelButton) {
LevelButton lb = (LevelButton) button;
TitleMenu.level = levels.get(lb.getId());
if (activeButton != null && activeButton != lb) {
activeButton.setActive(false);
}... |
6ca3a07a-7487-4e75-92ed-3f6a1dc7829a | 6 | @EventHandler
public void GiantFastDigging(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.getGiantConfig().getDouble("Giant.FastDi... |
c8081981-c909-496c-8cf5-7cdff02cd0af | 2 | public final Customer getCustomer(String custID) {
Customer customer = null;
for (Customer c : customers) {
if (custID.equals(c.getCustID())) {
customer = c;
break;
}
}
return customer;
} |
9b57c1fa-f50d-436e-97cb-de7893910465 | 2 | protected final String getCommand() throws MenuException{
// Scanner inFile = Memorygame.getInputFile();
Scanner inFile = new Scanner(System.in);
String command;
boolean valid = false;
do {
command = inFile.nextLine();
command = command.trim().toUpperCase... |
6c980c9f-18cf-4bbb-8357-7231bba058e9 | 2 | private void formUserList(SessionRequestContent request) throws ServletLogicException {
Criteria criteria = new Criteria();
User user = (User) request.getSessionAttribute(JSP_USER);
if (user != null) {
ClientType type = ClientTypeManager.clientTypeOf(user.getRole().getRoleName());
... |
fd2f074e-cb7e-4e82-80d0-dd5d86ea0d30 | 1 | public boolean isCellEditable(int row, int column) {
if (!finalEdit)
return super.isCellEditable(row, column);
column = convertColumnIndexToModel(column);
return cellEditors[row][column] != null;
} |
36b64eab-1277-4c9f-a4bf-81dcbfad00e1 | 7 | public static Slot lookupVisibleSlot(Stella_Class renamed_Class, Stella_Object slotName) {
{ Slot slot = null;
String slotnamestring = null;
Module module = ((Module)(Stella.$MODULE$.get()));
{ Surrogate testValue000 = Stella_Object.safePrimaryType(slotName);
if (Surrogate.subtypeOfSymbo... |
8bb41dd2-6afe-47e8-93a8-8addade7a92d | 8 | private List<FactoryPoint<?>> findAllFactoryPoints(final List<Member> allMembers, final List<Method> allMethods,
final BeanKey factoryBean, final TypeMap typeMap) {
final List<FactoryPoint<?>> factoryPoints = new ArrayList<FactoryPoint<?>>();
for (... |
888f6619-b414-4222-b512-5f6e33545c25 | 1 | public Value naryOperation(final AbstractInsnNode insn, final List values) {
int size;
if (insn.getOpcode() == MULTIANEWARRAY) {
size = 1;
} else {
size = Type.getReturnType(((MethodInsnNode) insn).desc).getSize();
}
return new SourceValue(size, insn);
... |
bd3ed33d-8601-48f2-bd9f-eeb0dc86ca9f | 0 | public void setFunEstado(String funEstado) {
this.funEstado = funEstado;
} |
d5cf6c8c-3379-4cf6-bb43-52bf6bd43103 | 2 | public void visitTableSwitchInsn(
final int min,
final int max,
final Label dflt,
final Label[] labels)
{
buf.setLength(0);
buf.append(tab2).append("TABLESWITCH\n");
for (int i = 0; i < labels.length; ++i) {
buf.append(tab3).append(min + i).append(... |
271d55cf-c568-48e9-a538-e421a628c698 | 1 | protected void stopPlayer() throws JavaLayerException
{
if (player!=null)
{
player.close();
player = null;
playerThread = null;
}
} |
143b07e0-3563-44a9-8bd0-5b23fbf8e5c5 | 3 | @SuppressWarnings("deprecation")
public ConfigAccessor(JavaPlugin plugin, String fileName) {
if (plugin == null) {
throw new IllegalArgumentException("plugin cannot be null");
}
if (!plugin.isInitialized()) {
throw new IllegalArgumentException("plugin must be initialized");
}
this.plugin = plugin;
th... |
6463eeda-7ecb-414b-8a9e-233e7de31108 | 7 | public void declareSplitWinnings(int dealer, int player, int split) {
int winnings = 0;
if (playerHand.blackJack()) {
winnings += playerHand.getBet() + (playerHand.getBet() * 3) / 2;
} else if (player > dealer) {
winnings += playerHand.getBet() * 2;
} else if (pla... |
7d78015a-9293-41f3-9df8-d5f5c39d9574 | 1 | protected static BigDecimal parseBigDecimal(final Object obj, final String type) throws ParseException {
final BigDecimal result;
try {
result = new BigDecimal(obj.toString());
} catch (NumberFormatException nfe) {
throw new ParseException(obj + " is not a valid " + type + ".");
}
return... |
f0dd1034-8c41-4980-9a8d-3d36e9e5b08e | 1 | public Set<String> copySet(Set<String> set) {
Set<String> out = new HashSet<String>();
for (String elem : set) {
out.add(elem);
}
return out;
} |
eeae3dc2-d4ab-42ca-8bd6-d329fb9f9d96 | 8 | private void createInterface() {
boolean b = true;
for (int i = 0; i < model.getTabellone().length; i++) {
for (int j = 0; j < model.getTabellone()[i].length; j++) {
Cell cell = new Cell(i, j);
if (b) {
cell.setImage(whiteCell.getImage());
... |
2a1a7b4f-cef5-4270-99e9-a8aa1941bac3 | 9 | public EditorTab() {
this.setLayout(new BorderLayout());
this.list.setCellRenderer(this.renderer);
this.list.setTransferHandler(new BytecodeEditorTransferHandler(this));
ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
toolTipManager.registerComponent(this.list);
this.add(this.l... |
cb714484-b814-4dbd-b4c6-a4cd5277124d | 0 | public RedeclarationError(Symbol sym)
{
super("Symbol " + sym + " being redeclared.");
} |
ac8bb7ad-d19a-478a-98aa-6f623561125a | 7 | @Override
public void run() {
HashMap<String, String> args = msg.getArgs();
String ip = socket.getInetAddress().toString();
String username = args.get("username");
String password_ = args.get("password");
DebugLog.log("login", username);
String password = null;
try {
password = DaoFactory.cre... |
e3cc5633-df38-48d5-9b52-f9a0e796d2d5 | 2 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
try {
long id = Long.parseLong(jTextField1.getText());
long tel = Long.parseLong(jTextField5.getText());
String nome = ... |
17c9b1f5-0668-44a9-b249-714093978066 | 8 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
final MOB target=this.getTarget(mob,commands,givenTarget);
if(target==null)
return false;
if(!super.invoke(mob,commands,givenTarget,auto,asLevel))
return false;
final boolean success=prof... |
f9571c81-37a8-4335-9e65-8944639f4123 | 8 | private void checkCollision()
{
for (int i = 0; i < traps.size(); i ++) {
Trap t = traps.get(i);
if (t.functioning) {
double distance = player.pos.x - t.pos.x;
if (distance < 10 && distance > - 5) {
if (player.state != Player.STATE.JUMPING || (player.state == Player.STATE.JUMPING && (player.getJum... |
dfa6fe31-c965-4af7-9496-cb89f0f93412 | 7 | public void compFinalResult() {
do {
iStage++;
compAllocation();
if (compDistribution()) {
/* deadline can not be satisfied */
if (!bDeadline) {
System.out.println("THE DEADLINE CAN NOT BE SATISFIED!");
return;
} else {
System.out.println("\nNEW ROUND WITHOUT CHECKING:");
dEv... |
b299a697-2a85-4bf7-8433-d391ed6a6161 | 7 | public static String BigIntMultDif(String a, String b, int intLevel) {
int k1 = a.length();
int k2 = b.length();
StringBuffer strLevel = new StringBuffer("\n");
for (int i = 0; i < intLevel; i++) {
strLevel.append(" ");
}
if (k1 < 4 && k2 < 4) {
i... |
eb02fea0-f9b3-4978-aad3-19c5a53eb78e | 3 | @Override
public TestResult test(String input, Integer... args) {
if( !String.class.equals(input.getClass()) ){
throw new IllegalArgumentException("Parameter 'input' ONLY support 'String' type.");
}
final int length = input.length();
final int minLength = args[0];
final int maxLength = args[1];
bo... |
63fdcc85-8a56-4a25-9178-04babf25362e | 8 | public int compareChromoName(Interval interval) {
Chromosome i2 = (Chromosome) interval;
// Both of them are non-numeric: Compare as string
if ((chromosomeNum == 0) && (i2.chromosomeNum == 0)) return id.compareTo(i2.id);
// One of them is a number? => the number goes first
if ((chromosomeNum != 0) && (i2.ch... |
3729accf-35dc-44ae-aafe-01e43e3e32e6 | 3 | public boolean escribirCliente (int i,CCliente cliente){
if(i>=0 && i<= nregs){
try{//uso try porque puede generar errores
fes.seek(i*tam); //situamos el puntero en la posición que me indica i (será nregs*tamaño de cada registro)
fes.writeUTF(cliente.getDN... |
6cd60683-0445-4437-ace6-6f327be36d16 | 3 | public synchronized Connection get() throws DataException {
// ensure we haven't used too many connections
if (usedConnections.size() >= MAX_CONNECTIONS) {
throw new DataException("The database connection pool is out of connections -- a maximum number of " + MAX_CONNECTIONS);
}//if
try {
... |
1f7cfd82-081a-43d1-be26-7fdcd2d0ae9d | 7 | public void onReceivePushSolution(RepairSolution solution) {
logger_.info("Solution for path {} received.", solution.failedPath);
// Update routing table.
for (PeerReference ref : solution.failedHosts) {
Host failedHost = Deserializer.deserializeHost(ref);
logger_.debug(... |
2d9ea648-17ef-46b9-9c96-3169b8de55ac | 6 | public static TreeNode commonAncestor(TreeNode root, int childOne, int childTwo) {
if (root == null)
return null;
if (childOne == root.value || childTwo == root.value)
return root;
TreeNode left = commonAncestor(root.left, childOne, childTwo);
TreeNode right = commonAncestor(root.right, childOne, ch... |
cb643644-0d31-4bc9-91da-f064dad9701a | 7 | @Override
public boolean equals(Object other){
if(other instanceof HttpResponse){
HttpResponse otherResponse = (HttpResponse) other;
if(header == null)
return statusCode == otherResponse.statusCode &&
body.equals(otherResponse.body);
... |
0160c182-f82e-4bbf-8fde-0752e9564fd8 | 9 | public static List<String> generateAllSentencesWithAllDefinitions(GRESCTask task) {
List<String> pSentences = new ArrayList<String>();
List<GRESCOption> options = task.getOptions().get(0);
for (GRESCOption option : options) {
String sentence = task.getSentence().replaceAll("%s", "\\(%s\\)");
String formatte... |
c8c1b67d-708d-4b17-9fb4-fad74be74ad8 | 9 | @Override protected boolean canFigureMove(Point x, Point Abs) {
if ((x.x==1*getFI() || (x.x == 2*getFI() && isFirstMove)) && x.y == 0)
if (!C.isFigure(Abs) && x.x == 1*getFI() || !C.isFigure(Abs) &&
!C.isFigure(new Point(Abs.x-getFI(),Abs.y)) && x.x == 2*getFI())
ret... |
8c93490b-3ceb-424c-8d0c-fef16faa12cb | 2 | @Override
public void paint(Graphics g) {
Dimension currentSize = getSize();
Dimension maximumSize = getMaximumSize();
if (currentSize.width > maximumSize.width || currentSize.height > maximumSize.height) {
currentSize.width = Math.min(maximumSize.width, currentSize.width);
... |
271e37e0-03ec-47c9-9da7-31dd4ac0d220 | 0 | public static UDPChat getInstance()
{
return instance;
} |
a4dcae60-58f5-444f-abc5-8b011b01d8ff | 9 | @Override
public void run() {
if (state == GameState.Running) {
while (true) {
robot.update();
if (robot.isJumped()) {
currentSprite = characterJumped;
} else if (robot.isJumped() == false
&& robot.isDucked() == false) {
currentSprite = anim.getImage();
}
ArrayList<Projectile>... |
63518f12-1eb7-467f-8693-ad7944fd4c9c | 8 | @Override
public Parameter getParameter(final int parameterIndex) {
Parameter parameter;
switch (parameterIndex) {
case 0:
parameter = effect1On;
break;
case 1:
parameter = effect2On;
break;
case 2:
... |
48323098-1e3d-40aa-8461-7323095670c8 | 2 | @EventHandler(priority = EventPriority.NORMAL)
public void onEntityDeath(EntityDeathEvent event) {
if (event.getEntityType() == EntityType.PLAYER) {
Player player = (Player) event.getEntity();
RemovePlayer(player);
}
if (event instanceof PlayerDeathEvent) {
PlayerDeathEvent e = (PlayerDeathEvent) event... |
6a824ed2-965a-4b1a-8ce9-b1ebf8d43735 | 7 | public static int lengthOfLongestSubstring(String s) {
if(s.equals("")) {
return 0;
}
HashMap<String, Integer> table = new HashMap<String, Integer>();
int tmpLen = 0;
int maxLen = 0;
int start = 1;
String[] subStrings = s.split("");
int len = subS... |
ed9cbef6-62d9-4f5e-b79c-6bb88aae2493 | 8 | public void run() {
InetAddress group = null;
try {
group = InetAddress.getByName(multicast);
} catch (UnknownHostException e) {
e.printStackTrace();
}
//create Multicast socket to to pretending group
MulticastSock... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.