继续咱们的绿坝行动,嘿嘿
来源:互联网 发布:淘宝营销推广策略 编辑:程序博客网 时间:2024/04/26 07:01
function List() {
this.list = new Array();
}
List.prototype.add = function(e) {
this.list.push(e);
return true;
};
List.prototype.clear = function() {
this.list = new Array();
};
List.prototype.contains = function(e) {
return this.indexOf(e) >= 0;
};
List.prototype.isEmpty = function() {
return this.size() == 0;
};
List.prototype.size = function() {
return this.list.length;
};
List.prototype.toArray = function() {
return this.list;
};
List.prototype.remove = function(index) {
assert(index >=0 && index < this.size(), "param is error!");
var tmp = this.get(index);
this.list.splice(index, 1);
return tmp;
};
List.prototype.compareTo = function(obj) {
assert(obj != null && obj instanceof Collection, "param type is error!");
var index = 0, tmp = null;
while(index < this.size() && index < obj.size()) {
tmp = this.get(index) > obj.get(index) ? 1 : this.get(index) < obj.get(index) ? -1 : 0;
if(tmp != 0) {
return tmp;
}
index++;
}
return tmp >= this.size() && tmp >= obj.size() ? 0 : tmp >= this.size() ? -1 : 1;
};
List.prototype.equals = function(obj) {
return this.compareTo(obj) == 0;
};
List.prototype.insert = function(index, e) {
assert(index >= 0 && index < this.size(), "param is error!");
this.list.splice(index, 0, e);
};
List.prototype.get = function(index) {
assert(index >= 0 && index < this.size(), "param is error!");
return this.list[index];
};
List.prototype.indexOf = function(e, fromIndex) {
return this.list.indexOf(e, fromIndex);
};
List.prototype.lastIndexOf = function(e, fromIndex) {
return this.list.lastIndexOf(e, fromIndex)
};
List.prototype.set = function(index, e) {
assert(index >= 0 && index < this.size(), "param is error!");
this.list[index] = e;
};
List.prototype.iterator = function() {
return new Iterator(this);
};
List.prototype.listIterator = function() {
return new ListIterator(this);
};
function Iterator(list) {
assert(list instanceof List, "param type is error!");
this.list = list;
this.curIdx = -1;
}
Iterator.prototype.hasNext = function() {
return this.curIdx + 1 < this.list.size();
};
Iterator.prototype.next = function() {
return this.list.get(++this.curIdx);
};
Iterator.prototype.remove = function() {
this.list.remove(this.curIdx--);
};
function ListIterator(list) {
Iterator.call(this, list);
}
ListIterator.prototype = new Iterator();
ListIterator.prototype.add = function(e) {
this.list.insert(this.curIdx + 1, e);
};
ListIterator.prototype.hasPrevious = function() {
return this.curIdx - 1 >= 0;
};
ListIterator.prototype.nextIndex = function() {
return this.curIdx + 1;
};
ListIterator.prototype.previous = function() {
return this.list.get(--this.curIdx);
};
ListIterator.prototype.previousIndex = function() {
return this.curIdx - 1;
};
ListIterator.prototype.set = function(e) {
this.list.set(this.curIdx, e);
};
function Set() {
List.call(this);
}
Set.prototype = new List();
Set.prototype.add = function(e) {
if(this.contains(e)) {
return false;
}
return this.add(e);
};
function Queue() {
this.list = new List();
}
Queue.prototype.add = function(e) {
return this.list.add(e);
};
Queue.prototype.remove = function() {
return this.list.shift();
};
Queue.prototype.element = function() {
return this.list.get[0];
};
Queue.prototype.isEmpty = function() {
return this.list.isEmpty();
};
Queue.prototype.clear = function() {
this.list.clear();
};
function Stack() {
this.list = new List();
}
Stack.prototype.push = function(e) {
return this.list.add(e);
};
Stack.prototype.pop = function() {
return this.list.pop();
};
Stack.prototype.peek = function() {
return this.list.get(this.list.size() - 1);
};
Stack.prototype.isEmpty = function() {
return this.list.isEmpty();
};
Stack.prototype.clear = function() {
this.list.clear();
};
function Entry(key, value) {
this.key = key;
this.value = value;
}
function Map() {
this.list = new Set();
}
Map.prototype.clear = function() {
this.list.clear();
};
Map.prototype.containsKey = function(key) {
var tmp = this.keySet();
return tmp.indexOf(key) >= 0;
};
Map.prototype.containsValue = function(value) {
var tmp = this.values();
return tmp.indexOf(value) >= 0;
};
Map.prototype.entrySet = function() {
return this.list;
};
Map.prototype.equals = function(map) {
assert(map instanceof Map, "param type is error!");
return this.list.equals(map.list);
};
Map.prototype.get = function(key) {
var tmp = this.keySet();
var index = tmp.indexOf(key);
return this.list.get(index);
};
Map.prototype.isEmpty = function() {
return this.list.isEmpty();
};
Map.prototype.keySet = function() {
var ite = this.entrySet().iterator();
var tmp = new Set();
while(ite.hasNext()) {
tmp.add(ite.next().key);
}
return tmp;
};
Map.prototype.put = function(key, value) {
var tmp = this.keySet();
if(tmp.indexOf(key) >= 0) {
return false;
}
return this.list.add(new Entry(key, value));
};
Map.prototype.remvoe = function(key) {
var index = this.list.indexOf(key);
return index < 0 ? null : this.list.remove(index);
};
Map.prototype.size = function() {
return this.list.size();
};
Map.prototype.values = function() {
var ite = this.entrySet().iterator();
var tmp = new List();
while(ite.hasNext()) {
tmp.add(ite.next().value);
}
return tmp;
};
- 继续咱们的绿坝行动,嘿嘿
- 绿坝的两个看法
- 深圳“红绿丝带”公益行动
- 咱们也真够疯狂的。。
- 曾经的咱们.
- “咱们吃鸡吧”的背后
- 征集咱们BLOG的副标题!
- 咱们的第六口铁锅
- 咱们的我的文档和收藏夹
- 绿坝,监控了哪些应用程序?装了绿坝的朋友,使用要小心啊!
- 贴个俺的成果,嘿嘿
- 新来的~~嘿嘿~
- 摘来的 嘿嘿
- 转载的嘿嘿!
- 来波大的 嘿嘿
- 嘿嘿
- 嘿嘿
- 嘿嘿
- 来讨论我眼中的hao123导航
- 华夏黑客联盟教程
- CSDN测试题笔记
- SA
- 用JS模拟的几个常用Java类实现,咱也学绿坝找免费测试哈
- 继续咱们的绿坝行动,嘿嘿
- 请尊重梦想
- 第三课 排列与组合
- 就算风景一如从前
- JAVA综合面试题:页面的抓取、解析、保存数据库和生成HTML的
- 在校生如何开始学习数据库(二) oracle数据库的安装
- 基于ARM9开发板的按键字符设备驱动实现(全集)
- DOS命令大全
- 关于Hibernate中inverse=true的转载