
JavaScript.src.antlr4.Utils.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of antlr4-runtime-testsuite Show documentation
Show all versions of antlr4-runtime-testsuite Show documentation
A collection of tests for ANTLR 4 Runtime libraries.
function arrayToString(a) {
return "[" + a.join(", ") + "]";
}
String.prototype.hashCode = function(s) {
var hash = 0;
if (this.length === 0) {
return hash;
}
for (var i = 0; i < this.length; i++) {
var character = this.charCodeAt(i);
hash = ((hash << 5) - hash) + character;
hash = hash & hash; // Convert to 32bit integer
}
return hash;
};
function standardEqualsFunction(a,b) {
return a.equals(b);
}
function standardHashFunction(a) {
return a.hashString();
}
function Set(hashFunction, equalsFunction) {
this.data = {};
this.hashFunction = hashFunction || standardHashFunction;
this.equalsFunction = equalsFunction || standardEqualsFunction;
return this;
}
Object.defineProperty(Set.prototype, "length", {
get : function() {
return this.values().length;
}
});
Set.prototype.add = function(value) {
var hash = this.hashFunction(value);
var key = "hash_" + hash.hashCode();
if(key in this.data) {
var i;
var values = this.data[key];
for(i=0;i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy