Last active
August 29, 2015 14:01
-
-
Save icholy/d73c9e8ea349492e8f26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var FlatCoordinates = function () { | |
var FlatCoordinates = function FlatCoordinates (coordinates) { | |
this._coordinates = coordinates; | |
}; | |
FlatCoordinates.prototype.shift = function () { | |
var c = this._coordinates; | |
c.shift(); | |
c.shift(); | |
}; | |
FlatCoordinates.prototype.pop = function () { | |
var c = this._coordinates; | |
c.pop(); | |
c.pop(); | |
}; | |
FlatCoordinates.prototype.push = function (coordinate) { | |
var c = this._coordinates; | |
c.push(coordinate[0]); | |
c.push(coordinate[1]); | |
}; | |
FlatCoordinates.prototype.get = function (index) { | |
return this._coordinates.slice(index*2, (index*2)+2); | |
}; | |
FlatCoordinates.prototype.set = function (index, coordinate) { | |
this._coordinates.splice(index, index+2, coordinate[0], coordinate[1]); | |
}; | |
FlatCoordinates.prototype.unshift = function (coordinate) { | |
var c = this._coordinates; | |
c.unshift(coordinate[0]); | |
c.unshift(coordinate[1]); | |
}; | |
FlatCoordinates.prototype.length = function () { | |
return this._coordinates.length / 2; | |
}; | |
return FlatCoordinates; | |
}.call(null); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment