method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
dd6ee098-f62b-4781-b5ea-00700b0df021 | 5 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
MarkPk other = (MarkPk) obj;
if (idCours != other.idCours)
return false;
if (idUser != other.idUser)
return false;
return true;
} |
2ff1cc96-564d-45ca-97af-413ee90dc0bb | 3 | public UIMenu toUIMenu(String heading) {
if (null == heading)
throw new IllegalArgumentException();
if (_menu.size() <= 1)
throw new IllegalStateException();
UIMenu.Pair[] array = new UIMenu.Pair[_menu.size()];
for (int i = 0; i < _menu.size(); i++)
array[i] = _menu.get(i);
return ... |
dc0612aa-3d2e-448f-b1e1-2d054d326a14 | 5 | public static void main(String[] args) throws Exception
{
String urlString;
if (args.length == 0)
{
urlString = "http://www.w3.org/";
System.out.println("Using " + urlString);
}
else urlString = args[0];
URL url = new URL(urlString);
InputStream in = url.op... |
3a610b7a-923d-4083-a37f-20a9e875533c | 7 | private NodeVariable getFixableLoad(NodeFunction f) throws NoMoreValuesException {
LinkedList<NodeVariable> xes = new LinkedList<NodeVariable>(f.getNeighbour());
Collections.shuffle(xes);
//for (NodeVariable x : f.getNeighbour()) {
// xes let the load to be chosen in random order (not al... |
ec1ccb43-fdfa-4719-b66b-894f2e3b69f0 | 5 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AffectationPK other = (AffectationPK) obj;
if (idEmp != other.idEmp)
return false;
if (idProj != other.idProj)
return false;
return tru... |
cdfbdbe2-1edd-4038-888b-137dd8064355 | 9 | public Expr Mul_Expr() throws ParseException {
Expr e, et;
Token tok;
e = Un_Expr();
label_25:
while (true) {
switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case MUL:
case DIV:
case MOD:
break;
... |
06d43bac-26da-4b11-9693-72f7ebbba081 | 5 | public void parse(String fileName) {
parserFactory = new ObjLineParserFactory(this);
InputStream fileInput = ResourceLoader.getResourceAsStream(fileName);
if (fileInput == null) {
// Could not find the file in the jar.
try {
File file = new File(fileName);
if (file.exists()) fileInput = new FileIn... |
cf363864-c7eb-4a73-a1a3-e7e222abda5c | 4 | public static int lastIndexOfNonWhiteSpace( String string )
{
if ( isEmpty( string ) ) {
return 0;
}
int right = string.length();
char[] chars = string.toCharArray();
for ( int idx = right - 1; idx > 0; idx-- ) {
char eachChar = chars[idx];
... |
58b6a42c-386a-4f99-9434-5be56b43ec64 | 9 | public List<WorldNode> getNeighbours(WorldNode node) {
if(log.isLoggable(Logger.INFO))
log.log(Logger.INFO, "getNeighbours() for node: " + node.getxCoord() + ", " + node.getyCoord());
List<WorldNode> result = new ArrayList<WorldNode>();
int[] offset = {1, -1};
WorldNode child = null;
for (int i ... |
c0cfec0d-18a6-4899-89fc-fc71cd64fa93 | 6 | public boolean run( char option, char jogador )
{
switch( option )
{
case 'P':
// TODO
break;
case 'N':
// TODO
break;
case 'U':
// TODO
break;
case 'F':
// TODO
break;
case 'T':
return runTabela();
case 'H':
return runHelp();
}
Util.println( "Opção nã... |
66555365-9e5e-41f4-a896-48f64b1d6e8d | 9 | public String getColumnText(Object element, int columnIndex) {
if (element != null) {
switch (columnIndex) {
case 0:
return ((StockDTO) element).getTickerSymbol();
case 1:
return ((StockDTO) element).getLastTrade().toString();
case 2:
return numberFormat.format(((StockDTO) element).getVolume()... |
68d174b1-855a-4f2d-b568-086c2b6a2402 | 3 | protected List[] verticalSlices(List childBoundables, int sliceCount) {
int sliceCapacity = (int) Math.ceil(childBoundables.size() / (double) sliceCount);
List[] slices = new List[sliceCount];
Iterator i = childBoundables.iterator();
for (int j = 0; j < sliceCount; j++) {
slices[j] = new ArrayList... |
cc34c912-71ff-44b4-9f06-06ff119cf058 | 4 | static void bindMouseEvents(Drawer drawer, Component component) {
MouseAdapter mouseAdapter = new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
if ((evt.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {
// source.setText(source.getText() + "nLeft... |
3224372a-9949-4575-a325-dabc8902d9c3 | 7 | @Override
public void handleFile(File file) {
if (getProcessMode() == MODE_BIG_CHUNK) {
String contents = FileTools.readFileToString(file, getOpenEncoding(), lineEnding);
contents = processContents(file, contents);
// If contents are null then don't write anything out.
if (contents == null) {
ret... |
ca4f1e74-1d3f-46b3-91b2-29a2e9b482c2 | 6 | public void loadEquipment(Element docEle){
NodeList equipmentsList = docEle.getElementsByTagName("Equipment");
Node equipmentsNode = equipmentsList.item(0);
Element equipmentElement = (Element)equipmentsNode;
String equipmentsPath = equipmentElement.getAttribute("FolderPath");
String equipmentPrefix = equipme... |
1f25e561-a6a3-440b-b440-dca04a2ec3f0 | 0 | public Marker getMarker (Position position){
return (Marker)board[position.getY()][position.getX()];
} |
7cf9d3da-bded-46e7-b8fa-257dcc346889 | 7 | public static byte[] getFileBytes(File file) {
try {
InputStream is = new FileInputStream(file);
long length = file.length();
if (length > Integer.MAX_VALUE) {
System.out.println("File " + file.getName() + " was too big to attain file bytes.");
is.close();
return null;
}
byte[] bytes = new ... |
49710d88-5327-4ae7-94bc-c9b31b1383cb | 1 | public void addOuterValueListener(OuterValueListener l) {
if (ovListeners == null)
ovListeners = new Vector();
ovListeners.addElement(l);
} |
51687b25-8ac1-4de5-ac7a-f76d54e486e0 | 8 | private int fillOcean(Map map, Position p, ServerRegion region,
Rectangle bounds) {
Queue<Position> q = new LinkedList<Position>();
int n = 0;
boolean[][] visited = new boolean[map.getWidth()][map.getHeight()];
visited[p.getX()][p.getY()] = true;
q.add(p... |
63ca76a0-aea1-4118-9f7a-ba2192f64b16 | 3 | @Override
protected void setRolloverTab(int index) {
int oldIndex = getRolloverTab();
super.setRolloverTab(index);
if (oldIndex != index) {
if (oldIndex != -1) {
tabPane.repaint(getTabBounds(tabPane, oldIndex));
}
if (index != -1) {
... |
b3c0c114-61c9-45bc-907f-f229a8544e8d | 7 | public static TestThread createRequestGenerator(Scanner canal, int src){
if(src == 1)
System.out.print("Origin: ");
int origin = Integer.parseInt(canal.nextLine());
if(src == 1)
System.out.print("Target: ");
int target = Integer.parseInt(canal.nextLine());
if(src == 1)
System.out.print("Operations:... |
2be03dbd-9d06-46e9-bb0e-b8937a640410 | 4 | public void saveData(Result result) {
// Erstelle ein TemplateObject für die Ausgabedatei
Template tpl = new Template();
// Lade vorlage
tpl.load("templates/truth.kml.tpl");
// Füge Name im Template ein
tpl.replace("name", result.getName());
... |
93f17291-cfbe-489d-bbcf-f55c67092eb0 | 1 | private byte[] encrypt(byte[] data) throws InvalidKeyException,
IllegalBlockSizeException, BadPaddingException {
if (data.length > MAX_ENC_SIZE) {
System.err
.println("Data to long to encrypt. Reason: Possible cheating! Fix: Exit");
System.exit(1);
}
RSAKeyParameters kp = new RSAKeyParameters(fa... |
0b385f08-18e6-4c28-a2bc-82500fbc0209 | 6 | public void doMain(String[] args) {
CmdLineParser parser = new CmdLineParser(this);
try {
parser.parseArgument(args);
} catch (CmdLineException e) {
// TODO Auto-generated catch block
e.printStackTrace();
parser.printUsage(System.out);
return;
}
if (help)
parser.printUsage(System.out);
el... |
001ec829-5860-4b95-b293-d7c553162452 | 4 | public static boolean checkEnfrentamiento(Cancha cancha, int x, int y){
int[][] dimension=cancha.getDimension();
for (int i=(x-4);i<x+4;i++){
for(int j=(y-4);j<(y+4);j++){
if(dimension[i][j]==1 || dimension[i][j]==2){
return true; //true igual conflicto p... |
69167de2-cdaf-47c4-8fd7-6aa75a2de429 | 4 | */
public void selectAll () {
checkWidget ();
if ((getStyle () & SWT.SINGLE) != 0) return;
selectedItems = new CTableItem [itemsCount];
System.arraycopy (items, 0, selectedItems, 0, itemsCount);
if (isFocusControl () || (getStyle () & SWT.HIDE_SELECTION) == 0) {
redraw ();
}
for (int i = 0; i < selectedItems.l... |
76b6d764-642f-406e-973e-9c993f1778f6 | 1 | public static void setPropertyAsString(PropertyContainer container, String key, String value) {
if (container != null) {
container.setProperty(key, value);
} else {
throw new IllegalArgumentException("Provided PropertyContainer was null.");
}
} |
d622f5ca-89a0-4c4b-91e6-7ad996f91b67 | 7 | public static ArrayList<PenPoint> readPointsFromFile(File f) {
BufferedReader br = null;
ArrayList<PenPoint> points;
points = new ArrayList<PenPoint>();
try {
String sCurrentLine;
br = new BufferedReader(new FileReader(f));
boolean flagForPenState = false;
while((sCurrentLine = br.readLine()) != nul... |
6144c343-50a4-42fe-855e-ec5a8bab4248 | 3 | @Override
public void run(){
try{
System.out.println("HireDataNodeServer is waiting for new workers on the port: "+this.portNum);
while(running){
Socket dataNodeSocket = serverSocket.accept();
DataNodeManagerServer managerServer = new DataNodeManagerS... |
d231fbe2-99ce-4806-8a79-7993c0c00d1f | 5 | public Norm containsNorm(Action ac, NormType nt)
{
for ( Norm norm: getAllRestrictNorms().values() )
{
Action a = norm.getNormResource().getAction();
if ( a!=null && a.getName().equalsIgnoreCase(ac.getName()) && norm.getNormType() == nt && norm.isActive() )
{
return norm;
}
}
return null;
} |
63b49582-02ea-4888-b6b6-05963e1914c8 | 6 | public static void main(String[] args) {
String movie = "";
Sub sub = null;
while(true)
{
movie = CLib.input("SubID");
try {
/*context = JAXBContext.newInstance(Root.class);
File file = new File("./omdbapi_text.xml");
System.out.println("Unmarshaling...");
Root r = (Root) c... |
a50565b4-2d91-4e43-9257-df575e4687b0 | 2 | @Override
public void keyReleased(KeyEvent e) {
if (e.getKeyChar() == 's') {
plateau.resetVitesse();
}
if (e.getKeyChar() == '2') {
plateau2.resetVitesse();
}
} |
adb3ca60-f966-4d58-858f-cf0135b2c6f7 | 0 | @Override
public void windowClosing(WindowEvent arg0)
{
} |
2a1e7e1a-3e89-4523-b08d-fe9b08a2c71b | 2 | @Test
public void getFinishedQuestions() throws Exception {
for (int i = 0; i < 10; i++) {
assertEquals(i, st.getFinishedQuestions());
if (i % 2 == 0) {
st.incRightQuestions();
} else {
st.incMistakeQuestions();
}
}
... |
b477f25c-3cb8-45a3-824b-066e5a694fb0 | 7 | public static void main(String[] args) {
int BITS_PER_LINE = 16;
if (args.length == 1) {
BITS_PER_LINE = Integer.parseInt(args[0]);
}
int count;
for (count = 0; !BinaryStdIn.isEmpty(); count++) {
if (BITS_PER_LINE == 0) { BinaryStdIn.readBoolean(); contin... |
e0fed38a-457a-43e2-9842-6b38bc2e0bc1 | 6 | public LLNode getSummedLinkedList(LLNode head1, LLNode head2, int carry) {
if(head1==null && head2==null)
return null;
else {
LLNode node=null;
int num1 = (head1==null)?0:head1.data;
int num2 = (head2==null)?0:head2.data;
int sum = num1+num2+carry;
node = new LLNode(sum%10);
node.next = getSumm... |
8c074915-57df-4946-aafc-cc6fce6cc993 | 0 | public Integer getExtraPoints() {
return extraPoints;
} |
6d99117c-5d56-4b86-afb8-f20a4b257465 | 2 | boolean isSkip(String skipName) {
return (skipName.equals(name)&&skip==true)? true : false;
} |
18787f8a-d4b2-439b-b1dd-58c2f979b18c | 3 | private static void doDescriptionTest()
{
System.out.print("Testing description command ");
try
{
File testFolder = new File( TEST_FOLDER );
String mvdName = TEST_FOLDER+File.separator+"test.mvd";
if ( !testFolder.exists() )
testFolder.mkdir();
String[] args0 = { "-c","create","-m",mvdName,"-d","... |
e5fda61e-0e7d-4250-959a-fb9f16e69072 | 2 | public void startLogger() {
Calendar cal = Calendar.getInstance();
cal.clear(Calendar.HOUR);
cal.clear(Calendar.MINUTE);
cal.clear(Calendar.SECOND);
cal.clear(Calendar.MILLISECOND);
logger = new Logger("logs/" + cal.getTime() + ".txt", this);
String filename = cal.getTime().toString().replace(" ", "-");
... |
6974c53f-eb66-49fb-abf3-7f868ca1f638 | 1 | public void atualizar(Local local) throws Exception
{
String sql = "UPDATE local SET cidade = ?, estado = ?, descricao = ? WHERE id = ?";
try
{
PreparedStatement stmt = ConnectionFactory.getConnection().prepareStatement(sql);
stmt.setString(1, local.getCidade());
stmt.setString(2, local.getEstado());
... |
cee0b885-02f5-45f9-b03e-cba4ae8ff663 | 7 | */
public void centerHorizontal(FastVector nodes) {
// update undo stack
if (m_bNeedsUndoAction) {
addUndoAction(new centerHorizontalAction(nodes));
}
int nMinY = -1;
int nMaxY = -1;
for (int iNode = 0; iNode < nodes.size(); iNode++) {
int nY = getPositionY((Integer) nodes.elementAt(iNode));
if (n... |
5917af32-6cd8-4f56-9a0c-1fc3d7efc35e | 9 | public static void writeHttpRequest(OutputStream stream, Keyword method, String host, String urlPath, KeyValueList headers, Stella_Object content) {
{ long contentlength = 0l;
stream.nativeStream.print(method.symbolName + " " + urlPath + " HTTP/1.0\r\n");
if (host != null) {
if (headers == null... |
f3ed45f8-8a79-4348-9118-ece435820cdb | 4 | public static void sobreescribirFichero(ArrayList<Cliente> array){
try{
FileWriter fichero=new FileWriter("src/Ficheros/Clientes.txt");
PrintWriter pw=new PrintWriter(fichero);
float aux_cuenta_corriente=0, aux_cuenta_ahorro=0, aux_penalizacion=0;
for(int i=0; i<array.size(); i++){
if(array.get(i)... |
1efa4467-ed89-473c-b797-e5d08ae2bf7c | 7 | public double FindPeak(long[][] arr) {
long max = 0;
for (int i = 0; i < ximlen; i++) {
for (int j = 0; j < yimlen; j++) {
if (arr[i][j] > max) {
max = arr[i][j];
}
}
}
// this fractal has extreme values at certain points, cut down the max
// value
if (gradient <= 0.3)
return Math.pow... |
200201a3-1018-48e9-a306-6bb9962f9266 | 1 | @Override
public int getRoll(){
if(Historical.getInstance().isEmpty()){
return getRandomInt();
}
return getMediumHistoricResult();
} |
290dbca4-586b-4d30-8468-01e374074132 | 9 | public static void handleItemOption7(Player player, int slotId, int itemId,
Item item) {
long time = Utils.currentTimeMillis();
if (player.getLockDelay() >= time
|| player.getEmotesManager().getNextEmoteEnd() >= time)
return;
if (!player.getControlerManager().canDropItem(item))
return;
player.stopA... |
46f98a7a-e3e5-4e3d-ac64-34ad8acf4b2f | 6 | public List<DisplayTable> getTables(String world) {
Connection conn = null;
PreparedStatement st = null;
ResultSet rs = null;
List<DisplayTable> tables = new ArrayList<DisplayTable>();
try {
conn = getConnection();
st = conn.prepareStatement(SELECT_WORLD);... |
7e765231-7943-4a63-a55b-df5abbb42ea4 | 1 | public void visitNegExpr(final NegExpr expr) {
if (isLeaf(expr.expr())) {
firstOrder = true;
}
} |
65e085df-c6ab-4ea5-b22e-d4e91e1ff4f3 | 5 | private void writeSelectorsAndHuffmanTables() throws IOException {
final BZip2BitOutputStream bitOutputStream = this.bitOutputStream;
final byte[] selectors = this.selectors;
final int totalSelectors = selectors.length;
final int[][] huffmanCodeLengths = this.huffmanCodeLengths;
final int mtfAlphabetSize = t... |
6cf2b52b-d630-4c03-a91e-6a5fde55bb55 | 5 | @EventHandler
public void onInteract(PlayerInteractEvent event) {
final Player p = event.getPlayer();
if (Core.getState() != State.INGAME) {
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
if (event.getItem() == null) ... |
d1acfd42-c587-4b12-9901-a74fa3687d82 | 4 | @Override
public String execute() throws Exception {
try {
Map session = ActionContext.getContext().getSession();
setUser((User) session.get("User"));
setUserdetails((UserDetails) getMyDao().getDbsession().get(UserDetails.class, getUser().getEmailId()));
... |
63f80e57-52e2-4a2d-a09b-551154df2c43 | 4 | public Manacher(String s) {
this.s = s.toCharArray();
t = preprocess();
p = new int[t.length];
int center = 0, right = 0;
for (int i = 1; i < t.length - 1; i++) {
int mirror = 2 * center - i;
if (right > i)
p[i] = Math.min(right - i, p[mirror]);
// attempt to expand palindrome centere... |
65837eff-d979-42f0-922b-922ea570e746 | 3 | public static void compress() {
int run = 0;
boolean old = false;
while (!BinaryStdIn.isEmpty()) {
boolean current = BinaryStdIn.readBoolean();
// alternate bit
if (current != old) {
BinaryStdOut.write(run, lgR);
run = 1;
old = !old;
}
// sam... |
8a84ef25-07ad-4a4b-b117-a41c243be6a5 | 7 | private void setUpField() throws Exception {
m_fieldIndex = -1;
m_fieldValueIndex = -1;
m_field = null;
if (m_fieldDefs != null) {
m_fieldIndex = getFieldDefIndex(m_fieldName);
if (m_fieldIndex < 0) {
throw new Exception("[NormDiscrete] Can't find field " + m_fieldName
... |
1ad76875-46b0-45ad-858c-892c739d3057 | 2 | static double[][] add(double[][] matrix1, double[][] matrix2){
double[][] sum = new double[matrix1.length][matrix1[0].length];
for(int i = 0; i < sum.length; i++)
for(int j = 0; j < sum[0].length; j++)
sum[i][j] = matrix1[i][j] + matrix2[i][j];
return sum;
} |
fb76f268-1987-4aa2-808e-e103522fa2a6 | 5 | public byte[] renderImage(final ACamera camera) {
// measure render time
LOG.info("rendering image...");
this.information = new RenderInformation();
this.information.start();
// calculate the size of the image data
this.data = new byte[this.settings.getBytes()];
// initialize the render pool
int thre... |
b9863003-184e-437b-ae98-26a5472ca3e7 | 7 | @Override
protected boolean processSourceMessage(CMMsg msg, String str, int numToMess)
{
if(msg.sourceMessage()==null)
return true;
int wordStart=msg.sourceMessage().indexOf('\'');
if(wordStart<0)
return true;
String wordsSaid=CMStrings.getSayFromMessage(msg.sourceMessage());
if(wordsSaid == null)
... |
5e84bf33-28a3-424f-b9a9-5bde025f6b1b | 5 | private void pop(char c) throws JSONException {
if (this.top <= 0) {
throw new JSONException("Nesting error.");
}
char m = this.stack[this.top - 1] == null ? 'a' : 'k';
if (m != c) {
throw new JSONException("Nesting error.");
}
this.top -= 1;
... |
20bd7b0f-465e-48d6-961d-0f6ebfc35143 | 2 | public Coord mod(Coord d) {
int v, w;
v = x % d.x;
w = y % d.y;
if (v < 0)
v += d.x;
if (w < 0)
w += d.y;
return (new Coord(v, w));
} |
ca978f0a-7949-477b-a61f-9bf2bf386784 | 0 | public long getLength() {
return length;
} |
3761b856-a351-4b51-bc10-e735c4a9d1c1 | 7 | private Boolean waitForJobToComplete(String jobId, String sqsQueueURL) throws InterruptedException, JsonParseException, IOException {
Boolean messageFound = false;
Boolean jobSuccessful = false;
while (!messageFound) {
out.println("Checking for messages on queue '" + sqsQueueURL + "... |
c8edeca5-1639-4bf0-8bd9-2dc6766b82c7 | 9 | public boolean skipPast(String to) throws JSONException {
boolean b;
char c;
int i;
int j;
int offset = 0;
int length = to.length();
char[] circle = new char[length];
/*
* First fill the circle buffer with as many characters as are in the
* to str... |
c7e6de1a-84f7-4427-8e84-8da59104269b | 9 | static int blendfactor(int c, int factor, int src, int dst) {
switch (factor) {
case 1:
return c;
case 2:
return colorMul(c, src);
case 3:
return colorMul(c, colorSub(0xFFFFFFFF, src));
case 4:
return colorMul(c, dst);
case 5:
return colorMul(c, colorSub(0xFFFFFFFF, dst));
case 6:
return... |
65f41f5f-26c7-4889-8f6e-d61657805f1e | 1 | public char getChar(){
if( value.length() != 1 )
throw new XException( "not a character: " + value );
return value.charAt( 0 );
} |
c9532fc4-2efb-428d-82fb-e7b7555bdb50 | 3 | private void rellenarTabla() {
TableColumnModel tcm;
if(tarea.getSubtareas()!=null && !tarea.getSubtareas().isEmpty()){
tableModel = new JDEditar.TableModel(tarea.getSubtareas());
jTabla.setModel(tableModel);
}
tcm = jTabla.getColumnModel();
for (int col =... |
9534edd1-d6c8-47f5-9692-155ae92978b2 | 6 | public static void collectVariableBinding(String name, Stella_Object type, Stella_Object binding, KeyValueList bindings) {
if (binding != null) {
if (type != null) {
type = Logic.getDescription(type);
}
if (RDBMS.collectionValuedConstraintP(binding)) {
{ Cons args = Stella.NIL;
... |
fc23c233-bea9-464f-ae56-50fd7f94b1c9 | 0 | public void setMedicoCollection(Collection<Medico> medicoCollection) {
this.medicoCollection = medicoCollection;
} |
eebdd440-bbb3-463b-af34-4715efa1f27c | 9 | public Powerup(){
int i = rand.nextInt(225);
if (i >= 25) this.type = PowerupType.NUKE;
if (i < 25) this.type = PowerupType.SLOWTIME;
if(i >= 100) this.type = PowerupType.LIVES;
if(i >= 150) this.type = PowerupType.SHRINK;
if(i >= 200) this.type = PowerupType.RANDOM;
this.xPos = this.rand.nextInt(Snow.ga... |
35ebd8e5-7dd1-4ea8-81f8-9791389b1207 | 3 | @Override
public void mark(int boardPosition, Cell[] cellBoard, int rows, int columns) throws IllegalMark {
//Find the row.
int boardPositionRow = boardPosition / columns;
//Find the column.
int boardPositionColumn = boardPosition % columns;
//Posit... |
89f1c626-c2d3-4607-b8d1-8d2ba9a6644b | 7 | public boolean collision(HashMap<Body, Personnage> personnages) {
if (world == null)
return false;
Personnage persCourant;
// collision avec l'environnement est apparu?
CollisionEvent[] evenement = world.getContacts(body);
float Normal_x;
for (int i = 0; i < evenement.length; i++) {
Normal_x = eveneme... |
a7403599-8dab-466e-a997-72283acc7143 | 3 | public static void main(String[] args){
Socket socket = null;
DataOutputStream os = null;
DataInputStream is = null;
Scanner sc = new Scanner(System.in);
try{
socket = new Socket("192.168.22.1",5000);
os = new DataOutputStream(socket.getOutputStream());
is = new DataInputStream(socket.getInputStream... |
87a6550a-f8e4-4969-9412-a5a95bda0846 | 7 | public final String methodR(int j) {
if(j >= 0 && j < 10000)
return String.valueOf(j);
if(j >= 10000 && j < 10000000)
return j / 1000 + "K";
if(j >= 10000000 && j < 999999999)
return j / 1000000 + "M";
if(j >= 999999999)
return "*";
else... |
edfd3dd1-1917-430a-9054-079a7b2c8e6d | 8 | @Override
public void stateChanged(ChangeEvent evt) {
if (evt.getSource().equals(targetDayPicker.getModel())) {
targetDay.set( targetDayPicker.getModel().getYear(),
targetDayPicker.getModel().getMonth(),
targetDayPicker.getModel().getDay());
updateRosterList();
updateTripList();
}
i... |
42233c55-7363-4d7d-8efe-a26249048429 | 5 | public Notebook() {
getContentPane().add(content);
scrollPane = new JScrollPane(content);
getContentPane().add(scrollPane, "Center");
for (menu_count = 0; menu_count < menu.length; menu_count++) {
nbMenuBar.add(menu[menu_count]);
menu[menu_count].addActionListener(this);
while ((menu_count == 0) && (m... |
1b250b14-ef3c-4ca3-81c3-c5a679449973 | 7 | public void monitorarSoro(float qtdSoro, Paciente paciente)
throws ControllerException {
try {
if (qtdSoro < 0 || qtdSoro > 500) {
throw new ControllerException(
"valor de quantidade de soro inválido");
}
if (ValidarPaciente(paciente) && qtdSoro < 20) {
Publish publish = new Publish(pacient... |
d41f21e2-7203-4cae-bb0b-821a4811c780 | 8 | public int largestRectangleArea(int[] height) {
// Start typing your Java solution below
// DO NOT write main() function
Stack<Pair> sta = new Stack<Pair>();
if (height.length == 0)
return 0;
int res = 0;
int i = 0;
for (; i < height.length; i++) {
int preH = sta.isEmpty() ? -1 : height[sta.peek().i... |
15491180-2c82-49c4-a320-3a603b89ea4b | 1 | public Boolean equals(Eisenstein that) {
return this.a == that.a && this.b == that.b;
} |
1f49529d-6ac0-4adb-ab3e-c66778dcb898 | 5 | @Override
public String toString() {
String result = "";
int counter = 0;
if (!isEmpty()) {
for (Object obj : queue) {
if (obj != null) {
result += counter + "[" + obj + "] ";
if (counter == (head) % queue.length) {
result += "(head) ";
}
if (counter == (tail) % queue.length) {
... |
da621315-ce01-491b-81d8-7de044716b8c | 5 | public Card handleSuggestion(Solution suggestion){
ArrayList<Card> clues = new ArrayList<Card>();
Random roller = new Random();
for(Player player : players) {
if(player.getName().equals(suggestion.getPerson()))
player.setLocation(currentPlayer.getLocation());
if(players.get(currentPlayerIndex) == pla... |
4b1a13eb-4926-4a84-8981-6da08f6938ce | 9 | static String findCommonString(String string1, String string2) {
int length1 = string1.length();
int length2 = string2.length();
int[][] traceMap = new int[length1][length2];
int maxNum = 0;
int lastSubBegin = 0;
String commonSub = "";
if(length1==0 || length2==0) return "";
for(int i=0;i<length1;... |
ed1d9ba7-11d2-43c6-94fd-abce176bf458 | 3 | public VariableStack mapStackToLocal(VariableStack stack) {
VariableStack newStack;
int params = cond.getFreeOperandCount();
if (params > 0) {
condStack = stack.peek(params);
newStack = stack.pop(params);
} else
newStack = stack;
VariableStack after = VariableStack.merge(thenBlock
.mapStackToLoc... |
680c9feb-927d-4578-bdd8-195c8ac01f57 | 9 | private int square(Piece[][] pieces, int from_x, int from_y, int to_x, int to_y) {
if((to_x == from_x && Math.abs(to_y - from_y) == 1 || to_y == from_y && Math.abs(to_x - from_x) == 1 || Math.abs(to_x - from_x) == 1 && Math.abs(to_y - from_y) == 1) && (isOccupiedByAnOpponent(pieces[to_x][to_y]) || isEm... |
1398f55d-1783-429c-aafd-65e2b0e7b323 | 6 | void FillDistancesPrices()
{
for (int i = Base.kStartPosModelIndex; i < Base.kNumFullDistances; i++)
{
final int posSlot = GetPosSlot(i);
final int footerBits = ((posSlot >> 1) - 1);
final int baseVal = (2 | posSlot & 1) << footerBits;
tempPrices[i] = ... |
6cba0dfb-c82a-434a-bf9a-2e11b946c416 | 4 | @Override
public void run(ListIterator<Instruction> iter){
Instruction i = iter.next();
// if this function does any function calls, the return
// address will need to be saved
if(i instanceof Call) {
registersUsed.add(retAddrReg);
}
Integer color = i.getC... |
06dd37a1-00bc-430a-bbf0-686db0734554 | 5 | public boolean isFull(int i, int j) // is site (row i, column j) full?
{
if (i<1 || i>N || j<1 || j>N)
{
throw new java.lang.IndexOutOfBoundsException();
}
return isOpen(i, j) && uf_real.connected(N * (i - 1) + j - 1, N * N);
} |
d34f1d1b-a2e4-4141-929c-730a223fbe9b | 9 | static void lsp_to_curve(float[] curve, int[] map, int n, int ln,
float[] lsp, int m, float amp, float ampoffset) {
int i;
float wdel = M_PI / ln;
for (i = 0; i < m; i++) {
lsp[i] = Lookup.coslook(lsp[i]);
}
int m2 = (m / 2) * 2;
i = 0;
wh... |
71f189a8-65a7-4758-8db7-bf18f5772bf7 | 6 | public String nextCDATA() throws JSONException {
char c;
int i;
StringBuffer sb = new StringBuffer();
for (;;) {
c = next();
if (end()) {
throw syntaxError("Unclosed CDATA");
}
sb.append(c);
i = ... |
62338984-cc0f-4df1-b0dc-ac11a7ef08e6 | 1 | @Override
public int decidePlay(int turn, int drawn, boolean fromDiscard) {
DataInstance d = getHistory(drawn, false);
playNet.compute(d.inputs);
int actual = playNet.getOutput()-1;
//Train
if (model_mimic != null){
int target = model_mimic.decidePlay(turn, drawn, fromDiscard);
playNet.trainBackprop(0.... |
c6b28227-0427-4816-995d-e74528ddb9c2 | 8 | private String queryServer() throws IOException {
ih_str = "";
byte[] info_hash = this.torrentInfo.info_hash.array();
for (int i = 0; i < info_hash.length; i++) {
ih_str += "%" + this.HEXCHARS[(info_hash[i] & 0xF0) >>> 4]
+ this.HEXCHARS[info_hash[i] & 0x0F];
}
//System.out.println("info hash:... |
aa4a2698-f21a-4d0a-b793-339a10302cec | 7 | @Override
public boolean onResponse(Message message) {
String msg = message.content.toLowerCase();
Pattern pattern = Pattern.compile("^@((qinbot)|(亲妹子)) +help(.*)");
Matcher matcher = pattern.matcher(msg);
if (matcher.find()) {
//总帮助提示
if (matcher.group(4)==null||matcher.group(4).trim().equals(""))... |
ca76db57-be02-4b9d-87bc-791880e13ebd | 1 | public long getElapsedTimeSecs() {
long elapsed;
if (running) {
elapsed = ((System.currentTimeMillis() - startTime) / 1000);
}
else {
elapsed = ((stopTime - startTime) / 1000);
}
return elapsed;
} |
b9f9f2da-ed54-4679-b3bf-5ba18bf66110 | 9 | public ArrayList<Disciplina> Disciplinas() throws FileNotFoundException {
try {
Scanner fi = new Scanner(new File("src/Ficheiros/disciplinas.txt"));
Scanner ji = new Scanner(new File("src/Ficheiros/disciplinas.txt"));
String bb = fi.nextLine();
String bbb = ji.ne... |
269d609c-fe8f-40eb-a7f2-73d31a9d97d1 | 1 | public void addMarker(double latitude,double longtitude)
{
if(markers<20)
{
marker[markers] = new MarkerRect(latitude,longtitude);
markers++;
}
} |
68ab5afc-ff4f-4714-a66c-65c411c622df | 7 | @Override
// Over writes the table cell renderer to perform custom cell rendering
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
// Create a rendered label for easy manipulation
JLabel renderedLabel = (J... |
ef911ba3-5af4-47e2-b664-a381ddc8dd62 | 1 | private static void addAll(Set<String> target, Set<String> toAdd, String prefix){
for(String i : toAdd){
// System.out.println((prefix+i));
target.add((prefix+i));
}
} |
ab8df6e9-fa22-4d03-96bd-1f81f8ec6106 | 4 | @Override
protected void paintScreen(Graphics2D g) {
paintInstructions(g);
int maxNbChoicesOnScreen = (getScreenHeight() - INSTRUCTIONS_AREA_HEIGHT)
/ CHOICE_HEIGHT - 1;
int start = 0;
if (selectedIndex >= maxNbChoicesOnScreen) {
start = selectedIndex - maxNbChoicesOnScreen + 1;
}
int lastChoiceTo... |
944f26c4-3231-4ac0-b5f8-a1d032867754 | 8 | public boolean isBlockSolidOnSide(World world, int x, int y, int z, int side)
{
int meta = world.getBlockMetadata(x, y, z);
if (this instanceof BlockStep)
{
return (((meta & 8) == 8 && (side == 1)) || isOpaqueCube());
}
else if (this instanceof BlockFarmland)
... |
539d56e6-9b33-440c-afd3-ee69a46eb0d3 | 7 | protected void updateOrigin()
{
mxRectangle bounds = getGraphBounds();
if (bounds != null)
{
double scale = getView().getScale();
double x = bounds.getX() / scale - getBorder();
double y = bounds.getY() / scale - getBorder();
if (x < 0 || y < 0)
{
double x0 = Math.min(0, x);
double y0 = ... |
813ec839-c512-4066-a8f9-cb3a7cc6cdfb | 7 | public static void main(String[] args) throws Exception {
IfolorLoader loader = new IfolorLoader();
ProjectPath path = TestData.getTestProject();
Book book = loader.load(path);
HashSet<String> duplicateFind = new HashSet<String>();
int doubles = 0;
for (BookPage pg : book.pages)
for (BookElement el : ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.