- 注册时间
- 2011-11-4
- 最后登录
- 2011-11-4
- 阅读权限
- 10
- 积分
- 5
- 精华
- 0
- 帖子
- 1
升级 10%
|
String类
System.out.println(userLst.size());
Iterator<User> it = userLst.iterator();
while(it.hasNext()){
User u = it.next();
System.out.println(u.getId()+"---"+u.getName());
}
User类
算法1:掏出用户有权限跟不决义权限的内容
有个条件对象必需笼罩:
SELECT *
FROM content a -- 内容表(内容ID)
WHERE (EXISTS (SELECT 1
FROM privilige b -- 权限表(内容ID,用户ID)
WHERE a.content_id = b.contentid
AND a.content_type_id = :1
AND b.userid = :2) OR NOT EXISTS
(SELECT 1 FROM privilige b WHERE a.content_id = b.contentid))
AND a.content_type_id = :1
这几天作名目研讨出来了多少个算法,给大家分享:
// 覆盖equals
public boolean equals(Object user){
if(((User)user).getId().equals(this.getId())){
return true;
}else{
return false;
}
}
// 覆盖hashCode
public int hashCode() {
int result;
result = this.id.hashCode() + this.id.toLowerCase().hashCode();
return result;
}
User[] users = {new User("111A","张三"),
new User("111a","张三"),
new User("111","李四"),
new User("222","王麻子")};
HashSet<User> hs = new HashSet<User>(Arrays.asList(users));
List<User> userLst = new ArrayList<User>(hs);
String[] aaa = {"aaa","bbb","aaa","ccc"};
List<String> src = Arrays.asList(aaa);
HashSet hs = new HashSet(src);
List<String> rslt = new ArrayList<String>(hs);
算法2:Java对象排重 |
|