montagejs / collections

This package contains JavaScript implementations of common data structures with idiomatic interfaces.
http://www.collectionsjs.com
Other
2.1k stars 183 forks source link

SortedArraySet#length not updating #64

Closed cbarrick closed 10 years ago

cbarrick commented 10 years ago

SortedArraySet#length doesn't update when you .pop() and .shift()

Here's an example from the Node REPL:

> var SortedArraySet = require('collections/sorted-array-set')
undefined
> var a = new SortedArraySet()
undefined
> a.add('foo')
true
> a.add('bar')
true
> a.length
2
> a.pop()
'foo'
> a.shift()
'bar'
> a.length
2
> a.length === a.array.length
false
> a
{ array: [],
  contentEquals: [Function],
  contentCompare: [Function],
  getDefault: [Function],
  length: 2 }
>