method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
91c8b7ad-eec9-4415-9a73-1b890e30e4d9 | 6 | private String getDebugInfo(Game.CarInfo myCarInfo, Game game, double desiredSpeed, double throttle, AngleState as, double nextAngle) {
GameInit.Race.Track.Piece piece = game.track.pieces[myCarInfo.pieceIndex];
double racc = myCarInfo.getRAcceleration();
double r = myCarInfo.getR();
if (... |
f2641e32-730c-4b5a-a977-c7288bfe0dc8 | 3 | public int getTurn()
{
int count = 0;
for(int j = 0; j < takenSpaces.length; j++)
{
if(takenSpaces[j] != 0)
{
count++;
}
}
if(count%2 == 0)
{
return 1;
}
else
return 2;
} |
07c6b546-a5c5-434e-b694-eff3ac37600a | 6 | private void colorGrid() {
m_layeredPane.resetColors();
int day = m_currentWeek.getDayOfWeek().getValue(); // 1-7
// plan before / after
int startHour = m_appSettings.getStartPlanningTime().getHour();
int endHour = m_appSettings.getEndPlanningTime().getHour();
int startMinutes = m_appSettings.getStartPlanni... |
7e264e67-e102-4eb7-822d-3ed62d780878 | 6 | public Command getCommand(char operator) {
switch (operator) {
case '>':
return new GoToNextCell();
case '<':
return new GotoPrevCell();
case '+':
return new IncrementValue();
case '-':
return new De... |
c8f12a2c-abf1-4c0c-94af-5eb789803b11 | 5 | private static int onkoMillainenPari(Sitsaaja sitsaaja) {
if (sitsaaja.avecIsSet()) {
if (sitsaaja.isMies() && sitsaaja.getAvec().isMies() == false) {
return 1;
} else if (sitsaaja.isMies() == false && sitsaaja.getAvec().isMies()) {
return -1;
... |
cffa4e9e-52dd-47a1-a8a4-1aacba547c52 | 5 | public static Bitmap[][] recolor(Bitmap[][] bitmaps, int a0, int b0, int a1, int b1) {
for (int x = 0; x < bitmaps.length; x++) {
for (int y = 0; y < bitmaps[x].length; y++) {
Bitmap bm = bitmaps[x][y];
for (int i = 0; i < bm.pixels.length; i++) {
if (bm.pixels[i] == a0) bm.pixels[i] = b0;
if (bm... |
068a5338-db5f-4cad-ba75-e7856dd71b99 | 4 | public void move()
{
if (xcor >= framex)
{
xcor = -image.getWidth(null);
}
else if (xcor <= -image.getWidth(null))
{
xcor = framex;
}
// Controls wrap around in the y-axis
if (ycor >= framey)
{
ycor = -image.... |
74b39c35-595a-4a0e-8e04-e04e74ccaebd | 4 | public String toString(){
if (var!=null) return var.data;
else if (list != null){
String res = "(";
for (LISP_object it: list) res = res+it.toString()+" ";
res = res+")";
return res;
}else if (proc != null) return "FUNCTION";
else return ""... |
25a2934f-5c40-4823-9fa7-5442d18bf106 | 2 | public void countInitialFitnessAllPop() throws Exception {
for (int i = 0; i < getSpecies().size(); i++) {
for (int j = 0; j < getSpecies().get(i).getNumberOrganisms(); j++) {
getSpecies().get(i).getOrganism(j).countFitnessOut(1);
}
}
} |
c741a3f9-e0cf-479e-ad81-2c2367c87b08 | 4 | public void mousePressed(MouseEvent e) {
// Stops any moves from being made once the puzzle is solved.
if (isSolved())
return;
// Gets the row and column of the clicked square
int row = e.getY() / 100;
int col = e.getX() / 100;
// get coordinate of black square
int[] blackSquare = adjacentBlackSquare... |
8b027d90-af96-4d2b-a497-c1a95bd06c92 | 8 | public LinkedList<Point> getAdjacentPoints(int x, int y){
LinkedList<Point> adjacents = new LinkedList<Point>();
int cx,cy;
for(int i = -1; i <= 1; i++){
for(int j = -1; j <= 1; j++){
cx = x + i;
cy = y + j;
if(cx >= 0 && cx < gridDims.width &&
cy >= 0 && cy < gridDims.height &&
!(i ==... |
fb9ed428-eb2b-4683-af53-b976c5968c66 | 4 | protected void buy(Player player, Game game) {
Integer gold = player.getGold();
for (CardsToBuy couple : buyOrder) {
if (couple.numberToBuy > 0 && couple.card.getCost() <= gold) {
try {
game.buy(couple.card, player);
couple.numberToBuy--;
break;
} catch (BuyException e) {
logger.error... |
b0911a15-3de3-415b-b526-9a37c468d25c | 0 | public void setFPS(int fps) {
this.fps = fps;
} |
ca354aa2-d7cd-46db-82e9-a819dd213b23 | 2 | @Override
public void manageInput(InputEvent e) {
if (e.isKeyInput()) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
exitScreen();
} else {
panel.manageInput(e);
cancelButton.manageInput(e);
}
} |
cb2b09f9-6db4-4163-b24b-fdbe917432ee | 4 | public ArrayList<Process> generateProcesses()
{
float arrivalTime;
float expectedTime;
int priority;
generator = new Random(1); //paramater is seed used for random number generator
for(int i = 0; i < numProcesses; i++){
//create random number for arrival time
... |
534cf32e-0261-46f9-87c3-f1efa0347e8f | 7 | @Override
public String resaveFaction(Faction F)
{
if((F.factionID().length()>0)
&&(CMLib.factions().getFaction(F.factionID())!=null))
{
if(!CMath.bset(F.getInternalFlags(), Faction.IFLAG_NEVERSAVE))
{
final StringBuffer buf = rebuildFactionProperties(F);
String factionFilename = makeFactionFilena... |
29ca95fe-6eaf-4c76-a55a-c8a2691e524c | 3 | public void run() {
System.out.println("Chef run");
try {
while (!Thread.interrupted()) {
restaurant.lock.lock();
try {
if (restaurant.meal != null)
restaurant.noMealCondition.await();
restaurant.meal = new Meal(0);
System.out.println("Meal come");
restaurant.fullMealCondition.sign... |
e6c469ae-ba50-44f6-b33a-5630d60b45e5 | 6 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!getClass().equals(obj.getClass()))
return false;
Device other = (Device) obj;
return id == other.id && idComponent == other.idComponent
&& idPrev == other.idPrev && title.equals(other.... |
5ed37035-ed7e-4814-be9b-87ea0e2f9e88 | 5 | public void keyReleased(int k) {
if(k == KeyEvent.VK_LEFT) player.setLeft(false);
if(k == KeyEvent.VK_RIGHT) player.setRight(false);
if(k == KeyEvent.VK_UP) player.setUp(false);
if(k == KeyEvent.VK_DOWN) player.setDown(false);
if(k == KeyEvent.VK_W) player.setJumping(false);
} |
6f83f0d1-0140-43e5-9882-20e19f7e09b9 | 3 | public void set(int key, int value) {
Node node = map.get(key);
if (capacity == map.size()) {
if (null == node) {
Node rmn = dlist.removeEnd();
map.remove(rmn.key);
Node n = new Node(key, value);
dlist.add(n);
map.put(key, n);
} else {
Node n = dlist.remov... |
a9398d22-2216-4a07-a08d-9d21875ff791 | 4 | public static void arc(double x, double y, double r, double angle1, double angle2) {
if (r < 0) throw new RuntimeException("arc radius can't be negative");
while (angle2 < angle1) angle2 += 360;
double xs = scaleX(x);
double ys = scaleY(y);
double ws = factorX(2*r);
doubl... |
0a0f986e-5067-4b1b-96c7-8a5325d8c965 | 9 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
MOB target=mob;
if((auto)&&(givenTarget!=null)&&(givenTarget instanceof MOB))
target=(MOB)givenTarget;
if(target.fetchEffect(this.ID())!=null)
{
mob.tell(target,null,null,L("<S-NAME> alread... |
ca61769b-1ce9-4e48-ad89-2e999d7ab1fa | 7 | private final void step6()
{ j = k;
if (b[k] == 'e')
{ int a = m();
if (a > 1 || a == 1 && !cvc(k-1)) k--;
}
if (b[k] == 'l' && doublec(k) && m() > 1) k--;
} |
d65031cf-4549-41a5-bf63-9be6599b1d64 | 5 | private boolean checkScannedRobot(){
boolean scanned = false;
for (int i = 0; i < Board.robots.size(); i++) {
if(Board.robots.get(i) != this){
Point2D pfradar = this.movePoint(this.radar.x+18 , this.radar.y+20, this.radar.angle, 800);
Line... |
7227bd0c-14dc-4c9c-bc41-0b9fca2a4b4d | 3 | void setCellBackground () {
if (!instance.startup) {
textNode1.setBackground (1, cellBackgroundColor);
imageNode1.setBackground (1, cellBackgroundColor);
}
/* Set the background color item's image to match the background color of the cell. */
Color color = cellBackgroundColor;
if (color == null) color =... |
5936c2fb-ea74-4aa2-b12f-e3c9866447f8 | 0 | @Basic
@Column(name = "PRP_FECHA")
public Integer getPrpFecha() {
return prpFecha;
} |
f66841e9-4d18-45c9-b681-03f657d7012b | 3 | private DbHelper() {
try {
Class.forName(driver);
if (login.equals("")) {
conn = DriverManager.getConnection(url);
} else {
conn = DriverManager.getConnection(url, login, password);
}
logger.info("Connection OK!");
... |
29e1c910-8f9d-432c-9b21-42f8ae825e69 | 4 | @Test
public void test_twoParamComplexExtends() {
TypeToken<?> token = new TypeToken<Map<String, Map<? super Integer, ? extends List<? extends Number>>>>() {};
doTest(token,
"java.util.Map<java.lang.String, java.util.Map<" +
"? super java.lang.Integer, ? extends java.... |
4d353a37-af6c-4b6d-99a2-232d407c5984 | 9 | public static void main(String[] args) {
double a, b;
Func f = new Func();
ArrayList<String> al = new ArrayList<String>();
try(Scanner in = new Scanner(System.in)) {
System.out.println("Enter operation:");
while(in.hasNext()) {
al.clear();
String str = in.nextLine(); // read line from c... |
13744eec-e997-44c6-acc6-09a7b9bdd1c3 | 2 | private int getArgIndex(final int arg) {
int index = (access & Opcodes.ACC_STATIC) == 0 ? 1 : 0;
for (int i = 0; i < arg; i++) {
index += argumentTypes[i].getSize();
}
return index;
} |
7777da3d-b5de-431a-a86d-f66e8fdff334 | 5 | public Circuit decoder(String endroit){
try {
Circuit c = new Circuit();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new InputSource(endroi... |
080c9d82-5908-42a0-8ef6-cfd8d47fd888 | 3 | private void paintInfoForCurrentObj(Graphics2D g2, Placeable obj) {
if (obj != null && obj.isEnemy()) {
paintInfoForCurrentEnemy(g2, (Enemy) obj);
} else if (currentObject instanceof ShootableTower) {
paintInfoForCurrentTower(g2, (ShootableTower) currentObject);
}
} |
1799cd5f-3ff1-40e8-a5a4-97c1e7c6b9dc | 7 | public void setFamily(Family family) {
Person husband = family.getHusband();
Person wife = family.getWife();
lblCaption.setText((husband == null || husband.getName() == null ? "?"
: husband.getName().getFamilyName())
+ "/"
+ (wife == null || wife.getName() == null ? "?" : wife
.getName().getFam... |
c7dd61ad-dcd0-4c4c-a732-09f8f94ca68b | 0 | public String getVis_matricule() {
return vis_matricule;
} |
395734f2-bd07-4843-a1ed-4f036ef02bb1 | 3 | private void copyTo(MCHashEntry[] var1) {
MCHashEntry[] var2 = this.slots;
int var3 = var1.length;
for(int var4 = 0; var4 < var2.length; ++var4) {
MCHashEntry var5 = var2[var4];
if(var5 != null) {
var2[var4] = null;
MCHashEntry var6;
do {
... |
193fa35b-817c-411e-a070-94922f63b1c8 | 7 | @EventHandler(priority = EventPriority.HIGH)
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
if (event.isCancelled())
return;
for (Block block : event.getBlocks())
if (new PartialCKDoor(block).isBlockPartOfCKDoor()) { //Make sure the door is one that needs to be protected
if (DebugFiles.... |
4843a3e3-b058-4c52-8d2c-283384b44d8e | 8 | private void findFrequencies() {
for(int i = 0; i < modifiedSamples.length; i++){
int width = AudioData.WINDOW_SIZE;
int result = autoCorrelation(i, width);
if(result!= -1){//markFrequencyMethod
//the autocorrelated max result minus the index starting point gives the width of the si... |
39f91e06-b470-4093-a6d6-adb49df0a599 | 0 | @Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
ImageIcon color = (ImageIcon) value;
setText("");... |
11ddc430-8ace-443b-b2df-82fff2286433 | 0 | public void setQuest(QuestPoint quest) {
this.quest = quest;
} |
ace4c1e7-0d7e-4233-b2da-661c15258d76 | 2 | @Override
public void doLoopAction()
{
if (hit)
{
super.doHit();
if (getGoinUp() == 20)
{
hit = false;
setGoinUp(0);
}
}
} |
cc1a83d8-6db3-4803-958b-04c285e97568 | 6 | public static void transfer(InputStream in, OutputStream out, long len)
throws IOException {
byte[] buf = new byte[4096];
while (len != 0) {
int count = len < 0 || buf.length < len ? buf.length : (int)len;
count = in.read(buf, 0, count);
if (count == -1) {... |
5af7ff9c-54a8-4add-840e-87bc20ee24cb | 7 | private void executeOaiListAggregateSetRecords( String verb, HttpServletResponse response, boolean authenicate, String aggregateSetName, String metadataPrefix, boolean forceNewDate ) throws IOException {
AggregateList aggregateSets = new AggregateList();
AggregateSet setToRetrieve = aggregateSets.getAggregateS... |
4c5b4342-f468-4f5f-afec-e073af037d23 | 7 | public ShapeParcela(SimpleFeature f, String tipo) {
super(f, tipo);
shapeId = "PARCELA" + super.newShapeId();
// Para agrupar geometrias segun su codigo de masa
codigoMasa = ((String) f.getAttribute("MASA")).replaceAll(
"[^\\p{L}\\p{N}]", "") + "-";
this.poligons = new ArrayList<LineString>();
//... |
3110c5c4-9c51-477c-99e0-a8dc55235f06 | 2 | public void add(String s){
if(s.equals("Head")){
m[size++] = "Head";
countHead();
}else if(s.equals("Tail")){
m[size++] = "Tail";
countTail();
}
} |
a6bc923e-0a32-417e-b4b2-aeaba83b0eef | 7 | public void shutdown() {
try {
registry.unbind(bindingName);
} catch (AccessException e) {
logger.error("couldn't unbind the Registry");
} catch (RemoteException e) {
logger.error("couldn't unbind the Registry");
} catch (NotBoundException e) {
logger.error("couldn't unbind the Registry");
}
try... |
8fa78250-c116-4af2-a318-751fa4463def | 7 | public Queens(final int size) {
if (size > 0) {
this.size = size;
placementConstraints = new PlacementPart[size][size];
// build placement constraints
for (int row = 0; row < size; ++row) {
for (int col = 0; col < size; ++col) {
placementConstraints[row][col] = new PlacementPart(
this, ro... |
96c859cf-17fd-44b7-a9d5-fde29a3282e1 | 3 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
try {
String nome = jTextField1.getText();
long id = Long.parseLong(jTextField2.getText());
long tel = Long.parseLong(j... |
ab72560e-3f63-4527-ab22-069d352b0ec0 | 5 | private int computeLocalSize() {
int size = (allocator.getRegNumber() + 2) * 4; // useless, just to make
// code logic simple
int maxReg = 0;
for (int reg : regMap.values()) {
if (maxReg < reg) {
maxReg = reg;
}
}
if (maxReg > allocator.getRegNumber() + 2) {
size = maxReg * 4;
}
... |
cfbae795-0399-4481-90ab-dfac1c88158d | 3 | public String getAllTriples(Model model) {
StringBuffer dump = new StringBuffer();
StmtIterator statements = model.listStatements();
while (statements.hasNext()) {
Statement statement = statements.nextStatement();
RDFNode object = statement.getObject();
dump.append(statement.getSubject().getLocalName())... |
7ac1e799-2999-4256-a6de-712c84dcd1d9 | 5 | public int authorize(String user, String pass){
// go through all users, look for username
User currentUser = null;
for (User u : users){
if (u.username.equals(user)){
currentUser = u;
break;
}
}
// return 0 = invalid username
if (currentUser == null)
return 0;
// determine type of ... |
234b1535-4ffd-43c9-9e31-a358fe0310ec | 2 | public static void appendToFile( String fileName, String content ) {
File file = new File( fileName );
file = new File( file.getParent() );
if ( !file.exists() ) {
file.mkdirs();
}
FileWriter fw = null;
try {
fw = new FileWriter( fileName, tru... |
8491115e-3fb2-4277-839b-5ad46cf62c02 | 4 | public static boolean wordBreak(String s, Set<String> dict) {
int len = s.length();
boolean[] iswordbreak = new boolean[len + 1];
iswordbreak[len] = true;
for (int i = len - 1; i >= 0; i--) {
for (int j = i; j < len; j++) {
String word = s.substring(i, j + 1);
if (iswordbreak[j +... |
52d88dae-2573-4c21-ab81-4aa90bbbd00a | 2 | @Override
public int hashCode()
{
int res = this.propertyId.intValue();
res+=this.propertyTableNameId;
if(this.propertyClassNameId!=null)
{
res+=this.propertyClassNameId;
}
if(this.relationName!=null)
{
res+=this.relationName.hashCode();
}
return res;
} |
b0d0801e-a5be-4279-9ab0-edf2ad5e7b4e | 9 | public void update(FriendshPk pk, Friendsh dto) throws FriendshDaoException {
long t1 = System.currentTimeMillis();
// declare variables
final boolean isConnSupplied = (userConn != null);
Connection conn = null;
PreparedStatement stmt = null;
try {
// get the user-specified connection or get a connection fr... |
cabe428a-d29d-478b-a202-06d50677fc67 | 0 | public BinaryHeap() {
heap = new DynamicArray();
heapSize = 0;
} |
418aa088-2c62-4963-80f5-c254d81822e2 | 7 | public boolean find(String xmlPathQuery) {
XmlPath xmlPath = XmlPathParser.parse(xmlPathQuery);
XmlNode node;
while((node = pullXmlNode()) != null) {
if(node instanceof XmlStartElement) {
XmlStartElement startElement = (XmlStartElement) node;
Element ... |
8caa5980-96b6-4e35-bcec-b8b827268636 | 7 | public void writeToFile(String outFileName)
throws SoundException
{
/*
get an audioInputStream that represents this sound.
then, we will write from the stream to the file
*/
AudioInputStream audioInputStream = makeAIS();
AudioFileFormat.Type type = audioFileFormat.getType();
... |
beeb1911-2f65-41d2-a811-f2ebfebdbcb2 | 7 | public final static boolean finish() throws FatalError {
try {
// HTTP parameters stores header etc.
HttpParams params = new BasicHttpParams();
params.setParameter("http.protocol.handle-redirects", false);
HttpGet httpget = new HttpGet(Config.getHost() + "quests/start");
httpget.setParams(params);
... |
df5dfe62-2b0d-49dc-bd60-5e6e8acef57d | 7 | */
@Override
public void paintComponent(Graphics g) {
Object map = Toolkit.getDefaultToolkit().getDesktopProperty(
"awt.font.desktophints"); //$NON-NLS-1$
if (map != null) {
((Graphics2D) g).addRenderingHints((Map<?, ?>) map);
}
Rectangle clip = g.getClipBounds();
// Fill backgro... |
bda898d7-6a7c-4623-94d9-d2ab2d17348d | 8 | @Override
public void run() {
while(this.running) {
switch(r.nextInt(6)+1)
{
case 1:
this.lagermitarbeiter.addTeil(Lagermitarbeiter.ETeil.TEIL_ARM, this.pgnr("Arm"));
logger.log(Level.INFO, "Neuer Arm wurde angeliefert!");
case 2:
this.lagermitarbeiter.addTeil(Lagermitarbeiter... |
d2a4eef0-f3ee-49db-87de-fe82019a8548 | 5 | private static Map<String, String[][]> parseStyle(String styleText) {
String[] styleArray = styleText.split(",");
Map<String, String[][]> styleMap = null;
if (styleArray.length != 0) {
styleMap = new HashMap<String, String[][]>();
String[][] styleContentArray = null;
for (int i = 0; i < styleArray.length... |
b18160c3-a668-45c0-b148-fd616f06f97a | 3 | private void init(){
for(int i=1;i<=100000;++i){
aux[i-1]=num(i);
}
sum[0]=1;
for(int i=1;i<100000;++i){
sum[i]=sum[i-1]+(aux[i]%2!=0?1:0);
}
} |
edca79de-3b05-4466-9d16-775a4c971bb8 | 7 | @Override
public int compareTo(UpcomingEventItem o) {
if (getWhen() == null) return -1;
if (getWhen().getTime() == null) return -1;
if (o == null) return 1;
if (o.getWhen() == null) return 1;
if (o.getWhen().getTime() == null) return 1;
if (getWhen().getTime().getTimeInMillis() < o.getWhen().getTime().getT... |
be8498ea-3600-4e81-9ea2-0078bc8971b4 | 6 | public Encoder tableEncoder(String sql, String name) throws SQLiteException {
/*
* Pack peers table Table ::= SEQUENCE { name TableName, fields SEQUENCE
* OF FieldName, fieldTypes SEQUENCE OF FieldType, rows SEQUENCE OF
* SEQUENCE OF NULLOCTETSTRING }
*/
Database db = manager.getDB();
Table peer=db.... |
b1976813-ed60-4e4d-9c80-035ea93fbd7e | 3 | protected String validate(String zipCode) {
Pattern REGEX = Pattern.compile("^\\d{5}(-\\d{4})?$");
if (zipCode == null) {
throw new NullPointerException("Zip Code cannot be null!");
}
if (!strictMode || REGEX.matcher(zipCode).matches()) {
return zipCode;
... |
9dddf67b-9a5c-4e4c-a8ed-c570fe6fab36 | 1 | private void impact(int range2, int speed2) {
Point startPoint = new Point(Game.PLAYER.getX(), Game.PLAYER.getY());
Point endPoint = new Point(0, 0);
for(double i = 0; i < 2*Math.PI-0.01; i+= 0.1){
endPoint = new Point(Game.PLAYER.getX() + (int) (Math.cos(i)*range),Game.PLAYER.getY() + (int) (Math.sin(i)*r... |
22ae9ddb-7f9d-40ff-91b7-28028853644a | 2 | public boolean warpPlayer(ProxiedPlayer player) throws IOException {
ServerInfo CurrentServer = player.getServer().getInfo();
ServerInfo TargetServer = ProxyServer.getInstance().getServerInfo(
wl.getServer());
if (CurrentServer.equals(TargetServer)) {
ByteArrayOutputStream b = new ByteArrayOutputStream();... |
d59e930c-aee5-4c8c-a50e-1a31f08f7968 | 2 | public void testPropertySetSecond() {
LocalDateTime test = new LocalDateTime(2005, 6, 9, 10, 20, 30, 40);
LocalDateTime copy = test.secondOfMinute().setCopy(12);
check(test, 2005, 6, 9, 10, 20, 30, 40);
check(copy, 2005, 6, 9, 10, 20, 12, 40);
try {
test.seco... |
451b1ad0-483c-4f45-8033-542d99f00067 | 2 | public String decrypt(byte[] encondeMessage) {
int[] intText = byte2int(encondeMessage);
int sum, n, rounds, z, e, y, ind;
n = blockSize;
rounds = 6 + 52 / n;
sum = rounds * delta;
y = intText[0];
while (sum != 0) {
e = (sum >> 2) & 3;
for (ind = n - 1; ind > 0; ind--) {
z = intText[ind - 1];
... |
7c1368f5-8054-4550-b321-849e4b228b29 | 8 | void generateRandomNet(BayesNet bayesNet, Instances instances) {
int nNodes = instances.numAttributes();
// clear network
for (int iNode = 0; iNode < nNodes; iNode++) {
ParentSet parentSet = bayesNet.getParentSet(iNode);
while (parentSet.getNrOfParents() > 0) {
parentSet.deleteLastParent(instances);
... |
eb202eb2-aecd-4fad-b66d-6b79f992d2d1 | 5 | @Override protected void paintComponent ( Graphics arg0 ) {
if ( this.board.isReady ) {
for ( int i = 0 ; i < this.board.boardHeight ; i++ ) {
for ( int j = 0 ; j < this.board.boardWidth ; j++ ) {
this.grid[ i ][ j ].setChar ( this.board.charGrid[ i ][ j ] ) ;
}
}
String ... |
0ce5eb47-0d93-4ff4-8787-274f64bd3616 | 9 | public void removeNode (Tree forRemove) {
Tree parent = forRemove.getParent();
Tree leftChild = forRemove.getLeftChild();
Tree rightChild = forRemove.getRightChild();
// get highest child from removable tree
Tree highestTree = getLeftHeight(forRemove) > getRightHeight(forRemove) ? leftChild : rightChild;
... |
955af32c-9b78-47a6-9b09-5c629195c331 | 7 | public static void sort(String f1, String f2) throws FileNotFoundException, IOException {
RandomAccessFile a = new RandomAccessFile(f1, "r");
RandomAccessFile a2 = new RandomAccessFile(f1, "rw");
RandomAccessFile b = new RandomAccessFile(f2, "rw");
DataOutputStream dosb;
DataOutputStream dosa;
DataInputStre... |
a30a99a9-58ec-4e09-bc4f-13f55f389255 | 3 | @Test
public void getTwoUserByEmail() {
// 7. partialEmail이 'user'인 CalendarUser가 2명임을 확인하는 테스크 코드 작성
// [주의] public List<CalendarUser> findUsersByEmail(String partialEmail)를 테스트 하는 코드
System.out.println("\n7.------------------------------------------------");
//findUsersByEmail 메소드로 user 메일에 user가 들어가는 모든 ... |
70871e98-b658-4361-939d-64b5254c59b4 | 8 | private List<String> purseLine(final String line) {
List<String> result = new ArrayList<String>();
if (StringUtility.isNotEmpty(line)) {
StringBuilder sb = new StringBuilder();
boolean dblFlg = false;
for (int i = 0; i < line.length(); i++) {
char c = line.charAt(i);
if (dblFlg) {
if ('"' == c... |
ae541efe-ffc4-4aa5-8f5a-5c4e952fd516 | 9 | public static void main(String[] args) {
// Get command-line parameters
int m = Integer.parseInt(args[0]);
int d = Integer.parseInt(args[1]);
// Print values
System.out.println("Month: " + m);
System.out.println("Day: " + d);
// Is month and day in spring?
... |
724c884a-ca63-4b22-be72-c877d2b5b0a1 | 2 | public static int[] translate(int[] pixs, int tx, int ty, int w, int h, int ow, int oh) {
int u, v;
int[] pix = new int[ow * oh];
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
u = i + tx;
v = j + ty;
pix[v * ow + u] = pixs[j * w + i];
}
}
return pix;
} |
0226b88b-ce7b-49c6-8c68-f4624bdc59a9 | 3 | public void removeWar(String name) {
GenericObject toRemove = null;
for (GenericObject war : getWars()) {
if (war.getString("name").equals(name)) {
toRemove = war;
break;
}
}
if (toRemove != null) {
toRemove.getParent().... |
bd5367ea-8c68-4b64-ba1b-96e4ee1c75c2 | 6 | public static Update performCheck(Options rel, boolean requireRestart) {
if (requireRestart && Game.isActive()) {
int Confirmation = JOptionPane.showConfirmDialog(rel,
"Some changes will not affect the current game.\n" +
"Quit the current game and start a new one?\n" +
"Clicking \"No\" will stil... |
7051552b-ccbc-4856-857f-711a5ba695e8 | 3 | protected void header(String key, String value) {
if(! statusSent) throw new IllegalStateException("Must send status " +
"before headers");
if(headersSent) throw new IllegalStateException("Cannot send headers " +
"after data");
key = key.substring(0, 1).toUpperCase() + key.substring(1);
byte[] byt... |
bc499fdf-e2af-4081-86e9-401730ba2c0a | 4 | public Direction hitWall() {
if (pos_x + v_x < 0)
return Direction.LEFT;
else if (pos_x + v_x > max_x)
return Direction.RIGHT;
if (pos_y + v_y < 0)
return Direction.UP;
else if (pos_y + v_y > max_y)
return Direction.DOWN;
else return null;
} |
0e9ef7ec-41b3-4d57-9393-4ec43180515a | 2 | private String sha(String text) {
StringBuilder key = new StringBuilder();
try {
MessageDigest md = MessageDigest.getInstance("sha1");
md.update(text.getBytes());
for (byte b : md.digest()) {
key.append(Integer.toHexString((0xff & b) | 0xffffff00)
.substring(6));
}
} catch (Exception ex) {
... |
615fecec-37b7-4715-b84a-df8b2c3298ab | 9 | @Override
public boolean equals(Object obj) {
if (obj == this) { // simple case
return true;
}
// now try to reject equality...
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof XYDrawableAnnotation)) {
return false;
... |
19948ee1-8b6d-4535-bba7-f5bf07381a80 | 3 | protected boolean AddInventory(Inventory inventory) throws NullPointerException{
if (null == Inventory.libraryMaterials) {
return false;
}
try{
if (Inventory.libraryMaterials.containsKey(Inventory.libraryMaterialID)) {
return false;
}
... |
17f96ac0-eb8f-49f5-82e5-6e14a972a6b6 | 3 | public void complexLoadFromTag(DataTag tag)
{
try
{
int size = tag.getInteger("Size", 0);
for (int i = 0; i < size; i++)
{
DataTag t = tag.getTag("" + i);
Class<?> c = Class.forName(t.getString("Class Name", null));
Sprite s = (Sprite) c.newInstance();
set(i, s);
}
}
catch (Exceptio... |
f3111151-be81-48d5-9a98-1e04bf005cd0 | 5 | private ITrieNode[] getMaxChild(final HashMap<Integer,Integer> frontierMap) {
// returns two largest weight nodes in order
HashMap<Character, ITrieNode> availableChildren = getAvailableChildren(frontierMap);
if (availableChildren == null) {
return null;
}
ITrieNode re... |
c2b3673b-0288-4dbe-a1c8-84700276a83f | 5 | public void create(Comment comment) throws RollbackFailureException, Exception {
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
Article newsID = comment.getNewsID();
if (newsID != null) {
newsID = em.getReference(newsI... |
309f2684-2aee-457b-a3f3-9d7f7aa7a388 | 5 | private Entry<Point, Item> pickBestMove(Entry<Point, Item> itemA,
Entry<Point, Item> itemB) {
Entry<Point, Item> best = itemA;
if (greenEnergy <= pinkEnergy) {
if (itemB.getValue() != null) {
best = itemA.getValue().greenGain * itemA.getValue().quantity > itemB.getValue().greenGain * itemB.getValue(... |
6db2c699-44a2-4fdd-b603-5bee857e609c | 1 | public String[][] makeNewTableArray(ArrayList<HostRoom> L) {
String[][] array = new String[L.size()][4];
for (int i = 0; i < array.length; i++) {
array[i][0] = L.get(i).GameName;
array[i][1] = Integer.toString(L.get(i).ClientCount) + "/"
+ Integer.toString(L.get(i).MaxSize);
array[i][2] = L.get(i).Roo... |
53bbdb58-dd48-4a17-8987-d0cc490bbe3f | 4 | private boolean isRankConsistent(STNode<Key, Value> x)
{
for (int i = 0; i < size(x); i++)
if (i != rank(select(i)))
{
return false;
}
for (Key key : keys())
if (key.compareTo(select(rank(key))) != 0)
return false;
return true;
} |
d5c118f5-140a-49fa-9a44-e29aa6588a3c | 5 | @Override
public Account createAccount(Account account) {
Connection cn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
cn = ConnectionHelper.getConnection();
ps = cn.prepareStatement(QTPL_INSERT_ACCOUNT, new String[] { "account_id" });
... |
6a957e3b-4a5e-4e80-bdb2-7676ef22a4cd | 9 | @Override
public void paint(Graphics g) {
// the healthbar
g.setColor(Color.BLACK);
g.drawRect(x + 3, y - 10, 20, 5);
g.setColor(Color.RED);
g.fillRect(x + 4, y - 9, 19, 4);
g.setColor(Color.GREEN);
g.fillRect(x + 4, y - 9,
(int) (((enemy.getHP() * 1.0) / (enemy.defHP * 1.0)) * 20) - 1,
4);
/... |
f122e03e-24c2-4fb5-b63e-51a7f8db9833 | 7 | public static void main(String[] args) {
// Instantiate a Scanner object
Scanner sc = new Scanner(System.in);
String choice ="y";
System.out.println("Welcome to the Loan Calculator");
System.out.println("");
System.out.println("DATA ENT... |
f8b20be6-63b5-439d-bd85-3d06bb3d74ec | 5 | public Character shoot(Matrix matrix, Player player, int ns, int shootX, int shootY) {
int nx = Math.round(shootX/ns);
int ny = Math.round(shootY/ns);
Node node = matrix.getNode(nx, ny);
System.out.println("testing node at " + "(" + node.getX() + ":" + node.getY() + ")");
if (!(node instanceof Square)) {
r... |
133c83b7-927d-475c-a545-fff2343d7464 | 3 | @Override
public Command receive() {
// Process the history
if (m_histo.size() != 0) {
return m_histo.remove(0);
}
System.out.println("[CLIENT] Wait for some message ...");
try {
// Parse the message
ObjectMessage msg = (ObjectMessage) m_sub.receive();
if (msg.getObject() instanceof Command)
... |
bfc7c4bf-8894-4f86-a04b-9e0dfdb1bf47 | 2 | private void checkUpdate(boolean showNoUpdate) throws InterruptedException, ExecutionException, MalformedURLException{
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<Boolean> task = null;
task = executor.submit(new Updater(lastVersionURL));
if (task.get())
showMessage(("New version a... |
21fccc35-d7f6-461a-923b-9bf6351b32bd | 5 | public void endElement(String uri, String localName, String qName)
throws SAXException {
// sort out element name if (no) namespace in use
String elementName = localName;
if ("".equals(elementName)) {
elementName = qName;
}
if (elementName.equals("book")) {
bookList.addBook(currentBook);
} else if(... |
abd85fc8-a120-4227-8cfc-03ab7cac5cb6 | 7 | public void run() {
try {
m_visual.setAnimated();
m_Saver.setInstances(m_dataSet);
if (m_logger != null) {
m_logger.statusMessage(statusMessagePrefix() + "Saving "
+ m_dataSet.relationName() + "...");
}
m_Saver.writeBatch();
... |
7da41cd9-9b6d-4563-968c-748796edc0af | 6 | public boolean isValid() throws Exception {
int virtualGraphs=0;
int defaultGraphs=0;
for (NamedGraph g:graphs){
if (g.getDepth()==-1){
virtualGraphs++;
if (virtualGraphs>1){
throw new Exception("Multiple virtual graphs");
}
}
if (g.getName().length()==0){
defaultGraphs++;
if (de... |
61b72dcd-a8d2-48c8-a848-07cc80c19012 | 2 | public void add(PlanObject plan) {
if (insertPointer == plans.length) {
PlanObject[] help = plans;
plans = new PlanObject[insertPointer + 1];
for (int i = 0; i < help.length; i++) {
plans[i] = help[i];
}
}
plan.setPlanManager(this);
plans[insertPointer] = plan;
insertPointer++;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.