This functionality was lacking when I was implementing order book service (https://docs.kraken.com/websockets/#message-book) through SortedMap. When the maximum stored length is reached and a new level comes we want to pop the last element.
This could of course be implemented through map.delete(map.entries()[0][0]) but a call to entries would run a loop over each item in the map which is ineffective.
Currently I've implemented pop through map.store.pop(); map.length = map.store.length which uses the internals but does the job. Maybe there already is a cleaner way?
This functionality was lacking when I was implementing order book service (https://docs.kraken.com/websockets/#message-book) through SortedMap. When the maximum stored length is reached and a new level comes we want to
pop
the last element.This could of course be implemented through
map.delete(map.entries()[0][0])
but a call toentries
would run a loop over each item in the map which is ineffective.Currently I've implemented
pop
throughmap.store.pop(); map.length = map.store.length
which uses the internals but does the job. Maybe there already is a cleaner way?