1

So I finally found a nice functional data structure, Scalaz DList, for constant prepend/append and a good complexity for concatenating two collections, however why doesn't DListhave a size or length member method, and how do I calculate its size?

An isEmpty function would do as well.

Thanks

Johan S
  • 3,531
  • 6
  • 35
  • 63
  • It's probably because under the hood, `DLists` are functions that only construct a list at the end, rather than building one up as elements are appended – Squidly Jan 13 '15 at 10:07
  • See http://stackoverflow.com/q/3352418/215924 for some more about difflists – Squidly Jan 13 '15 at 10:08
  • @MrBones, yeah I read that thread and I understand that if it would be easy to do, they would have a method for it. However, do you know of any way to calculate the size or if the `DList` is empty in constant time and if so, could you post it as an answer? – Johan S Jan 13 '15 at 10:12

0 Answers0