function Buhin(number){\r
// method\r
- function push(name, data){ // void\r
- var temp = new Object();\r
- temp.name = name;\r
- temp.data = data;\r
- this.array.push(temp);\r
- }\r
- Buhin.prototype.push = push;\r
- \r
function set(name, data){ // void\r
- var temp = new Object();\r
- temp.name = name;\r
- temp.data = data;\r
- for(var i = 0; i < this.array.length; i++){\r
- if(this.array[i].name == name){\r
- this.array.splice(i, 1);\r
- }\r
- }\r
- this.array.push(temp);\r
+ this.hash[name] = data;\r
}\r
+ Buhin.prototype.push = set;\r
Buhin.prototype.set = set;\r
\r
function search(name){ // string\r
- for(var i = 0; i < this.array.length; i++){\r
- if(this.array[i].name == name){\r
- return this.array[i].data;\r
- }\r
+ if(this.hash[name]){\r
+ return this.hash[name];\r
}\r
return ""; // no data\r
}\r
Buhin.prototype.search = search;\r
\r
// property\r
- this.array = new Array();\r
+ this.hash = {};\r
\r
// initialize\r
// no operation\r