You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.0 KiB
49 lines
1.0 KiB
4 years ago
|
/**
|
||
|
* 选择器
|
||
|
*/
|
||
|
export class AxSelection {
|
||
|
constructor() {
|
||
|
}
|
||
|
private objects: Set<any> = new Set<any>();
|
||
|
// 获得第一个对象
|
||
|
public first(): any {
|
||
|
if (this.objects.size > 0) {
|
||
|
return this.objects[0];
|
||
|
} else {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
// 获得所有对象
|
||
|
public all() {
|
||
|
return this.objects;
|
||
|
}
|
||
|
// 获取集合长度
|
||
|
public size(): number {
|
||
|
return this.objects.size;
|
||
|
}
|
||
|
// 添加对象
|
||
|
public add(obj: any) {
|
||
|
this.objects.add(obj);
|
||
|
}
|
||
|
// 添加集合
|
||
|
public addArray(array: any[]) {
|
||
|
array.forEach(item => {
|
||
|
this.objects.add(item);
|
||
|
});
|
||
|
}
|
||
|
// 移除对象
|
||
|
public delete(obj: any) {
|
||
|
this.objects.delete(obj);
|
||
|
}
|
||
|
// 移除集合
|
||
|
public deleteArray(array: any[]) {
|
||
|
array.forEach(item => {
|
||
|
this.objects.delete(item);
|
||
|
});
|
||
|
}
|
||
|
// 清空所有对象
|
||
|
public clear() {
|
||
|
this.objects.clear();
|
||
|
}
|
||
|
}
|