日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

java 实现set_js 实现JAVASET

發布時間:2025/3/21 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 实现set_js 实现JAVASET 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

/**

* Created with IntelliJ IDEA.

* User: chicheng

* Date: 14-11-7

* Time: 下午9:24

* To change this template use File | Settings | File Templates.

*/

function Set() {

this.elements = new Array();

//獲取Set元素個數

this.size = function() {

return this.elements.length;

}

//判斷Set是否為空

this.isEmpty = function() {

return (this.elements.length < 1);

}

//清除Set

this.clear = function() {

this.elements = new Array();

}

//增加一個元素,不重復

this.add = function(value) {

//alert(this.containsKey(_key));

if(this.containsValue(value)){

this.remove(value);

}

this.elements.push(value);

}

//移除一個值

this.remove = function(value) {

var bln = false;

try {

for (i = 0; i < this.elements.length; i++) {

if (this.elements[i] == value) {

this.elements.splice(i, 1);

return true;

}

}

} catch (e) {

bln = false;

}

return bln;

}

//移除一個值,索引

this.kill=function (index){

this.remove(this.get(index));

}

//得到一個值,索引

this.get = function(_index) {

if (_index < 0 || _index >= this.elements.length) {

return null;

}

return this.elements[_index];

}

//查看是否包含一個值 ??? this.containsValue = function(value) { ??????? var bln = false; ??????? try { ??????????? for (i = 0; i < this.elements.length; i++) { ??????????????? if (this.elements[i] == value) { ??????????????????? bln = true; ??????????????? } ??????????? } ??????? } catch (e) { ??????????? bln = false; ??????? } ??????? return bln; ??? } }

總結

以上是生活随笔為你收集整理的java 实现set_js 实现JAVASET的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。