method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
5086bd59-7f8c-49b1-8697-f7c33c142677 | 4 | protected void updateLabeling(double slack) {
for (int w = 0; w < dim; w++) {
if (committedWorkers[w]) {
labelByWorker[w] += slack;
}
}
for (int j = 0; j < dim; j++) {
if (parentWorkerByCommittedJob[j] != -1) {
labelByJob[j] -= slack;
} else {
minSlackValueByJ... |
374a1896-4e70-4280-96ee-c16b090c300b | 7 | public URL getAlias()
{
if (__checkAliases && !_aliasChecked)
{
try
{
String abs=_file.getAbsolutePath();
String can=_file.getCanonicalPath();
if (abs.length()!=can.length() || !abs.equals(can))
... |
50934aa4-b862-4166-aee2-169547ed6969 | 8 | private static void createZip(File set) {
ZipOutputStream outputStream = null;
InputStream inputStream = null;
try {
ArrayList cards = new ArrayList();
for (final File card : set.listFiles()) {
cards.add(card);
}
File zipDir = new File(DeckFileHandler.getDatabaseFilePath() + "zips");
output... |
b2940a94-6e36-40e0-ae1e-dbc79a64a895 | 8 | @Override
public void mouseClicked(final MouseEvent e) {
for (Map.Entry<Button.TYPE, Button> entry : buttons.entrySet()) {
if (entry.getValue().contains(e.getPoint())) {
processMouseClick(entry.getKey());
}
}
if (discardPlayer != null) {
C... |
2f7998fa-b285-43ae-b0f9-8c666a8a75bd | 8 | public void generateSubSectorMeshForSector(GroupSector sector) {
clearMeshesOn(sector);
TriangleMesh mesh = new TriangleMesh("_mesh");
MeshNode meshDataNode = new MeshNode("_mesh", mesh);
sector.addChild(meshDataNode);
GeneralTriangle[] isfs;
boolean generated;
for (Direction d : Direction.values()) {
... |
458cf853-b463-4054-aa39-04e41949cb9a | 3 | public int linearRegLookback( int optInTimePeriod )
{
if( (int)optInTimePeriod == ( Integer.MIN_VALUE ) )
optInTimePeriod = 14;
else if( ((int)optInTimePeriod < 2) || ((int)optInTimePeriod > 100000) )
return -1;
return optInTimePeriod-1;
} |
badb5a60-d4d9-4041-a614-154567cf5a68 | 4 | private Boolean checkAndSyncSchema(Class<?> c, Connection connection) throws SQLException{
if(!alreadyChecked.contains(c)){
try {
makeCreateTable(c, connection);
} catch (SQLException e) {
if(e.getMessage().indexOf("already exists") != -1){
makeAlterTable(c, connection);
}else{
throw e;... |
95ebc856-7cd3-4d0e-81c9-6b797547cb02 | 0 | public static void Info(String s){ log.info("[AprilonIRC] " + s);} |
12cec578-0d31-47f2-8515-cb6953bb8b63 | 2 | @Override
public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
try {
ClienteDao_Mysql oClienteDAO = new ClienteDao_Mysql(Conexion.getConection());
ClienteBean oCliente = new ClienteBean();
Gson gson = new Gson();
... |
bbc99fc9-c61e-48eb-9c9d-d749e4ac456b | 5 | public void getCompleteBipartiteGraph(mxAnalysisGraph aGraph, int numVerticesGroup1, int numVerticesGroup2)
{
if (numVerticesGroup1 < 0 || numVerticesGroup2 < 0)
{
throw new IllegalArgumentException();
}
int numVertices = numVerticesGroup1 + numVerticesGroup2;
mxGraph graph = aGraph.getGraph();
Object ... |
cc896f98-1726-480f-8586-56ade9e0c500 | 3 | public void cargarEmpleados(){
try {
Connection conn = Conexion.GetConnection();
try {
st = conn.createStatement();
emp = st.executeQuery("SELECT * FROM Empleados");
} catch (SQLException e) {
JOptionPane.showMessag... |
81a70330-c810-4dee-b017-e274462d55a5 | 6 | @Override
public byte[] getBytes() {
byte[] b = Util.getBytes(n);
byte[] varInt;
if (n < 0xfd && n >= 0) {
varInt = new byte[] { b[7] };
} else if (n < 0xffff && n >= 0) {
varInt = new byte[] { (byte) 0xfd, b[6], b[7] };
} else if (n < 0xffff_ffffL && n >= 0) {
varInt = new byte[] { (byte) 0xfe, b[... |
1f272656-499d-4a92-934b-324236e82b69 | 6 | public void setEditValue(int n, EditInfo ei) {
if (n == 0 && ei.value > 0) {
triggerI = ei.value;
}
if (n == 1 && ei.value > 0) {
holdingI = ei.value;
}
if (n == 2 && ei.value > 0) {
cresistance = ei.value;
}
} |
4b80b6d5-ac9d-4b81-8f48-d3e85c7ec92b | 0 | @Test
public void delMinHeapIsEmptyAfterLastEntryCalled() {
h.insert(v);
h.delMin();
assertTrue(h.isEmpty());
} |
d94d8d18-6e79-4515-a30e-7c3961a7495c | 1 | public void WheelDown()
{
switch(Main.Screen)
{
case "inGame":
Main.inGameManager.WheelDown();
break;
}
} |
7801da7d-1ac2-4768-beb1-7d185bd475f7 | 8 | public static Binding getDirectBinding(Expression someExpression) {
if ((someExpression.bits & ASTNode.IgnoreNoEffectAssignCheck) != 0) {
return null;
}
if (someExpression instanceof SingleNameReference) {
return ((SingleNameReference)someExpression).binding;
} else if (someExpression instanceof FieldReference)... |
013f3c46-141b-43e3-ae05-917c1b555837 | 4 | public static CommandType getCommandType(String command){
if(command.equals(GET_JOB))
return CommandType.GET_JOB;
else if(command.equals(CHECKOUT_JOB))
return CommandType.CHECKOUT_JOB;
else if(command.equals(COMPLETE_JOB))
return CommandType.COMPLETE_JOB;
... |
1b93d866-3feb-4351-81e0-b4ea3ea631b4 | 0 | @Override
public void setSocialId(final Long socialId) {
this.socialId = socialId;
} |
0f1a6bb2-dea2-4a4e-b3ac-0cef3b11bbbf | 3 | public boolean handleEnter(String line) {
line = line.trim();
int delim = line.indexOf(' ');
final String baseCommand;
final String[] args;
if (delim < 0) {
baseCommand = line;
args = NO_ARGS;
} else {
baseCommand = line.substring(0, delim);
args = line.substring(delim + 1).split(" ", 2);
}
... |
391d24b9-5ade-4227-82e3-448d9e33934d | 6 | public boolean peutModifierCategorie(Utilisateur utilisateur) {
return (
utilisateur != null
&& (
utilisateur.getRole().getValeur() >= Role.Administrateur.getValeur()
|| (
utilisateur.getRole().getValeur() >= Role.Moderateur.getValeur()... |
de50ba4b-33b3-4f38-a951-fe1bd0327b9e | 0 | public Component getComponentBefore(Container container, Component component) {
return cycle(component, -1);
} |
b7a29dfb-300c-4160-86f3-32ef44271e5e | 6 | @Test
public void forEachToimii() {
Hakemisto<Integer, String> hakemisto = new Hakemisto<Integer, String> ();
hakemisto.put(7, "moikka");
hakemisto.put(4, "heippa");
hakemisto.put(65, "maara");
hakemisto.put(-8, "joku juttu");
for (Vektori<Integer,String> ve... |
d4efa840-dce7-4b28-8367-740ca56ec91c | 0 | public static void t(CanFight x) {
x.fight();
} |
00f34c70-b2e5-4feb-a882-11d8d72403ce | 1 | public Object clone()
{
try
{
return super.clone();
}
catch (CloneNotSupportedException ex)
{
throw new InternalError(this+": "+ex);
}
} |
8d1c411a-85a9-4bfd-8b21-a28f459c329e | 4 | private StringBuffer Get10kSearchPage(String urlStr)
{
/** the length of input stream */
int chByte = 0;
URL url = null;
/** HTTP connection */
HttpURLConnection httpConn = null;
InputStream in = null;
StringBuffer sb = new ... |
0df83444-2fa0-4070-ba03-bcb957774e3d | 4 | public static ArrayList<String> readDomains(String filename){
ArrayList<String> list = new ArrayList<>();
try {
BufferedReader reader = new BufferedReader(new FileReader(new File(filename)));
while (true) {
String mail = reader.readLine();
... |
4fef0d53-46e0-4add-bbfd-380fab4e4ebe | 8 | private void addCubeFace(IntPoint p1, IntPoint shift) {
IntPoint p2 = p1.add(shift);
int value1, value2, orientation;
if(shift.equals(IntPoint.UP) || shift.equals(IntPoint.DOWN)) {
orientation = CubeFace.Z_AXIS;
} else if(shift.equals(IntPoint.LEFT) || shift.equals(IntPoint.RIGHT)) {
orientation = Cube... |
b54f4a1e-d01e-49a6-8515-45c67f346c6e | 7 | public static int getExpRate(MapleCharacter noob){
if(noob.getGMSMode() > 0 && !noob.isJounin()){
return 0;
}
double expRate = Village.getExpRate(noob.getVillage());
if(Modes.getInstance(noob).hasKyubi()){
if(noob.getVillage() != 5) {
expRate *= 2;... |
a313a4ac-b170-4618-ac9b-7ecd94a89c0e | 2 | public static String addResourcePathToPackagePath(Class<?> clazz,
String resourceName) {
Assert.notNull(resourceName, "Resource name must not be null");
if (!resourceName.startsWith("/")) {
return classPackageAsResourcePath(clazz) + "/" + resourceName;
}
return classPackageAsResourcePath(clazz) + resource... |
62038e11-cc3b-462d-88b9-14c4cf3708fb | 5 | public static double logGamma(double x) {
double xcopy = x;
double fg = 0.0D;
double first = x + lgfGamma + 0.5;
double second = lgfCoeff[0];
if (x >= 0.0) {
first -= (x + 0.5) * Math.log(first);
for (int i = 1; i <= lgfN; i++)
second += lgfCoeff[i] / ++xcopy;
fg = Math.log(Math.sqrt(2.0 * Math.... |
58f89c7c-d058-43bd-8090-216d2a3963d6 | 4 | protected String getMethodHeader(ArrayList<JXScriptArgument<?>> arguments)
{
String methodHeader = "var obj = new Object();\n"
+ "obj.calc = function(";
if( arguments != null )
{
for( int i=0; i<arguments.size(); i++ )
{
methodHeader += arguments.get(i).getName();
if( i < (arguments.size()-1... |
5bf5f73a-758c-471c-8a84-66f29baff6c3 | 3 | private List<Header> getExpandedHeaders(final Request request) {
final List<Header> headers = request.getHeaders();
final List<Variable> contextVariables = workflow.getContext().getVariables();
for (final Header header : headers) {
final String newValue = VariableHelper.substituteVariables(header.getValue(),... |
ae25d0e0-0904-4da6-b272-57f6ba12c7a4 | 1 | final public CycVariable sentenceDenotingMetaVariable(boolean requireEOF) throws ParseException {
CycVariable val = null;
val = metaVariable(false);
eof(requireEOF);
{if (true) return val;}
throw new Error("Missing return statement in function");
} |
29e15e58-6cf6-4b79-addd-790c2e78b411 | 3 | public boolean equals(Object obj)
{
boolean isEqual = false;
if (obj != null && obj.getClass() == this.getClass()) {
TestRunInfo testRunInfo = (TestRunInfo) obj;
if (testRunInfo != null) {
isEqual = (this.toString().equals(testRunInfo.toString()));
}
}
r... |
45254711-247a-4eac-b90b-2a34881a755e | 3 | public GUI3() {
Dimension screenSize = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getSize();
try {
INGRESS_FONT = Font.createFont(Font.TRUETYPE_FONT, new FileInputStream("Coda.ttf"));
} catch(Exception e) {
INGRESS_FONT = new Font("Courier ... |
48862c3d-a4d7-4c7b-9547-7df30162f1ae | 9 | public static void main( String args[])
{
int opcao;
int vezes;
int intervalo =0;
do
{
opcao = interacao.lerInt("1. Random Int\n2.Random Float\n3.Random Double\n0.Sair");
if(opcao <0 || opcao > 3)
{
interacao.mensagem("Seu idiota! Escolha valor no intervalo!");
}
}while( opcao < 0 || opc... |
34865ee7-0ae4-474f-a490-ddcd148fd766 | 0 | public Integer getProblemId() {
return this.problemId;
} |
1d1a5ec2-1ddf-43d4-8811-8f712275ae59 | 0 | public String getTableName() {
return tableName;
} |
06d04185-3ec8-4bbf-81ed-2b04405fc2b0 | 0 | public SymbolTable()
{
parent = null;
table = new LinkedHashMap<String, Symbol>();
} |
59df5c53-9edc-41b5-b930-bf4900cb062c | 9 | public boolean isBoxInFrustum(double par1, double par3, double par5, double par7, double par9, double par11)
{
for (int var13 = 0; var13 < 6; ++var13)
{
if ((double)this.frustum[var13][0] * par1 + (double)this.frustum[var13][1] * par3 + (double)this.frustum[var13][2] * par5 + (double)thi... |
ab676bac-22d0-4cc9-a3ab-05d5d40bccf1 | 1 | public List<String> findItinerary(String[][] tickets) {
Map<String,PriorityQueue<String>> ticketMap=new HashMap<String, PriorityQueue<String>>();
for(String[] ticket : tickets){
// ticketMap.computeIfAbsent(ticket[0],k->new PriorityQueue<String>()).add(ticket[1]);
}
List<Strin... |
6298eb74-894a-4365-83b2-e7406b80eb4b | 8 | public void setDisAppearLine(List<Integer> fulledLines, TScoreManager scoreMng) {
//remove squares in the fulled line
int cnt = fulledLines.size();
for (TBlock blk: blks) {
List<TSquare> sqRemove = new ArrayList<TSquare>();
TSquare[] sqs = blk.getSquares();
for (TSquare sq: sqs) {
int x = (int)sq.get... |
ca0ea7fc-4eb9-434c-8e8f-d140b6045924 | 1 | public Account lookup (String id){
UUID searchAccountId = UUID.fromString(id);
Account searchAccount = null;
if(accounts.containsKey(searchAccountId))
searchAccount = accounts.get(searchAccountId);
return searchAccount;
} |
26c8f0ad-5cd0-4800-bcec-2b24695eb387 | 1 | public boolean isPrintMouseCoords() {
if(frame == null) buildGUI();
return printMouseCoords.isSelected();
} |
dc0e5af9-0191-46ab-a96c-c58dbecc85e1 | 7 | public void partialTreeAlignment(PriorityQueue<Tree<String>> sQ) {
Tree<String> ts = sQ.poll();
boolean flag = false;
PriorityQueue<Tree<String>> rQ = new PriorityQueue<Tree<String>>();
boolean i = false;// all unaligned items inserted
while (!sQ.isEmpty()) {
Tree<Str... |
107edadf-ec05-4855-b39d-e8f8ce519183 | 1 | public void paintComponent(Graphics g)
{
super.paintComponent(g);
int h = this.getHeight();
int w = this.getWidth();
g.setColor(background);
g.fillRect(0, 0, w, h);
if (this.image != null)
{
int wb = (w - this.image.getWidth()) / 2;
in... |
caaa098e-69de-42bf-95df-9c00b46b34a5 | 1 | private JPanel buildWhatsnewPane()
{
JPanel panel = new JPanel(new BorderLayout());
try {
JEditorPane editor = new JEditorPane( Main.class.getResource("help/whatsnew.html") );
editor.setEditable(false);
panel.setBorder(BorderFactory.createEmptyBorder(8, ... |
e1c97b2c-34a9-4dce-bf69-6a6dab77279c | 9 | public Node findIdNode(String id, String scopeName) {
String nodetype = "I";
for (Scope scope : (LexParser.symtab).scopestack.subList(0, (LexParser.symtab).scopestack.size())) {
if(scope.Scopetype.equalsIgnoreCase(scopeName)) {
Symbol sym = scope.symbolMap.get(id);
... |
d2727c28-2d90-4b34-8493-ec3b71987246 | 7 | public static String getDay(int i)
{
switch(i){
case 1: return "Sunday";
case 2: return "Monday";
case 3: return "Tuesday";
case 4: return "Wednesday";
case 5: return "Thursday";
case 6: return "Friday";
case 7: return "Saturday";
}
return "";
} |
134611f3-8e51-4494-91e4-30de14b8df80 | 8 | public void save()
{
//create a buffered writer stream
FileOutputStream fileOutputStream = null;
OutputStreamWriter outputStreamWriter = null;
BufferedWriter out = null;
try{
fileOutputStream = new FileOutputStream(filename);
outputStreamWriter =
new Out... |
1066ffbf-59dc-4442-9e2c-e86e20092cab | 7 | private void loadRiverCrossings(Path baseDir) throws IOException{
Path mapImagePath = getFilePath(MapFile.RIVERS, baseDir);
try(InputStream stream = new FileInputStream(mapImagePath.toString())) {
BufferedImage mapImage = ImageIO.read(stream);
int[] rgbValues = mapImage.getRGB(0... |
c5159065-6aa3-4c86-b58e-862f754c497b | 3 | private void setParsedResults(String[] prasedText) {
if (jcbSortOutput.isSelected()) {
Arrays.sort(prasedText);
}
DefaultListModel listModel = (DefaultListModel) jlOutputText.getModel();
cleanOutputs();
int parsedLinesCount = 0;
for (String line : prasedText) ... |
5318c9e2-0183-45be-be5e-acde6bc487c0 | 2 | public ArrayList viewBookingPayment() {
ArrayList temp = new ArrayList();
Query q = em.createQuery("SELECT t from BookingEntity t");
for (Object o : q.getResultList()) {
BookingEntity p = (BookingEntity) o;
if (p.getAccount().getId() == userId) {
temp.add... |
bb8813bd-e061-45f2-b596-ee13414f8803 | 3 | public static void main(String[] args)
{
long startTime = System.currentTimeMillis();
if(args.length == 0){
System.out.println("Please provide the location of the workload file!");
System.exit(-1);
}
try {
String fileName = args[0];
... |
b732309b-95c0-40c2-807b-ccacff9a8477 | 9 | private void readDatatypeArray(int type, Document document, String key) {
ValueList tempList = valueList.getNextList();
if (tempList == null) {
document.put(key,null);
return;
}
int len = tempList.length();
Object[] array = null;
if (type == Eleme... |
4131d264-114a-4b18-8017-cac64d961cd8 | 6 | @EventHandler
public void EnderDragonPoison(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.getEnderDragonConfig().getDouble("Ender... |
ce01cfb9-0a3c-4b92-b418-ade5f2b8b780 | 4 | public int uniquePaths(int m, int n) {
if (n == 1)
return 1;
if (m == 1)
return 1;
int[] arr = new int[n];
Arrays.fill(arr, 1);
for (int j = 1; j < m; j++) {
for (int i = 1; i < n; i++) {
arr[i] = arr[i - 1] + arr[i];
... |
7748e8a9-fc24-4d9d-a317-3b63d0d0ca50 | 9 | void dds() {
int ini_fevals = Math.max(5, (int) Math.round(0.005 * maxiter));
int ileft = maxiter - ini_fevals;
double fvalue = 0;
double Ftest;
for (int i = 0; i < ini_fevals; i++) {
// sample an initial solution candidate (uniform random sampling):
fo... |
caf0dae6-3294-4e9f-8dc9-db1b0150751b | 1 | public static void MakeFramesNotEnable(Boolean state)
{
for(int i =0;i<callFrameList.size();i++)
callFrameList.get(i).setEnabled(state);
} |
8b793a6b-c393-4444-8aaf-03b8cf659d44 | 3 | * @return the meeting with the requested ID, or null if it there is none.
* @throws IllegalArgumentException if there is a meeting with that ID happening in the past
*/
public FutureMeeting getFutureMeeting(int id) throws IllegalArgumentException
{
Meeting m = getMeeting(id);
if(m == null)
{
return (Futu... |
b9ed6181-b131-4d9d-9170-a7b49450ae73 | 0 | public void setOpenEncoding(String openEncoding) {
this.openEncoding = openEncoding;
} |
afa2491c-673b-4985-9cd7-bf06a4acadb8 | 1 | public static boolean getKey(int key)
{
return (key < keys.length) ? keys[key] : false;
} |
0fab8d38-6709-4de3-9401-347e31637176 | 6 | public void setDefaultCommandHistory() {
// Insert default tools into command history for convenience.
File file = new File(".");
File files[] = file.listFiles();
for (int i = 0; i < files.length; ++i) {
String name = files[i].getName();
if (name.endsWith(".java")... |
35731d3f-394b-4737-910b-7599af3d7d7b | 6 | public boolean mapword(String word1, String word2){
if(word1 == null || word2 == null || word1.length() != word2.length())
return false;
HashMap<Character, Character> map = new HashMap<Character, Character>();
for(int i=0 ; i<word1.length(); i++){
char c = word2.charAt(i);
if(map.containsKey(c)){
... |
c49259c1-d549-42a4-a99f-abc31d42500b | 7 | private int getPoints(GeneralPath path, float[] mypoints) {
int count = 0;
float x = 0;
float y = 0;
float startx = 0;
float starty = 0;
float[] coords = new float[6];
PathIterator pi = path.getPathIterator(new AffineTransform());
while (!pi.isDone()) {
... |
cdec698a-3b5b-4b75-94ca-72c58bf827fc | 6 | public boolean isCellEditable(int row, int col){
if (isEnabled && col == 1 && dataFormat != Format.BIN_FORMAT &&
(endEnabling == -1 || (row>= startEnabling && row <= endEnabling)))
return true;
else
return false;
} |
1041faf0-bb0d-4010-b242-adb4991f8834 | 3 | public void walkUp() {
face = 0;
if (!(y == 0) && !walkblockactive)
if (!Collision.check(new Position(x, y), face)) {
y -= walkspeed;
setWalkBlock(walkblocktick);
}
} |
25afed5a-356e-4c4e-b475-959105b67268 | 7 | private void writeFieldsToFile(HashMap <String,String> fields) {
// What is the write method going to do
// Well, it can read the old file
// Replace / Add valuues to it
// And then re-write it
// Let's save it as plain-text for now, maybe look at zipping it after
// Firstly, read the old values and re... |
6e8848a5-e8a0-4dc1-b976-9c5ca79ffe9a | 6 | private void autosave_game () {
Game game = freeColClient.getGame();
if (game == null) return;
// unconditional save per round (fix file "last-turn")
String autosave_text
= Messages.message("clientOptions.savegames.autosave.fileprefix");
String filename = autosave_te... |
4305907e-7505-49e6-a92c-3ab1378ab72f | 4 | private static void sendStatus(Status status, String date, boolean publicStatus){
try{
for (int i = 0; i < Friends.friendList.size(); i++){
Friends friend = Friends.friendList.get(i);
if(publicStatus){
Message.postStatus(Main.userName + "##"+ date + "##" + status.getContent(), InetAddress.getByName(fr... |
3c51aff4-c63e-48ac-96f7-9a8ae6ceb6a1 | 3 | public void fromByteArray(byte[] array) throws Exception {
int i = -1;
while (array[++i] != -1 )
namensfeld = new String(new byte[] { array[i] }, "UTF-8") + namensfeld;
String sZahl = "";
while (array[++i] != -1 )
sZahl = new String(new byte[] { array[i] }, "UTF-8") + sZahl;
zahl = Integer.p... |
2c32dabd-7c4f-40ee-9aab-1f4e0e82e8cc | 6 | public static void main(String[] args) {
// TODO Auto-generated method stub
try{
String currentPath = new java.io.File( "." ).getCanonicalPath();
if(Utility.DBG)
System.out.println("Current dir:"+currentPath);
BufferedReader br = Utility.openFileToRead(currentPath+"\\src\\Input\\Problem1");
String... |
25ccc503-0491-4c83-bc2f-349443cebbe9 | 0 | public static void main(String[] args) {
//Primitives
boolean aBoolean = true;
char aChar = 'x';
byte aByte = 0;
short aShort = 0;
int anInt = 0;
long aLong = 0L;
float aFloat = 0.0F;
double aDouble = 0.0D;
//Boxing
Boolean aBoolea... |
d01b9224-a088-4aa0-87ea-f801ddf4987b | 5 | public static String encode(String str) {
byte[] buffer = str.getBytes();
int a = 0, i = 0, size = buffer.length;
char[] ch = new char[((size + 2) / 3) * 4];
while (i < size) {
byte b01 = buffer[i++];
byte b12 = i < size ? buffer[i++] : 0;
byte b23 = i < size ? buffer[i++] : 0;
int mask = 0x3F;
c... |
cda7d148-8bfb-43d5-8708-3b63a736564c | 7 | public boolean hasPathSum(TreeNode root, int sum){
if(root == null) return false;
LinkedList<TreeNode> nodes = new LinkedList<TreeNode>();
LinkedList<Integer> sumValu = new LinkedList<Integer>();
nodes.add(root);
sumValu.add(root.val);
while(!nodes.isEmpty()){
TreeNode current... |
bbd6a6e7-1265-4d4c-b06d-9c4e8f5bad03 | 5 | public static void main (String agrs[])
{
try
{
droneControl = new CustomDroneControl();
}
catch(Exception e)
{
if(droneControl != null)
droneControl.Abort(e);
else
... |
9708a809-da72-41a7-8a9e-3a7c9a7dabad | 1 | public static byte[] compressData(String zipEntryName, byte[] data) throws IOException {
if (Utils.isCompressedPath(zipEntryName)) {
throw new IllegalArgumentException("Zip entry name must have an uncompressed file extention");
}
ByteArrayInputStream inputStream = new ByteAr... |
699476b0-073f-4912-8653-71700e802712 | 1 | @EventHandler
public void onJoin(PlayerJoinEvent event) {
Player p = event.getPlayer();
if (FileUtil.checkPlayerDat(p)) {
event.setJoinMessage("NEW PLAYER!");
}
PlayerUtil pu = new PlayerUtil(p);
pu.updateName();
} |
d0e084a7-7bb8-4fb0-8d28-3084ae4a7bfa | 3 | protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) {
Polygon shape = new Polygon();
shape.addPoint(x - (h / 4), y + h);
shape.addPoint(x + (h / 4), y);
shape.addPoint(x + w - (h / 4), y);
if (isSelected ... |
c26b3a95-4036-4c49-bc91-b3b394e1ae65 | 5 | public void decrementNutrientLevels(boolean slow) {
for (Nutrient nutrient : nutrientLevels.keySet()) {
int level = nutrientLevels.get(nutrient);
if (level > (double)Config.maxNutrientLevel / 2.0 && slow)
return;
else if (level <= (double)Config.maxNutrientLevel / 2.0 && !slow)
return;
add... |
abc3e606-a4a5-4ac1-86c9-2605207c9147 | 8 | public void processRoute(ArrayList<String> rout, String fileName, boolean draw,
boolean writeToFile,
Filter filter) throws IOException {
ArrayList<Point> prout = new ArrayList<Point>();
double sumKm = 0;
for (int i = 1;i < rout.size();i++) {
double y = Math.abs(points.get(rout.get(i)).lon -
... |
96e7e597-fc15-4cec-bf00-c8b503d112b8 | 7 | private void optimize(int i) {
// look to see if there is overlap like this:
// t: <---i>
// t: <----->
if (i == size - 1) {
return;
}
int j = i + 1;
while (j < size && ranges[j] <= ranges[i]) {
j += 1;
}
if (j == size) {
size = i + 1;
} else {
int d = j - i - 1;
if (d % 2 == 0) ... |
761588fe-b24c-4e9f-a7a5-6ae9f32ef890 | 8 | public void formatStringTwo(char[] str, int length) {
boolean isWord = false;
int wordCount = 0;
for (int i = 0; i < length; i++) {
if (str[i] != ' ' && isWord == false) {
isWord = true;
if (wordCount > 0) {
System.out.print(' ');
}
wordCount++;
System.out.print(str[i]);
} else if (... |
96ff367c-7409-4ec9-b3bc-eee954e02c27 | 6 | @Override
public void action() {
RConsole.println("Ball Has been detected");
// TODO Auto-generated method stub
int increased = 0;
Color colorSensed = Sputnik.colorSensor.getColor();
int blue = colorSensed.getBlue();
int red = colorSensed.getRed();
while (blue > 80 || red > 80) {
PathFollowing.ball = ... |
661663e8-16e4-416e-ac6b-00aed048dbfb | 5 | public static ArrayList<Song> download(long time, String userName, ArrayList<Song> songs)
{
ArrayList<Song> allSongs=songs;
ArrayList<String> dates= new ArrayList<String>();
ArrayList<String> names= new ArrayList<String>();
ArrayList<String> artists = new ArrayList<String>();
Elements dateList;
Elements na... |
868b4aef-bc3a-4bdd-b3c0-31252a9f7a65 | 3 | @Override
public boolean delete(String question) {
// Man skal have valgt et spil for at kunne tilføje et spørgsmål
if (currentgame == null)
{
return false;
}
for (int i = 0; i < currentgame.getQuestions().size(); i++) {
if (question.... |
64d2b4fe-b780-4eed-9b3e-1b777185c7c4 | 1 | public static void main(String[] args) throws InterruptedException {
//creating Random numbers
Random random = new Random();
for (int i = 0; i < 10; i++) {
System.out.println("Integer random is: " + random.nextInt(10));
}
//semaphore , number of permits
Semaph... |
5cc9e327-7b91-4315-8efd-87d23acc2f05 | 3 | private Link generateRandomizedGameLink(EntityManager em, Player player) {
Link outputLink = new Link("", "");
ArrayList<Long> friendIDs = player.getFriendList();
// You need at least 5 friends to play and generate a valid link
if (friendIDs.size() <= 4) {
outputLink.setHref("index.html");
outputLink
... |
beb5c160-e6fc-4d56-b983-f0fcec92ce81 | 9 | @Override
public void detectRelationships(Obituary obit) throws Exception {
List<List<Term>> sentences = extractor.tagEntities(obit);
for (List<Term> sentence : sentences) {
sentence = EntityUtils.combineEntities(sentence);
chunker.addBIOChunks(sentence);
List<String> lines = new ArrayList<String>();
L... |
ea3c4f44-ea37-481a-b1de-dad213eb3e41 | 5 | public static void main(String[] args) throws IOException
{
BufferedInputStream bis = new BufferedInputStream(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = readInt(bis);
int r = 0;
TreeSet<Integer> a = new TreeSet<>();
for (int i = 0 ; i < n ; i++... |
1bea5f6b-60d4-4d72-95f4-daeefa545c3c | 0 | protected boolean isFinished() {
return false;
} |
a2f24d17-f7ca-4d20-82fe-cb9d6913b8e0 | 7 | public String getState()
{
if(type == 0 && hasFood)
{
return "<state>"+x+" "+y+" food hasFood</state>";
}
if(type == 2 && !doorOpen)
{
return "<state>"+x+" "+y+" door doorClosed</state>";
}
if((type == 0 || type == 2) && ant != null)
{
return "<state>"+x+" "+y+" antId "+ant.getId()+"</st... |
eb6a2480-0fa3-4cf4-882c-60eabe2e3d3f | 8 | static final public void NonNewArrayExpr() throws ParseException {
if (jj_2_7(3)) {
Literal();
NonNewArrayExpr2();
} else if (jj_2_8(3)) {
jj_consume_token(THIS);
NonNewArrayExpr2();
} else if (jj_2_9(3)) {
jj_consume_token(LP);
Expression();
jj_consume_token(RP);
... |
4c2bf971-bbdd-4635-addc-e1c688fe2835 | 7 | private void draw()
{
Plot2DPanel plot = new Plot2DPanel();
Color[] couleurs = new Color[]{Color.red,Color.blue,Color.ORANGE,Color.green,Color.yellow};
plot.removePlotToolBar();
plot.addLegend("SOUTH");
plot.ge... |
1115c181-308b-44dc-bd15-fa0551387b34 | 7 | protected void loadCatalystActivity() {
String name = "CatalystActivity";
String fileName = dirName + name + ".txt";
if (verbose) Timer.showStdErr("Loading " + name + " from '" + fileName + "'");
int i = 1;
for (String line : Gpr.readFile(fileName).split("\n")) {
// Parse line
String rec[] = line.split... |
00fa2d17-3a7f-42fd-ae53-fea57f8f621d | 7 | public boolean sendMessageToServer(String message) {
InetAddress serverAddr;
try {
serverAddr = InetAddress.getByName(getStrServerAddress());
Socket sendSocket = new Socket();
sendSocket.connect(new InetSocketAddress(serverAddr, getIntServerPort()), TIMEOUT);
ObjectOutputStream oos = new ObjectOutputStr... |
19848d29-eca3-4dcf-b743-d7fb907ab89f | 1 | public List<Double> getVarianceList() {
List<Double> result= new ArrayList<Double>();
double[] values= this.getVarianceArray();
for (int i= 0; i< values.length; ++i) {
result.add(Double.valueOf(values[i]));
}
return result;
} |
fd365f13-84b2-4545-94e5-f4f8be389d26 | 0 | public void setId(long id) {
this.id = id;
} |
6b83db51-8e8f-4a0f-b7b4-3806c77e37b3 | 8 | public void tick() {
Street end1 = streets.get(streets.size()-1);
for(Vehicle vdel:end1.getVehicles()) {
end1.leaveStreet(vdel);
vehicles.remove(vdel);
System.out.println("VEhicle removed: " + vdel);
}
for(Intersection i: intersections) {
... |
d5030ec3-3645-4aa5-be70-9556432b5ebf | 4 | public Alignment getAlignmentScore() {
int maxScore = Integer.MIN_VALUE;
int xMax = 0;
int yMax = 0;
for (int i = 0; i < matrixA.length; i++) {
if (matrixA[i][matrixA[i].length - 1] > maxScore) {
maxScore = matrixA[i][matrixA[i].length - 1];
xMax = i;
yMax = matrixA[i].length-1;
}
}
for (i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.