341.flatten-nested-list-iterator.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * // This is the interface that allows for creating nested lists.
  3. * // You should not implement it, or speculate about its implementation
  4. * function NestedInteger() {
  5. *
  6. * Return true if this NestedInteger holds a single integer, rather than a nested list.
  7. * @return {boolean}
  8. * this.isInteger = function() {
  9. * ...
  10. * };
  11. *
  12. * Return the single integer that this NestedInteger holds, if it holds a single integer
  13. * Return null if this NestedInteger holds a nested list
  14. * @return {integer}
  15. * this.getInteger = function() {
  16. * ...
  17. * };
  18. *
  19. * Return the nested list that this NestedInteger holds, if it holds a nested list
  20. * Return null if this NestedInteger holds a single integer
  21. * @return {NestedInteger[]}
  22. * this.getList = function() {
  23. * ...
  24. * };
  25. * };
  26. */
  27. /**
  28. * @constructor
  29. * @param {NestedInteger[]} nestedList
  30. */
  31. var NestedIterator = function(nestedList) {
  32. };
  33. /**
  34. * @this NestedIterator
  35. * @returns {boolean}
  36. */
  37. NestedIterator.prototype.hasNext = function() {
  38. };
  39. /**
  40. * @this NestedIterator
  41. * @returns {integer}
  42. */
  43. NestedIterator.prototype.next = function() {
  44. };
  45. /**
  46. * Your NestedIterator will be called like this:
  47. * var i = new NestedIterator(nestedList), a = [];
  48. * while (i.hasNext()) a.push(i.next());
  49. */