如何在eclipse中为不同的配置指定预处理程序指令?例如,如果我有多个主电源应该在不同的配置中运行并指定
#ifdef Problem1
//main func
#endif /*Problem1*/
Run Code Online (Sandbox Code Playgroud)
请注意,这是使用托管makefile
我已经在这个项目上工作了很长一段时间,而且我的大脑都被炒了.我可以使用一些人的帮助.
我正在尝试制作一个逐行读取文本文件的程序,每行都是一个,ArrayList所以我可以访问每个令牌.我究竟做错了什么?
import java.util.*;
import java.util.ArrayList;
import java.io.*;
import java.rmi.server.UID;
import java.util.concurrent.atomic.AtomicInteger;
public class PCB {
public void read (String [] args) {
BufferedReader inputStream = null;
try {
inputStream = new BufferedReader(new FileReader("processes1.txt"));
String l;
while ((l = inputStream.readLine()) != null) {
write(l);
}
}
finally {
if (inputStream != null) {
inputStream.close();
}
}
}
public void write(String table) {
char status;
String name;
int priority;
ArrayList<String> tokens = new ArrayList<String>();
Scanner tokenize = new Scanner(table); …Run Code Online (Sandbox Code Playgroud) 当用户在AlertDialog中单击"确定"时,我想将变量传递给外部函数.我正在尝试这个例子,但它不会识别变量(Yup).
public final void deleteBookmark(Cursor cur, int pos) {
//fetching info
((Cursor) cur).moveToPosition(pos);
String bookmark_id = ((Cursor) cur).getString(((Cursor) cur).getColumnIndex(Browser.BookmarkColumns._ID));
String bookmark_title = ((Cursor) cur).getString(((Cursor) cur).getColumnIndex(Browser.BookmarkColumns.TITLE));
//asking user to approve delete request
AlertDialog alertDialog = new AlertDialog.Builder(Dmarks.this).create();
alertDialog.setTitle("Delete" + " " + bookmark_title);
alertDialog.setIcon(R.drawable.icon);
alertDialog.setMessage("Are you sure you want to delete this Bookmark?");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
**String Yup = "yes";**
} });
alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { …Run Code Online (Sandbox Code Playgroud) 对于大约5,000-10,000行的表,使用SQL Server 2005的最有效的分页解决方案是什么?我见过几个,但没有比较它们.
我已经设置了一个表示单词的循环链表数据结构,列表中的每个元素都是单词中的一个字母.在我的问题的底部是列表的类定义和列表的元素.
列表数据结构的目的是能够比较循环词.所以......"picture"和"turepic"是相同的循环词,所以这两个列表是相同的.
所以我equals()在比较两个列表时会覆盖,而且我已经读过,每当你必须覆盖时equals(),你也必须覆盖hashCode().但是,我真的不知道如何做到这一点.
我应该如何为我设置的内容定义一个好的hashCode?我应该考虑什么?在"picture"和"turepic"的例子中,两个列表是相同的,因此它们的hashCode需要相同.有任何想法吗?
谢谢,Hristo
public class Letter {
char value;
Letter theNextNode;
/**
* Default constructor for an element of the list.
*
* @param theCharacter - the value for this node.
*/
Letter(char theCharacter) {
this.value = theCharacter;
}
}
public class CircularWord {
/*
* Class Variables
*/
Letter head;
Letter tail;
Letter theCurrentNode;
int iNumberOfElements;
/**
* Default Constructor. All characters that make up 'theWord' are stored in a
* …Run Code Online (Sandbox Code Playgroud) 我有一个模板的下一部分:
<select name="interest">
<option value="seo">SEO ? ????????????</option>
<option value="auto">????</option>
<option value="business">??????</option>
<option value="design">??????</option>
...
Run Code Online (Sandbox Code Playgroud)
并存储结果值$result['interest'].
如何option用PHP选择元素?
谢谢!
所以我有这门课
public static class MyClass
{
static MyClass()
{
...
}
}
Run Code Online (Sandbox Code Playgroud)
哪个没有方法,字段或属性.它所做的就是将处理程序连接到其他地方定义的静态事件.
由于类型初始化程序永远不会被调用,因为从不实际访问静态类,所以事件不会被连接起来.
所以我希望能够通过反射ala来调用类型初始化器typeof(MyClass).TypeInitializer().Invoke(...),这MyClass会引发一个抽象类.
最终,该应用程序将具有其他静态类,其格式与业务规则相对应.在将任何内容保存到数据库之前,将触发与要保存的对象类型相对应的静态事件.因此,如果我想要做的事情最终无法实现,那么任何重构建议都必须遵循该结构.
编辑:
关于我正在尝试做什么,我可能不太清楚.基本上我有一个数据层,你可以在其中初始化a的实例,DataContext然后在SubmitChanges()调用时我检查ChangeSetforfor是否插入/更新/删除,并为每个要插入/更新/删除的类型触发静态事件.这一切都很有效,我只是想找到一种方法,在应用程序启动时将处理程序连接到事件.所以我玩的是这个:
static DataContext()
{
System.Reflection.Assembly.GetExecutingAssembly().GetTypes()
.Where(t => t.Namespace == 'Data.Business')
.ToList()
.ForEach( t => {
// invoke the static TypeInitializer here,
// so that it can wire up it's event handlers.
});
}
Run Code Online (Sandbox Code Playgroud)
我可以使用静态Initialize方法,但由于这些只应该初始化一次,我在想TypeInitializer.
编辑2:
我已经阅读了MEF,这确实提供了一种方法来做我想做的事情.
我使用connect()和cursor()来使用SQLite
self.connector = sqlite3.connect(self.dbFile) self.cursor = self.connector.cursor()
并且close()停止使用它.
self.cursor.close()
它们的价格(处理时间)有多贵?它是如此昂贵,只有绝对必要的使用它是必要的吗?或者,在功能中多次使用它是否可以?
我使用以下简单代码进行了测试.proc1()使用在运行查询时始终打开和关闭的代码,proc2()只运行一次.
from sqlite import *
import timeit
import math
def proc1():
db = SQLiteDB("./example.db", False)
db.getOpenRunClose("SELECT * from Benchmark")
db.getOpenRunClose("SELECT * from Benchmark")
db.getOpenRunClose("SELECT * from Benchmark")
db.getOpenRunClose("SELECT * from Benchmark")
db.getOpenRunClose("SELECT * from Benchmark")
db.getOpenRunClose("SELECT * from Benchmark")
def proc2():
db = SQLiteDB("./example.db")
res = db.runSQLToGetResult("SELECT * from Benchmark")
res = db.runSQLToGetResult("SELECT * from Benchmark")
res = db.runSQLToGetResult("SELECT * from Benchmark")
res = db.runSQLToGetResult("SELECT * from Benchmark")
res …Run Code Online (Sandbox Code Playgroud) 所以我实际上在某个地方看到了一个完整的ajax网站(我忘记了哪里),并认为这将是一个新的和有趣的尝试.我使用了我构建的旧网站并将其放在新服务器上.通过一点jquery和ajax,我能够使整个站点在一页加载上工作.
我的问题是,这种方法有哪些优点和(更有可能)缺点?
请注意 - 该网站通过半智能链接功能工作.如果用户没有启用javascript,则所有内容都可以正常运行,新请求的页面会像在任何其他网站上一样加载.
更多细节 - 假设用户加载站点的主页,然后登录.当他们登录时,登录框淡出并重新显示用户信息.登录时页面上的其他内容会根据需要加载.如果他们点击链接,让我们说"文章",主页上的一列会向上滑动并向下滑动文章.如果他们点击主页,文章会向上滑动,主页内容会向下滑动.发布评论,查看个人资料,投票等事情都是通过ajax完成的.
这是一个糟糕的网页设计方法吗?如果是这样,为什么?
我对所有答案/意见持开放态度.
我的问题非常类似于:通过Spring将字段注入Hibernate加载的实体
不同之处在于,我使用的是JPA2实体,而不是hibernate.虽然底层仍然处于休眠状态(3.5.5).
我的春季版是3.0.4.
eventListenersJPA的世界中有什么相应的?
原帖的示例代码:
class Student {
int id; //loaded from DB
String name; //loaded from DB
int injectedProperty; //Inject via Spring
transient Service serviceImpl; //Inject via Spring
}
Run Code Online (Sandbox Code Playgroud)
我知道可能有aspectJ的解决方案,但我更喜欢纯java解决方案.谢谢.