method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
cc622f1a-9c09-4082-af61-5d99e2afe06e | 3 | private void queryTable(String tableName) throws SQLException {
if (conn != null)
{
PreparedStatement stmt = conn.prepareStatement(String.format("SELECT * FROM %s", tableName));
ResultSet rs = stmt.executeQuery();
while (rs.next())
{
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) ... |
e41fa2ac-541d-43f4-bbb7-91fa08fb8245 | 2 | @Override
public void startSetup(Attributes atts) {
setText(atts.getValue(A_TEXT));
String mnemonic = atts.getValue(A_MNEMONIC);
if (mnemonic != null && mnemonic.length() > 0) {
mnemonic = mnemonic.trim().toUpperCase();
int mnemonicInt = mnemonic.charAt(0);
setMnemonic(mnemonicInt);
}
Outliner... |
6b969a16-0644-4ca6-94d0-d099b466be17 | 4 | protected synchronized void processEvent(Sim_event ev)
{
switch ( ev.get_tag() )
{
case GridSimTags.PKT_FORWARD:
case GridSimTags.JUNK_PKT:
processNetPacket( ev, ev.get_tag() );
break;
case GridSimTags.ROUTER_AD:
re... |
5516ea34-8587-4ec8-8324-af89025bdac4 | 6 | public static void main(String[] args) {
File f = new File("files/readme.txt");
BufferedReader reader = null;
BufferedWriter out = null;
int recuento = 0;
try {
reader = new BufferedReader(new InputStreamReader(
new FileInputStream(f)));
String line = reader.readLine();
while (line != null) {
... |
f4573cd9-4a3b-4aa6-be6a-ac6a1fe5baee | 9 | public Object getSelectedItem(Object component) {
String classname = getClass(component);
if ((classname == "combobox") || (classname == "tabbedpane")) {
int index = getInteger(component, "selected",
(classname == "combobox") ? -1 : 0);
return (index != -1) ? getItemImpl(component, ":comp", index) : null;... |
bf7fd652-aacd-4709-8b26-f69ff9c86c61 | 9 | public static void changeData(String c_id,String c_pw, String c_name, String c_email, String c_phone, String path)
{
Connection conn = null;
FileInputStream fis = null;
PreparedStatement psmt =null;
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://... |
f9995319-8cc1-40e1-a4a9-1b8079e28cbb | 8 | final public void Block_statement() throws ParseException {
/*@bgen(jjtree) Block_statement */
SimpleNode jjtn000 = new SimpleNode(JJTBLOCK_STATEMENT);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
jjtn000.jjtSetFirstToken(getToken(1));
try {
Statement();
} catch (... |
65ad98a5-f7fe-4f28-9eea-b25dbdad7d0b | 3 | public static void sort(long []arr){
int k=0;
long tmp = 0;
for(int i=0;i<arr.length;i++){
k = i;
for(int j=i;j<arr.length;j++){
if(arr[j] < arr[k]){
k = j;
}
}
tmp = arr[i];
arr[i] = arr[k];
arr[k] = tmp;
}
} |
b258938f-0ebb-454d-a280-0e69b912e031 | 7 | public static String setOfSequencesToString(FastVector setOfSequences, Instances dataSet, FastVector filterAttributes) {
StringBuffer resString = new StringBuffer();
Enumeration SequencesEnum = setOfSequences.elements();
int i = 1;
boolean printSeq;
while(SequencesEnum.hasMoreElements()) {
Se... |
ede81bef-a73b-408e-b28e-fcd7cfb538a2 | 5 | public static void displayResults(Event event) {
int size = loserStack.size();
for (int i = 0; i < size; i++) {
Team team = (Team) loserStack.pop();
if (i > 2) {
System.out.println(i + 1 + "th:" + " "
+ team.olympian1.getName() + " "
+ team.olympian2.getName());
event.getPlacing()[i] = te... |
27739a82-d776-4390-9ba8-079a06c5a7ef | 5 | private StoreInstruction getExceptionStore(StructuredBlock catchBlock) {
if (!(catchBlock instanceof SequentialBlock)
|| !(catchBlock.getSubBlocks()[0] instanceof InstructionBlock))
return null;
Expression instr = ((InstructionBlock) catchBlock.getSubBlocks()[0])
.getInstruction();
if (!(instr instanc... |
91827aee-a93b-4bf0-8704-d2b4b4d10923 | 8 | public void loadRestrictions() {
// Clear res.
restrictions.clear();
List<String> items = plugin.getConfigHandler().getRestrictedItems();
int count = 0;
// For every name included in the config, do some things
for (String item : items) {
Restriction r = new Restriction();
int itemID = plugin.getCo... |
6a5a0107-9487-4acf-a37f-035a6682c120 | 8 | private static void addSomeMetadata( OtuWrapper wrapper,
String inFile, String outFile, boolean rOutput )
throws Exception
{
HashMap<String, PatientMetadata> metaMap =
PatientMetadata.getAsMap();
HashMap<String, NewBiomarkerParser> bioMarkerMetaMap =
NewBiomarkerParser.getMetaMap();
//Syste... |
5def3196-421b-44be-9d3f-dafa394b22f8 | 4 | public boolean isOutOfCellBounds()
{
boolean out = false;
switch (direction) {
case 0:
out = (int)y <= (row - 1) * pixels + pixels / 2;
break;
case 1:
out = (int)x >= (column + 1) * pixels + pixels / 2;
... |
d2da0f9b-f0c2-4e38-9e3e-5bac4911fe37 | 4 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Teacher other = (Teacher) obj;
if (!Objects.equals(this.getName(), other.getName())) {
return... |
9cdfcbe3-12f2-4a54-93e7-644d4f27e2e8 | 3 | @Override
public int compareTo(Edge o) {
if(this==o){ return 0; }
if(this.weight==o.weight){
return 0;
}
if(this.weight>o.weight){
return 1;
} else {
return -1;
}
} |
b7d13eb9-cdd3-435f-9ac2-3fe4a57fa7d5 | 2 | public void lisaaSeuraavaArvollinen(Arvollinen arvollinen)
throws IllegalArgumentException, IllegalStateException {
if (arvollinen == null) {
throw new IllegalArgumentException();
}
if (seuraavaArvollinen != null) {
throw new IllegalStateException();... |
dd4b03ba-5f8d-48a4-a853-8648e76e8665 | 8 | static String filterZinOfWoord(String reeks) {
for(int i = 0; i < reeks.length(); i++) {
char temp = reeks.charAt(i);
String temp2 = Character.toString(temp);
if(reeks.charAt(i) > 31 && reeks.charAt(i) < 65)
reeks = reeks.replace(temp2," ");
else if(reeks.charAt(i) > 90 && reeks.charAt(i) < 97)
r... |
02629cfa-48b2-43b6-8921-4471175da917 | 9 | public void actionPerformed(ActionEvent e) {
if(e.getSource() == login_but)
{
if (login.getText().length() != 0 &&
password.getPassword().length != 0)
{
String pass = CallbackConstants.toMD5_String(password.getPassword().toString());
String log = login.getText();
try {
int callbac... |
b2dd7796-080e-486a-bf75-855fbc837573 | 9 | @Override
public boolean isDone(Game game)
{
//END Condition: there must be in the game:
// * exactly limit amount of sprites of type stype1
// * exactly subTypesNum number of subtypes of stype1
boolean ended = super.isFinished(game);
if(ended)
return true;... |
2065b628-1019-44bc-ab4a-2eb3ee2a64f5 | 3 | public static void main(String[] args){
System.out.println("_________________________________________________");
System.out.println("Welcome to the Innumeracy Math Library for Java demo!");
System.out.println("Choose from 1 of the following options:");
System.out.println("_______________________________________... |
6368204f-21e4-4808-b59d-44fcead461bc | 5 | public static void Prepare(Plugin plugin) {
MySQL.setPlugin(plugin);
SQLLogin = new File(plugin.getDataFolder() + File.separator + "MySQL.yml");
System.out.println("Filepath" + SQLLogin.getPath());
if (!SQLLogin.exists()) {
System.out.println("MySQL.yml was not found, Creating it");
System.out.println("Pl... |
e332913a-6142-4cd2-a14d-6cd0d37d5054 | 4 | public BoundMethod(Object self, Method method, Object[] parameters) {
this.self = self;
this.method = method;
this.parameters = parameters;
if (method != null && parameters != null) {
Class[] methodTypes = method.getParameterTypes();
if (methodTypes.length != par... |
755e6e6e-0a2e-40c9-ac95-b60abb496cf4 | 3 | @EventHandler
public void onPlayerCancelRoute(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack item = event.getItem();
if (this.manager.isRouteCancelItem(item) && this.manager.isRoutePlayer(player)) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Location loc = event.getCli... |
c518e8b6-87ab-464c-82f9-04f5586442a3 | 8 | protected void drawMixedMediaText(BufferedImage target, ArrayList<MixedMediaText> lines, ElementLayout elementLayout) {
Graphics2D g = (Graphics2D) target.getGraphics();
g.setFont(elementLayout.getFont());
g.setColor(elementLayout.getCardFont().getColor());
g.setRenderingHint(RenderingHi... |
b0a4e8fc-4f23-4e0f-9dcb-3b3368654765 | 0 | @Id
@GeneratedValue
public int getId() {
return id;
} |
9e475059-9b92-4dd5-b60e-a32af82be2cc | 4 | private void deleteItem()
{
String stock_num = null;
System.out.println("Type the stock number of the item you would like to delete from the cart.");
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
stock_num = br.readLine();
} catch (Exception e) {
System.out.println("error... |
17cb909a-dd4d-430c-9a57-f5ae4861f77b | 7 | public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String line = "";
StringBuilder out = new StringBuilder();
Dijkstra G = new Dijkstra(101);
while ((line = in.readLine()) != null && line.length() != 0) {
int[] nk = readInts... |
7378a7a1-b696-4792-af79-6fed15aa7c6c | 6 | public int find(String string) {
if (string==null) {
return -1;
}
for (int i=0;i!=m_stringOffsets.length;++i) {
int offset=m_stringOffsets[i];
int length=getShort(m_strings,offset);
if (length!=string.length()) {
continue;
}
int j=0;
for (;j!=length;++j) {
offset+=2;
if (string.ch... |
9925ea19-4aa4-4691-82f8-c9b7a9f489c3 | 0 | public byte getBiomeID(int x,int z){
return biomeID[x][z];
} |
e85de163-bbf3-42d8-8b25-ca0bec6a0dc3 | 8 | public ManagerArchivo() {
try {
escribirLog("[" + new Date() + "] INICIO DEL PROGRAMA");
FileReader fr = null;
BufferedReader br = null;
ArrayList<String> lineas = new ArrayList<String>();
fr = new FileReader(new File("estudio_juridico.conf"));
... |
d7930775-10a9-47ba-8b5e-519bdef65a13 | 9 | public Command(String name, int numberOfArgs, String helpMessage) {
this.name = name;
this.numberOfArgs = numberOfArgs;
this.helpMessage = helpMessage;
commands.add(this);
} |
564b8ea9-b4a3-4893-891b-c915680fdbe8 | 6 | public void add(double value) {
if (Double.isNaN(value)) {
value = 0d;
}
Date now = new Date();
lastValue = value;
avg30Min += value;
last30Minutes.add(new Tuple<Date, Double>(new Date(), value));
if (last30Minutes.size() > 30) {
avg30Min -= first(last30Minutes).getSecond();
last30Minutes.remove... |
00ac547c-0eeb-4176-9891-b0ed26134f4c | 7 | public void remove() {
if (this.root != null) {
FibonacciHeapNode beforeHighestPriority = this.root;
FibonacciHeapNode root = this.root.next;
if (root == null) {
this.root.tree.remove();
} else {
do {
if (befor... |
ab95f145-17be-4610-a21d-925ec6bdc3a8 | 6 | public static void run_spell_check(File dic, File doc, String option)
{
// Creating a new SpellCheckerUtil object with the dictionary file
SpellCheckUtil mySC = new SpellCheckUtil(dic);
// Creating a list of misspelled words after checking spellcheking the document
List<String> misspelledWords = mySC.spellC... |
7e422a16-762f-40c8-9345-5141c9cb5f2e | 3 | public int readMono(short[] outputArray) throws IOException {
if (this.nChannels == 1) {
return read(outputArray);
} else {
int len = outputArray.length;
short[] stereoArray = new short[len * 2];
int bytesRead = read(stereoArray);
for (int i = ... |
09429d3b-1194-4cab-a4f4-d413c5c7c4a7 | 3 | private void parseArgs(String[] args) {
if (args.length <= 1) throw new IllegalArgumentException("Not enough arguments.");
String targetFilename = args[0];
if (!targetFilename.endsWith(".zip")) throw new IllegalArgumentException("The target filename must end in .zip");
outFile = new TransactionalFileOutputStrea... |
70d3fdd1-4e46-4c27-9af4-e393b67170aa | 1 | public void testConstructor_RI_RD5() throws Throwable {
DateTime dt = new DateTime(TEST_TIME_NOW);
Duration dur = new Duration(-1);
try {
new MutableInterval(dt, dur);
fail();
} catch (IllegalArgumentException ex) {}
} |
5e518d21-8796-449c-b8ce-8345d839fe83 | 9 | @Override
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
//g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);... |
0df03570-c731-42b1-83ba-a39c0e55d71c | 1 | private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bitfield = 0;
read(new org.apache.thrift.protocol.... |
3f8f20ef-5162-4cd0-a13b-9047a28d3cf9 | 7 | public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int number = 0;
List<Integer> factors = new ArrayList<Integer>();
try {
boolean success = false;
while (!success) {
try {
System.out.print(... |
7e049506-e6b2-48d1-8752-3f26db0ffe25 | 5 | @Override
public List<E> insert(E d) {
if (this.isEmpty()) {
super.insert(d);
} else {
this.setFirst();
// New item is the smallest item so far
if (list.data.compareTo(d) > 0) {
insertFirst(d);
return this;
}
// Find the item where the new item should be placed after
while (list.nex... |
814bf755-d445-40dc-8496-5e4d3d93f6b0 | 4 | public static void addToEmptyTeam(Player player) {
if (blueMembers == null) {
blueMembers = player;
blueFriends.add(player);
} else if (greenMembers == null) {
greenMembers = player;
greenFriends.add(player);
} else if (orangeMembers == null) {
orangeMembers = player;
orangeFriends.add(player);
... |
4ca3c5d6-3809-4bcf-bba7-33d36580dd9a | 8 | private void digOut(final LayeredMap map,
Point p, Point dir, int range, Random rand)
{
if(range < 1) {
return;
}
// System.err.println("Digging " + range + " squares.");
final Point pos = new Point(p.x, p.y);
for(int x=0; x<range; x++) ... |
515e3642-f415-431f-a002-61928501777e | 0 | public Secteur getSecteur() {
return secteur;
} |
ca5ea999-4d80-4d68-ac9d-e3d578dc317a | 0 | protected void addMenu() {
JMenuBar bar = new JMenuBar();
JMenu op = new JMenu("");
JMenu help = new JMenu("");
JMenuItem admin = new JMenuItem("¼û");
JMenuItem exit = new JMenuItem("˳");
JMenuItem author = new JMenuItem("");
admin.setActionCommand("admin");
exit.setActionCommand("exit");
author.set... |
008c4faa-5284-4fa9-99e2-932c82a2887e | 7 | public void genLegalDestsSaveKing(Piece king, Piece threat)
{
if ((isBlack() ? mBoard.getGame().getBlackRules() : mBoard.getGame().getWhiteRules()).objectivePiece(isBlack()) == this)
return;
if (king == null)
return;
Iterator<Square> oldLegalDests = getLegalDests().iterator();
Square sq = null;
if (mI... |
d9b75369-ff8c-4422-8636-7f1fde503ee8 | 6 | public static void main (String[] args) {
System.out.println("MAX_INPUT: " + MAX_INPUT);
int numberOfNets = 100;
Net[] nets = new Net[numberOfNets];
int netLength, netWidth;
netLength = netWidth = 6;
for (int runs = 0; runs < numberOfNets; runs++) {
... |
7365b0be-0588-4f92-82aa-728773c99e13 | 4 | @Override
public void toString(String indent, StringBuilder buffer)
{
if (this.length == 0)
{
buffer.append("[]");
return;
}
if (this.subtype != TYPE_NBT)
{
buffer.append("[ ");
buffer.append(Array.get(this.array, 0));
for (int i = 1; i < this.length; i++)
{
buffer.append(", ").appen... |
24518f0b-5bd9-4981-95e2-13800417f17c | 8 | private boolean cleverRandom (Square square, Human human, Mark mark) {
Mark humanMark = new Mark(human.getMark());
if (square.belongs(humanMark, '2', 'a') && square.belongs(humanMark, '1', 'b')) {
mark.setLeftCoord('1');
mark.setTopCoord('a');
square.putMark(mark);
... |
8e702328-8dfd-485a-a743-69a567b30d31 | 4 | protected void setAttributesByShortcut(String shortcut, TimeBanBanCommand command) {
ConfigurationSection shortcuts = config.getConfigurationSection("shortcuts");
// configure reason
String reason = shortcuts.getConfigurationSection(shortcut).getString("reason");
if (reason == null || r... |
634ad516-0b16-4df6-8903-3bfd81b5aa71 | 4 | public static boolean importHover(double xPos,double yPos) {
int check = 0;
if((xPos > importXborderL) && (xPos < importXborderR))
check+=1;
if((yPos > importYborderT) && (yPos < importYborderB))
check+=1;
return check == 2;
} |
62971eb0-749c-4870-941b-5c475d8757bc | 5 | public static int doExecuteUpdate(String storedProcedure, ArrayList<String> arglist) throws DALException
{
try {
String prepCallParams = "";
for (int i=0; i<arglist.size(); i++)
prepCallParams += prepCallParams == "" ? "?" : ",?";
cstm = conn.prepareCall(" { CALL "+storedProcedure+"(" + prepCallParams ... |
36c5fb39-d0c7-47da-a563-c9ca17f22035 | 6 | private void remplirHashMap(String key) {
ArrayList<Character> al=new ArrayList<Character>();
for(int i=0;i<key.length();i++) {
if(this.alpha.contains(key.charAt(i)+"")) {
al.add(key.charAt(i));
}
}
for(int i=0;i<ALPHABET.length();i++) {
if(!al.contains(ALPHABET.charAt(i)) && this.alpha.contains(AL... |
4960501e-89ef-4a0a-94ed-d69de9e1cdda | 9 | public boolean equals(Object object) {
if (this == object) return true;
if (!(object instanceof CacheKey)) return false;
final CacheKey cacheKey = (CacheKey) object;
if (hashcode != cacheKey.hashcode) return false;
if (checksum != cacheKey.checksum) return false;
if (count != cacheKey.count) r... |
cdd54aa7-de76-4200-9e32-d6fd3be8e237 | 2 | public ShipUnlockPanel( FTLFrame frame ) {
this.setLayout( new BoxLayout(this, BoxLayout.Y_AXIS) );
this.frame = frame;
log.trace( "Creating Ship Unlock panel" );
log.trace("Adding ship unlocks");
JPanel shipPanel = new JPanel();
shipPanel.setLayout( new GridLayout(0, 3) );
shipPanel.setBorder( BorderF... |
c3beaffa-6e60-49cc-a6ee-6f5e8cabcc9f | 0 | public static Text getLabel(Graphics pen, Text text, String label)
{
Text temp = new Text(label);
double x = text.getPos().x + text.getWidth(pen) / 2 - temp.getWidth(pen) / 2;
double y = text.getPos().y - 2 * text.getHeight(pen);
temp.setPos(new Point2D.Double(x, y));
return... |
e00b4c67-331a-4527-9d37-6d4201bb481d | 4 | private Action getAction(String line) {
String[] lineSplitted = line.split(" ");
int second = Integer.parseInt(lineSplitted[0]);
String filePath = lineSplitted[2];
ActionsName a = ActionsName.valueOf(lineSplitted[ACTION_INDEX]);
Action action;
switch (a) {
... |
d572850e-54cd-49a6-bd23-31e43222320d | 6 | private boolean r_post_process_last_consonants() {
int among_var;
// (, line 415
// [, line 416
ket = cursor;
// substring, line 416
among_var = find_among_b(a_23, 4);
if (among_var == 0)
... |
ade9b169-9d2b-4073-b9fd-e8b07e3790e6 | 2 | public void setEnabledEditorTagged(boolean enabled) {
for (int i = 0; i < tabbed.getTabCount(); i++) {
Component c = tabbed.getComponentAt(i);
if (((Tag) componentTags.get(c)) instanceof EditorTag)
tabbed.setEnabledAt(i, enabled);
}
} |
bea01567-da2d-448f-8f51-a16a8aca630b | 5 | private void btnRenameItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnRenameItemActionPerformed
{//GEN-HEADEREND:event_btnRenameItemActionPerformed
String thename = JOptionPane.showInputDialog(this, "Enter the new name for the item:", "WiiExplorer", JOptionPane.QUESTION_MESSAGE);
... |
72fef23e-4c02-4673-8d58-829a7c025295 | 8 | public void run () {
if (threadId == 1) {
try {
lm.Lock (1, "a", LockManager.READ);
}
catch (DeadlockException e) {
System.out.println ("Deadlock.... ");
}
try {
this.sleep (4000);
}
catch (InterruptedException e) { }
try {
lm.Lock (1, "a", LockMan... |
608ee5a8-a7b6-4b56-b3aa-c58a46ff0963 | 0 | private static void invokeMethod(Method m, Object obj) throws Exception {
m.invoke(obj, "dynamically invoked");
} |
3e45d2c7-e41d-40b1-b9a5-2ba121548095 | 2 | private int getChar() throws IOException
{
if(this.eof)
{
return -1;
}
int result = this.in.read();
if(result == -1)
{
this.eof = true;
}
return result;
} |
55e5ae12-f0f7-4853-8f50-478521d1026f | 9 | @Override
protected String buildHeader() {
String header = options().header();
if (options().copyHeader()) {
Configuration def = getDefaults();
if ((def != null) && (def instanceof FileConfiguration)) {
FileConfiguration filedefaults = (FileConfiguration) de... |
0054f566-508e-4cb0-ab26-b10fe53afc2f | 8 | public AttackState isAdvancing(Move mov) {
int iterateVertical = mov.getEnd().row - mov.getStart().row;
int iterateHorizontal = mov.getEnd().column - mov.getStart().column;
Piece.adjLoc nextSpace = new Piece.adjLoc(mov.getEnd().row + iterateVertical, mov.getEnd().column + iterateHorizontal);
Piece.adjLoc previo... |
bb7f8219-6cc2-41e6-92e4-dba03fd6e94f | 7 | public static void main(String[] args) throws InterruptedException {
int nbRows = 0, nbColumns = 0;
int minRows = 10, minCols = 10;
boolean cont = true;
while(cont) {
try {
System.out.println("Enter a number of rows (min " + minRows + ") : ");
nbRows = new Scanner(System.in).nextInt();
if... |
e12909bb-2fda-4d04-8bed-e57701c72904 | 3 | @SuppressWarnings("deprecation")
public void GET(String request, String full, Server server) {
BrowserGETRequestEvent bgre = new BrowserGETRequestEvent(this, request, full);
server.getEventSystem().callEvent(bgre);
if (bgre.isCancelled())
return;
String respond = bgre.getResponse();
if (respond.equals("")... |
480f79aa-fbf7-4c98-b39e-c5ba387d32af | 2 | public int maxProfit(int k, int[] prices) {
if(k>(prices.length+1)/2){
k=(prices.length+1)/2;
}
if(k==0) return 0;
prices=handle(prices);
return f(k,prices);
// 下面是另一种解法,使用的标准DP思想,复杂度也是多项式: N*N*N ,但是会超时
// Integer[][] aux = new Integer[prices.length + 1][];
// ... |
7387f0f0-e5a6-4c54-af44-7a213706d4b9 | 0 | public String getAlgorithm() {
return algorithm;
} |
f08b58f8-32a7-48f8-a75d-8adeabf4e004 | 1 | private boolean jj_3_77() {
if (jj_scan_token(PLUS)) return true;
return false;
} |
ed36a0dc-c0e8-442c-9ccf-0049b311b9a5 | 3 | public String getCommand(int x) {
String y;
if (x == 1) {
y = "attack";
}
else if (x == 2) {
y = "defend";
}
else if (x == 3) {
y = "jump";
}
else {
y = "";
}
return y;
} |
53fef148-107b-423a-a2f3-36f6580f15e3 | 8 | @Override
public void execute() {
SceneObject rock = SceneEntities.getNearest(Main.getRockIDs());
if (Inventory.isFull()) {
if (BANK_AREA.contains(Players.getLocal().getLocation())) {
if (Bank.isOpen()) {
Bank.deposit(Main.oreID, 28);
} else {
Bank.open();
}
} else if (MINE_AREA.contain... |
7ec0ceab-0504-403c-8dab-95641134fc7d | 9 | public int compareTo(DBType dt) {
ByteArrayType bt = null;
if (dt instanceof ByteArrayType) {
bt = (ByteArrayType) dt;
} else {
return -1;
}
int thisLen = bytes!=null?bytes.length:0;
int btLen = bt.bytes!=null?bt.bytes.length:0;
if (btLen < thisLen) {
return 1;
}
if (btLen > thisLen) {
... |
84426ecd-ccde-4f4b-b383-80b779ebe893 | 8 | public void update() {
UP = key[KeyEvent.VK_UP] || key[KeyEvent.VK_W];
DOWN = key[KeyEvent.VK_DOWN] || key[KeyEvent.VK_S];
LEFT = key[KeyEvent.VK_LEFT] || key[KeyEvent.VK_A];
RIGHT = key[KeyEvent.VK_RIGHT] || key[KeyEvent.VK_D];
if (UP != prevUP) {
System.out... |
227c3314-9298-4a6a-a02d-ac742b302ff6 | 0 | public UndoQueueListener[] getUndoQueueListeners() {
return (UndoQueueListener[]) undoQueueListeners.toArray();
} |
bcfa07b7-19df-4949-9669-8b86240b6696 | 0 | @BeforeClass
public static void setUpClass() {
} |
578c423b-0dc5-45a3-8dba-61b7822c54e6 | 0 | @Id
@GeneratedValue
public int getId() {
return id;
} |
f54dea14-20c7-452f-8062-8eeb85cfff5c | 3 | public ArrayList<Edge> getEdges() {
ArrayList<Edge> g = new ArrayList<Edge>();
setState(States.ARR_ADJ);
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (arr_adj[i][j] != 0)
g.add(new Edge(i, j, arr_adj[i][j]));
}
}
return g;
} |
7b077481-db2b-4793-ade7-24bd307012e8 | 1 | public boolean _setSprite(Sprite sprite)
{
if(sprite != null)
{
this.sprite = sprite;
return true;
}
else
{
return false;
}
} |
dcb89302-8539-4cd9-9562-3b92ec878233 | 1 | private void compute_new_v()
{
// 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... |
a911c1ee-319b-4250-9145-58bd7db09dfb | 0 | public static void setConfigFile(String configFile) {
HibernateSessionFactory.configFile = configFile;
sessionFactory = null;
} |
423b1ad4-f72a-4194-9c4a-f2ec1d819610 | 3 | private boolean notOverrideVessel(Map<String, EnumElement> board,
EnumLine line, EnumColumn column, boolean vertical,
EnumElement vessel) {
boolean empty = true;
for (int i = 1; i < (vessel.getLength() + 1); i++) {
if (vertical) {
line = EnumLine.getEnumLine(i);
empty = this.isEmpty(board, line, ... |
29b1ed99-4206-4b24-80cb-e35635116220 | 4 | private void circumference (int circumference) throws IllegalArgumentException, Exception {
// Illegal call or Illegal arguments
if(socket == null) {
throw new Exception("Client:>>>Please connect to a host before specifying trust ring circumference");
} else if (circumference == 0) {
circumference = 1;
}
... |
26bc96de-68c1-4584-be77-db820ce2d1bb | 1 | public ArrayList<treeNode> generateTrees(int n) {
if (n == 0) {
ArrayList<treeNode> roots = new ArrayList<treeNode>();
roots.add(null);
return roots;
}
return generateSubTree(1, n);
} |
94f2a200-f615-404f-9bb9-0f2925c56526 | 8 | public void parse()
throws FileNotFoundException, IOException, ExParser, ExManifest {
BufferedReader lReader = null;
try {
lReader = new BufferedReader(new FileReader(mManifestFile));
String lLine;
int lHighestSequencePosition = 0;
Map<String, Integer> lFileIndexes = ne... |
05280547-d6f8-45c2-880f-12b0be1f5ffb | 9 | void compress(int init_bits, OutputStream outs) throws IOException {
int fcode;
int i /* = 0 */;
int c;
int ent;
int disp;
int hsize_reg;
int hshift;
// Set up the globals: g_init_bits - initial number of bits
g_init_bits = init_bits;
// Set up the necessary values
clear_fl... |
98bae88a-5f1b-49de-8ea0-2b438fce58f4 | 6 | public static boolean Load() {
sheets.clear();
Connection c = RpgConnection.getConnection();
if(c!=null) {
Statement s = null;
ResultSet results = null;
try {
s = c.createStatement();
results = s.executeQue... |
8114569c-d6f5-4043-98e8-ce21cbd92369 | 3 | static protected Location parseLocationLine(String line) {
String latitude, longitude;
int latitudeSign = 1, longitudeSign = 1;
if(log.isDebugEnabled())
log.debug("line:" + line);
latitude = line.replaceAll("^.*CENTER LOCATED NEAR ", "");
latitude = latitude.replaceAll(" AT.*$", "");
if(latitude.ma... |
6161f21b-c1eb-4391-b7cc-9eed3c800a2b | 0 | @FXML
private void handleCancelButton(ActionEvent event) {
getMessageBox().userAction = UserAction.CANCEL;
hide();
} |
30706910-76c0-4fc9-9966-2bad26ec6788 | 0 | public void setStateName(String stateName) {
this.stateName.set(stateName);
} |
a351720e-c67f-45b2-bb3c-74b6c395a01b | 0 | @Override
public String getCur() {return cur.toString();} |
7a363e2c-23cf-4fc3-8f21-64e7324bf02a | 9 | protected Object computeAssign(IEnv env, Object right) {
ASTNode leftNode = left();
if (leftNode instanceof PrimaryExpr) {
PrimaryExpr expr = (PrimaryExpr) leftNode;
if (expr.hasPostfix(0) && expr.postfix(0) instanceof ArrayRef) {
Object object = expr.evaluateSubExpr(env, 1);
if (object instanceof Obj... |
718fc8e5-547f-4e54-ae87-8ccc43da563d | 5 | boolean wordBreakDFS( String s, Set<String> dict ) {
boolean result = false;
for( int i = 0; i < s.length(); i++ ) {
String head = s.substring(0, i + 1 );
String tail = s.substring( i + 1 );
if( dict.contains( head ) ) {
if( tail.length() == 0 ) {
... |
9de6015f-11e5-4469-b289-3856a6b71841 | 0 | public FiguraGeometrica(double x, double y) {
posX = x;
posY = y;
} |
2e05e286-0ea6-446b-8c45-15ad292f384b | 5 | public static void debugPrintBlockedArray() {
for (int x = 0; x < MapEditorData.WIDTH_IN_TILES; x++) {
System.out.print("-");
}
System.out.println();
for (int y = 0; y < MapEditorData.HEIGHT_IN_TILES; y++) {
System.out.print("|");
for (int x = 0; x < MapEditorData.WIDTH_IN_TILES; x++) {
System.out.... |
a08bb2de-22d5-4cd6-9634-54a1c9fd3cfc | 4 | public static void scoreRecords(Collection<Record> records) throws SQLException
{
Map<Integer, Integer> recordScoreSum = new TreeMap<Integer, Integer>();
Map<Integer, Integer> scoreCount = new TreeMap<Integer, Integer>();
String sql = "SELECT record_id,score_value from score_history where user_id ... |
a1e78fd4-4ad6-4c31-bb81-35787a7034f8 | 6 | private void resize() {
width = getSkinnable().getWidth();
height = getSkinnable().getHeight();
if (getSkinnable().isKeepAspect()) {
if (aspectRatio * width > height) {
width = 1 / (aspectRatio / height);
} else if (1 / (aspectRatio / height) > width) {
... |
5ce51b8d-25ad-44de-9e9e-d70c46237601 | 1 | public synchronized void closeAllConnections() {
for (Socket socket : openConnections) {
safeClose(socket);
}
} |
49ecd5d4-b21e-4d60-9308-1120308aa5d9 | 2 | public Dimension calculatePreferredHeaderSize(TreePanel panel) {
Font font = getHeaderFont();
int width = getWidth();
if (panel.isUserSortable()) {
width -= SORTER_WIDTH;
}
Dimension size = TextDrawing.getPreferredSize(font, TextDrawing.wrapToPixelWidth(font, getName(), width));
if (panel.isUserSortable(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.