From 3f6ef77a5a72157bb9d5cde5deb2431e7cb5589c Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 23 Jan 2013 17:43:41 +0100 Subject: [PATCH] Add ol.structs.LinkedMap.prototype.peekLastKey --- src/ol/structs/linkedmap.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ol/structs/linkedmap.js b/src/ol/structs/linkedmap.js index 3a9810d8a0..63971748c5 100644 --- a/src/ol/structs/linkedmap.js +++ b/src/ol/structs/linkedmap.js @@ -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.