Comments (2)
A possible workaround can be -
if (properties.replaceDuplicateKey) {
bucketEntry[0] = key;
oldValue = bucketEntry[1];
bucketEntry[1] = value+", "+oldValue;
}
else{
bucketEntry[1] = value;
}
But this is not a good way to do so. I think if there exist duplicate values
then it will return an array other than the plain object.
Original comment by [email protected]
on 13 Feb 2015 at 6:04
from jshashtable.
This is the expected behaviour. If you put a new value for an existing key, the
value should always be replaced, which is how all hash table implementations
that I've used work. The replaceDuplicateKey determines what happens to the key
that is stored in that situation. The following example illustrates this:
var key1 = { foo: 1, name: "key1" }, key2 = { foo: 1, name: "key2" };
function keysEquals(k1, k2) {
return k1.foo == k2.foo;
}
var hash1 = new Hashtable( { equals: keysEquals, replaceDuplicateKey: true } );
hash1.put(key1, 1);
hash1.put(key2, 2);
console.log(hash1.keys()[0].name); // key2
var hash2 = new Hashtable( { equals: keysEquals, replaceDuplicateKey: false } );
hash2.put(key1, 1);
hash2.put(key2, 2);
console.log(hash2.keys()[0].name); // key1
Original comment by [email protected]
on 18 Feb 2015 at 11:26
- Changed state: Invalid
from jshashtable.
Related Issues (12)
- Using an ActiveX object (such as XMLHttpRequest in IE 6) as a key gives an error HOT 1
- Can't use request object after storing It in jshashtable HOT 4
- package manager
- How can we create a deep copy of Hashtable object ?
- API function toQueryString HOT 4
- Suggestion: HashSet.add should always update/set key value, regardless of equality HOT 12
- Extern File for Closure Compiler HOT 1
- (bug report + fix) jshashset entries are not replaced when using equalityFunction HOT 6
- Hashtable does not accept array objects containing XML document types as keys HOT 2
- Complemented HOT 2
- Hashtable key array of one date HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jshashtable.