From e700dd01a63d2e2218ffaa456d90f27a29262f7a Mon Sep 17 00:00:00 2001 From: Karl Lundfall Date: Fri, 21 Apr 2017 12:32:58 +0200 Subject: [PATCH] Added a function to convert the list sequence to an array --- src/LinkedListViewSequence.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/LinkedListViewSequence.js b/src/LinkedListViewSequence.js index 7d8b376..1ef4301 100644 --- a/src/LinkedListViewSequence.js +++ b/src/LinkedListViewSequence.js @@ -165,6 +165,18 @@ define(function(require, exports, module) { return -1; }; + LinkedListViewSequence.prototype.toArray = function() { + var sequence = this._.head; + var index = 0; + var arrayConversion = new Array(this.getLength()); + while (sequence) { + arrayConversion[index] = sequence._value; + index++; + sequence = sequence._next; + } + return arrayConversion; + }; + /** * Finds the view-sequence item at the given index. *