问题如下:
List<InProperties> list = new ArrayList<InProperties>();
list.add(new InProperties("2222", "name", "you"));
list.add(new InProperties("2222", "phone", "139"));
list.add(new InProperties("2222", "email", "[email protected]")); List alllist = new ArrayList();
list2.add(list);
list2.add("user2"); List<InProperties> list2 = new ArrayList<InProperties>();
list2.add(new InProperties("3333", "name", "she"));
list2.add(new InProperties("3333", "phone", "138"));
list2.add(new InProperties("2222", "email", "[email protected]"));
alllist.add(list);
alllist.add("user3");..............alllist 这个List是存放用户的属性,和改用户的ID号,
list,list2,list3.....这些是用户的属性
以上这个结构可以随便怎么设置, 比如你想用HASHMAP, 或其它的数据结构
只要表达个意思就可了, 现有字段name, phone, industry, email, interest. 我想用一个HASHM或ARRAYLIST存储以下数据
HashMap中存放的数据要按name, phone, industry, email, interest. 这个顺序, 如果那个LIST中没这个值, 就用 表示
比如list中没有industry这个值, 就用 表示Map map = new HashMap();
map.put("<td>you</td><td>139</td><td> </td><td>[email protected]</td><td> </td>");
map.put("<td>she</td><td>138</td><td> </td><td>[email protected]</td><td> </td>");
...........
有没有高效的算法能处理这个问题, 尤其是时间的长短?
InProperties代码如下class InProperties {
InProperties(String ID, String properties, String value) {
this.ID = ID;
this.properties = properties;
this.value = value; } private String ID; public String getID() {
return ID;
} public void setID(String id) {
ID = id;
} public String getProperties() {
return properties;
} public void setProperties(String properties) {
this.properties = properties;
} public String getValue() {
return value;
} public void setValue(String value) {
this.value = value;
} private String properties;
private String value;
}
问题如下:
List all = new ArrayList(); //用户2的所有属性
List<InProperties> list2 = new ArrayList<InProperties>();
list2.add(new InProperties("2222", "name", "you"));
list2.add(new InProperties("2222", "phone", "139"));
list2.add(new InProperties("2222", "email", "[email protected]")); // user2 存放用户2以及其属性
List user2 = new ArrayList();
user2.add(list2);
user2.add("user2"); // 所用用户添加到ALL中
all.add(user2); //用户3的所有属性
List<InProperties> list3 = new ArrayList<InProperties>();
list3.add(new InProperties("3333", "name", "she"));
list3.add(new InProperties("3333", "phone", "138"));
list3.add(new InProperties("2222", "email", "[email protected]")); // user3 存放用户3以及其属性
List user3 = new ArrayList();
user3.add(list3);
user3.add("user3"); // 所用用户添加到ALL中
all.add(user3);
..............all 这个List是存放每个用户的属性,和改用户的ID号,
list2,list3.....这些是用户的属性
以上这个结构可以随便怎么设置, 比如你想用HASHMAP, 或其它的数据结构
只要表达个意思就可了, 现有字段name, phone, industry, email, interest. 我想用一个HASHM或ARRAYLIST存储以下数据
HashMap中存放的数据要按name, phone, industry, email, interest. 这个顺序, 如果那个LIST中没这个值(用户没有这个属性时), 就用 表示
比如list2中没有industry这个值(用户2没有行业这个属性), 就用 表示Map map = new HashMap();
map.put("<td>you</td><td>139</td><td> </td><td>[email protected]</td><td> </td>");
map.put("<td>she</td><td>138</td><td> </td><td>[email protected]</td><td> </td>");
...........
有没有高效的算法能处理这个问题, 尤其是时间的长短?
InProperties代码如下class InProperties {
InProperties(String ID, String properties, String value) {
this.ID = ID;
this.properties = properties;
this.value = value; } private String ID; public String getID() {
return ID;
} public void setID(String id) {
ID = id;
} public String getProperties() {
return properties;
} public void setProperties(String properties) {
this.properties = properties;
} public String getValue() {
return value;
} public void setValue(String value) {
this.value = value;
} private String properties;
private String value;
}
User(id, name, phone, industry, email, interest) 的对象啊?
InProperties 的属性
如果属性的最大个数确定,最好用Object[] = new Object[length]
public static final int ID=0;
public static final int NAME=1;
public static final int PHONE=2;
if(Object[arg0] != null) return Object[arg0].toString();
else " ";
如果不想用Object[],也可以用Map<Integer or String,Object>(除非有特殊作用,否则的话,用Map效率比不上Object[])