I have an ember function that is continuing the sequence of 2^x where X is the length of the array.
//sequence of ^2: 1, 2, 4, 8, 16, etc...
this.set("numSeq", Ember.Array([1, 2, 4]));
when i push a button I update the sequence using the update
function
update: function(){
var numSeq = this.get("numSeq");
let Sqlength = numSeq.length;
let node = Math.pow(2,Sqlength);
const nodeMax = Math.pow(2,20);
if(node >= nodeMax){
this.initializeSequence();
}
else if(Sqlength >= 10){
sequence.pushObject(node);
let smallFry = sequence[0];
sequence.removeObject(smallFry);
}
else{
sequence.pushObject(node);
}
there are two restrictions to the update function, when a new array input exceeds 2^20 we reset the array, and when the length is greater than 10 we remove the smallest element and still add the new node.
My issue comes when trying to push new objects to array and remove the bottom most element, any method I have used to far slice
,removeat
,removeobject
, it "freezes" the array and just adds the last element not the new node
(example after pressing the button 12 times [1,2,4,...,512,1024,1024,1024]
no errors so i believe this my fault and a misunderstanding of concepts
Aucun commentaire:
Enregistrer un commentaire