method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
825551c7-a645-4914-af7a-257fd04af56f | 5 | public CheckResultMessage checkDayofMonth10() {
int r1 = get(13, 5);
int c1 = get(14, 5);
date();
if (checkVersion(file).equals("2003")) {
try {
in = new FileInputStream(file);
hWorkbook = new HSSFWorkbook(in);
if (!(getValueString(r1 + maxDay, c1 - 1, 3).equals(maxDay
+ "日"))) {
retur... |
bdf7235c-2b08-4e03-a692-a8f660097520 | 3 | @Test
public void testWhacks() {
int minWhack = insetMap.getMinWhack();
int maxWhack = insetMap.getMaxWhack();
int numWhacks = insetMap.countWhacks();
Assert.assertEquals(maxWhack - minWhack + 1, numWhacks,
"Expected " + numWhacks + " whacks.");
in... |
c30ecdc8-f35d-43b4-a4cf-194925e29e7c | 3 | private static StructuredBlock getPredecessor(StructuredBlock stmt) {
if (stmt.outer instanceof SequentialBlock) {
SequentialBlock seq = (SequentialBlock) stmt.outer;
if (seq.subBlocks[1] == stmt)
return seq.subBlocks[0];
else if (seq.outer instanceof SequentialBlock)
return seq.outer.getSubBlocks()[... |
25c3ab59-9ca9-48a8-ac64-92099e2e7046 | 5 | @Override
public void updateWith(InputProxy input) {
if (input.isTouched()) {
// If the input is touched, we were previously not touching, and
// the touch is within the button then press the button.
if (hasReleasedTouch && checkInput(input.getX(), input.getY()))
press();
// Because the input is touc... |
ddc759b9-6da6-484c-bb64-5e8f46bcbc27 | 7 | private static StringBuffer buildNetworkInterfaceDescriptor() {
Enumeration e1;
try {
e1 = NetworkInterface.getNetworkInterfaces();
} catch (Throwable t) {
// not available
return null;
}
StringBuffer b = new StringBuffer();
while (e1.hasMoreElements()) {
NetworkInterface ni = (NetworkInterface)... |
db81f77e-5c3f-4e42-94e3-e12e4bcb86bd | 9 | public static String readHeaderFromClient(InputStream clientInpStream)
throws IOException, IllegalRequestException {
StringBuffer header = new StringBuffer(500);
int inp = 0;
int dfaState = 0;
int FINAL_STATE = 4; // a DFA being used with 4 states
while (dfaState != FINAL_STATE && (inp = clientInpStream.r... |
0a977291-606f-4e78-8a27-5e070675a549 | 7 | @Override
public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
String data;
try {
ArrayList<FilterBean> alFilter = new ArrayList<>();
if (request.getParameter("filter") != null) {
if (request.getParameter("filterop... |
a871e017-d120-4737-b7b9-c07533a5107c | 3 | private E createInstance() {
E instance = null;
try {
instance = clazz.newInstance();
for (String propertyName : parameterMap.keySet()) {
Method m = findMethodFor(propertyName, clazz);
if (m != null) {
m.invoke(instance, parameterMap.get(propertyName));
}
}
} catch (Exception e) {
e.... |
f3167044-0bb1-43ee-81d3-e417f101625b | 2 | static boolean testPrime(int n){
boolean isPrime=true;
int limit;
limit=(int) (Math.sqrt(n)+1);
for(int count=2;count<limit;count++){
if(n%count==0){
isPrime=false;
break;
}
}
return isPrime;
} |
9c042d0a-fd90-40c4-9411-e9e1dcd374f3 | 7 | public void handleQuery(DNSPacket aPacket, InetAddress aAddress, int aiPort) {
resolveConflicts(aPacket);
Responder responder = new Responder(_MahaloSocket, _HostInfo, _LocalServices, aPacket, aAddress, aiPort);
// If I can answer every question in this query alone, respond immediately
boolean bonly... |
e14f5b9a-327f-43ef-a7b5-af8e9c5f0e5e | 5 | public static InfixOperation getInfixOperation(String type, Expression L, Expression R){
String noSpace = type.replaceAll("\\s+","");
String s = noSpace.toLowerCase();
if( "+".equals(s) ){
return new Sum( L , R);
} else if ( "-".equals(s)) {
return new Difference( L , R);
}else if ( "*".equals(s)) {
... |
43e294cf-8715-460d-b1cc-de4c42cfc9d4 | 3 | @SuppressWarnings("unchecked")
public T perform(T object) throws UpdateException {
DatabaseUpdater updater = new DatabaseUpdater();
try {
object = (T) this.delete(updater, object);
} catch (DBException e) {
updater.rollback();
throw new DBException("delet... |
b3db7d2e-4b8b-4a7e-872b-3f1c7264a5e1 | 2 | public boolean action(Joueur j, Dices dices) throws NoMoreMoneyException
{
if(proprietaire != null)
{
int multiplier = (proprietaire.getNbServicePublic() == 2) ? 10 : 4;
j.payer(dices.getTotal()*multiplier, proprietaire);
return false;
}
else
{
return true;
}
} |
e06dd5e7-3bbd-442a-8a52-47c7b05ca86f | 2 | @Override
public String toString() {
StringBuilder sb = new StringBuilder();
char c[] = new char[length];
for (int i = 0; i < length; i++)
c[i] = getBase(i);
sb.append(c);
sb.append("\t");
for (int i = 0; i < codes.length; i++)
sb.append(Integer.toHexString(codes[i]));
return sb.toString();
} |
f0556587-8383-494e-9664-0da0bafa1733 | 9 | private int getAliveNeighbours(int x, int y)
{
int startX = x > 0 ? (x - 1) : 0,
startY = y > 0 ? (y - 1) : 0,
maxX = (x + 1) < width ? (x + 1) : width - 1,
maxY = (y + 1) < height ? (y + 1) : height - 1,
neighbours = 0;
for (int i = startY; i <= maxY; i++)
{
for (in... |
141f46a3-2f4e-4164-a655-e3735c9df204 | 5 | protected void changeAnalysisTools(int toolIndex) {
if (displayedToolIndex == toolIndex) { //we have nothing to refresh
return;
}
displayedToolIndex = toolIndex;
this.toolContainer.removeAll();
switch (displayedToolIndex) {
case 0:
break;
case 1:
addHeader();
addPixelLine("Start Point", startX... |
e56829a6-450e-43fe-9f8d-a85ad3fceee0 | 9 | public void init()
{
canvas = new MinecraftApplet$1(this);
boolean fullscreen = false;
if(getParameter("fullscreen") != null)
{
fullscreen = getParameter("fullscreen").equalsIgnoreCase("true");
}
minecraft = new Minecraft(canvas, this, getWidth(), getHeight(), fullscreen);
minecraft.host = getDocu... |
db079f2a-658b-497e-a9fe-b311df660c87 | 2 | private boolean cmdGlobalInfo(CommandSender sender) {
try {
String[] info = WebUtils.readContentsToArray(new URL("http://server.mcforge.net/gcinfo.txt"));
for (int i = 0; i < info.length; i++) {
sender.sendMessage(info[i].replace('&', ChatColor.COLOR_CHAR));
}
info = null;
}
catch (IOException... |
4d35ebf6-6f67-4b28-8cef-b1782f8e7286 | 7 | public void checkLose(SnakePart s){
if(s!=snake.get(0)){
if(s.x==snake.get(0).x && s.y == snake.get(0).y){
gameEnd();
return;
}
}
if(s.x >= wa || s.y >= ha || s.x < 0 || s.y < 0){
gameEnd();
return;
}
} |
26c4ea50-8b98-4479-b47a-44e2b2ebefdf | 0 | @Test
public void test_getYSize() {
assertNotNull(board);
assertEquals(ySize, board.getYSize());
} |
3b63a77a-3c3d-408b-a9ff-928d9a777772 | 3 | public boolean search(T item){
LinkedListNode<T> current;
boolean found;
current = first;
found = false;
//search the list
while (current != null && !found){
if (current.info.equals(item)) //item is found
found = true;
else
... |
c638f70c-0131-4cb6-97f6-f83b623f0731 | 2 | public static void main(String[] args) throws KeyStoreException {
String rootDatabase = "master.players.json";
final PlayerStore playerStore = FileBackedStore.create("");
PlayerStore.Reader in = playerStore.createReader();
Iterable<? extends Player> core = in.readPlayers(rootDatabase);... |
dba15362-a805-419c-b8be-915d4dd9391c | 1 | private static int get2Fold(int fold) {
int ret = 2;
while (ret < fold) {
ret *= 2;
}
return ret;
} |
83eac258-50d7-4000-aa15-c6a0a84831de | 5 | private static void quit() {
// We're done. Thank the player and exit.
System.out.println("Would you like to look back on your walkthrough of the game? \n f is for forward (from the start), r is for reverse (from current position), anything else just quits");
String walkthrough = transacti... |
48e3d8e0-cd4d-44a8-9f08-f893d750d76b | 3 | @Override
public List<Paciente> listByNome(String nome) {
Connection con = null;
PreparedStatement pstm = null;
ResultSet rs = null;
List<Paciente> pacientes = new ArrayList<>();
try {
con = ConnectionFactory.getConnection();
pstm = con.prepareStateme... |
0a6e7443-98ee-454d-a9b0-12708b9264fa | 1 | @Override
public void remove(UsuarioBean oUsuarioBean) throws Exception {
try {
oMysql.conexion(enumTipoConexion);
oMysql.removeOne(oUsuarioBean.getId(), "usuario");
oMysql.desconexion();
} catch (Exception e) {
throw new Exception("UsuarioDao.removeUs... |
ee1600a3-114a-4d44-a36e-034a1b71251c | 8 | public void handleSend(Channel channel, Frame sendFrame) throws SocketException {
String topic = sendFrame.getHeaderValue(HEADER_DESTINATION);
synchronized (authentication) {
if (!authentication.canSend(clientsSessionToken.get(channel), topic)) {
sendError(channel, "Can't send message", "You're not allowed ... |
29bf60be-6b1b-4406-8a97-126b6602ca43 | 0 | public JButton getResetButton() {
return resetButton;
} |
534d1f94-81f2-4c16-b21d-62e019b88a3e | 2 | public final boolean stringInFile(final String text, final File file) throws FileNotFoundException {
Scanner fileScanner = new Scanner(file);
boolean found = false;
while (fileScanner.hasNextLine()) {
if (text.equals(fileScanner.nextLine().trim())) {
found = true;
break;
}
}
... |
1adfccb3-f258-4eff-82ec-0a39b6ce9582 | 4 | public void movePages() {
if(mainMenu != null)
mainMenu.move();
if(loadMenu != null)
loadMenu.move();
if(optionsMenu != null)
optionsMenu.move();
if(fieldLoad != null)
fieldLoad.move();
} |
476a663e-8f50-4d33-9595-eb63954adcd9 | 1 | static final void indent(Writer writer, int indent) throws IOException {
for (int i = 0; i < indent; i += 1) {
writer.write(' ');
}
} |
90de453b-c02e-48ec-bb47-f0c134dc1baf | 3 | public void update() {
if (isPaused)
return;
processInput();
updateCamera();
updateGravityAnimation();
updateQuadTree();
GameContext g = getGameContext();
// reset all resolved flags
for (Mob m : dots) {
((Collidable)m).setResolved(false);
}
// for (Mob m : lines) {
// ((Col... |
4cd62ab3-f8b6-4a4f-8719-2657c3ae9529 | 9 | private void driveBy() {
if (cmdArgs.length() < 2 || !cmdArgs.startsWith("#")) {
connection.msgChannel(config.getChannel(), "Invalid channel: " + cmdArgs);
return;
}
config.setBaseChan(config.getChannel()); // The channel JRobo will return to
connection.moveToChannel(config.getChannel(), cmd... |
5c8f581c-0da4-4f28-a122-a42fa22ac14a | 2 | public Client(String[] args) throws IOException {
FTPService.start();
s = new Session();
if (args.length > 0 && args[0].equals("test")) {
testMakespan(args[1]);
} else {
Frontend.launch(s);
}
} |
c87cbec8-e33a-4c81-8e31-62728cc76999 | 0 | public int getH(){
return countH;
} |
416447da-a7b8-474b-84f1-0cbe7d49f68c | 7 | @Override
public void render(float delta) {
if (!initialized) {
batch = new SpriteBatch();
shape = new ShapeRenderer();
init();
initialized = true;
}
tick();
if (hasChild) {
if (child.renderBehind()) {
render2(delta);
}
child.render(delta);
if (child.disposeMe) {
hasChild = fals... |
10cf04a9-cf60-45d7-8c09-5b9baa6ec1de | 7 | public void testPresent9() {
try {
TreeNode result = contains(mkChain(new String[]{ "root", "branch1", "branch2", "branch3", "branch4", "branch5", "branch6", new String("node") }), new TreeNode(new String("node")));
assertTrue(null, "Failed to locate the last node of a chain!",
... |
7e06077d-2c1c-4890-a129-8addd55eed01 | 8 | public void mouseClicked(MouseEvent e) {
if( e.isAltDown() )
centersOfGravity.add( new int[]{e.getX(), e.getY()});
//panalElements
for(PanalElement p : panalElems)
if( p.contains(e.getPoint()) ) {
if( p == gravityUp )
gravity += .1;
if( p == gravityDown )
gravity -= .1;
... |
80de80ae-0d2b-465f-878c-befa52b30a2f | 8 | private void paintCroppedTabEdge(Graphics g, int tabPlacement, int tabIndex, int x, int y) {
g.setColor(Color.gray);
switch (tabPlacement) {
case LEFT:
case RIGHT:
int xx = x;
while (xx <= x + rects[tabIndex].width) {
for (int i... |
50a9372f-798c-4525-bf01-d7814e1a16e0 | 2 | public void activateController(int controllerIndex) {
try {
if (!activeControllers.contains(controllers[controllerIndex]))
activeControllers.add(new JInputController(controllers[controllerIndex]));
}
catch (Exception e) {
System.exit(0);
}
} |
1bb148e7-9857-4b49-8ea2-7d88127293ca | 7 | public static WarcRecord readNextWarcRecord(DataInputStream in) throws IOException {
// LOG.info("Starting read of WARC record");
StringBuffer recordHeader=new StringBuffer();
byte[] recordContent=readNextRecord(in, recordHeader);
if (recordContent==null) {
// LOG.info("WARC content is null - fil... |
b5792b3c-470d-4ee8-82c6-88e41529ea26 | 2 | public Grid executeMove(Move move) {
HashMap<Character, Vehicle> newVehicles = new HashMap<Character, Vehicle>(vehicles);
ArrayList<Grid> newPreviousGrids = new ArrayList<Grid>(previousGrids);
newPreviousGrids.add(this);
Vehicle v = newVehicles.get(move.getVehicle().identifier);
Coordinate modifiedPosition = ... |
ae2aec0e-7183-4266-9b52-b6a41625cb10 | 4 | public static Class getType(Member m) {
if (m instanceof Method) return ((Method)m).getReturnType();
if (m instanceof Field) return ((Field)m).getType();
if (m instanceof LocalField) return ((LocalField)m).getType();
// otherwise it must be java.lang.reflect.Constructor
if (Debug.enabled)
Debu... |
bbc63af4-06d2-4894-bb20-c84632bda144 | 3 | public double collision(Ray ray){
//setting up values for quad formula
double t0;
double t1;
double t = Double.MAX_VALUE;
Vector3D oMinC = (ray.getOrigin().subtract(position));
double a = Vector3D.dotProduct(ray.getDirection(),ray.getDirection());
double b = 2*Vector3D.dotProduct(oMinC,ray.getDirection())... |
76494ada-5e51-4189-9899-3e8bab49f783 | 6 | public HashSet<Integer> chooseCorrectPushupPhi(final Block predecessor,
final HashSet<Integer> liveness) {
HashSet<Integer> validLive = new HashSet<Integer>(liveness);
for (SSAInstruction ins : instructions) {
if (ins.getOP() != OP.PHI) {
break;
}
if (predecessor == thenPre) {
removeLiveVarForO... |
8baa8a3c-77f4-452e-a4de-6b0565407bf9 | 7 | public static void main(String[] args) throws Exception {
// loadFile(new File("Towns.csv"));
// loadFile(new File("Tuesday2013.csv"));
// loadFile(new File("Friday2013.csv"));
// loadFile(new File("Tuesday2014.csv"));
loadFile(new File("Friday2014.csv"));
// Convert input to correct format
arrayListToDo... |
bec70c19-c218-41d4-a35c-204091bf1e9c | 4 | public ArrayList<Integer> getWaitingQueueIds() throws QueueGetWaitingException {
try {
_out.writeInt(8); //Size
_out.writeInt(Response.MSG_GET_WAITING_QUEUES);
_out.writeInt(_clientId);
_out.flush();
int messageType = _in.readInt();
if(mes... |
45b85b8f-c061-4e0a-91db-1a08a6ecda52 | 8 | @Override
public void mouseWheelMoved(int i) {
if (i < 0 && scale > .15f) {
scale = (float) (scale - .05);
//do check to see if we scaled off of map
} else if (i > 0 && scale < 1.25f) {
scale = (float) (scale + .05);
} else if (i < 0 && scale <= .15) {
... |
dc4016fc-fdaf-41c2-b7e4-0cea4cc2d418 | 2 | public void removeChild(Object obj){
children.remove(obj);
if(children.size() == 0){
if(parent != null){
parent.removeChild(this);
}
}
} |
d626eef0-f178-43cf-87d8-a4825c194fc7 | 0 | public void setSize(int size) {
this.size = size;
} |
9b7630f7-e8d3-412a-9ae2-511add1daa7d | 1 | @Override
public void EmployeeToBatiment(Batiment batiment, List<Employee> employees) {
for(Employee employee:employees){
employee.setBatiment(batiment);
bat.persist(employee);
}
} |
b9ab8a4d-097d-4600-9a3e-d14882b92b55 | 9 | protected void checkSpaceship2AsteroidCollisions(SpaceShip spaceShip, Player.State state)
throws GameOverException {
ArrayList<Asteroid> asteroids = mGameState.getAsteroids();
ArrayList<Asteroid> toRemove = new ArrayList<>();
ArrayList<Asteroid> toAdd = new ArrayList<>();
synchronized (asteroids) {
... |
dcdc66b5-2746-49ed-8964-c378ecb68b76 | 2 | public String getTelnetSessionAsString(String tcb) throws SocketException, IOException, InterruptedException {
startTelnetSession();
String rtn="blah";
GosLink.dw.append("Logging into server "+tcb+".");
if (tcb.equals("1")){
rtn=loginUser(GosLink.prps("user1"),GosLink.prps("game... |
a2130ae5-8160-4d4d-8641-c8df556641e7 | 3 | public final void mapAbbreviation(Character abbr, Action a) {
if(abbrMap.containsKey(abbr)) {
System.err.println("[CLC] The abbreviation -" + abbr + " has already been registered.");
} else if(!Character.isLetter(abbr)) {
System.err.println("[CLC] The abbreviation -" + abbr + " is not alphabetic.");
} else ... |
842024f2-50d7-4367-bdc6-99ff2af79051 | 6 | public <V> Adapter.Getter<V> makeGetter(String methodName, Class<V> _class) {
try {
T version = (T) start.get().newVersion;
final Method method = version.getClass().getMethod(methodName);
return new Adapter.Getter<V>() {
public V call() {
try {
Transaction me = Threa... |
2d8aa091-0a47-48f4-aebb-c0c7d04acfc2 | 6 | private void distributeTo(Batch <Venue> reached, Service provided[]) {
//
// First, tabulate total supply and demand within the area-
float
supply[] = new float[provided.length],
demand[] = new float[provided.length] ;
for (Venue venue : reached) {
for (int i = provided.length ; i-- >... |
2604e272-814e-4839-b13d-23bb69cda5b5 | 7 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Cell other = (Cell) obj;
if (loc == null) {
if (other.loc != null)
return false;
} else if (!loc.equals(other.loc))
return false;
i... |
41d446fb-df39-4260-8799-c0916f5d42e0 | 8 | @SuppressWarnings("unchecked")
private void stripBlankWires(List<Gate> res) {
// We now strip the blank wires
// false means blank
// Runs from top to bottom, decrementing the appropriate wires
// Is a bit funky since we cannot guarantee the input circuit
// is sorted by output wires
for (int i = origina... |
45188775-daed-4ab9-8085-9d1f061b710a | 6 | protected ApiProperties() {
try {
InputStream file = new FileInputStream(
new File("butler.properties"));
Properties props = new Properties();
props.load(file);
appId = props.getProperty("appId");
appSecret = props.getProperty("appSecret");
apiAccesKey = props.getProperty("apiAccesKey");
cl... |
c0af2305-6cd9-4f0c-b427-ada61cfab7e0 | 0 | public Automaton getAutomaton() {
return automaton;
} |
7f0a3b41-90dd-4e6d-a258-4d22d303c14a | 3 | private static boolean searchArrayList(ArrayList<Integer> arrayListToSearch, int valueToSearchFor, String arrayListName) {
Boolean found = false; // track if value is ever found
int currentLocation = 1; // track location since we are iterating a list
// required foreach loop to search the array... |
36e29149-66bb-4deb-af86-466b379cc9d4 | 4 | private void checkFeeds() {
for(Feed f : feeds) {
try {
List<String> msgs = f.check(showMsgsCount);
if( !msgs.isEmpty() && !firstRun )
sendChainedMessages(f, msgs);
} catch(IOException e) {
setError(e);
}
... |
6f486956-71f9-4893-9d51-f55dba8296bd | 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... |
82029ba0-0f5b-473a-b2a8-62e4fa968de0 | 6 | public static LightHouse getRandomHouse(double widthMin, double widthMax,
double lengthMin, double lengthMax,
int floorsMin, int floorsMax) {
if (widthMin > widthMax){
throw new IllegalArgumentException(
... |
c5b38309-eb44-4bdd-984e-89a6041413b3 | 1 | public int getOffset(long instant) {
return (instant < transition ? winterOffset : winterOffset + sizeMillis);
} |
fb0836c5-16ff-4c2b-9e4c-0600047a0f74 | 8 | public void deplacement(Coordonnee nouveauPosition) {
/*
* movimiento de un casillero en un casillero, en dirección a la nueva posición
*
* Calculo para el eje de las 'x'
*/
if ((nouveauPosition.getX()-this.getCoordonnee().getX())>0)
{
nouveauPosition.setX(this.getCoordonnee().getX()+1)... |
8789363a-bbfa-4c9a-94cd-6f95e3f37e19 | 7 | private void checkMove7 () {
if (row != 0 && col!= 0 && Othello.board[row-1][col-1] == null) {
for (int i=row, j=col; i<8 && j<8; i++, j++) {
if (Othello.board[i][j]==player) {
list[7] = new Possible(row-1, col-1, i, j); break;
}
else if (Othello.board[i][j] == null) break;
}
}
} |
1247bc3e-5529-42f5-bc52-467572e670b0 | 9 | public void testSetData() {
double[] xNullVal = null;
double[] vNullVal = null;
double[] xValueSize6 = new double[6];
double[] vValueSize6 = new double[6];
double[] xValueSize4 = new double[4];
double[] vValueSize4 = new double[4];
... |
26732bea-4fb8-4e15-bc4a-b47ad8577212 | 6 | @EventHandler
public void WolfFastDigging(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.getWolfConfig().getDouble("Wolf.FastDiggi... |
95efd5bd-db44-4484-8fd9-bba303aefdc3 | 6 | public static String getContentAndReplaceInputStream(InputStream[] inArray, boolean convertToHex) {
String content = null;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
InputStream in = inArray[0];
byte[] buf = new byte[1024];
while (... |
1c51f0ae-8f70-413c-9012-d529f42fc1d4 | 5 | public int clearRows() {
int rowsCleared = 0;
int[] row;
boolean isFilled;
for (int i = 0; i < mGrid.length; i++) {
row = mGrid[i];
isFilled = true;
for (int j = 0; j < row.length; j++) {
if (row[j] == -1 || mLiveT... |
a2cff04f-f8e9-4aae-9d3d-1133603b014f | 6 | public static int antallUlikeSortert(int[] a){
int[] array = a;
erSortert(array);
boolean sortert = erSortert(array);
int forekomster=0;
if(!sortert)
throw new IllegalStateException("Tabellen er ikke sortert");
if(sortert){
... |
e8010967-def2-4a64-93c0-86930429c91b | 8 | @Override
public int getAlignPurity(int faction, Faction.Align eq)
{
int bottom=Integer.MAX_VALUE;
int top=Integer.MIN_VALUE;
final int pct=getPercent(AlignID(),faction);
final Enumeration<FRange> e = getRanges(AlignID());
if(e!=null)
for(;e.hasMoreElements();)
{
final Faction.FRange R=e.nextElement(... |
9dd81301-4628-4874-872e-59defe458eaf | 0 | public static String createGUID() {
return UUID.randomUUID().toString();
} |
3dfaec74-c3ff-4206-a294-03a42d050531 | 3 | protected synchronized boolean isLocked(MemoryManageable mm) {
Set entries = locked.entrySet();
// this can get pretty inefficient if locked is large
for (Object entry1 : entries) {
Map.Entry entry = (Map.Entry) entry1;
HashSet inUse = (HashSet) entry.getValue();
... |
509dbd73-5d60-4a9b-89c6-46ba8372cab9 | 6 | @Override
public void putAll(Map<? extends String, ? extends V> map) {
if (map.isEmpty()) {
return;
}
for (Map.Entry<? extends String, ? extends V> entry : map.entrySet()) {
put(entry.getKey(), entry.getValue());
}
} |
dfbce351-bac6-479c-b9e8-50024416775c | 3 | private void craftItem(Item item) {
// get required resources and quantities from item
RequiredItem[] requiredResources = item.getRequiredResources();
// check to see if required resources are available
boolean adequateResources = InventoryControl.checkAvailableResources(requiredResour... |
b284cafb-aad9-4c65-932d-e9a48bfc6b46 | 4 | private Value factor() throws Exception
{
Value rval;
if(scan.sym == Token.openparen) {
scan.next();
rval = expression();
if(scan.sym == Token.closeparen) {
scan.next();
} else {
throw new Exception("Factor: no closing '... |
dd84482a-201b-47c4-ae4f-79630a17672d | 9 | public static void doDaily(PlayerPtrVector ppv, TeamPtrDivVector tpdv,
Modus modus, int round, Schedule schedule, News news) {
// update all players
int nofPlayers = ppv.GetNofPlayers();
for (int i = 0; i < nofPlayers; i++) {
Player player = ppv.GetPlayer(i);
player.updateDay(modus.getGameType() == Modus... |
515e12b1-4a22-4b65-b0f7-0198c2ce7d11 | 0 | public void setDate(String date) {
this.date = date;
} |
1f141327-7af0-40d1-9071-339710a3a2b6 | 8 | private void pivot(int p, int q) {
// everything but row p and column q
for (int i = 0; i <= M; i++)
for (int j = 0; j <= M + N; j++)
if (i != p && j != q) a[i][j] -= a[p][j] * a[i][q] / a[p][q];
// zero out column q
for (int i = 0; i <= M; i++)
... |
5d1bb0e0-c9c0-4dc7-a1e0-7229ee4a6961 | 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... |
e491ee3d-ca1f-49be-9f29-584dc6f658ad | 2 | public int lastIndexOf(String datum) {
for (int i = size - 1; i >= 0; i--) {
if (data[i] == datum) {
return i;
}
}
return -1;
} |
3510857d-b001-4e70-a762-a457291494a4 | 6 | private static Trajectory getTrajectory() {
Particle p = new Particle(particleDefault);
Trajectory t = new Trajectory();
{
Point currentPoint = new Point(p);
t.get().add(currentPoint);
}
double time = 0.5;
do {
double accelerationX=0,a... |
0ddd74ab-0918-455a-b6f8-11a031beb1e1 | 7 | @EventHandler
public void WitherBlindness(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("Wither.Blind... |
f7d3acd7-3197-4367-a57c-dc1f43069f6c | 5 | @Override
public boolean containsAll(Collection c) {
boolean[] found = new boolean[c.size()];
Object[] cArray = c.toArray();
for (int i = 0; i < this.currentSize; i++) {
T current = this.elements[i];
for (int x = 0; x < cArray.length; x++) {
if (cArray... |
3eca3adb-64fc-4ed9-abe6-b9b742ef9431 | 5 | @Override
public boolean onCommand(CommandSender sender, Command command,
String label, String[] args) {
if (!(args.length == 0)) {
return false;
}
sender.sendMessage(plugin.getBroadcaster().styleMessage(
"Red = started;Green = not started"));
sender.sendMessage(plugin.getBroadcaster().styleMessage("... |
05406817-7bdd-495e-ac2d-c7df1eb479e2 | 7 | public String[] setActiveLangArray(String LanguageArray)
{
if (LanguageArray.equalsIgnoreCase("LangArray_Top_2"))
{
String[ ] LangArray = new String[ ] {"li.en-CA","li.en-GB"};
return LangArray;
}
else if (LanguageArray.equalsIgnoreCase("LangArray_Top_5"))
{
String[ ] LangArray = new Strin... |
a13bda98-4e55-4c02-a5c5-c20ae4256e8e | 8 | private int jjMoveStringLiteralDfa9_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjMoveNfa_0(0, 8);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
return jjMoveNfa_0(0, 8);
}
switch(curChar)
{
case 84:
if ((active0 & 0x40000000L)... |
75f5c6b5-e5fb-4a20-92ba-381561d17638 | 0 | protected void onRemoveChannelLimit(String channel, String sourceNick, String sourceLogin, String sourceHostname) {} |
4a82c59a-ef72-479a-89ea-d16d6821eaa9 | 3 | public String[] getPage(int pageNumber) {
int index = this.perPage * (Math.abs(pageNumber) - 1);
ArrayList<String> list = new ArrayList<String>();
if (pageNumber <= getDoubleIndex()) {
for (int i = index; i < (index + this.perPage); i++) {
if (raw.size() > i) {
... |
ac3a6f73-a913-4aa7-92a2-143b330dda9d | 1 | public static void checkhide() {
synchronized (cache) {
for (Resource res : cache.values()) {
res.checkhidden();
}
}
} |
78345412-4424-4773-aafe-1682ca3a114b | 5 | @EventHandler(priority = EventPriority.HIGH)
private void onPlayerMove_Func(PlayerMoveEvent event) {
Player player = event.getPlayer();
Location playerLocation = null;
Location signLocation = null;
if (GcEntityListener.signExists.containsKey(player)) {
if (!GcEntityListener.signExists.get(player)) {
pl... |
35126358-50f9-40ad-a246-a8e2ca9f13c3 | 7 | void Dijkstra(int start) {
Arrays.fill(u, false);
for (int i = 0; i < n; i++) {
int v = - 1;
for (int j = 0; j < n; j++) {
if (!u[j] && (v == -1 || d[start][j] < d[start][v]))
v = j;
}
if (d[start][v] == INF)
... |
b33e01dd-eab8-4899-8300-3510facf27fe | 3 | public static void run(String[] args)
{
try
{
final String outFile;
if (args.length > 0)
outFile = args[0];
else
outFile = "out/output.mp4";
// This is the robot for taking a snapshot of the
// screen. It's part of Java AWT
final Robot robot = new Robot();
... |
d28e5a93-9b03-42ff-8077-56643b83ebfd | 5 | public static Class<?> eval(Code code, String fileName) {
File root = new File(isWindows()? "C:\\" : "/tmp/java-fun/");
File sourceFile = new File(root, fileName + ".java");
root.mkdirs();
try {
FileUtils.write(sourceFile, code.wrappedCode);
} catch (IOExcept... |
b2327e47-1577-4cd9-9e64-c77758a797f9 | 3 | public static void main(String[] args) throws KeyStoreException {
String rootDatabase = "master.players.json";
final PlayerStore playerStore = FileBackedStore.create("");
PlayerStore.Reader in = playerStore.createReader();
Iterable<? extends Player> core = in.readPlayers(rootDatabase);... |
66051794-998d-4819-9807-0fea4fcf0481 | 9 | protected void FillBuff() throws IOException
{
if (maxNextCharInd == available)
{
if (available == bufsize)
{
if (tokenBegin > 2048)
{
bufpos = maxNextCharInd = 0;
available = tokenBegin;
}
else if (tokenBegin < 0)
... |
cd43a6f0-7b9b-476d-9302-874b8bbf7658 | 2 | public Node getOther(Node n) {
if (n.equals(nodeUn)) {
return nodeDeux;
}
if (n.equals(nodeDeux)) {
return nodeUn;
}
return null;
} |
5ff9e318-f837-4718-aa0b-8b53d2d347c9 | 8 | @Override
public QueryResult execQuery(Query q) {
Statement st = null;
ArrayList<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();
if(!q.isParsed()) {
q.parse();
}
try {
st = con.createStatement();
ResultSet res = st.executeQuery(q.getParsedQuery());
while(res.nex... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.