logoots-structs
Version:
Provides several data structures to represent a text using a ropes-like structure and manipulating it
57 lines (44 loc) • 1.44 kB
JavaScript
/**
*
*/
var IdentifierInterval = function(base, begin, end) {
this.base = base || [];
this.begin = begin || 0;
this.end = end || 0;
};
IdentifierInterval.prototype.copy = function() {
return new IdentifierInterval(Utils.copy(this.base), this.begin, this.end);
};
IdentifierInterval.prototype.getBaseId = function (u) {
return new Identifier(this.base, u);
};
IdentifierInterval.prototype.addBegin = function (begin) {
this.begin += begin;
};
IdentifierInterval.prototype.addEnd = function (end) {
this.end += end;
};
IdentifierInterval.prototype.getBeginId = function () {
return new Identifier(this.base, this.begin);
};
IdentifierInterval.prototype.getEndId = function () {
return new Identifier(this.base, this.end);
};
IdentifierInterval.prototype.equals = function (o) {
if(this==o) return true;
if(typeof(o) != typeof(this)) return false;
if(o.begin!=this.begin) return false;
if(o.end!=this.end) return false;
if (this.base != null ? !this.base.equals(o.base) : o.base != null) return false;
return true;
};
IdentifierInterval.prototype.hashCode = function () {
var result = this.base != null ? base.hashCode() : 0;
result = 31 * result + this.begin;
result = 31 * result + this.end;
return result;
};
IdentifierInterval.prototype.toString = function () {
return 'IdentifierInterval{[' + this.base + '],[' + this.begin + '..' + this.end + ']}';
}
module.exports = IdentifierInterval;