Change CreateHashTable function.
This commit is contained in:
1 parent
dbbfee500a
commit
297d3f6490
1 file changed
+14
-1
+14
-1
@@ -65,7 +65,7 @@ function min(x, y){
|
||||
return y;
|
||||
}
|
||||
|
||||
function CreateHashTable(mkeys, mvalues){
|
||||
function CreateHashTable2(mkeys, mvalues){
|
||||
var k = min(mkeys.length, mvalues.length);
|
||||
var hash = new Object();
|
||||
for(var i=0;i<k;i++){
|
||||
@@ -74,6 +74,19 @@ function CreateHashTable(mkeys, mvalues){
|
||||
return hash;
|
||||
}
|
||||
|
||||
function CreateHashTable3(arr){
|
||||
var hash = new Object();
|
||||
for(var i=0;i<arr.length;i++){
|
||||
hash[arr[i][0]] = arr[i][1];
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
function CreateHashTable(a, b){
|
||||
return (typeof(b) =="undefined") ? CreateHashTable3(a)
|
||||
: CreateHashTable2(a,b);
|
||||
}
|
||||
|
||||
function ord(str){
|
||||
return str.charCodeAt(0);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user