复制代码代码如下:
var map = function () {
this._entrys = new Array ();
this.put = function (คีย์, ค่า) {
if (key == null || key == undefined) {
กลับ;
-
var index = this._getIndex (คีย์);
if (index == -1) {
VAR entry = new Object ();
entry.key = key;
entry.value = ค่า;
this._entrys [this._entrys.length] = รายการ;
}อื่น{
this._entrys [ดัชนี] .Value = ค่า;
-
-
this.get = function (key) {
var index = this._getIndex (คีย์);
return (index! = -1)? this._entrys [ดัชนี] .Value: NULL;
-
this.remove = function (key) {
var index = this._getIndex (คีย์);
ถ้า (ดัชนี! = -1) {
this._entrys.splice (ดัชนี, 1);
-
-
this.clear = function () {
this._entrys.length = 0 ;;
-
this.contains = function (key) {
var index = this._getIndex (คีย์);
return (index! = -1)? จริง: เท็จ;
-
this.getCount = function () {
ส่งคืนสิ่งนี้ _entrys.length;
-
this.getEntrys = function () {
ส่งคืนสิ่งนี้ _Entrys;
-
this._getIndex = ฟังก์ชั่น (คีย์) {
if (key == null || key == undefined) {
กลับ -1;
-
var _length = this._entrys.length;
สำหรับ (var i = 0; i <_length; i ++) {
var entry = this._entrys [i];
if (entry == null || entry == undefined) {
ดำเนินการต่อ;
-
if (entry.key === คีย์) {// เท่ากัน
กลับฉัน;
-
-
กลับ -1;
-
this._ToString = function () {
var string = "";
สำหรับ (var i = 0; i <this.getEntrys (). length; i ++) {
String+= this.getEntrys () [i] .key+"::"+this.getEntrys () [i] .Value;
ถ้า (i! = this.getEntrys (). length-1) {
สตริง += ";";
-
-
สตริงกลับ;
-
-