Operand expected in operator without parameters

 

I have this class which stores items and their display rank . The display array is the visibility one while the items array is obviously the names array.

I want to give the user the ability to quickly rank the items they want to be visible .

Why am i not removing the invisible items and why will the user want the invisible items ? 

This is for a table display of statistics from the tester alongside the inputs of an optimization pass so deleting the inputs wont happen (in order to be able to create set files) and the order must be the same (although i suspect set files work via search nowadays)

What on earth do i "need" :

I have set operator << to take the following item ,increase the rank and assign that rank in the visibility array.

But i also need a reset rank operator to restart the rank counter from the top .

The operators work okay but if i do not provide a number between the operators >> and << then i get operand expected.

This is a superficial querry because it can work fine if i have a reset function or with the 0 in between or if i don't have a reset at all as the user will only set the rank once via code probably.

I'm just curious if its possible . 

Thanks 

#property version   "1.00"

class list{
string items[];//we have the items here , this order does not change
int    visibility[];//and here we have the display index and -1 if its not displayed
int    rank;
       public:
       list(void){reset();}
      ~list(void){reset();}
  void reset(){
       ArrayFree(items);
       ArrayFree(visibility);
       rank=-1;
       }
   int add_item(string _name){
       int ns=ArraySize(items)+1;
       ArrayResize(items,ns,0);
       ArrayResize(visibility,ns,0);
       items[ns-1]=_name;
       visibility[ns-1]=ns-1;
       return(ns-1);
       }
   int find(string _name){
       for(int i=0;i<ArraySize(items);i++){
       if(items[i]==_name){return(i);}
       }
       return(-1);
       }
string print_ranked(string separator){
       int sorter[][2];
       ArrayResize(sorter,ArraySize(items),0);
       for(int i=0;i<ArraySize(items);i++){
          sorter[i][0]=visibility[i];
          if(visibility[i]==-1){sorter[i][0]=ArraySize(items);}
          sorter[i][1]=i;
          }
       ArraySort(sorter);
       string result="";
       for(int i=0;i<ArraySize(items);i++){
       int ix=sorter[i][1];
       if(visibility[ix]!=-1){
       result+=items[ix]+separator;
       }}
       return(result);
       }
list* reset_rank(){
      rank=-1;
      for(int i=0;i<ArraySize(items);i++){visibility[i]=-1;}
      return(GetPointer(this));      
      }
      //reorder operator
list* operator<<(string _name){
      int ix=find(_name);
      if(ix!=-1){
      rank++;
      visibility[ix]=rank;      
      }
      return(GetPointer(this));
      }
list* operator<<(int ix){
      rank++;
      visibility[ix]=rank;      
      return(GetPointer(this));
      }      
list* operator>>(int f=0){
      rank=-1;
      for(int i=0;i<ArraySize(items);i++){visibility[i]=-1;}
      return(GetPointer(this));
      }
};

int OnInit()
  {
//---
  list MyList;
  MyList.add_item("Oranges");
  MyList.add_item("Bananas");
  MyList.add_item("Apples");
  MyList.add_item("Pineapples");
  MyList.add_item("Grapes");
  Alert(MyList.print_ranked("\n"));
  //rearrange 
  //MyList>>0<<"Grapes"<<"Apples"<<"Oranges";
  MyList>><<"Grapes"<<"Apples"<<"Oranges";
  MyList<<"Bananas";
  Alert(MyList.print_ranked("\n"));
  
  delete(GetPointer(MyList)); 
//---
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
//---
   
  }

void OnTick()
  {
//---
   
  }