method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
9de17d6a-5eef-486c-aa6d-baf8c3b4666b | 1 | public void addItem( GraphItem item ){
items.add( item );
for( GraphListener listener : listeners() ){
listener.itemAdded( this, item );
}
} |
bf443d40-2a22-4b5c-8c4c-3c0e6a4e1155 | 3 | public Set<ValueType> intersection(Set<ValueType> set1, Set<ValueType> set2) {
Set<ValueType> crossSet = new Set<>();
SetElement<ValueType> current = set1.head;
if (!set1.isEmpty()) {
while (current != set1.tail.getNext()) {
if (set2.exist(current.getValue())) {
... |
6afbc0dd-81fd-46d3-ab09-b0c20550b068 | 8 | public int compareTo(Tablero o) {
if(pos[0] < o.pos[0])return -1;
if(pos[0] > o.pos[0])return 1;
if(pos[1] < o.pos[1])return -1;
if(pos[1] > o.pos[1])return 1;
if(pos[2] < o.pos[2])return -1;
if(pos[2] > o.pos[2])return 1;
if(pos[3] < o.pos[3])return -1;
if(pos[3] > o.pos[3])return 1;
return ... |
fad6896d-424a-490d-9fc7-4db80690a369 | 0 | public String getName() {
return name;
} |
a1a729f5-9d39-438b-a738-44e6f89a834e | 3 | public boolean equalsExpr(final Expr other) {
return (other instanceof LocalExpr)
&& ((LocalExpr) other).type.simple().equals(type.simple())
&& (((LocalExpr) other).fromStack == fromStack)
&& (((LocalExpr) other).index == index);
} |
7d22352f-05d8-46a6-9bde-3503649dfaec | 3 | public ChatServerMain(int portNumber) {
isRunning = true;
audioRooms = new TreeMap<String, AudioThread>();
databaseSetup();
/* Create the server socket */
try {
port = portNumber;
serverSocket = new ServerSocket(portNumber);
System.out.println... |
66610b49-09c2-4f86-8bc1-44e248f2bb43 | 3 | public boolean collisionFeet(Obstacle[][] obs, int j, int k) {
// Testing the boxes below Stubi :
int i = (y+height)/Obstacle.getHeight(); // box below the Nbox (one occupied by Stubi's feet)
if (i<0) {
System.out.println("Above the box");
return false;
}
boolean collide = obs[i][j].CollisionTop(); // b... |
03832b42-4e04-4c30-b8ad-c2f037c6bc44 | 7 | private int lookAtPlayer(int _player)
{
for (int k = 0; k < column; k++)
{
for (int i = 0; i < row; i++)
{
if (gameGrid[i][k] == _player)
{
if (checkUp(i, k, _player) == true)
{
return _player;
}
else if (checkUpRight(i, k, _player) == true)
{
return _player;
... |
3e2b6598-aa77-4f37-98a2-c029b4708e1d | 0 | public String getFormattedLocation() {
return formattedLocation;
} |
6cac7933-ebb6-4a06-ae0b-ec224057660e | 6 | @SuppressWarnings({ "rawtypes", "unchecked" })
void splitLineToMap(HashMap hashMap, String line) {
String[] words=line.split(" ");
HashMap<String,HashMap<String,Integer>> bigramMap=(HashMap<String,HashMap<String,Integer>>)hashMap;
ArrayList<String> wordList=new ArrayList<String>(words.length+1);
for(String wor... |
d559b804-4db8-4af9-9651-89620c1fab5b | 4 | private void procCompanyInfo(Packet p) {
PacketReader pr = p.getByteBufferReader();
Company c = new Company();
if (pr.readUint8() != NETWORK_COMPANY_INFO_VERSION) {
return;
}
if (pr.readBool()) {
c.setId(pr.readUint8());
c.setName(pr.readString());
c.setStartYear((int) pr.readUint32());
c.se... |
76ee718f-2f6c-48c2-b52b-3b0005827653 | 7 | public void saveGame() {
Image resizedImage = background.getImage().getScaledInstance(400, 300,
Image.SCALE_SMOOTH);
background = new ImageIcon(resizedImage);
JPanel mainPanel = new JPanel() {
// Displays the background image on the panel.
@Override
public void paintComponent(Graphics g) {
g.dra... |
4fcb942e-0349-4250-8783-533a15cbcc13 | 4 | public static void makeDirs(Socket socket){
try {
// Read how many dirs need to be made
int numDirs = Integer.parseInt(readLine(socket));
//Make each directory
for(int i = 0; i < numDirs; i++){
// Read the dir name on the server
St... |
59538e9a-c849-4e9d-a569-4f57f059d8af | 5 | @Override
public void run() {
while(running){
// Here goes the things that should be updated constantly...
gamePanel.repaint();
if(!audio.isPlaying()){
audio.setPlaying(true);
audio.startPlaying(BACKGROUND_MUSIC);
}
try {Thread.sleep(10);} catch (InterruptedException e) {e.printStackTr... |
96431563-d834-4f6a-9127-5a2b3e3923be | 0 | public Map<Character,Product> getProducts() {
return products;
} |
bd185fa9-173e-4228-803e-0dcc8b1cada3 | 6 | public static void buySell(int[] input){
// find local minima and local maxima till it reaches the end
int index = 0;
while(index < input.length-1){
//find local minima .. make sure you are not going over the limit
// compare index with index+1
while(index < ... |
7a33c611-d0da-463d-8851-92ec70034cec | 3 | static public String page(String uri, String urlParameters)
{
URL url;
HttpURLConnection connection = null;
try {
// Create connection
url = new URL(uri);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST"... |
45c6054d-793c-4ca3-8743-d27c3f3e5e90 | 4 | static void Dec2Bin(){
System.out.println();
System.out.print("Please enter a decimal (integer) number: ");
String binary = "";
int decimal = s.nextInt();
double temp = decimal;
int logarithm = (int)Math.sqrt(decimal) + 1;
System.out.println(loga... |
ce41fee4-46c8-45c5-a2e1-64d5122219b9 | 8 | public static Cons evaluateRemainingArguments(LogicObject predicatevalue, Cons arguments) {
{ Cons evaluatedarguments = Stella.NIL;
if ((predicatevalue != null) &&
Stella_Object.isaP(predicatevalue, Logic.SGT_LOGIC_NAMED_DESCRIPTION)) {
{ List variabletypes = ((NamedDescription)(predicateva... |
a511e1d4-95cf-424f-8989-e2c15ca82be1 | 0 | @Override
public String getName() {
return this.name;
} |
50bc927c-d7c1-4e7a-8ecb-cf7e441c3db4 | 8 | public static LinkedList<CartsModel> XmlExport(SchedSystem ss) {
Document doc;
try {
doc = XmlReader.getDoc("carts/xml/output.xml");
} catch (ParserConfigurationException | SAXException | IOException e1) {
e1.printStackTrace();
return null;
}
// TODO THHHHHHHOOOOOOOOOOOOOOOOORRRRRRRRRRRRRRRRRRRRR
... |
5feb7fe9-4820-429f-9b8f-50895b59cde0 | 8 | public void run() {
final byte[] buffer = new byte[4096];
try {
short idle = 0;
while (true) {
final int bytesRead = m_in.read(buffer, 0, buffer.length);
if (bytesRead == -1) {
break;
}
if (bytesRead == 0) {
idle++;
} else {
m_out.write(buffer, 0, bytesRead);
idle = 0;... |
485cb859-b78c-4c41-b57a-c1de2c08c5d4 | 4 | public NextDirection opposite(){
switch (this){
case DOWN:
return UP;
case RIGHT:
return LEFT;
case LEFT:
return RIGHT;
case UP:
return DOWN;
defaul... |
f440ed1a-6f9c-4eca-8b81-356c704195c8 | 8 | @Override
public WeightedGraph<Sensor, Link> createNetwork(float sensorRange) {
resetStatistics();
WeightedGraph<Sensor, Link> network = new WeightedGraph<Sensor, Link>();
// Add all vertices in the logical network to the new network.
Iterator<Sensor> vertsIter = logicalNetwork.vertices().iterator();
whil... |
08a0313a-65ed-47a1-8863-db03378e7347 | 9 | protected void initDefaultStyle() {
if (this.styleMap == null) {
this.styleMap = DefaultStyle.getDefaults();
}
//background
if (!styleMap.containsKey(BACKGROUND_KEY))
styleMap.put(BACKGROUND_KEY, new Color(209, 215, 226));
//header title font
if... |
dd394b26-eaf6-4db7-a31f-745716fb6fb7 | 7 | public final DirkExpParser.literal_return literal() throws RecognitionException {
DirkExpParser.literal_return retval = new DirkExpParser.literal_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
DirkExpParser.numbericLiteral_return numbericLiteral33 = null;
Dirk... |
7e23b21d-a075-4dca-98b7-99a27c5576ce | 6 | public final Interface getReceiver(Interface sender) {
if(sender instanceof Role) {
if(((Role)sender).getName().equals(this.sideA.getName())) {
return this.sideB;
}
else if(((Role)sender).getName().equals(this.sideB.getName())) {
return this.sideA;
}
}
else if(sender instanceof Port) {
if((... |
bd586dcb-38b9-4e92-ae64-7624724688d6 | 1 | private void notifyListeners(List<E> results) {
if (mListener != null)
mListener.notify(results);
} |
56c18fda-fc29-46c0-b972-b69ddcf477ea | 2 | public Drawer(String name, int w, int h) {
if (w < 1 || h < 1) throw new RuntimeException("width and height must be positive");
this.width = w;
this.height = h;
this.name = name;
init();
} |
4ad3c8c9-98ae-4ebf-b8a1-2b1fa4b2aca0 | 8 | public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
throws SAXException {
//Handle accumulated text
finishText();
insideElement = localName;
if (ELEMENT_document.equals(localName)){
createPageObject();
//Producer
int i;
if ((i = atts... |
45d95183-72e9-477c-894c-167b49730be2 | 2 | public static ArrayList<Usuarios> sqlSelectTodos()
{
ArrayList<Usuarios> usu = new ArrayList();
if(!BD.getInstance().sqlSelect("select * from usuarios ")){
return usu;
}
while(BD.getInstance().sqlFetch()){
usu.add(new Usuarios(BD.getInstance().getStrin... |
e311e682-18b0-464a-94f7-1377f05c2bd0 | 0 | @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
UserListPopupMenu = new javax.swing.JPopupMenu();
SendFileButton = new javax.swing.JMenuItem();
voiceTalkButton = new javax.swing.JMen... |
4330d183-1c62-435d-831f-df2e8194a90c | 4 | public boolean onCommand(CommandSender sender, Command cmd, String commandlabel, String[] args) {
final ChatColor yellow = ChatColor.YELLOW;
final ChatColor green = ChatColor.GREEN;
final ChatColor red = ChatColor.RED;
final ChatColor purple = ChatColor.DARK_PURPLE;
if(args.length < 1) {
sender.sendM... |
e23c5f88-3cab-49dc-9f1f-7cca0ac799a6 | 5 | public static void testEphemeris(JPLEphemeris ephemeris) {
if (ephemeris == null) {
System.out.println("EPHEMERIS OBJECT IS NULL");
return;
}
double tEarliest = ephemeris.getEarliestDate();
double tLatest = ephemeris.getLatestDate();
System.out.println("Ephemeris has number "
+ ephemeris.getEphemer... |
f569e6ab-b407-49df-bee8-68d78b180f50 | 6 | private static Control findControl(Type type, Control... controls) {
if (controls == null || controls.length == 0) return null;
for (Control control : controls) {
if (control.getType().equals(type)) return control;
if (control instanceof CompoundControl) {
CompoundControl compoundControl = (CompoundContro... |
047f92af-0f19-4dfb-bd12-885d79cf0d9b | 8 | private void readFile(final String fileName) {
BufferedReader reader = null;
log.info("Start reading file " + fileName);
try {
try {
reader = new BufferedReader(new FileReader(fileName));
int instructionNumber = 0;
int ... |
52fcc4a7-2b01-49e2-b4db-803b3eff37a5 | 6 | public static String createDir(String url) {
StringTokenizer tokenizer = new StringTokenizer(url, "/");
String tmp = tokenizer.nextToken();
StringBuilder sb = new StringBuilder();
if (basePath == null || "".equals(basePath)) {
System.out.println("文件存储基本路径未指定!无法存储文件!");
return "ERROR";
}
sb.append(bas... |
d6a437cb-2b8e-42c9-bc62-620163464507 | 3 | private static void closeConnection(Connection conn) {
if( conn != null ) {
try {
if( !conn.isClosed() ) {
conn.close();
}
} catch (SQLException e) {
logger.error("Error closing the connection.", e);
}
}
} |
5307c737-38ba-4638-a3fd-2863f46bca75 | 1 | public List<Card> getCards() {
return (cards != null ? cards : new ArrayList<Card>());
} |
5cc6d81f-72e3-4d84-9c72-540e025be902 | 6 | @Override
public void mouseReleased(MouseEvent arg0) {
switch (arg0.getButton()) {
case MouseEvent.BUTTON1:
keymap.put(VK_MOUSE_1, false);
break;
case MouseEvent.BUTTON3:
keymap.put(VK_MOUSE_2, false);
break;
case MouseEvent.BUTTON2:
... |
23139c12-fb0a-47c3-9f45-849689f0ba89 | 0 | public SQLPermissionOp() {
super("op");
} |
f221fec5-6f77-4c34-99be-2b37c1071eb2 | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
QueryAttribute other = (QueryAttribute) obj;
if (columnName == null) {
if (other.columnName != null)
return false;
} else if (!columnNam... |
c9c64541-e25c-44c0-aab6-a010bf0e53bf | 2 | public static byte dna2Code(char base) {
if (base == '-') return -1;
byte c = DNA_TO_CODE[(byte) base];
if (c < 0) throw new RuntimeException("Unknown code for amino acid '" + base + "' (ord: " + ((int) base) + " )");
return c;
} |
8e0eabb4-44c6-4d37-b0df-99fbcb6b1792 | 5 | public ClassAnalyzer findAnonClass(String name) {
if (innerAnalyzers != null) {
Enumeration enum_ = innerAnalyzers.elements();
while (enum_.hasMoreElements()) {
ClassAnalyzer classAna = (ClassAnalyzer) enum_.nextElement();
if (classAna.getParent() == this && classAna.getName() != null
&& classAna.... |
2e11efef-a526-4e9d-8834-f7cab23824cc | 8 | private static double getAverage(String level, String tissue, String taxa, String highLo)
throws Exception
{
taxa = taxa.replaceAll("\\.", " ");
if( taxa.equals("Escherichia Shigella"))
taxa = "Escherichia/Shigella";
BufferedReader reader = new BufferedReader(new FileReader(new File(
ConfigReader.... |
7b07950b-a31a-474f-b5df-36c2603acc9c | 0 | @Override
public void finishOutline () {} |
39c2bcb7-a820-4f6d-9015-33212689488f | 6 | public void setFile(File fileIn) {
if(fileIn == null || !fileIn.exists()) {
clearSelection();
return;
}
cancelButton.setEnabled(true);
file = fileIn;
int i = file.getName().lastIndexOf('.');
String ext = "file";
if(i >= 0) {
ext = file.getName().substring(i+1);
... |
d79876e6-69dc-413f-bfc7-30605f60a36a | 9 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
jScrollPane1.setVisible(true);
jScrollPane2.setVisible(false);
DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
int bookcode = 0;
int n = 0;
St... |
19830a66-392d-4cd8-bf19-8889a802c684 | 8 | @Override
public boolean execute(MOB mob, List<String> commands, int metaFlags)
throws java.io.IOException
{
String parm = (commands.size() > 1) ? CMParms.combine(commands,1) : "";
if((!mob.isAttributeSet(MOB.Attrib.AUTOWEATHER) && (parm.length()==0))||(parm.equalsIgnoreCase("ON")))
{
mob.setAttribute(MO... |
d7792fd8-360f-4a6e-b5db-7427d11d117b | 7 | public static void loadFile(String filename) {
org.apache.commons.configuration.Configuration conf = null;
try {
conf = new PropertiesConfiguration(filename);
} catch (ConfigurationException e) {
Formatter.printErrorLine("Failed to load configuration file");
Formatter.printErrorLine(e.getLocalizedMessage... |
34548191-6f07-4277-a4c1-3e5b1d559ac0 | 1 | public boolean setAccButtonHeight(int height) {
boolean ret = true;
if (height <= 0) {
this.buttonAccess_Height = UISizeInits.ACC_BTN.getHeight();
ret = false;
} else {
this.buttonAccess_Height = height;
}
somethingChanged();
return ... |
350c27a4-e29b-4031-8826-568478fe3b96 | 6 | public Token analizzaExpr(ArrayList<Token> espr) throws OperazioneNonValidaException, OperatoreMissingException, ExtraTokenException, ParentesiParsingException, OperandoMissingException
{
ArrayList<Token> espressione = new ArrayList<Token>();
Token t = peek();
if(t.ritornaTipoToken().equals(Tok.LEFT_PAR))
{
... |
b081ae3c-77ee-46ef-8a15-d0db27ea98ca | 1 | public String toString(){
String tmp;
tmp = "name: " + name + " " + phone + "\n" + "Seats Booked:";
ArrayList<String> tmplist = new ArrayList<>();
for (Seat bookedSeat : bookedSeats) {
tmp += bookedSeat.getCode() + " ";
}
return tmp;
} |
07816e39-a0e4-450f-a2f6-2073bec27f8f | 6 | void initResources() {
final Class clazz = this.getClass();
if (resourceBundle != null) {
try {
if (images == null) {
images = new Image[imageLocations.length];
for (int i = 0; i < imageLocations.length; ++i) {
InputStream sourceStream = clazz.getResourceAsStream(imageLocations[i]);
Ima... |
bcf6007a-da1a-4455-81c6-7d133faa6ae2 | 1 | @Override
public JPanel getLinkPanel() {
super.getLinkPanel();
if( timePanel == null ) {
timePanel = createTimePanel();
}
setTimeSpinners();
return timePanel;
} |
1a493b56-c98c-46db-96ca-a22e31b98f37 | 5 | @Override
public void insertAfter(Element element, Element after,
String outerBlockNames) throws RemoteException {
if("".equals(outerBlockNames.trim())){
confText = ReadConf();
//confText not contains element, return @
String editconfText = BlockInsertAfter(confText,element,after);
// write t... |
c53e01e2-546f-4e6b-95f4-28b0409af39a | 4 | public void keyReleased(KeyEvent e)
{
int key = e.getKeyCode();
if(key == KeyEvent.VK_UP || key == KeyEvent.VK_DOWN || key == KeyEvent.VK_RIGHT || key == KeyEvent.VK_LEFT){keyboardInput=true;}
} |
c33dac98-4eba-4db8-9cc6-6395f13dcbcf | 5 | public static void makeEconomyCall(boolean bVault) {
if(bVault) {
String banker = McJobs.getPlugin().getConfig().getString("advanced.bank_account", "");
HashMap<String, Double> tmp = new HashMap<>();
tmp.putAll(_payCache);
_payCache.clear();
for(Map.En... |
461caedf-8196-4403-86ed-78b71e24c5da | 5 | final AnimatableToolkit method614(byte i, int i_531_, boolean bool) {
anInt5426++;
Class64_Sub2 class64_sub2_532_;
Class64_Sub2 class64_sub2_533_;
if ((i ^ 0xffffffff) != -2) {
if ((i ^ 0xffffffff) != -3) {
if ((i ^ 0xffffffff) != -4) {
if (i != 4) {
if ((i ^ 0xffffffff) == -6) {
class64_sub2... |
8ae3b521-51b4-44f2-82d8-05b7af7963c3 | 0 | public void onStatus(Status status) {
statusRepo.add(status);
freqUpdate(status);
sampleFreqUpdate(status);
/*HashtagEntity[] tags = status.getHashtagEntities();
String hashtags = "";
for (HashtagEntity t: tags) hashtags+=t.getText()+",";
System.out.println(status.getCreatedAt()+", [" + hashtags + "]... |
a077a07d-e4ff-401b-bc59-075015ed7cea | 5 | private void tick() throws Exception
{
if(currentState == State.Splash)
{
Thread.sleep(1750);
currentState = State.Title;
}
if(currentState == State.Title)
{
currentState = State.Menu;
}
else if(currentState == State.Game)
{
Character.tick();
Object.tickItem();
Object.t... |
f7ead52c-257c-40ef-bc59-62836c058a89 | 8 | public float shortestPath(Position source, Position target) throws IllegalArgumentException, IllegalStateException, PositionsNotConnectedException {
// Check whether the Positions exist.
if (!nodes.containsKey(source) || !nodes.containsKey(target)) {
throw new IllegalArgumentException();
}
// Add a tempor... |
237dc112-8018-4781-bb8e-8c5639e52d1f | 1 | @Override
public V put(K key, V value) throws InvalidPositionException,
BoundaryViolationException, EmptyTreeException, InvalidKeyException {
checkKey(key);
Position<Entry<K, V>> currentP = treeSearch(key, root());
BSTEntry<K, V> e = new BSTEntry<K, V>(key, value, currentP);
actionP = currentP;
if (!isI... |
c14d4521-18f8-4aa7-8803-c8ee8e7c12e6 | 6 | @Override
public int compareTo(Vector o) {
if (x != o.x)
return (x < o.x ? -1 : 1);
if (y != o.y)
return (y < o.y ? -1 : 1);
if (z != o.z)
return (z < o.z ? -1 : 1);
return 0;
} |
c0202703-14ab-4af7-a2a7-16aea5f04917 | 1 | public HLLCounter get() {
TreeSet<Long> ts = new TreeSet<Long>();
for(long l : minhash){
ts.add(l);
}
HLLCounter hll = new HLLCounter(p, k > 0, k, M, ts);
return hll;
} |
ec2a9a2c-38ad-43f4-8453-69a192444127 | 5 | public static void main(String[] args){
int[] p = new int[(int) 1e6];
int pCount = 0;
for(int i=0;i<1e6;i++) p[i]=1;
for(int i=2;i<1e6;i++){
if (p[i] == 1){
pCount++;
if (pCount == 10001) System.out.println(i);
for (int j=i;j<1e6;j+=i) p[j] = 0;
}
}
} |
502efcc3-adf3-42e8-9b2f-9fbebd12a7ea | 1 | private boolean isVerticalEndOfBoard(long binPosition){
if( (binPosition & 0xFF_00_00_00_00_00_00_FFl) != 0 )
return true;
else
return false;
} |
d6be550d-fab7-47c4-a0a5-69ec10a00b70 | 5 | @Override
public void skip(long pFrames) throws AudioException {
if ( this.mClosed ) {
throw new IllegalStateException( "The Audio is not opened" );
}
if ( !this.canSeek() ) {
throw new AudioException( "can't seek on this audio" );
}
//FIXME: skipping in wav files
double rate = ((double) pFrames) / t... |
6f20e8b1-16b7-4f46-a7ee-584949f5625f | 4 | public void onCommand(CommandSender sender, ChunkyCommand command, String label, String[] args) {
if (!(sender instanceof Player)) {
Language.IN_GAME_ONLY.bad(sender);
return;
}
if (args.length == 0) {
ChunkyPlayer chunkyPlayer = ChunkyManager.getChunkyPlayer(... |
8f99f38b-b72c-47ba-94fc-dc20541cc125 | 6 | @SuppressWarnings("unused")
public List<String> getFrameNames() {
File dir = new File(this.framesDir);
String[] filesArray = dir.list();
List<String> files = new ArrayList<String>();
long lenFirst = 0;
for (String fileName : filesArray) {
// only continue if jpg picture
if (fileName.indexOf(".jpg") >= ... |
6de694d2-8c35-4ec3-9153-d2cd4cc4a898 | 5 | public static void openLink(String lnk)
{
URI link;
try
{
link = new URI(lnk);
try
{
Class<?> desktopClass = Class.forName("java.awt.Desktop");
Object o = desktopClass.getMethod("getDesktop", new Class[0]).invoke(null, new Object[0]);
desktopClass.getMethod("browse", new Class[] ... |
0147c953-4e27-4d72-b784-3f6ca0c6c5e5 | 0 | @Test
public void testGetS2() {
System.out.println("getS2");
Sense instance = new Sense(Sense.senseDir.HERE, 3, 6, Sense.condition.FOE);
int expResult = 6;
int result = instance.getS2();
assertEquals(expResult, result);
} |
1d2af058-ff9a-45f3-8e3d-43ed2eb47bfc | 6 | private static void handleDeltas(long[] push, long[] pull) throws Exception {
if (push.length > 0) {
for (long i : push) storeB.addIfNew(i, storeA.getValue(i));
System.out.print("push[" + push.length + "]: ");
for (long i : push) System.out.print(i + " "); System.out.pri... |
6cfd0ffb-43fa-42f4-9e25-a6263318c91e | 3 | public static boolean writeObject(Object object, String filename)
{
ObjectOutputStream out = null;
try {
out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(filename)));
out.writeObject(object);
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
if (out... |
7c5342f6-50fb-4764-b263-cf386e3fa842 | 8 | public boolean canCreate(Player player)
{
if (player.hasPermission("travelpad.create") || player.isOp())
{
List<UnnamedPad> upads = manager.getUnnamedPadsFrom(player);
if (!upads.isEmpty())
{
player.sendMessage(ChatColor.RED+l.create_deny_waiting... |
99b72f10-17b2-4c5f-b4e4-dcc9101ac0fc | 2 | @Override
public void render() {
super.render();
if(scores != null) {
int indx = 0;
for(Score s : scores) {
Renderer.get().drawText(s.toString(), x+30, y+30+indx*35);
indx++;
}
}
else {
Renderer.... |
a0f6ff40-4723-4432-b674-c152e4780f6e | 4 | public String getDisplayType() {
String key = type != null && type.length() > 0 ? type : tag;
if (key != null) {
String displayType = DISPLAY_TYPE.get(key.toUpperCase());
if (displayType != null) {
return displayType;
}
}
return OTHER_TYPE;
} |
48ad5827-8417-4528-81b5-b604f195c007 | 6 | public void update(GameContainer container, int delta) {
Key.updateKeys();
Window.updateMouse();
boolean tickOnlySpecial = false;
if (Room.transition != ETransition.None) {
Transition tr = Room.transition == ETransition.Out ? Room.tOut : Room.tIn;
if (tr != null && tr.stopsGameplay()) tickOnlySpecial =... |
70c07c3a-30ab-4dee-9717-2211b8f80295 | 5 | public void guardarPersonaTexto(String rutaFichero, LinkedHashMap<Integer, Persona> personas) {
FileOutputStream fos = null;
try {
fos = new FileOutputStream(rutaFichero);
ObjectOutputStream object = new ObjectOutputStream(fos);
//recorro el key set del HM y grabo a f... |
eb8fbf32-d4db-4461-b1f6-1b5641959791 | 9 | public static void main(String[] args) {;
boolean res;
// --
/*System.out.println("Trying to perform transaction (using doTransactionally)");
res = Transaction.doTransactionally(new Callable<Boolean>() {
public Boolean call() {
x = 1;
y = 1;
return true;
}
}, new Callable<Boolean>() {
... |
19e099d6-220f-48ac-9523-ef11509ed1c8 | 7 | public static BlockFace getPistonBlockFace(Vector direction, Vector player) {
Vector vec = direction.clone();
int x = vec.getBlockX();
int y = vec.getBlockY();
int z = vec.getBlockZ();
if(y==0||y==1||x>=2||x<-2||z>=2||z<-2){
return get4BlockFace(player);
} els... |
fe08caaf-3101-49f2-bcc9-625b3a2eecf6 | 3 | @Override
public int[] getBiomeData(int px, int pz, int sx, int sz)
{
int px2 = px >> 1;
int pz2 = pz >> 1;
int sx2 = (sx >> 1) + 3;
int sz2 = (sz >> 1) + 3;
int[] data2 = this.base.getBiomeData(px2, pz2, sx2, sz2);
int[] data = ArrayCache.newInt(sx2 * 2 * sz2 * 2... |
5b0f9666-fbb2-4e7b-a625-aecf29127aac | 0 | public Manufacturer getManufacturer() {
return manufacturer;
} |
ed9e84a8-68fa-45e6-8a83-ca3d1259de01 | 7 | @Override
public String getJSONString() {
StringBuilder json = new StringBuilder()
.append("{")
.append(super.getJSONBaseString());
if(this.getDate()!=null && this.getDate()!="")
json.append("\"date\":\"").append(this.getDate()).append("\",");
json.append("\"completed\":").append((this.isCompleted() ? "tr... |
cecc6fca-533b-467b-b5f5-f66c6094d686 | 9 | @EventHandler
public void TributeChat(AsyncPlayerChatEvent event){
Player p = event.getPlayer();
String pname = p.getName();
if(plugin.getArena(p)!= null){
String msg = "<" + ChatColor.RED + "[Tribute] " + ChatColor.WHITE + pname + ">" + " " + event.getMessage();
if(plugin.config.getString("ChatClose").equ... |
524e1ba2-7419-4f73-8630-a43075d27d88 | 1 | private byte[] readBuffer(InputStream data) throws IOException
{
byte[] buf = new byte[bufferSize];
int len = data.read(buf);
return len > 0 ? Arrays.copyOfRange(buf, 0, len) : null;
} |
19c583c8-3954-4503-b950-7369671c0fd4 | 3 | public String[] melonerror(String aurl, String name, String period) {
try {
URL url = new URL(aurl);
url.openStream();
String out = new Scanner(url.openStream(), "UTF-8").useDelimiter(
"\\A").next();
JSONParser parser = new JSONParser();
... |
81a21053-17b8-485d-812f-b6349baa2d75 | 0 | public Object getField3() {
return field3;
} |
edf7704b-d873-411e-b7b3-e63a868c9704 | 8 | private void onInput() {
int prevmode = clockmode;
// Read push button states
if (b1 != b1p || b2 != b2p) {
if (b1 && b2) {
clkinput.alarmOn = !clkinput.alarmOn;
chb_alarmon.setState(clkinput.alarmOn);
chb_tshow.setState(true);
clockmode = MODE_ATOGGLE;
} else if (b1) {
clkinput.choice ... |
89f9b7c5-1518-4118-82d8-82f3ba65d6e8 | 7 | public void vaccinateRandFracPeopleAtHighDegLocRestByHomeDist(int numVaccines, double fraction, int percentile, double minHomeDist, double maxHomeDist){
HashMap distances = EpiSimUtil.locationsRestByHomeDist(minHomeDist, maxHomeDist, percentile);
int numFetchRows = 100;
try {
Connection con = EpiSimUtil.dbConn... |
c8de096e-eac6-4114-bf17-6db47804ad57 | 9 | final void copyRek(final Path source, final Path destination)
throws IOException {
if (source.toFile().isDirectory()) {
if (destination.toFile().exists()
&& !destination.toFile().isDirectory()) {
this.initState.setFailed();
throw new IOException("Copying directory to file");
}
final String[] ... |
4d953f0f-42ba-408e-a627-fd38059fd739 | 6 | public static List<String> parseFile(String fileName)
throws MowItNowException {
if (StringUtils.isBlank(fileName))
throw new MowItNowException(ERROR_FILE_NOT_FOUND);
List<String> list = new ArrayList<String>();
final File file = new File(fileName);
if (file.exists() && file.canRead()) {
// Read the fi... |
d73f7fd3-fc1b-4885-adad-cbd404681b45 | 3 | public JSONWriter object() throws JSONException {
if (this.mode == 'i') {
this.mode = 'o';
}
if (this.mode == 'o' || this.mode == 'a') {
this.append("{");
this.push(new JSONObject());
this.comma = false;
return this;
}
t... |
315e7374-15dc-4113-a97f-080817a84e8a | 5 | public StrongSlot first() {
LuaValue key = strongkey();
LuaValue value = strongvalue();
if (key != null && value != null) {
return new LuaTable.NormalEntry(key, value);
} else if (key != null && this.value instanceof WeakValue && ((WeakValue) this.value).ref.get() == null) {
return new LuaTable.Norm... |
bdfbcbda-cd90-4383-9d48-5579eff57087 | 6 | public MethodType(String signature) {
super(TC_METHOD);
this.signature = signature;
int index = 1, types = 0;
while (signature.charAt(index) != ')') {
types++;
while (signature.charAt(index) == '[')
index++;
if (signature.charAt(index) == 'L')
index = signature.indexOf(';', index);
index++;
... |
2fc51d2b-1adf-4c71-9c2e-df93dbdd931b | 1 | double getVariance(List<Double> data) {
double mean = getMean(data);
double temp = 0;
for (double a : data) {
temp += (mean - a) * (mean - a);
}
return temp / data.size();
} |
6a8c8815-e5ae-4773-a93e-2305a82973fa | 5 | public static boolean isBackboneFragmentIonType(FragmentIonType ionType) {
return (ionType.equals(FragmentIonType.A_ION) || ionType.equals(FragmentIonType.B_ION) || ionType.equals(FragmentIonType.C_ION) ||
ionType.equals(FragmentIonType.X_ION) || ionType.equals(FragmentIonType.Y_ION) || ionType.... |
e908e897-0776-403d-a5a5-d9611edb8765 | 1 | @Override
public double[] itemSimilarities(long arg0, long[] arg1)
throws TasteException {
double scores[] = new double[arg1.length];
for(int i=0;i<arg1.length;i++){
double score=itemSimilarity(arg0, arg1[i]);
scores[i]=score;
}
return scores;
} |
bb7fc21e-0dd1-4716-9dec-545a68e7396d | 1 | public List<Integer> StringToList(String range) {
List<Integer> idx = new ArrayList<Integer>();
String s0 = range.replace(" ","");
String s1 = s0.replace("{","");
String s2 = s1.replace("}","");
String[] s3 = s2.split(",");
for (String s : s3) {
int mi = Int... |
1812382b-fb66-4f34-af52-9ccdcf13c867 | 9 | private static String _put(nitro_service service, String request, String objtype) throws Exception
{
HttpURLConnection httpURLConnection;
StringBuilder responseStr = new StringBuilder();
try
{
String urlstr;
String ipaddress = service.get_ipaddress();
String sessionid = service.get_sessionid();
St... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.