text stringlengths 14 410k | label int32 0 9 |
|---|---|
static String formatHanyuPinyin(String pinyinStr, HanyuPinyinOutputFormat outputFormat)
throws BadHanyuPinyinOutputFormatCombination {
if ((HanyuPinyinToneType.WITH_TONE_MARK == outputFormat.getToneType())
&& ((HanyuPinyinVCharType.WITH_V == outputFormat.getVCharType()) || (HanyuPinyinVCharType.WITH_U... | 8 |
@Override
public boolean supportsAttributes() {return true;} | 0 |
private static int count(int[] array) { // this is a brute force approach ...
int count = 0;
for (int i = 0; i < array.length; i++) {
for (int j = i + 1; j < array.length; j++) {
for (int k = j + 1; k < array.length; k++) {
if (array[i] + array[j] + array... | 4 |
@Override
public void run() {
try {
DataOutputStream outToSlave = new DataOutputStream(slaveSocket.getOutputStream());
InputStream in = slaveSocket.getInputStream();
BufferedReader inFromSlave = new BufferedReader(new InputStreamReader(in));
String line;
... | 5 |
private Boolean addBracketOpen(CalculatorReader expressionReader) {
String el = expressionReader.getSymbol();
if (el.equals("(")) {
//System.out.println("--addBracketOpen = " + el);
expressionReader.incPosition();
expressionStack.bracketStack.push(expressionStack.oper... | 1 |
public void setSelectGraphElement(GraphElement ge, boolean b) {
if (!b) {
this.selectlist.remove(ge.getId());
} else {
this.selectlist.put(ge.getId(), ge);
}
} | 1 |
private void boardMenu(GameState state, Scanner inputScanner)
{
String choice = "";
while(!choice.equals("q"))
{
System.out.println("\nBoard Menu: \n");
System.out.println("d: View Deck");
System.out.println("l: View Loot");
System.out.println("q: Quit to Previous Menu\n");
choice = inputScann... | 8 |
public static boolean handleDoor(Player player, WorldObject object) {
if (World.isSpawnedObject(object))
return false;
WorldObject openedDoor = new WorldObject(object.getId(),
object.getType(), object.getRotation() + 1, object.getX(),
object.getY(), object.getPlane());
if (object.getRotation() == 0)
... | 6 |
public boolean isPopOrder(int[] line1,int[] line2)
{
if(line1==null || line2==null)
return false;
int point1=0;
Stack<Integer> stack=new Stack<Integer>();
for(int i=0;i<line2.length;i++)
{
if(!stack.isEmpty() && stack.peek()==line2[i])
{
stack.pop();
}
else
{
if(point1==line1.len... | 9 |
public TreeNode buildTree(int[] preorder, int[] inorder) {
if(preorder.length == 0)
return null;
int pos = indexOf(inorder,preorder[0]);
TreeNode node = new TreeNode(preorder[0]);
//have left subTree
if(pos >0){
node.left = buildTree(Arrays.copyOfRange(p... | 3 |
public long insert(String name, String _abstract) {
if (Config.LOGD) Log.d(TAG, "insert name=" + name + " _abstract=" + _abstract);
PreparedStatement statement = null;
try {
statement = mConnection.prepareStatement(SQL_INSERT, Statement.RETURN_GENERATED_KEYS);
statement.... | 7 |
public Message()
{
} | 0 |
private void downloadTransactions(int level, String endDate) {
Map<Integer,String> codeLookup = new HashMap<Integer,String>();
for (Account a : mongoDao.getAccounts()) {
codeLookup.put(a.getId(), a.getCode());
}
try {
accountService.clearTotals();
Obje... | 7 |
private BufferedImage getIcon(String picture)
{
try
{
URL file = this.getClass().getResource("/data/" + picture);
return ImageIO.read(file);
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this, e);
}
return null;
} | 1 |
@Override
public Card drawCard(int playerId) throws ActionNotAllowedException {
if (gameStatus.isBeginningCardDrawn() && playerOnTheMove(playerId)) {
throw new ActionNotAllowedException(EXCEPTION_DRAW_MORE_THAN_ONE_CARD);
}
if (playerIsNotOnTheMove(playerId)) {
throw... | 5 |
public String runCommand() {
int commandNumber = rand.nextInt(100);
try {
if (commandNumber < 10) {
this.currentMachine.powerToggle();
System.out.println("Machine turned " + (this.currentMachine.isOn() ? "on" : "off"));
} else if (commandNumber < 30) {
insertFunds();
System.out.println("More m... | 9 |
private int[] toArray(int val) {
int ret[] = new int[4];
for (int j = 3; j >= 0; --j) {
ret[j] |= ((val >>> 8*(3-j)) & (0xff));
}
return ret;
} | 1 |
private static void loadRules()
{
int k= da.getNumberOfRules();
for(int i=1; i<=k; i++)
{
if(da.getRuleCounter(i) == -1 || da.getRuleCounter(i) > THRESHOLD )
{
Rules.add(new Rule(da.getRuleCondition(i),da.getRuleAnswer(i), da.getRuleCounter(i)));
... | 3 |
public void loadProducts(){
Product p = null;
productList.clear();
if(strat != null){
do{
try {
p = strat.readObject();
if(p == null) {
} else
add(p);
} catch (IOException e) {
e.printStackTrace();
}
} while (p != null);
} else {
JOptionPane.showMessageDialog(... | 6 |
private void Diagnose_Combobox_NameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Diagnose_Combobox_NameActionPerformed
name=(String)Diagnose_Combobox_Name.getSelectedItem();
try {
try {
try {
try {
try {
... | 5 |
private void renderLevelBlend(final Graphics g) {
switch (renderlevel % 6) {
case 0:
// 1 rect, left-up to right-down
rect.x = 0;
rect.y = 0;
rect.width = (MAX_LEVEL_BLEND - levelBlendTimeleft) * WIDTH / MAX_LEVEL_BLEND;
rect.height = (MAX_LEVEL_BLEND - levelBlendTimeleft) * HEIGHT / MAX_LEVE... | 6 |
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
if(user != null) {
UserModel usermod = DataStore.getUser(user.getUserId());
... | 2 |
public boolean inputIsNULL()
{
if(inputUser.getText().length()==0)return false;
if(inputPass.getText().length()==0)return false;
if(inputFirstName.getText().length()==0)return false;
if(inputSureName.getText().length()==0)return false;
return true;
} | 4 |
private void findEndOfStatement() {
do{
try {
token = lexer.get_token();
} catch (SyntaxError e) {
controller.consoleOut(e.toString()+" at line: "+e.getLine()+'\n');
}
}while(!token.value.equals(";") && !token.value.equals("}") && !token.value.equals("{") && token.type!=token_type.FINISHED);
if(token.val... | 7 |
public boolean add(String hostName, int ip){
return ipAddresses.put(hostName, ip) && hostNames.put(ip, hostName);
} | 1 |
private void setRoles() {
//initial states
roleStateAdministrator = 0;
roleStateProjektledare = 0;
roleStateSpecialist = 0;
cbAdministrator.setEnabled(false);
cbProjektledare.setEnabled(false);
cbSpecialist.setEnabled(false);
int pl;
int sp;
... | 6 |
public System(
String name, String houseName, String description,
String imgName, float starX, float starY,
Trait climate, int gravity, Object... args
) {
super(name, null, null, -1, NOT_A_GUILD, args) ;
this.houseName = houseName ;
this.description = description ;
this.image = imgName == ... | 7 |
public V valAt(K key) {
for (int i = 0; i < lookups.length; i++) {
V val = lookups[i].valAt(key);
if (val != null) return val;
}
return null;
} | 2 |
private static void printNetworkInterfaceInfo(NetworkInterface netint) {
Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
for (InetAddress inetAddress : Collections.list(inetAddresses)) {
System.out.printf("InetAddress: %s\n", inetAddress);
}
} | 1 |
public boolean isRelation()
{
if (getType() == TYPE_SEQUENCE)
{
return true;
}
if (getType() == TYPE_BAG)
{
return true;
}
if (getType() != TYPE_SET)
{
return false;
}
if ((m_s... | 7 |
public void drawGrid(Graphics g) {
if (!Settings.displayGrid) {
return;
}
g.setColor(new Color(255, 255, 255, 15));
int width = instance.getCanvasWidth();
int height = instance.getCanvasHeight();
int horizontalCount = width / (Main.horizontalScale != 0 ? Main.horizontalScale : 1);
int verticalCount = h... | 5 |
private JDBCUtils() {
} | 0 |
public void ReadfromProperties(){
Properties prop = new Properties();
try {
//load a properties file
prop.load(new FileInputStream("config.properties"));
setEmail(prop.getProperty("gmailPassword"));
//get the property value and print it out
... | 1 |
protected TerminalSize waitForTerminalSizeReport(int timeoutMs) {
long startTime = System.currentTimeMillis();
synchronized(readMutex) {
while(System.currentTimeMillis() - startTime < timeoutMs) {
Key key = inputDecoder.getNextCharacter();
if(key == null) {
... | 5 |
public String recieve() {
String input = null;
try {
try {
if (this.client.isClosed()) {
this.running = false;
return null;
} else if (!this.client.isClosed()) {
InputStreamReader stream = new InputSt... | 6 |
private File[] getFiles(String path) throws FileNotFoundException {
File file = Enigma.resolvePath(path);
if (file != null && file.exists()) {
if (file.isDirectory())
return file.listFiles(); // path was single directory
else
return new File[] { fi... | 5 |
final void reflectY() {
byte[] is = ((ImageSprite) this).colorIndex;
if (((ImageSprite) this).alphaIndex == null) {
for (int i = ((ImageSprite) this).indexHeight - 1; i >= 0; i--) {
int i_98_ = i * ((ImageSprite) this).indexWidth;
for (int i_99_ = (i + 1) * ((ImageSprite) this).indexWidth;
i_98_ < i_9... | 5 |
public static java.sql.Timestamp javaDateToSQL(java.util.Date date) {
if (date != null) {
java.sql.Timestamp time = new java.sql.Timestamp(date.getTime());
return time;
} else {
return new java.sql.Timestamp(0);
}
} | 1 |
private byte[] decompress(Sprite s) throws IOException {
byte[] buffer = new byte[0];
// Size of data in file
int compsize = 0;
// uncompressed size
int datasize = 0;
int testsize;
// while we still need data
while (true) {
if (s.hasFlag(SpriteInfo.Compressed)) {
testsize... | 8 |
public void receiveMessage(Message message)
{
ServerHelper.log(LogType.CONTROLLER, "Empfange Nachricht [Typ: " + message.getType().name() + "]" + ": " + message.getMessage());
switch(message.getType())
{
case GENERAL:
{
break;
}
... | 9 |
private void beginScopeSymbolTable() {
symbolTable.beginScope();
} | 0 |
public static String splitCasCode(String casCode){
String result = "";
if(isBlank(casCode)){
return result;
}
for(int i =0; i <casCode.length()/3;++i){
result += "," + casCode.substring(i*3, (i+1)*3);
}
return result;
} | 2 |
public String toString() {
if (m_Instances == null) {
return "Bayesian logistic regression: No model built yet.";
}
StringBuffer buf = new StringBuffer();
String text = "";
switch (HyperparameterSelection) {
case 1:
text = "Norm-Based Hyperparameter Selection: ";
break;
... | 7 |
public static void forceAppToFront() {
if (Platform.isMacintosh()) {
Application.getApplication().requestForeground(true);
} else if (OK_TO_USE_FULLSCREEN_TRICK) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
AppWindow windo... | 2 |
public void setSelectedFontStyle(int style)
{
for (int i = 0; i < FONT_STYLE_CODES.length; i++)
{
if (FONT_STYLE_CODES[i] == style)
{
getFontStyleList().setSelectedIndex(i);
break;
}
}
updateSampleFont();
} | 2 |
public static void listFilesForFolder(final File folder) {
for (final File fileEntry : folder.listFiles()) {
String filename = fileEntry.getName();
String filePath = fileEntry.getPath();
String filePathExtension = filePath.substring(filePath.indexOf(targetFolder)+targetFolder.length(), filePath.l... | 5 |
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Mahnung)) {
return false;
}
Mahnung other = (Mahnung) object;
if ((this.id == null && other.id != null) || (thi... | 5 |
public boolean regresaBuscaLogin(String login) {
boolean res = true;
Statement statement;
ResultSet resultSet;
try {
Connection con = DriverManager.getConnection(connectString, user, password);
statement = con.createStatement();
resultSet = statement.... | 2 |
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String firstLine = sc.nextLine();
String secondLine = sc.nextLine();
String[] firstStrArr = firstLine.split(" ");
String[] secondStrArr = secondLine.split(" ");
ArrayList<Character> l1 = new ArrayList<>();
ArrayList<Cha... | 5 |
public static Request parse(final SocketChannel socketChannel, final ByteBuffer buffer) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(buffer.array())));
final String uri;
final Map<String, String> params = new HashMap<String, Strin... | 9 |
public hasNotChosenCharactersState(GameMachine gumballMachine) {
this.gumballMachine = gumballMachine;
} | 0 |
private int[] initiation(List<Adventurer> adventurers) {
int[] init = new int[adventurers.size()];
Adventurer adventurer;
for (int i = 0, end = adventurers.size(); i < end; i++) {
boolean valid = false;
boolean match = false;
adventurer = adventurers.get(i);... | 9 |
@Basic
@Column(name = "debt")
public double getDebt() {
return debt;
} | 0 |
private void updateTabla(){
//** pido los datos a la tabla
Object[][] vcta = this.getDatos();
//** se colocan los datos en la tabla
DefaultTableModel datos = new DefaultTableModel();
tabla.setModel(datos); ... | 5 |
public void makeConnection(Socket insock) {
log.debug("makeConnection()::" + insock.toString());
if ((connectionFilter == null) || ((connectionFilter != null) && connectionFilter.isAllowed(insock.getInetAddress()))) {
// we create the connection data object at this point to
// st... | 5 |
public static boolean isValidProduction(Production production, Set set) {
String lhs = production.getLHS();
for (int k = 0; k < lhs.length(); k++) {
if (!isInUsefulVariableSet(lhs.charAt(k), set))
return false;
}
return isUsefulProduction(production, set);
} | 2 |
private boolean jj_scan_token(int kind) {
if (jj_scanpos == jj_lastpos) {
jj_la--;
if (jj_scanpos.next == null) {
jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
} else {
jj_lastpos = jj_scanpos = jj_scanpos.next;
}
} else {
jj_scanpos = jj_... | 9 |
public boolean readBoolean() {
String s = readString();
if (s.equalsIgnoreCase("true")) return true;
if (s.equalsIgnoreCase("false")) return false;
if (s.equals("1")) return true;
if (s.equals("0")) return false;
throw new java.util.InputMisma... | 4 |
private void process(String name,long timestamp) {
if(!name.endsWith(".class"))
return; // not a class
name = name.substring(0,name.length()-6);
name = name.replace('/','.'); // make it a class naem
// find a match
for( Classes c : patterns )
if(c.include.... | 5 |
private void doit() {
TransactionManager tm = this.createTM();
Queue<Request> requests = new LinkedList<Request>();
Scanner scanner = new Scanner(System.in);
String line = "";
while (true) {
line = scanner.nextLine();
String[] instructions = line.trim().... | 3 |
public int getId() {
return id;
} | 0 |
@Override
public void update(GameContainer gc, int delta) {
sprite = ((Mob) gameObject).getSprite();
switch (gameObject.getMoveDir()) {
case MOVE_UP:
lastSprite = idleUp;
sprite = up;
break;
case MOVE_DOWN:
lastSprite = idleDown;
sprite = down;
break;
case MOVE_LEFT:
lastSprite = idleLef... | 5 |
public static void initALServerLog()
{
if(g_bInit)
return ;
g_bInit = true;
Properties properties = new Properties();
InputStream propertiesInputStream = null;
try
{
propertiesInputStream = new FileInputStream("./con... | 6 |
public void extractOperators(String input){
String operatorRegex = "[+//*^-]";
// String numInput = ("3 + 2 / 4.0 * 1 ^ 17.34");
//[+//*^-]\
//extracts all operators in math equation
//extractOperators("3 + 2 / 4.0 * 1 ^ 17.34") = ["+", "/", "*", "^"]
p = Pattern.compile(operatorRegex);
m = p.matcher(input... | 1 |
@EventHandler
public void load(FMLInitializationEvent event)
{
} | 0 |
public void setPackInfo(PackInfo packInfo) {
//HACK
//I need to rework the way platform & solder data interact to produce a complete pack, but until I do so, this
//awesome hack will combine platform & solder data where necessary
if (packInfo instanceof SolderPackInfo && this.packInfo i... | 8 |
protected void moveView(int x, int y) {
boolean xTest = (viewPort.x + x + this.getWidth() <= mapImage_Scaled
.getWidth() && viewPort.x + x >= 0);
// Checks new position is valid
if (xTest) {
// changes position.
viewPort.x = viewPort.x + x;
}
boolean yTest = (viewPort.y + y + this.getHeight() <= map... | 4 |
public static <T extends Model> List<T> where(final Class<T> cls, final String query, final String... params) {
final String tableName = Reflection.getSimpleClassName(cls);
final List<T> result = new ArrayList<T>();
final StringBuffer sql = new StringBuffer();
sql.append("SELECT * FROM ");
sql.append(tableN... | 2 |
@Override
public ModelAndView resolveException(HttpServletRequest request,
HttpServletResponse response, Object handler, Exception ex) {
HandlerMethod handlerMethod = (HandlerMethod) handler;
ExceptionResolver exceptionResolver = handlerMethod
... | 2 |
Class367_Sub9(NativeOpenGlToolkit class377, IndexLoader class45, Class269 class269) {
super(class377);
try {
aClass269_7375 = class269;
if (class45 != null && ((NativeOpenGlToolkit) class377).aBoolean9921
&& ((NativeOpenGlToolkit) class377).aBoolean9922) {
Class39 class39
= (Class328.method2608
... | 8 |
@Test
public void twoEdgesCompareCorrectly() {
Edge e = new Edge(null, null);
Edge f = new Edge(null, null);
Edge g = new Edge(null, null);
e.setWeight(1);
f.setWeight(1);
g.setWeight(2);
assertTrue(e.compareTo(g) < 0);
assertTrue(g.compareTo(e) > 0);
... | 0 |
private String replaceLogs(String calculation) {
Matcher matcher = Pattern.compile("log (\\d+(\\.\\d+)?)").matcher(calculation);
StringBuffer out = new StringBuffer();
while (matcher.find()) {
double num = Double.parseDouble(matcher.group(1));
matcher.appendReplacement(ou... | 1 |
public static String showTable(List<String> ids ,List<TrigerState[]> signals){
String result = "";
for (int i = 0; i < ids.size(); i++) {
result += ids.get(i) +" ";
}
result += "\n";
for (int i = 0; i < signals.size(); i++) {
for (int j = 0; j < s... | 3 |
public static BufferedImage[] load(String s, int x, int y, int subImages) {
BufferedImage[] ret;
try {
final BufferedImage spritesheet = ImageIO.read(Images.class
.getResourceAsStream(s));
ret = new BufferedImage[subImages];
for (int i = 0; i < subImages; i++) {
ret[i] = spritesheet.getSubimage(... | 2 |
public JMenuBar addFileMenu(JMenuBar menubar) {
String text ="hello";
// create the file menu
JMenu file = new JMenu("File");
file.setMnemonic(KeyEvent.VK_F);
// add menu items and mnemonics/ tool tips
JMenuItem exit = new JMenuItem("Exit", null);
exit.setMnemonic(KeyEvent.VK_E);
... | 3 |
public void op1()
{
if(have(Token.Kind.ADD)){
expectRetrieve(Token.Kind.ADD);
}
else if(have(Token.Kind.SUB)){
expectRetrieve(Token.Kind.SUB);
}
if(have(Token.Kind.OR)){
expectRetrieve(Token.Kind.OR);
}
} | 3 |
private boolean fireExceptionEvent(ExceptionEvent evt) {
return true;
} | 0 |
protected HttpUriRequest addAuthHeader(HttpUriRequest request) {
if (!request.containsHeader(AUTH.WWW_AUTH_RESP)) {
if (mToken != EMPTY_TOKEN) {
request.addHeader(createOAuthHeader(mToken));
}
}
return request;
} | 2 |
public GreeterComponent(GUIComponentGroup superGroup) {
super(superGroup);
bannerImage = new ImageComponent(this);
bannerImage.setImage("giant_eight");
bannerImage.setImageLocationC(this.getLocationXC(), this.getLocationYC());
bannerImage.animateColor(new AlphaColorAnimation(200... | 2 |
public Shape(int row, int col)
{
super(row,col); // Set Superclasses Constructor
moveable = true; // The shape can move
Random Generator = new Random(); //Generate Random Numbers
Orientation = 1 ; // Set Default Orientation
int randomShape = 1 + Generator.nextInt(7);
Shapetype = randomShape... | 7 |
public int calculate(String s) {
int result = 0;
Stack<Integer> stack = new Stack<Integer>();
int operator = 1;
int number = 0;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
switch (c) {
case '+':
result += operator * number;
number = 0;
operator = 1;
break;
case '-'... | 7 |
public static Node<Integer> reOrder(Node<Integer> head) {
//take care of zero size and single size lists
if(head == null || head.next == null) {
return head;
}
// first break the list into two equal parts and reverse the later part
Node<Integer> slow = head;
... | 6 |
static int nextIndex(int index, int size) {
if (size <= 1) {
return -1;
}
// TODO: refactor, simplify
int i = index + 1; // switch to 1-based
if (isMinLevel(index)) { // we are at min level
if ((i & (i + 1)) == 0) { // complete min level
if (i == size) {
... | 8 |
public void territoryFill(int r, int c, List<Intersection.Piece> colors, boolean checked[][], List<Coord> area){
if (r < 0 || c < 0 || r >= 9 || c >= 9) {
return;
}
if(checked[r][c]==true){
return;
}
else if(board[r][c].getContents()!=Intersection.Piece.EMPTY){
colors.add(board[r][c].getContents());
... | 6 |
public static void main(String[] args) throws InterruptedException {
GWCAConnection gwcaConnection = null;
try {
LOG.info("Executing \"Java GWCAConstants\" (version {})", Version.getVersion());
//TODO: Fill in the PID here
gwcaConnection = new NamedPipeGWCAConnectio... | 2 |
public void driver() {
System.out.println("benz car drive");
} | 0 |
public Set<OrderStatus> possibleTransitions(OrderStatus from_status, DeliveryType for_deliveryType)
{
Set<OrderStatus> ret = new HashSet<>();
if(from_status != null)
switch(from_status)
{
case PROCESSING:
ret.addAll(Arrays.asList(DELIVERY, CANCELLED));
break;
case DELIVERY:
if(for_deli... | 6 |
@Override
public int getMetricInternal() {
EflUtil.runToAddressNoLimit(0, 0, 0xe28d); // RodResponse
boolean bite = (curGb.getRegister(Register.DE) & 0xFF) == 1;
if (!bite)
return 0;
int bc = curGb.getRegister(Register.BC);
int curLvl = (bc >> 8) & 0xFF;
int curMon = bc & 0xFF;
if((lvl > 0 && lvl != ... | 5 |
public static byte[] decrypt(byte[] data, byte[] key) {
int i;
byte[] tmp = new byte[data.length];
byte[] bloc = new byte[8];
K = generateSubKeys(key);
for (i = 0; i < data.length; i++) {
if (i > 0 && i % 8 == 0) {
bloc = encrypt64Bloc(bloc,K, true);
System.arraycopy(bloc, 0, tmp, i - 8, bloc.l... | 4 |
public int[] howMany(String answers) {
charIntMapping.put('A', 0);
charIntMapping.put('B', 1);
charIntMapping.put('C', 2);
for (int i = 0; i < answers.length(); i++) {
countABC[charIntMapping.get(answers.charAt(i))]++;
}
for (int i : countABC)
... | 7 |
public static <A, E extends A> A[] toArray(Enumeration<E> enumeration,
A[] array) {
ArrayList<A> elements = new ArrayList<A>();
while (enumeration.hasMoreElements()) {
elements.add(enumeration.nextElement());
}
return elements.toArray(array);
} | 1 |
public ServerImpl(String ip, String inputfile) throws RemoteException
{
servers = new HashMap<Integer, Server>();
transactionCounter = 0;
nofAborts = 0;
activeTransaction = null;
readGlobalParameters(inputfile);
resources = new ArrayList<Resource>();
for (int i = 0; i < Globals.NOF_RESOURC... | 9 |
public void getPhone(String phone)
{
boolean isPhonefound = false;
int noOfPages = Integer.parseInt(pageCount.getText());
System.out.println("Total number of pages : " + noOfPages);
for (int i = 0 ; i< noOfPages ; i++)
{
List<WebElement> elements = Page.driver.findElements(By.cssSelector("span.l... | 4 |
public void save()
{
//create a buffered writer stream
FileOutputStream fileOutputStream = null;
OutputStreamWriter outputStreamWriter = null;
BufferedWriter out = null;
try{
fileOutputStream = new FileOutputStream(filename);
outputStreamWriter =
new Outpu... | 8 |
public Object nextContent() throws JSONException {
char c;
StringBuffer sb;
do {
c = next();
} while (Character.isWhitespace(c));
if (c == 0) {
return null;
}
if (c == '<') {
return XML.LT;
}
sb = new Str... | 7 |
@Test
public void testBuildSettlement() {
VertexLocationRequest location1 = new VertexLocationRequest(0, 0, VertexDirection.NorthWest);
BuildSettlementRequest request = new BuildSettlementRequest(0, location1, true);
ServerModel aGame;
aGame = gamesList.get(1);
int totalBuildingsBEFORE = aGame.getMap().ge... | 5 |
int calc(String a, String b){
int n = a.length();
int m = b.length();
int[][] dp = new int[n+1][m+1];
for(int i=0; i<=n; i++){
for(int j=0; j<=m; j++){
if(i==0) dp[i][j] = j; else
if(j==0) dp[i][j] = i; else dp[i][j]=m+n;
if(i==... | 7 |
public void wasAttacked(int dmg, int debuff){
health -= dmg;
if (health <= 0){
death();
}
if (dmg == 0 && !tenacious && jolly){
cc = debuff;
jolly = false;
crowdControlled(cc);
}
} | 4 |
public void move(int xa, int ya)
{
if(xa != 0 && ya != 0)
{
move(xa, 0);
move(0, ya);
numSteps--;
return;
}
numSteps++;
if(!hasCollided(xa,ya))
{
if(ya < 0) movingDir = 0;
if(ya > 0) movingDir = 1;
if(xa < 0) movingDir = 2;
if(xa > 0) movingDir = 3;
x += xa * speed;
y += y... | 7 |
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine().trim());
for (int t = 1; t <= T; t++) {
int n = Integer.parseInt(br.readLine().trim());
int[] arr = n... | 9 |
Subsets and Splits
SQL Console for giganticode/java-cmpx-v1
The query retrieves a limited number of text entries within a specific length range, providing basic filtering but minimal analytical insight.