MCPcopy Create free account
hub / github.com/corbanbrook/dsp.js / Iterator

Function Iterator

examples/js/processing.js:3686–3719  ·  view source on GitHub ↗
(conversion, removeItem)

Source from the content-addressed store, hash-verified

3684 }
3685
3686 function Iterator(conversion, removeItem) {
3687 var bucketIndex = 0;
3688 var itemIndex = -1;
3689 var endOfBuckets = false;
3690
3691 function findNext() {
3692 while (!endOfBuckets) {
3693 ++itemIndex;
3694 if (bucketIndex >= buckets.length) {
3695 endOfBuckets = true;
3696 } else if (buckets[bucketIndex] === undef || itemIndex >= buckets[bucketIndex].length) {
3697 itemIndex = -1;
3698 ++bucketIndex;
3699 } else {
3700 return;
3701 }
3702 }
3703 }
3704
3705 this.hasNext = function() {
3706 return !endOfBuckets;
3707 };
3708 this.next = function() {
3709 var result = conversion(buckets[bucketIndex][itemIndex]);
3710 findNext();
3711 return result;
3712 };
3713 this.remove = function() {
3714 removeItem(this.next());
3715 --itemIndex;
3716 };
3717
3718 findNext();
3719 }
3720
3721 function Set(conversion, isIn, removeItem) {
3722 this.clear = function() {

Callers

nothing calls this directly

Calls 1

findNextFunction · 0.85

Tested by

no test coverage detected