method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
783c234e-b96b-4769-9bfe-85ec8825c621 | 5 | private int divideGetPivotPos(int startIndex, int endIndex) {
int pivotPos = getOptimalPos(startIndex, endIndex);
int pivotValue = a[pivotPos];
swap(a, endIndex, pivotPos);
int firstGreaterPos = -1;
for(int i = startIndex; i < endIndex; i++) {
if(a[i] < pivotValue ) {... |
7803daa1-0024-4f55-8838-5c850e6431b5 | 9 | public void ReadMassage() {
try {
ReadSelector.selectNow();
Set readyKeys = ReadSelector.selectedKeys();
Iterator i = readyKeys.iterator();
... |
349602b8-f990-400d-95ef-c8c07233ded8 | 9 | public void automove() {
int nextX;
int nextY;
do {
nextY = this.posY;
nextX = this.posX;
int test = (int) (Math.random() * 4);
switch (test) {
case 0:
nextX++;
break;
case ... |
6d7bfc79-f01a-45b3-87bf-3c7f2722f35d | 8 | private static Pledgepayment setPledgepayment(ResultSet resultset) {
Pledgepayment pledgepayment = new Pledgepayment();
try {
pledgepayment.setActual_amount(resultset.getFloat("actual_amount"));
pledgepayment.setContribution_id(resultset.getInt("contribution_id"));
pl... |
389e3c5d-d1d4-412b-85b7-401288215417 | 4 | @Override
public synchronized void execute() throws IOException
{
try
{
/* Contact the bootstrap node */
this.error = true;
this.attempts = 0;
Message m = new ConnectMessage(this.localNode.getNode());
/* Send a connect message to the b... |
90f59f3f-54ca-4ef3-872d-727c4016ed13 | 7 | void scrollByUnits(JScrollBar scrollbar, int direction, int units) {
// This method is called from BasicScrollPaneUI to implement wheel
// scrolling, as well as from scrollByUnit().
int delta;
for (int i = 0; i < units; i++) {
if (direction > 0) {
delta = scrollbar.getUnitIncrement(direction);
... |
7f49707b-a9db-4424-8537-0e1fcccaa126 | 3 | @Override
public void invokeNext(Request request, Response response,
ValveContext valveContext) throws ValveException {
int subscript = stage;
stage = stage + 1;
// Invoke the requested Valve for the current request thread
if (subscript < valves.length) {
valves[subscript].invoke(this);
} else ... |
c2c6d892-2873-403d-b7c2-23acb8877911 | 7 | public static int discrete(double[] a) {
double EPSILON = 1E-14;
double sum = 0.0;
for (int i = 0; i < a.length; i++) {
if (a[i] < 0.0) throw new IllegalArgumentException("array entry " + i + " is negative: " + a[i]);
sum = sum + a[i];
}
if (sum > 1.0 + EP... |
56517254-f174-4f8d-950f-9fbf3cb2409c | 0 | @Override public String toString()
{
return "[com.cube.geojson.Circle type: " + type + " coordinates: " + coordinates + " radius: " + radius + "]";
} |
93eda266-3c14-4d04-b544-9523b1271cc9 | 7 | public void playerTurn(int turn) {
int c;
Duelist duelist = this.duelists[turn];
Duelist opponent = this.duelists[turn].opponent;
MonsterZone mz;
this.turn = turn;
for (c = 0; c < opponent.field.monsterzones.length; c++) {
if (opponent.field.monsterzones[c].card != null) {
MonsterCard mc = MonsterCar... |
005fbd28-66ab-4218-9d3d-d59cd7c49a5b | 7 | public static void sort(Stack sortingStack) {
if (sortingStack.top == null) return;
Stack newStack = new Stack();
newStack.push(sortingStack.pop());
stacks.add(newStack);
while (sortingStack.top != null) {
int d = sortingStack.pop();
boolean minStack = false;
for(Stack s : stacks) {
if (d < s.top... |
599e5530-b833-4817-9b68-dd8cb5e310c0 | 5 | public void save(){
if(this.getId() != null){
String q = "SELECT id, " +
"first_name," +
"middle_name," +
"last_name," +
"position " +
"FROM workers " +
"WHERE id = ? " +
... |
b12b5c60-81f7-4428-94ce-e955c3eafd35 | 2 | public static void main(String[] args) {
try {
throw new LoggingException();
} catch (LoggingException e) {
System.err.println("Caught " + e);
}
try {
throw new LoggingException();
} catch (LoggingException e) {
System.out.println("Caught " + e);
}
} |
45e0eedc-6796-42f2-9516-bc503e6ab757 | 5 | public FileSplitter() {
setTitle("File Splitter");
final JFileChooser fc = new JFileChooser();
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(0, 0, 0, 0));
setContentPane(contentPane);
contentP... |
445446e8-1cee-4e8b-bc25-7e4ac619a6ec | 8 | public Worker_Thread_Payloads(int timing_millis, Splinter_IMPLANT agent, int payload_index, String clipboard_injection_text, String addr_controller, int port_controller, File directoryToRendor)
{
try
{
if (timing_millis < 100) {
timing_millis = 100;
}
if (clipboard_injection_text == ... |
9db38d70-776e-42f1-beb7-2784074fb783 | 2 | public ArrayList<Result> getResultsFromEvent(String identifier)
{
//We iterate through the whole list, checking for the Event with that identifier
//If we don't find any events with that identifier, we throw an exception
for(Event e: events){
if(e.getIdentifier().equals(iden... |
d06eaf13-e0ee-413c-8d1e-4b52cf9da293 | 9 | public static int getMoveForImage(BufferedImage image, boolean ui)
throws VisionException {
// Load the OpenCV Library
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
// Load the connect four original image
originalBoardImage = bufferedImageToMat(image);
// Resize the image to a more manageable size
Imgp... |
d124375c-d34d-4a1c-8734-b23fd15cf5ae | 9 | public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
String JSONtext = "";
switch (command) {
case "chatmessage": //JTextField
try {
JSONtext = enc.encode(new Message(lg.chatgui.field.getText(), ""));
lg.chatgui.field.setText("");
} catch (JSONException e1) {
e1... |
5f3b86ec-d702-46a8-ac9d-395c7539feb2 | 7 | public static void piirra(Graphics g, Teema teema, Pelihistoria historia) {
List<String> siirrot = historia == null ? new ArrayList<String>() : historia.getSiirrot();
g.setFont(new Font("Ariel", Font.BOLD, 18));
g.setColor(teema.tummaTeksti);
int alku = 0;
if (siirrot.size() > 24... |
0c5e8ecb-a4e5-44d1-b562-4c3448b18ac4 | 1 | public void calculate() {
int counter = 1;
long result = 1;
System.out.println("n\tn!");
while (counter <= 20) {
result = counter * result;
System.out.printf("%d\t%d\n", counter, result);
counter++;
}
} |
51895d39-65d8-4576-ba01-d736a33502d6 | 4 | @Override
public boolean isVisible(Entity e) {
if(selectedTower == e) return true;
PointD p1 = transformPointBack(gui.tlCorner);
PointD p2 = transformPointBack(gui.brCorner);
double s = e.getSize() * e.sizeMultiplier / 2d;
return (e.loc.x - s/2d > p1.x - 1d) && (e.loc.x + s < p2.x + 1d) &&
(e.loc.y - s ... |
453faeb7-0fe2-4ace-bf55-0bc8fac0d430 | 3 | public boolean isPalindrome(int num) {
String fullNum = "" + num;
int numLen = fullNum.length();
if (!(numLen % 2 == 0)) { // if number length is odd, disregard middle digit (read same both ways)
fullNum = fullNum.substring(0, numLen / 2) + fullNum.substring((numLen / 2) + 1, numLen);
numLen = fullNum... |
49dfc0ea-1767-4f63-b11e-d5c5d33fdff5 | 4 | protected void newProfile(String text) {
boolean doit = true;
for(int i=profiles.size()-1; i>=0; i--) {
Profile p = profiles.get(i);
if(p.name.equals(text)){
doit = false;
}
}
if(doit && text.length()>2){
profiles.add(new Profile(text,"base"));
profileListMdl.addElement(text);
txtPro... |
bdb24fc9-75c0-4e00-ad3e-d71c7561726b | 6 | @EventHandler
public void ZombieJump(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.getZombieConfig().getDouble("Zombie.Jump.Dodge... |
fcca902e-4b57-4d2e-96ca-37ac70e519a5 | 6 | static public void adjustBeginLineColumn(int newLine, int newCol)
{
int start = tokenBegin;
int len;
if (bufpos >= tokenBegin)
{
len = bufpos - tokenBegin + inBuf + 1;
}
else
{
len = bufsize - tokenBegin + bufpos + 1 + inBuf;
}
int i = 0, j = 0, k = 0;
int nextCol... |
bb5576d3-162a-4c8d-8384-9c26b530963b | 4 | private void editSelected() {
if (table.getSelectedRowCount() > 10) {
if (JOptionPane.showConfirmDialog(frmDictionaryEditor, Localization.getInstance().get("messageConfirmEntryEdit")+ " " + table.getSelectedRowCount() +
" " + Localization.getInstance().get("dConfMult2"), Localization.getInstance().get("messag... |
a4cd89fe-94a6-4a8e-aec8-11987f4d03b9 | 5 | public void connect() throws ConnectionException, IOException {
if(pause != null) {
try {
setInputStream(new FileInputStream(pause));
}
catch(IOException e) {
throw new ConnectionException(e);
}
}
if (serverConnection == null || serverConnection.isClosed()) {
try {
serverConnection = ne... |
8fbeac54-669a-440a-98e8-5832f9c1d874 | 2 | private String[] getNodes(String clusterName) {
String s = conf.getProperty(CLUSTER_KEY + clusterName);
if (s != null) {
String[] n = s.split("\\s+");
if (n.length < 1) {
throw new IllegalArgumentException("No nodes in cluster " + clusterName);
}
... |
e293eca4-fd4a-4df1-a46e-264d4d03a347 | 8 | public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox)
{
if (this.averageGroundLevel < 0)
{
this.averageGroundLevel = this.getAverageGroundLevel(par1World, par3StructureBoundingBox);
if (this.averageGroundLevel < 0... |
49463935-e51f-4b17-91b2-28b59462469e | 8 | protected static int partition(Instances insts, int[] index, int attidx, int l, int r) {
double pivot = insts.instance(index[(l + r) / 2]).value(attidx);
int help;
while (l < r) {
while ((insts.instance(index[l]).value(attidx) < pivot) && (l < r)) {
l++;
}
while ((insts.insta... |
7023d2c2-7bbd-476f-9d59-18ffb4597cb1 | 9 | static String toJSON(Document document, String separator, boolean topLevel) {
if (separator == null) {
separator = "";
}
String json = separator + "{" + separator;
boolean first = true;
for (String key : document.keySet()) {
if (!first) {
j... |
20ace447-ae88-42f7-bd1e-b03d4a790644 | 6 | public void render(int xScroll, int yScroll, Screen screen) {
screen.setOffset(xScroll, yScroll);
int x0 = xScroll >> 4;
int x1 = (xScroll + screen.width + 16) >> 4;
int y0 = yScroll >> 4;
int y1 = (yScroll + screen.height + 16) >> 4;
for (int y = y0; y < y1; y++) {
for (int x = x0; x < x1; x++) {
ge... |
1bfa95a0-1acf-4ac0-a3c1-68aeb2a4b00c | 4 | private void btnCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCerrarActionPerformed
//codigo cerrar archivo
if (principal != null) {
if (!principal.guardado) {
int g = JOptionPane.showConfirmDialog(null, "¿Quieres guardar antes de cerrar?");
... |
8b9d0a69-ddd0-42dd-9003-af610c82628d | 4 | public void load()
{
//load all properties for the checkboxes
allInOneCheckBox.setSelected(stream.singleFileCB);
lengthRecordCheckBox.setSelected(stream.maxTimeCB);
maxSizeMBCheckBox.setSelected(stream.maxMBCB);
runIndexCheckBox.setSelected(stream.sequenzCB);
patternCheckBox.setSelected(stream.patternCB);
... |
450a24ee-6a4f-42a2-9210-04f286ff7710 | 7 | private int getBalancedPredciateEndLocation(String literalString, int locStart) throws ComponentMismatchException {
int bracketCount = 0;
int currLoc = locStart;
while (currLoc < literalString.length() && literalString.charAt(currLoc) != DflTheoryConst.PREDICATE_START) {
currLoc++;
}
if (literalString.cha... |
e3d7f36b-2cf1-438f-813d-4f6709c31624 | 0 | public void setDescription(String description) {
this.description = description;
} |
f7a2a4a8-4bce-4729-8985-fd24eed3701c | 8 | @Override
public void visitClass(ClassNode cn) {
for (CallGraph graph : CallGraphBuilder.GRAPHS.keySet()) {
CallGraph other = CallGraphBuilder.GRAPHS.get(graph);
if (graph.calls().size() > other.calls().size()) {// This means that "other" is the true dummy method.
for (CallExpr call : other.calls()) {
... |
bce1f857-bf85-4bbb-b6b7-638b3775a70b | 3 | private boolean isLineWin(int line){
if(model.getField().getCell(0,line)== Field.DEFAULT_VALUE) return false;
if(model.getField().getCell(0, line) == model.getField().getCell(1, line) &&
model.getField().getCell(0, line) == model.getField().getCell(2, line))
return true;
... |
1b5cac70-d805-4d93-9f58-6bc058323e67 | 6 | public int overwriteResult() {
if(cbAllFiles.isSelected() && overwriteFile){
return Controller.OVERWRITE_ALL_YES;
} else if(cbAllFiles.isSelected() && !overwriteFile){
return Controller.OVERWRITE_ALL_NO;
} else if(!cbAllFiles.isSelected() && overwriteFile){
return Controller.OVERWRIT... |
fd81048d-6a58-4318-bae7-0bdcaa2b3098 | 5 | public static int startsWithWeight(String s1, String s2) {
if ((s1 == null) || (s2 == null)) {
return 0;
}
char[] charArray1 = s1.toCharArray();
char[] charArray2 = s2.toCharArray();
int i = 0;
for (; (i < charArray1.length) && (i < charArray2.length); i++) {
if (charArray1[i] != charArray2[i]) {
... |
0d13ff3d-b6c0-4f26-adb0-9c6caf3fcad4 | 6 | public char reverseMap(short glyphID) {
// look at each segment
for (Iterator i = segments.keySet().iterator(); i.hasNext();) {
Segment s = (Segment) i.next();
// see if we have a map or a delta
if (s.hasMap) {
char[] map = (char[]) segmen... |
19e0dcba-9489-4253-8bf6-79708ed43d86 | 7 | private void buildUI() {
setTitle("Post Room Assembler");
setLayout(new BorderLayout());
JLabel header = new JLabel("", JLabel.CENTER);
JTable table = null;
// If the assembler encountered errors display them
if(assembler.hasErrors()) {
header... |
e1126d39-fab6-4aa9-b268-054615988e3e | 6 | public static int SEQLargerThanSearch(int[] array, int k, boolean print) {
if(array == null || array.length == 0) {
return -1;
}
for(int i=0;i<array.length;i++) {
if(array[i]>k) {
if(print) System.out.println("Result is " + array[i]);
return i;
}
}
if(print) System.out.println("No Result")... |
74c701d6-04ec-4d31-9b45-94b92071c271 | 5 | public static String find() {
String portName = "";
PyramidPort port;
Courier courier;
RS232Socket socket = new RS232Socket();
// Get all currently available ports
String[] availablePorts = PyramidPort.getPortList();
for (String p : availablePorts) {
... |
f5a5715d-ee6e-426f-9253-a71f5e034a18 | 1 | public IdentificadorVariavelCampoRegistro(String nome, int deslocamento,
Tipo tipo) throws SemanticError {
super(nome, deslocamento, tipo);
if(!Tipo.isPreDefinido(tipo))
throw new SemanticError("Campos de registro exigem um tipo pré-definido");
} |
3ca7fa1c-211d-4066-9ffc-52c479a9b9b0 | 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... |
2d9af0af-4c41-4e03-b5ca-5dc3f340f60f | 3 | public String getStrE(String edgeID, String attr){
increaseAccess();
Edge e = edgeMap.get(edgeID);
if (e != null){
Object val = e.getAttr(attr);
if(val != null && val instanceof String){
return (String)val;
}
}
return "";
} |
11a3dbf5-bb81-47bd-bb0a-6b8ed4f56f9a | 9 | protected void FillBuff() throws java.io.IOException
{
if (maxNextCharInd == available)
{
if (available == bufsize)
{
if (tokenBegin > 2048)
{
bufpos = maxNextCharInd = 0;
available = tokenBegin;
}
else if (tokenBegin < 0)
bufpos = maxN... |
ffb72556-1f2f-464c-b574-e00c33848d04 | 5 | public void loadWarpsOld() {
File file = getOldFile();
if (file.exists()) {
try {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file.getAbsolutePath()));
Object result = ois.readObject();
ois.close();
if (r... |
e78cee32-cbe4-464e-8b82-3e667e1dcfbd | 6 | public String execute()throws Exception{
con = getConnection();
try{
String sql = "select * from Author";
st = (Statement)con.createStatement();
ResultSet res = st.executeQuery(sql);
boolean flag = false;
String TeAuthorID = null;
while(res.next()){
if(Authorname.equals(res.getString("Name... |
cc5b923b-896a-40a7-b1a3-0a89711c9195 | 5 | public void createInfixEquationArray(String equation)
{
BaseOperClass token;
for(String s: equation.split(" "))
{
if (s.equals("+")) token = new AdditionOperator();
else if (s.equals("-")) token = new SubtractionOperator();
else if (s.equals("/")) token = new DivisionOperator();
else if (s.equals("*"... |
8f8f3679-ff55-44a9-9dc4-1a6630857562 | 0 | public static String getKeyName(int keyCode) {
return KeyEvent.getKeyText(keyCode);
} |
0c2e02ba-e877-41f1-8db2-e8a649588ed4 | 1 | @Override
public void flush() {
try {
printToFile();
} catch (IOException ex) {
System.out.println(ex);
}
} |
178fac22-4f59-4510-a112-0ced8b5da95c | 5 | public void write(String filename) throws FileNotFoundException,
IOException {
String temp;
BufferedWriter file = new BufferedWriter(new FileWriter(filename));
try {
file.write(String.valueOf(L.length) + "\r\n");
for (int i = 0; i < L.length; i++) {
temp = "";
for (int j = 0; j < L.length; j++... |
a6c72a36-66e8-4c0f-ae1c-c61890676157 | 3 | public void update() {
money.setText(String.format("$%,d", model.getBankAccount().getMoney()));
FuelTank tank = model.getRobot().getFuelTank();
if(tank.isInfinite()) {
fuelTankInfo.setText("Fuel Tank: Tier DANIEL, Fuel Level: INFINITE");
fuelTankBar.setValue(100);
reserveInfo.setText("Fuel tank reserves:... |
a245a98f-5b5e-4d1c-a45e-e95b41b5f900 | 4 | public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringBuilder out = new StringBuilder();
int nCases = Integer.parseInt(in.readLine().trim());
for (int nCase = 0; nCase < nCases; nCase++) {
int[] nk = readInts(in.readLine())... |
8e4fe9b4-84b8-4557-97ad-426446490aa4 | 0 | public static Serializable getLastObjectOpened() {
return lastObject;
} |
c4dcddc9-a13a-4771-82e9-0dd8ed18c623 | 3 | private void dribbleTowardOtherGoal(){
turnTowardBall();
if(distanceBall < 0.7){
if(canSeeOtherGoal){
if(distanceOtherGoal < 30) getPlayer().kick(100, directionOtherGoal);
else getPlayer().kick(40, directionOtherGoal);
}else getPlayer().turnNeck(90... |
e2321842-700d-4005-a261-9bd6a19bf956 | 6 | @Override
public boolean equals(Object other){
if (other == null) return false;
if (other == this) return true;
if (!(other instanceof Formula)) return false;
Formula otherFormula = (Formula)other;
boolean equals = otherFormula.name.equals(this.name) && otherFormula.property1.equals(this.property1);
if (... |
677bc491-7b26-4257-abc1-1140c2d5917d | 2 | static private Source getNextFreeSource() {
for (Source source : sources) {
if (!source.isPlaying()) // means playback has ended
return source;
}
return null;
} |
bd9ff51c-e985-42ba-920a-0448d67fede4 | 1 | public void testToStandardDays() {
Weeks test = Weeks.weeks(2);
Days expected = Days.days(14);
assertEquals(expected, test.toStandardDays());
try {
Weeks.MAX_VALUE.toStandardDays();
fail();
} catch (ArithmeticException ex) {
// expecte... |
ae700da7-cd00-46ba-8f9f-b1375123a4d3 | 7 | public static void addItem(Messagable ui, String name, String category, float dailyLateFee, float maxLateFee, int numberOfCopies){
boolean itemAdded = true;
if(Item.itemExists(name, category)){
itemAdded = false;
ui.sendMessage("ERROR: Item already exists");
}
if(numberOfCopies < 1){
itemAdded = false;... |
d5e82282-5e24-4044-a44a-b58126c47cad | 1 | public static boolean isOcean(int x, int y, int[][] sea)
{
return (isTile(x, y, sea) && sea[x][y] == Sea.OCEAN);
} |
06f151b4-75e2-4b73-884c-11e510b88cf3 | 5 | public void setValor(int x, int y, double valor) throws Exception{
if(this.sx <= x || this.sy <= y)
throw new Exception("FueraDeRango["+x+","+y+"]");
boolean reescrito = false;
for(int i=0; i<elementos.size(); i++)
if(elementos.elementAt(i).enIgualPosicion(x, y)){
elementos.elementAt(i).setValo... |
e97bd913-84f4-4fb3-b38b-19a3e2dd001d | 2 | public static String readId(String line) {
String id = line.split("\\s")[0]; // Remove everything after the first space character
if (id.endsWith("/1")) return id.substring(0, id.length() - 2);
if (id.endsWith("/2")) return id.substring(0, id.length() - 2);
return id;
} |
26a02580-549f-4257-bc74-04f2e832a5cb | 3 | public LibraryBean[] searchInNaturalMode(String query){
LinkedList<LibraryBean> list = new LinkedList<>();
try {
PreparedStatement statement = connection.prepareStatement(SEARCH_IN_NATURAL_MODE);
statement.setString(1, query);
ResultSet resultSet = statement.executeQuery();
LinkedList<Integer> listO... |
254d4c3f-8a93-4158-9157-b7cebd8d6426 | 1 | public int getTotalAdjacentBlank(State s,String color){
MyList color_list = s.ownees(color);
int total_adjacent = 0;
Iterator it = color_list.iterator();
while (it.hasNext()) {
Hexpos hp = (Hexpos) it.next();
total_adjacent += getAdjacentBlank(s,hp);
}
// System.out.println(total_adjacent);
return to... |
dc34dfe1-47cc-46f7-9fb6-e10560e8b83d | 1 | public String userName()
{
String userPrompt = "Enter username: ";
String[] result = new String[1];
write(userPrompt);
new ConsoleReader(this, result);
if (!history.isEmpty())
{
history.remove(history.size()-1);
historyIndex--;
}
return result[0];
} |
4de88126-18e7-444a-a770-cbe22198eaac | 3 | public VariableStack mapStackToLocal(VariableStack stack) {
VariableStack newStack = stack;
if (instr != null) {
int params = instr.getFreeOperandCount();
if (params > 0) {
this.stack = stack.peek(params);
newStack = stack.pop(params);
}
}
if (jump != null)
jump.stackMap = newStack;
return... |
e812268e-b332-4009-aa2e-be8cbc430e4f | 5 | private static boolean isIntegral(JsonPrimitive primitive) {
if (primitive.value instanceof Number) {
Number number = (Number) primitive.value;
return number instanceof BigInteger || number instanceof Long || number instanceof Integer
|| number instanceof Short || number instanceof Byte;
}... |
50a5b0b5-92cd-423f-b3d4-3b424e1a90cd | 6 | public static Stella_Class defineClassFromParseTree(Cons parsetree) {
if (Cons.badArgumentRangeP(parsetree, 2, Stella.NULL_INTEGER)) {
return (null);
}
if (!(Stella_Object.symbolP(parsetree.rest.value) &&
Stella_Object.consP(parsetree.rest.rest.value))) {
{ Object old$PrintreadablyP$000 ... |
e0840d0d-5642-4c74-95ea-0a87c366405e | 8 | public void fireBeforeWrite(State state, int data_addr, byte value) {
if (data_addr != base) {
Terminal.printRed("Unexpected interception by printer!");
}
Simulator sim = state.getSimulator();
AtmelInterpreter a = (AtmelInterpreter) sim.getInterpreter();
String ids... |
e0bf2c13-d2e2-4911-9da4-de0f4e2b3d56 | 3 | private Area recursiveGetAreaAt(Area root, int x, int y)
{
if (root.getBounds().contains(x, y))
{
for (int i = 0; i < root.getChildCount(); i++)
{
Area ret = recursiveGetAreaAt(root.getChildArea(i), x, y);
if (ret != null)
r... |
f0a4ad4b-b257-4aff-a1ce-abd64e4ed249 | 6 | public void refreshBonuses() {
bonuses = new int[18];
for (Item item : player.getEquipment().getItems().getItems()) {
if (item == null)
continue;
int[] bonuses = ItemBonuses.getItemBonuses(item.getId());
if (bonuses == null)
continue;
for (int id = 0; id < bonuses.length; id++) {
if (id == 1... |
7aac54c5-67fd-461b-8736-98a797d321c9 | 5 | public static int[] bubbleSort(int[] array, boolean ascendingOrder) {
if (array == null || array.length <= 1) {
return array;
}
for (int i = 1; i < array.length; i++) {
for (int j = 0; j < array.length - i; j++) {
if (Utils.compareOrder(array[j], array[j + 1], ascendingOrder) == false) {
Utils.swap... |
f06b0e84-d9cc-4c9f-ac2b-018ddf66e70b | 3 | public List < AState > getAllNeighbors(AState state)
{
List < AState > neighbors = new ArrayList < AState >();
for(Direction dir : Direction.values())
{
AState neighbor = this.getNeighbor(state, dir);
if(neighbor != null && !neighbor.isBlock())
neighbors.add(neighbor);
}
return neighbors;
} |
a412960e-beca-498d-a325-f22f2d5fdbb9 | 9 | protected void loadFields(com.sforce.ws.parser.XmlInputStream __in,
com.sforce.ws.bind.TypeMapper __typeMapper) throws java.io.IOException, com.sforce.ws.ConnectionException {
super.loadFields(__in, __typeMapper);
__in.peekTag();
if (__typeMapper.isElement(__in, Contact__typeInfo)) {
... |
67633918-ca8e-45b8-b042-9db8df4865da | 4 | public static void main(String[] args)
{
// reading the configuration file.
ConfigurationReader configuration = new ConfigurationReader(_propertiesFile);
if (!configuration.readConfigurationFile())
{
System.out.println("Failed in reading configuration file.");
return;
}
// creating client
RpcClie... |
1af04163-0e30-498a-b5ff-3378c8124ffe | 9 | public String parseReference() throws IOException {
int c = nextNonWhitespace();
if( c < 0 ) {
error("Expected '$' or '%' but found end of file");
}
if( c == 'n' ) {
// Might be a null
int[] pos = position(-1);
String check = "ull... |
304fd3a4-c722-4368-8291-a0b0a74fec02 | 4 | public boolean addColumn(String sheetName,String colName){
try{
fis = new FileInputStream(path);
workbook = new XSSFWorkbook(fis);
int index = workbook.getSheetIndex(sheetName);
if(index==-1)
return false;
XSSFCellStyle style = workbook.createCellStyle();
style.setFillForegroundColo... |
d4875ffb-303f-48a5-8be0-85853a69bbef | 8 | @Override
public void gameUpdate() {
if((!gameOver) && (hasStarted)) {
elapsedTimeInSeconds = (System.nanoTime() - currentTime) / 1000000000f;
//elapsedTimeInSeconds = 0.25f;
currentTime = System.nanoTime();
previousPositionOfBall.x = ballX;
previousPositionOfBall.y = ballY;
yEnergy += (YFORCE ... |
74124a3e-3b6c-4b7d-bbe1-c479d9cb8c88 | 7 | public Path getBestMove(int playerColor) {
pieces = new ArrayList<Piece>();
cellsAvailable = new ArrayList<CellPoint>();
cellPointsList = new TreeSet<CellPoint>();
this.playerColor = playerColor;
for (Piece p : player.getPieces()) {
if (p.getColor() == playerColor) {
pieces.add(p);
}
}// pieces n... |
3e576f90-96d1-4dfe-85d6-eec7431c18dc | 9 | private void execute(File f, int i) throws Exception {
BufferedReader br = new BufferedReader(new FileReader(f));
String line = null;
System.out.println("***********" + f.getName());
while ((line = br.readLine()) != null) {
String[] split = line.split(splitmark);
if (split.length < 2) continue;
totalWo... |
0402a948-1f81-4279-a1db-b328cb053e17 | 3 | public double[][][] getGridDydx2(){
double[][][] ret = new double[this.lPoints][this.mPoints][this.nPoints];
for(int i=0; i<this.lPoints; i++){
for(int j=0; j<this.mPoints; j++){
for(int k=0; k<this.nPoints; k++){
ret[this.x1indices[i]]... |
356bf710-6077-4df7-986f-437d2882b152 | 9 | private void setCapacity(int capacity) {
if (capacity < _n) {
capacity = _n;
}
double factor = (_factor < 0.01) ? 0.01 : (_factor > 0.99) ? 0.99 : _factor;
int nbit, nmax;
for (nbit = 1, nmax = 2; nmax * factor < capacity && nmax < NMAX; ++nbit, nmax *= 2) {
... |
9b450c3e-f3fa-4c38-a0f7-444f535a6c46 | 7 | @SuppressWarnings("unchecked")
public List<Class<CellularAutomaton<?>>> getClasses() {
List<Class<CellularAutomaton<?>>> classes = new ArrayList<Class<CellularAutomaton<?>>>();
for (int i = 0; i < classNames.size(); i++) {
try {
classes.add((Class<CellularAutomaton<?>>)super.loadClass(classNames.get(i)));
... |
e07e4da0-7cfe-40c4-97da-6106adb3dc5e | 7 | private void customer_action(String task, int custId,String type) {
try {
if(task.equals(task_1))
{
if(type.equals("initiate"))
{
System.out.println("Customer "+this.custId+" asks postal worker"+CurrentCustPw.get(this.custId)+" to buy stamps ");
System.out.println("Postal worker "+Curr... |
59bfd4cd-23d1-4cb1-b58b-8524a9ec9556 | 3 | public void set(String name, Recipe r){
Mash m = new Mash(r);
m.setName(name);
r.mash = m;
r.allowRecalcs = false;
for (int x=0;x<defaults.size();x++){
ArrayList<String> d = defaults.get(x);
if (d.contains(name)){
int size = Integer.parseInt(d.get(1).toString());
int j = 2;
while ... |
b43bcb92-9f5f-4fe5-ba20-6c3817c95b92 | 7 | public static void main(String[] args) {
System.out.print("Pensez a un personnage : Mlle Rose, ");
System.out.println("le Professeur Violet, le Colonel Moutarde,");
System.out.println("le Reverend Olive ou Mme Leblanc.\n");
System.out.print("Votre personnage a-t-il des moustaches ? ");... |
378ca6e3-7113-47b4-a9cf-8747b8097ca7 | 6 | @EventHandler
public void playerMove(PlayerMoveEvent event) {
NoEditTeam team = null;
for (CTFTeam t : Teams) {
if (t.inTeam( CTFPlugin.getTeamPlayer(event.getPlayer()) )) {
team = (NoEditTeam) t;
break;
}
}
if (team == null){
return;
}
Goal goal = team.getGoal();
if ... |
9d11df89-b030-4ba8-9c22-6ae3ed1f7dbf | 7 | public boolean isStreet(Rectangle r) {
// System.out.println(" " + bkgHeight + " " + bkgWidth + " " + r.y + " " + r.x + " " + r.height + " " +r.width);
this.r[index++] = r;
index %=4;
return(
r.y + r.height <= bkgHeight &&
r.x + r.width <= bkgWidth &&
r.x >=0 &&
r.y >= 00 &&
img.getRGB(r.x, r.y) =... |
ca4c5744-957b-45a1-9b10-75d32705e2e4 | 3 | @Override
public String strip(String s) throws Exception {
byte[] oldBytes = s.getBytes("utf-8");
byte[] newBytes = new byte[oldBytes.length];
int newlen = 0;
for (int j = 0; j < oldBytes.length; j++) {
byte ch = oldBytes[j];
if (!(ch >= 0 && ch < 32)) {
... |
8df49e80-09f1-4824-9706-ee774003c2f7 | 6 | public void parse(String fileName)
{
int currentIndex = 1;
int endIndex;
ArrayList<String> outputData = new ArrayList<String>();
String tempString;
String data = this.readFileAsString(fileName);
this.SetTeamNames(data);
this.SetThreeLetterNames(fileName);
currentIndex = data.indexOf("nbaGIPBPTeams")... |
a222ee16-696f-42ec-8241-a466c1460c62 | 2 | public double[] standardizedItemTotals(){
if(!this.dataPreprocessed)this.preprocessData();
if(!this.variancesCalculated)this.meansAndVariances();
return this.standardizedItemTotals;
} |
b032303f-7295-4ca4-b042-0224f291e407 | 2 | public static List<ParisModel> getAllTeamParisByUser(String userId, boolean finish) {
List<ParisModel> result = new ArrayList<ParisModel>();
List<ParisVictoryModel> parisVict = getAllVictoryParisByUser(userId,finish);
for(ParisVictoryModel paris : parisVict) {
result.add(paris);
}
List<ParisScoreModel> par... |
3d2e3f68-6823-434c-9927-4d88c9221daf | 4 | protected Style readStyle() throws Exception {
if ( mainReadHandle == null ) {
throw new Exception("Read Handle is null.");
}
Read in = mainReadHandle;
if ( !in.nextLine().isEmpty()) {
throw new Exception("Read Error.");
}
if ( !in.nextLine().equals("StyleObjectB")) {
throw new Exception("Read Erro... |
b4eb7f51-f49b-4dff-ae27-492f0f796c09 | 9 | @RequestMapping( method = RequestMethod.GET )
public final void handleGet(
@PathVariable String institution, // must be adr, see below
@RequestParam(required = true, value = "verb") String oaiVerb,
@RequestParam(required = false, value = "set") String set,
@RequestParam(required = false, value = "metadata... |
9ddbdad8-6bc3-4210-99be-bda04443203a | 5 | public boolean onCommand(CommandSender cs, Command cmnd, String alias, String[] args) {
// To allow nulling server commands out
if (args.length == 1 && args[0].equalsIgnoreCase("donothing")) {
return true;
}
if (cs.hasPermission("BetterAlias.reload") || cs.isOp()) {
... |
148f8bf4-e6e9-41ef-91fc-fd2c76dc56f8 | 4 | public static void main(String[] args) {
GradedActivity act = new GradedActivity();
act.setScore(83);
FinalExam exam = new FinalExam(10, 7);
PassFailActivity pf = new PassFailActivity();
pf.setScore(55);
GradedActivity[] activities = {act, exam, pf};
for (Graded... |
6563d64a-33ed-4b85-8bf9-8c221518f763 | 5 | public void update(double dt) {
if (paused) return;
if (gameOver) return;
map.update(dt, snakes);
for (Snake s : snakes) { s.update(dt, map, snakes); }
for (Snake s : snakes) { if (s.hasCrashed()) gameOver = true; }
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.