Add ol.structs.LinkedMap.prototype.peekLastKey

This commit is contained in:
Tom Payne
2013-01-23 17:43:41 +01:00
parent c7d0712480
commit 3f6ef77a5a

View File

@@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// FIXME replace this with goog.structs.LinkedMap when goog.structs.LinkedMap
// adds peekLastKey()
/**
* @fileoverview A LinkedMap data structure that is accessed using key/value
* pairs like an ordinary Map, but which guarantees a consistent iteration
@@ -164,6 +167,16 @@ ol.structs.LinkedMap.prototype.peekLast = function() {
};
/**
* Returns the key of the last node without making any modifications.
* @return {string|undefined} The key of the last node or undefined if the map
* is empty.
*/
ol.structs.LinkedMap.prototype.peekLastKey = function() {
return this.head_.prev.key;
};
/**
* Removes the first node from the list and returns its value.
* @return {*} The value of the popped node, or undefined if the map was empty.