method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
92fcbb4a-b352-4245-9a56-a93470b0944b | 8 | public static void main(String[] args) throws Exception {
int choice = -1;
while (choice < 4) {
System.out.println("Please Enter your choice\n");
System.out
.println("1. Create New Array \n2. Search Element \n3. Delete Element \n4. Exit\n");
BufferedReader reader = new BufferedReader(new InputStreamRe... |
8bb493de-59ef-4ff6-9699-96b37e800514 | 2 | private void init() {
try {
// Setup Parser
factory = SAXParserFactory.newInstance();
factory.setValidating(true);
reader = factory.newSAXParser().getXMLReader();
reader.setErrorHandler(new SimpleSAXErrorHandler());
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAX... |
5a51a714-bc8c-49ca-a78f-217c3ec0401b | 6 | private static double readNum(String[] tokens,int[] st,int end,boolean allowNeg,int lnum,String line)
throws IOException{
if(st[0]==end) throwMe("syntax error",lnum,line);
String s=tokens[st[0]++];
boolean neg=s.equals("-");
if(neg){
if(!allowNeg) throwMe("envelope durations must be positive",lnum,line);
... |
adcbda5f-d9a8-4b87-a5e7-fb2928d3e865 | 2 | private void addFirst(Item item) {
if (item == null)
throw new NullPointerException();
if (isEmpty()) {
first = new Node<Item>();
last = new Node<Item>();
first.item = item;
last = first;
} else {
Node<Item> node = new Node<... |
2395b020-623a-4aed-997c-5ae1eebb3b5a | 7 | public void setParameterDefs(ArrayList<Attribute> paramDefs) throws Exception {
if (paramDefs.size() != m_parameters.size()) {
throw new Exception("[DefineFunction] number of parameter definitions does not match "
+ "number of parameters!");
}
// check these defs against the optypes of ... |
2e87e924-199e-4a67-8bfc-3165c70f8fa3 | 3 | public static void main(String args[]){
String[][] dateExamples = new String [][]{{"24-04-2013", "27-04-2013"},{"24-10-2014","27-10-2014"},{"29-03-2014","31-03-2014"},{"01-04-2014","31-03-2014"}} ;
for (String[] testData : dateExamples) {
int num = DateTimeComparisonSampler.numberOfDaysWro... |
a5d7f08c-51f0-4879-b418-31d5eee61715 | 9 | @Override
public String putString(Rider R)
{
switch(rideBasis)
{
case Rideable.RIDEABLE_AIR:
case Rideable.RIDEABLE_LAND:
case Rideable.RIDEABLE_WAGON:
case Rideable.RIDEABLE_WATER:
case Rideable.RIDEABLE_SLEEP:
case Rideable.RIDEABLE_ENTERIN:
return "in";
case Rideable.RIDEABLE_SIT:
case Ridea... |
ffed1931-2740-43ae-86a3-4e13bd9fab30 | 8 | protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, DataAccessException, Exception {
response.setContentType("text/html;charset=UTF-8");
// app initialization parameters
String email = this.getServletContext().... |
bb2a8c24-eb1b-4b60-84d8-2230d27dd551 | 2 | public int getY(Board board, int x) {
for (int y=0; y<6; y++) {
if (board.get_state(x, y) == 0) {
return y;
}
}
return -1; //return -1 if column is full
} |
8e9b4431-e5b9-4445-9a90-802715a7626b | 8 | final public void BraExp() throws ParseException {/*@bgen(jjtree) BraExp */
SimpleNode jjtn000 = (SimpleNode)SimpleNode.jjtCreate(this, JJTBRAEXP);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
jj_consume_token(LEFTB);
Expression();
jj_consume_token(RIGHTB);
} catch (Throw... |
a56c7dfd-39fd-41ee-91e6-60051ba00866 | 9 | public GraphPanel(int width, int height) {
this.setPreferredSize(new Dimension(width, height));
requestFocus();
requestFocusInWindow();
addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
ctrl = e.isControlDown();
... |
8afe8768-9e04-4c76-876a-4b567d0995f8 | 6 | public final void method65(int i, int[] is, int i_8_, int i_9_, int i_10_,
byte i_11_, int i_12_) {
if (Class108.aClass304_1662 != ((Class310_Sub2) this).aClass304_3896
|| ((Class310_Sub2) this).aClass68_3895 != Class68.aClass68_1183)
throw new RuntimeException();
if (i_11_ != 112)
((Class310... |
34e5e085-430c-454d-817c-a9e32c4c1d51 | 9 | public void updateStatus(){
if(jobState == JobState.MAP_RUNNING || jobState == JobState.REDUCE_RUNNING){
int numTaskComplete = 0;
Map<Integer,Task> runningTasks = null;
if (jobState == JobState.MAP_RUNNING){
runningTasks = this.mapTasks;
} else ... |
127ac241-7cc3-4c38-85cb-3851e6efec4e | 0 | public static PastPane getPastPaneNoScroll(Configuration configuration) {
return new PastPane(configuration);
} |
e270d096-73c1-46f4-9c15-f97609622bb2 | 5 | private void doLog(String msg){
if(toConsole) {
System.out.append(msg);
System.out.flush();
}
if(toFile) {
try {
fw.append(msg);
fw.flush();
} catch(IOException e) {
e.printStackTrace();
log.log(Level.SEVERE, "IOException while writing to LogFile!"); //<_may cause loop!?
}
}
if(... |
fe3b1c8f-4655-4d2e-8202-09288c834aea | 8 | @Override
public void tActionEvent(TActionEvent event)
{
Object source = event.getSource();
if (source == newSimButton)
{
mainMenu.setX(0);
newSimMenu.setX(640);
simWidth = (int) simWidthSlider.getValue(0);
}
else if (source == resumeSimButton)
{
if (Hub.simW... |
db256b0a-8c2f-4ae6-abc6-5b4d03f8b8a1 | 1 | public void randomRoom(Rectangle bounds) {
Point bstart = bounds.start;
Point bend = bounds.end;
int max_x = (int) (bend.x - bstart.x - min_size.x + 1);
int max_y = (int) (bend.y - bstart.y - min_size.y + 1);
int x = Rand.randRange(1, max_x);
int y = Rand.randRange(1, max... |
cd48f9f4-a09f-493a-8305-601cd6811f1b | 3 | public void processFile() {
LOG.info("processFile ... " + file);
// final Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
// LOG.info("Locale : " + locale.getDisplayName());
if (file != null) {
try {
final InputStream is = file.getIn... |
0c169f5f-0f55-456f-8fbf-4de27f3a6b34 | 1 | public void printImplements(final PrintWriter out, int indent) {
// There are multiple roots to the implements graph.
indent += 2;
final Iterator roots = this.implementsGraph.roots().iterator();
while (roots.hasNext()) {
final TypeNode iNode = (TypeNode) roots.next();
indent(out, indent);
out.println(i... |
95616fb6-2714-4f54-9a75-633b7c610fea | 2 | @Override
public void printAnswer(Object answer) {
if (!(answer instanceof int[])) return;
int[] choices = (int[]) answer;
for (int i=0; i<choices.length; i++){
System.out.println(i+"). "+choices[i]);
}
} |
aef62de6-a19f-494f-93b3-c2e7c98cdb9f | 2 | private void btnRestartSyncActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRestartSyncActionPerformed
// Make sure we ended current synch process
// If not, ask user what to do with current synch process
if (this.syncState != SyncState.COMPLETE) {
if (JOptionPan... |
52bc9164-1e97-4d22-8663-1564850dd9c9 | 8 | private static Map<String, DPermission> groupPagesByPermissions(String source) {
//convert input to array
List<DPermission> list = new ArrayList<DPermission>();
String[] array = source.split("\n");
for (String s : array) {
String[] perArray = s.split(",");
DPermis... |
16a41074-f363-4010-93d2-04232ef1d1f6 | 5 | public static String getDirectory(){
String relativeWdPath,workingDirectory;
String inputFileName;
//Folder workingDirectory;
//Because userHome is a public static field, it can be used without having initialized any instance of Folder:
//This because the static variables have their own memory sp... |
c0d21e55-c4ee-4193-924d-dff0951146fb | 7 | private void moveNewZipFiles(String zipPath) {
File[] list = listFilesOrError(new File(zipPath));
for (final File dFile : list) {
if (dFile.isDirectory() && this.pluginExists(dFile.getName())) {
// Current dir
final File oFile = new File(this.plugin.getDataFol... |
517174fb-b69f-45d2-8e3f-a26fcf360011 | 7 | public Component getListComponentForDataSection(TaskObserver taskObserver, String dataSectionName, List list, Iterator indexIterator) throws InterruptedException
{
if ( (GameVersion.MM6 == outdoorDataMap.getGameVersion())
&& (dataSectionName == DATA_SECTION_TERRAIN_NORMAL_DATA) ) return getNonApp... |
71926390-2005-4cfb-b9fa-a4b3cf5731ac | 7 | public void sumMatrix()
{
// Sums the matrix and places the result in the Division Factor text box
float sum = 0;
int size = Integer.parseInt(windowSizes[jComboBox1.getSelectedIndex()].substring(0,1));
int start_position = 0;
switch(size)
{
case... |
6cae8b21-bbc1-481d-a602-49953d65364f | 6 | private boolean canTrim() {
if(!(s.endsWith(")")&&s.startsWith("("))) {
return false;
}
int grade=1;
for(int i=1;i<s.length()-1;i++) {
if(s.charAt(i)==')') {
grade--;
}
else if(s.charAt(i)=='(') {
grade++;
... |
332e8035-4853-47da-b011-eb0891f80c75 | 8 | public void preiseAnpassen()
{
int unterschiedMehl = this.mengeMehlEnde - this.mengeMehlAnfang;
int unterschiedKorn = this.mengeKornEnde - this.mengeKornAnfang;
// wenn der Mehlendbestand sich um min. 50% des Anfangsbestandes erhöht
// hat wird das Mehl ggf. billiger
if ( unterschiedMehl >= ( (int) ( this.m... |
172d40d4-bb75-44c9-907e-cb4ccbc41622 | 5 | public void run()
{
//WHILE loop for game commands
while (AL_ManagerCommands.size() > 0)
{
//Checking which command to pick
// ::: ::: ::: ::: :::
/* DESTROY
*
* Format: [COMMAND #], object ID
* */
if (AL_ManagerCommands.get(0)[0] == REMOVE)
{
DestroyByID(AL_ManagerCommands.ge... |
30b24d77-af77-4c3f-b180-391a93d8065c | 5 | public static String getFolder() {
os = OS.getOS();
String path = "";
switch (os) {
case LINUX:
path = System.getProperty("user.home", ".") + File.separator + ".minecraft" + File.separator;
break;
case WINDOWS:
String appdat... |
b7cf7fba-8a97-48ba-b05c-f4ac7353d86e | 8 | public int getAttributes() {
int perms = 0;
if (archive)
perms |= net.decasdev.dokan.FileAttribute.FILE_ATTRIBUTE_ARCHIVE;
if (compressed)
perms |= net.decasdev.dokan.FileAttribute.FILE_ATTRIBUTE_COMPRESSED;
if (encrypted)
perms |= net.decasdev.dokan.FileAttribute.FILE_ATTRIBUTE_ENCRYPTED;
... |
6b2889dc-17f7-4a27-aa5a-58361a99192d | 5 | public void closeTag(LangProfile profile) {
if (profile != null && tag_ == target_ && buf_.length() > threshold_) {
NGram gram = new NGram();
for(int i=0; i<buf_.length(); ++i) {
gram.addChar(buf_.charAt(i));
for(int n=1; n<=NGram.N_GRAM; ++n) {
... |
c7170785-7577-49b3-911c-0dd2a60c0d0c | 5 | private void addMenuItemForFileToMenu(DocumentInfo docInfo) {
RecentFilesListItem menuItem = null;
// switch on nameform to create a menu item
String path = PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_PATH);
switch (currentDisplayNameForm) {
case FULL_PATHNAME:
default:
... |
32bba022-cd2c-40ee-945f-7ee0f9f8acd8 | 9 | public DrawableTree getCurrentTree() {
DrawableTree tree = null;
if (currentLine == null)
return null;
try {
int index = currentLine.indexOf("(");
int parenDepth = 1;
int lastIndex = 0;
StringBuilder treeStrBuilder = new StringBuilder();
treeStrBuilder.append("(");
//If the tree spans multip... |
8ad2ffb7-219c-4c60-aa65-a5017ddb037e | 5 | public SimulationWorkerResult(double[] wins, double[] ties, double[] loses)
{
if (wins == null || ties == null || loses == null) {
throw new NullPointerException();
} else if (wins.length != ties.length || ties.length != loses.length) {
throw new IllegalArgumentException();
... |
696b7059-adb5-4f41-98f2-43243f417943 | 9 | public Serializable call(Class<?> iface, Serializable param,
long receivedTime) throws IOException {
try {
Invocation call = (Invocation) param; //调用参数 Invocationd对象包含方法名称 形式参数列表和实际参数列表
if (verbose)
log("Call: " + call);
//从实例缓存中按照接口寻找实例对象
Object instance = INSTANCE_CACHE.get(iface);
if ... |
7279bbf5-f4ef-414a-8485-1df81701c955 | 9 | @Override
public void handle(String dataDir, String arg) throws Exception
{
if(inputDataDir == null || inputDataDir.length() == 0)
{
inputDataDir = dataDir;
}
File queryFile = new File(arg);
if(queryFile.exists())
{
if(queryFile.isDirectory... |
520b8513-0c97-4e8c-9ad6-260610504d53 | 8 | @Override
public boolean execute(MOB mob, List<String> commands, int metaFlags)
throws java.io.IOException
{
String parm = (commands.size() > 1) ? CMParms.combine(commands,1) : "";
if((!mob.isAttributeSet(MOB.Attrib.AUTOLOOT) && (parm.length()==0))||(parm.equalsIgnoreCase("ON")))
{
mob.setAttribute(MOB.At... |
c4d41126-7c89-4a8e-aa8a-a8fc38ce1ed5 | 8 | private void generateClassifierForNode(Instances data, Range classes,
Random rand, Classifier classifier, Hashtable table)
throws Exception {
// Get the indices
int[] indices = classes.getSelection();
// Randomize the order of the indices
for (int j = ind... |
51f059a3-07cb-465d-9985-613497d3af22 | 8 | public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
n = Integer.parseInt(br.readLine());
cost = new int[n];
StringTokenizer st = new StringTokenizer(br.readLine());
for(int i=0; i<n; i++){
... |
d0b59980-650b-46b7-97a8-08411abadf46 | 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");
... |
f3c47c1c-7f7e-42a5-a262-9d49ce1a3717 | 6 | public static double findNetworkDistance(NeuralNetwork one,NeuralNetwork two){
ArrayList<Node> oneNodes=Node.sort(one.getAllNodes());
ArrayList<Node> twoNodes=Node.sort(two.getAllNodes());
double distance=0.0;
int i=0;
int f=0;
int oneIn=oneNodes.get(i).getInnovationNum();
int twoIn=t... |
42cdf4fd-a63a-4d2c-a8a8-d242f991c84d | 2 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
if(this.jTextField1.getText().isEmpty()){
Error np = new Error(this,true);
np.ready("Debe ingresar su nombre de usuario");
np.setVisible(true);
}
else{
... |
fba912e4-3249-4491-9b94-33ce1cec30cc | 1 | private void compute_new_v_old()
{
// p is fully initialized from x1
//float[] p = _p;
// pp is fully initialized from p
//float[] pp = _pp;
//float[] new_v = _new_v;
float[] new_v = new float[32]; // new V[0-15] and V[33-48] of Figure 3-A.2 in ISO DIS 11172-3
float[] p = new float[16];
float[]... |
896b686e-7bfc-4b70-a951-c3ad45f18ad0 | 0 | public String toString() {
return id + ": " + "i4 = " + i4 + ", INT_5 = " + INT_5;
} |
16cd9b99-a661-49fd-850c-51442117854a | 3 | public void buttonClicked(String actionCommand) {
if (MANAGE.equals(actionCommand)) {
showAccountManager(accounts, accountTypes);
} else if (DETAILS.equals(actionCommand)) {
AccountDetails.getAccountDetails(lijst.getSelectedValue(), journals, journalInputGUI);
} else if (... |
959f76e3-691d-4a7f-9eaf-2fd6aadf46ce | 9 | public FoodFileBean getFileName(int idx) throws Exception{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
FoodFileBean fileBean = null;
String sql = "";
String filename = "";
String fileTmp = "";
try{
conn = getConnection();
sql = "select * from foodfile where idx=?";... |
5d8d4372-3057-4221-a83f-7fd619a67dcc | 6 | private static boolean isHexString(String str) {
if (str == null
|| !(str.startsWith("0x") || str.startsWith("0X"))
|| str.length() <= 2) return false;
for (int i = 2; i < str.length(); i++) {
if ("0123456789ABCDEFabcdef".indexOf(str.substring(i, i+1)) < 0) {
... |
e504679d-045b-49b0-83a7-0f09d6b6eb4f | 7 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Game other = (Game) o;
if (getQuestionsCount() != other.getQuestionsCount() || !getName().equals(other.getName())) {
return false;
}... |
7c0433f8-ae89-4105-a8d4-414d7710c2e3 | 5 | private boolean mouseOverBottomArrow(int mx, int my) {
if (!isVisible) return false;
if (mx < positionX || mx > positionX + width) return false;
if (my < positionY || my > positionY + height) return false;
return (my >= positionY + height - 16);
} |
106a6c0f-5c58-438d-853f-2184c1d78302 | 5 | public double pow(double x, int n) {
if (n == 0)
return 1;
if (n == 1)
return x;
if (n == -1) {
if (x != 0) {
return 1 / x;
} else {
return Integer.MAX_VALUE;
}
}
// n>=2 || n<=-2;
double square = x * x;
if (n > 0) {
int powerForSquare = n / 2;
int restPower = n % 2;
re... |
281211d3-7e09-4d34-b466-01f7e35c5ffc | 3 | public void testXML2JSON(){
String generatedJson = "{\"response\":{\"ip_addresses\":{\"ip_address\":\"66.249.17.251\",\"domain_names\":[\"DMAINTOOLS.COM\",\"DOAMINTOOLS.COM\"],\"domain_count\":52}}}";
String originalJson = "{\"response\":{\"ip_addresses\":{\"ip_address\":\"66.249.17.251\",\"domain_count\":52,\"doma... |
cfeb970a-b4fd-4353-b3ee-eb45836f5ed6 | 4 | @Override
public int mover() {
Partida.Pantalla pantalla = Partida.getPantalla();
//cambiamos el estado del disparo si saliera del panel del Juego
if(x < -width)
return -1;
if(x > pantalla.getX()*2 + pantalla.getWidth())
return -1;//sale por... |
46aa9ff4-d527-4b14-88da-1cd5377fafc8 | 4 | public void test_add_RP_int_intarray_int() {
int[] values = new int[] {10, 20, 30, 40};
int[] expected = new int[] {10, 20, 30, 40};
BaseDateTimeField field = new MockStandardBaseDateTimeField();
int[] result = field.add(new TimeOfDay(), 2, values, 0);
assertEquals(true, Arrays.e... |
92667c7c-bb12-4ca2-bb41-6c675361131d | 3 | public Boolean http_status_filter(String url){
HttpResponse response;
try {
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet httpget=new HttpGet(url);
httpget.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 3000);
resp... |
6c843052-8dc6-47dd-8734-b28498c50910 | 5 | private boolean shouldIgnorePacket(DatagramPacket packet) {
boolean result = false;
InetAddress from = packet.getAddress();
if (from != null)
{
if (from.isLinkLocalAddress() && (!_BoundAddress.isLinkLocalAddress()))
{
// Ignore linklocal pack... |
3f7e5eeb-38b7-4059-ba71-ed80a21e9117 | 9 | public BookBuilderSpec<P> paperColors(Map<PaperBuilderSpec<?>, ColorBuilderSpec<?>> paperColors) {
verifyMutable();
if (this.paperColors == null) {
this.paperColors = new HashMap<PaperBuilderSpec<?>, ColorBuilderSpec<?>>();
}
if (paperColors != null) {
for (Map.Entry<PaperBuilderSpec<?>, ColorBuilderSpec... |
98b4cbbb-91ad-4887-9437-743d566aefc8 | 5 | public String apply(String s) {
if (s == null) {
if (matchesNull()) {
if (!replace.contains("$1")) {
return replace;
}
}
return null;
}
Matcher m = pattern.matcher(s);
StringBuffer sb = new StringBuff... |
d4c6064e-92c4-4b92-8f36-16914856e7ee | 4 | public void setOpponentSkin(int character) {
String s;
s = character == 0 ? "/Characters/TestChar.png"
: "/Characters/TestChar2.png";
// load sprites
try {
final BufferedImage spritesheet = ImageIO.read(getClass()
.getResourceAsStream(s));
sprites = new ArrayList<BufferedImage[]>();
for (... |
450a8b48-4d9d-4579-99f2-2b4d3e2e066b | 5 | @Override
public boolean equals(Object other) {
if (other instanceof BackpackData) {
return ((BackpackData) other).isRegistered() == this.isRegistered()
&& ((BackpackData) other).getType().equals(this.getType())
&& ((BackpackData) other).getOwner().equals(... |
25734d39-e534-4ac9-9f38-fcaf3fef8f1a | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TextAnalyzer other = (TextAnalyzer) obj;
if (averageSentenceCharLength != other.averageSentenceCharLength)
return false;
if (averageSentence... |
983e708f-b6ca-43b9-a825-48777a2b75f3 | 3 | @Override
public List<ByteBuffer> transfer(List<ByteBuffer> elements)
{
List<ByteBuffer> denied = new ArrayList<ByteBuffer>();
// Calculate how much memory is transfered to this factory, and build
// a list of the buffers denied for caching.
for (ByteBuffer b : elements)
{
// If the buffer can be cached,... |
4b0b8dd5-d5cf-4d48-ac62-b95079a8b63f | 7 | @Override
public int hashCode()
{
int result = _name.hashCode();
result = 31 * result + (_hidden ? 1 : 0);
result = 31 * result + (_systemHidden ? 1 : 0);
result = 31 * result + _resultType.hashCode();
result = 31 * result + (_value != null ? _value.hashCode() : 0);
result = 31 * result + (_... |
90b85d59-1d64-4f80-9fb8-f0633d74b5ad | 8 | private void ParseHtml(StringBuffer buffer, ITag root)
throws HtmlParseException {
int startIndex = 0;
// Iterate as long as there are children
while (true) {
int startTagStartIndex = 0;
int startTagEndIndex = 0;
int endTagStartIndex = 0;
int endTagEndIndex = 0;
// Find the beginning of the ne... |
4afe15c3-519a-4e6d-89d8-b6e0f59c625c | 4 | public static void main(String args[]) throws Exception, CannotProduceDateParser, ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
String xmlPath = "monitor.xml";
if (args.length > 0) xmlPath = args[0];
xmlPath = new File(... |
f5e29e5f-9c12-4f69-a6e7-3655c1ad4e26 | 8 | public int maximumGap(int[] nums) {
if (nums.length < 2) {
return 0;
}
int max = 0;
int min = Integer.MAX_VALUE;
for (int n : nums) {
max = Math.max(max, n);
min = Math.min(min, n);
}
int len = (max - min) / nums.length + 1;
int size = (max - min) / len + 1;
int buckets[][] = new int[size][2]... |
a9b6c7c8-d843-4594-a478-974abd80a6f8 | 1 | public String getSuperclass() {
if (cachedSuperclass == null)
cachedSuperclass = constPool.getClassInfo(superClass);
return cachedSuperclass;
} |
a66257a2-543c-4a29-90c2-87cd0b5cdc5c | 8 | private Dimension layoutSize(Container target, boolean preferred)
{
synchronized (target.getTreeLock())
{
// Each row must fit with the width allocated to the containter.
// When the container width = 0, the preferred width of the container
// has not yet been calculated so lets ask for the maximum.
int ... |
9008c16a-a02d-4abf-abef-e4d6fed95f93 | 6 | public static String numberToString(Number number) throws JSONException {
if (number == null) {
throw new JSONException("Null pointer");
}
testValidity(number);
// Shave off trailing zeros and decimal point, if possible.
String string = number.toString();
if (string... |
c376f167-61c3-482c-8d2c-78929e8a9353 | 1 | public void test_append_nullPrinter() {
try {
DateTimeFormatterBuilder bld2 = new DateTimeFormatterBuilder();
bld2.append((DateTimePrinter) null);
fail();
} catch (IllegalArgumentException ex) {
// expected
}
} |
b2bcbc42-7657-4ae1-aa82-de6e0eefd57f | 8 | public void render()
{
try
{
buffer = createImage(720, 720);
Graphics g = buffer.getGraphics();
Graphics i = image.getGraphics();
g.drawImage(board.getImage(), 0, 0, 720, 720, this);
i.drawImage(board.getImage(), 0, 0, 720, 720, this);
g.setColor(Color.BLACK);
g.drawRect(x - 25, y - 25, 50, 5... |
32c11db4-1f15-4c54-a676-f5fa6ea25813 | 7 | public static void main(String[] args) {
// Create a variable for the connection string.
String connectionUrl = "jdbc:sqlserver://localhost:1433;" +
"databaseName=AdventureWorks;integratedSecurity=true;";
// Declare the JDBC objects.
Connection con = null;
Stateme... |
ec96f261-e350-43cc-95b5-e205d2780bf6 | 1 | public void setLeaves(final List leaves) {
if (SSAPRE.DEBUG) {
System.out.println("setting leaves of " + this + " to "
+ leaves);
}
this.leaves = new ArrayList(leaves);
} |
6e167b64-0474-4cc6-b5f4-a11e0a5329d8 | 6 | public static void print(int[][] table, CustomLogic logic) {
int padding = String.valueOf(table[table.length - 1][table[0].length - 1]).length();
String strFmt = " %" + padding + "s |";
String dgtFmt = " %" + padding + "s |";
String sep = "+";
for (int i = 0; i < padding + 2; i++... |
bf189608-252d-4af0-a9f8-1e70bf439833 | 2 | public boolean quitChecker(String input)
{
boolean okToQuit = false;
if(input != null && input.equals("bye"))
{
okToQuit = true;
}
return okToQuit;
} |
b2b92858-5fbe-45cd-92f1-76d42e33b516 | 7 | private String DDCRET_String(int retcode)
{
switch ( retcode )
{
case DDC_SUCCESS: return "DDC_SUCCESS";
case DDC_FAILURE: return "DDC_FAILURE";
case DDC_OUT_OF_MEMORY: return "DDC_OUT_OF_MEMORY";
case DDC_FILE_ERROR: return "DDC_FILE_ERROR";
case DDC_INVALID_CALL:... |
8eb9743b-59d8-4665-b6b1-4e98643759b5 | 1 | @Override
public void show() {
// Lazy Instantiation
if (!initialized) {
initialize();
initialized = true;
}
OutlinerDocument doc = (OutlinerDocument) Outliner.documents.getMostRecentDocumentTouched();
documentTitleValue.setText(doc.getTitle());
int lineCount = doc.tree.getLineCount();
lineCo... |
634a30e0-d980-4045-bb47-6d68d700cd59 | 2 | public void enable() throws IOException {
// This has to be synchronized or it can collide with the check in the task.
synchronized (optOutLock) {
// Check if the server owner has already set opt-out, if not, set it.
if (isOptOut()) {
configuration.set("opt-out", ... |
7b211836-176b-4b52-940b-a6a79039fc87 | 0 | public void close() throws IOException {
//init();
isInited = true;
internalIn.close();
} |
0cb01bdf-14d3-4493-ad75-92acb028ae9b | 5 | @RequestMapping(value = "del", method = RequestMethod.POST)
@ResponseBody
public Map del(@RequestParam int[] id) {
Map<String, Object> map = new HashMap<>();
List<String> l1 = new ArrayList<>();
List<String> l2 = new ArrayList<>();
List<String> l3 = new ArrayList<>();
f... |
191ed027-014f-4226-a752-051bf725902d | 6 | @Override
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
DatabaseManager manager=DatabaseManager.getManager();
try {
MultipurposeRoom room = manager.getMultipurposeRoomDao().queryForId(
Integer.parseInt(request.getParameter(ID)));
if(r... |
071f57b3-3f61-477e-bc5c-420088ee6531 | 7 | public ByteBuffer formatCommand(String format, Object... args) throws IOException
{
Preconditions.checkNotNull(format);
for (Object arg : args)
{
Preconditions.checkNotNull(arg);
}
int argidx = 0;
ByteBuffer result = BufferUtils.EMPTY;
... |
70883750-e08d-42ee-b16a-cb78e8575383 | 9 | void setProperty(String propertyName, Object value, BitSet bs) {
if ("color" == propertyName) {
isActive = true;
short colix = Graphics3D.getColix(value);
if (bsColixSet == null)
bsColixSet = new BitSet();
byte pid = JmolConstants.pidOf(value);
for (int i = atomCount; --i >= 0;... |
e80fa460-8a2f-40d8-ab1a-9865cb71afdb | 8 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof Project_eXceed))
return false;
Project_eXceed other = (Project_eXceed) obj;
if (id != other.id)
return false;
if (project_Name == null) {
if (other.project_Name != ... |
62a11026-dfff-420d-9339-ab2a36ccc6ff | 8 | @Override
public void caseADeclAvalieDefinicaoComando(ADeclAvalieDefinicaoComando node)
{
inADeclAvalieDefinicaoComando(node);
if(node.getAvalie() != null)
{
node.getAvalie().apply(this);
}
if(node.getLPar() != null)
{
node.getLPar().apply(... |
54d182a9-01b4-4785-9ba0-55f45b941fb3 | 4 | @Override
public int compareTo(SASRunner compareTarget)
{
if (this.priorityLevel != null || compareTarget.getPriority() != null)
{
if (this.priorityLevel > ((SASRunner)compareTarget).getPriority())
{
return -1;
}
else if (this.priorityLevel < ((SASRunner)compareTarget).getPriority())
{
ret... |
021dad13-0255-496e-94c8-ccc67adcf42d | 9 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
final int dirCode=CMLib.directions().getDirectionCode(CMParms.combine(commands,0));
if(dirCode<0)
{
mob.tell(L("Climb where?"));
return false;
}
if((mob.location().getRoomInDir(dirCode)==... |
3a015f5a-cd02-41d1-b258-8be7cd4a743f | 6 | @Override
protected void lock() {
while (true) {
if (!calcLocker.isWriteLocked() && calcLocker.writeLock().tryLock())
if (calcLocker.getWriteHoldCount() != 1)
calcLocker.writeLock().unlock();
else if (hasAdjustment() == PRO_ADJ_PAR
... |
5e4e3130-589f-4b71-9a9b-2ed17a0824ef | 9 | @Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final BinaryNode other = (BinaryNode) obj;
if (left == null) {
if (other.left != null) {
return false;
}
} el... |
2848415e-b4cd-44a5-a448-04a807a1f358 | 7 | public static BufferedImage buildCostume(Object[] form) {
int width = ((Number)form[0]).intValue();
int height = ((Number)form[1]).intValue();
int depth = ((Number)form[2]).intValue();
int[] bitmap;
try {
bitmap = decodePixels((byte[]) form[4]);
} catch (IOException e) {
System.err.println("Fail... |
552ee653-9443-4ecb-8c4d-a05414252185 | 4 | public int plusDILookback( int optInTimePeriod )
{
if( (int)optInTimePeriod == ( Integer.MIN_VALUE ) )
optInTimePeriod = 14;
else if( ((int)optInTimePeriod < 1) || ((int)optInTimePeriod > 100000) )
return -1;
if( optInTimePeriod > 1 )
return optInTimePeriod + (this.unstab... |
fff39479-ce1d-4d26-b054-7fe1d3722da6 | 1 | @SuppressWarnings("unchecked")
public Transition usingId(Id id) {
if (this.id != null) {
throw new IllegalStateException("Id already assigned!");
}
this.id = id;
return this;
} |
1df3fdf0-7c3d-4009-8145-32d775ff4691 | 7 | public synchronized void preDraw(Graphics2D g) {
if (!updated) {
dw = dh = 0;
lines.clear();
for (Information info : list) {
dw = Math.max(dw, (double) info.wrap(g, maxWidth, lines));
// Mala medzera medzi spavami
dh -= g.getFon... |
01ebb6f0-acd5-4afa-89a7-886fbe177a9e | 7 | @Override
public LinkedList<Tuple<Sentence_tree, Tuple<String, String>>> interesting_subtree(Hashtable<String,Boolean> voc, Hashtable<String, Boolean> subvoc){
LinkedList<Sentence_tree> keyword_list = bfs_name(voc);
LinkedList<Tuple<Sentence_tree, Tuple<String, String>>> interest = new LinkedList<Tuple<Sentence_tr... |
c785f0a8-a9bb-4d23-80bf-957506ca060a | 0 | public String compileDetail(){
myCompiler.compileSource(pass_code);
return SUCCESS;
} |
28b09d94-25c7-45fa-8af7-97d6ab00db38 | 6 | @SuppressWarnings("unchecked")
@Override
public void drop(DropTargetDropEvent event) {
Transferable tr = event.getTransferable();
if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
event.acceptDrop(DnDConstants.ACTION_COPY);
final List<File> files;
try {
files = new LinkedList<File>((List... |
564ce7aa-a6d5-4f9d-9f95-c225412a1cc2 | 8 | public int maximalSquare(char[][] matrix) {
if (matrix.length == 0) {
return 0;
}
int height = matrix.length;
int width = matrix[0].length;
int dp[][] = new int[height][width];
for (int i = 0; i < height; i++) {
dp[i][0] = Character.getNumericValue(matrix[i][0]);
}
for (int i = 0; i < width; i++... |
32d24c60-22e7-4cea-a6fb-c10a4ef81f23 | 3 | private void resize() {
size = getSkinnable().getWidth() < getSkinnable().getHeight() ? getSkinnable().getWidth() : getSkinnable().getHeight();
if (size > 0) {
for (Region led : leds) {
led.setPrefSize(size, size);
} ... |
abd3768e-b177-457c-b607-42c53e1bc42e | 2 | public boolean checkCollision(int r, int c)
{
if (row == r && column == c)
{
alive = false;
return true;
}
return false;
} |
1daf75ad-81df-443a-86b8-100122930095 | 7 | @Override
public void execute(FileSystem fs, String[] parts) {
if (parts.length > 2) {
throw new IllegalArgumentException("too much arguments, use only file name");
}
String name = parts[1];
boolean nonexistent = true;
Locker.lock(Thread.currentThread().getId());
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.