samedi 23 mai 2020

Problem pushing a value into a list being called by a getter function

I'm trying to push a value to a list. My list is inside a class that contains many lists, the class contains a function getList(int) that takes an integer and returns the list that it represents. e.g getList(6) will return list G. The class that cointains all lists is called "z". However, when I try to push a value using that: z.getList(6).push(value); it will not push it into G. How can I write a line that pushes a value into a list that it is being called with a getter function? Code that I have:

class Fila {
public:
    LList a,b,c,d,e,f,g,h,i,j;
//public:
    LList q;
    LList getList(int n);
};

LList Fila::getList(int n) {
    if(n==0){return a;}
    else if(n==1){return b;}
    else if(n==2){return c;}
    else if(n==3){return d;}
    else if(n==4){return e;}
    else if(n==5){return f;}
    else if(n==6){return g;}
    else if(n==7){return h;}
    else if(n==8){return i;}
    else {return j;}
}

void radixsort(Node *front, Node *back) {
    Fila z;
    Node *t=front;
    while(t){
        z.q.push(t->data);
        t=t->next;
    }
    for(int k=0;k<log(99)+1;k++){
        while(!z.q.empty()){ //anade a los bucket
            if(k==0){
                for(int l=0;l<10;l++){
                    if((z.q.front())%10==l){
                        z.getList(l).push(z.q.front()); //THIS LINE 
                        break;
                    }
...

Aucun commentaire:

Enregistrer un commentaire