method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
a4f1eca2-abef-4b48-a82a-5d5b673aabfb | 7 | public static int search(int[] A, int target) {
int len = A.length;
int low = 0;
int high = len - 1;
while (low <= high) {
int mid = (high + low) / 2;
int val = A[mid];
if (val == target) {
return mid;
}
if (A[mid] >= A[low]) {
... |
885742ff-1905-46aa-964b-d96fe42f581c | 0 | public boolean isEspecial() {
return especial;
} |
6d57479b-a19f-48f8-9b2c-d91b1d5def8d | 0 | public ObjectProperty getObjectProperty(OntModel model) {
return model.createObjectProperty(getUri());
} |
6636cb24-0574-4712-9cb9-34411b10bae5 | 1 | private Server(User user, Socket s, String name){
this.user = user;
this.s = s;
try {
addUser(s, name);
oin = new ObjectInputStream(s.getInputStream());
} catch (Exception e){
e.printStackTrace();
}
setDaemon(true);
setPriorit... |
af15d04f-74fe-4511-8bd6-5f53f9e50c86 | 2 | public static void initLayout(){
/*Math and Layout below this line, pass at your own risk
----------------------------------------------------------*/
{
int rows[] = new int[34];
for(int x = 0; x < rows.length; x++){
rows[x] = (Height/rows.length)/2;
}
int columns[] = new int[60];
for(int x = 0... |
4457b011-3741-4c91-ad8e-bfff6f594272 | 2 | @Override
public int compareTo(Object arg0) {
if (!(arg0 instanceof TargetTransition))
throw new ClassCastException();
TargetTransition t0 = (TargetTransition) arg0;
int compareActions = this.action.compareTo(t0.action);
if (compareActions != 0)
return compareActions;
else
return this.invoke.compar... |
4dfbaa35-8db9-4310-b560-ae2c27cb483a | 5 | public CostReadings readReadings(JsonReader reader) throws IOException {
Number period = null;
Number cost = null;
Number energy = null;
String ts = null;
reader.beginObject();
while (reader.hasNext()) {
String key = reader.nextName();
if (key.equals("period")) {
pe... |
cb77ded8-a7ed-409a-9e60-ced6ae4a8629 | 8 | static void initialization() {
if (initialized == false) {
for (int i = 0; i <= sizeOfMemInt; i++) {
if ((i < rootSize) || ((i >= (rootSize + FATSize)) && i < sizeOfMemInt)) {
setMem(i, 0);
}
if (i >= rootSiz... |
ea26d8db-d790-49c4-90d6-547eee768028 | 5 | public int filterRGB(int fx, int fy, int argb) {
fx -= x;
fy -= y;
if( fx < 0 || fy < 0 || fx >= w || fy >= h)
return argb;
int d = data[fx + w*fy];
return (d < 0) // first bit set -> opaque
? d
: argb;
} |
2f9a3d72-684b-40da-82f5-6221bca1e932 | 5 | @Override
public int compareTo(TLValue that) {
if(this.isNumber() && that.isNumber()) {
if(this.equals(that)) {
return 0;
}
else {
return this.asDouble().compareTo(that.asDouble());
}
}
else if(this.isString() && that.isString()) {
return this.asString().compa... |
a652cd5c-9156-4a01-b5b5-d937c7cbd570 | 2 | public Hand getActiveHand() {
for (Hand hand : hands) {
if (hand.isActive()) {
return hand;
}
}
return null;
} |
222001be-f326-41c4-b91b-b24c57a0dde3 | 4 | public void addAgent(){
Random rand = new Random();
int x;
int y;
for(Integer i = 0;i < ((EnvironnementParticule)environment).nb_agent;i++){
//on les place dans un coin au hazard (attention boucle infini si + d'Agent que de case)
do{
x = rand.nextInt(environment.taille_envi);
y = rand.nextInt(enviro... |
c05fc825-b11b-4b06-85d4-b032d97c51a0 | 8 | public static void select(JoeTree tree, OutlineLayoutManager layout, int type) {
Node node = null;
Node youngestNode = null;
Node oldestNode = null;
switch(type) {
case UP:
youngestNode = tree.getYoungestInSelection();
node = youngestNode.prevSibling();
if (node == youngestNode) {return;}
... |
e4031842-3268-49e7-adde-448de8868f6b | 7 | public static void addTiles(Tile[][] tiles, int startX, int startY, String path, List<Tile> spawnPoints) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
InputStream is = classLoader.getResourceAsStream(path);
BufferedReader reader;
if(is == null) {
reader = new Buff... |
a3a34b3a-1aeb-48cc-8648-ab9173bd2241 | 7 | private static double[] discreteAverage (double[] values, PricingVector pricing,
double awareness, double sensitivity)
{
// Initialize the auxiliary variables.
double temp = 0;
double sum = 0;
double overDiff = 0, overDiffTemp = 0;
int start, end;
double newPrice;
int durationCheapest = 0;
// Find... |
531c1ec2-bff9-4aaf-aa74-66e7cfd02c69 | 2 | public List<CreditProgram> getActivePrograms() {
//Создаем результирующий список
List<CreditProgram> resultList = new ArrayList<CreditProgram>();
try {
//Создаем запрос к БД
Statement statement = getConnection().createStatement();
ResultSet result = statement.... |
a650731f-fae9-421e-b81f-5f60392d0ec7 | 6 | private void triangulate(int[] sides) {
boolean[] discard = new boolean[sides.length];
int index = 0;
for (int i = 0; i < sides.length - 2; i++) {
int[] tri = new int[3];
for (int j = 0; j < 3; j++) {
if (index < sides.length) {
if (!discard[index]) {
tri[j] = sides[index];
} else {
... |
47d14930-1e80-41dd-b3bc-1801f793f486 | 7 | public void readDirectory(File currentDir){
if(currentDir == null || currentDir.isHidden()){
return;
}
if(fileExtension == null){
fileExtension = "";
}
if (currentDir.isFile() && (currentDir.getName().endsWith(fileExtension))) {
readFile(currentDir);
}
if (currentDir.isDirectory()) {
File[... |
56209984-1d0b-4c50-8261-6ea0975bd5d8 | 9 | private void drawData() {
worker.setAntiAliasing(gdef.antiAliasing);
worker.clip(im.xorigin, im.yorigin - gdef.height - 1, gdef.width, gdef.height + 2);
double[] x = xtr(dproc.getTimestamps());
double[] lastY = null;
double[] bottomY = null;
for (Map.Entry<PlotElement, I... |
56906cbe-8965-46bf-85c4-b292c666f659 | 6 | public void getList(int rep) {
String tempQuery = "";
if(rep == 0) {
tempQuery = DEFAULT_QUERY;
}
else if(rep == 1) {
tempQuery = "";
}
Statement stmt = null;
this.connect();
conn = this.getConnection();
try {
... |
81850977-3b1a-4765-97aa-4531b9f66f3f | 3 | protected void setPieceDims()
{
int wmax = -1;
int hmax = -1;
for (int i = 0; i < body.length; i++)
{
if (body[i].x > wmax)
wmax = body[i].x;
if (body[i].y > hmax)
hmax = body[i].y;
}
width = wm... |
be52cf39-da37-49c9-a2e2-017135581ea6 | 6 | public boolean transferOwnership(String regionName, String newOwner, World world) {
// World world = Bukkit.getServer().getWorld("world");
ProtectedRegion target = _plugin.WORLDGUARD.getGlobalRegionManager().get(world).getRegion(regionName);
String currentOwner = getOwnerName(regionName, world);
boolean ret;
i... |
76c04228-b1b5-4e94-8c15-e4670383a750 | 5 | @Override
public UserVo getUser(String email, String password) {
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try{
con = dataSource.getConnection();
stmt = con.prepareStatement(
"select UNO, EMAIL, PWD, NAME, TEL"
+ " from SE_USERS"
+ " where EMAIL=? and PWD... |
20a82ae8-12a3-47e5-b291-2f7fb18c5a50 | 0 | public boolean isInitialized() {
return this.initialized;
} |
a6bc0e8e-5c97-4c46-bd3d-226d984cae12 | 3 | @Test
public void findsShortestPath3()
{
Tree<Vertex> vertices = new Tree<>(new VertexComparator());
Vertex v1 = new Vertex(0,0);
Vertex v2 = new Vertex(1,0);
Vertex v3 = new Vertex(1,1);
Vertex v4 = new Vertex(2,1);
Vertex v5 = new Vertex(2,2);
Vertex v6 ... |
909e7d84-446b-4748-90c9-e743f6209940 | 9 | private boolean jj_scan_token(int kind) {
if (jj_scanpos == jj_lastpos) {
jj_la--;
if (jj_scanpos.next == null) {
jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
} else {
jj_lastpos = jj_scanpos = jj_scanpos.next;
}
} else {
jj_scanpos = jj_... |
6a6fdf32-209e-4eda-b5a2-d7966e429a9e | 6 | @Override
public void paintComponent(Graphics g){ //de paintComponent die alle Blokken in de blokken-HashMap op de juiste plaats zal painten
super.paintComponent(g);
int breedte = Constanten.BLOKGROOTTE;
int hoogte = Constanten.BLOKGROOTTE;
for(Positie pos : blokken.keySet()){
... |
eaa65c83-c2b1-45a7-84cd-5605361ac9bc | 7 | protected Color parseRGBColor(String str) {
if (RGB_COLOR.matcher(str).find())
return parseRGBA(str);
if (RGBA_COLOR.matcher(str).find())
return parseRGBA(str);
if (str.startsWith("0x")) {
try {
return new Color(Integer.valueOf(str.substring(2), 16));
}
catch (NumberFormatException e) {
out... |
9a97be89-6cf7-4514-9b5f-72601e700802 | 0 | public void executionFinished() {
executionFinished = true;
} |
55e3adff-099d-47a4-84d5-04cf67ae903c | 5 | public String[] getImageLinks(String Make, String Model) {
String searchText = Make + " " + Model;
searchText = searchText.replaceAll(" ", "+");
String[] links = new String[1];
String key="AIzaSyDUmEpoEHSYB-pBKrM_slE2KmTyX_LJGwk";
String cx = "004334298273927197431:bennqbfbvec";
URL url;
try {
url = ne... |
440f8684-52a8-4f87-91d6-8d8f86e540c1 | 3 | public String getNewVariableWithLambdaProduction(Grammar grammar,
Set lambdaSet) {
String[] variables = grammar.getVariables();
for (int k = 0; k < variables.length; k++) {
if (!lambdaSet.contains(variables[k])
&& isVariableWithLambdaProduction(variables[k], grammar)) {
return variables[k];
}
}
... |
69d0bca6-9ce4-4aed-a435-fbb3a821965e | 4 | @Override
public Object getValueAt(int rowIndex, int columnIndex) {
switch(columnIndex){
case 0:
return list.get(rowIndex).getOutputSpEmployeeTargetPK().getSzYear();
case 1:
return list.get(rowIndex).getOutputSpEmployeeTargetPK().getSzMonth();
... |
e6f446f4-3eec-4045-bb9e-382e54180ba7 | 7 | public ArrayList<String> cbProjetos() throws SQLException {
ArrayList<String> Projeto = new ArrayList<>();
Connection conexao = null;
PreparedStatement comando = null;
ResultSet resultado = null;
try {
conexao = BancoDadosUtil.getConnection();
comando =... |
98434c9b-8441-4e41-a929-a0389bf4c3fc | 9 | @Override
public void build() {
if (eastLonBound <= westLonBound) {
throw new ExceptionInvalidParam("East bound <= West bound");
}
if (northLatBound <= southLatBound) {
throw new ExceptionInvalidParam("North bound <= South bound");
}
if (destWidth <= 0... |
d167441e-bd98-4def-b5f1-964380cadd19 | 6 | public void printOut(){
File file=new File(name);
PrintWriter myout;
try{
myout=new PrintWriter(new FileOutputStream(file));
myout.println("<mapfile bitmap=\""+mygraph.getImageName()+"\" scale-feet-per-pixel=\""+mygraph.getScale()+"\">");
for(int i=0;i<mygraph.getCurr();i++){
myout... |
181231f7-afe9-4dd0-8f72-c8a08aea948e | 3 | protected TreeNode<K, D> predecessor(TreeNode<K, D> node) {
if (!isNil(node.getLeftChild())) {
return getMaxNode(node.getLeftChild());
}
TreeNode<K, D> parent = node.getParent();
while (!isNil(parent) && node == parent.getLeftChild()) {
node = parent;
... |
c31759d0-1e29-40d4-a242-671d9302a0fc | 1 | public void addGraph(final Graph graph) {
if (graph == null) {
throw new IllegalArgumentException("Graph cannot be null");
}
graphs.add(graph);
} |
a2fd8883-b7a6-46c5-bc1a-503a13d60db8 | 9 | private BandCholesky decompose(AbstractBandMatrix A) {
if (n != A.numRows())
throw new IllegalArgumentException("n != A.numRows()");
if (upper && A.ku != kd)
throw new IllegalArgumentException("A.ku != kd");
if (!upper && A.kl != kd)
throw new IllegalArgumentE... |
38212f8c-10a3-4cf5-aa43-15af0ac917cc | 9 | public static double swap(TailContainer<Plane> sol, double temperature) {
for (Plane pi : sol.getRecords()) {
for (Plane pj : sol.getRecords()) {
if (pi != pj){
for (int i = 0; i < pi.getSchedule().size(); i++) {
for (int j = 1; j < pj.getSchedule().size(); j++) {
// Are these two swapable at... |
fba7a0c7-7349-43d0-8599-100c3be0be5f | 1 | public void update(double percent) {
if (percent > 1) {
dispose();
return;
}
message.setText(loadingMessage + Math.round(percent * 100) + " %");
Stage st = (Stage) scene.getWindow();
st.setTitle("Loading..." + Math.floor(percent * 100));
} |
b4e23d3b-e213-4b1b-80a2-5d19e151e62e | 0 | public ChatMessage(String authorId, String message) {
this.authorId = authorId;
this.message = message;
time = new Date();
} |
541bed02-deb3-40f8-af49-ef12d5e49547 | 7 | public void stopAllRunningModels() {
if (map.isEmpty())
return;
synchronized (map) {
for (ModelCanvas mc : map.values()) {
if (mc.getMdContainer() instanceof AtomContainer) {
if (((AtomContainer) mc.getMdContainer()).hasDNAScroller())
((AtomContainer) mc.getMdContainer()).stopDNAAnimation();
... |
5a23ea1e-a34a-4e21-9005-2ebc6a071847 | 2 | public double getDouble(String key) throws JSONException {
Object o = get(key);
try {
return o instanceof Number ?
((Number)o).doubleValue() :
Double.valueOf((String)o).doubleValue();
} catch (Exception e) {
throw new JSONException("JSONObj... |
7d728246-9337-40e8-b9b6-1325d0b027b9 | 8 | public void find(int mode, String searchby, Object keyfield, String keyword, int sort) {
String searchstring = searchby + "Search=" + convert(keyword) +
"&mode=" + MODES[mode] + "&type=lite" +
((sort == -1) ? "" : ("&sort=" + getSort(MODES[mode])[sort]));
// add the new keyword to the list
boolean cache... |
6aaa0239-8192-4c2f-b197-fdadc3d9bc8b | 8 | public void debugDisplay(String val) {
if (isVisible()) {
__debug = true;
parentRepaint();
getFather().hideToolTip(__tooltip);
if (val != null && val.length() > 0) {
if (val.length() > 10) {
val = val.substring(0, 7) + "...";
}
OVNode n = getOutNode();
if (n != null && n.visible()) {
... |
3f11ab0a-3d75-47a1-b124-691944904d53 | 4 | public boolean accept(File f) {
if (f.isDirectory())
return true;
String fname = f.getName();
int lastSlash = fname.lastIndexOf(".");
if (lastSlash < 0)
return false;
String extension = fname.substring(lastSlash + 1);
if (extension != null) {
if (extension.equalsIgnoreCase("json")) {
... |
6236a100-f5c8-421e-97e7-6c2617f3195d | 4 | @SuppressWarnings("unchecked")
private void tuesdayCheckActionPerformed(java.awt.event.ActionEvent evt) {
if(this.dayChecks[2].isSelected()) {
this.numSelected++;
if(this.firstSelection) {
stretch();
}
... |
eba8369c-4b8b-4d4f-b677-4df274d2f879 | 0 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
this.setVisible(false);
}//GEN-LAST:event_jButton1ActionPerformed |
33f75a2a-3042-4ffd-8b58-c7414b204b97 | 9 | private double[] refactorDistApart(double[] distApart, double threshold) {
for (int i = 0; i < window; i++) {
distApart[i] = threshold;
}
for (int i = distApart.length - window; i < distApart.length; i++) {
distApart[i] = threshold;
}
for (int i = 0; i <... |
3033915e-8997-4913-872a-59d5e7eb840c | 6 | public static void openUserProfile(User user)
{
if(user == null)
return;
final Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if(desktop != null && desktop.isSupported(Desktop.Action.BROWSE))
try
{
if(user.getUsername().equalsIgnoreCase(""))
return;
desktop.br... |
f01cb5bc-d70b-4d3e-9b08-c2ecbb3a25c1 | 8 | TupleNode parseTuple(SeekableStringReader sr)
{
//tuple = tuple_empty | tuple_one | tuple_more
//tuple_empty = '()' .
//tuple_one = '(' expr ',' <whitespace> ')' .
//tuple_more = '(' expr_list trailing_comma ')' .
// trailing_comma = '' | ',' .
sr.read(); // (
sr.skipWhitespace... |
1e103e48-f189-4691-8484-8395d7c48eac | 2 | public int compareTo(Piece other) {
if (this == other) {
return 0;
}
if (this.seen < other.seen) {
return -1;
} else {
return 1;
}
} |
c89e6ad1-39c0-430a-8441-801d6883bbb5 | 2 | @Override
public int uniqueWordsCount() {
int count = 0;
for(Map.Entry<String, Integer> entry : storage.entrySet()) {
if(entry.getValue() == 1) {
count ++;
}
}
return count;
} |
7979c066-4ccf-469a-af1d-425d5d23db78 | 6 | public void aimEnemy() {
int x = Math.abs(me.getX() - nearestEnemy.getX());
int y = Math.abs(me.getY() - nearestEnemy.getY());
double result = Math.toDegrees(Math.atan((double)y / (double)x));
if(nearestEnemy.getX() <= me.getX() && nearestEnemy.getY() <= me.getY()) {
result =... |
07182d68-6b74-460a-8c0c-4c7b4be2b97d | 1 | public void sendChat(String message) {
try {
byte[] sendBuffer = ("type:chat\nmsg:" + message + "\n").getBytes();
DatagramPacket sendPacket = new DatagramPacket(sendBuffer, sendBuffer.length, ip, port);
sock.send(sendPacket);
} catch (Exception e) {
}
} |
737754b6-1e2b-44d3-af01-9f5fb3fe3f16 | 5 | @Override
public ByteBuffer getData() {
int dataOffset = 0; // TODO
ByteBuffer buffer = ByteBuffer.allocate(100); // TODO
if (name != null) {
buffer.putInt(dataOffset | 0x80000000);
int stringoffset = dataOffset;
ByteBuffer strbuf = ByteBuffer.allocate(na... |
c5bd2da1-68e3-4695-bbf2-1b1db8fdf87b | 4 | public void draw(Vector2f camera, Vector2f pos, PlayerState ps){
float tempX = pos.getX();
float tempY = pos.getY();
tempX = TileUtil.toIsoX(pos.getX(), pos.getY()) + camera.getX() - 32;
tempY = TileUtil.toIsoY(pos.getX(), pos.getY()) + camera.getY() - 57;
switch (ps){
case WALK_DOWN:
case WALK_LEFT... |
c4d93cf3-8214-4d18-b6d8-1cbd25d03763 | 2 | public void doSearch() {
for (int i = 0; i < mThreadNum; i++) {
new Thread(new Runnable() {
@Override
public void run() {
while (true){
mListener.parseH5();
}
}
}).start();
... |
b96321bb-06bf-4c5d-b35c-6ae675e819a2 | 6 | @Override
public Map<TKey<?, ?>, List<Class<? extends Enum<?>>>> getRelationTargets(TKey<?, ?> key) {
return validRelations.get(key);
} |
91de4a6a-8c23-4ce5-84a0-7500fba91d23 | 3 | public int[] bubbleSort(int[] pZahlen) {
for (int i = 0; i < pZahlen.length; i++) {
for (int j = 0; j < pZahlen.length - 1; j++) {
if (pZahlen[j] > pZahlen[j + 1]) {
int lBuffer = pZahlen[j];
pZahlen[j] = pZahlen[j + 1];
pZa... |
e7d586a3-672c-40af-ba1b-24da2b11c463 | 0 | @Override
public void setLoggerName(String loggerName) {
this.loggerName = loggerName;
} |
bcc44c7c-44c7-4557-a19e-e93e35f534a0 | 9 | public void lineDetection() {
ArrayList<Integer> numbLigne = new ArrayList<Integer>();
int count = 0;
for(int i=0; i < tab.length; i++) {
count = 0;
for(int j=0; j < tab[0].length; j++) {
if(tab[i][j].getValue() != 0) {
count++;
}
if(count == 10) {
numbLigne.add(i);
}
}
}
i... |
1373ea58-5643-46c3-96e4-8966112017f8 | 4 | public static SelectItem[] getSelectItems(List<?> entities, boolean selectOne) {
int size = selectOne ? entities.size() + 1 : entities.size();
SelectItem[] items = new SelectItem[size];
int i = 0;
if (selectOne) {
items[0] = new SelectItem("", "---");
i++;
... |
20914b75-c744-495f-9ddb-c19e7f93e456 | 5 | public void searchLogradouro() {
facesContext = FacesContext.getCurrentInstance();
requestContext = RequestContext.getCurrentInstance();
if (selectBtnSearchBairro == true && this.bairro.getCidade() != null) {
List<Logradouro> listLogradouro;
try {
lograd... |
faf11f00-de3a-4911-b009-06b4e1b71036 | 2 | public int getAttackDamageBonus(Entity e) {
if (type == ToolType.axe) {
return (level + 1) * 2 + random.nextInt(4);
}
if (type == ToolType.sword) {
return (level + 1) * 3 + random.nextInt(2 + level * level * 2);
}
return 1;
} |
b2df9a51-e96c-471c-b7b2-68f5f967b5cf | 5 | public static Moves getFightingMovesRound1(BotState state, int armiesForFighting) {
Moves out = new Moves();
List<Region> southAmericaBorderRegions = new ArrayList<>();
List<Region> australiaBorderRegions = new ArrayList<>();
SuperRegion australia = state.getVisibleMap().getSuperRegion(6);
SuperRegion southAm... |
8d6c2b2f-ab43-4635-898c-837416aad626 | 4 | @Override
public String toString()
{
if(ouder1 != null && ouder2 != null)
return this.ouder1.toString() + " & " + this.ouder2.toString();
else if(ouder1 != null)
return this.ouder1.toString();
else if (ouder2 != null)
return this.ouder2.toStrin... |
9318ad9a-1363-4ffc-af11-5ba29981225d | 0 | public UndoQueueEvent(Document doc, int type) {
setDocument(doc);
setType(type);
} |
d2c0a7fb-c019-445f-8e05-4d6e37f5703b | 3 | public static void main(String[] args) throws InterruptedException {
ArrayList<Integer> list = new ArrayList<>();
ExecutorService executor = Executors.newCachedThreadPool();
Future<Integer> future;
for (int i = 1; i < 10; i++) {
future = executor.submit(new MyCallable(i));
... |
4368daec-2837-4fab-9bca-a900d4e3e360 | 8 | public static boolean checkDataIntegrity(int gameVersion, byte[] data, int offset, int expectedNewOffset)
{
offset = 0;
try
{
offset += BLANK_MAX_LENGTH;
offset += DEFAULT_ODM_MAX_LENGTH;
if ((GameVersion.MM6 == gameVersion) || (GameVersion.MM7 ==... |
f29144fa-685f-4d6a-8d04-4bf3d3cac556 | 9 | public static void main(String[] args) {
int total = 0;
for (int i : primeSieve(1000000)) {
if (i < 10) {
continue;
}
if (isPrime(i)) {
boolean flag = true;
for (int j = 1; j < Integer.toString(i).length(); j++) {
... |
22c4aeb2-1db7-4d2e-8200-113b2bc9e918 | 7 | public void executeQuery(String supplierName) {
CachedRowSet coffees = null;
CachedRowSet suppliers = null;
JoinRowSet jrs = null;
try {
coffees = new CachedRowSetImpl();
coffees.setCommand("SELECT * FROM COFFEES");
coffees.execute(connection);
... |
7953c9a4-d679-4a00-933e-2fe0a96e36fa | 3 | private void setDiceArray(FieldCircularList[] map) {
int index;
FieldCircularList[] diceArray;
for(int i = 0; i < map.length; i++) {
diceArray = new FieldCircularList[11];
for(int j = 0; j < diceArray.length; j++) {
index = i + 2 + j;
if(index >= map.length) {
index -= map.length;
}
d... |
1d52385c-9503-453f-ac0c-fb41f8446eaf | 9 | public String longestPalindrome(String s) {
// Start typing your Java solution below
// DO NOT write main() function
int maxi = 0;
int max = 0;
StringBuilder sb = new StringBuilder();
sb.append('\001');
for (int i = 0; i < s.length(); i++) {
sb.append(s.charAt(i));
sb.append('\001');
}
String ss... |
f26ce26e-d7e7-4b11-b219-7503eac95ce7 | 2 | public int getDeathYear() {
return (death == null || death.getDate() == null) ? 0 : death.getDate().getYear();
} |
c8059416-9ecb-427b-a6a1-9b914bb0781e | 9 | public void update(DeltaState deltaState) {
if (!this.getScene().getSystemPause() && this.getScene().getPlayState()) {
if (this.cantidadDeVidas <= 0) {
this.morir();
} else {
if (this.cantidadDeVidas < 7) {
intervaloDeAccion = 80;
}
this.getScene().bossMataBrosEnElCamino(this);
if (th... |
8dc5b6c0-963d-485a-aa48-d6a1a0b24442 | 1 | public static int gcd(int a, int b) {
if(b == 0) {
return a;
}
return gcd(b, a % b);
} |
b09387de-d2c1-44a5-8fe3-3e68ce6e89bd | 9 | public static double[][] computeDistance(Artist[] artists,DatabaseConnector db){
int na=artists.length;
double[][] dist=new double[na][na];
double[][] var=new double[na][na];
String stringArtists="";
int p=0;
HashMap<String,Integer> artistMap=new HashMap<String,Integer>();
for(Artist a:artists){
if(p>0... |
affb0764-5b75-4e08-84e6-acbf5d0410ec | 7 | public String build(List<Integer> list) {
for(Integer i : list) {
if (i > 0 && i <= 3) {
firstRow = buildRow(i, firstRow);
} else if (i > 3 && i <= 6) {
secondRow = buildRow(i-3, secondRow);
} else if (i > 6 && i <= 9) {
thirdR... |
f2d78f17-565f-471c-a74c-7fd747260f3b | 4 | public ShopElement[] getShopListInfo(){
ShopElement[] finalList = new ShopElement[shopListArr.length];
//Since a SAX XML parser reads a file from the beginning to end,
//we need to sort the current shopList array in ascending order to read the XML file
//from the beginning.
if(isSorted)... |
d8f64ee0-f707-4075-b1a7-1597d666747b | 8 | public Job createJob(Element eElement) {
Job job = new Job(eElement.getAttribute("name"),eElement.getAttribute("description"));
if(eElement.hasChildNodes()){
NodeList list = eElement.getChildNodes();
for(int i = 0; i < list.getLength(); i++){
Nod... |
48617601-f99f-4e72-ad0e-dec06ff73f7b | 5 | public UncheckedBinding outbound(UncheckedBinding outBinding) {
UncheckedBinding inBinding = outBinding;
if (outBinding == null)
return null;
if (outBinding.getObj() == null) {
inBinding = new Binding<Timestamp>(Timestamp.class, null);
}
if (Time.class == ... |
b5476de8-fdb9-4a66-9b77-863470727a79 | 8 | public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
this.inputCounter -= delta;
Input input = gc.getInput();
mouse.x = input.getMouseX(); mouse.y = input.getMouseY();
boolean click = input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON);
if (inputC... |
3e751c8a-7d28-449f-81be-5af753aa5419 | 2 | public void start() {
conversation.start();
while (true) {
Message msg = conversation.getMessage();
ui.addMessage(msg);
if (playSound()) {
GoogleVoice v = voices.get(msg.bot);
v.read(msg.msg);
}
... |
cbc0f5e6-cad4-4b94-9ba8-ec47382ae27a | 0 | public double getMean(){
return mean;
} |
d0a12870-8f38-4760-b764-be1111aa4d9a | 5 | @Override
public void print() throws AnimalException {
System.out.println("\tInformatii animal:");
if (this.getNumeAnimal() == null)
throw new AnimalException("Animal's name is invalid!");
if (this.getOrigine() == null)
throw new AnimalException("Country's name is invalid!");
if (numeRezervatie == nul... |
e0dc24ba-3df1-4446-a2e4-4246844f42ab | 5 | @Override
public void setMode(EditorMode mode) {
if (mode == EditorMode.DEBUG) {
interpreter_.setDebug(true);
} else {
interpreter_.setDebug(false);
}
this.mode_ = mode;
for (String s : settings_.keySet()) {
for (Setting stg : settings_.get(s)) {
stg.setMode(getMode());
}
}
if (mode_ != ... |
be68691d-038e-4111-940a-f4a08c8c64b7 | 7 | public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null || !(obj instanceof Person))
return false;
Person other = (Person)obj;
if(other.getId() != getId() ||
!Helper.compareObjects(this.getVorname(), other.getVorname()) ||
!Helper.compareObjects(this.getNachname(),... |
f93ff760-8890-4ac5-9f03-c480a18cc60a | 0 | public String concatenate(String one, String two){
return one + two;
} |
06a8f85d-16c1-4e1a-9d17-8f4cb610588d | 6 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Utilisateur other = (Utilisateur) obj;
if (nom == null) {
if (other.nom != null)
return false;
} else if (!nom.equals(other.nom)) {
r... |
4f8f377b-1ab5-4483-9135-ab041c7317b4 | 6 | public static void save(String filename, double[] input) {
// assumes 44,100 samples per second
// use 16-bit audio, mono, signed PCM, little Endian
AudioFormat format = new AudioFormat(SAMPLE_RATE, 16, 1, true, false);
byte[] data = new byte[2 * input.length];
for (int i = 0; i... |
36d80b70-d18c-47a5-a912-710f0fa4afdc | 8 | @Override
public Datagram onReceive(Datagram datagram) {
RemoteObjectReference remoteObjectReference;
RegistryMessage registryMessage;
if (datagram.type.equals(Datagram.DatagramType.DATAGRAM_BIND)) {
registryMessage = (RegistryMessage) datagram.body;
String name = (S... |
b4a724d0-1619-476d-9057-65b918d71b0a | 7 | private void constraint_31B() throws IOException {
for (int k = 1; k <= NUM_VARS; k++) {
for (int m = 1; m <= SQUARE_SIZE; m += 3) {
for (int n = 1; n <= SQUARE_SIZE; n += 3) {
int p = 0;
// place box row by row into a an array to create one... |
023b0a37-e431-4a35-8bd8-86744fada705 | 6 | public void ordenarListaRequerimientos(GrafoTabla Grafico){
ArrayList <Requerimiento> ListaAuxiliar = new ArrayList();
ArrayList <Double> ListaAuxiliarDouble = new ArrayList();
int nodo_aux = 0;
double distancia_ref;
double distancia;
... |
a8ff7971-097e-46cb-a685-8f95cf0b8348 | 4 | @Override
public Tile getTile(Tile source, Direction dir) {
int x = source.getX();
int y = source.getY();
switch(dir) {
case NORTH:
y--;
break;
case SOUTH:
y++;
break;
case EAST:
x++;
break;
case WEST:
x--;
break;
}
return tiles[x][y];
} |
f9b8d7df-e485-46a0-9e08-7bebe36916f8 | 8 | public static void assertEquals(String message, Object expected, Object actual)
{
if (!assertionsEnabled)
{
return;
}
// If one but not both of the objects are null, fail.
String failureMessagePostfix = ": Expected <"+expected+"> but had <"+actual+">.";
if ((expected == null && actual != null) || (expec... |
1718c7b9-89d9-4f3c-8d8e-b8ad0d8beff6 | 1 | public void setProperty(String key, Object value)
{
if (properties == null)
{
properties = new HashMap<String, Object>();
}
properties.put(key, value);
} |
cda3e09b-2418-4f72-8962-17aaf8a127c9 | 3 | @Override
public void delete(Key key)
{
int i = hash(key);
if (st[i].contains(key)) // Note: More efficient using than
// contains(key) as
// duplicate calculation of hash(key) not
// involved
N--;
st[i].delete(key);
if (M > INIT_CAPACITY && N <= 2 * M)
resize(M / 2);
} |
66276f08-2dd7-49ce-a691-0170950b4ef0 | 9 | public static NaturalSetCollection intersect(NaturalSetCollection a, NaturalSetCollection b) throws NaturalSetException{
NaturalSetCollection intersect = null;
if(b.domain.equals(a.domain)){
intersect = new NaturalSetCollection(b.domain);
ArrayList<NaturalSet> first = b.elements, second = a.elements;
in... |
fb19aab2-8271-4251-b8aa-6a746bf4a1a1 | 5 | public void body()
{
initializeResultsFile(); // create new files for statistics
createGridlet(NUM_GRIDLETS); // create gridlets
// send a reminder to itself at time init_time, with a message to
// submit Gridlets.
super.send(super.get_id(), GridSimTags.SCHEDULE_NO... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.