📄 viewset.java
字号:
package com.nari.pmos.amm.amm;
import java.util.ArrayList;
import java.util.Collection;
import com.nari.pmos.amm.view_amm.User_View_View;
/**
* @author hujun
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class ViewSet {
// private final LinkedList list = new LinkedList();
private final ArrayList list = new ArrayList();
/**
*
*/
public ViewSet() {
super();
// TODO Auto-generated constructor stub
list.clear();
}
public void clear() {
list.clear();
}
public int size() {
return list.size();
}
public void add(User_View_View uv)// add last
{
User_View_View pv = null;
int i = 0;
int n = list.size();
boolean found = false;
for (i = 0; i < n; i++) {
pv = (User_View_View) list.get(i);
if (uv.getView_Id() == pv.getView_Id()) {
// 相等,不增加
found = true;
// System.out.println("uv: " + uv.getView_Id());
// System.out.println("pv: " + pv.getView_Id());
break;
}
}
if (!found) {
// list.addLast(uv);
list.add(uv);
// System.out.println("+++: " + uv);
}
}
public User_View_View get(int i) {
User_View_View pv = null;
Object obj = list.get(i);
if (obj != null)
pv = (User_View_View) obj;
return pv;
}
public Collection getChildByIndex(int index) {
Collection col = new ArrayList();
int i = 0;
int n = list.size();
User_View_View pv = null;
User_View_View uv = (User_View_View) list.get(index);
for (i = index + 1; i < n; i++) {
pv = (User_View_View) list.get(i);
if (pv.getView_Pid() == uv.getView_Id()) {
col.add(pv);
}
}
return col;
}
public Collection getChildById(int id) {
Collection col = new ArrayList();
int i = 0;
int n = list.size();
User_View_View pv = null;
for (i = 0; i < n; i++) {
pv = (User_View_View) list.get(i);
if (pv.getView_Pid() == id) {
col.add(pv);
}
}
return col;
}
public Collection getNodeByLevel(int level) {
Collection col = new ArrayList();
User_View_View pv = null;
int i = 0;
int n = list.size();
boolean found = false;
for (i = 0; i < n - 1; i++) {
pv = (User_View_View) list.get(i);
if (pv.getNode_Level() <= level) {
if (pv.getNode_Level() == level) {// 相等
col.add(pv);
}
}
}
return col;
}
public Collection getChildIByIndex(int index) {
Collection col = new ArrayList();
int i = 0;
int n = list.size();
User_View_View pv = null;
User_View_View uv = (User_View_View) list.get(index);
for (i = index + 1; i < n; i++) {
pv = (User_View_View) list.get(i);
if (pv.getView_Pid() == uv.getView_Id()) {
col.add(new Integer(i));
}
}
return col;
}
public Collection getChildIById(int id) {
Collection col = new ArrayList();
int i = 0;
int n = list.size();
User_View_View pv = null;
for (i = 0; i < n; i++) {
pv = (User_View_View) list.get(i);
if (pv.getView_Pid() == id) {
col.add(new Integer(i));
}
}
return col;
}
public Collection getNodeIByLevel(int level) {
Collection col = new ArrayList();
User_View_View pv = null;
int i = 0;
int n = list.size();
boolean found = false;
for (i = 0; i < n - 1; i++) {
pv = (User_View_View) list.get(i);
if (pv.getNode_Level() <= level) {
if (pv.getNode_Level() == level) {// 相等
col.add(new Integer(i));
}
}
}
return col;
}
public Collection getAllNodes() {
return this.list;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -