method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
2b600598-c9c0-44bf-8f8b-5037832e6f83 | 0 | @Test
public void testRemoveBlackMarker() {
System.out.println("removeBlackMarker");
Cell instance = new Cell(0,0);
instance.addBlackMarker(0);
instance.addBlackMarker(1);
instance.addBlackMarker(2);
instance.addBlackMarker(3);
instance.addBlackMarker(4);
... |
46c5df15-61fd-4a28-bac3-e05e0037f5f3 | 6 | public boolean studentFulfillsDegreeRequirements(int studentId, int degreeId) {
if(!isValidId(studentId) || !isValidId(degreeId)) {
return false;
}
Student student = studentDao.getStudent(studentId);
Degree degree = degreeDao.getDegree(degreeId);
if (student != null && degree != null) {
for (C... |
d9868f63-a4a6-4e4b-bab2-8cb09479d33b | 8 | private ArrayList<Cell> getVisitedNeighbors(Cell curCell) {
ArrayList<Cell> neighbors = new ArrayList<Cell>();
//Look at top...
if(curCell.getX() - 1 >= 0 && !cellMaze[curCell.getX() - 1][curCell.getY()].isVisited())
neighbors.add(cellMaze[curCell.getX() - 1][curCell.getY()]);
//Look at bottom...
... |
157d4b3f-6c7b-431f-b810-512a7829ac36 | 0 | public void setServeurBd(String serveurBd) {
this.serveurBd = serveurBd;
} |
b16fad51-0a40-4285-818f-1f3e1864ec3b | 3 | @Override
public <T> Invoker<T> select(List<Invoker<T>> invokers, TpURL tpURL, Invocation invocation) throws RpcException {
if (invokers == null || invokers.size() == 0) {
return null;
}
if (invokers.size() == 1) {
return invokers.get(0);
}
return doSelect(invokers, tpURL, invocation);
} |
e86de740-e9f8-470e-bc97-b57ad8b1366a | 4 | private boolean patternSame( byte[] pattern )
{
if ( this.pattern != null && this.pattern.length == pattern.length )
{
for ( int i=0;i<pattern.length;i++ )
if ( pattern[i] != this.pattern[i] )
return false;
return true;
}
else
return false;
} |
cf567fa0-df52-42b8-92a4-01b5ca1bca34 | 1 | @Test
public void testPutTracking()throws Exception{
Tracking tracking = new Tracking("RC328021065CN");
tracking.setSlug("canada-post");
tracking.setTitle("another title");
Tracking tracking2 = connection.putTracking(tracking);
Assert.assertEquals("Should be equals title", "... |
7d6eebe7-8b76-4117-8c90-a87c61e07e5e | 5 | public void cmdBids(CommandSender sender, String[] args) {
if( args.length < 2 ) {
sender.sendMessage(Conf.colorMain + "Usage:");
sender.sendMessage(Conf.colorAccent + "/ee bids <material name>");
return;
}
Material material = materials.get(args[1]);
if( material == null ) {
sender.sendMessage... |
b1603a03-df0d-47ac-9746-57b204c95293 | 4 | public static void main(String[] args) throws IOException,
InstantiationException, IllegalAccessException, InterruptedException, ExecutionException {
System.out.println("Running benchmark. Press any key to continue.");
System.in.read();
Map<Class<?>, Map<String, String>> keyLookupCl... |
e9febcb1-1e31-41b5-948e-8361fe59cc63 | 2 | private synchronized static void cleanUpAllExpiredSession() {
Iterator it = sessions.entrySet().iterator();
long currTime = new Date().getTime();
while(it.hasNext()) {
Map.Entry pair = (Map.Entry)it.next();
Session iSession = (Session)pair.getValue();
if(iSession.isExpired(currTime)) {
it.remove();
... |
85f30710-28fc-4ba3-8ca4-a96d695f40bc | 8 | private String sendRequest(String endpoint, Map<String, String> params) {
try {
StringBuffer paramBuffer = new StringBuffer();
Iterator<Map.Entry<String, String>> it = params.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> pair = it.next();
paramBuffer.append(URLEncoder.encode... |
af33cdcc-fa2d-4d40-8452-6f36408264d6 | 3 | public void Mstep(List<Instance> instances) {
int insIndex = 0;
List <Double> counts = new ArrayList<Double>();
List <FeatureVector> newClusters = new ArrayList<FeatureVector>();
// init the counts and new clusters.
for (int i = 0 ; i < clusters.size() ; i++ ) {
counts.add(0.0);
newClusters.add(new Feat... |
3078191d-485b-4c17-8336-eff4f33dac68 | 7 | protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
ArrayList<CompRequest> comp = new ArrayList<CompRequest>();
ArrayList<PaidRequest> paid = new ArrayList<PaidRequest>();
response.setContentType("text/html;char... |
0bf05541-ab02-4b5d-afe9-1785e6ff160a | 1 | final public CycList nonAtomicSentenceDenotingDenotationalTerm(boolean requireEOF) throws ParseException, java.io.IOException, UnsupportedVocabularyException {
CycList val;
val = nonAtomicDenotationalTerm(false);
eof(requireEOF);
{if (true) return val;}
throw new Error("Missing return statement in fun... |
3e3ecb03-ea8d-4598-bbb0-d498fce2f8e3 | 5 | Object[] parameterForType(String typeName, String value, Widget widget) {
if (typeName.equals("org.eclipse.swt.widgets.TreeItem")) {
TreeItem item = findItem(value, ((Tree) widget).getItems());
if (item != null) return new Object[] {item};
}
if (typeName.equals("[Lorg.eclipse.swt.widgets.TreeItem;")) {
S... |
9ca62851-1d31-454d-9030-8949d4ff56dd | 0 | private void initialize() {
this.history = new DefaultComboBoxModel();
// Setup North Panel
JPanel north_panel = new JPanel();
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
north_panel.setLayout(gridbag);
LOCATION = "Location"; // GUITreeLoader.reg.... |
3c1a3fc0-296b-4694-90bf-6d9d7014e43a | 4 | private void moveSnakeHeadToTheOtherSideOfTheWorld(SnakePiece head)
{
int x = head.getX();
int y = head.getY();
if (x < 0)
{
head.setX(width);
}
else if (x > width)
{
head.setX(0);
}
if (y < 0)
{
head.setY(height);
}
else if (y > height)
{
head.setY(0);
}
} |
90e3880b-992a-41ec-b9fd-67fe8d2a90ae | 5 | public void rotateRight(RBNode x) {
// pushing node x down and to the Right to balance the tree. x's Left child (y)
// replaces x (since x < y), and y's Right child becomes x's Left child
// (since it's < x but > y).
RBNode y = x.getLeft(); // get x's Left node, this becomes y
// set x's... |
e039b114-05c5-4403-ab6f-fd464215e110 | 8 | * @Post: Queries the user for what type to upgrade the pawn to, and does so
* @Return: None
*/
private void upgradePawn(Piece thePiece) {
int whatToUpgradeTo=-1;
Object answer = null;
Object[] possibilities = {"Queen", "Knight", "Rook", "Bishop"};
if(isAI(isWhitesTurn()))//then it is the AI of the current... |
fe2a07e6-840e-49ec-8460-1f6019694ff5 | 0 | public String toString()
{
return "Employee[name=" + name + ",salary=" + salary + ",hireDay=" + hireDay + "]";
} |
23405934-243a-43cf-b3bf-5e7514c62d3b | 7 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
final MOB target=this.getTarget(mob,commands,givenTarget);
if(target==null)
return false;
if(!super.invoke(mob,commands,givenTarget,auto,asLevel))
return false;
boolean success=proficienc... |
265de792-d8e9-4bb5-a62d-857ea2d54434 | 7 | public static void main(String[] args) {
int port = 8888;
Socket socket = null;
BufferedReader in = null;
PrintWriter out = null;
try {
socket = new Socket("127.0.0.1", port);
in = new BufferedReader(new InputStreamReader(
socket.getInputStream()));
out = new PrintWriter(socket.getOutputStream()... |
31d9cf55-3e90-405e-927d-1dca5de15986 | 6 | private String moveCardOntoTopRow(List<Card> from, int boardIndexTo, int listIndexFrom) {
List<Card> pile = topRow.get(boardIndexTo);
Card fromTop = from.get(listIndexFrom);
if (pile.size() == 0) {
if (fromTop.getRank() == Card.Rank.ACE) {
pile.add(from.get(listIndex... |
d5e2db3b-06b3-4291-af67-3ba0de82647e | 5 | public void blackTurn(int sx, int sy, int ex, int ey) {
int piece = board.getPiece(sx, sy);
board.blackTurn(sx, sy, ex, ey);
if (board.getMoveB()) {
setInfo(0);
turns++;
if (cm.canAttackKing(board.getBoard(), piece, ex, ey)) {
... |
f9e720af-bcf6-45a7-8ba9-56c2994588bc | 1 | private static final double getPositionNearSource( int amountOfPixelsAway, TextStrategyParameters parameters ) {
double length = parameters.getPath().getTotalLength();
if( length == 0 ) {
return 0;
}
double position = amountOfPixelsAway / length;
return Math.max( 0, Math.min( 0.5, position ) );
} |
ef7706b5-2210-4a02-b866-47d3e892abed | 0 | public GameChrono(GameCanvas gc, ProBotGame game) {
this.gc = gc;
this.game = game;
} |
31a9b915-fc45-4e27-bbbc-110b41e1ea80 | 9 | public Object calculate(GraphModel g) {
ZagrebIndexFunctions zif = new ZagrebIndexFunctions(g);
ZagrebIndexFunctions zifL = new ZagrebIndexFunctions(LineGraph.createLineGraph(g));
RenderTable ret = new RenderTable();
Vector<String> titles = new Vector<>();
titles.add(" p ");
... |
a27ade8d-14b2-42b6-87a4-2bd218e63c49 | 4 | @Override
public void caseAVetorVar(AVetorVar node)
{
inAVetorVar(node);
if(node.getIdentificador() != null)
{
node.getIdentificador().apply(this);
}
if(node.getColcheteE() != null)
{
node.getColcheteE().apply(this);
}
if(no... |
facb6590-45f8-44e9-94c0-837d9c08052c | 3 | public final boolean postSync( Message event ){
int dispatchedCount = 0;
MessageType type = event.getType();
for( MListener listener : ELIST ){
if( listener.isSupported( type ) ){
listener.update( event );
++dispatchedCount;
}
}
if( dispatchedCount == 0 ){
... |
1264e805-fb0a-4e07-8b87-fd7f4a52af13 | 0 | private void recordActive() {
this.activeSince = new Date().getTime();
} |
3e615326-7d18-46c1-a045-1ed56552dd24 | 6 | public String diff_toDelta(LinkedList<Diff> diffs) {
StringBuilder text = new StringBuilder();
for (Diff aDiff : diffs) {
switch (aDiff.operation) {
case INSERT:
try {
text.append("+").append(URLEncoder.encode(aDiff.text, "UTF-8")
.replace('+', ' ')).append("\t");
} catch (UnsupportedEncod... |
167a1dc5-bb0c-4b33-a664-dac76b09bc44 | 6 | public void method464(Model model, boolean flag)
{
anInt1626 = model.anInt1626;
anInt1630 = model.anInt1630;
anInt1642 = model.anInt1642;
if(anIntArray1622.length < anInt1626)
{
anIntArray1622 = new int[anInt1626 + 100];
anIntArray1623 = new int[anInt1626 + 100];
anIntArray1624 = new int[anInt1626 +... |
6f9ca9ed-9230-4141-aa94-74c5ed253d28 | 4 | private String md5Encode(String plainText) {
String re_md5 = new String();
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(plainText.getBytes());
byte b[] = md.digest();
int i;
StringBuffer buf = new StringBuffer("");
for (int offset = 0; offset < b.length; offset++) {
i =... |
51bb5e28-528e-4324-a00c-656cea5b3d74 | 7 | @Override
public void write(File file) throws IOException {
FileOutputStream fout = new FileOutputStream(file);
DataOutputStream dout = new DataOutputStream(fout);
//check if charFrequencies should be stored as a byte, short, or int
byte dataType = 0;
for(int i : charFrequencies) {
if(i > Short.MAX_VAL... |
0f26ace6-08fa-4631-b72d-4a25237008e0 | 0 | public void setCheckinDate(Date checkinDate) {
this.checkinDate = checkinDate;
} |
07e27054-689c-4433-8132-8b3b1619b3d1 | 9 | public void create(PypAdmAgend pypAdmAgend) {
if (pypAdmAgend.getPypAdmAsistConList() == null) {
pypAdmAgend.setPypAdmAsistConList(new ArrayList<PypAdmAsistCon>());
}
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
... |
01056162-5540-4153-9018-60b737469f9f | 0 | public void setText(String s)
{
myText = s;
refresh();
} |
319bdd7d-d3ff-45ab-8b62-c329723f2c65 | 4 | private File searchOtherFiles(File folder, String searchFile) {
File retVal = null;
for (File file : reverseArray(folder.listFiles())) {
if (file.isDirectory()) {
retVal = searchOtherFiles(file, searchFile);
if (retVal != null) {
return retVal;
}
} else {
if (file.getName().equals(search... |
6936454d-a6ce-4eef-bdfe-452acb4a5c26 | 7 | public Enumeration listOptions() {
Vector result;
Enumeration enm;
String param;
SelectedTag tag;
int i;
result = new Vector();
enm = super.listOptions();
while (enm.hasMoreElements())
result.addElement(enm.nextElement());
param = "";
for (i = 0; i < TAGS_ALGORITHM... |
010ff8dd-0546-4fa3-befa-295f48be870d | 3 | public void loadSound(String fileName)
{
AudioInputStream audioIn = null;
try
{
URL url = Main.class.getResource(fileName);
audioIn = AudioSystem.getAudioInputStream(url);
Clip player = AudioSystem.getClip();
player.open(audioIn);
s... |
99a788b7-3809-4149-a016-ae0230248826 | 4 | public void limitMaximumSpeed() {
// prevent speed from getting to fast
if (xOffset > MAX_SPEED)
xOffset = MAX_SPEED;
if (xOffset < -MAX_SPEED)
xOffset = -MAX_SPEED;
if (yOffset > MAX_SPEED)
yOffset = MAX_SPEED;
if (yOffset < -MAX_SPEED)
yOffset = -MAX_SPEED;
} |
f1a0c854-267c-4b7e-a349-dd2564a027dd | 3 | public static Quiz[] getQuizzesbyUser(int UserId, boolean Completed)
{
try {
String query = String.format("SELECT * FROM QUIZ\n" +
"where quizid %s in (select quizid from quizresult where \n" +
"userid = %d)", Completed? " " : "not", UserId);
ResultSe... |
c71f6de1-c0ea-4e04-b531-c1d62a36edd4 | 9 | public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
if (l1 == null)
return l2;
if (l2 == null)
return l1;
ListNode head = new ListNode(0);
ListNode current = head;
ListNode previous = null;
int carry = 0;
while (l1 != null && l2 !=... |
95ea9236-e378-45db-93b9-c5d9f6372ad6 | 9 | public static void main(String[] args) {
try {
Tools[] rtss = new Tools[]{new RepositoryTools("repo"), new CLIEntryTools("entry"), new MacroTools("macro"), new CLIRoutineTools("routine"), new CLIUtilityTools("util")};
CLIParams params = getCommandLineParamaters(args);
if (params == null) return;
Strin... |
babb86f7-a002-40c4-ac9f-6818508cc4cf | 2 | @Override
public String toString()
{
StringBuffer ret = new StringBuffer("");
// Do the static stuff
ret.append("#T#" + trackNumber + "~" + title + "~" + lengthInSeconds);
// Do the personnel
Iterator<Artist> pIt = personnel.iterator();
while (pIt.hasNext())
ret.appe... |
abada58b-b79a-449c-9c46-c6a99dcaef7f | 2 | public static void drawBufferedObject(BufferData bd)
{
GL2 gl = RobotPart.gl;
gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL2.GL_NORMAL_ARRAY);
if(bd.getTextureId() != -1)
gl.glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
... |
85b18b99-1cd9-4799-8400-a598f0e6a5e8 | 1 | public DNode getNext(DNode v) throws IllegalStateException{
if(isEmpty()) throw new IllegalStateException("List is empty");
return v.getNext();
} |
f948e764-a156-4bcb-8b9a-fa78ba55598c | 1 | public void getConnected() {
cpds = new ComboPooledDataSource();
try {
cpds.setDriverClass("com.mysqljdbc.Driver");
} catch (PropertyVetoException e) {
e.printStackTrace();
}
cpds.setJdbcUrl("jdbc:mysql://localhost:3456/bw_web");
cpds.setUser("cbw");
cpds.setPassword("test");
cpds.setMinPoolSiz... |
66d29d77-474a-4fd4-8e1d-0a39722935dd | 6 | @Test
public void testSetupFromOpenID() {
CredentialConnection conn = CredentialConnection.getInstance();
conn.setDebug(true);
try {
conn.setupFromOpenID("hasdfttps://asldhlakjhs");
fail("Malformed URL!");
} catch (MalformedURLException e) {
//ok
... |
3529c11a-b338-4d7d-8922-d64e90306c66 | 9 | private void checkNewPos() {
if (Main.getGamestate().getMonster().awake) {
Main.getGamestate().getMonster().move(Main.getGamestate().getPlayer());
}
for (int i = 0; i <= 4; i++) {
if (Main.getGamestate().getEntities().containsKey(RenderPriority.getRenderPriorityFromId(i))) {
for (Entity entity : Main.ge... |
8395a209-c424-4bc6-b4a5-a82dc98cf436 | 5 | public void removeSelected() {
if (getSelectionPath() != null) {
Object o = getSelectionPath().getLastPathComponent();
if (o != null && o instanceof DefaultMutableTreeNode) {
DefaultMutableTreeNode n = (DefaultMutableTreeNode) o;
if (n.getUserObject() != null
&& n.getUserObject() instanceof NodeLa... |
7a569d6b-9989-40ee-98d9-60861449b4e9 | 7 | @Override
public void undo() throws CannotUndoException {
super.undo();
if (selectedManipulable instanceof Part) {
Shape shape = selectedManipulable.getShape();
if (shape instanceof TransformableShape) {
TransformableShape s = (TransformableShape) shape;
switch (scaleDirection) {
case 0:
s.s... |
adfe49f2-434a-4a28-bc80-4b46f8b5ad61 | 3 | public void encodeDirectBits(int v, int numTotalBits) throws IOException {
for (int i = numTotalBits - 1; i >= 0; i--) {
Range >>>= 1;
if (((v >>> i) & 1) == 1) {
Low += Range;
}
if ((Range & Encoder.kTopMask) == 0) {
Range <<= 8;
... |
81c2b22d-8dc9-4ca1-92b2-8f5790b6cb8f | 7 | void checkCommands1()
{
int i;
Entity thnStore;
String strStore=null;
for (i=0;i<vctSide1.size();i++)
{
thnStore = (Entity)vctSide1.elementAt(i);
if (!thnStore.vctCommands.isEmpty())
{
strStore = (String)thnStore.vctCommands.elementAt(0);
thnStore.vctCommands.removeElementAt(0);
if (strS... |
f540c80a-9cf1-41b6-939d-cffb23566495 | 1 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html");
final int rID = Integer.parseInt(request.getParameter("rID"));
PrintWriter out = response.getWriter();
if (new Control(rID).startPlagiatsSearch(rID))
{
... |
7aedbc5e-c575-45a2-9433-a979ceab59f8 | 3 | public void act() {
// This function handles all of an Agents' behavior in
// any given step.
// First, check if the Agent has enough energy to survive
// the step, otherwise remove it.
if (energy < metabolism) {
remove();
} else {
// Let the Agent kn... |
4554a927-38df-47b5-8850-a232a829068a | 3 | Shard build(Config config) throws IOException {
NestedShard root = new NestedShard();
for (Map.Entry<String, ConfigValue> entry : config.root().entrySet()) {
String key = entry.getKey();
Shard shard = EMPTY_SHARD;
if (ConfigValueType.STRING.equa... |
57befd42-2c56-4173-b72e-7efb12acfb8e | 9 | private void updateStateTellCountryFound(List<Keyword> keywords, List<String> terms) {
//We came here due to a jump, so the Ingredient should have been passed, if not there's an error
if (keywords != null && !keywords.isEmpty()) {
for (Keyword kw : keywords) {
if (kw.getKeywordData().getType().equals(KeywordT... |
c8114d6d-9e9f-40f0-9236-ce53e0abcec1 | 5 | static String locDesc(Description descr, Locale l) {
if (l == null) {
return descr.value();
}
if (l.getLanguage().equals("en")) {
return descr.en().isEmpty() ? descr.value() : descr.en();
} else if (l.getLanguage().equals("de")) {
... |
65a86f02-15d2-44f3-8a09-e5b2d913b4a2 | 7 | public Screen createNew() {
try {
Constructor<? extends Screen> c = clazz.getDeclaredConstructor(new Class[] {});
return c.newInstance();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printSta... |
b274f057-77c4-42f2-9751-5f91ce6a0b0e | 4 | public static String getBookID(){
try {
ResultSet rs=DB.myConnection().createStatement().executeQuery("select max(BookID) from book");
while(rs.next()){
int ongoingId=(rs.getInt(1));
int nextId=ongoingId+1;
maxid=Integer.toString(nextId);
... |
3d4986cb-ac1d-4117-88af-236bc35f4284 | 4 | public void run() {
/////////////////////////////////////////////////////
// For ease of I/O (since we haven't yet discussed
// binary packet data), convert the distance vector into
// a String so it can be read using a Scanner:
//////////////////////////////////////////////////... |
48774d34-6736-4f38-b754-5cf9d17ede44 | 0 | public void setjLabel1(JLabel jLabel1) {
this.jLabel1 = jLabel1;
} |
12a84be5-55c8-4b25-8b52-719b0c84148c | 4 | public void save()
{
if(this.chunkFile == null)
{
log.warning("Chunk file not found. You might want to check that if you want to save anything.");
return;
}
try
{
this.chunks.save(this.chunkFile);
}
catch(IOException ex)
... |
780f8949-a978-44da-b418-903744ea8b21 | 9 | public void excute(Minecart minecart, MinecartControl mc, String... job) {
if (!(minecart instanceof InventoryHolder) || minecart instanceof PoweredMinecart) {
return;
}
InventoryHolder invMinecart = (InventoryHolder) minecart;
HashSet<ItemStack> itemStacks = mc.getUtils()... |
454ca003-6eea-452f-8f43-5449fc1fe875 | 6 | @Override
public ReduceOutput call(){
ReduceOutput reduceResult = new ReduceOutput(mapOut.elementAt(0).fileName, in.NC);
for (int i = 0; i < mapOut.size(); i++) {
reduceResult.wordCount += mapOut.elementAt(i).wordCount;
Iterator it = mapOut.elementAt(i).docVector.entrySet().i... |
0a21ff3a-cba0-4b70-8f93-6e66b49722ff | 9 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Camion other = (Camion) obj;
if (this.carga != other.carga) {
return false;
}
... |
fbd460a1-5493-4654-ab91-6e985259a88a | 1 | public FreebaseUrl(String url){
super(url);
Properties props = new Properties();
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("secrets.properties");
try{
props.load(inputStream);
key = props.getProperty("omnom.freebase.apikey");
}
catch(IOException ex){
ex.printStackTra... |
5bdfe686-7eae-477d-b571-a460c15217fe | 6 | private static void testBoundaries() {
int[] boundaries = {
1602,
540,
488,
238,
245,
258,
430,
441,
440,
441,
441,
422,
298,
430,
1000};
int[] histogram = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
Hand h;
for(int i = 0; i < 1000000; i++) {
if(i % 10000 == 0... |
e7b35fb8-8df6-40c3-acc8-51c5c477a8e4 | 9 | public void render(Screen screen) {
if (getDir() == 0)
sprite = Sprite.zombie_up;
if (getDir() == 1)
sprite = Sprite.zombie_right;
if (getDir() == 2)
sprite = Sprite.zombie_down;
if (getDir() == 3)
sprite = Sprite.zombie_left;
if (dead)
sprite = Sprite.zombie_dead;
screen.renderItem(x - 16, y... |
34ceb5eb-4a46-49fd-b1db-6ef18e99ecc8 | 3 | public void shrink (int maximumCapacity) {
if (maximumCapacity < 0) throw new IllegalArgumentException("maximumCapacity must be >= 0: " + maximumCapacity);
if (size > maximumCapacity) maximumCapacity = size;
if (capacity <= maximumCapacity) return;
maximumCapacity = ObjectMap.nextPowerOfTwo(maximumCapacity);
... |
54690fde-c66d-435a-94e2-210e66c3e005 | 6 | public void initHSLbyRGB( int R, int G, int B )
{
// sets Hue, Sat, Lum
int cMax;
int cMin;
int RDelta;
int GDelta;
int BDelta;
int cMinus;
int cPlus;
pRed = R;
pGreen = G;
pBlue = B;
//Set Max & MinColor Values
cMax = iMax( iMax( R, G ), B );
cMin = iMin( iMin( R, G ), B );
cMinus = c... |
c0e82d8a-9f6e-4547-8499-eac6ba129fa4 | 1 | @Override
public long spawnBoss(String bossData) {
super.spawnBoss(bossData);
GameActor a = Application.get().getLogic().createActor(bossData);
PhysicsComponent pc = (PhysicsComponent)a.getComponent("PhysicsComponent");
pc.setLocation(x + Display.getWidth() + 100, y + 200);
p... |
e0fece9a-066a-46c6-bf80-ef66d0508770 | 9 | public boolean execute()throws MalformedURLException,IOException,TransactionException{
Transaction tr;
int code;
do{
tr=new Transaction(host,path,port);
if(tr.execute()){
code=tr.getCode();
switch (code){
cas... |
e5bd8522-8170-46c1-8006-b70311ea67f2 | 7 | @Override
public void sawOpcode(int opcodeSeen) {
boolean check = true;
String sigOperand = "";
try
{
sigOperand = getSigConstantOperand().toString();
}
catch(IllegalStateException e)
{
check = false;
}
if (check == true && opcodeSeen == INVOKESTATIC && getClassConstantOperand().equals("java/... |
6ca17571-7677-444a-848e-6aa96d747f43 | 0 | @Override
public int getType() { return BuildingType.FARM.ordinal(); } |
58875367-8312-43d1-b151-bbf99f0a12a8 | 6 | public Animation(BufferedImage step1, BufferedImage step2, BufferedImage step3){
if(step1 == null || step2 == null || step3 == null) {
if(step1 == null) System.err.print("Step 1 was NPE. Address: " + this + "\n");
if(step2 == null) System.err.print("Step 2 was NPE. Address: " + this + "\n");
if(step3 == null... |
b6d554d8-7dc6-4370-bfcd-ea18760676b4 | 3 | private void updateNeededMoney(int amount) {
int money = this.money + amount;
if(money < 0) {
neededMoney -= money;
} else if(neededMoney > 0) {
neededMoney -= money;
if(neededMoney < 0) {
neededMoney = 0;
}
}
} |
9b92377d-156a-4ec4-8559-f51ee052f69e | 0 | public void addPredator(Animal animal) {
predators.add(animal);
} |
009e1339-6df0-46e0-843e-c7ffa8872288 | 4 | public JSONObject toJSONObject(JSONArray names) throws JSONException {
if (names == null || names.length() == 0 || this.length() == 0) {
return null;
}
JSONObject jo = new JSONObject();
for (int i = 0; i < names.length(); i += 1) {
jo.put(names.getString(i), this.... |
be8d7a04-a996-4807-bad6-cf7f62d4ac79 | 3 | @Override
public void doTag() throws JspException {
JspWriter out = getJspContext().getOut();
// sorge für Verbindung zur Datenbank
FilmothekModel model = new FilmothekModel();
UserBean borrower;
try {
// gibt das Rückgabedatum aus, falls der Film ausgeliehen is... |
454f0a66-704d-4b8d-a5d8-b5085c99faab | 1 | private void promptForMatchSave() {
int chosenOption = JOptionPane.showConfirmDialog(this, "Save the current game before closing it?", "Quit without saving?",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (chosenOption == JOptionPane.YES_OPTION) {
showSaveDialog();
}
} |
5363d8d0-1acf-458b-b983-9bfda23aadf8 | 3 | @Override
public void reactPressed(MouseEvent e) {
if (isPressed)
return;
super.reactPressed(e);
if (StateMachine.getState() == ProgramState.SONG_PLAYING) {
StateMachine.setState(ProgramState.EDITING);
theStaff.stopSong();
} else if (StateMachine.g... |
63257a54-ed1c-4f94-8ae2-0584a5991717 | 5 | public static void listPlayersHomes( BSPlayer player ) throws SQLException {
if ( player.getHomes().isEmpty() ) {
player.sendMessage( Messages.NO_HOMES );
return;
}
boolean empty = true;
for ( String server : player.getHomes().keySet() ) {
String homes... |
499a1f27-22a0-436a-87f3-e55d7100bed2 | 3 | public void checkConnection() throws Exception
{
if (!socket.isConnected())
{
//fixed
if(Server.mapTest.containsKey(socket))
{
Server.mapTest.remove(socket);
}
//fixed
for (Map.Entry<Socket,User> entry: Server.mapTest.entrySet())
{
Socket temp = entry.getKey();
PrintWriter temp... |
2944b4fe-7a23-4868-be8b-cae37839ed4d | 3 | static boolean check(int r, int c) {
return r >= 0 && r < 4 && c >= 0 && c < 4;
} |
d8b072ec-f0d9-454d-a093-aab2b5798a26 | 2 | private void tblEmployeeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblEmployeeMouseClicked
int row = tblEmployee.convertRowIndexToModel(tblEmployee.getSelectedRow());
int personeelsnummer = Integer.parseInt(tblEmployee.getModel().getValueAt(row, 0).toString());
selectedEmploy... |
615b055a-75fc-4a6b-a58d-137fea3ec90c | 5 | public CycList deleteDuplicates() {
if (this.isProperList) {
if (this.contains(this.dottedElement)) {
this.setDottedElement(null);
}
}
for (int i = 0; i < this.size(); i++) {
for (int j = i + 1; j < this.size(); j++) {
if (this.get(i).equals(this.get(j))) {
this.r... |
408d5aee-8aea-447e-a915-0528c0149ada | 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... |
a659c03e-c0fd-4825-9250-9f864ad211bc | 8 | public static boolean wordBreak(String s, HashSet<String> dict) {
int len = s.length();
boolean res = false;
//String tmpStr = s;
Iterator<String> iterator=dict.iterator();
String[] str = new String[len*len];
int[] idx = new int[len*len];
int i=0;
int tmpidx;
String repStr = "";
int nextStart = 0;
... |
656af2a3-2ab7-4fc2-8996-c8d1447f981e | 4 | @Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attr) {
if (attr.isRegularFile()) {
String name = "" + file;
if (name.endsWith(".txt")) {
for (JSONArray comments : extractor.extractFromCrawler(file, related)) {
this.docs.addJSONComments(comments);
}
} else if (Characte... |
459398b5-cb09-46f1-ac53-9dfea2e07a0e | 4 | @Override
public void initTableModel(JTable table, List<Users> list) {
//Формируем массив пользователей для модели таблицы
Object[][] usersArr = new Object[list.size()][table.getColumnCount()];
int i = 0;
for (Users user : list) {
//Создаем массив для пользователя
... |
f5f8f685-5b57-4a87-ae8c-de1ad8d71261 | 1 | public static <R,T> R reduce(Collection<T> c, Function2<R,T> f, R z) {
for (T e : c) {
z = f.apply(z, e);
}
return z;
} |
6f4d8c6c-af7f-4281-9a0a-0b63522459f8 | 2 | public boolean wordExists(final String word, final List<String> words){
for (final String current : words) {
if( word.equalsIgnoreCase(current) ) {
return true;
}
}
return false;
} |
a11514ef-61a6-4529-854c-333c428e07fa | 5 | private ImageProcessor performWatershedding(List<Point> maximList, List<BoundaryBox> bbs,
int width, int height, double[] hMin, ImageProcessor origImg){
ImageProcessor tempMask = new ByteProcessor(width, height);
for(int i = 0; i < maximList.size(); i++){
BoundaryBox bb = bbs.get(i);
BoundaryBox boundBox ... |
5b0c5bff-eacb-42d4-a93e-654b387066d7 | 4 | @Override
public boolean onMouseDown(int mX, int mY, int button) {
if(mX > x && mX < x + width && mY > y && mY < y + height) {
//GameActor toBuy = Application.get().getLogic().getActor(Application.get().getLogic().createActor("assets/data/actors/cannon.xml"));
//Application.get().get... |
c5ff7b0e-aeeb-4f50-aba1-4b75ef65d026 | 7 | public static void main(String args[]){
int i=0;
int j=0;
addset.add(firstset[0]);
for(i =0 ;i< firstset.length;i++){
for(j=0;j<secondset.length;j++){
if (firstset[i] == secondset[j]){
subsset[i] = 0;
}
if(!addset.contains(secondset[j])){
addset.add(secondset[j]);
}
if(!add... |
ea3980f1-7ce5-4a1a-b07b-fb370e0bac57 | 3 | private boolean isObstructed() {
IntPoint[] blocks = fallingPiece.getBlocks();
for(int i = 0; i < 4; i++) {
IntPoint p = blocks[i];
if(!p.inBounds(length, width, height))
return false;
if(cubes[p.getX()][p.getY()][p.getZ()] != Piece.NOTHING) {
return false;
}
}
return true;
} |
6f5b0db1-053c-4ec0-b7ce-ba65a0ec69a0 | 1 | @Override
public void deleteUser(Integer id) {
User user = userDao.findById(id);
if(user==null)
return;
userDao.delete(user);
} |
5729e808-c461-47d7-8526-dc55356da9a1 | 4 | public void run(){
requestFocus();
long lastTime = System.nanoTime();
long timer = System.currentTimeMillis();
final double ns = 1000000000.0 / 60.0;
double delta = 0;
int frames = 0;
int updates = 0;
while(running){
long now = System.nanoTime();
delta += (now - lastTime) / ns;
lastTime = now;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.