method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
38927385-b145-4d1b-97ad-7976f0452ec8 | 8 | public static int getLevenshteinDistance(String s, String t) {
if (s == null || t == null) {
throw new IllegalArgumentException("Strings must not be null");
}
/*
* The difference between this impl. and the previous is that, rather
* than creating and retaining a ma... |
83ed7683-9cc1-46bc-90e3-c6c7e109a37a | 4 | public String getPowerSwitchingMode ()
{
switch (getHubCharacteristics () & 0x0003) {
case 0x00: return "ganged";
case 0x01: return "switched";
case 0x02: return "reserved-2";
case 0x03: return "reserved-3";
}
return "?";
} |
66f3ee18-309f-4a6c-b9df-3b1320413f38 | 3 | public static boolean isRolateString(String s,String t){
if(s == null || t == null){
return false;
}
s += s;
if(s.contains(t)){
return true;
}
return false;
} |
c86144d7-7575-4f34-b06c-6d5ba2c9564d | 2 | public String searchByPhone(final String phone) throws IOException {
for (Record record : notebookCache.values()) {
Record rec = new Record(record.toString());
if (rec.phone.equals(phone)) {
return rec.name;
}
}
return null;
} |
0f608390-89a2-4f5f-b035-b07e7a9a5d2e | 3 | protected Color getTextForeground(boolean selected)
{
Color c = UIManager
.getColor(selected ? "SimpleInternalFrame.activeTitleForeground"
: "SimpleInternalFrame.inactiveTitleForeground");
if (c != null) {
return c;
}
return UIManag... |
b7d83703-77fe-4119-9309-00064569e208 | 4 | public String getLCS(int i, int j)
{
LinkedList<Character> lst = new LinkedList<>();
while (i >= 0 && j >= 0)
{
if (X.charAt(i) == Y.charAt(j))
{
lst.addFirst(X.charAt(i));
i--;
j--;
}
else
{
if (len[i][j] == len[i][j - 1])
j--;
else
i--;
}
}
return lst.toStri... |
848ef975-d641-4bfe-b7c8-550395855e65 | 3 | public static void main (String [] args){
int a=9;
if (a>40){
System.out.println("condition 1");
}else if (a>20){
System.out.println("condition 2");
}else if (a<10){
System.out.println("condition 3");
}else{
System.out.println("Else condition");
}
} |
accf9e31-3d8b-49d5-9c91-732ee48d445a | 8 | public void setTrisBLabels(int t) {
// t = t & 0b11111111;
int a = t & 0b00000001;
int b = t & 0b00000010;
int c = t & 0b00000100;
int d = t & 0b00001000;
int e = t & 0b00010000;
int f = t & 0b00100000;
int g = t & 0b01000000;
int h = t & 0b10000000;
if (a > 0) {
label_35.setText("I");
} else {... |
745ce997-aee3-4730-b914-df1506e9c43b | 8 | public void keyPressed()
{
if (!playing)
{
playing = true;
loop();
}
TetrisDirection t = null;
switch (key)
{
case CODED:
switch (keyCode)
{
case DOWN:
// t = TetrisDirection.DOWN;
t = TetrisDirection.RIGHT;
break;
case UP:
// t = TetrisDirection.UP;
t = TetrisDirect... |
b66d3e43-6296-4b28-b57e-d5b317f09dc4 | 2 | public void add(Packet p) {
newAdded = true;
activePackets.append(p);
if(Configuration.asynchronousMode && !Configuration.interferenceIsAdditive) {
testForInterference();
}
} |
48a9498f-ecad-4b1a-ba08-46b55dff726c | 1 | private IRemoteCallObject setResponse(long key, IRemoteCallObject response,
boolean complete, boolean error) {
IRemoteCallObject obj = getCallObj(key);
if (obj != null) {
obj.setResponseRemoteCallObject(response);
obj.setComplete(complete);
obj.setError(error);
}
return obj;
... |
7178e1e6-26dd-4553-a0bb-b869b7ea35f8 | 3 | public void checkForHelpTopics(DriverGenerator dg) {
// boiler plate
WebDriver wd = dg.generate();
ParallelPrepHelper pph = new ParallelPrepHelper(wd);
// setup
boolean madeItToPage = pph.goToURL(AMAZON_HOME_PAGE);
boolean helpLink = pph.clickOnVisibleElement(HELP_LINK);
int numberOfHelpTopicsFound = pph.... |
49bbc1af-2874-4301-904e-4d9eb3865956 | 3 | private void closeApp() {
int result = JOptionPane.showConfirmDialog(
this,
"Are you sure you want to exit the application?",
"Exit Application",
JOptionPane.YES_NO_OPTION);
if(result == JOptionPane.YES_OPTION) {
mainPanel.unsibscribeAll();
... |
ce019166-f503-46d6-9609-4dacbff5c6ee | 6 | @Override
public void read() throws IOException
{
if (isNotReady())
{
return;
}
long startTime = System.nanoTime();
inbound.clear();
packetsRead = 0;
int read = onRead( buffer );
if (read == -1)
{
close();
}
else
{
buffer.flip();
while (!closed && readBuffer(buf... |
abeab3fc-a05c-4dc1-99f2-c6c23e12c4c0 | 7 | public void register(Class<?> clazz) {
List<org.bukkit.command.Command> registeredCommands = new LinkedList<>();
Object obj = null;
try {
obj = clazz.newInstance();
} catch (IllegalAccessException | InstantiationException e) {
this.log("Couldn't register command for " + clazz.getCanonicalName());
}
... |
bcdbb7d6-2a27-46bd-b981-3dbb0304d327 | 9 | public void update(int delta) {
//After the player is updated, update viewport changes
if(em.getPlayer()!=null){
lastPlayerX = em.getPlayer().x;
lastPlayerY = em.getPlayer().y;
}
if(lastPlayerX+MAP_OFFSET_X >= DISPLAY_WIDTH-MAP_EDGE_BUFFER){
addToMapOffsetX(-1);
}
if(lastPlayerY+MAP_OFFSET_Y >= DIS... |
c16d865f-0b4c-492e-b63e-5d9484abb23f | 3 | private static Object[] parseArray(LinkedList<Character> json)
{
char c = json.removeFirst();
if (c == ']') // Check for empty array
return new Object[0];
json.addFirst(c);
ArrayList<Object> temp = new ArrayList<Object>();
do
{
temp.add(parse(json));
c = json.removeFirst();
}
while (c !=... |
3401999e-3598-4a86-bbe8-532ba26749ea | 0 | public static void main(String[] args) {
System.out.println(12);
System.out.println(012);
System.out.println(0x12);
} |
64338c2e-7dda-4cc7-91b9-5a55bca0e8b5 | 5 | @Override
public Component getListCellRendererComponent(JList<? extends Session> list,
Session j, int index, boolean isSelected, boolean cellHasFocus) {
label_j1.setForeground(new Color(0xCCCCCC));
label_j2.setForeground(new Color(0xCCCCCC));
Color bgColor;
if(isSelected)
if(cellHasFocus)
bg... |
839ba60b-cfb0-4cec-8092-ea51eb368d05 | 1 | private void resetLayout() {
this.removeAll();
this.add(Box.createRigidArea(new Dimension((FRAME_WIDTH / 100) * 2, FRAME_HEIGHT / 5)));
for (JLabel label : labels) {
this.add(label);
this.add(Box.createRigidArea(new Dimension((FRAME_WIDTH / 100) * 2, (FRAME_HEIGHT / 100)... |
924a946c-aa3f-49d0-893d-7674cac9992d | 2 | private void clearFullLines() {
for (int i = 0; i < rows.length; i++) {
if (clearLineIfFull(i))
linesCleared++;
}
} |
50e26031-49f0-49aa-bb7a-d484dffe842f | 8 | public void lees()
throws DbException{
Scanner filescanner = null;
try {
filescanner = new Scanner(handler.getBestand());
} catch (FileNotFoundException e1) {
throw new DbException("file not available");
}
while(filescanner.hasNextLine())
{
Scanner linescanner = new Scanner(filescanner.nextLine... |
b404b378-610f-4512-a477-a0497b427515 | 3 | public RAFFile findRessource(String input) throws IOException {
RAFFile retVal = null;
outtaloop:
for(Map.Entry<String,ArrayList<RAFFile>> file : archives.entrySet())
{
for(RAFFile rafFile : file.getValue())
{
if(rafFile.searchForRessource(input) !... |
ed7129a8-df37-4043-a8f0-c7069915f449 | 3 | public Money calcCurrentMoney(){
Money balance = new Money();
int sizeOfList = transactions.size();
for(int index = 0; index < sizeOfList; index++){
if(transactions.get(index).transactionType == "deposit"){
balance = balance.add(transactions.get(index).tMoney);
}
else if(transactions.get(index).trans... |
e8e50fb6-55f5-4e4e-add0-5a4390bc45df | 7 | private void createNavigationMenu(int numberOfPages, int currentPage) throws IOException {
Logger.getLogger(ReportGenerator.class.getName()).entering(ReportGenerator.class.getName(), "createNavigationMenu", new Object[] {numberOfPages, currentPage});
if (numberOfPages==0) {
return;
}... |
a80f32b1-bd44-4f3c-ac11-4f0ae30f32e3 | 7 | public static void logProperties(Logger logger, Properties properties) {
Set<Object> propKeys = properties.keySet();
List<String> lines = new ArrayList<String>();
String leftWall = "# ";
String equals = " = ";
int lineOffset = 2;
int maxLength = 0;
for (Object key: propKeys) {
if (key instanceof ... |
58bcf0ac-20af-460a-814a-abd7c1da9378 | 2 | public void setCurrentAnimation(int index) {
if (index < 0 || index >= animations.size()) {
throw new IndexOutOfBoundsException();
}
currentState = animations.get(index);
currentState.reset();
} |
1d080847-1c2d-4c4e-b15a-37924ad15446 | 1 | private String SHA1 (String text) {
try {
MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] sha1hash = new byte[40];
md.update(text.getBytes("iso-8859-1"), 0, text.length());
sha1hash = md.digest();
return convToHex(sha1hash);
} catch (Exception e) {
e.printStac... |
7962e436-9309-417d-a722-c457a4e9a69a | 6 | public static String escape(String string) {
StringBuffer sb = new StringBuffer();
for (int i = 0, length = string.length(); i < length; i++) {
char c = string.charAt(i);
switch (c) {
case '&':
sb.append("&");
break;
cas... |
8ceee06b-8a19-4555-b9a1-1857e1327ece | 2 | static public boolean isBound(final CSProperties p, String key, int dim) {
String bound = p.getInfo(key).get("bound");
if (bound == null) {
return false;
}
StringTokenizer t = new StringTokenizer(bound, ",");
if (t.countTokens() == dim) {
return true;
... |
7e976a08-f60a-42b3-b822-2db5b20a79f0 | 6 | public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringBuilder out = new StringBuilder();
String line = "";
LIM = Integer.MAX_VALUE;
while ((line = in.readLine()) != null && line.length() != 0) {
int times = Integer.parseI... |
05f357e6-9062-46c4-a8eb-5c6cbd60ab5a | 6 | public void showTopPlayers(CommandSender sender,
PDComp sortBy,
int page,
int itemsPerPage) {
List<PlayerData> rawList = plugin.sqlDb.readAllPlayers();
// Sort first by total playtime, then by total logins
Collections.sort(rawList, PDComp.desc(PDComp.getComparator(sortBy)));
Li... |
bdf06bb9-8a26-4b8e-802d-d74340b223df | 9 | private void traverseFileNames(String fixed, Pattern pattern, boolean forward) {
currentCount = 0;
estimatedTotalCount = 1000;
final ArrayList selectedFileNames = new ArrayList();
Exchange ex = null;
StringBuilder sb = new StringBuilder();
try {
ex = persistit... |
9684eec8-ed12-4de2-8e00-db08aad39afc | 6 | public void update(boolean full) {
owner = tile.getOwner();
owningSettlement = tile.getOwningSettlement();
tileItems.clear();
TileItemContainer tic = tile.getTileItemContainer();
if (tic != null) {
tileItems.addAll(tic.getImprovements());
if (tic.getResou... |
384b1e8d-7e88-4c41-8ccb-a4c5bae21623 | 9 | public Queue<String> peonXMLUnit(){
try {
path = new File(".").getCanonicalPath();
FileInputStream file =
new FileInputStream(new File(path + "/xml/papabicho.xml"));
DocumentBuilderFactory builderFactory =
DocumentBuilderFactory.newInstance();
Docum... |
eecd9da9-fe66-4743-871f-78d432552ae2 | 3 | public Question poserQuestion(){
int p = this.palierActuel;
int i = 0;
Question q;
boolean trouver = false;
while((!trouver ) && (i < this.catalogue.size())){
if( p == this.catalogue.get(i).getPalier())
trouver = true... |
4eaf7415-cfc4-4d4e-85d7-448560e60b8d | 2 | public static void main(String args[])
{
String query="select name,inauthors from inauthor where paperid=4";
SQLconnection sqLconnection=new connection().conn();
ResultSet rsSet=sqLconnection.Query(query);
String authors;
try {
while(rsSet.next()){
authors = rsSet.getString("inauthors");
System.ou... |
ed4501c4-f30b-4869-a4e8-bad71a3dadb2 | 1 | public void sendAttackRequest(int x, int y) {
//set displaying
if (gui != null) {
gui.updateState(eBattleFieldMode.Displaying);
}
Message<Coordinates> attack = new Message<>();
attack.setMessageType(eMessageType.attack);
attack.setDataContainer(new Coordinates... |
d87513c5-60b7-4295-a588-ca9fec8aa1f9 | 0 | public int getId() {
return this.id;
} |
9012e697-53f5-4007-874a-b93e1375a1b1 | 4 | Object readResolve() throws ObjectStreamException {
try {
int n = interfaces.length;
Class[] infs = new Class[n];
for (int i = 0; i < n; i++)
infs[i] = loadClass(interfaces[i]);
ProxyFactory f = new ProxyFactory();
f.setSuperclass(load... |
8ce0d072-e06d-4ab4-a279-ef231319e97a | 5 | public void takeTurn(Point selectedLocation) throws Connect4Exception, GameException {
Player currentPlayer = this.game.getCurrentPlayer();
Player otherPlayer = this.game.getOtherPlayer();
PlayerType playerType = currentPlayer.getPlayerType();
if (this.game.getGameType() == Ga... |
8aee9956-5b5f-413c-981b-03feeea4d596 | 0 | public String getPackgeName() {
return packgeName;
} |
b8871afe-0bac-41e2-a32f-78bf9255d1a7 | 9 | public void render(Screen screen){
for(int ya = y; ya < y + h; ya++){
for(int xa = x; xa < x + w; xa++){
int col = 0xff7d7d7d;
if(xa == x || ya == y || xa == x + w - 1 || ya == y + h - 1){
if(selected) col = 0xffffffff;
else col = 0xffbfbfbf;
}
screen.renderPixel(xa, ya, col);
}
}
... |
0343db56-3fe0-4aee-b0c3-5617444d800c | 5 | public void startTurn(){
new Thread(new Runnable() {
public void run() {
try {
for (SimonButton button : buttons) {
button.setEnabled(false);
/// button.removeActionListeners();
}
... |
824b71ac-173d-4a97-b43b-d71e1bab1d69 | 2 | @Override
public Object getAttribute(String key) {
if (attributes != null) {
if (key == null) {
key = "";
}
return attributes.get(key);
}
return null;
} |
f581204a-74b0-41b0-86c8-030007f58a07 | 9 | public ArrayList<ArrayList<Integer>> rangeCombine(int startN, int endN,
int k) {
ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
int countInRange = endN - startN + 1;
if (startN > endN || countInRange < k)
return result;
// count in range same as k, only one comb
if (countI... |
7967e5de-2978-4516-b9ed-53b9565ff22d | 2 | public static <T> T firstElementOrNull( final Iterable<T> iterable )
{
if ( iterable == null ) {
return null;
}
final Iterator<T> iterator = iterable.iterator();
if ( iterator.hasNext() ) {
return iterator.next();
} else {
return null;
... |
5f1ef8d6-ada2-4a4d-81dd-a5d6a6f4e43b | 8 | public java.sql.Date asDate()
{
try {
if (isNull()) {
return null;
} else if (isDate()) {
return (java.sql.Date) value;
}
Calendar cal = Calendar.getInstance();
if (isTimestamp()) {
Timestamp ts = (Timestamp) value;
long date = ts.getTime();
int nanos = ts.getNanos();
retur... |
309935f7-7b83-4720-8c95-5741f555ac1e | 6 | @Test
public void randomFigurePlacement() {
FiguresPlacement figuresPlacement = new BishopsPlacement();
Set<String> boards = figuresPlacement.placeFigureOnBoard(BISHOP.getFigure(), EMPTY_BOARD_SIZE_6);
assertThat("boards are not full", boards.size() == 36, is(true));
assertThat("boa... |
ea4adf0f-953f-4f54-96de-7ebd24110e30 | 3 | @SuppressWarnings("resource")
public static void main(String[] args) {
ServerSocket serverSocket = null;
int serverPort = 8888;
try {
serverSocket = new ServerSocket(serverPort);
} catch (Exception e) {
System.out.println("Das Serversocket konnte nicht erzeugt werden");
return;
}
... |
290fa72a-76ed-4f48-b17f-c59c887a74cc | 5 | public CheckResultMessage checkL5(int day){
int r1 = get(17,5);
int c1 = get(18,5);
int r2 = get(27,5);
int c2 = get(28,5);
if(checkVersion(file).equals("2003")){
try {
in = new FileInputStream(file);
hWorkbook = new HSSFWorkbook(in);
if(0!=getValue(r2+5, c2+day, 10).compareTo(getValue(r1+2+day... |
0f0a031f-e134-4534-a5aa-2e8a77d265a2 | 3 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
try {
int generat = (int) spingen.getValue();
int popul = (int) spinpopul.getValue();
double ci = (double) spincross.getValue();
double mc = (double) sp... |
78e5a3fd-04bd-477d-8703-f76036cde16f | 3 | private boolean outOfBounds()
{
return x + getWidth() > Const.width ||
y + getHeight() > Const.height ||
x < 0 || y < 0;
} |
57590191-49f3-4b48-acee-851bcad36baa | 4 | private static GridResourceWithFailure createGridResource(String name,
double baud_rate, double delay, int MTU, int totalPE,
int totalMachine, int rating, String sched_alg)
{
// Here are the steps needed to create a Grid resource:
// 1. We need to crea... |
655d3c55-e6a4-4e0b-a402-9e62dd04ff12 | 1 | @Override
public double arvo() throws IllegalStateException {
if (!super.argumenttiAsetettu()) {
throw new IllegalStateException();
}
return Math.cos(super.getArgumentti().arvo());
} |
963ae209-4558-4493-9df2-07424cbdc70e | 1 | public void setSubLCommand(final CycList command) {
if (getStatus().equals(SubLWorkerStatus.NOT_STARTED_STATUS)) {
subLCommand = command;
} else {
throw new UnsupportedOperationException("Worker has already started.");
}
} |
f3536544-3512-4a61-a884-a49983639fd4 | 2 | public void testGetField_int() {
LocalDate test = new LocalDate(COPTIC_PARIS);
assertSame(COPTIC_UTC.year(), test.getField(0));
assertSame(COPTIC_UTC.monthOfYear(), test.getField(1));
assertSame(COPTIC_UTC.dayOfMonth(), test.getField(2));
try {
test.getField(-1);
... |
18b8085d-29c1-4e33-a0e7-03aed8c3d87a | 5 | public static void main(String[] args){
int top=1;
int bot=1;
for(int i=10;i<100;i++){
for(int j=i+1;j<100;j++){
if (hasCommon(i, j)){
double ii = i;
double jj = j;
if (Math.abs(ii/jj - elimiCommon(i,j)) < (0.0000000001)){
System.out.println(i + " " + j + " "+ Math.abs(ii/jj - elimiCom... |
5d8b51cc-4639-418a-bf8b-5307f3ae4d55 | 7 | private ArrayList<ArrayList<Integer>> createGen() {
ArrayList<ArrayList<Integer>> nextGen = new ArrayList<ArrayList<Integer>>();
double fitSum = getFitSum();
for (int i = 0; i < currGen.size(); i++) {
nextGen.add(new ArrayList<Integer>());
int parentOne = getIndividual(f... |
bc5ebc77-4507-43ea-bb90-817921575d28 | 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... |
e649e9c8-45b2-49f5-8746-47071e296943 | 2 | private void action(String s) {
StringTokenizer st = new StringTokenizer(s," ");
String tString;
while (st.hasMoreTokens()) {
tString = st.nextToken();
if (isValidStringToAdd(tString)) {
results.add(tString);
}
}
} |
a8926997-45cc-476a-a522-ef2667ddf5f2 | 8 | public static void main(String[] args) {
final BoundedBuffer<Integer> buffer = new BoundedBuffer<Integer>(5);
final Random random = new Random();
Thread thread1 = new Thread(new Runnable() {
@Override
public void run() {
int t1 = 1000;
whi... |
310f8f16-2b8f-4336-bc74-1df43625d6aa | 6 | final Class318_Sub4 method2386(int i, AbstractToolkit var_ha) {
anInt10057++;
AnimatableToolkit class64 = ((Class318_Sub1_Sub3_Sub2) this).aClass235_10045
.method1668(false, true, -127, 2048, var_ha);
if (class64 == null)
return null;
Class101 class101 = var_ha.method3705();
class101.method894(((Clas... |
d1d25673-7dbd-4d04-a657-61a6294e675c | 6 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ExerciseSet other = (ExerciseSet) obj;
if (delegate == null) {
if (other.delegate != null)
return false;
} else if (!delegate.equals(oth... |
9627655e-d562-4c90-b33d-fa0624b35a14 | 4 | public int setEtat(String etat) {
if(etat.equalsIgnoreCase(ConfigGlobale.etatHS) || etat.equalsIgnoreCase(ConfigGlobale.etatOK) || etat.equalsIgnoreCase(ConfigGlobale.etatOFF) || etat.equalsIgnoreCase(ConfigGlobale.etatMaintenance)){
this.etat = etat.toLowerCase();
return 0;
}
... |
2c9b43ec-f630-4eee-a203-6caaade1f02b | 9 | @Override
public Object execute() throws OperationNotSupportedException {
Object result = null;
switch (operation) {
// twitter specific actions
case FAVORITE_AS:
break;
case REPLY_WITH:
break;
case RETWEET_AS:
break;
case SEND_DIRECT_MESSAGE:
break;
// general actions
case ASSIGN_... |
455e61b6-7e18-47a1-af5f-5d299f280701 | 5 | @Override
public ResourceDefinition create(DataNode node) throws ResourceException {
validator.validate(node);
String type = node.getAttribute("type");
String id = node.getAttribute("id");
ResourceDefinition definition = new BasicResourceDefinition(id, type);
for (Entry<String, String> entry : node.getA... |
2d9a9b4a-dd37-4736-97ad-cc94f2645b69 | 0 | public static void main(String[] args) {
test(10, 5);
System.out.println(result);
test(5, 10);
System.out.println(result);
test(5, 5);
System.out.println(result);
} |
6cd189a3-f7d3-4baf-83ce-d56bcf5ce105 | 9 | @Override
public boolean checkLegal(String prev_pos, String new_pos)
{
String convert_old_pos = CUtil.pos_Finder(prev_pos);
String convert_new_pos = CUtil.pos_Finder(new_pos);
int pfile = Integer.parseInt(convert_old_pos.substring(0,1));
int prank = Integer.parseInt(convert_old_pos.substring(1));
int nfile... |
37be4f8b-4569-4774-a866-59208bfe3524 | 4 | public byte[] decryptData(byte[] encryptedData){
try {
try {
this.cipher.init(Cipher.DECRYPT_MODE, this.key, this.ivspec);
} catch (InvalidAlgorithmParameterException e) {
LOGGER.log(Level.SEVERE, "Error building security cipher. [" + e.getMessage() + "]");
... |
8e8f5d71-25b8-452d-8c96-73392b508c0a | 4 | public int minimumTotal(ArrayList<ArrayList<Integer>> triangle) {
int n = triangle.size();
if (n == 0)
return 0;
int[] result = new int[n];
for (int i = 0; i < n; i++)
result[i] = triangle.get(n - 1).get(i);
for (int j = n - 2; j > -1; j--) {
... |
5e664324-a3f4-426b-969a-55318ea33f55 | 3 | @Override
public void actionPerformed(ActionEvent e) {
if (mode == eBattleFieldMode.Playable) {
game.sendAttackRequest(positionX, positionY);
} else if (mode == eBattleFieldMode.Design) {
game.getShipToPlace().setStartPoint(new Coordinates(positionX, posit... |
ced5e309-f52c-4e47-b512-32e98c9724c6 | 5 | private void validateCustomer(Customer customer) {
if (customer.getId() < 0) {
throw new WebApplicationException(Response
.status(Status.INTERNAL_SERVER_ERROR)
.entity("Invalid Customer id " + customer.getId()).build());
}
if (Strings.isNullOrEmpty(customer.getName())
|| customer.getName().trim()... |
1d15bba6-ee10-4ff7-8e6e-90dac8b3c828 | 0 | public String getMessage() {
return " You";
} |
090d8026-60df-4e95-acb4-5d4c229d9478 | 8 | public static String findNewLeader(Collection<BrokerReference> replicaBrokers, BrokerReference oldLeader, String topicId, int partitionId) throws Exception {
for (int i = 0; i < 3; i++) {
boolean goToSleep = false;
PartitionMetadata metadata = findLeader(replicaBrokers, replicaBrokers, topicId, partitionId);
... |
92558b8b-352e-47ea-97dc-7fe8dcdd4402 | 1 | public QuizDataObject convert() {
QuizDataObject quizDTO;
if (this.type == QuestType.DECISIONQUEST) {
String [] arr = getGoToList().toArray(new String[getGoToList().size()]);
quizDTO = new QuizDataObject(QuestName, arr,wrong,Integer.toString(questId));
return quizDTO;
} else {
quizDTO = new QuizDat... |
85b4d4fe-e248-4b55-bd62-6a9fbc1431bc | 2 | public static void ChooseJames ()
{
if (Game.characterChoice == 1)
{
Game.CharacterOne = "James";
Game.CharacterOneHP = CharacterStats.JamesHP;
Game.CharacterOneAttack = CharacterStats.JamesAttack;
Game.CharacterOneMana = CharacterStats.JamesMana;
Game.CharacterOneRegen = CharacterStats.J... |
04636754-2cd4-4467-99fb-ee7e4e752ff2 | 6 | @Override
public int getKillCount(int player_id) {
PreparedStatement pst = null;
ResultSet rs = null;
try {
pst = conn.prepareStatement("SELECT killcount FROM ffa_leaderboards WHERE player_id=?");
pst.setInt(1, player_id);
rs = pst.executeQuery();
while (rs.next()) {
return rs.getInt("killcount")... |
382c6282-c166-49a7-bfff-169fc8eb598d | 9 | public MyLibraryManager_Sort() {
sortIndex=new int [MyLibraryManager_Library.data.size()/8];
p = new JPanel(); //creates new panel with drop-down lists and buttons added
p.setLayout(new FlowLayout());
sortLabel.setFont(new Font("Century Gothic",Font.BOLD, 14));
OK.setFont(new Font("Century ... |
c39fee9b-b12d-40c6-8b10-126348e637f4 | 2 | public static void reset()
{
System.out.println("Game reset");
BattleShipAI.reset();
game.destroy();
startGame();
game.mySea.renderEditingShip = true;
game.editingPos = -1;
game.editNextShip();
readyToSwap = false;
swappingNow = false;
placingShips = true;
manualAdding = true;
editing... |
4cbc4576-dd0f-4db9-96a3-222d6c3e7c79 | 8 | @Override
public void keyPressed(KeyEvent e) {
if(e.getKeyCode()==45 && currentScale>0){
currentScale--;
scale.setScale(availableScales.get(currentScale));
}
if(e.getKeyCode()==521 && currentScale<availableScales.size()-1){
currentScale++;
scal... |
8c44a2dc-4715-43a5-b19e-17d63ba561dc | 1 | final Object peek() {
int size = stack.size();
return size == 0 ? null : stack.get(size - 1);
} |
77574777-2920-4126-9149-2b4dedbb8062 | 4 | public boolean validMovement(int myXCoor, int myYCoor, int targXCoor, int targYCoor, Board board){
double slope = Math.abs(super.getSlope(myXCoor,myYCoor,targXCoor,targYCoor));
if ((slope == 2.0 || slope == 0.5) && (Math.abs(myXCoor - targXCoor) == 1 || Math.abs(myYCoor - targYCoor) == 1))
return true;
else
... |
cb7955bd-6c14-464b-9e85-b15beb3a0936 | 7 | PacketType getPacketTypeFromChar(char c){
switch(c){
case 'L':
return PacketType.LOGIN;
case 'X':
return PacketType.LOG_OUT;
case 'R':
return PacketType.LOGIN_RESPONSE;
case 'D':
return PacketType.DATA_PAYLOAD;
case 'Y':
return PacketType.ACKNOWLEDGE;
case 'N':
return PacketT... |
e45ce2d0-ccc9-419c-a00e-963fde882948 | 5 | private synchronized void populateChildren(String path) {
ChildrenCallback cb = new ChildrenCallback() {
@Override
public void processResult(int rc, String path, Object ctx,
List<String> childrenNames) {
ZVNodeImpl parent = nodes.get(path);
... |
da60cb53-4bc5-4c75-8ebf-4b596c49359f | 5 | public static Matrix collate(Matrix... matrices) {
int columnCount = matrices[0].columnCount;
int rowCount = matrices[0].rowCount;
double[][] elements = new double[rowCount][columnCount * matrices.length];
int columnsFilled = 0;
for (int i = 0; i < matrices.length; i++) {
... |
92250539-535e-43e2-a779-2f5e57a0ae6a | 8 | public ConstructEditor createConstructEditor(String uri, Construct construct)
{
String className = config.getEditorClassName(uri);
if(className == null) {
return null;
}
Class editorClass;
Constructor constructor;
try {
editorClass = Class.forName(className);
constructor = editorClass.getDeclared... |
a7ca0e86-d3f6-4960-b709-2654ed2fef18 | 8 | public synchronized byte[] getOutGoingCommand(long frame, GameServerOutputThread gsot){
while(outComs.size() == 0 || register.get(gsot)){
try {
wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
byte[] coms = new byte[1*players + 8];
byte[] frameBytes = ByteBuffer.allocate(8).p... |
013c225f-5802-44e4-b094-b17fce710df6 | 5 | public static void initUI(JFrame frame) {
UIManager.LookAndFeelInfo[] installedLafs = UIManager
.getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo lafInfo : installedLafs) {
try {
Class<?> lnfClass = Class.forName(lafInfo.getClassName());
LookAndFeel laf = (LookAndFeel) (lnfClass.newInstance... |
60cc1643-3ea6-4bb4-bb84-040f2a6373ff | 4 | protected static Ptg calcHex2Dec( Ptg[] operands )
{
if( operands.length < 1 )
{
return new PtgErr( PtgErr.ERROR_NULL );
}
debugOperands( operands, "HEX2DEC" );
String hString = operands[0].getString().trim();
// 10 digits (40 bits) at most
if( hString.length() > 10 )
{
return new PtgErr( PtgErr.... |
36ee2264-41fa-457f-b878-e002bec8debd | 1 | public void testIsEqual_LocalDateTime() {
LocalDateTime test1 = new LocalDateTime(2005, 6, 2, 10, 20, 30, 40);
LocalDateTime test1a = new LocalDateTime(2005, 6, 2, 10, 20, 30, 40);
assertEquals(true, test1.isEqual(test1a));
assertEquals(true, test1a.isEqual(test1));
assertEquals(... |
93d6d479-1264-458c-8102-a6d078495595 | 2 | public int add(sols.Model.Section section) {
int generated_Sec_ID=-1;
StringBuffer sql = new StringBuffer();
sql.append("INSERT INTO Section");
sql.append("(`Section_ID`,");
sql.append("`Exam_ID`,");
sql.append("`Section_Name`,");
sql.append("`TimeLimit`)");
... |
1515f0fb-934e-4945-923e-b2dae64a50c9 | 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... |
165db4f8-cd4c-4b78-83fc-e86ec5d0c609 | 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... |
23b58f66-507d-4223-92cc-557eb3aa9244 | 6 | public Class<?> getColumnClass(int c) {
if (dataVector.isEmpty()) {
return Object.class;
}
if (c == DeckTable.getQuantityColumnNumber() || c == DeckTable.getLevelColumnNumber() || c == DeckTable.getSoulColumnNumber()
|| c == DeckTable.getCostColumnNumber()) {
r... |
d89e986d-2ffd-47fd-a279-5514dba80226 | 0 | protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
propertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue);
} |
d8b7cf2c-fda0-4060-a68b-732bbde951a9 | 8 | private void jButton0MouseMouseClicked(MouseEvent event) {
String sql = jTextField0.getText();
String seporator = (String) jComboBox0.getSelectedItem();
String csvName = jTextField1.getText();
String character = (String) jComboBox1.getSelectedItem();
if (sql == null || "".equals(sql)) {
jLabel0.setFo... |
6e7bfbce-0353-4fbc-9483-de60792767f2 | 9 | public boolean searchMatrix(int[][] matrix, int target) {
//find row
if (target < matrix[0][0]) {
return false;
}
int startRow = 0;
int endRow = matrix.length - 1;
while (startRow <= endRow) {
int midRow = (startRow + endRow) / 2;
if (... |
1b4319a7-8b65-4be8-b117-4f0f9c8eddbb | 9 | private static String[] getDefaultFontSearchPath()
{
String osName = null;
try {
osName = System.getProperty("os.name");
} catch (SecurityException e) {
// preserve null osName
}
if (osName == null) {
// Makes it a bit tricky to figure out... |
54141575-7045-483f-8b86-07d69f99c44b | 7 | public Object down(Event evt) {
Object retval=super.down(evt);
switch(evt.getType()) {
case Event.VIEW_CHANGE:
for(Address logical_addr: view.getMembersRaw()) {
PhysicalAddress physical_addr=(PhysicalAddress)down_prot.down(new Event(Event.GET_PHYSICAL_ADDR... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.